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

Extend AnalyzerTest to support tests for DiagnosticSuppressor analyzers #916

Closed
wants to merge 12 commits into from

Conversation

tom-englert
Copy link
Contributor

@tom-englert tom-englert commented Oct 4, 2021

This implements scenario 1 from #915 by conditionally selecting dependencies and extend the analyzer validation code.

Comment on lines +37 to +39
<Testing_MicrosoftCodeAnalysisWorkspaces_Version>3.8.0</Testing_MicrosoftCodeAnalysisWorkspaces_Version>
<Testing_MicrosoftCodeAnalysisAnalyzers_Version>3.3.2</Testing_MicrosoftCodeAnalysisAnalyzers_Version>
<DefineConstants Condition="'$(Language)' == 'C#'">$(DefineConstants);DIAG_SUPPORTS_SUPPRESSION</DefineConstants>
Copy link
Member

Choose a reason for hiding this comment

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

❗ These can't change. Light-up/reflection must be used to support the scenario in cases where the APIs do not exist.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, then I will do another PR using reflection.

Copy link
Member

Choose a reason for hiding this comment

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

We have a few places where it's already used. See CodeActionExtensions for an example:

public static ImmutableArray<CodeAction> GetNestedActions(this CodeAction action)
{
var property = typeof(CodeAction).GetTypeInfo().DeclaredProperties.SingleOrDefault(property => property.Name == "NestedCodeActions");
if (property is null)
{
return ImmutableArray<CodeAction>.Empty;
}
return (ImmutableArray<CodeAction>)(property.GetValue(action) ?? throw new NotSupportedException());
}

Copy link
Member

Choose a reason for hiding this comment

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

Also the support for AnalyzerConfigDocuments #734

Comment on lines +23 to +26
ProjectSection(SolutionItems) = preProject
src\Microsoft.CodeAnalysis.Testing\Directory.Build.props = src\Microsoft.CodeAnalysis.Testing\Directory.Build.props
src\Microsoft.CodeAnalysis.Testing\Directory.Build.targets = src\Microsoft.CodeAnalysis.Testing\Directory.Build.targets
EndProjectSection
Copy link
Member

Choose a reason for hiding this comment

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

💡 These don't need to be added to the solution. They are visible in Solution Explorer with this button:

image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not about viewing the file, it's about getting FindInFiles with scope solution working as expected. (for guys like me being not so used to all the features and tweaks in an unknown solution)
However I won't insist in adding this...

Copy link
Member

@sharwell sharwell Oct 4, 2021

Choose a reason for hiding this comment

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

I find it's a losing battle to keep solution files synchronized with the solution. The only way it's always consistent is to omit them all and point users to the solution filter button. 😄

The button used to work much better in Visual Studio 2017 (one click would toggle show/hide). Now it's tedious but still technically works.

@tom-englert
Copy link
Contributor Author

Replaced by #917

@tom-englert tom-englert closed this Oct 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants