Skip to content

Commit

Permalink
Update the test data factory. Some special types are structs!
Browse files Browse the repository at this point in the history
  • Loading branch information
mandel-macaque committed Jan 23, 2025
1 parent 7b433d9 commit 6ad32da
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/rgen/Microsoft.Macios.Generator/DataModel/TypeInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ public override string ToString ()
sb.Append ($"IsSmartEnum: {IsSmartEnum}, ");
sb.Append ($"IsArray: {IsArray}, ");
sb.Append ($"IsReferenceType: {IsReferenceType}, ");
sb.Append ($"IsStruct: {IsStruct}, ");
sb.Append ($"IsVoid : {IsVoid}, ");
sb.Append ($"IsNSObject : {IsNSObject}, ");
sb.Append ($"IsNativeObject: {IsINativeObject}, ");
Expand Down
14 changes: 9 additions & 5 deletions tests/rgen/Microsoft.Macios.Generator.Tests/TestDataFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ public static TypeInfo ReturnTypeForInt (bool isNullable = false)
name: "int",
specialType: SpecialType.System_Int32,
isBlittable: !isNullable,
isNullable: isNullable
isNullable: isNullable,
isStruct: true
) {
Parents = ["System.ValueType", "object"],
Interfaces = isNullable
Expand Down Expand Up @@ -86,7 +87,8 @@ public static TypeInfo ReturnTypeForIntPtr (bool isNullable = false)
name: "nint",
specialType: SpecialType.System_IntPtr,
isBlittable: !isNullable,
isNullable: isNullable
isNullable: isNullable,
isStruct: true
) {
Parents = ["System.ValueType", "object"],
Interfaces = isNullable
Expand Down Expand Up @@ -132,7 +134,8 @@ public static TypeInfo ReturnTypeForBool ()
=> new (
name: "bool",
specialType: SpecialType.System_Boolean,
isBlittable: false
isBlittable: false,
isStruct: true
) {
Parents = ["System.ValueType", "object"],
Interfaces = [
Expand All @@ -147,7 +150,7 @@ public static TypeInfo ReturnTypeForBool ()
};

public static TypeInfo ReturnTypeForVoid ()
=> new ("void", SpecialType.System_Void) { Parents = ["System.ValueType", "object"], };
=> new ("void", SpecialType.System_Void, isStruct: true) { Parents = ["System.ValueType", "object"], };

public static TypeInfo ReturnTypeForClass (string className, bool isNullable = false)
=> new (
Expand All @@ -174,7 +177,8 @@ public static TypeInfo ReturnTypeForInterface (string interfaceName)

public static TypeInfo ReturnTypeForStruct (string structName)
=> new (
name: structName
name: structName,
isStruct: true
) { Parents = ["System.ValueType", "object"] };

public static TypeInfo ReturnTypeForEnum (string enumName, bool isSmartEnum = false, bool isNativeEnum = false)
Expand Down

0 comments on commit 6ad32da

Please sign in to comment.