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

Remove potential partial snapshot in codefixservice #59586

Merged
merged 5 commits into from
Feb 17, 2022

Conversation

CyrusNajmabadi
Copy link
Member

Followup to #59582

@CyrusNajmabadi CyrusNajmabadi marked this pull request as ready for review February 16, 2022 22:40
@CyrusNajmabadi
Copy link
Member Author

@jasonmalinowski @mavasani this is ready to review.

// Note: it feels very strange that we could ever not find a fixer in our list. However, this
// occurs in testing scenarios. I'm not sure if the tests represent a bogus potential input, or if
// this is something that can actually occur in practice and we want to keep working.
return null;
Copy link
Member Author

Choose a reason for hiding this comment

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

@mavasani for thoughts on this. Specifically, if i throw here, tests in CodeFixService tests fail. but i think they're likely constructing this service wrong.

Copy link
Member Author

Choose a reason for hiding this comment

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

for example it does:

            var fixService = new CodeFixService(
                diagnosticService, logger, fixers, SpecializedCollections.EmptyEnumerable<Lazy<IConfigurationFixProvider, CodeChangeProviderMetadata>>());

So we have a list of fixers, but no metadata about htem. i can't tell if htis is a reasonable or rational think that coudl actually happen in practice.

Copy link
Contributor

Choose a reason for hiding this comment

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

Do you recall which tests were failing? From what I vaguely recall, we had some scenario where if a code fixer throws some exception during creation due to some missing types or something, we wouldn't be able to create an instance of the fixer, and had to handle this error case with nulls. I am wondering if the failures you saw were coming from tests explicitly validating exception during fixer creation.

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah, it was tests in CodeFixServiceTets. THere we manually instnatiated some test-only CodeFixProviders, then instantiated the CodeFixService. But we passed along an empty metadata-array, presumably because we didn't care in those tests and the code was resilient to not having it. But i can't tell if that's a real scenario taht occurs in practice.

Copy link
Member

@jasonmalinowski jasonmalinowski left a comment

Choose a reason for hiding this comment

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

That lazy that this is getting rid of seemed hugely sketchy, in that it assumed that when it's realized all the fixers must have been realized; this is a lot more explicit that it's safe to skip the uncreated lazies since we couldn't have gotten the fixer any other way.

I agree with you that "return null" looks fishy for those tests, but would defer to @mavasani for what to do there.

@CyrusNajmabadi CyrusNajmabadi merged commit 46beb84 into dotnet:main Feb 17, 2022
@ghost ghost added this to the Next milestone Feb 17, 2022
@CyrusNajmabadi CyrusNajmabadi deleted the partialSnapshot branch February 17, 2022 02:22
@RikkiGibson RikkiGibson modified the milestones: Next, 17.2.P2 Mar 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants