Skip to content
This repository was archived by the owner on Apr 20, 2023. It is now read-only.

Conversation

@wli3
Copy link

@wli3 wli3 commented Apr 19, 2019

No description provided.


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!

@wli3 wli3 requested a review from dsplaisted April 19, 2019 02:39
@wli3
Copy link
Author

wli3 commented Apr 19, 2019

@dsplaisted I find s.t.json api breaking change at the same time, but this should prove our original bug is not longer repro

@wli3
Copy link
Author

wli3 commented Apr 19, 2019

@johnbeisner could you look at "F:\workspace_work\1\s.dotnet\sdk\3.0.100-preview5-011462\Microsoft.Common.CurrentVersion.targets(4552,5): error MSB3030: Could not copy the file "F:\workspace_work\1\s.dotnet\sdk\3.0.100-preview5-011317.version" because it was not found." error?

Sorry nvm. I forget to update LKG version

Copy link

@ahsonkhan ahsonkhan left a comment

Choose a reason for hiding this comment

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

Looks good to me.

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.

@wli3 wli3 mentioned this pull request Apr 19, 2019
@johnbeisner
Copy link

LGTM

@wli3 wli3 merged commit 6487f2f into dotnet:master Apr 19, 2019
@wli3 wli3 deleted the update-stage0 branch April 19, 2019 16:31
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants