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

[VS Code] Fix project.razor.json serialization issue #8489

Merged
merged 2 commits into from
Mar 23, 2023

Conversation

allisonchou
Copy link
Contributor

Summary of the changes

  • We were throwing an exception in VS Code with project.razor.json files because we were trying to serialize the project snapshot when we should have been serializing the ProjectRazorJson type. We used to do this correctly but it seems this behavior was somehow changed in External access #8046 (Ryan's parting gift to us 😄 )

@allisonchou allisonchou requested a review from a team as a code owner March 22, 2023 19:55
Copy link
Contributor

@ryzngard ryzngard left a comment

Choose a reason for hiding this comment

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

As with most things, would love some sort of test for this :)

@@ -94,7 +95,8 @@ protected virtual void SerializeToFile(OmniSharpProjectSnapshot projectSnapshot,
// by the time we move the tempfile into its place
using (var writer = tempFileInfo.CreateText())
{
_serializer.Serialize(writer, projectSnapshot);
var projectRazorJson = new ProjectRazorJson(publishFilePath, projectSnapshot.InternalProjectSnapshot);
Copy link
Contributor

Choose a reason for hiding this comment

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

❓is there ever a time when serializing the snapshot is correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It results in a circular dependency, so I don't think so (or at least not any scenario I can think of)

// Licensed under the MIT license. See License.txt in the project root for license information.

using System.Runtime.CompilerServices;

[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Razor.OmniSharpPlugin, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")]
Copy link
Contributor

Choose a reason for hiding this comment

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

This should go too. Anything OmniSharpPlugin needs from this project can just be public in this project

@allisonchou
Copy link
Contributor Author

Thanks for the reviews and feedback Andrew and David! @davidwengier could I get another look at this?

@allisonchou allisonchou enabled auto-merge (squash) March 23, 2023 04:18
@allisonchou allisonchou merged commit d26d207 into main Mar 23, 2023
@allisonchou allisonchou deleted the allichou/FixProjectJsonVSCode branch March 23, 2023 04:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants