property-name-conflict
@azure-tools/typespec-client-generator-core/property-name-conflictAvoid naming conflicts between a property and a model of the same name.
A property whose name matches its enclosing model’s name causes problems with
some language emitters (notably C#), where the generated property would
collide with the type name. Rename the property, or use @clientName to
rename it for the affected language.
Impact
Section titled “Impact”- Area: SDK generation, primarily C#. A property whose name collides with its enclosing model’s name produces code that does not compile in C# (applies to both data-plane and management-plane).
- Not affected: The service definition and the wire protocol are unchanged; the collision only affects the generated client code.
❌ Incorrect Usage
Section titled “❌ Incorrect Usage”model Widget { widget: string;}Diagnostic Message
Section titled “Diagnostic Message”For the model above, the linter reports that the property name is the same as its enclosing model name:
Property 'widget' having the same name as its enclosing model will cause problems with C# code generation. Consider renaming the property directly or using the @clientName("newName", "csharp") decorator to rename the property for C#.✅ How to Fix
Section titled “✅ How to Fix”Rename the property:
model Widget { name: string;}Or keep the TypeSpec name and rename it for C# only:
model Widget { @clientName("widgetName", "csharp") widget: string;}Suppression
Section titled “Suppression”This rule should not be suppressed. Although it is reported as a warning, the name conflict breaks C# code generation, so it must be fixed rather than suppressed.