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

Forgot to escape JSON string output #4280

Merged
merged 1 commit into from
Aug 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/Generators/Microsoft.Gen.ComplianceReports/Emitter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,10 @@ private void OutArray(string name, Action action)

private void OutNameValue(string name, string value)
{
value = value
Copy link
Member

Choose a reason for hiding this comment

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

Why not use JsonSerializer.Serialize(value) ?

Copy link
Contributor

Choose a reason for hiding this comment

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

IIRC Generators can't reference packages (e.g. System.Text.Json). @geeknoid, is that correct?

Copy link
Member

Choose a reason for hiding this comment

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

And they target NS2.0, so that wouldn't be possible, ok.

Copy link
Member Author

Choose a reason for hiding this comment

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

That's what I thought until a few minutes ago. Someone just sent me https://github.com/dotnet/roslyn/blob/main/docs/features/source-generators.cookbook.md#use-functionality-from-nuget-packages which shows the MSBuild magic to make this happen.

I'll create an issue to track upgrading to that approach.

.Replace("\\", "\\\\")
.Replace("\"", "\\\"");

NewItem();
OutIndent();
Out($"\"{name}\": \"{value}\"");
Expand Down
Loading