diff --git a/src/rgen/Microsoft.Macios.Generator/DataModel/Constructor.cs b/src/rgen/Microsoft.Macios.Generator/DataModel/Constructor.cs
index b992ac530eed..a669154aac27 100644
--- a/src/rgen/Microsoft.Macios.Generator/DataModel/Constructor.cs
+++ b/src/rgen/Microsoft.Macios.Generator/DataModel/Constructor.cs
@@ -68,6 +68,7 @@ public static bool TryCreate (ConstructorDeclarationSyntax declaration, Semantic
IsParams = parameter.IsParams,
IsThis = parameter.IsThis,
IsNullable = parameter.NullableAnnotation == NullableAnnotation.Annotated,
+ IsSmartEnum = parameter.Type.IsSmartEnum (),
DefaultValue = (parameter.HasExplicitDefaultValue) ? parameter.ExplicitDefaultValue?.ToString () : null,
ReferenceKind = parameter.RefKind.ToReferenceKind (),
Attributes = parameterDeclaration.GetAttributeCodeChanges (semanticModel),
diff --git a/src/rgen/Microsoft.Macios.Generator/DataModel/Method.cs b/src/rgen/Microsoft.Macios.Generator/DataModel/Method.cs
index cb97253ae2d7..e4ba66c4f1ce 100644
--- a/src/rgen/Microsoft.Macios.Generator/DataModel/Method.cs
+++ b/src/rgen/Microsoft.Macios.Generator/DataModel/Method.cs
@@ -81,6 +81,7 @@ public static bool TryCreate (MethodDeclarationSyntax declaration, SemanticModel
IsParams = parameter.IsParams,
IsThis = parameter.IsThis,
IsNullable = parameter.NullableAnnotation == NullableAnnotation.Annotated,
+ IsSmartEnum = parameter.Type.IsSmartEnum (),
DefaultValue = (parameter.HasExplicitDefaultValue) ? parameter.ExplicitDefaultValue?.ToString () : null,
ReferenceKind = parameter.RefKind.ToReferenceKind (),
Attributes = parameterDeclaration.GetAttributeCodeChanges (semanticModel),
diff --git a/src/rgen/Microsoft.Macios.Generator/DataModel/Parameter.cs b/src/rgen/Microsoft.Macios.Generator/DataModel/Parameter.cs
index 3339485432b4..9f4ffab6a427 100644
--- a/src/rgen/Microsoft.Macios.Generator/DataModel/Parameter.cs
+++ b/src/rgen/Microsoft.Macios.Generator/DataModel/Parameter.cs
@@ -43,6 +43,11 @@ namespace Microsoft.Macios.Generator.DataModel;
///
public bool IsNullable { get; init; }
+ ///
+ /// Returns if the parameter type is a smart enum.
+ ///
+ public bool IsSmartEnum { get; init; }
+
///
/// Optional default value.
///
@@ -82,6 +87,8 @@ public bool Equals (Parameter other)
return false;
if (IsNullable != other.IsNullable)
return false;
+ if (IsSmartEnum != other.IsSmartEnum)
+ return false;
if (DefaultValue != other.DefaultValue)
return false;
if (ReferenceKind != other.ReferenceKind)
@@ -107,6 +114,7 @@ public override int GetHashCode ()
hashCode.Add (IsParams);
hashCode.Add (IsThis);
hashCode.Add (IsNullable);
+ hashCode.Add (IsSmartEnum);
hashCode.Add (DefaultValue);
hashCode.Add ((int) ReferenceKind);
return hashCode.ToHashCode ();
@@ -135,6 +143,7 @@ public override string ToString ()
sb.Append ($"IsParams {IsParams}, ");
sb.Append ($"IsThis: {IsThis}, ");
sb.Append ($"IsNullable: {IsNullable}, ");
+ sb.Append ($"IsSmartEnum: {IsSmartEnum}, ");
sb.Append ($"DefaultValue: {DefaultValue}, ");
sb.Append ($"ReferenceKind: {ReferenceKind} }}");
return sb.ToString ();
diff --git a/src/rgen/Microsoft.Macios.Generator/DataModel/Property.cs b/src/rgen/Microsoft.Macios.Generator/DataModel/Property.cs
index 19c352b30eb5..a355ef3ff129 100644
--- a/src/rgen/Microsoft.Macios.Generator/DataModel/Property.cs
+++ b/src/rgen/Microsoft.Macios.Generator/DataModel/Property.cs
@@ -26,6 +26,11 @@ namespace Microsoft.Macios.Generator.DataModel;
///
public string Type { get; } = string.Empty;
+ ///
+ /// Returns if the parameter type is a smart enum.
+ ///
+ public bool IsSmartEnum { get; }
+
///
/// The platform availability of the property.
///
@@ -67,12 +72,14 @@ namespace Microsoft.Macios.Generator.DataModel;
public ImmutableArray Accessors { get; } = [];
internal Property (string name, string type,
+ bool isSmartEnum,
SymbolAvailability symbolAvailability,
ImmutableArray attributes,
ImmutableArray modifiers, ImmutableArray accessors)
{
Name = name;
Type = type;
+ IsSmartEnum = isSmartEnum;
SymbolAvailability = symbolAvailability;
Attributes = attributes;
Modifiers = modifiers;
@@ -87,6 +94,8 @@ public bool Equals (Property other)
return false;
if (Type != other.Type)
return false;
+ if (IsSmartEnum != other.IsSmartEnum)
+ return false;
if (SymbolAvailability != other.SymbolAvailability)
return false;
if (ExportFieldData != other.ExportFieldData)
@@ -115,7 +124,7 @@ public override bool Equals (object? obj)
///
public override int GetHashCode ()
{
- return HashCode.Combine (Name, Type, Attributes, Modifiers, Accessors);
+ return HashCode.Combine (Name, Type, IsSmartEnum, Attributes, Modifiers, Accessors);
}
public static bool operator == (Property left, Property right)
@@ -169,6 +178,7 @@ public static bool TryCreate (PropertyDeclarationSyntax declaration, SemanticMod
change = new (
name: memberName,
type: type,
+ isSmartEnum: propertySymbol.Type.IsSmartEnum (),
symbolAvailability: propertySupportedPlatforms,
attributes: attributes,
modifiers: [.. declaration.Modifiers],
@@ -183,7 +193,7 @@ public static bool TryCreate (PropertyDeclarationSyntax declaration, SemanticMod
public override string ToString ()
{
var sb = new StringBuilder (
- $"Name: '{Name}', Type: '{Type}', Supported Platforms: {SymbolAvailability}, ExportFieldData: '{ExportFieldData?.ToString () ?? "null"}', ExportPropertyData: '{ExportPropertyData?.ToString () ?? "null"}' Attributes: [");
+ $"Name: '{Name}', Type: '{Type}', IsSmartEnum: {IsSmartEnum}, Supported Platforms: {SymbolAvailability}, ExportFieldData: '{ExportFieldData?.ToString () ?? "null"}', ExportPropertyData: '{ExportPropertyData?.ToString () ?? "null"}' Attributes: [");
sb.AppendJoin (",", Attributes);
sb.Append ("], Modifiers: [");
sb.AppendJoin (",", Modifiers.Select (x => x.Text));
diff --git a/src/rgen/Microsoft.Macios.Generator/Extensions/TypeSymbolExtensions.cs b/src/rgen/Microsoft.Macios.Generator/Extensions/TypeSymbolExtensions.cs
index a01820850969..ab546cd125b6 100644
--- a/src/rgen/Microsoft.Macios.Generator/Extensions/TypeSymbolExtensions.cs
+++ b/src/rgen/Microsoft.Macios.Generator/Extensions/TypeSymbolExtensions.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
+using System.Linq;
using Microsoft.CodeAnalysis;
using Microsoft.Macios.Generator.Attributes;
using Microsoft.Macios.Generator.Availability;
@@ -125,6 +126,29 @@ public static SymbolAvailability GetSupportedPlatforms (this ISymbol symbol)
return availability;
}
+ public static bool HasAttribute (this ISymbol symbol, string attribute)
+ {
+ var boundAttributes = symbol.GetAttributes ();
+ if (boundAttributes.Length == 0) {
+ return false;
+ }
+ foreach (var attributeData in boundAttributes) {
+ var attrName = attributeData.AttributeClass?.ToDisplayString ();
+ if (attrName == attribute) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public static bool IsSmartEnum (this ITypeSymbol symbol)
+ {
+ // a type is a smart enum if its type is a enum one AND it was decorated with the
+ // binding type attribute
+ return symbol.TypeKind == TypeKind.Enum
+ && symbol.HasAttribute (AttributesNames.BindingAttribute);
+ }
+
public static BindingTypeData GetBindingData (this ISymbol symbol)
{
var boundAttributes = symbol.GetAttributes ();
diff --git a/tests/rgen/Microsoft.Macios.Generator.Tests/DataModel/ClassCodeChangesTests.cs b/tests/rgen/Microsoft.Macios.Generator.Tests/DataModel/ClassCodeChangesTests.cs
index 45d9b1b6e605..3e5f7cbbf7ee 100644
--- a/tests/rgen/Microsoft.Macios.Generator.Tests/DataModel/ClassCodeChangesTests.cs
+++ b/tests/rgen/Microsoft.Macios.Generator.Tests/DataModel/ClassCodeChangesTests.cs
@@ -270,6 +270,7 @@ public partial class MyClass {
new (
name: "Name",
type: "string",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("ObjCBindings.ExportAttribute", ["name"])
@@ -283,7 +284,121 @@ public partial class MyClass {
new (AccessorKind.Setter, new (), [], []),
]
) {
+ ExportPropertyData = new ("name")
+ }
+ ]
+ }
+ ];
+
+ const string singlePropertySmartEnumClass = @"
+using ObjCBindings;
+
+namespace NS;
+
+[BindingType]
+public enum MyEnum {
+ None = 0,
+}
+
+[BindingType]
+public partial class MyClass {
+ [Export (""name"")]
+ public partial MyEnum Name { get; set; }
+}
+";
+
+ yield return [
+ singlePropertySmartEnumClass,
+ new CodeChanges (
+ bindingData: new (new BindingTypeData ()),
+ name: "MyClass",
+ @namespace: ["NS"],
+ fullyQualifiedSymbol: "NS.MyClass",
+ symbolAvailability: new ()
+ ) {
+ Attributes = [
+ new ("ObjCBindings.BindingTypeAttribute")
+ ],
+ UsingDirectives = new HashSet { "ObjCBindings" },
+ Modifiers = [
+ SyntaxFactory.Token (SyntaxKind.PublicKeyword),
+ SyntaxFactory.Token (SyntaxKind.PartialKeyword)
+ ],
+ Properties = [
+ new (
+ name: "Name",
+ type: "NS.MyEnum",
+ isSmartEnum: true,
+ symbolAvailability: new (),
+ attributes: [
+ new ("ObjCBindings.ExportAttribute", ["name"])
+ ],
+ modifiers: [
+ SyntaxFactory.Token (SyntaxKind.PublicKeyword),
+ SyntaxFactory.Token (SyntaxKind.PartialKeyword),
+ ],
+ accessors: [
+ new (AccessorKind.Getter, new (), [], []),
+ new (AccessorKind.Setter, new (), [], []),
+ ]
+ ) {
+ ExportPropertyData = new ("name")
+ }
+ ]
+ }
+ ];
+ const string singlePropertyEnumClass = @"
+using ObjCBindings;
+
+namespace NS;
+
+public enum MyEnum {
+ None = 0,
+}
+
+[BindingType]
+public partial class MyClass {
+ [Export (""name"")]
+ public partial MyEnum Name { get; set; }
+}
+";
+
+ yield return [
+ singlePropertyEnumClass,
+ new CodeChanges (
+ bindingData: new (new BindingTypeData ()),
+ name: "MyClass",
+ @namespace: ["NS"],
+ fullyQualifiedSymbol: "NS.MyClass",
+ symbolAvailability: new ()
+ ) {
+ Attributes = [
+ new ("ObjCBindings.BindingTypeAttribute")
+ ],
+ UsingDirectives = new HashSet { "ObjCBindings" },
+ Modifiers = [
+ SyntaxFactory.Token (SyntaxKind.PublicKeyword),
+ SyntaxFactory.Token (SyntaxKind.PartialKeyword)
+ ],
+ Properties = [
+ new (
+ name: "Name",
+ type: "NS.MyEnum",
+ isSmartEnum: false,
+ symbolAvailability: new (),
+ attributes: [
+ new ("ObjCBindings.ExportAttribute", ["name"])
+ ],
+ modifiers: [
+ SyntaxFactory.Token (SyntaxKind.PublicKeyword),
+ SyntaxFactory.Token (SyntaxKind.PartialKeyword),
+ ],
+ accessors: [
+ new (AccessorKind.Getter, new (), [], []),
+ new (AccessorKind.Setter, new (), [], []),
+ ]
+ ) {
ExportPropertyData = new ("name")
}
]
@@ -323,6 +438,7 @@ public partial class MyClass {
new (
name: "Name",
type: "string",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("ObjCBindings.ExportAttribute", ["name", "ObjCBindings.Property.Notification"])
@@ -376,6 +492,7 @@ public partial class MyClass {
new (
name: "Name",
type: "string",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("ObjCBindings.ExportAttribute", ["CONSTANT"])
@@ -432,6 +549,7 @@ public partial class MyClass {
new (
name: "Name",
type: "string",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("ObjCBindings.ExportAttribute", ["name"])
@@ -487,6 +605,7 @@ public partial class MyClass {
new (
name: "Name",
type: "string",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("ObjCBindings.ExportAttribute", ["name"])
@@ -505,6 +624,7 @@ public partial class MyClass {
new (
name: "Surname",
type: "string",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("ObjCBindings.ExportAttribute", ["surname"])
diff --git a/tests/rgen/Microsoft.Macios.Generator.Tests/DataModel/CodeChangesComparerTests.cs b/tests/rgen/Microsoft.Macios.Generator.Tests/DataModel/CodeChangesComparerTests.cs
index 4bb7d486da9b..348b2cbdecb9 100644
--- a/tests/rgen/Microsoft.Macios.Generator.Tests/DataModel/CodeChangesComparerTests.cs
+++ b/tests/rgen/Microsoft.Macios.Generator.Tests/DataModel/CodeChangesComparerTests.cs
@@ -200,6 +200,7 @@ public void CompareDifferentPropertyLength ()
new (
name: "Name",
type: "Utils.MyClass",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -233,6 +234,7 @@ public void CompareSamePropertiesDiffOrder ()
new (
name: "Surname",
type: "string",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -249,6 +251,7 @@ public void CompareSamePropertiesDiffOrder ()
new (
name: "Name",
type: "Utils.MyClass",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -277,6 +280,7 @@ public void CompareSamePropertiesDiffOrder ()
new (
name: "Name",
type: "Utils.MyClass",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -295,6 +299,7 @@ public void CompareSamePropertiesDiffOrder ()
new (
name: "Surname",
type: "string",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -327,6 +332,7 @@ public void CompareDifferentProperties ()
new (
name: "Surname",
type: "string",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -343,6 +349,7 @@ public void CompareDifferentProperties ()
new (
name: "Name",
type: "string",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -371,6 +378,7 @@ public void CompareDifferentProperties ()
new (
name: "Name",
type: "Utils.MyClass",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -389,6 +397,7 @@ public void CompareDifferentProperties ()
new (
name: "Surname",
type: "string",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -421,6 +430,7 @@ public void CompareDifferentEventsLength ()
new (
name: "Surname",
type: "string",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -437,6 +447,7 @@ public void CompareDifferentEventsLength ()
new (
name: "Name",
type: "Utils.MyClass",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -476,6 +487,7 @@ public void CompareDifferentEventsLength ()
new (
name: "Name",
type: "Utils.MyClass",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -494,6 +506,7 @@ public void CompareDifferentEventsLength ()
new (
name: "Surname",
type: "string",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -526,6 +539,7 @@ public void CompareSameEventsDiffOrder ()
new (
name: "Surname",
type: "string",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -542,6 +556,7 @@ public void CompareSameEventsDiffOrder ()
new (
name: "Name",
type: "Utils.MyClass",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -591,6 +606,7 @@ public void CompareSameEventsDiffOrder ()
new (
name: "Name",
type: "Utils.MyClass",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -609,6 +625,7 @@ public void CompareSameEventsDiffOrder ()
new (
name: "Surname",
type: "string",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -663,6 +680,7 @@ public void CompareDifferentEvents ()
new (
name: "Surname",
type: "string",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -679,6 +697,7 @@ public void CompareDifferentEvents ()
new (
name: "Name",
type: "Utils.MyClass",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -718,6 +737,7 @@ public void CompareDifferentEvents ()
new (
name: "Name",
type: "Utils.MyClass",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -736,6 +756,7 @@ public void CompareDifferentEvents ()
new (
name: "Surname",
type: "string",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -781,6 +802,7 @@ public void CompareDifferentMethodsLength ()
new (
name: "Surname",
type: "string",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -797,6 +819,7 @@ public void CompareDifferentMethodsLength ()
new (
name: "Name",
type: "Utils.MyClass",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -877,6 +900,7 @@ public void CompareDifferentMethodsLength ()
new (
name: "Name",
type: "Utils.MyClass",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -895,6 +919,7 @@ public void CompareDifferentMethodsLength ()
new (
name: "Surname",
type: "string",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -967,6 +992,7 @@ public void CompareSameMethodsDiffOrder ()
new (
name: "Surname",
type: "string",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -983,6 +1009,7 @@ public void CompareSameMethodsDiffOrder ()
new (
name: "Name",
type: "Utils.MyClass",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -1063,6 +1090,7 @@ public void CompareSameMethodsDiffOrder ()
new (
name: "Name",
type: "Utils.MyClass",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -1081,6 +1109,7 @@ public void CompareSameMethodsDiffOrder ()
new (
name: "Surname",
type: "string",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -1166,6 +1195,7 @@ public void CompareDifferentMethods ()
new (
name: "Surname",
type: "string",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -1182,6 +1212,7 @@ public void CompareDifferentMethods ()
new (
name: "Name",
type: "Utils.MyClass",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -1246,6 +1277,7 @@ public void CompareDifferentMethods ()
new (
name: "Name",
type: "Utils.MyClass",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -1264,6 +1296,7 @@ public void CompareDifferentMethods ()
new (
name: "Surname",
type: "string",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -1339,6 +1372,7 @@ public void CompareSameMethodsDiffAvailability ()
new (
name: "Surname",
type: "string",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -1355,6 +1389,7 @@ public void CompareSameMethodsDiffAvailability ()
new (
name: "Name",
type: "Utils.MyClass",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -1435,6 +1470,7 @@ public void CompareSameMethodsDiffAvailability ()
new (
name: "Name",
type: "Utils.MyClass",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -1453,6 +1489,7 @@ public void CompareSameMethodsDiffAvailability ()
new (
name: "Surname",
type: "string",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -1541,6 +1578,7 @@ public void CompareSameMethodsSameAvailability ()
new (
name: "Surname",
type: "string",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -1557,6 +1595,7 @@ public void CompareSameMethodsSameAvailability ()
new (
name: "Name",
type: "Utils.MyClass",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -1637,6 +1676,7 @@ public void CompareSameMethodsSameAvailability ()
new (
name: "Name",
type: "Utils.MyClass",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -1655,6 +1695,7 @@ public void CompareSameMethodsSameAvailability ()
new (
name: "Surname",
type: "string",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
diff --git a/tests/rgen/Microsoft.Macios.Generator.Tests/DataModel/CodeChangesEqualityComparerTests.cs b/tests/rgen/Microsoft.Macios.Generator.Tests/DataModel/CodeChangesEqualityComparerTests.cs
index 3234b8e7467d..d8bfd8667c18 100644
--- a/tests/rgen/Microsoft.Macios.Generator.Tests/DataModel/CodeChangesEqualityComparerTests.cs
+++ b/tests/rgen/Microsoft.Macios.Generator.Tests/DataModel/CodeChangesEqualityComparerTests.cs
@@ -162,6 +162,7 @@ public void CompareDifferentPropertyLength ()
new (
name: "Name",
type: "Utils.MyClass",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -197,6 +198,7 @@ public void CompareSamePropertiesDiffOrder ()
new (
name: "Surname",
type: "string",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -213,6 +215,7 @@ public void CompareSamePropertiesDiffOrder ()
new (
name: "Name",
type: "Utils.MyClass",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -241,6 +244,7 @@ public void CompareSamePropertiesDiffOrder ()
new (
name: "Name",
type: "Utils.MyClass",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -259,6 +263,7 @@ public void CompareSamePropertiesDiffOrder ()
new (
name: "Surname",
type: "string",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -291,6 +296,7 @@ public void CompareDifferentProperties ()
new (
name: "Surname",
type: "string",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -307,6 +313,7 @@ public void CompareDifferentProperties ()
new (
name: "Name",
type: "string",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -335,6 +342,7 @@ public void CompareDifferentProperties ()
new (
name: "Name",
type: "Utils.MyClass",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -353,6 +361,7 @@ public void CompareDifferentProperties ()
new (
name: "Surname",
type: "string",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -385,6 +394,7 @@ public void CompareDifferentConstructorLength ()
new (
name: "Surname",
type: "string",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -401,6 +411,7 @@ public void CompareDifferentConstructorLength ()
new (
name: "Name",
type: "Utils.MyClass",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -430,6 +441,7 @@ public void CompareDifferentConstructorLength ()
new (
name: "Name",
type: "Utils.MyClass",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -448,6 +460,7 @@ public void CompareDifferentConstructorLength ()
new (
name: "Surname",
type: "string",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -483,6 +496,7 @@ public void CompareDifferentConstructors ()
new (
name: "Surname",
type: "string",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -499,6 +513,7 @@ public void CompareDifferentConstructors ()
new (
name: "Name",
type: "Utils.MyClass",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -530,6 +545,7 @@ public void CompareDifferentConstructors ()
new (
name: "Name",
type: "Utils.MyClass",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -548,6 +564,7 @@ public void CompareDifferentConstructors ()
new (
name: "Surname",
type: "string",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -589,6 +606,7 @@ public void CompareSameConstructors ()
new (
name: "Surname",
type: "string",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -605,6 +623,7 @@ public void CompareSameConstructors ()
new (
name: "Name",
type: "Utils.MyClass",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -643,6 +662,7 @@ public void CompareSameConstructors ()
new (
name: "Name",
type: "Utils.MyClass",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -661,6 +681,7 @@ public void CompareSameConstructors ()
new (
name: "Surname",
type: "string",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -703,6 +724,7 @@ public void CompareSameConstructorsDiffOrder ()
new (
name: "Surname",
type: "string",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -719,6 +741,7 @@ public void CompareSameConstructorsDiffOrder ()
new (
name: "Name",
type: "Utils.MyClass",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -757,6 +780,7 @@ public void CompareSameConstructorsDiffOrder ()
new (
name: "Name",
type: "Utils.MyClass",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -775,6 +799,7 @@ public void CompareSameConstructorsDiffOrder ()
new (
name: "Surname",
type: "string",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -821,6 +846,7 @@ public void CompareSameDiffModifiers ()
new (
name: "Surname",
type: "string",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -837,6 +863,7 @@ public void CompareSameDiffModifiers ()
new (
name: "Name",
type: "Utils.MyClass",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -880,6 +907,7 @@ public void CompareSameDiffModifiers ()
new (
name: "Name",
type: "Utils.MyClass",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -898,6 +926,7 @@ public void CompareSameDiffModifiers ()
new (
name: "Surname",
type: "string",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
diff --git a/tests/rgen/Microsoft.Macios.Generator.Tests/DataModel/ConstructorComparerTests.cs b/tests/rgen/Microsoft.Macios.Generator.Tests/DataModel/ConstructorComparerTests.cs
index 4d7ae4e089bb..1020613f6bac 100644
--- a/tests/rgen/Microsoft.Macios.Generator.Tests/DataModel/ConstructorComparerTests.cs
+++ b/tests/rgen/Microsoft.Macios.Generator.Tests/DataModel/ConstructorComparerTests.cs
@@ -174,4 +174,39 @@ public void CompareDiffParameters ()
var parameterCompare = new ParameterComparer ();
Assert.Equal (parameterCompare.Compare (x.Parameters [0], y.Parameters [0]), comparer.Compare (x, y));
}
+
+ [Fact]
+ public void CompareDiffParametersSmartEnum ()
+ {
+ var x = new Constructor ("MyClass",
+ symbolAvailability: new (),
+ attributes: [
+ new ("FirstAttr"),
+ ],
+ modifiers: [
+ SyntaxFactory.Token (SyntaxKind.PartialKeyword),
+ SyntaxFactory.Token (SyntaxKind.PublicKeyword),
+ ],
+ parameters: [
+ new (0, "MyEnum", "name") {
+ IsSmartEnum = true
+ },
+ ]);
+ var y = new Constructor ("MyClass",
+ symbolAvailability: new (),
+ attributes: [
+ new ("FirstAttr"),
+ ],
+ modifiers: [
+ SyntaxFactory.Token (SyntaxKind.PartialKeyword),
+ SyntaxFactory.Token (SyntaxKind.PublicKeyword),
+ ],
+ parameters: [
+ new (0, "MyEnum", "name") {
+ IsSmartEnum = false
+ },
+ ]);
+ var parameterCompare = new ParameterComparer ();
+ Assert.Equal (parameterCompare.Compare (x.Parameters [0], y.Parameters [0]), comparer.Compare (x, y));
+ }
}
diff --git a/tests/rgen/Microsoft.Macios.Generator.Tests/DataModel/InterfaceCodeChangesTests.cs b/tests/rgen/Microsoft.Macios.Generator.Tests/DataModel/InterfaceCodeChangesTests.cs
index 39178f18a64f..a1626c9c0f05 100644
--- a/tests/rgen/Microsoft.Macios.Generator.Tests/DataModel/InterfaceCodeChangesTests.cs
+++ b/tests/rgen/Microsoft.Macios.Generator.Tests/DataModel/InterfaceCodeChangesTests.cs
@@ -118,6 +118,122 @@ public partial interface IProtocol {
new (
name: "Name",
type: "string",
+ isSmartEnum: false,
+ symbolAvailability: new (),
+ attributes: [
+ new ("ObjCBindings.ExportAttribute", ["name"])
+ ],
+ modifiers: [
+ SyntaxFactory.Token (SyntaxKind.PublicKeyword),
+ SyntaxFactory.Token (SyntaxKind.PartialKeyword),
+ ],
+ accessors: [
+ new (AccessorKind.Getter, new (), [], []),
+ new (AccessorKind.Setter, new (), [], []),
+ ]
+ ) {
+ ExportPropertyData = new ("name")
+ }
+ ]
+ }
+ ];
+
+ const string singlePropertySmartEnumInterface = @"
+using ObjCBindings;
+
+namespace NS;
+
+[BindingType]
+public enum MyEnum {
+ First,
+}
+
+[BindingType]
+public partial interface IProtocol {
+ [Export (""name"")]
+ public partial MyEnum Name { get; set; }
+}
+";
+
+ yield return [
+ singlePropertySmartEnumInterface,
+ new CodeChanges (
+ bindingData: new (new BindingTypeData ()),
+ name: "IProtocol",
+ @namespace: ["NS"],
+ fullyQualifiedSymbol: "NS.IProtocol",
+ symbolAvailability: new ()
+ ) {
+ Attributes = [
+ new ("ObjCBindings.BindingTypeAttribute")
+ ],
+ UsingDirectives = new HashSet { "ObjCBindings" },
+ Modifiers = [
+ SyntaxFactory.Token (SyntaxKind.PublicKeyword),
+ SyntaxFactory.Token (SyntaxKind.PartialKeyword)
+ ],
+ Properties = [
+ new (
+ name: "Name",
+ type: "NS.MyEnum",
+ isSmartEnum: true,
+ symbolAvailability: new (),
+ attributes: [
+ new ("ObjCBindings.ExportAttribute", ["name"])
+ ],
+ modifiers: [
+ SyntaxFactory.Token (SyntaxKind.PublicKeyword),
+ SyntaxFactory.Token (SyntaxKind.PartialKeyword),
+ ],
+ accessors: [
+ new (AccessorKind.Getter, new (), [], []),
+ new (AccessorKind.Setter, new (), [], []),
+ ]
+ ) {
+ ExportPropertyData = new ("name")
+ }
+ ]
+ }
+ ];
+
+ const string singlePropertyEnumInterface = @"
+using ObjCBindings;
+
+namespace NS;
+
+public enum MyEnum {
+ First,
+}
+
+[BindingType]
+public partial interface IProtocol {
+ [Export (""name"")]
+ public partial MyEnum Name { get; set; }
+}
+";
+
+ yield return [
+ singlePropertyEnumInterface,
+ new CodeChanges (
+ bindingData: new (new BindingTypeData ()),
+ name: "IProtocol",
+ @namespace: ["NS"],
+ fullyQualifiedSymbol: "NS.IProtocol",
+ symbolAvailability: new ()
+ ) {
+ Attributes = [
+ new ("ObjCBindings.BindingTypeAttribute")
+ ],
+ UsingDirectives = new HashSet { "ObjCBindings" },
+ Modifiers = [
+ SyntaxFactory.Token (SyntaxKind.PublicKeyword),
+ SyntaxFactory.Token (SyntaxKind.PartialKeyword)
+ ],
+ Properties = [
+ new (
+ name: "Name",
+ type: "NS.MyEnum",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("ObjCBindings.ExportAttribute", ["name"])
@@ -170,6 +286,7 @@ public partial interface IProtocol {
new (
name: "Name",
type: "string",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("ObjCBindings.ExportAttribute", ["name", "ObjCBindings.Property.Notification"])
@@ -224,6 +341,7 @@ public partial interface IProtocol {
new (
name: "Name",
type: "string",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("ObjCBindings.ExportAttribute", ["name"])
@@ -279,6 +397,7 @@ public partial interface IProtocol {
new (
name: "Name",
type: "string",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("ObjCBindings.ExportAttribute", ["name"])
@@ -297,6 +416,7 @@ public partial interface IProtocol {
new (
name: "Surname",
type: "string",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [
new ("ObjCBindings.ExportAttribute", ["surname"])
diff --git a/tests/rgen/Microsoft.Macios.Generator.Tests/DataModel/MethodComparerTests.cs b/tests/rgen/Microsoft.Macios.Generator.Tests/DataModel/MethodComparerTests.cs
index 408cda26acbb..8377901e3edc 100644
--- a/tests/rgen/Microsoft.Macios.Generator.Tests/DataModel/MethodComparerTests.cs
+++ b/tests/rgen/Microsoft.Macios.Generator.Tests/DataModel/MethodComparerTests.cs
@@ -288,4 +288,46 @@ public void CompareDiffParameters ()
var parameterCompare = new ParameterComparer ();
Assert.Equal (parameterCompare.Compare (x.Parameters [0], y.Parameters [0]), comparer.Compare (x, y));
}
+
+ [Fact]
+ public void CompareDiffParametersSmartEnum ()
+ {
+ var x = new Method (
+ type: "MyType",
+ name: "MyMethod",
+ returnType: "void",
+ symbolAvailability: new (),
+ attributes: [
+ new ("FirstAttr"),
+ ],
+ modifiers: [
+ SyntaxFactory.Token (SyntaxKind.PublicKeyword),
+ ],
+ parameters: [
+ new (0, "MyEnum", "name") {
+ IsSmartEnum = true
+ },
+ ]
+ );
+
+ var y = new Method (
+ type: "MyType",
+ name: "MyMethod",
+ returnType: "void",
+ symbolAvailability: new (),
+ attributes: [
+ new ("FirstAttr"),
+ ],
+ modifiers: [
+ SyntaxFactory.Token (SyntaxKind.PublicKeyword),
+ ],
+ parameters: [
+ new (0, "MyEnum", "name") {
+ IsSmartEnum = false
+ },
+ ]
+ );
+ var parameterCompare = new ParameterComparer ();
+ Assert.Equal (parameterCompare.Compare (x.Parameters [0], y.Parameters [0]), comparer.Compare (x, y));
+ }
}
diff --git a/tests/rgen/Microsoft.Macios.Generator.Tests/DataModel/PropertiesEqualityComparerTests.cs b/tests/rgen/Microsoft.Macios.Generator.Tests/DataModel/PropertiesEqualityComparerTests.cs
index c2de5574a43f..b82e51e3e044 100644
--- a/tests/rgen/Microsoft.Macios.Generator.Tests/DataModel/PropertiesEqualityComparerTests.cs
+++ b/tests/rgen/Microsoft.Macios.Generator.Tests/DataModel/PropertiesEqualityComparerTests.cs
@@ -24,6 +24,7 @@ public void CompareDifferentSize ()
new (
name: "FirstProperty",
type: "string",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [],
modifiers: [
@@ -35,6 +36,7 @@ public void CompareDifferentSize ()
new (
name: "SecondProperty",
type: "string",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [],
modifiers: [
@@ -48,6 +50,7 @@ public void CompareDifferentSize ()
new (
name: "FirstProperty",
type: "string",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [],
modifiers: [
@@ -68,6 +71,7 @@ public void CompareSameSizeDiffProperties ()
new (
name: "FirstProperty",
type: "string",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [],
modifiers: [
@@ -81,6 +85,7 @@ public void CompareSameSizeDiffProperties ()
new (
name: "FirstProperty",
type: "AVFoundation.AVVideo",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [],
modifiers: [
@@ -101,6 +106,7 @@ public void CompareSameSizeSameProperties ()
new (
name: "FirstProperty",
type: "string",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [],
modifiers: [
@@ -113,6 +119,7 @@ public void CompareSameSizeSameProperties ()
ImmutableArray y = [
new (
name: "FirstProperty",
+ isSmartEnum: false,
type: "string",
symbolAvailability: new (),
attributes: [],
@@ -126,4 +133,39 @@ public void CompareSameSizeSameProperties ()
Assert.True (equalityComparer.Equals (x, y));
}
+
+ [Fact]
+ public void CompareDiffSmartEnum ()
+ {
+ ImmutableArray x = [
+ new (
+ name: "FirstProperty",
+ type: "string",
+ isSmartEnum: false,
+ symbolAvailability: new (),
+ attributes: [],
+ modifiers: [
+ SyntaxFactory.Token (SyntaxKind.PublicKeyword),
+ ],
+ accessors: [
+ new (AccessorKind.Getter, new (), [], [])
+ ]),
+ ];
+ ImmutableArray y = [
+ new (
+ name: "FirstProperty",
+ isSmartEnum: true,
+ type: "string",
+ symbolAvailability: new (),
+ attributes: [],
+ modifiers: [
+ SyntaxFactory.Token (SyntaxKind.PublicKeyword),
+ ],
+ accessors: [
+ new (AccessorKind.Getter, new (), [], [])
+ ]),
+ ];
+
+ Assert.False (equalityComparer.Equals (x, y));
+ }
}
diff --git a/tests/rgen/Microsoft.Macios.Generator.Tests/DataModel/PropertyTests.cs b/tests/rgen/Microsoft.Macios.Generator.Tests/DataModel/PropertyTests.cs
index 116de0a39fd2..5f958a7083fc 100644
--- a/tests/rgen/Microsoft.Macios.Generator.Tests/DataModel/PropertyTests.cs
+++ b/tests/rgen/Microsoft.Macios.Generator.Tests/DataModel/PropertyTests.cs
@@ -16,8 +16,8 @@ public class PropertyTests : BaseGeneratorTestClass {
[Fact]
public void CompareDiffName ()
{
- var x = new Property ("First", "string", new (), [], [], []);
- var y = new Property ("Second", "string", new (), [], [], []);
+ var x = new Property ("First", "string", false, new (), [], [], []);
+ var y = new Property ("Second", "string", false, new (), [], [], []);
Assert.False (x.Equals (y));
Assert.False (y.Equals (x));
@@ -28,8 +28,8 @@ public void CompareDiffName ()
[Fact]
public void CompareDiffType ()
{
- var x = new Property ("First", "string", new (), [], [], []);
- var y = new Property ("First", "int", new (), [], [], []);
+ var x = new Property ("First", "string", false, new (), [], [], []);
+ var y = new Property ("First", "int", false, new (), [], [], []);
Assert.False (x.Equals (y));
Assert.False (y.Equals (x));
@@ -40,11 +40,11 @@ public void CompareDiffType ()
[Fact]
public void CompareDiffAttrs ()
{
- var x = new Property ("First", "string", new (), [
+ var x = new Property ("First", "string", false, new (), [
new ("Attr1"),
new ("Attr2"),
], [], []);
- var y = new Property ("First", "int", new (), [
+ var y = new Property ("First", "int", false, new (), [
new ("Attr2"),
], [], []);
@@ -57,13 +57,13 @@ public void CompareDiffAttrs ()
[Fact]
public void CompareDiffModifiers ()
{
- var x = new Property ("First", "string", new (), [
+ var x = new Property ("First", "string", false, new (), [
new ("Attr1"),
new ("Attr2"),
], [
SyntaxFactory.Token (SyntaxKind.AbstractKeyword)
], []);
- var y = new Property ("First", "int", new (), [
+ var y = new Property ("First", "int", false, new (), [
new ("Attr1"),
new ("Attr2"),
], [
@@ -79,7 +79,7 @@ public void CompareDiffModifiers ()
[Fact]
public void CompareDiffAccessors ()
{
- var x = new Property ("First", "string", new (), [
+ var x = new Property ("First", "string", false, new (), [
new ("Attr1"),
new ("Attr2"),
], [
@@ -88,7 +88,7 @@ public void CompareDiffAccessors ()
new (AccessorKind.Getter, new (), [], []),
new (AccessorKind.Setter, new (), [], []),
]);
- var y = new Property ("First", "int", new (), [
+ var y = new Property ("First", "int", false, new (), [
new ("Attr1"),
new ("Attr2"),
], [
@@ -106,7 +106,7 @@ public void CompareDiffAccessors ()
[Fact]
public void CompareEquals ()
{
- var x = new Property ("First", "string", new (), [
+ var x = new Property ("First", "string", false, new (), [
new ("Attr1"),
new ("Attr2"),
], [
@@ -115,7 +115,7 @@ public void CompareEquals ()
new (AccessorKind.Getter, new (), [], []),
new (AccessorKind.Setter, new (), [], []),
]);
- var y = new Property ("First", "string", new (), [
+ var y = new Property ("First", "string", false, new (), [
new ("Attr1"),
new ("Attr2"),
], [
@@ -149,6 +149,7 @@ public class TestClass {
new Property (
name: "Name",
type: "string",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [],
modifiers: [
@@ -175,6 +176,7 @@ public class TestClass {
new Property (
name: "Name",
type: "string",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [],
modifiers: [
@@ -200,6 +202,7 @@ public class TestClass {
new Property (
name: "Name",
type: "string",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [],
modifiers: [
@@ -224,6 +227,7 @@ public class TestClass {
new Property (
name: "Name",
type: "string",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [],
modifiers: [
@@ -250,6 +254,7 @@ public string Name {
new Property (
name: "Name",
type: "string",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [],
modifiers: [
@@ -278,6 +283,7 @@ public string Name {
new Property (
name: "Name",
type: "string",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [],
modifiers: [
@@ -306,6 +312,7 @@ public string Name {
new Property (
name: "Name",
type: "string",
+ isSmartEnum: false,
symbolAvailability: new (),
attributes: [],
modifiers: [
@@ -342,6 +349,7 @@ public string Name {
new Property (
name: "Name",
type: "string",
+ isSmartEnum: false,
symbolAvailability: propertyAvailabilityBuilder.ToImmutable (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -379,6 +387,7 @@ public string Name {
new Property (
name: "Name",
type: "string",
+ isSmartEnum: false,
symbolAvailability: propertyAvailabilityBuilder.ToImmutable (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -421,6 +430,7 @@ public string Name {
new Property (
name: "Name",
type: "string",
+ isSmartEnum: false,
symbolAvailability: propertyAvailabilityBuilder.ToImmutable (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
@@ -469,6 +479,7 @@ public Utils.MyClass Name {
new Property (
name: "Name",
type: "Utils.MyClass",
+ isSmartEnum: false,
symbolAvailability: propertyAvailabilityBuilder.ToImmutable (),
attributes: [
new ("System.Runtime.Versioning.SupportedOSPlatformAttribute", ["ios"]),
diff --git a/tests/rgen/Microsoft.Macios.Generator.Tests/Extensions/TypeSymbolExtensionsTests.cs b/tests/rgen/Microsoft.Macios.Generator.Tests/Extensions/TypeSymbolExtensionsTests.cs
index 0772426f87b1..5cb9586f0058 100644
--- a/tests/rgen/Microsoft.Macios.Generator.Tests/Extensions/TypeSymbolExtensionsTests.cs
+++ b/tests/rgen/Microsoft.Macios.Generator.Tests/Extensions/TypeSymbolExtensionsTests.cs
@@ -318,6 +318,105 @@ void GetSupportedPlatforms (ApplePlatform platform, string inputText,
Assert.Equal (availability, expectedAvailability);
}
+ class TestDataHasAttribute : IEnumerable