[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:
Manuel de la Pena 2023-02-06 18:01:29 -05:00 коммит произвёл GitHub
Родитель 59aebf259c
Коммит 961c0e5b5b
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 25 добавлений и 20 удалений

Просмотреть файл

@ -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" />