Skip to content

RZ1000 triggered when Utf8 strings literals are used #12132

@gfoidl

Description

@gfoidl

Description

Using Utf8 string literals in a razor page trigger

RZ1000
Unterminated string literal.  Strings that start with a quotation mark (") must be terminated before the end of the line.  However, strings that start with @ and a quotation mark (@") can span multiple lines.

PR that introduced this (?): #11086

Repro

Create a ASP.NET Core Web App (Razor Pages) project and add the following code to Index.cshtml:

@page
@using System.Text
@model IndexModel

<div class="text-center">
    @{
        ReadOnlySpan<byte> span = "hello"u8;    // <- here's the error location
    }

    <p>@Encoding.UTF8.GetString(span)</p>
</div>

(yeah I know it's nonsense, but stripped down from a real project were Utf8 literals makes sense).

Expected behavior

Utf8 string literals are supported and don't trigger RZ1000.

Workaround

Update csproj with

<PropertyGroup>
    <NoWarn>$(NoWarn);RZ1000</NoWarn>
</PropertyGroup>

Metadata

Metadata

Labels

area-compilerUmbrella for all compiler issues

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions