Skip to content

Conversation

@sbomer
Copy link
Member

@sbomer sbomer commented Jul 27, 2023

This adds support for top-level statements to the illink/nativeaot/trim-analyzer test infrastructure. Each file with top-level statements gets compiled into its own testcase assembly, which is placed into a subdirectory of the Mono.Linker.Tests.Cases build output.

sbomer added 6 commits July 26, 2023 21:10
The object model wouldn't preserve declaring typesin these cases
because the warnings are produced for members that are removed.
Fixing the testcases to preserve these members lets us remove
this workaround.
@ghost ghost assigned sbomer Jul 27, 2023
@ghost ghost added the area-Tools-ILLink .NET linker development as well as trimming analyzers label Jul 27, 2023
@ghost
Copy link

ghost commented Jul 27, 2023

Tagging subscribers to this area: @agocke, @sbomer, @vitek-karas
See info in area-owners.md if you want to be subscribed.

Issue Details

null

Author: sbomer
Assignees: sbomer
Labels:

area-Tools-ILLink

Milestone: -

@sbomer sbomer closed this Jul 27, 2023
@sbomer sbomer reopened this Jul 27, 2023
@sbomer sbomer requested a review from vitek-karas July 28, 2023 16:24
@sbomer sbomer changed the title Top level statement tests Add top level statement trimming tests Jul 28, 2023
@sbomer sbomer marked this pull request as ready for review July 28, 2023 16:25
@sbomer sbomer requested a review from marek-safar as a code owner July 28, 2023 16:25
{
public const string TestCaseAssembly = "Mono.Linker.Tests.Cases";

public void Execute (GeneratorExecutionContext context)
Copy link
Member Author

Choose a reason for hiding this comment

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

This was dead code, left over from #86260.

Copy link
Member

@vitek-karas vitek-karas left a comment

Choose a reason for hiding this comment

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

Nice :-)

Comment on lines 148 to 149
if (member is MethodDefinition method && method.Name.Contains("<Main>$"))
return false;
Copy link
Member

Choose a reason for hiding this comment

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

I find this a bit confusing. The IsCompilerGeneratedMember effectively dictates if we should perform "Kept" validation on the member.

I think we should instead change ShouldMethodBeKept which basically says that entry point is always kept (regardless of attributes). I wonder why the entrypoint is not set to the compiler generated main though... insteresting...

Copy link
Member Author

Choose a reason for hiding this comment

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

It took me a bit to remember why I did this - it's needed for Kept validation of top-level methods. I added a clarifying comment. (I checked and the generated Main method does get treated as the entry point.)

- Remove left-over debugging output
- Add comment about checking of
  compiler-generated top-level methods
@sbomer
Copy link
Member Author

sbomer commented Aug 1, 2023

Failure is #88586

@sbomer sbomer merged commit efde006 into dotnet:main Aug 1, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Aug 31, 2023
@sbomer sbomer deleted the topLevelStatementTests branch November 3, 2023 18:36
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-Tools-ILLink .NET linker development as well as trimming analyzers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants