-
Notifications
You must be signed in to change notification settings - Fork 1k
Update stage 0 and adjust to s.t.json api #11193
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,7 @@ | |
| using NuGet.Versioning; | ||
| using System.Text.Json; | ||
| using System.Text; | ||
| using System.Buffers; | ||
|
|
||
| namespace Microsoft.DotNet.ToolManifest | ||
| { | ||
|
|
@@ -75,7 +76,8 @@ public void Add( | |
|
|
||
| deserializedManifest.Tools.Add( | ||
| new SerializableLocalToolSinglePackage | ||
| { PackageId = packageId.ToString(), | ||
| { | ||
| PackageId = packageId.ToString(), | ||
| Version = nuGetVersion.ToNormalizedString(), | ||
| Commands = toolCommandNames.Select(c => c.Value).ToArray() | ||
| }); | ||
|
|
@@ -359,10 +361,9 @@ private class SerializableLocalToolsManifest | |
|
|
||
| public string ToJson() | ||
| { | ||
| var state = new JsonWriterState(options: new JsonWriterOptions { Indented = true }); | ||
| using (var arrayBufferWriter = new ArrayBufferWriter<byte>()) | ||
| var arrayBufferWriter = new ArrayBufferWriter<byte>(); | ||
| using (var writer = new Utf8JsonWriter(arrayBufferWriter, new JsonWriterOptions { Indented = true })) | ||
| { | ||
| var writer = new Utf8JsonWriter(arrayBufferWriter, state); | ||
|
|
||
| writer.WriteStartObject(); | ||
|
|
||
|
|
@@ -394,7 +395,7 @@ public string ToJson() | |
|
|
||
| writer.WriteEndObject(); | ||
| writer.WriteEndObject(); | ||
| writer.Flush(true); | ||
| writer.Flush(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: add the following after the call to flush, if you want to be super paranoid (but it isn't necessary). Debug.Assert(writer.CurrentDepth == 0);
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! I try to minimize debug vs release difference. So I will just keep it like that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't necessarily see why you wouldn't use It's already used all over the place in this repo, which is expected. https://github.com/dotnet/cli/search?q=debug.assert&unscoped_q=debug.assert There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Btw, for context, the reason why I brought it up is because So you could have done write.StartObject and then forget to call write.EndObject. Adding such a debug.assert just validates correct depth for you and would catch accidental missing calls (especially if you pass the writer along and have deeper call graphs). FWIW. |
||
|
|
||
| return Encoding.UTF8.GetString(arrayBufferWriter.WrittenMemory.ToArray()); | ||
| } | ||
|
|
||
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.
@ahsonkhan i need to get this in by the end of friday. Hope you can look at it soon. Thanks!