Skip to content

Roslyn hits "unreachable" exception when processing type forward to a class containing an extension group #79894

@tannergooding

Description

@tannergooding

Version Used: 5.0.0-2.25412.102

Steps to Reproduce:

  1. Create a new class library, ClassLibrary1, containing the following contents:
public static class Extensions
{
    extension(int)
    {
    }
}
  1. Create another new class library, ClassLibrary2, which references the first and which contains the following contents:
[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(Extensions))]

-- Note: The original repro had a proper extension group containing members, this is a minified repro.

Expected Behavior:

The compilation should succeed.

Actual Behavior:

The compilation of ClassLibrary2 fails with the following:

  ClassLibrary1 succeeded (1.4s) → ClassLibrary1\bin\Release\net10.0\ClassLibrary1.dll
  ClassLibrary2 failed with 21 error(s) (3.2s)
    D:\Users\tagoo\.nuget\packages\microsoft.net.compilers.toolset\5.0.0-2.25412.102\tasks\netcore\Microsoft.CSharp.Core.targets(84,5): error : Unhandled exception. System.InvalidOperationException: This program location is thought to be unreachable. File='/_/src/roslyn/src/Compilers/CSharp/Portable/Emitter/Model/NamedTypeSymbolAdapter.cs' Line=800
    D:\Users\tagoo\.nuget\packages\microsoft.net.compilers.toolset\5.0.0-2.25412.102\tasks\netcore\Microsoft.CSharp.Core.targets(84,5): error :    at Microsoft.CodeAnalysis.CSharp.Symbols.NamedTypeSymbol.Microsoft.Cci.INamedEntity.get_Name()
    D:\Users\tagoo\.nuget\packages\microsoft.net.compilers.toolset\5.0.0-2.25412.102\tasks\netcore\Microsoft.CSharp.Core.targets(84,5): error :    at Microsoft.Cci.MetadataWriter.GetMetadataName(INamedTypeReference namedType, Int32 generation)
    D:\Users\tagoo\.nuget\packages\microsoft.net.compilers.toolset\5.0.0-2.25412.102\tasks\netcore\Microsoft.CSharp.Core.targets(84,5): error :    at Microsoft.Cci.MetadataWriter.PopulateExportedTypeTableRows()
    D:\Users\tagoo\.nuget\packages\microsoft.net.compilers.toolset\5.0.0-2.25412.102\tasks\netcore\Microsoft.CSharp.Core.targets(84,5): error :    at Microsoft.Cci.MetadataWriter.PopulateTypeSystemTables(Int32[] methodBodyOffsets, Int32 mappedFieldDataStartOffset, PooledBlobBuilder& mappedFieldDataWriter, PooledBlobBuilder& resourceWriter, BlobBuilder dynamicAnalysisData, Blob& mvidFixup)
    D:\Users\tagoo\.nuget\packages\microsoft.net.compilers.toolset\5.0.0-2.25412.102\tasks\netcore\Microsoft.CSharp.Core.targets(84,5): error :    at Microsoft.Cci.MetadataWriter.BuildMetadataAndIL(PdbWriter nativePdbWriterOpt, BlobBuilder ilBuilder, PooledBlobBuilder& mappedFieldDataBuilder, PooledBlobBuilder& managedResourceDataBuilder, Blob& mvidFixup, Blob& mvidStringFixup)
    D:\Users\tagoo\.nuget\packages\microsoft.net.compilers.toolset\5.0.0-2.25412.102\tasks\netcore\Microsoft.CSharp.Core.targets(84,5): error :    at Microsoft.Cci.PeWriter.WritePeToStream(EmitContext context, CommonMessageProvider messageProvider, Func`1 getPeStream, Func`1 getPortablePdbStreamOpt, PdbWriter nativePdbWriterOpt, String pdbPathOpt, Boolean metadataOnly, Boolean isDeterministic, Boolean emitTestCoverageData, Nullable`1 privateKeyOpt, CancellationToken cancellationToken)
    D:\Users\tagoo\.nuget\packages\microsoft.net.compilers.toolset\5.0.0-2.25412.102\tasks\netcore\Microsoft.CSharp.Core.targets(84,5): error :    at Microsoft.CodeAnalysis.Compilation.SerializePeToStream(CommonPEModuleBuilder moduleBeingBuilt, DiagnosticBag metadataDiagnostics, CommonMessageProvider messageProvider, Func`1 getPeStream, Func`1 getMetadataPeStreamOpt, Func`1 getPortablePdbStreamOpt, PdbWriter nativePdbWriterOpt, String pdbPathOpt, RebuildData rebuildData, Boolean metadataOnly, Boolean includePrivateMembers, Boolean isDeterministic, Boolean emitTestCoverageData, Nullable`1 privateKeyOpt, CancellationToken cancellationToken)
    D:\Users\tagoo\.nuget\packages\microsoft.net.compilers.toolset\5.0.0-2.25412.102\tasks\netcore\Microsoft.CSharp.Core.targets(84,5): error :    at Microsoft.CodeAnalysis.Compilation.SerializeToPeStream(CommonPEModuleBuilder moduleBeingBuilt, EmitStreamProvider peStreamProvider, EmitStreamProvider metadataPEStreamProvider, EmitStreamProvider pdbStreamProvider, RebuildData rebuildData, Func`2 testSymWriterFactory, DiagnosticBag diagnostics, EmitOptions emitOptions, Nullable`1 privateKeyOpt, CancellationToken cancellationToken)
    D:\Users\tagoo\.nuget\packages\microsoft.net.compilers.toolset\5.0.0-2.25412.102\tasks\netcore\Microsoft.CSharp.Core.targets(84,5): error :    at Microsoft.CodeAnalysis.CommonCompiler.CompileAndEmit(TouchedFileLogger touchedFilesLogger, Compilation& compilation, ImmutableArray`1 analyzers, ImmutableArray`1 generators, ImmutableArray`1 additionalTextFiles, AnalyzerConfigSet analyzerConfigSet, ImmutableArray`1 sourceFileAnalyzerConfigOptions, ImmutableArray`1 embeddedTexts, DiagnosticBag diagnostics, ErrorLogger errorLogger, CancellationToken cancellationToken, CancellationTokenSource& analyzerCts, AnalyzerDriver& analyzerDriver, Nullable`1& generatorTimingInfo)
    D:\Users\tagoo\.nuget\packages\microsoft.net.compilers.toolset\5.0.0-2.25412.102\tasks\netcore\Microsoft.CSharp.Core.targets(84,5): error :    at Microsoft.CodeAnalysis.CommonCompiler.RunCore(TextWriter consoleOutput, ErrorLogger errorLogger, CancellationToken cancellationToken)
    D:\Users\tagoo\.nuget\packages\microsoft.net.compilers.toolset\5.0.0-2.25412.102\tasks\netcore\Microsoft.CSharp.Core.targets(84,5): error :    at Microsoft.CodeAnalysis.CommonCompiler.Run(TextWriter consoleOutput, CancellationToken cancellationToken)
    D:\Users\tagoo\.nuget\packages\microsoft.net.compilers.toolset\5.0.0-2.25412.102\tasks\netcore\Microsoft.CSharp.Core.targets(84,5): error :    at Microsoft.CodeAnalysis.CSharp.CommandLine.Csc.<>c__DisplayClass1_0.<Run>b__0(TextWriter tw)
    D:\Users\tagoo\.nuget\packages\microsoft.net.compilers.toolset\5.0.0-2.25412.102\tasks\netcore\Microsoft.CSharp.Core.targets(84,5): error :    at Microsoft.CodeAnalysis.CommandLine.ConsoleUtil.RunWithUtf8Output[T](Func`2 func)
    D:\Users\tagoo\.nuget\packages\microsoft.net.compilers.toolset\5.0.0-2.25412.102\tasks\netcore\Microsoft.CSharp.Core.targets(84,5): error :    at Microsoft.CodeAnalysis.CommandLine.ConsoleUtil.RunWithUtf8Output[T](Boolean utf8Output, TextWriter textWriter, Func`2 func)
    D:\Users\tagoo\.nuget\packages\microsoft.net.compilers.toolset\5.0.0-2.25412.102\tasks\netcore\Microsoft.CSharp.Core.targets(84,5): error :    at Microsoft.CodeAnalysis.CSharp.CommandLine.Csc.Run(String[] args, BuildPaths buildPaths, TextWriter textWriter, IAnalyzerAssemblyLoader analyzerLoader)
    D:\Users\tagoo\.nuget\packages\microsoft.net.compilers.toolset\5.0.0-2.25412.102\tasks\netcore\Microsoft.CSharp.Core.targets(84,5): error :    at Microsoft.CodeAnalysis.CommandLine.BuildClient.RunLocalCompilation(String[] arguments, BuildPaths buildPaths, TextWriter textWriter)
    D:\Users\tagoo\.nuget\packages\microsoft.net.compilers.toolset\5.0.0-2.25412.102\tasks\netcore\Microsoft.CSharp.Core.targets(84,5): error :    at Microsoft.CodeAnalysis.CommandLine.BuildClient.RunCompilation(IEnumerable`1 originalArguments, BuildPaths buildPaths, TextWriter textWriter, String pipeName)
    D:\Users\tagoo\.nuget\packages\microsoft.net.compilers.toolset\5.0.0-2.25412.102\tasks\netcore\Microsoft.CSharp.Core.targets(84,5): error :    at Microsoft.CodeAnalysis.CommandLine.BuildClient.Run(IEnumerable`1 arguments, RequestLanguage language, CompileFunc compileFunc, CompileOnServerFunc compileOnServerFunc, ICompilerServerLogger logger)
    D:\Users\tagoo\.nuget\packages\microsoft.net.compilers.toolset\5.0.0-2.25412.102\tasks\netcore\Microsoft.CSharp.Core.targets(84,5): error :    at Microsoft.CodeAnalysis.CSharp.CommandLine.Program.MainCore(String[] args)
    D:\Users\tagoo\.nuget\packages\microsoft.net.compilers.toolset\5.0.0-2.25412.102\tasks\netcore\Microsoft.CSharp.Core.targets(84,5): error :    at Microsoft.CodeAnalysis.CSharp.CommandLine.Program.Main(String[] args)

Metadata

Metadata

Assignees

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions