Skip to content

Commit

Permalink
[Rgen] Mark 'Constructor' named methods as constructors in the transf…
Browse files Browse the repository at this point in the history
…ormer.

The old bindings use that name to denote constructors, these methods in
the new API will be converted to actual constructors.
  • Loading branch information
mandel-macaque committed Feb 1, 2025
1 parent aa4e62c commit fec4ab5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ public ExportData? ExportMethodData {
/// True if the method was exported with the MarshalNativeExceptions flag allowing it to support native exceptions.
/// </summary>
public bool MarshalNativeExceptions => HasMarshalNativeExceptionsFlag;

const string constructorName = "Constructor";
/// <summary>
/// True if the method is considered to be a constructor in the old bindings.
/// </summary>
public bool IsConstructor => Name == constructorName;

public Method (string type,
string name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,21 @@ namespace Microsoft.Macios.Transformer.Tests.DataModel;

public class MethodTests : BaseTransformerTestClass {

[Theory]
[InlineData ("Hello", false)]
[InlineData ("Constructor", true)]
public void IsConstructorTests (string methodName, bool expectedResult)
{
var method = new Method (
type: "TestClass",
name: methodName,
returnType: ReturnTypeForVoid (),
symbolAvailability: new(),
attributes: new(),
parameters: []);
Assert.Equal (expectedResult, method.IsConstructor);
}

class TestDataTryCreate : IEnumerable<object []> {
public IEnumerator<object []> GetEnumerator ()
{
Expand Down

0 comments on commit fec4ab5

Please sign in to comment.