[generator] Dispose of the universe when done with it. (#13305)

Hopefully fixes https://github.com/xamarin/maccore/issues/2463.
This commit is contained in:
Rolf Bjarne Kvinge 2021-11-08 21:02:46 +01:00 коммит произвёл GitHub
Родитель 9daff111e6
Коммит b083494e4b
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 21 добавлений и 3 удалений

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

@ -42,7 +42,7 @@ using Foundation;
using Xamarin.Bundler; using Xamarin.Bundler;
using Xamarin.Utils; using Xamarin.Utils;
public class BindingTouch { public class BindingTouch : IDisposable {
TargetFramework? target_framework; TargetFramework? target_framework;
public PlatformName CurrentPlatform; public PlatformName CurrentPlatform;
public bool BindThirdPartyLibrary = true; public bool BindThirdPartyLibrary = true;
@ -59,7 +59,7 @@ public class BindingTouch {
public TypeManager TypeManager = new TypeManager (); public TypeManager TypeManager = new TypeManager ();
public Frameworks? Frameworks; public Frameworks? Frameworks;
public AttributeManager? AttributeManager; public AttributeManager? AttributeManager;
bool disposedValue;
readonly Dictionary<System.Type, Type> ikvm_type_lookup = new Dictionary<System.Type, Type> (); readonly Dictionary<System.Type, Type> ikvm_type_lookup = new Dictionary<System.Type, Type> ();
internal Dictionary<System.Type, Type> IKVMTypeLookup { internal Dictionary<System.Type, Type> IKVMTypeLookup {
get { return ikvm_type_lookup; } get { return ikvm_type_lookup; }
@ -195,7 +195,7 @@ public class BindingTouch {
static int Main2 (string [] args) static int Main2 (string [] args)
{ {
var touch = new BindingTouch (); using var touch = new BindingTouch ();
return touch.Main3 (args); return touch.Main3 (args);
} }
@ -593,6 +593,24 @@ public class BindingTouch {
return di.FullName; return di.FullName;
} }
} }
protected virtual void Dispose (bool disposing)
{
if (!disposedValue) {
if (disposing) {
universe?.Dispose ();
universe = null;
}
disposedValue = true;
}
}
public void Dispose ()
{
Dispose (disposing: true);
GC.SuppressFinalize (this);
}
} }
static class ReferenceFixer static class ReferenceFixer