Skip to content
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

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

archerzz
Copy link
Member

  • 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 #4771

- 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
@microsoft-github-policy-service microsoft-github-policy-service bot added the emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp label Nov 20, 2024
@archerzz archerzz changed the title refactor(http-client-csharp): remove filter-out-core-models option refactor(http-client-csharp): dump deprecated description properties Nov 20, 2024
@azure-sdk
Copy link
Collaborator

azure-sdk commented Nov 20, 2024

API change check

APIView has identified API level changes in this PR and created following API reviews.

Microsoft.Generator.CSharp.Input

Comment on lines 17 to 21
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);
Copy link
Member

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?

Copy link
Member

@ArcturusZhang ArcturusZhang Nov 21, 2024

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 {}

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 we should do string.Empty instead of "". Also should this be null?

It cannot be null, because nullable check is enabled.
image

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 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.

Copy link
Member

@ArcturusZhang ArcturusZhang Nov 21, 2024

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.

: base(name)
{
CrossLanguageDefinitionId = crossLanguageDefinitionId;
Accessibility = accessibility;
Deprecated = deprecated;
Description = description;
Description = string.IsNullOrEmpty(summary) ? (doc ?? string.Empty) : summary;
Copy link
Member

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.

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 see two different strategies regarding the input types between http-client-csharp and autorest.csharp:

  1. In http-client-csharp, we declare them as class. So, I keep the minimal interface here.
  2. In autorest.csharp, we declare them as record. So, I keep the interface like the original data schema as much as possible.

Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants