8000 Simplify access to the SemanticModel in analyzers by meziantou · Pull Request #1167 · spectreconsole/spectre.console · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Simplify access to the SemanticModel in analyzers #1167

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

Merged
merged 1 commit into from
Mar 13, 2023
Merged

Simplify access to the SemanticModel in analyzers #1167

merged 1 commit into from
Mar 13, 2023

Conversation

meziantou
Copy link
Contributor

No description provided.

#pragma warning disable RS1030 // Do not invoke Compilation.GetSemanticModel() method within a diagnostic analyzer
var model = context.Compilation.GetSemanticModel(context.Operation.Syntax.SyntaxTree);
#pragma warning restore RS1030 // Do not invoke Compilation.GetSemanticModel() method within a diagnostic analyzer
var model = context.Operation.SemanticModel!;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

According to the doc it is safe to consider the SemanticModel to be non-null

documentation

Optional semantic model that was used to generate this operation. Non-null for operations generated from source with GetOperation(SyntaxNode, CancellationToken) API and operation callbacks made to analyzers. Null for operations inside a ControlFlowGraph.

@meziantou meziantou marked this pull request as ready for review February 19, 2023 18:56
@patriksvensson
Copy link
Contributor

@phil-scott-78 Do you have time to look at this?

@phil-scott-78
Copy link
Contributor

If @meziantou submitted it, then I'll probably learn something cool - so, of course! I'll carve out time tonight

@meziantou
Copy link
Contributor Author

If @meziantou submitted it, then I'll probably learn something cool - so, of course! I'll carve out time tonight

I don't think there is a lot to learn from this PR, but I hope you'll like the next one #1169 😉

@meziantou
Copy link
Contributor Author

@phil-scott-78 Have you got time to review this PR? (and others small PRs I've opened)

@phil-scott-78
Copy link
Contributor

absolutely. thanks for the nudge, would have missed them otherwise.

@phil-scott-78 phil-scott-78 merged commit 142942b into spectreconsole:main Mar 13, 2023
@meziantou meziantou deleted the simplify-semanticmodel branch March 13, 2023 23:59
@phil-scott-78
Copy link
Contributor

I think we got them all! Thanks @meziantou!

@meziantou
Copy link
Contributor Author

That was fast 🚀
Thanks!

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.

3 participants
0