Skip to content

Fix analyzer test generation for non-public Main#3151

Merged
sbomer merged 1 commit intodotnet:mainfrom
sbomer:internalMain
Dec 6, 2022
Merged

Fix analyzer test generation for non-public Main#3151
sbomer merged 1 commit intodotnet:mainfrom
sbomer:internalMain

Conversation

@sbomer
Copy link
Member

@sbomer sbomer commented Dec 6, 2022

In dotnet/runtime#79011 @tlakollo discovered that the ILLink analyzer testcase generator was generating extra testcases in dotnet/runtime, compared to linker. It turned out that in dotnet/linker, testcases with non-public Main methods were not getting generated, because the generator was getting a reference assembly for Mono.Linker.Tests.Cases.dll (which doesn't contain the non-public entry point), whereas dotnet/runtime has ref assembly generation turned off (so the analyzer was correctly discovering testcases based on the implementation assembly).

This fixes the issue by turning off ref assembly generation for all projects except those specifically designed to be ref assemblies.

The CompilerGeneratedCodeSubstitutions is disabled as in dotnet/runtime#79011.

@sbomer sbomer requested a review from marek-safar as a code owner December 6, 2022 21:57
@sbomer sbomer requested a review from tlakollo December 6, 2022 21:58

[Fact]
public Task BaseProvidesInterfaceMethod ()
public Task VarianceBasic ()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we know why this happens? I do see that the VarianceBasic had a private Main method and is fine that we now have the Fact being generated. But why the BaseProvidesInterfaceMethod disappeared? And why there are no other tests? inside the Inheritance.Interfaces.StaticInterfaceMethods folder I see 10 files.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The BaseProvidesInterfaceMethods and other tests besides VarianceBasic already exist in the non-generated StaticInterfaceMethods.cs. The generated BaseProvidesInterfaceMethod was left over even though the source generator is no longer generating it - and it wasn't being overwritten because it thought all of the testcases were already present (it doesn't generate a file with no facts in that case).

@sbomer sbomer merged commit c9ba21d into dotnet:main Dec 6, 2022
tlakollo pushed a commit to tlakollo/linker that referenced this pull request Dec 20, 2022
The ILLink analyzer testcase generator was generating extra
testcases in dotnet/runtime, compared to linker. It turned out
that in dotnet/linker, testcases with non-public Main methods
were not getting generated, because the generator was getting a
reference assembly for Mono.Linker.Tests.Cases.dll (which doesn't
contain the non-public entry point), whereas dotnet/runtime has
ref assembly generation turned off (so the analyzer was correctly
discovering testcases based on the implementation assembly).

This fixes the issue by turning off ref assembly generation for
all projects except those specifically designed to be ref
assemblies.

The CompilerGeneratedCodeSubstitutions is disabled because it is
not supported by the analyzer.

Commit migrated from dotnet@c9ba21d
tlakollo pushed a commit to tlakollo/runtime that referenced this pull request Dec 22, 2022
The ILLink analyzer testcase generator was generating extra
testcases in dotnet/runtime, compared to linker. It turned out
that in dotnet/linker, testcases with non-public Main methods
were not getting generated, because the generator was getting a
reference assembly for Mono.Linker.Tests.Cases.dll (which doesn't
contain the non-public entry point), whereas dotnet/runtime has
ref assembly generation turned off (so the analyzer was correctly
discovering testcases based on the implementation assembly).

This fixes the issue by turning off ref assembly generation for
all projects except those specifically designed to be ref
assemblies.

The CompilerGeneratedCodeSubstitutions is disabled because it is
not supported by the analyzer.

Commit migrated from dotnet/linker@c9ba21d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants