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

Implement analyzer and code-fixers for DynamicInterfaceCastableImplementation analyzers #5129

Merged
merged 27 commits into from
Aug 18, 2021

Conversation

jkoritzinsky
Copy link
Member

@jkoritzinsky jkoritzinsky commented May 24, 2021

Implement analyzers and code fixes as per dotnet/runtime#41529

Fixes dotnet/runtime#41529

@jkoritzinsky jkoritzinsky requested a review from a team as a code owner May 24, 2021 22:16
@codecov
Copy link

codecov bot commented May 25, 2021

Codecov Report

Merging #5129 (47fb625) into release/6.0.1xx (ec2f382) will increase coverage by 0.00%.
The diff coverage is 95.98%.

@@                Coverage Diff                 @@
##           release/6.0.1xx    #5129     +/-   ##
==================================================
  Coverage            95.61%   95.62%             
==================================================
  Files                 1240     1244      +4     
  Lines               285455   286799   +1344     
  Branches             17134    17213     +79     
==================================================
+ Hits                272951   274248   +1297     
- Misses               10193    10232     +39     
- Partials              2311     2319      +8     

async ct => await SealMemberDeclaredOnImplementationType(declaration, context.Document, context.CancellationToken).ConfigureAwait(false),
equivalenceKey: nameof(MicrosoftNetCoreAnalyzersResources.SealMethodDeclaredOnImplementationType)),
diagnostic);
}
Copy link
Member

Choose a reason for hiding this comment

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

else throw NotSupportedException or something that ensures the code path isn't reachable?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think silently falling through here is ok unless the pattern in the repo otherwise is to throw.

<value>Implement inherited interfaces</value>
</data>
<data name="InterfaceMethodsMissingImplementationDescription" xml:space="preserve">
<value>Types attributed with 'DynamicInterfaceCastableImplementationAttribute' act as an interface implementation for a type that implements the 'IDynamicInterfaceCastable' type. As a result, it must provide an implementation of all of the methods defined in the inherited interfaces, because the type that implements 'IDynamicInterfaceCastable' will not provide them otherwise.</value>
Copy link
Member

Choose a reason for hiding this comment

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

Is IDynamicInterfaceCastable is a must to use DynamicInterfaceCastableImplementationAttribute? Any separate analyzer work for that?

Copy link
Member Author

Choose a reason for hiding this comment

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

IDynamicInterfaceCastable is a must-use type related to the DynamicInterfaceCastableImplementationAttribute type. But since IDynamicInterfaceCastable will be implemented by a different type, so there's no analyzer work for that.

@jkoritzinsky
Copy link
Member Author

@dotnet/roslyn-analysis just want to make sure that reviewing this is on the backlog as it's been green in CI and waiting for review for 27 days.

Copy link
Contributor

@ryzngard ryzngard left a comment

Choose a reason for hiding this comment

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

Some style problems. In general I think this repo uses var when possible. I marked a few but realized a lot of the same comment would get tedious.

There also may be some missing paths for testing.

@jkoritzinsky
Copy link
Member Author

@sharwell is there an ETA on when this will be reviewed? Last review pass was two weeks ago and the only changes since then were resolving merge conflicts.

<value>All members declared in parent interfaces must have an implementation in a DynamicInterfaceCastableImplementation-attributed interface</value>
</data>
<data name="MembersDeclaredOnImplementationTypeMustBeSealedDescription" xml:space="preserve">
<value>Since a type that implements 'IDynamicInterfaceCastable' will conventionally not specify that it implements a 'DynamicInterfaceCastableImplementationAttribute'-attributed type, only the public interface type, virtual interface method lookup will fail even if the method has an implementation. As a result, all members on 'DynamicInterfaceCastableImplementation'-attributed types should be 'sealed'.</value>
Copy link
Member

Choose a reason for hiding this comment

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

... will conventionally not specify that it implements a 'DynamicInterfaceCastableImplementationAttribute'-attributed type, only the public interface type, virtual interface method lookup will fail even if the method has an implementation ...

I don't understand this wording. Can you suggest a rephrasing to iterate on it?

Copy link
Member Author

@jkoritzinsky jkoritzinsky Jul 27, 2021

Choose a reason for hiding this comment

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

Suggested change
<value>Since a type that implements 'IDynamicInterfaceCastable' will conventionally not specify that it implements a 'DynamicInterfaceCastableImplementationAttribute'-attributed type, only the public interface type, virtual interface method lookup will fail even if the method has an implementation. As a result, all members on 'DynamicInterfaceCastableImplementation'-attributed types should be 'sealed'.</value>
<value>Since a type that implements 'IDynamicInterfaceCastable' will not specify in source or in the `IDynamicInterfaceCastable` implementation that it implements a 'DynamicInterfaceCastableImplementationAttribute'-attributed type, virtual interface method lookup will fail even if the method has an implementation. As a result, all members on 'DynamicInterfaceCastableImplementation'-attributed types should be 'sealed'.</value>

@jkoritzinsky
Copy link
Member Author

CI failure is #5381 and is unrelated to this PR (it's failing in the release/6.0.1xx branch without this change).

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.

4 participants