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

Update analyzer testing to Microsoft.CodeAnalysis.Testing #1272

Closed
wants to merge 11 commits into from

Conversation

sharwell
Copy link

@sharwell sharwell commented Apr 29, 2019

Description

  • Update the analyzer test project to use Microsoft.CodeAnalysis.Testing, the new shared analyzer testing library
  • Update the analyzer test project references to meet the minimum requirements of Microsoft.CodeAnalysis.Testing (no impact on end users)

Motivation and Context

This change makes it easier to comprehensively test analyzers.

Recommended review strategy: review each commit individually in sequence.

Testing

This is a test-only change.

Screenshots (if appropriate)

N/A

Types of changes

This is a test-only change; no observable impact on shipping code.

Checklist

  • My code follows the code style of this project
  • My change requires a change to the documentation
  • I have updated the documentation accordingly
  • I have read the README document
  • I have added tests to cover my changes
  • All new and existing tests passed

License

  • I confirm that this pull request can be released under the Apache 2 license

@normj
Copy link
Member

normj commented Aug 13, 2019

I'm uncomfortable adding a myget feed to our build dependency. Is that required?

@sharwell
Copy link
Author

sharwell commented Aug 13, 2019

@normj Yes, this is one of the primary locations where Roslyn team publishes intermediate packages. They are still signed binaries, but don't fall under release API compat guarantees. There is no immediate plan to publish the testing library to NuGet, despite the fact that it already works very well. We are still making changes to the API as we find new cases that people want to test.

@sharwell
Copy link
Author

Please feel free to ask questions about anything you see. I try to answer questions directly, from a "this is how we arrived at the current state" view, as opposed to trying to say whether something is right or wrong. The testing library was developed to help people write better tests that in turn lead to better analyzers and better code fixes. We're interested in any feedback related to that end-to-end story so the community can be successful.

@github-actions
Copy link

github-actions bot commented Feb 2, 2022

We have noticed this issue has not received attention in 1 year. We will close this issue for now. If you think this is in error, please feel free to comment and reopen the issue.

@sharwell
Copy link
Author

sharwell commented Feb 2, 2022

📝 The feed location changed; I can update this pull request to use the new one.

@sharwell
Copy link
Author

sharwell commented Feb 2, 2022

@normj This pull request now references code from nuget.org.

@@ -36,32 +36,25 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.CodeAnalysis, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.CodeAnalysis.Common.1.0.0\lib\net45\Microsoft.CodeAnalysis.dll</HintPath>
<Private>True</Private>
<HintPath>..\..\packages\Microsoft.CodeAnalysis.Common.1.0.1\lib\net45\Microsoft.CodeAnalysis.dll</HintPath>
Copy link
Author

Choose a reason for hiding this comment

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

📝 The changes in this commit would be tremendously simplified for the future if the project transitions to <PackageReference> for package references.

@@ -22,6 +23,8 @@ public Test()

return solution;
});

TestBehaviors |= TestBehaviors.SkipGeneratedCodeCheck;
Copy link
Author

Choose a reason for hiding this comment

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

📝 This line can be removed if the analyzers update to Roslyn 1.2.1 and add a call to ConfigureGeneratedCodeAnalysis.

@ashishdhingra ashishdhingra added the feature-request A feature should be added or improved. label Oct 11, 2022
@ashishdhingra
Copy link
Contributor

@sharwell Good afternoon. I was reviewing outstanding PR(s) and came across this feature request. Please let me know if this PR is still relevant, or else confirm to close the same.

Thanks,
Ashish

@ashishdhingra ashishdhingra added the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Mar 20, 2023
@sharwell
Copy link
Author

Hi @ashishdhingra ,

This change makes it easier to write tests for the analyzers in this project. Since it is a maintainability improvement and not an end-user product improvement, the relevance depends on the goals of the project. If the maintainers of this project intend to continue developing features in this repository, this change would still be relevant.

Thanks,
Sam

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Mar 22, 2023
@dscpinheiro
Copy link
Contributor

I'm closing this PR since we recently updated all of our analyzer projects to target netstandard2.0.

We're now using a much more modern version of Microsoft.CodeAnalysis (4.6.0 - https://github.com/aws/aws-sdk-net/blob/master/sdk/code-analysis/MockAnalyzer/MockAnalyzer.csproj#L9), and we also addressed some of the comments you mentioned (such as configuring generated code analysis - https://github.com/aws/aws-sdk-net/blob/master/sdk/code-analysis/SharedAnalysisCode/AbstractPropertyValueAssignmentAnalyzer.cs#L177-L178).

Please feel free to open a new issue if needed.

@dscpinheiro dscpinheiro closed this Jul 3, 2023
@sharwell
Copy link
Author

sharwell commented Jul 5, 2023

Hi @dscpinheiro,

It appears the changes you describe were reverted. Please feel free to reach out if you have questions about updating this code.

Thanks,
Sam

@dscpinheiro
Copy link
Contributor

dscpinheiro commented Jul 5, 2023

Hi @sharwell! Yes, we ended up reverting because my change to the CodeAnalysis package broke customers.

We still want to update our analyzers to target netstandard2.0, and there was a recommendation on the other GitHub issue to target an older version (such as 2.10.0 - chosen from https://learn.microsoft.com/en-us/visualstudio/extensibility/roslyn-version-support?view=vs-2022 since it was the last one for VS2017).

Are there any concerns with this approach? We decided to revert the commit first (instead of only downgrading the package) as we weren't sure if that specific version could still break customers with older tooling (such as VS 2017 users prior to 15.9).

@sharwell
Copy link
Author

sharwell commented Jul 6, 2023

We still want to update our analyzers to target netstandard2.0

Is there a specific motivating need to do this? Analyzers targeting netstandard1.3 (e.g. StyleCop Analyzers) will still execute within current versions of Visual Studio.

The 2.10.0 release of Microsoft.CodeAnalysis.Common targets netstandard1.3. I'm not sure what the official support status is for a netstandard2.0 analyzer is when running inside Visual Studio 2017. Most users I know of have either dropped VS 2017 support, or maintained the analyzers targeting netstandard1.3.

@dscpinheiro
Copy link
Contributor

@sharwell We ended up targeting netstandard2.0: #2998

Thanks a lot for your help!

@sharwell sharwell deleted the analyzer-testing branch July 25, 2023 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request A feature should be added or improved.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants