Only add getters and setters for type-forwarded properties to public API#1657
Merged
DustinCampbell merged 1 commit intodotnet:masterfrom Apr 3, 2018
Merged
Conversation
During normal operation, properties are not added to the public API surface area because the analyzer does not register a symbol
action for `SymbolKind.Property`. This works fine, there is an action registered for `SymbolKind.Method`, which ensures that getters
and setters are added as expected. Things are a bit different for forwarded types.
In the case of a forwarded type, the public API surface area is discovered by recursively searching members and nested types. However,
this code adds both properties *and* accessors, resulting in the PublicAPI.Shipped.txt file needs to include an entry for the property
and the accessors, like so:
```
Microsoft.CodeAnalysis.FileTextLoader.Path.get -> string (forwarded, contained in Microsoft.CodeAnalysis.Workspaces)
Microsoft.CodeAnalysis.FileTextLoader.Path { get; } -> string (forwarded, contained in Microsoft.CodeAnalysis.Workspaces)
```
This change fixes the analyzer to not consider property symbols when recursively searching through forwarded types. However, it still
considers their accessors.
8 tasks
Codecov Report
@@ Coverage Diff @@
## master #1657 +/- ##
==========================================
+ Coverage 93.44% 93.45% +<.01%
==========================================
Files 731 731
Lines 126044 126071 +27
Branches 3512 3513 +1
==========================================
+ Hits 117786 117814 +28
+ Misses 7472 7471 -1
Partials 786 786
Continue to review full report at Codecov.
|
mavasani
approved these changes
Apr 3, 2018
jasonmalinowski
approved these changes
Apr 3, 2018
DustinCampbell
added a commit
to DustinCampbell/roslyn
that referenced
this pull request
Apr 3, 2018
Since we're moving this type from Microsoft.CodeAnalysis.Workspaces.Desktop to Microsoft.CodeAnalysis.Workspaces, a type forward is required. There is currently a bug with the Public API analyzer with properties on forwarded types that I have to work around in the PublicAPI.Shipped.txt, but a fix is already out for that dotnet/roslyn-analyzers#1657. Once the analyzers are updated in the roslyn repo, this will get fixed.
sharwell
added a commit
to sharwell/PublicApiAnalyzer
that referenced
this pull request
Jan 7, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
During normal operation, properties are not added to the public API surface area because the analyzer does not register a symbol
action for
SymbolKind.Property. This works fine, there is an action registered forSymbolKind.Method, which ensures that gettersand setters are added as expected. Things are a bit different for forwarded types.
In the case of a forwarded type, the public API surface area is discovered by recursively searching members and nested types. However,
this code adds both properties and accessors, resulting in the PublicAPI.Shipped.txt file needs to include an entry for the property
and the accessors, like so:
This change fixes the analyzer to not consider property symbols when recursively searching through forwarded types. However, it still
considers their accessors.