Annotate more CodeAnalysis and CodeAnalysis.CSharp public types#43025
Annotate more CodeAnalysis and CodeAnalysis.CSharp public types#43025jcouv merged 20 commits intodotnet:masterfrom
Conversation
|
@dotnet/roslyn-compiler for review. Thanks #Resolved |
| /// <summary> | ||
| /// Attaches the node to a SyntaxTree that the same options as <paramref name="oldTree"/> | ||
| /// </summary> | ||
| [return:NotNullIfNotNull("node")] |
There was a problem hiding this comment.
Should this imply that node should be annotated? #Closed
| { | ||
| if (child.IsNode) | ||
| { | ||
| var d = child.AsNode().GetLastDirective(predicate); |
There was a problem hiding this comment.
Do you think it's worth adding an extension method for this pattern with an out? #Resolved
There was a problem hiding this comment.
Debated it, but Jared didn't introduce such pattern for most syntax changes he made. I'll stay with existing pattern.
In reply to: 405830860 [](ancestors = 405830860)
There was a problem hiding this comment.
I definitely didn't use that pattern when I was first exploring annotating syntax. I was more getting used to the feature and didn't wan to change as much around it while I was annotating. Now though I'm more comfortable with that type of change and if we have a handy helper would opt for using it. #Resolved
There was a problem hiding this comment.
We don't have a helper yet. Would rather keep that separate.
In reply to: 414137782 [](ancestors = 414137782)
There was a problem hiding this comment.
Oh, actually, we do have AsNode(out ...). I'll use that
In reply to: 414179069 [](ancestors = 414179069,414137782)
| /// <param name="cancellationToken">A cancellation token for the search.</param> | ||
| /// <returns>A DocumentationComment.</returns> | ||
| protected internal abstract string GetDocumentationForSymbol( | ||
| protected internal abstract string? GetDocumentationForSymbol( |
There was a problem hiding this comment.
string? [](start = 36, length = 7)
Man, this API is a real victim of lack of NRT. Some implementations return string.Empty when nothing is there, some return null. #WontFix
| lazyLocalDiagnostics = lazyLocalDiagnostics ?? new Dictionary<SyntaxTree, Dictionary<DiagnosticAnalyzer, ImmutableArray<Diagnostic>.Builder>>(); | ||
|
|
||
| foreach (var diagsByTree in diagnostics.GroupBy(d => d.Location.SourceTree)) | ||
| foreach (var diagsByTree in diagnostics.GroupBy(d => d.Location.SourceTree!)) |
| private WrappedValue ComputeValue(TKey key) | ||
| { | ||
| var value = _computeValue(key); | ||
| return new WrappedValue { Value = value }; |
There was a problem hiding this comment.
First time I've seen us fall victim to this pattern. #Closed
|
|
||
| internal static XmlNameAttributeElementKind GetElementKind(this XmlNameAttributeSyntax attributeSyntax) | ||
| { | ||
| RoslynDebug.Assert(attributeSyntax.Parent is object); |
There was a problem hiding this comment.
Shouldn't be necessary. #Closed
There was a problem hiding this comment.
Will switch to to Debug.Assert (assuming that's what you meant)
In reply to: 405844872 [](ancestors = 405844872)
|
Done review pass (commit 13) #Resolved |
|
@333fred @dotnet/roslyn-compiler Please take another look. Thanks #Resolved |
|
Looks like there's a newly introduced warning though. #Resolved |
|
Yeah, I'll merge with latest master and resolve, but only after the review as some tools (cough CodeFlow) don't handle merge commits well ;-) #Resolved |
| case SyntaxKind.BaseConstructorInitializer: | ||
| case SyntaxKind.ThisConstructorInitializer: | ||
| var init = (ConstructorInitializerSyntax)original.Syntax; | ||
| Debug.Assert(init.Parent is object); |
There was a problem hiding this comment.
Confused why this would be necessary but the line above was able to cast without adding a ? to the type. If init was indeed maybe null here I would expect that the type cast above would have to say that as well. #Resolved
There was a problem hiding this comment.
The problem is not that init is maybe-null, but that init.Parent is.
In reply to: 414135650 [](ancestors = 414135650)
| _name = declaratorSyntax.Identifier.ValueText; | ||
|
|
||
| var declaratorDiagnostics = DiagnosticBag.GetInstance(); | ||
| Debug.Assert(declaratorSyntax.Parent is object); |
There was a problem hiding this comment.
Consider moving this Debug.Assert to the top of the method body as it's effectively a pre-condition for the method itself, not this specific point in the method. #Resolved
| { | ||
| if (child.ContainsDirectives) | ||
| { | ||
| if (child.IsNode) |
There was a problem hiding this comment.
Consider using child.AsNode(out var node) here to avoid the ! below. #Resolved
| { | ||
| if (child.IsNode) | ||
| { | ||
| var d = child.AsNode().GetLastDirective(predicate); |
There was a problem hiding this comment.
I definitely didn't use that pattern when I was first exploring annotating syntax. I was more getting used to the feature and didn't wan to change as much around it while I was annotating. Now though I'm more comfortable with that type of change and if we have a handy helper would opt for using it. #Resolved
No description provided.