-
Notifications
You must be signed in to change notification settings - Fork 223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(http-client-csharp): dump deprecated description
properties
#5154
base: main
Are you sure you want to change the base?
refactor(http-client-csharp): dump deprecated description
properties
#5154
Conversation
- emitter: replace all `description` properties of input types with `summary` and `doc` - generator: - update json converters for the emitter schema change - only expose `Summary` and `Doc` properties if they are used by other classes - update test cases accordingly part of microsoft#4771
filter-out-core-models
optiondescription
properties
API change check APIView has identified API level changes in this PR and created following API reviews. |
private static readonly InputClient _animalClient = new("animal", "", "AnimalClient description", [], [], TestClientName); | ||
private static readonly InputClient _dogClient = new("dog", "", "DogClient description", [], [], _animalClient.Name); | ||
private static readonly InputClient _catClient = new("cat", "", "CatClient description", [], [], _animalClient.Name); | ||
private static readonly InputClient _hawkClient = new("hawkClient", "", "HawkClient description", [], [], _animalClient.Name); | ||
private static readonly InputClient _huskyClient = new("husky", "", "HuskyClient description", [], [], _dogClient.Name); |
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.
i think we should do string.Empty
instead of ""
.
Also should this be null
?
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.
I think it is never required to have summary or doc there these two properties should be nullable.
And there should be difference between when we have:
model Foo {}
and
@doc("")
model Foo {}
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.
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.
I think it is never required to have summary or doc there these two properties should be nullable. And there should be difference between when we have:
model Foo {}
and
@doc("") model Foo {}
Zero values are the same here. You don't want to generate an empty doc anyway. Also, we're not consistent in our code base. Some defines string?
and others define string
. I just follow what the current codes were written.
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.
This comment follows this one: #5154 (comment)
For example an input enum type is not required to have a doc or summary or description, therefore our definition here is wrong in the first place.
We define this in this way, because previously these are defined for azure purpose, and for azure libraries, types, properties are not allowed without documentation. But in unbranded libraries, there is no such rules.
Azure part should change accordingly if we change it here - assign default value when an output type is constructed.
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.
changed all Summary
and Doc
as string?
: base(name) | ||
{ | ||
CrossLanguageDefinitionId = crossLanguageDefinitionId; | ||
Accessibility = accessibility; | ||
Deprecated = deprecated; | ||
Description = description; | ||
Description = string.IsNullOrEmpty(summary) ? (doc ?? string.Empty) : summary; |
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.
I think we should change this property to two new properties Summary
and Doc
The classes in input types should just be the C# version of those typescript interfaces.
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.
I see two different strategies regarding the input types between http-client-csharp
and autorest.csharp
:
- In
http-client-csharp
, we declare them asclass
. So, I keep the minimal interface here. - In
autorest.csharp
, we declare them asrecord
. So, I keep the interface like the original data schema as much as possible.
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.
record is a class, there is no differences.
Making this change might take quite a few efforts, this I admit.
But we should not be avoiding them - I have done multiple of those when consolidating the models part.
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.
removed all Description
properties, replace with codes in the output model
Changes since last review:
|
@@ -424,7 +425,7 @@ private ScmMethodProvider BuildProtocolMethod(MethodProvider createRequestMethod | |||
|
|||
var methodSignature = new MethodSignature( | |||
isAsync ? _cleanOperationName + "Async" : _cleanOperationName, | |||
FormattableStringHelpers.FromString(Operation.Description), | |||
DocHelpers.GetFormattableDescription(Operation.Summary, Operation.Doc) ?? FormattableStringHelpers.FromString(Operation.Name), |
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.
Description of MethodSignature is nullable. Why do we mock the operation.Name as its description here?
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.
Description of MethodSignature is nullable. Why do we mock the operation.Name as its description here?
It's because previously we use Operation.Name
if Description
is not available:
Line 91 in b6dcb04
operation.Description = description ?? name; // default to name to avoid a case that we do not have description (and leads to no xml doc at all) |
After discussion with Dapeng, we thought we should do less in the input type converters. So, I moved the logic in TypeSepcInputOperationConverter
to the output model here.
We have similar changes elsewhere in this PR as well.
description
properties of input types withsummary
anddoc
Summary
andDoc
properties if they are used by other classespart of #4771