Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor TypeProperty to better represent ObjectType state #16053

Merged
merged 3 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ private static ObjectType GetConfigurationType()
{
return new ObjectType("configuration", TypeSymbolValidationFlags.Default, new[]
{
new TypeProperty("connectionString", LanguageConstants.String, TypePropertyFlags.Required),
new NamedTypeProperty("connectionString", LanguageConstants.String, TypePropertyFlags.Required),
}, null);
}

Expand All @@ -44,9 +44,9 @@ private class BarTypeProvider : ResourceTypeProviderBase, IResourceTypeProvider
ResourceFlags.None,
new ObjectType("Service properties", TypeSymbolValidationFlags.Default, new[]
{
new TypeProperty("staticWebsiteEnabled", LanguageConstants.Bool),
new TypeProperty("staticWebsiteIndexDocument", LanguageConstants.String),
new TypeProperty("staticWebsiteErrorDocument404Path", LanguageConstants.String),
new NamedTypeProperty("staticWebsiteEnabled", LanguageConstants.Bool),
new NamedTypeProperty("staticWebsiteIndexDocument", LanguageConstants.String),
new NamedTypeProperty("staticWebsiteErrorDocument404Path", LanguageConstants.String),
}, null)),
new ResourceTypeComponents(
ResourceTypeReference.Parse("container"),
Expand All @@ -55,7 +55,7 @@ private class BarTypeProvider : ResourceTypeProviderBase, IResourceTypeProvider
ResourceFlags.None,
new ObjectType("Container properties", TypeSymbolValidationFlags.Default, new[]
{
new TypeProperty("name", LanguageConstants.String, TypePropertyFlags.Required),
new NamedTypeProperty("name", LanguageConstants.String, TypePropertyFlags.Required),
}, null)),
new ResourceTypeComponents(
ResourceTypeReference.Parse("blob"),
Expand All @@ -64,9 +64,9 @@ private class BarTypeProvider : ResourceTypeProviderBase, IResourceTypeProvider
ResourceFlags.None,
new ObjectType("Blob properties", TypeSymbolValidationFlags.Default, new[]
{
new TypeProperty("containerName", LanguageConstants.String, TypePropertyFlags.Required),
new TypeProperty("name", LanguageConstants.String, TypePropertyFlags.Required),
new TypeProperty("base64Content", LanguageConstants.String, TypePropertyFlags.Required),
new NamedTypeProperty("containerName", LanguageConstants.String, TypePropertyFlags.Required),
new NamedTypeProperty("name", LanguageConstants.String, TypePropertyFlags.Required),
new NamedTypeProperty("base64Content", LanguageConstants.String, TypePropertyFlags.Required),
}, null)),
}.ToImmutableDictionary(x => x.TypeReference);

Expand Down Expand Up @@ -109,7 +109,7 @@ public static NamespaceType Create(string aliasName)
return new NamespaceType(
aliasName,
Settings,
ImmutableArray<TypeProperty>.Empty,
ImmutableArray<NamedTypeProperty>.Empty,
ImmutableArray<FunctionOverload>.Empty,
ImmutableArray<BannedFunction>.Empty,
ImmutableArray<Decorator>.Empty,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ private class FooTypeProvider : ResourceTypeProviderBase, IResourceTypeProvider
ResourceFlags.None,
new ObjectType("application", TypeSymbolValidationFlags.Default, new[]
{
new TypeProperty("uniqueName", LanguageConstants.String, TypePropertyFlags.Required | TypePropertyFlags.SystemProperty),
new TypeProperty("appId", LanguageConstants.String, TypePropertyFlags.ReadOnly),
new NamedTypeProperty("uniqueName", LanguageConstants.String, TypePropertyFlags.Required | TypePropertyFlags.SystemProperty),
new NamedTypeProperty("appId", LanguageConstants.String, TypePropertyFlags.ReadOnly),
}, null)),
}.ToImmutableDictionary(x => x.TypeReference);

