[Generator] Move GeneratedType out and enable nullability. (#17434)
Co-authored-by: GitHub Actions Autoformatter <github-actions-autoformatter@xamarin.com>
This commit is contained in:
Родитель
367f0a5c13
Коммит
84b3e3e09d
|
@ -0,0 +1,52 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
|
||||
#nullable enable
|
||||
|
||||
//
|
||||
// This class is used to generate a graph of the type hierarchy of the
|
||||
// generated types and required by the UIApperance support to determine
|
||||
// which types need to have Appearance methods created
|
||||
//
|
||||
public class GeneratedType {
|
||||
public GeneratedType (Type t, GeneratedTypes root)
|
||||
{
|
||||
Root = root;
|
||||
Type = t;
|
||||
var generator = root.Generator;
|
||||
foreach (var iface in Type.GetInterfaces ()) {
|
||||
if (iface.Name == "UIAppearance" || iface.Name == "IUIAppearance")
|
||||
ImplementsAppearance = true;
|
||||
}
|
||||
var btype = ReflectionExtensions.GetBaseType (Type, generator);
|
||||
if (btype != generator.TypeManager.System_Object) {
|
||||
Parent = btype;
|
||||
// protected against a StackOverflowException - bug #19751
|
||||
// it does not protect against large cycles (but good against copy/paste errors)
|
||||
if (Parent == Type)
|
||||
throw new BindingException (1030, true, Type, Parent);
|
||||
ParentGenerated = Root.Lookup (Parent);
|
||||
|
||||
// If our parent had UIAppearance, we flag this class as well
|
||||
if (ParentGenerated.ImplementsAppearance)
|
||||
ImplementsAppearance = true;
|
||||
ParentGenerated.Children.Add (this);
|
||||
}
|
||||
|
||||
if (generator.AttributeManager.HasAttribute<CategoryAttribute> (t))
|
||||
ImplementsAppearance = false;
|
||||
}
|
||||
public GeneratedTypes Root;
|
||||
public Type Type;
|
||||
public List<GeneratedType> Children = new (1);
|
||||
public Type? Parent;
|
||||
public GeneratedType? ParentGenerated;
|
||||
public bool ImplementsAppearance;
|
||||
|
||||
List<MemberInfo>? appearance_selectors;
|
||||
|
||||
public List<MemberInfo> AppearanceSelectors {
|
||||
get { return appearance_selectors ??= new (); }
|
||||
}
|
||||
}
|
|
@ -54,57 +54,6 @@ using ObjCRuntime;
|
|||
using Foundation;
|
||||
using Xamarin.Utils;
|
||||
|
||||
//
|
||||
// This class is used to generate a graph of the type hierarchy of the
|
||||
// generated types and required by the UIApperance support to determine
|
||||
// which types need to have Appearance methods created
|
||||
//
|
||||
public class GeneratedType {
|
||||
public GeneratedType (Type t, GeneratedTypes root)
|
||||
{
|
||||
Root = root;
|
||||
Type = t;
|
||||
var generator = root.Generator;
|
||||
foreach (var iface in Type.GetInterfaces ()) {
|
||||
if (iface.Name == "UIAppearance" || iface.Name == "IUIAppearance")
|
||||
ImplementsAppearance = true;
|
||||
}
|
||||
var btype = ReflectionExtensions.GetBaseType (Type, generator);
|
||||
if (btype != generator.TypeManager.System_Object) {
|
||||
Parent = btype;
|
||||
// protected against a StackOverflowException - bug #19751
|
||||
// it does not protect against large cycles (but good against copy/paste errors)
|
||||
if (Parent == Type)
|
||||
throw new BindingException (1030, true, Type, Parent);
|
||||
ParentGenerated = Root.Lookup (Parent);
|
||||
|
||||
// If our parent had UIAppearance, we flag this class as well
|
||||
if (ParentGenerated.ImplementsAppearance)
|
||||
ImplementsAppearance = true;
|
||||
ParentGenerated.Children.Add (this);
|
||||
}
|
||||
|
||||
if (generator.AttributeManager.HasAttribute<CategoryAttribute> (t))
|
||||
ImplementsAppearance = false;
|
||||
}
|
||||
public GeneratedTypes Root;
|
||||
public Type Type;
|
||||
public List<GeneratedType> Children = new List<GeneratedType> (1);
|
||||
public Type Parent;
|
||||
public GeneratedType ParentGenerated;
|
||||
public bool ImplementsAppearance;
|
||||
|
||||
List<MemberInfo> appearance_selectors;
|
||||
|
||||
public List<MemberInfo> AppearanceSelectors {
|
||||
get {
|
||||
if (appearance_selectors == null)
|
||||
appearance_selectors = new List<MemberInfo> ();
|
||||
return appearance_selectors;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class GeneratedTypes {
|
||||
public Generator Generator;
|
||||
|
||||
|
|
|
@ -24,9 +24,9 @@ public class TrampolineInfo {
|
|||
public string DelegateReturnType;
|
||||
public string ReturnFormat;
|
||||
public string Clear;
|
||||
public string OutReturnType;
|
||||
public string? OutReturnType;
|
||||
public string PostConvert;
|
||||
public string UserDelegateTypeAttribute;
|
||||
public string? UserDelegateTypeAttribute;
|
||||
public Type Type;
|
||||
|
||||
public TrampolineInfo (string userDelegate, string delegateName, string trampolineName, string pars,
|
||||
|
|
|
@ -100,6 +100,7 @@
|
|||
<Compile Include="..\src\bgen\Enums.cs" />
|
||||
<Compile Include="..\src\bgen\ExtensionMethods.cs" />
|
||||
<Compile Include="..\src\bgen\Filters.cs" />
|
||||
<Compile Include="..\src\bgen\GeneratedType.cs" />
|
||||
<Compile Include="..\src\bgen\Generator.cs" />
|
||||
<Compile Include="..\src\bgen\MarshalInfo.cs" />
|
||||
<Compile Include="..\src\bgen\NamespaceManager.cs" />
|
||||
|
|
Загрузка…
Ссылка в новой задаче