Closed ArcturusZhang closed 2 months ago
All changed packages have been documented.
@azure-tools/typespec-client-generator-core
You can try these changes at https://cadlplayground.z22.web.core.windows.net/typespec-azure/prs/1015/
Check the website changes at https://tspwebsitepr.z22.web.core.windows.net/typespec-azure/prs/1015/
Since this is breaking, can you also write a quick migration guide for emitters? Thanks! We also need approval from all languages
Overall I like the direction, thanks for your contribution @ArcturusZhang
Usually where we write the migration? In the changelog?
@iscai-msft I added some guidance in the changelog.
@ArcturusZhang I understand and like your your 2 and 3 points in your description. Would like to understand more on 1, why do we remove those types?
@ArcturusZhang I understand and like your your 2 and 3 points in your description. Would like to understand more on 1, why do we remove those types?
several reasons:
Also I think it should be neutral for 3rd party extensions, and azure should be regarded as our first 3rd party extension. Therefore we need a way to be able to handle those azure types without making them special in TCGC's code.
we should not make "azure" special in such a fundamental library if we do not have to. This should benefit in the future if we need to trim azure off from TCGC because we already did it.
I think Java will still need the tspNamespace
info to calculate our schema's namespace. [code] @weidongxu-microsoft please correct me if I'm wrong.
I think Java will still need the
tspNamespace
info to calculate our schema's namespace. [code] @weidongxu-microsoft please correct me if I'm wrong.
We can have another discussion or PR to solve for Java namespace problem.
Dapeng's PR handles a different problem.
I think Java will still need the
tspNamespace
info to calculate our schema's namespace. [code] @weidongxu-microsoft please correct me if I'm wrong.We can have another discussion or PR to solve for Java namespace problem.
Dapeng's PR handles a different problem.
Yeah, sure, just saw tspNamespace
is removed, so raise this concern.
also seems this pr has a wrong merge from main that need to remove before merge.
Fixes https://github.com/Azure/typespec-azure/issues/1010 Fixes https://github.com/Azure/typespec-azure/issues/997 Fixes https://github.com/Azure/typespec-azure/issues/1106
Changes and migration guides
Changes
SdkBuiltInType
:uuid
(azure type)ipV4Address
(azure type)ipV6Address
(azure type)eTag
(azure type)armId
(azure type)azureLocation
(azure type)password
(removed)guid
(removed)uri
(removed)ipAddress
(removed)@format
can no longer change a string type to above azure types (uuid
,eTag
, etc).name
,crossLanguageDefinitionId
andbaseType
toSdkBuiltInType
,SdkDateTimeType
andSdkDurationType
.scalar
keyword will be parsed into eitherSdkBuiltInType
,SdkDateTimeType
orSdkDurationType
depending on the base type, with itsname
andcrossLanguageDefinitionId
.@encode
will be added to the scalar type, and will not propagate to its base type.isSdkFloatKind
now returnsfalse
fordecimal
anddecimal128
.Migration guides for emitters
The major breaking change introduced by this change is the removal of azure related kinds for
SdkBuiltInType
. Therefore for code such as:should be changed to the following if the emitter is doing something special for azure-location:
or just change it to this:
For those removed kinds, they no longer exist therefore it should be safe just remove related code snippets.
Summary
This PR includes the following changes:
SdkBuiltInType
:uuid
(azure type)ipV4Address
(azure type)ipV6Address
(azure type)eTag
(azure type)armId
(azure type)azureLocation
(azure type)password
(removed)guid
(removed)uri
(removed)ipAddress
(removed)@format
can no longer change a string type to above azure types (uuid
,eTag
, etc).name
,crossLanguageDefinitionId
andbaseType
toSdkBuiltInType
,SdkDatetimeType
andSdkDurationType
.scalar
keyword will be parsed into eitherSdkBuiltInType
,SdkDatetimeType
orSdkDurationType
depending on the base type, with itsname
andcrossLanguageDefinitionId
.@encode
will be added to the scalar type, and will not propagate to its base type.isSdkFloatKind
now returnsfalse
fordecimal
anddecimal128
.Reasons and motivations
TCGC should be "linguistic neutrality" which does not favor or disfavor any language and only represent the structures defined in a tsp file/files. Also I think it should be neutral for 3rd party extensions, and azure should be regarded as our first 3rd party extension. Therefore we need a way to be able to handle those azure types without making them special in TCGC's code.
The solution that this PR is applying is similar to the solution we have for models in azure core template. Instead of creating a special kind for models in azure core template (such as the
ResponseError
,TrackedResource
,Resource
orExtendedLocation
), we just parse them as regular models with their own name and tsp namespace, so that the downstream genreators could know where these types are defined, and if they want, they could do a filter, to handle those special types. Same thing could apply to scalars, for a scalar defined in azure core template:for those would care this, this stands for an "azure location", for those would not care, this is just a string. Therefore this PR introduces name and
crossLanguageDefinitionId
toSdkBuiltInType
just like we have in models, this scalar now will be parsed as:The
crossLanguageDefinitionId
is important for downstream generators to know whether this scalar is defined.baseType
here is also important and we must have this, because we do not want to see if users write scalars extending some of the scalars from azure core template, and it ends up with a string. For example, based on the fact that we have the aboveazureLocation
defined in our azure core template, and one could write:in this case, I think the generator should generate the
bar
property ofFoo
model asAzureLocation
type. But if we do not have thebaseType
, we only have this:which has nothing with
azureLocation
which is not acceptable.