Bug Description
The C# generator's custom code (CustomCodeView) Roslyn parser does not extract attributes from properties defined in custom .cs files. When PropertyHelpers.GetAllProperties() returns properties from CustomCodeView, their Attributes collection is always empty — even if the custom code declares attributes like [Obsolete], [EditorBrowsable], etc.
This prevents the generator from detecting attributes on custom code properties at generation time.
Impact
The Azure SDK mgmt generator (@azure-typespec/http-client-csharp-mgmt) added logic in PR Azure/azure-sdk-for-net#57986 to skip [Obsolete] properties during @@Legacy.flattenProperty processing. However, this check (IsObsoleteProperty) always returns false for custom code properties because attributes are not populated.
Steps to Reproduce
- Define a TypeSpec model with a property (e.g.,
startTimeUtc)
- In custom code (partial class), declare the same property with
[Obsolete]
- At generation time, access
modelProvider.CustomCodeView.Properties and check property.Attributes
Expected: Attributes contains the [Obsolete] attribute
Actual: Attributes is empty (attrCount=0)
Debug Evidence
From the Azure.ResourceManager.Hci SDK generation with debug logging in FlattenPropertyVisitor:
CustomCodeView props: [StartTimeUtc(obsolete=False, attrCount=0, attrTypes=[]),
EndTimeUtc(obsolete=False, attrCount=0, attrTypes=[]),
LastUpdatedTimeUtc(obsolete=False, attrCount=0, attrTypes=[])]
The custom .cs file declares:
[Obsolete("This property is now deprecated.")]
[EditorBrowsable(EditorBrowsableState.Never)]
public DateTimeOffset? StartTimeUtc { get => throw new NotSupportedException(); ... }
Expected Fix
The Roslyn parser that builds PropertyProvider instances from custom code should also extract AttributeData from IPropertySymbol and populate the Attributes collection on the resulting PropertyProvider.
Bug Description
The C# generator's custom code (
CustomCodeView) Roslyn parser does not extract attributes from properties defined in custom.csfiles. WhenPropertyHelpers.GetAllProperties()returns properties fromCustomCodeView, theirAttributescollection is always empty — even if the custom code declares attributes like[Obsolete],[EditorBrowsable], etc.This prevents the generator from detecting attributes on custom code properties at generation time.
Impact
The Azure SDK mgmt generator (
@azure-typespec/http-client-csharp-mgmt) added logic in PR Azure/azure-sdk-for-net#57986 to skip[Obsolete]properties during@@Legacy.flattenPropertyprocessing. However, this check (IsObsoleteProperty) always returnsfalsefor custom code properties because attributes are not populated.Steps to Reproduce
startTimeUtc)[Obsolete]modelProvider.CustomCodeView.Propertiesand checkproperty.AttributesExpected:
Attributescontains the[Obsolete]attributeActual:
Attributesis empty (attrCount=0)Debug Evidence
From the Azure.ResourceManager.Hci SDK generation with debug logging in
FlattenPropertyVisitor:The custom
.csfile declares:Expected Fix
The Roslyn parser that builds
PropertyProviderinstances from custom code should also extractAttributeDatafromIPropertySymboland populate theAttributescollection on the resultingPropertyProvider.