-
Notifications
You must be signed in to change notification settings - Fork 1k
[release/9.0] Fixing Analyzer issues, servicing, Part 2: Actual Fixes #13182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: servicing/RefactorAnalyzerTests9.0Rel
Are you sure you want to change the base?
[release/9.0] Fixing Analyzer issues, servicing, Part 2: Actual Fixes #13182
Conversation
19e5925
to
fe3dd24
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## release/9.0 #13182 +/- ##
=====================================================
- Coverage 74.83821% 74.79265% -0.04557%
=====================================================
Files 3022 2997 -25
Lines 630460 629261 -1199
Branches 46797 46742 -55
=====================================================
- Hits 471825 470641 -1184
- Misses 155247 155258 +11
+ Partials 3388 3362 -26
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
…ionConfiguration. * Addresses 13205, 13206, 13207, 13208.
c6effd1
to
7b2aaa0
Compare
@@ -12,6 +12,7 @@ | |||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | |||
<EnableUnsafeBinaryFormatterSerialization>true</EnableUnsafeBinaryFormatterSerialization> | |||
<GenerateResourceWarnOnBinaryFormatterUse>false</GenerateResourceWarnOnBinaryFormatterUse> | |||
<IsTestUtilityProject>true</IsTestUtilityProject> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this property needed? Do we not set shipping/notshipping properties based on the Test suffix?
Net8_0, | ||
Net9_0 | ||
Net6_0 = 0x00000006, | ||
Net7_0 = 0x00000007, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm concerned that eventually & will go out of support and will not be installed on the CI machines. Can we test only against 9 in the servicing branches?
|
||
using Microsoft.CodeAnalysis.Testing; | ||
|
||
// File-Cherry-Picked and modified a bit from Tanya Solyanik's Commit ec6a9f8, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not needed, we put notes like this when code is shared with other repos, and might go out of sync. In he same repo we can always look up history in the main branch
public static class WinFormsReferencesFactory | ||
{ | ||
private const string RefPackageName = "Microsoft.NETCore.App.Ref"; | ||
private const string PrivatePackagePath = "artifacts\\packages\\Debug\\NonShipping\\Microsoft.Private.Winforms.9.0.3-dev.nupkg"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see how this works -
it assumes someone had built Debug and it assumes specific version...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait... we shouldn't run against the current binary in the artifacts folder in the release branch, everything is already shipped...
if (objectTypeInfo.Type is not INamedTypeSymbol objectType | ||
|| !IsAncestorOrSelfOfType(objectType, "System.Windows.Forms.Control")) | ||
// For implicit calls, we check the containing type of the method itself. | ||
if (containingType is null || !IsAncestorOrSelfOfType(containingType, "System.Windows.Forms.Control")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also check if this binary references winforms? THeoretically it's possible to have user assembly that defines the same type.
|
||
// Does the property belong to a class which derives from Component? | ||
// We never flag a property named Site of type of ISite | ||
if (propertySymbol is null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use pattern matching
|
||
using System.Windows.Forms; | ||
|
||
public static class Program |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this file really needed?
<Compile Remove="Analyzer\AvoidPassingTaskWithoutCancellationToken\TestData\InvokeAsyncOnControl\AnalyzerTestCode.vb" /> | ||
<Compile Remove="Analyzer\MissingPropertySerializationConfiguration\TestData\CustomControlScenarios\AnalyzerTestCode.vb" /> | ||
<Compile Remove="Analyzer\MissingPropertySerializationConfiguration\TestData\CustomControlScenarios\CodeFixTestCode.vb" /> | ||
<Compile Remove="Analyzer\MissingPropertySerializationConfiguration\TestData\CustomControlScenarios\FixedTestCode.vb" /> | ||
<Compile Remove="Analyzer\MissingPropertySerializationConfiguration\TestData\CustomControlScenarios\Program.vb" /> | ||
<Compile Remove="Analyzer\MissingPropertySerializationConfiguration\TestData\EdgeCaseScenarios\AnalyzerTestCode.vb" /> | ||
<Compile Remove="Analyzer\MissingPropertySerializationConfiguration\TestData\EdgeCaseScenarios\Program.vb" /> | ||
<Compile Remove="D:\git\winforms\eng\CodeAnalysisSource.vb" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops
@@ -11,11 +11,16 @@ | |||
</PropertyGroup> | |||
|
|||
<ItemGroup> | |||
<Compile Remove="Analyzer\AvoidPassingTaskWithoutCancellationToken\TestData\ImplicitInvokeAsyncOnControl\AnalyzerTestCode.vb" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use DefaultItemExcludesInProjectFolder property
@@ -50,11 +55,16 @@ | |||
</ItemGroup> | |||
|
|||
<ItemGroup> | |||
<None Include="Analyzer\AvoidPassingTaskWithoutCancellationToken\TestData\ImplicitInvokeAsyncOnControl\AnalyzerTestCode.vb" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is this for?
</ItemGroup> | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra white line
|| propertySymbol.DeclaredAccessibility < Accessibility.Internal) | ||
{ | ||
return; | ||
} | ||
|
||
// Skip overridden properties since the base property should already have the appropriate serialization configuration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to iterate over the base properties?
if (propertySymbol.SetMethod is null | ||
// Is the property read/write and at least internal and doesn't have a private setter? | ||
if (propertySymbol.SetMethod is not IMethodSymbol propertySetter | ||
|| propertySetter.DeclaredAccessibility == Accessibility.Private |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is checking DeclaredAccessibility
sufficient? It should be the default accessibility.
if (propertySymbol.SetMethod is null | ||
// Is the property read/write and at least internal and doesn't have a private setter? | ||
if (propertySymbol.SetMethod is not IMethodSymbol propertySetter | ||
|| propertySetter.DeclaredAccessibility == Accessibility.Private | ||
|| propertySymbol.DeclaredAccessibility < Accessibility.Internal) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this check still needed?
|
||
## Table of Contents | ||
1. [Project Structure](#project-structure) | ||
2. [Language-Specific Considerations](#language-specific-considerations) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you set number as 1. for all these lines, the actual numbers will be auto-generated.
} | ||
|
||
// Skip static properties since they are not serialized by the designer | ||
if (propertySymbol.IsStatic) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please front-load this check to exit fast.
Part 2 of servicing Analyzer fixes back to release/9.0.
This PR contains the actual fixes along with the added tests based on the back ported infrastructure from .NET 10.
See Part 1, Changing the Infrastructure, here:
#13072
Microsoft Reviewers: Open in CodeFlow
Please note, that these fixes have been done and checked, so the respective other language applied, both in C# and Visual Basic, and then Unit Tests had been added to cover those scenarios.
From here, once these are OK'ed, we will back-port them (again, if you will, because the originally came from .NET 10 main), to .NET 10, and the new Clipboard Analyzer's tests will then be updated to integrate into the new test infra.
And after that, they can go into main/net10.