Skip to content

Commit

Permalink
Ensure customized properties are included in full constructor (#4734)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshLove-msft authored Oct 14, 2024
1 parent c215c5a commit 4e63496
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public CanonicalTypeProvider(TypeProvider generatedTypeProvider, InputType? inpu
protected override PropertyProvider[] BuildProperties()
{
var specProperties = _inputModel?.Properties ?? [];
var specPropertiesMap = specProperties.ToDictionary(p => p.Name, p => p);
var specPropertiesMap = specProperties.ToDictionary(p => p.Name.ToCleanName(), p => p);
var generatedProperties = _generatedTypeProvider.Properties;
var customProperties = _generatedTypeProvider.CustomCodeView?.Properties ?? [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public async Task CanChangePropertyName()
{
var props = new[]
{
InputFactory.Property("Prop1", InputFactory.Array(InputPrimitiveType.String))
InputFactory.Property("prop1", InputFactory.Array(InputPrimitiveType.String))
};

var inputModel = InputFactory.Model("mockInputModel", properties: props);
Expand All @@ -57,14 +57,18 @@ public async Task CanChangePropertyName()
Assert.AreEqual( "prop1", wireInfo!.SerializedName);

Assert.AreEqual(0, modelTypeProvider.Properties.Count);

var fullCtor = modelTypeProvider.Constructors.Last();
Assert.IsTrue(fullCtor.Signature.Modifiers.HasFlag(MethodSignatureModifiers.Internal));
Assert.AreEqual(2, fullCtor.Signature.Parameters.Count);
}

[Test]
public async Task CanChangePropertyNameAndRedefineOriginal()
{
var props = new[]
{
InputFactory.Property("Prop1", InputFactory.Array(InputPrimitiveType.String))
InputFactory.Property("prop1", InputFactory.Array(InputPrimitiveType.String))
};

var inputModel = InputFactory.Model("mockInputModel", properties: props);
Expand Down Expand Up @@ -94,7 +98,7 @@ public async Task CanChangePropertyType()
{
var props = new[]
{
InputFactory.Property("Prop1", InputFactory.Array(InputPrimitiveType.String))
InputFactory.Property("prop1", InputFactory.Array(InputPrimitiveType.String))
};

var inputModel = InputFactory.Model("mockInputModel", properties: props);
Expand Down Expand Up @@ -142,7 +146,7 @@ public async Task CanChangePropertyAccessibility()
var plugin = await MockHelpers.LoadMockPluginAsync(
inputModelTypes: new[] {
InputFactory.Model("mockInputModel", properties: new[] {
InputFactory.Property("Prop1", InputPrimitiveType.String)
InputFactory.Property("prop1", InputPrimitiveType.String)
})
},
compilation: async () => await Helpers.GetCompilationFromDirectoryAsync());
Expand Down

0 comments on commit 4e63496

Please sign in to comment.