diff --git a/src/bgen/bgen.csproj b/src/bgen/bgen.csproj index 169f5201d8..1b2b1f74df 100644 --- a/src/bgen/bgen.csproj +++ b/src/bgen/bgen.csproj @@ -31,7 +31,11 @@ + + + + @@ -60,15 +64,6 @@ Execution.cs - - src\generator-namespace-manager.cs - - - src\generator-extension-methods.cs - - - src\generator-nullability-info-context.cs - ..\Resources.resx diff --git a/src/generator-marshal-info.cs b/src/generator-marshal-info.cs new file mode 100644 index 0000000000..2006facdf8 --- /dev/null +++ b/src/generator-marshal-info.cs @@ -0,0 +1,41 @@ +using System; +using System.Reflection; + +#nullable enable + +// +// Used to encapsulate flags about types in either the parameter or the return value +// For now, it only supports the [PlainString] attribute on strings. +// +public class MarshalInfo { + public Generator Generator { get; } + public bool PlainString { get; } + public Type Type { get; } + public bool IsOut { get; } + + // This is set on a string parameter if the argument parameters are set to + // Copy. This means that we can do fast string passing. + public bool ZeroCopyStringMarshal { get; set; } + + public bool IsAligned; + + // Used for parameters + public MarshalInfo (Generator generator, MethodInfo mi, ParameterInfo pi) + { + this.Generator = generator; + PlainString = Generator.AttributeManager.HasAttribute (pi); + Type = pi.ParameterType; + ZeroCopyStringMarshal = (Type == Generator.TypeManager.System_String) && PlainString == false && !Generator.AttributeManager.HasAttribute (pi) && generator.type_wants_zero_copy; + if (ZeroCopyStringMarshal && Generator.AttributeManager.HasAttribute (mi)) + ZeroCopyStringMarshal = false; + IsOut = TypeManager.IsOutParameter (pi); + } + + // Used to return values + public MarshalInfo (Generator generator, MethodInfo mi) + { + this.Generator = generator; + PlainString = Generator.AttributeManager.HasAttribute (AttributeManager.GetReturnTypeCustomAttributes (mi)); + Type = mi.ReturnType; + } +} diff --git a/src/generator.cs b/src/generator.cs index 7c44b6061e..83166fd73e 100644 --- a/src/generator.cs +++ b/src/generator.cs @@ -54,43 +54,6 @@ using ObjCRuntime; using Foundation; using Xamarin.Utils; -// -// Used to encapsulate flags about types in either the parameter or the return value -// For now, it only supports the [PlainString] attribute on strings. -// -public class MarshalInfo { - public Generator Generator; - public bool PlainString; - public Type Type; - public bool IsOut; - - // This is set on a string parameter if the argument parameters are set to - // Copy. This means that we can do fast string passing. - public bool ZeroCopyStringMarshal; - - public bool IsAligned; - - // Used for parameters - public MarshalInfo (Generator generator, MethodInfo mi, ParameterInfo pi) - { - this.Generator = generator; - PlainString = Generator.AttributeManager.HasAttribute (pi); - Type = pi.ParameterType; - ZeroCopyStringMarshal = (Type == Generator.TypeManager.System_String) && PlainString == false && !Generator.AttributeManager.HasAttribute (pi) && generator.type_wants_zero_copy; - if (ZeroCopyStringMarshal && Generator.AttributeManager.HasAttribute (mi)) - ZeroCopyStringMarshal = false; - IsOut = TypeManager.IsOutParameter (pi); - } - - // Used to return values - public MarshalInfo (Generator generator, MethodInfo mi) - { - this.Generator = generator; - PlainString = Generator.AttributeManager.HasAttribute (AttributeManager.GetReturnTypeCustomAttributes (mi)); - Type = mi.ReturnType; - } -} - // // Encapsulates the information necessary to create a block delegate // diff --git a/src/generator.csproj b/src/generator.csproj index 0e13a458fc..6b3ab16c16 100644 --- a/src/generator.csproj +++ b/src/generator.csproj @@ -98,7 +98,11 @@ + + + + @@ -128,9 +132,6 @@ Execution.cs - - - Resources.resx