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

[Rgen] Mark 'Constructor' named methods as constructors in the transformer. #22095

Merged
merged 3 commits into from
Feb 2, 2025
Merged
Changes from 1 commit
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
Next Next commit
[Rgen] Mark 'Constructor' named methods as constructors in the transf…
…ormer.

The old bindings use that name to denote constructors, these methods in
the new API will be converted to actual constructors.
mandel-macaque committed Feb 1, 2025
commit fec4ab532e1f21f554486b77abac24cf22a4efeb
Original file line number Diff line number Diff line change
@@ -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,
Original file line number Diff line number Diff line change
@@ -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 ()
{