From 1fba54038758d292750b06e609d21fbc21aaea26 Mon Sep 17 00:00:00 2001 From: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com> Date: Tue, 20 Aug 2024 11:07:22 -0700 Subject: [PATCH] Visitor fixes (#4217) --- .../Microsoft.Generator.CSharp/src/LibraryVisitor.cs | 6 +++--- .../generator/Microsoft.Generator.CSharp/src/TypeFactory.cs | 2 +- .../test/InputLibraryVisitorTests.cs | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/LibraryVisitor.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/LibraryVisitor.cs index 4f4bed476..9b31038dc 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/LibraryVisitor.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/LibraryVisitor.cs @@ -96,17 +96,17 @@ namespace Microsoft.Generator.CSharp protected internal virtual TypeProvider? Visit(InputModelType model, TypeProvider? type) { - return new ModelProvider(model); + return type; } protected internal virtual PropertyProvider? Visit(InputModelProperty property, PropertyProvider? propertyProvider) { - return new PropertyProvider(property); + return propertyProvider; } protected internal virtual TypeProvider? Visit(InputEnumType enumType, TypeProvider? type) { - return EnumProvider.Create(enumType, type); + return type; } protected virtual TypeProvider? Visit(TypeProvider type) diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/TypeFactory.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/TypeFactory.cs index c1cb64171..283465cd9 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/TypeFactory.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/TypeFactory.cs @@ -206,7 +206,7 @@ namespace Microsoft.Generator.CSharp } foreach (var visitor in Visitors) { - type = visitor.Visit(enumType, declaringType); + type = visitor.Visit(enumType, type); } return type; } diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/InputLibraryVisitorTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/InputLibraryVisitorTests.cs index 478874da4..34b5380b0 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/InputLibraryVisitorTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/InputLibraryVisitorTests.cs @@ -57,7 +57,7 @@ namespace Microsoft.Generator.CSharp.Tests _mockVisitor.Protected().Verify("Visit", Times.Once(), inputModel, ItExpr.Is(m => m.Name == new ModelProvider(inputModel).Name)); - _mockVisitor.Protected().Verify("Visit", Times.Once(), inputEnum, ItExpr.IsNull()); + _mockVisitor.Protected().Verify("Visit", Times.Once(), inputEnum, ItExpr.Is(m => m.Name == EnumProvider.Create(inputEnum, null).Name)); } [Test] @@ -117,7 +117,7 @@ namespace Microsoft.Generator.CSharp.Tests { return null; } - return base.Visit(inputModelProperty, propertyProvider); + return new PropertyProvider(inputModelProperty); } } }