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

Check Saved on ProjectItem before calling Save #46393

Merged

Conversation

ryzngard
Copy link
Contributor

@ryzngard ryzngard commented Jul 28, 2020

If a ProjectItem is retrieved but has no Document property, calling Save throws a NRE. Add a check in ApplyDocumentInfoChanged if the item needs to be saved before doing so.

Fixes #46192

@davidwengier
Copy link
Contributor

Why not check the Document property, if thats the trigger for the NFE? Or does checking it cause the same NFE?

@ryzngard
Copy link
Contributor Author

Why not check the Document property, if thats the trigger for the NFE? Or does checking it cause the same NFE?

That's hypothetical on my end. I'm digging in to get a better stack and find out.

@ryzngard ryzngard changed the base branch from master to release/dev16.8-preview1 July 28, 2020 22:38
@ryzngard ryzngard requested review from a team as code owners July 28, 2020 22:38
if (!projectItemForDocument.Saved)
{
projectItemForDocument.Save();
}
Copy link
Member

Choose a reason for hiding this comment

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

@jasonmalinowski are you familiar with this space at all?

Copy link
Member

Choose a reason for hiding this comment

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

Not really. Chatting with @ryzngard privately it looks like this is an exception being thrown out of CPS, and thus is a CPS bug that it's throwing a null ref. @ryzngard is still investigating further.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I do believe we can do this as a workaround for now

Copy link
Member

Choose a reason for hiding this comment

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

So looking at the internal bug I think it's still not clear (at least to me) why this works because we don't quite understand what's throwing in the first place. If the project system folks think this is good enough then I'm OK with it.

I would however like it if we can update this code here to say it's a workaround and include the link to the bug so we can at least have some understanding of why it's here, and can perhaps remove it some day.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added comment and link to tracking bug

if (!projectItemForDocument.Saved)
{
projectItemForDocument.Save();
}
Copy link
Member

Choose a reason for hiding this comment

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

So looking at the internal bug I think it's still not clear (at least to me) why this works because we don't quite understand what's throwing in the first place. If the project system folks think this is good enough then I'm OK with it.

I would however like it if we can update this code here to say it's a workaround and include the link to the bug so we can at least have some understanding of why it's here, and can perhaps remove it some day.

@ghost
Copy link

ghost commented Jul 29, 2020

Hello @ryzngard!

Because this pull request has the auto-merge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Auto-approval

@ghost ghost merged commit f364b63 into dotnet:release/dev16.8-preview1 Jul 29, 2020
ryzngard pushed a commit to ryzngard/roslyn that referenced this pull request Oct 2, 2020
…name

Check `Saved` on ProjectItem before calling Save
ryzngard added a commit that referenced this pull request Oct 12, 2020
Merge pull request #46393 from ryzngard/issue/46192_nre_save_rename
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NullPointerException thrown when renaming class together with symbol's file
6 participants