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

Fix exception for non-cs/vb document #72677

Merged
merged 5 commits into from
Mar 24, 2024
Merged

Fix exception for non-cs/vb document #72677

merged 5 commits into from
Mar 24, 2024

Conversation

genlu
Copy link
Member

@genlu genlu commented Mar 22, 2024

No description provided.

@genlu genlu requested a review from a team as a code owner March 22, 2024 19:35
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Mar 22, 2024
var syntaxFacts = sourceDocument.GetRequiredLanguageService<ISyntaxFactsService>();
var containingMethod = syntaxFacts.GetContainingMethodDeclaration(root, range.Start, useFullSpan: false);
range = containingMethod?.Span ?? range;
if (sourceDocument.SupportsSyntaxTree)
Copy link
Member

Choose a reason for hiding this comment

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

i'd just move this above, and bail out immediately.

Copy link
Member Author

Choose a reason for hiding this comment

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

this is in case we want to support non cs/vb in roslyn workspace

Copy link
Member

Choose a reason for hiding this comment

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

so, i'm wary about thsi currently as i don't understand the semantics. specifically, what is hte impact of us passing in the full range of hte document into the methods you're calling.

Also, CodeFixService is firmly lang nutral. Any lang specific checks (like getting syntax facts, or asking about things like "the containzing method") need to move into a lang-specific api.

That way a langauge like xaml could do the same sort of thing. they need to be able to say "here's the span i want to limit myself to looking at".

Copy link
Member Author

@genlu genlu Mar 22, 2024

Choose a reason for hiding this comment

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

Make sense. How about we get this fix in to unblock insertion. I will follow up with a proper fix next.
Fixed in ed85d66

@genlu
Copy link
Member Author

genlu commented Mar 23, 2024

/azp run roslyn-CI

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

foreach (var diagnostic in diagnostics)
{
if (diagnostic.Location.SourceSpan.IntersectsWith(span.Value))
filteredDiagnostics.Add(diagnostic);
Copy link
Member

Choose a reason for hiding this comment

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

fine for now. but we really need this to be done through an ILangService so tha tthe language decides what span to be using instead. right now this is really just not the right way to encode this sort of concept into a feature.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

@genlu genlu enabled auto-merge March 23, 2024 00:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE 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.

3 participants