Skip to content
This repository was archived by the owner on Sep 25, 2026. It is now read-only.

Test Restructure - #2336

Merged
tlakollo merged 6 commits into
dotnet:release/6.0.2xxfrom
tlakollo:AddRAFToRequiresTestFile
Nov 2, 2021
Merged

tlakollo merged 6 commits into
dotnet:release/6.0.2xxfrom
tlakollo:AddRAFToRequiresTestFile

Conversation

@tlakollo

Copy link
Copy Markdown
Contributor

Add RequiresAssemblyFiles to RequiresCapability file
Add ProducedBy for LogContains and LogDoesNotContain
Remove Analyzer Generic for test case run, since now all analyzers are run

Add ProducedBy for LogContains and LogDoesNotContain
Remove Analyzer Generic for test case run, since now all analyzers are run
@tlakollo tlakollo self-assigned this Oct 27, 2021
…he base Requires file

Remove tests from Analyzer if they are being tested in linker
Add RequiresAssemblyFilesMismatchAttribute Tittle and Message to fix bug
Add testing in linker for mismatching attributes
Add testing in linker for Delegates in CompilerGenerated file
@tlakollo
tlakollo changed the base branch from main to release/6.0.2xx November 2, 2021 06:30
@tlakollo tlakollo closed this Nov 2, 2021
@tlakollo tlakollo reopened this Nov 2, 2021
@tlakollo
tlakollo marked this pull request as ready for review November 2, 2021 06:36
@tlakollo
tlakollo requested a review from marek-safar as a code owner November 2, 2021 06:36
}

[ExpectedWarning ("IL3003", "DerivedClassWithoutRequires.VirtualPropertyAnnotationInProperty", "BaseClassWithRequires.VirtualPropertyAnnotationInProperty", ProducedBy = ProducedBy.Analyzer)]
public override string VirtualPropertyAnnotationInProperty { get; set; }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why is this for assembly files only and not for unreferenced code as well?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You cannot place RUC on a property, but you can do it in RAF

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hmm that's a curious limitation... can you please create an issue somewhere to make this consistent? Unless there's a reason (and I just forgot).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

What about events?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think it's the same deal... In theory there's no reason for these two attributes to have different behavior (at least I'm not aware of one). It's fine if they're not identical right now, but I think they should be eventually.

var action = new Action (MethodWithRequires);
}

[ExpectedWarning ("IL2026", "Message from --InitString--", CompilerGeneratedCode = true)]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think these should have the CompilerGeneratedCode = true on them... that is meant for cases where the origin is from the compiler generated code (and thus it's not possible to put the attribute there). In this case the warning happens on a static field directly - so no need for this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

According to linker the warning comes from the static constructor, for example:
ILLink: Trim analysis warning IL2026: Mono.Linker.Tests.Cases.RequiresCapability.RequiresInCompilerGeneratedCode.SuppressInAsyncBody..cctor(): Using member 'Mono.Linker.Tests.Cases.RequiresCapability.RequiresInCompilerGeneratedCode.InitString()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Message from --InitString--. so the CompilerGeneratedCode is needed. In fact I think I forgot to add some code handling that I had before

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

OK _ I guess we can treat static .ctors as compiler generated code. This property was initially designed for the async/iterator state machine code, but it seems to make sense in other cases as well 😄

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added an additional piece of code in the result checker to verify the static constructor call (was already in #2113)

Add support for static constructor compiler generated calls
@tlakollo tlakollo mentioned this pull request Nov 2, 2021
@tlakollo
tlakollo merged commit 8e455f0 into dotnet:release/6.0.2xx Nov 2, 2021
@tlakollo
tlakollo deleted the AddRAFToRequiresTestFile branch November 2, 2021 22:50
@tlakollo

tlakollo commented Nov 3, 2021

Copy link
Copy Markdown
Contributor Author

Marked as done several points of #2299

agocke pushed a commit to dotnet/runtime that referenced this pull request Nov 16, 2022
Move RequiresAssemblyFiles from Analyzer to the linker RequiresCapability file
Move the new constraint code from RequiresUnreferencedCode to be on the base Requires file
Add Warning Id to messages from the analyzer to distinguish in a test which analyzer missed/found a warning
Add RequiresAssemblyFilesMismatchAttribute Title and Message to fix bug
Add testing in linker for mismatching attributes
Add testing in linker for Delegates in CompilerGenerated file
Add support for static constructor compiler-generated calls
Add additional warnings from DAM and RUC interaction. Not supported by the analyzer yet

Commit migrated from dotnet/linker@8e455f0
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants