Skip to content

Roslyn crashes when reporting an error with an "unusual" compilation unit name #11168

@jskeet

Description

@jskeet

Version Used: .NET 9.0.100

Steps to Reproduce:

  1. Create a new console application (dotnet new console)
  2. Edit Program.cs to:
#line 100 ":invalid:"
int x = 5.0;
  1. Run dotnet build

Expected Behavior:

Normal error messages without a crash.

Actual Behavior:

C:\Program Files\dotnet\sdk\9.0.100\Roslyn\Microsoft.CSharp.Core.targets(89,5): error MSB6006: "csc.dll" exited with code 1.

Notes:

  • Visual Studio indicates csc.dll exiting with code 1 as well
  • This is not reproducible in SharpLab - I suspect it's injecting its own #line directives
  • Changing ":invalid:" to "valid" produces normal error messages.
  • Names of ".", ".." and "..." produce some interesting results
  • Changing the code to only produce a warning (e.g. just int x = 5; which results in CS0219) when using ":invalid:" is weird - the build succeeds without issuing a warning at all

Metadata

Metadata

Assignees

No one assigned

    Labels

    gathering-feedbackThe issue requires feedback in order to be planned, please comment if the feature is useful for youtriaged

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions