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

Fix ignored Namespace attribute in OperationLightupGenerator #3378

Merged
merged 2 commits into from
Dec 9, 2021

Conversation

pavel-mikula-sonarsource
Copy link
Contributor

@pavel-mikula-sonarsource pavel-mikula-sonarsource commented Aug 24, 2021

Most of the wrapped IOperations are in Microsoft.CodeAnalysis.Operations namespace and there are 6 more of them in FlowAnalysis namespace:

Microsoft.CodeAnalysis.FlowAnalysis.ICaughtExceptionOperation
Microsoft.CodeAnalysis.FlowAnalysis.IFlowAnonymousFunctionOperation
Microsoft.CodeAnalysis.FlowAnalysis.IFlowCaptureOperation
Microsoft.CodeAnalysis.FlowAnalysis.IFlowCaptureReferenceOperation
Microsoft.CodeAnalysis.FlowAnalysis.IIsNullOperation
Microsoft.CodeAnalysis.FlowAnalysis.IStaticLocalInitializationSemaphoreOperation

This alternation is already configured in the OperationInterfaces.xml file, but the Namespace attribute was ignored in the code.

<Node Name="IFlowCaptureReferenceOperation" Base="IOperation" Namespace="FlowAnalysis">

Current behavior:
Using IFlowAnonymousFunctionOperationWrapper.FromOperation(anonymousFunction) throws cast exception, because IsInstance and LightupHelpers.CanWrapOperation finds the key, but returns null value for the type.

Most of the wrapped `IOperation`s are in `Microsoft.CodeAnalysis.Operations` namespace and there are 6 more of them in `FlowAnalysis` namespace:
```
Microsoft.CodeAnalysis.FlowAnalysis.ICaughtExceptionOperation
Microsoft.CodeAnalysis.FlowAnalysis.IFlowAnonymousFunctionOperation
Microsoft.CodeAnalysis.FlowAnalysis.IFlowCaptureOperation
Microsoft.CodeAnalysis.FlowAnalysis.IFlowCaptureReferenceOperation
Microsoft.CodeAnalysis.FlowAnalysis.IIsNullOperation
Microsoft.CodeAnalysis.FlowAnalysis.IStaticLocalInitializationSemaphoreOperation
```
This alternation is already configured in the `OperationInterfaces.xml` file, but the `Namespace` attribute was ignored in the code.
https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/a559b3e58af09387aadc1372a504f9208bce4909/StyleCop.Analyzers/StyleCop.Analyzers/Lightup/OperationInterfaces.xml#L2542
@codecov
Copy link

codecov bot commented Aug 24, 2021

Codecov Report

Merging #3378 (6b7b40d) into master (a559b3e) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master    #3378   +/-   ##
=======================================
  Coverage   93.45%   93.45%           
=======================================
  Files        1029     1029           
  Lines      111170   111170           
  Branches     3940     3940           
=======================================
  Hits       103891   103891           
  Misses       6263     6263           
  Partials     1016     1016           

Copy link
Member

@sharwell sharwell left a comment

Choose a reason for hiding this comment

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

This pull request is missing the corresponding changes to the generated files (created automatically by the build, but included to make visual inspection possible in review).

@sharwell sharwell merged commit ca7ccd2 into DotNetAnalyzers:master Dec 9, 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