Skip to content

Commit

Permalink
remove IsFlatten property according to review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Mingzhe Huang (from Dev Box) committed Oct 9, 2024
1 parent 79cc4a4 commit 9a5cf99
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ public void TestIntSerializationStatement(
var name = kind.ToString().ToLower();
var properties = new List<InputModelProperty>
{
new InputModelProperty("requiredInt", "requiredInt", "", new InputPrimitiveType(kind, name, $"TypeSpec.{name}", encode), true, false, false, false),
new InputModelProperty("requiredInt", "requiredInt", "", new InputPrimitiveType(kind, name, $"TypeSpec.{name}", encode), true, false, false),
};

var inputModel = new InputModelType("TestModel", "TestModel", "public", null, "Test model.", InputModelTypeUsage.Input, properties, null, Array.Empty<InputModelType>(), null, null, new Dictionary<string, InputModelType>(), null, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Microsoft.Generator.CSharp.Input
{
public class InputModelProperty
{
public InputModelProperty(string name, string serializedName, string? description, InputType type, bool isRequired, bool isReadOnly, bool isDiscriminator, bool isFlattened)
public InputModelProperty(string name, string serializedName, string? description, InputType type, bool isRequired, bool isReadOnly, bool isDiscriminator)
{
Name = name;
SerializedName = serializedName;
Expand All @@ -17,7 +17,6 @@ public InputModelProperty(string name, string serializedName, string? descriptio
IsRequired = isRequired;
IsReadOnly = isReadOnly;
IsDiscriminator = isDiscriminator;
IsFlattened = isFlattened;
}

public string Name { get; }
Expand All @@ -27,7 +26,6 @@ public InputModelProperty(string name, string serializedName, string? descriptio
public bool IsRequired { get; }
public bool IsReadOnly { get; }
public bool IsDiscriminator { get; }
public bool IsFlattened { get; }
public InputModelType? EnclosingType { get; internal set; }
public IReadOnlyList<InputDecoratorInfo> Decorators { get; internal set; } = new List<InputDecoratorInfo>();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@ internal set
DiscriminatorProperty.Type,
DiscriminatorProperty.IsRequired,
DiscriminatorProperty.IsReadOnly,
DiscriminatorProperty.IsDiscriminator,
DiscriminatorProperty.IsFlattened),
DiscriminatorProperty.IsDiscriminator),
new Dictionary<string, InputModelType>(),
null,
false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ private static InputModelProperty ReadInputModelProperty(ref Utf8JsonReader read
bool isReadOnly = false;
bool isOptional = false;
bool isDiscriminator = false;
bool isFlattened = false;
IReadOnlyList<InputDecoratorInfo>? decorators = null;

while (reader.TokenType != JsonTokenType.EndObject)
Expand All @@ -45,8 +44,7 @@ private static InputModelProperty ReadInputModelProperty(ref Utf8JsonReader read
|| reader.TryReadBoolean("readOnly", ref isReadOnly)
|| reader.TryReadBoolean("optional", ref isOptional)
|| reader.TryReadBoolean("discriminator", ref isDiscriminator)
|| reader.TryReadWithConverter("decorators", options, ref decorators)
|| reader.TryReadWithConverter("flatten", options, ref isFlattened);
|| reader.TryReadWithConverter("decorators", options, ref decorators);

if (!isKnownProperty)
{
Expand All @@ -59,7 +57,7 @@ private static InputModelProperty ReadInputModelProperty(ref Utf8JsonReader read
// description = BuilderHelpers.EscapeXmlDocDescription(description);
propertyType = propertyType ?? throw new JsonException($"{nameof(InputModelProperty)} must have a property type.");

var property = new InputModelProperty(name, serializedName ?? name, description, propertyType, !isOptional, isReadOnly, isDiscriminator, isFlattened) { Decorators = decorators ?? [] };
var property = new InputModelProperty(name, serializedName ?? name, description, propertyType, !isOptional, isReadOnly, isDiscriminator) { Decorators = decorators ?? [] };
if (id != null)
{
resolver.AddReference(id, property);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public CodeWriterBenchmark()
PluginInitializer.Initialize();
var properties = new[]
{
new InputModelProperty("MyProperty", "myProperty", "The property of mine", InputPrimitiveType.Int32, true, false, false, false)
new InputModelProperty("MyProperty", "myProperty", "The property of mine", InputPrimitiveType.Int32, true, false, false)
};
var inputModel = new InputModelType("MyModel", string.Empty, null, null, "Test model", InputModelTypeUsage.Input | InputModelTypeUsage.Output, properties, null, Array.Empty<InputModelType>(), null, null, new Dictionary<string, InputModelType>(), null, false);
var modelProvider = new ModelProvider(inputModel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,7 @@ public static InputModelProperty Property(
type,
isRequired,
isReadOnly,
isDiscriminator,
false);
isDiscriminator);
}

public static InputModelType Model(
Expand Down

0 comments on commit 9a5cf99

Please sign in to comment.