You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Offline discussed with @ArcturusZhang and we think anomymous model may not be a good practice and we should encourage to give a name for models especially for exposed public APIs.
Most of downstreaming language emitters may not have ability to handle inline expressions like typespec so they need to GUESS a name for anomymous models. This could introduce uncertainty if downstreaming name rule is different and for example the name rule introduced breakings between m4 and tcgc and one issue happened in common types is tracked here.
Even we could find a name rule and these names could be fragile and it would be changed with its context or code order if conflicting happened.
For example in TCGC we try to guess this name according to context, including parent model name + property name + model type. So the name could be changed once any of these factors changed. Also we may name some models during conflicting and any code order changes would impact the generated code.
model Ab {
c: {
foo: string;
};
}
// vs
model A {
b: {
c: {
foo: string;
};
};
}
Can we add a linter to discourage the anonymous model in typespec? Especially in azure could we avoid using anonymous model then?
MaryGao
changed the title
Discourage the anonymous model in typespec and always give an name for that model
[linter]discourage the anonymous model in typespec and always give an name for that model
Oct 22, 2024
MaryGao
changed the title
[linter]discourage the anonymous model in typespec and always give an name for that model
[linter]discourage to use anonymous model and always give a model name
Oct 22, 2024
We already discussed that in teh past and due to a lot of anonymous model used for config and templates it is not possible to do a generic version. This should be a tcgc issue which has a picture of when things are anonymous.
Clear and concise description of the problem
Offline discussed with @ArcturusZhang and we think anomymous model may not be a good practice and we should encourage to give a name for models especially for exposed public APIs.
Most of downstreaming language emitters may not have ability to handle inline expressions like typespec so they need to GUESS a name for anomymous models. This could introduce uncertainty if downstreaming name rule is different and for example the name rule introduced breakings between m4 and tcgc and one issue happened in common types is tracked here.
Even we could find a name rule and these names could be fragile and it would be changed with its context or code order if conflicting happened.
For example in TCGC we try to guess this name according to context, including
parent model name + property name + model type
. So the name could be changed once any of these factors changed. Also we may name some models during conflicting and any code order changes would impact the generated code.Can we add a linter to discourage the anonymous model in typespec? Especially in azure could we avoid using anonymous model then?
Checklist
The text was updated successfully, but these errors were encountered: