Skip to content
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

Produce warning on duplicate analyzer references #63264

Merged
merged 8 commits into from
Sep 1, 2022

Conversation

Youssef1313
Copy link
Member

Fixes #62610

@ghost ghost added the Community The pull request was submitted by a contributor who is not a Microsoft employee. label Aug 8, 2022
@Youssef1313 Youssef1313 marked this pull request as ready for review August 9, 2022 11:07
@Youssef1313 Youssef1313 requested a review from a team as a code owner August 9, 2022 11:07
@RikkiGibson RikkiGibson self-assigned this Aug 9, 2022
@Youssef1313 Youssef1313 requested review from a team as code owners August 11, 2022 07:12
Comment on lines 83 to 90
<!-- TODO: Remove once we consume an SDK with the fix from https://github.com/dotnet/wpf/pull/6799 -->
<Target Name="RemoveDuplicateAnalyzers" BeforeTargets="CoreCompile">
<ItemGroup>
<FilteredAnalyzer Include="@(Analyzer->Distinct())" />
<Analyzer Remove="@(Analyzer)" />
<Analyzer Include="@(FilteredAnalyzer)" />
</ItemGroup>
</Target>
Copy link
Member Author

@Youssef1313 Youssef1313 Aug 11, 2022

Choose a reason for hiding this comment

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

@Youssef1313 Youssef1313 requested a review from a team as a code owner August 11, 2022 08:41
@Youssef1313
Copy link
Member Author

@RikkiGibson This is green now :)

Copy link
Member

@jaredpar jaredpar left a comment

Choose a reason for hiding this comment

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

Can't use a hash set cause of deteriminism issues but everything else looks good.

@@ -367,6 +367,15 @@
</ItemGroup>
</Target>

<!-- TODO: Remove once we consume an SDK with the fix from https://github.com/dotnet/wpf/pull/6799 -->
Copy link
Member

Choose a reason for hiding this comment

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

Nit: can you match the general format for a work around comment as used in the rest of the file

Suggested change
<!-- TODO: Remove once we consume an SDK with the fix from https://github.com/dotnet/wpf/pull/6799 -->
<!-- Workaround for https://github.com/dotnet/wpf/pull/6799 -->

@@ -510,16 +510,22 @@ public IEnumerable<AnalyzerReference> ResolveAnalyzerReferences(IAnalyzerAssembl
}
};

var resolvedReferences = ArrayBuilder<AnalyzerFileReference>.GetInstance();
var resolvedReferences = PooledHashSet<AnalyzerFileReference>.GetInstance();
Copy link
Member

Choose a reason for hiding this comment

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

Can't use a hash set here because it introduces non-determinism into the compilation. Think we need two collections here: the resolved list and the hash set.

@jaredpar
Copy link
Member

@RikkiGibson PTAL

@RikkiGibson
Copy link
Contributor

It looks like a test baseline needs to be updated.

@Youssef1313
Copy link
Member Author

@RikkiGibson @jaredpar Anything else needed here?

@RikkiGibson
Copy link
Contributor

Thanks for the ping @Youssef1313.

I think we should do a few checks before merging here. Other projects could get that same issue with WPF projects that we had to work around if they start consuming this compiler. I'd like to test-insert this change to VS to verify the impact, but I won't be able to until our internal build gets fixed. I'll follow up when I have more info.

@RikkiGibson
Copy link
Contributor

Have created a test insertion (internal only) for this.

@JoeRobich
Copy link
Member

@RikkiGibson Test insertion is passing.

@RikkiGibson
Copy link
Contributor

Would like to merge as soon as we can verify dotnet/wpf#6792 (comment).

@RikkiGibson
Copy link
Contributor

I think we are good to go here since this should be going into RC1 at the same time as the WPF fix.

@RikkiGibson RikkiGibson merged commit ee9808b into dotnet:main Sep 1, 2022
@RikkiGibson
Copy link
Contributor

Thanks @Youssef1313!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers Community The pull request was submitted by a contributor who is not a Microsoft employee.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Report when the same analyzer is passed multiple times
5 participants