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

Add AdditionalTextValueProvider<TValue> #68092

Merged
merged 1 commit into from
May 9, 2023

Conversation

CyrusNajmabadi
Copy link
Member

Fixes #67611

This API acts the same as the existing SyntaxTreeValueProvider and SourceTextValueProvider. These helpers allow diagnostic analzyers to cache data associated with a particular tree, 'source text', and now 'additional text', ensuring that they don't have to recompute that same data across analysis calls if the associated item is unchanged.

This helps analyzers avoid having to figure out how to do this themselves (including having to go down potentially problematic paths, like managing their own conditional weak tables).

@CyrusNajmabadi CyrusNajmabadi requested review from a team as code owners May 4, 2023 17:36
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Analyzers untriaged Issues and PRs which have not yet been triaged by a lead labels May 4, 2023
@CyrusNajmabadi
Copy link
Member Author

@dotnet/roslyn-compiler ptal. This was approved in last API review meeting.

@CyrusNajmabadi
Copy link
Member Author

Ping @dotnet/roslyn-compiler . Simple PR :)

@@ -1,6 +1,11 @@
*REMOVED*static Microsoft.CodeAnalysis.SeparatedSyntaxList<TNode>.implicit operator Microsoft.CodeAnalysis.SeparatedSyntaxList<TNode!>(Microsoft.CodeAnalysis.SeparatedSyntaxList<Microsoft.CodeAnalysis.SyntaxNode!> nodes) -> Microsoft.CodeAnalysis.SeparatedSyntaxList<TNode!>
*REMOVED*static Microsoft.CodeAnalysis.SyntaxList<TNode>.implicit operator Microsoft.CodeAnalysis.SyntaxList<TNode!>(Microsoft.CodeAnalysis.SyntaxList<Microsoft.CodeAnalysis.SyntaxNode!> nodes) -> Microsoft.CodeAnalysis.SyntaxList<TNode!>
Microsoft.CodeAnalysis.Compilation.SupportsRuntimeCapability(Microsoft.CodeAnalysis.RuntimeCapability capability) -> bool
Microsoft.CodeAnalysis.Diagnostics.AdditionalTextValueProvider<TValue>
Microsoft.CodeAnalysis.Diagnostics.AdditionalTextValueProvider<TValue>.AdditionalTextValueProvider(System.Func<Microsoft.CodeAnalysis.AdditionalText!, TValue>! computeValue, System.Collections.Generic.IEqualityComparer<Microsoft.CodeAnalysis.AdditionalText!>? additionalTextComparer = null) -> void
Microsoft.CodeAnalysis.Diagnostics.AnalysisContext.TryGetValue<TValue>(Microsoft.CodeAnalysis.AdditionalText! text, Microsoft.CodeAnalysis.Diagnostics.AdditionalTextValueProvider<TValue>! valueProvider, out TValue value) -> bool
Copy link
Member

Choose a reason for hiding this comment

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

AnalysisContext.TryGetValue(Microsoft.CodeAnalysis.AdditionalText! text, Microsoft.CodeAnalysis.Diagnostics.AdditionalTextValueProvider! valueProvider, out TValue value)

It looks like this method was not included in the API review. Was that just an oversight?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. The clear intent (and approval from api review) was simply that thsi mirror the existing SyntaxTree/SourceText providers, which this falls under.

@CyrusNajmabadi
Copy link
Member Author

@dotnet/roslyn-compiler for another pair of eyes please.

@CyrusNajmabadi
Copy link
Member Author

@dotnet/roslyn-compiler @333fred ptal.

@CyrusNajmabadi CyrusNajmabadi merged commit e6655da into dotnet:main May 9, 2023
@CyrusNajmabadi CyrusNajmabadi deleted the additionalTextProvider branch May 9, 2023 18:02
@ghost ghost added this to the Next milestone May 9, 2023
@Cosifne Cosifne modified the milestones: Next, 17.7 P2 May 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Analyzers untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add AdditionalTextValueProvider<TValue>
4 participants