dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
18.84k stars 4k forks source link

Compiler tests failing on `net8.0` #71571

Open jaredpar opened 7 months ago

jaredpar commented 7 months ago

When the compiler moved a few test assemblies to net8.0 the stopped running on Linux due to an infrastructure issue. This was discovered in #71556 where we simplified how TFMs were handled in our build / test infrastructure.

These tests are being disabled on Linux for the moment to get the PR through (stop the bleeding). Will go back and evaluate the disabled tests later. This issue is tracking those tests.

jaredpar commented 7 months ago

@tmat the compiler tests are failing on Linux due to this assert you added into PEModuleBuilder.cs:

        private static void GetDocumentsForMethodsAndNestedTypes(PooledHashSet<Cci.DebugSourceDocument> documentList, ArrayBuilder<Cci.ITypeDefinition> typesToProcess, EmitContext context)
        {
            Debug.Assert(!context.MetadataOnly);

That assert is valid from the perspective of the command line API because never emit PDB data for metadata references. That is normalized during command line parsing:

                EmitPdb = emitPdb && !refOnly, // silently ignore emitPdb when refOnly is set

From the compiler API perspective though it's quite possible to create a PDB when building a metadata only assembly. All that needs to be done is construct the EmitOptions manually and pass them through. That is what's happening in these failures, the compiler is passing along an EmitOptions that specifies a PDB when building ref assemblies and it triggers the assert.

Not sure how to proceed here. Assuming you added the assert for a good reason but it does seem like a situation that is allowed by the APIs.