-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Support having a file be both a document and additional file. #20558
Support having a file be both a document and additional file. #20558
Conversation
…ditional documents
I recommend reading commit-by-commmit. Note that we can debate about whether the public API changes are warranted or not. |
Note: @davkean with this changed, if I renamed such a file in solution explorer in a CPS project I got tons of ugly exceptions from the project system... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd be up for debating the public API change. I get that the parameter was meaningless, but removing it seems an unnecessary binary breaking change.
var moniker = document.Key.Moniker; | ||
if (_documentMonikers.TryGetValue(moniker, out var value)) | ||
{ | ||
_documentMonikers[moniker] = (value.document, value.refCount++); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume the post-increment happens before the assignment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ugh. I'll separate it just to not have to think about this.
private void RemoveMoniker(IVisualStudioHostDocument document) | ||
{ | ||
var moniker = document.Key.Moniker; | ||
var value = _documentMonikers[moniker]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason to protect against the moniker not being in the Dictionary? If it's not, this will throw.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, the code previously just had _documentMonikers.Remove()
, which wouldn't throw. I'll guard.
Re: public API - going to take a look at removing all the internal bits, but leaving the public entry points with comments saying that they are ignored. I sort of agree that it's not worth breaking. |
Turns out we could end up with the same IVisualStudioHostDocument for both, if they are both added. Fixes dotnet#19968.
This is a breaking API change. Need to decide if we want to take it or not.
81bc054
to
818b0a7
Compare
@DustinCampbell care to take another look? Also - do you think I should squash the last two commits? |
@Pilchie What kind of ugly errors? |
Oh you mean if you renamed a file that was both a compile and additional file you got ugly errors? ie Not a regression introduced by this change? |
@davkean Right - with this change, if you F2 and rename a file in solution explorer that is both source and additional files there are a bunch of exceptions from the project system about the tree not being consistent. |
retest windows_debug_vs-integration_prtest please |
Hit the vsix installer error. |
Tagging @MattGertz for approval here. |
retest windows_debug_vs-integration_prtest please |
retest windows_debug_vs-integration_prtest please |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The overall approach seems sound. Some detail questions about the deprecated parameter (the comment doesn't make sense to me) and other questions.
/// Puts the specified additional document into the open state. | ||
/// </summary> | ||
/// <param name="documentId">The <see cref="DocumentId"/> to open.</param> | ||
/// <param name="activate">Ignored - not necessary for additional documents.</param> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't the statement for the param here more "this doesn't matter in the preview workspace?"
} | ||
|
||
UninitializeAdditionalDocument(document); | ||
} | ||
|
||
private void AddMoniker(IVisualStudioHostDocument document) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"AddToMonikerToDocumentMap"?
if (_documentMonikers.TryGetValue(moniker, out var value)) | ||
{ | ||
value.refCount++; | ||
_documentMonikers[moniker] = (value.document, value.refCount); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I must admit: using tuples here seems really terrifying and really likely to make a mistake....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't the right hand side just be "value" since you already have the tuple in hand though?
} | ||
else | ||
{ | ||
_documentMonikers[moniker] = (value.document, value.refCount); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't the right hand side just be "value" since you already have the tuple in hand though?
retest windows_debug_vs-integration_prtest please |
A bunch of tests failed in https://ci.dot.net/job/dotnet_roslyn/job/dev15.3.x/job/windows_debug_vs-integration_prtest/15/ with remoting exceptions. |
retest windows_debug_vs-integration_prtest please |
…-DuplicateSourceAndAdditionalFiles-DistinctIds"" This reverts commit d03cde8.
Ask Mode
Customer scenario
If a single filepath is included in both the
Compile
and theAdditionalFiles
item groups, the project system would fail to add the second of those two, and throw, leaving things in a bad state. In the legacy project system, that seemed to be caught and ignored, and likely you just didn't have the AdditionalFile in your compilations. In CPS a dialog would be displayed, and the file would end up in Miscellaneous files (however, this can happen during a transient state in CPS due to it's async nature). In Lightweight solution load, VS would crash.Bugs this fixes: Fixes #19968
Workarounds, if any: Not have the item in both
Compile
andAdditionalFiles
. Hard, because they may not realize they do, or it may be a transient case in CPS.Risk: Medium - plumbs through new ids for additional items, etc.
Performance impact: Low - most significant change is ref counting instead of mere entry in a dictionary.
Is this a regression from a previous update?: No, this behavior has been since additional files were added.
Root cause analysis:: We never expected an item to be in both groups.
How was the bug found?: Customers reported files ending up in "Miscellaneous files" in CPS after changing the build action.