Skip to content

Allow generate ctor intent to specify accessibility#59730

Merged
JoeRobich merged 9 commits intodotnet:release/dev17.2from
dibarbet:intellicode_accessibility
Mar 3, 2022
Merged

Allow generate ctor intent to specify accessibility#59730
JoeRobich merged 9 commits intodotnet:release/dev17.2from
dibarbet:intellicode_accessibility

Conversation

@dibarbet
Copy link
Copy Markdown
Member

Fixes issue where the generation would overwrite the typed accessibility.

Commit at a time recommended - the first commit just nullable enables a file.

@dibarbet dibarbet requested a review from a team as a code owner February 24, 2022 04:41
@dibarbet
Copy link
Copy Markdown
Member Author

cc @pgroene

}";

// lang=json
var intentData = @"{ ""Accessibility"": ""Private""}";
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

lower case because it is json?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Accessibility? desiredAccessibility = null;
if (serializedIntentData != null)
{
var intentData = JsonSerializer.Deserialize<GenerateConstructorIntentData>(serializedIntentData, _jsonSerializerOptions);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It feels like a leaky abstraction to have this know about json deserialization etc. Is it overkill to have an IntentDeserializer service that hides the json bits? Or can this be moved up to a higher level (I admit I haven't looked to see where serializedIntentData comes from)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think this is better - lmk!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, nice one

@dibarbet dibarbet force-pushed the intellicode_accessibility branch from b3f6df2 to 20112b9 Compare February 24, 2022 22:21
}";

// lang=json
var intentData = @"{ ""accessibility"": ""private""}";
Copy link
Copy Markdown
Member Author

@dibarbet dibarbet Feb 24, 2022

Choose a reason for hiding this comment

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

by the way syntax highlighting for this is great, thanks @CyrusNajmabadi
Now I just need raw strings to get rid of those extra "

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

:)

{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
};
_serializerOptions.Converters.Add(new JsonStringEnumConverter(JsonNamingPolicy.CamelCase));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

one concern i have is how are json exceptions handled when you use this? i think we need to presume the data may not be well formed, and we should be resilient to that.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done - added a report and catch to the deserialization path so that we know when it goes wrong. Since intellicode is providing the json, we definitely want to be notified if it is malformed.

Copy link
Copy Markdown
Contributor

@CyrusNajmabadi CyrusNajmabadi left a comment

Choose a reason for hiding this comment

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

tentative approval with review feedback handled.

@dibarbet dibarbet changed the base branch from main to release/dev17.2 March 1, 2022 22:01
@jinujoseph jinujoseph added this to the 17.2.P2 milestone Mar 2, 2022
@JoeRobich JoeRobich merged commit 1bc171c into dotnet:release/dev17.2 Mar 3, 2022
@dibarbet dibarbet deleted the intellicode_accessibility branch March 4, 2022 00:03
@RikkiGibson
Copy link
Copy Markdown
Member

Is this going through QB @dibarbet?

@dibarbet
Copy link
Copy Markdown
Member Author

dibarbet commented Mar 4, 2022

@RikkiGibson it was supposed to be m2 but the integration test failures blocked it for a while.
Would like to take in QB though I think

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.

7 participants