diff options
author | Vitek Karas <10670590+vitek-karas@users.noreply.github.com> | 2022-02-18 14:17:07 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-18 14:17:07 +0300 |
commit | f43e55cdf68c52e6111cf192bea837a02f18a4bc (patch) | |
tree | 5dfffce5c0593e467649a53c8e4097ac68759897 /test | |
parent | 2116ace70e38b1f9f7728b541f2e2746bb410cce (diff) |
Update comments on tests with fake generated backing fields (#2630)
The tests use fake generated backing fields, which the linker recognizes as the real thing, but the analyzer is not fooled. So it's expected the analyzer would produce warnings here - and the developer who writes code like this (hard to imagine why) should fix those warnings anyway.
Co-authored-by: Tlakaelel Axayakatl Ceja <tlakaelel.ceja@microsoft.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/Mono.Linker.Tests.Cases/DataFlow/PropertyDataFlow.cs | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/test/Mono.Linker.Tests.Cases/DataFlow/PropertyDataFlow.cs b/test/Mono.Linker.Tests.Cases/DataFlow/PropertyDataFlow.cs index d15df0179..ed83c7bea 100644 --- a/test/Mono.Linker.Tests.Cases/DataFlow/PropertyDataFlow.cs +++ b/test/Mono.Linker.Tests.Cases/DataFlow/PropertyDataFlow.cs @@ -192,7 +192,15 @@ namespace Mono.Linker.Tests.Cases.DataFlow } } - // Analyzer doesn't try to detect backing fields of properties: https://github.com/dotnet/linker/issues/2273 + // This test creates a property and field which linker will recognized as a compiler generated backing field for the property + // The purpose of the test is to verify, that linker flows the annotation to the backing field and since there's + // no good way to reference actual compiler generated backing field, we "Fake" it here as compiler generated. + // But this doesn't fool the analyzer - since it's seen as yet another user declared field, so it doesn't propagate the + // annotation. + // This discrepancy is currently by design and not worth the trouble to implement logic for it in the analyzer. + // Producing fields which are annotated with CompilerGeneratedAttribute and making them look like backing fields + // is highly unlikely to be done by anybody. If it happens, the analyzer will produce warnings which the linker will not + // but those warnings are not really wrong, so it's better if the developer fixes them anyway. [ExpectedWarning ("IL2077", nameof (DataFlowTypeExtensions) + "." + nameof (DataFlowTypeExtensions.RequiresPublicConstructors) + "(Type)", nameof (TestAutomaticPropagationType) + "." + nameof (PropertyWhichLooksLikeCompilerGenerated_Field), ProducedBy = ProducedBy.Analyzer)] @@ -208,7 +216,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicConstructors)] static Type PropertyWhichLooksLikeCompilerGenerated { - // Analyzer doesn't try to detect backing fields of properties: https://github.com/dotnet/linker/issues/2273 + // See above comment about fake compiler generated backing fields - this warning is expected from the analyzer [ExpectedWarning ("IL2078", nameof (TestAutomaticPropagationType) + "." + nameof (PropertyWhichLooksLikeCompilerGenerated) + ".get", nameof (TestAutomaticPropagationType) + "." + nameof (PropertyWhichLooksLikeCompilerGenerated_Field), ProducedBy = ProducedBy.Analyzer)] @@ -355,7 +363,7 @@ namespace Mono.Linker.Tests.Cases.DataFlow [DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicConstructors)] Type PropertyWithConflictingNoneAttributes { - // Analyzer doesn't try to detect backing fields of properties: https://github.com/dotnet/linker/issues/2273 + // See above comment about fake compiler generated backing fields - this warning is expected from analyzer [ExpectedWarning ("IL2078", nameof (TestAutomaticPropagationType) + "." + nameof (PropertyWithConflictingNoneAttributes) + ".get", nameof (TestAutomaticPropagationType) + "." + nameof (PropertyWithConflictingNoneAttributes_Field), ProducedBy = ProducedBy.Analyzer)] |