-
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
Cloning DocumentId
results in impossibility to get the valid result of GetSourceGeneratedDocumentAsync
#71581
Comments
Can you clarify this? |
Note: the design here was intentional. No other parties can make source-generated-docs, so there should be no need to create the IDs for them. I too would need more info on why cloning is needed or is happening. |
working with codelenses inside VSIX means one need to serialize data between processes (main VS process, and some codelens process, I don't know details), so project guid and document guid from "valid" There is also some theoretical (at now) scenarios where do I provide enough details? if no, please, give me a hint what you want to know exactly! could I ask for explanation for the following question: source generated documents are here for years, and they will not disappear, it is big part of Roslyn ecosystem and we all are happy to see it; so, why they are not a part of public API? why Roslyn team do not want to see it as a part of public API? we are talking about one Thanks! |
The issue I described is a real issue for my VSIX https://github.com/lsoft/SyncToAsyncExtension. |
@CyrusNajmabadi We need default the This is a 17.8 regression introduced by #69952. |
Because this may not be the representation we want in the future. Making something public means we cannot change it. |
I don't think this is appropriate. What we could do is make the internal representation tri-state. So the existing constructors would say "I don't know" (versus saying that it actually is a generated document). |
I understand this. But please take a look at this topic from the user's persprective. From user's perspective, user need to grab a var document = project.GetDocument(
documentId
);
if(document != null)
{
return document;
}
document = (await project.GetSourceGeneratedDocumentsAsync(CancellationToken.None))
.First(d => d.Id.Equals(documentId));
return document; after fixing this issue this code will be transformed into the following: var document = project.GetDocument(
documentId
);
if(document != null)
{
return document;
}
document = (await project.GetSourceGeneratedDocumentAsync(documentId, CancellationToken.None);
return document; but having if(!documentId.IsSourceGenerated)
return project.GetDocument(
documentId
);
else
return (await project.GetSourceGeneratedDocumentAsync(documentId, CancellationToken.None); This is, probably, good. |
@lsoft i'm not saying i don't get the use cases. I'm saying that public APIs come with significant costs. Especially in the case where we decide later it's not the representation we want. As an internal API we can trivially change things, as a public API, it is much much harder. :) |
I'm amenable to do this in two phases. Revert the regression (by making the existing constructor initialize things in a tri-state). Then in the future decide on a public, supported, representation. |
Version Used: Latest.
Steps to Reproduce:
DocumentId
of source-generated document.GetSourceGeneratedDocumentAsync
returns a valid SG-document with thisDocumentId
.DocumentId
via public-available constructors. (this is inevitable in some scenarios, like working with VS codelenses).GetSourceGeneratedDocumentAsync
returnsnull
.I suspect it is because
DocumentId.IsSourceGenerated
is internal, and cannot be set outside of Roslyn.Workaround exists:
(await project.GetSourceGeneratedDocumentsAsync(CancellationToken.None).First(d => d.Id.Equals(clonedDocumentId));
. But it is a VERY VERY confusion behavior.Expected Behavior:
Cloning
DocumentId
does not breakGetSourceGeneratedDocumentAsync
.Actual Behavior:
GetSourceGeneratedDocumentAsync
returnsnull
.The text was updated successfully, but these errors were encountered: