Skip to content

Commit d96e319

Browse files
sbomerJoshLove-msftlive1206
authored
Don't use C# name in model dictionary (#5376)
* Don't use C# name in model dictionary * Same for visitedTypes * Update generated code * Update preview.yml * Update preview.yml * Update preview.yml * Update eng/pipelines/preview.yml --------- Co-authored-by: JoshLove-msft <[email protected]> Co-authored-by: Wei Hu <[email protected]>
1 parent 2d547cc commit d96e319

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/AutoRest.CSharp/Common/Generation/Writers/ModelReaderWriterContextWriter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,15 @@ private static bool IsObsolete(CSharpType type)
8080
private IEnumerable<CSharpType> CollectBuildableTypes(IEnumerable<TypeProvider> models)
8181
{
8282
var buildableTypes = new HashSet<CSharpType>(new CSharpTypeNameComparer());
83-
var visitedTypes = new HashSet<CSharpType>(new CSharpTypeNameComparer());
83+
var visitedTypes = new HashSet<CSharpType>();
8484

8585
// for all Resource types, just add them directly to buildableTypes
8686
foreach (var resource in models.OfType<Resource>())
8787
{
8888
buildableTypes.Add(resource.Type);
8989
}
9090

91-
var modelDictionary = models.OfType<SerializableObjectType>().ToDictionary(m => m.Type, m => m, new CSharpTypeNameComparer());
91+
var modelDictionary = models.OfType<SerializableObjectType>().ToDictionary(m => m.Type, m => m);
9292

9393
foreach (var model in modelDictionary.Values)
9494
{

test/TestProjects/Customizations-TypeSpec/src/Generated/Models/CustomizationsInTspContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace CustomizationsInTsp
1414
/// Context class which will be filled in by the System.ClientModel.SourceGeneration.
1515
/// For more information see 'https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/System.ClientModel/src/docs/ModelReaderWriterContext.md'
1616
/// </summary>
17-
[ModelReaderWriterBuildable(typeof(ModelStruct?))]
17+
[ModelReaderWriterBuildable(typeof(ModelStruct))]
1818
[ModelReaderWriterBuildable(typeof(ModelToAddAdditionalSerializableProperty))]
1919
[ModelReaderWriterBuildable(typeof(ModelToChangeNamespace))]
2020
[ModelReaderWriterBuildable(typeof(ModelToMakeInternal))]

0 commit comments

Comments
 (0)