Expand Down Expand Up @@ -80,7 +80,7 @@ public static NamespaceType Create(string aliasName)
return new NamespaceType(
aliasName,
Settings,
ImmutableArray<TypeProperty>.Empty,
ImmutableArray<NamedTypeProperty>.Empty,
ImmutableArray<FunctionOverload>.Empty,
ImmutableArray<BannedFunction>.Empty,
ImmutableArray<Decorator>.Empty,
Expand Down
8 changes: 4 additions & 4 deletions src/Bicep.Core.IntegrationTests/ProviderImportTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ public async Task Ambiguous_function_references_must_be_qualified()
ConfigurationType: null,
TemplateExtensionName: "Ns1-Unused",
TemplateExtensionVersion: "1.0"),
ImmutableArray<TypeProperty>.Empty,
ImmutableArray<NamedTypeProperty>.Empty,
new[] {
new FunctionOverloadBuilder("ns1Func").Build(),
new FunctionOverloadBuilder("dupeFunc").Build(),
Expand All @@ -274,7 +274,7 @@ public async Task Ambiguous_function_references_must_be_qualified()
ConfigurationType: null,
TemplateExtensionName: "Ns2-Unused",
TemplateExtensionVersion: "1.0"),
ImmutableArray<TypeProperty>.Empty,
ImmutableArray<NamedTypeProperty>.Empty,
new[] {
new FunctionOverloadBuilder("ns2Func").Build(),
new FunctionOverloadBuilder("dupeFunc").Build(),
Expand Down Expand Up @@ -339,12 +339,12 @@ public async Task Config_with_optional_properties_can_be_skipped()
TypeSymbolValidationFlags.Default,
new[]
{
new TypeProperty("optionalConfig", LanguageConstants.String, TypePropertyFlags.DeployTimeConstant),
new NamedTypeProperty("optionalConfig", LanguageConstants.String, TypePropertyFlags.DeployTimeConstant),
},
null),
TemplateExtensionName: "Unused",
TemplateExtensionVersion: "1.0.0"),
ImmutableArray<TypeProperty>.Empty,
ImmutableArray<NamedTypeProperty>.Empty,
ImmutableArray<FunctionOverload>.Empty,
ImmutableArray<BannedFunction>.Empty,
ImmutableArray<Decorator>.Empty,
Expand Down
8 changes: 4 additions & 4 deletions src/Bicep.Core.IntegrationTests/ScenarioTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2802,11 +2802,11 @@ public void Test_Issue5456_1()
{
new ResourceTypeComponents(typeReference, ResourceScope.ResourceGroup, ResourceScope.None, ResourceFlags.None, new ObjectType(typeReference.FormatName(), TypeSymbolValidationFlags.Default, new[]
{
new TypeProperty("name", LanguageConstants.String, TypePropertyFlags.DeployTimeConstant, "name property"),
new TypeProperty("tags", LanguageConstants.Array, TypePropertyFlags.ReadOnly, "tags property"),
new TypeProperty("properties", new ObjectType("properties", TypeSymbolValidationFlags.Default, new[]
new NamedTypeProperty("name", LanguageConstants.String, TypePropertyFlags.DeployTimeConstant, "name property"),
new NamedTypeProperty("tags", LanguageConstants.Array, TypePropertyFlags.ReadOnly, "tags property"),
new NamedTypeProperty("properties", new ObjectType("properties", TypeSymbolValidationFlags.Default, new[]
{
new TypeProperty("prop1", LanguageConstants.String, TypePropertyFlags.ReadOnly, "prop1")
new NamedTypeProperty("prop1", LanguageConstants.String, TypePropertyFlags.ReadOnly, "prop1")
}, null), TypePropertyFlags.ReadOnly, "properties property"),
}, null))
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,9 @@ public void Test_Issue5960_case1()
var typeReference = ResourceTypeReference.Parse("My.Rp/myResource@2020-01-01");
var typeLoader = TestTypeHelper.CreateResourceTypeLoaderWithTypes(new[] {
new ResourceTypeComponents(typeReference, ResourceScope.ResourceGroup, ResourceScope.None, ResourceFlags.None, new ObjectType(typeReference.FormatName(), TypeSymbolValidationFlags.Default, new [] {
new TypeProperty("name", LanguageConstants.String, TypePropertyFlags.DeployTimeConstant | TypePropertyFlags.SystemProperty, "name property"),
new TypeProperty("required", LanguageConstants.String, TypePropertyFlags.Required, "required property"),
new TypeProperty("systemRequired", LanguageConstants.String, TypePropertyFlags.SystemProperty | TypePropertyFlags.Required, "system required property")
new NamedTypeProperty("name", LanguageConstants.String, TypePropertyFlags.DeployTimeConstant | TypePropertyFlags.SystemProperty, "name property"),
new NamedTypeProperty("required", LanguageConstants.String, TypePropertyFlags.Required, "required property"),
new NamedTypeProperty("systemRequired", LanguageConstants.String, TypePropertyFlags.SystemProperty | TypePropertyFlags.Required, "system required property")
}, null))
});

Expand All @@ -339,9 +339,9 @@ public void Test_Issue5960_case2()
var typeReference = ResourceTypeReference.Parse("My.Rp/myResource@2020-01-01");
var typeLoader = TestTypeHelper.CreateResourceTypeLoaderWithTypes(new[] {
new ResourceTypeComponents(typeReference, ResourceScope.ResourceGroup, ResourceScope.None, ResourceFlags.None, new ObjectType(typeReference.FormatName(), TypeSymbolValidationFlags.Default, new [] {
new TypeProperty("name", LanguageConstants.String, TypePropertyFlags.DeployTimeConstant | TypePropertyFlags.SystemProperty, "name property"),
new TypeProperty("required", LanguageConstants.String, TypePropertyFlags.Required, "required property"),
new TypeProperty("systemRequired", LanguageConstants.String, TypePropertyFlags.SystemProperty | TypePropertyFlags.Required, "system required property")
new NamedTypeProperty("name", LanguageConstants.String, TypePropertyFlags.DeployTimeConstant | TypePropertyFlags.SystemProperty, "name property"),
new NamedTypeProperty("required", LanguageConstants.String, TypePropertyFlags.Required, "required property"),
new NamedTypeProperty("systemRequired", LanguageConstants.String, TypePropertyFlags.SystemProperty | TypePropertyFlags.Required, "system required property")
}, null))
});

Expand All @@ -367,9 +367,9 @@ public void Test_Issue5960_case3()
var typeReference = ResourceTypeReference.Parse("My.Rp/myResource@2020-01-01");
var typeLoader = TestTypeHelper.CreateResourceTypeLoaderWithTypes(new[] {
new ResourceTypeComponents(typeReference, ResourceScope.ResourceGroup, ResourceScope.None, ResourceFlags.None, new ObjectType(typeReference.FormatName(), TypeSymbolValidationFlags.Default, new [] {
new TypeProperty("name", LanguageConstants.String, TypePropertyFlags.DeployTimeConstant | TypePropertyFlags.SystemProperty, "name property"),
new TypeProperty("required", LanguageConstants.String, TypePropertyFlags.Required, "required property"),
new TypeProperty("systemRequired", LanguageConstants.String, TypePropertyFlags.SystemProperty | TypePropertyFlags.Required, "system required property")
new NamedTypeProperty("name", LanguageConstants.String, TypePropertyFlags.DeployTimeConstant | TypePropertyFlags.SystemProperty, "name property"),
new NamedTypeProperty("required", LanguageConstants.String, TypePropertyFlags.Required, "required property"),
new NamedTypeProperty("systemRequired", LanguageConstants.String, TypePropertyFlags.SystemProperty | TypePropertyFlags.Required, "system required property")
}, null))
});

Expand All @@ -394,8 +394,8 @@ public void Test_Issue5960_case4()
var typeReference = ResourceTypeReference.Parse("My.Rp/myResource@2020-01-01");
var typeLoader = TestTypeHelper.CreateResourceTypeLoaderWithTypes(new[] {
new ResourceTypeComponents(typeReference, ResourceScope.ResourceGroup, ResourceScope.None, ResourceFlags.None, new ObjectType(typeReference.FormatName(), TypeSymbolValidationFlags.Default, new [] {
new TypeProperty("name", LanguageConstants.String, TypePropertyFlags.DeployTimeConstant | TypePropertyFlags.SystemProperty, "name property"),
new TypeProperty("systemRequired", LanguageConstants.String, TypePropertyFlags.SystemProperty | TypePropertyFlags.Required, "system required property")
new NamedTypeProperty("name", LanguageConstants.String, TypePropertyFlags.DeployTimeConstant | TypePropertyFlags.SystemProperty, "name property"),
new NamedTypeProperty("systemRequired", LanguageConstants.String, TypePropertyFlags.SystemProperty | TypePropertyFlags.Required, "system required property")
}, null))
});

Expand Down Expand Up @@ -437,8 +437,8 @@ public void Test_Issue5960_case6()
var typeReference = ResourceTypeReference.Parse("My.Rp/myResource@2020-01-01");
var typeLoader = TestTypeHelper.CreateResourceTypeLoaderWithTypes(new[] {
new ResourceTypeComponents(typeReference, ResourceScope.ResourceGroup, ResourceScope.None, ResourceFlags.None, new ObjectType(typeReference.FormatName(), TypeSymbolValidationFlags.Default, new [] {
new TypeProperty("name", LanguageConstants.String, TypePropertyFlags.DeployTimeConstant | TypePropertyFlags.SystemProperty, "name property"),
new TypeProperty("required", LanguageConstants.Object, TypePropertyFlags.Required, "required property"),
new NamedTypeProperty("name", LanguageConstants.String, TypePropertyFlags.DeployTimeConstant | TypePropertyFlags.SystemProperty, "name property"),
new NamedTypeProperty("required", LanguageConstants.Object, TypePropertyFlags.Required, "required property"),
}, null))
});

Expand All @@ -464,8 +464,8 @@ public void Test_Issue5960_case7()
var typeReference = ResourceTypeReference.Parse("My.Rp/myResource@2020-01-01");
var typeLoader = TestTypeHelper.CreateResourceTypeLoaderWithTypes(new[] {
new ResourceTypeComponents(typeReference, ResourceScope.ResourceGroup, ResourceScope.None, ResourceFlags.None, new ObjectType(typeReference.FormatName(), TypeSymbolValidationFlags.Default, new [] {
new TypeProperty("name", LanguageConstants.String, TypePropertyFlags.DeployTimeConstant | TypePropertyFlags.SystemProperty, "name property"),
new TypeProperty("systemRequired", LanguageConstants.Object, TypePropertyFlags.Required | TypePropertyFlags.SystemProperty, "system required property"),
new NamedTypeProperty("name", LanguageConstants.String, TypePropertyFlags.DeployTimeConstant | TypePropertyFlags.SystemProperty, "name property"),
new NamedTypeProperty("systemRequired", LanguageConstants.Object, TypePropertyFlags.Required | TypePropertyFlags.SystemProperty, "system required property"),
}, null))
});

Expand All @@ -491,9 +491,9 @@ public void Test_Issue5960_case8()
var typeReference = ResourceTypeReference.Parse("My.Rp/myResource@2020-01-01");
var typeLoader = TestTypeHelper.CreateResourceTypeLoaderWithTypes(new[] {
new ResourceTypeComponents(typeReference, ResourceScope.ResourceGroup, ResourceScope.None, ResourceFlags.None, new ObjectType(typeReference.FormatName(), TypeSymbolValidationFlags.Default, new [] {
new TypeProperty("name", LanguageConstants.String, TypePropertyFlags.DeployTimeConstant | TypePropertyFlags.SystemProperty, "name property"),
new TypeProperty("systemRequired", LanguageConstants.Object, TypePropertyFlags.Required | TypePropertyFlags.SystemProperty, "system required property"),
new TypeProperty("required", LanguageConstants.Object, TypePropertyFlags.Required, "required property"),
new NamedTypeProperty("name", LanguageConstants.String, TypePropertyFlags.DeployTimeConstant | TypePropertyFlags.SystemProperty, "name property"),
new NamedTypeProperty("systemRequired", LanguageConstants.Object, TypePropertyFlags.Required | TypePropertyFlags.SystemProperty, "system required property"),
new NamedTypeProperty("required", LanguageConstants.Object, TypePropertyFlags.Required, "required property"),
}, null))
});

Expand Down
Loading
Loading