[Generator] Move GeneratedTypes out and enable nullability. (#17435)
Moved the code out, also made a small improvement by reducing the number of lookups are needed to get the GeneratedType.
This commit is contained in:
Родитель
59aebf259c
Коммит
961c0e5b5b
|
@ -0,0 +1,24 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
#nullable enable
|
||||
|
||||
public class GeneratedTypes {
|
||||
public Generator Generator;
|
||||
|
||||
readonly Dictionary<Type, GeneratedType> knownTypes = new ();
|
||||
|
||||
public GeneratedTypes (Generator generator)
|
||||
{
|
||||
this.Generator = generator;
|
||||
}
|
||||
|
||||
public GeneratedType Lookup (Type t)
|
||||
{
|
||||
if (knownTypes.TryGetValue (t, out var n))
|
||||
return n;
|
||||
n = new (t, this);
|
||||
knownTypes [t] = n;
|
||||
return n;
|
||||
}
|
||||
}
|
|
@ -54,26 +54,6 @@ using ObjCRuntime;
|
|||
using Foundation;
|
||||
using Xamarin.Utils;
|
||||
|
||||
public class GeneratedTypes {
|
||||
public Generator Generator;
|
||||
|
||||
Dictionary<Type, GeneratedType> knownTypes = new Dictionary<Type, GeneratedType> ();
|
||||
|
||||
public GeneratedTypes (Generator generator)
|
||||
{
|
||||
this.Generator = generator;
|
||||
}
|
||||
|
||||
public GeneratedType Lookup (Type t)
|
||||
{
|
||||
if (knownTypes.ContainsKey (t))
|
||||
return knownTypes [t];
|
||||
var n = new GeneratedType (t, this);
|
||||
knownTypes [t] = n;
|
||||
return n;
|
||||
}
|
||||
}
|
||||
|
||||
public interface IMemberGatherer {
|
||||
IEnumerable<MethodInfo> GetTypeContractMethods (Type source);
|
||||
}
|
||||
|
|
|
@ -101,6 +101,7 @@
|
|||
<Compile Include="..\src\bgen\ExtensionMethods.cs" />
|
||||
<Compile Include="..\src\bgen\Filters.cs" />
|
||||
<Compile Include="..\src\bgen\GeneratedType.cs" />
|
||||
<Compile Include="..\src\bgen\GeneratedTypes.cs" />
|
||||
<Compile Include="..\src\bgen\Generator.cs" />
|
||||
<Compile Include="..\src\bgen\MarshalInfo.cs" />
|
||||
<Compile Include="..\src\bgen\NamespaceManager.cs" />
|
||||
|
|
Загрузка…
Ссылка в новой задаче