Skip to content

Conversation

@jcouv
Copy link
Member

@jcouv jcouv commented Aug 24, 2020

Fixes #47093
Fixes #47092

F.WellKnownMethod(WellKnownMember.System_Text_StringBuilder__AppendObject),
F.Convert(F.SpecialType(SpecialType.System_Object), value))));
Debug.Assert(value.Type is not null);
if (value.Type.IsValueType)
Copy link
Member

@CyrusNajmabadi CyrusNajmabadi Aug 24, 2020

Choose a reason for hiding this comment

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

does this work for thigns like where T : struct type parameters? #Resolved

Copy link
Member Author

@jcouv jcouv Aug 24, 2020

Choose a reason for hiding this comment

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

@jcouv jcouv marked this pull request as ready for review August 25, 2020 01:41
@jcouv jcouv requested a review from a team as a code owner August 25, 2020 01:41
// builder.Append(<name>);
// builder.Append(" = ");
// builder.Append((object)<value>);
// builder.Append(<value>.ToString()); OR builder.Append(<value>.ToString());
Copy link
Contributor

@cston cston Aug 25, 2020

Choose a reason for hiding this comment

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

.ToString() [](start = 77, length = 18)

(object)<value> #Closed


// this.print(builder);
block.Add(F.ExpressionStatement(F.Call(F.This(), _printMethod, builderLocal)));
// if (this.print(builder)) builder.Append(" ");
Copy link
Contributor

@cston cston Aug 25, 2020

Choose a reason for hiding this comment

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

// if (this.print(builder)) builder.Append(" "); [](start = 16, length = 48)

If PrintMembers() is only used internally, to implement ToString(), could this if (this.print(builder)) be removed and simply have PrintMembers() add a " " before each member? #ByDesign

Copy link
Contributor

@cston cston Aug 25, 2020

Choose a reason for hiding this comment

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

could this if (this.print(builder)) be removed and simply have PrintMembers() add a " " before each member?

Given that PrintMembers() or ToString() can be implemented explicitly, it seems either conditionally adding a trailing space here, or requiring a leading space before each member, will make one of the two methods somewhat awkward.


In reply to: 476183479 [](ancestors = 476183479)

Copy link
Member

Choose a reason for hiding this comment

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

I feel like the simpler implementation, for both us and consumers, is to just require a leading space in front of all members. Then there's no conditionals or questions.


In reply to: 476188140 [](ancestors = 476188140,476183479)

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it's more regular to let the caller of PrintMembers to deal with the returned bool and using it to print the separators. We do that for printing the comma separator; the space separator should be no different.


In reply to: 476650024 [](ancestors = 476650024,476188140,476183479)


// this.print(builder);
block.Add(F.ExpressionStatement(F.Call(F.This(), _printMethod, builderLocal)));
// if (this.print(builder)) builder.Append(" ");
Copy link
Contributor

@cston cston Aug 25, 2020

Choose a reason for hiding this comment

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

print [](start = 28, length = 5)

Consider using this.PrintMembers explicitly in the comment. #Closed

@cston
Copy link
Contributor

cston commented Aug 25, 2020

/// The `bool PrintMembers(StringBuilder)` method is responsible for printing members declared

Should PrintMembers() be called AppendMembers() (since it appends to a builder rather than printing)? #ByDesign


Refers to: src/Compilers/CSharp/Portable/Symbols/Synthesized/Records/SynthesizedRecordPrintMembers.cs:16 in 9fb3f77. [](commit_id = 9fb3f77, deletion_comment = False)

@jcouv
Copy link
Member Author

jcouv commented Aug 25, 2020

Should PrintMembers() be called AppendMembers() (since it appends to a builder rather than printing)?

I don't think we can change the name now, as RC1 locks the public contract for records. #ByDesign

@jcouv jcouv requested a review from cston August 25, 2020 18:11
// builder.Append(<name>);
// builder.Append(" = ");
// builder.Append((object)<value>);
// builder.Append((object)<value>); OR builder.Append(<value>.ToString());
Copy link
Member

@333fred 333fred Aug 25, 2020

Choose a reason for hiding this comment

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

Consider clarifying when the OR applies. #Closed

@333fred
Copy link
Member

333fred commented Aug 25, 2020

Done review pass (commit 5)

@RikkiGibson
Copy link
Member

FYI, the correctness failure has been fixed in the base branch.

Copy link
Member

@333fred 333fred left a comment

Choose a reason for hiding this comment

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

LGTM (commit 6)

@jcouv jcouv merged commit 62d0895 into dotnet:master Aug 26, 2020
@ghost ghost added this to the Next milestone Aug 26, 2020
@jcouv jcouv deleted the record-tweaks2 branch August 26, 2020 18:42
333fred added a commit to 333fred/roslyn that referenced this pull request Aug 27, 2020
…-only-errors

* upstream/master: (236 commits)
  Fix bug when "End statement" is used in single-line if (dotnet#47062)
  Solution asset cache refactoring (dotnet#46948)
  add specific tests to validate behavior between keys and snapshots
  Extract into separate files
  rename parameters
  rename parameters
  rename parameters
  rename parameters
  Add CancellationToken parameters to SyntaxTreeOptionsProvider
  Reuse nullable override checks for delegate conversions (dotnet#46953)
  Introduce warning for multiple entry points (sync + async) (dotnet#46832)
  Switch from throwing NotImplementedException and return E_NOTIMPL
  Delete Building for Core CLR.md (dotnet#47146)
  Adjust PrintMembers to avoid boxing and avoid extra space (dotnet#47095)
  Track asynchronous operation in InProcLanguageServer
  Use Task.FromCanceled where appropriate
  Apply suggestions from code review
  Address feedback
  Expose ParseOptions on generator context (dotnet#46919)
  Remove redundant statement in added tests
  ...
@allisonchou allisonchou removed this from the Next milestone Aug 31, 2020
@allisonchou allisonchou added this to the 16.8.P3 milestone Aug 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Empty record should print with single space between braces Record's PrintMembers method should avoid boxing values

6 participants