Skip to content
This repository was archived by the owner on Apr 20, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</PropertyGroup>
<!-- Production Dependencies -->
<PropertyGroup>
<DotNetCoreSdkLKGVersion>3.0.100-preview5-011317</DotNetCoreSdkLKGVersion>
<DotNetCoreSdkLKGVersion>3.0.100-preview5-011462</DotNetCoreSdkLKGVersion>
<MicrosoftAspNetCoreDeveloperCertificatesXPlatPackageVersion>2.2.0</MicrosoftAspNetCoreDeveloperCertificatesXPlatPackageVersion>
<MicrosoftNETCoreDotNetHostResolverPackageVersion>2.2.1</MicrosoftNETCoreDotNetHostResolverPackageVersion>
<MicrosoftApplicationInsightsPackageVersion>2.0.0</MicrosoftApplicationInsightsPackageVersion>
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"tools": {
"dotnet": "3.0.100-preview5-011317"
"dotnet": "3.0.100-preview5-011462"
},
"msbuild-sdks": {
"Microsoft.DotNet.Arcade.Sdk": "1.0.0-beta.19218.1"
Expand Down
182 changes: 0 additions & 182 deletions src/dotnet/ToolManifest/ArrayBufferWriter.cs

This file was deleted.

11 changes: 6 additions & 5 deletions src/dotnet/ToolManifest/ToolManifestEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using NuGet.Versioning;
using System.Text.Json;
using System.Text;
using System.Buffers;

namespace Microsoft.DotNet.ToolManifest
{
Expand Down Expand Up @@ -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()
});
Expand Down Expand Up @@ -359,10 +361,9 @@ private class SerializableLocalToolsManifest

public string ToJson()
{
var state = new JsonWriterState(options: new JsonWriterOptions { Indented = true });
Copy link
Author

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!

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();

Expand Down Expand Up @@ -394,7 +395,7 @@ public string ToJson()

writer.WriteEndObject();
writer.WriteEndObject();
writer.Flush(true);
writer.Flush();

Choose a reason for hiding this comment

The 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);

Copy link
Author

Choose a reason for hiding this comment

The 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

Choose a reason for hiding this comment

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

I don't necessarily see why you wouldn't use Debug.Asserts to ensure things you expect to be invariant (just to catch possible oversight in source), but that's fine. Ideally this should be caught in your unit tests anyway.

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

Copy link

@ahsonkhan ahsonkhan Apr 19, 2019

Choose a reason for hiding this comment

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

Btw, for context, the reason why I brought it up is because Flush() doesn't guard against un-closed start object/array delimiters.

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());
}
Expand Down