diff --git a/CHANGELOG.md b/CHANGELOG.md index f815d76..89b6a64 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,20 @@ # Microsoft.Extensions.Hosting for Unity +## [1.2.0] - 2021-07-23 +### Fixed +- Removed reload on change for FileConfigurationSources (caused UnityEditor to enter play mode with long delay) + +### Added +- ScriptableObject registration +- MonoBehaviour HostedService registration +- Possibility to pass args to the host +- Host log level parameter in the host Inspector +- Host graceful shutduwn timeout parameter in the host Inspector + +## [1.1.0] - 2021-05-27 +### Fixed +- Dependency resolving for MonoBehaviours + ## [1.0.4] - 2021-05-27 ### Fixed - Dependency resolving for MonoBehaviours diff --git a/CHANGELOG.md.meta b/CHANGELOG.md.meta index 3a96b08..650091f 100644 --- a/CHANGELOG.md.meta +++ b/CHANGELOG.md.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 34c92eefb2b277e409644b21fcbb6570 +guid: 9b99558518613ab4da9e461ffb51abee TextScriptImporter: externalObjects: {} userData: diff --git a/Documentation.meta b/Documentation.meta index 293a4b4..4daf261 100644 --- a/Documentation.meta +++ b/Documentation.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: caecc24540c038c4a83d5790cc77e22f +guid: 5051de82ea24c2448966c752f0a7df51 folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Documentation/microsoft.extensions.hosting.md.meta b/Documentation/microsoft.extensions.hosting.md.meta index 7acb8fd..a654c35 100644 --- a/Documentation/microsoft.extensions.hosting.md.meta +++ b/Documentation/microsoft.extensions.hosting.md.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: ee2d0f67f1888b24691fc8abcd290338 +guid: 10104ec9833fb3a428ff47ab443fdc5f TextScriptImporter: externalObjects: {} userData: diff --git a/Editor.meta b/Editor.meta index ed41c12..9205256 100644 --- a/Editor.meta +++ b/Editor.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: f3bfa0681d67df3439ba882bf5e72f18 +guid: ee3ad722a9e71e84bb9e419fc5a29e22 folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Editor/Bsr.Microsoft.Extensions.Hosting.Unity.Editor.asmdef b/Editor/Bsr.Microsoft.Extensions.Hosting.Unity.Editor.asmdef index 6c8e469..3c0fb63 100644 --- a/Editor/Bsr.Microsoft.Extensions.Hosting.Unity.Editor.asmdef +++ b/Editor/Bsr.Microsoft.Extensions.Hosting.Unity.Editor.asmdef @@ -1,8 +1,8 @@ { "name": "Bsr.Microsoft.Extensions.Hosting.Unity.Editor", - "rootNamespace": "", + "rootNamespace": "Microsoft.Extensions.Hosting.Unity", "references": [ - "GUID:71c6c6e852165ba4581c85f94bb30ef3" + "GUID:f02d2e96a369c224ba36e2b6953983a3" ], "includePlatforms": [ "Editor" diff --git a/Editor/Bsr.Microsoft.Extensions.Hosting.Unity.Editor.asmdef.meta b/Editor/Bsr.Microsoft.Extensions.Hosting.Unity.Editor.asmdef.meta index 2af8809..2121869 100644 --- a/Editor/Bsr.Microsoft.Extensions.Hosting.Unity.Editor.asmdef.meta +++ b/Editor/Bsr.Microsoft.Extensions.Hosting.Unity.Editor.asmdef.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 46ce381c3e71b704ca709b2ee613d18d +guid: 143b881097284564d99889963dd009bb AssemblyDefinitionImporter: externalObjects: {} userData: diff --git a/Editor/Extensions.meta b/Editor/Extensions.meta index 2f020a7..29a21eb 100644 --- a/Editor/Extensions.meta +++ b/Editor/Extensions.meta @@ -1,3 +1,3 @@ fileFormatVersion: 2 -guid: 2f99b5357dc9452c9f2a80e68e149195 +guid: 2ada831a0f8eb734aae8ded8197c5fd2 timeCreated: 1618790039 \ No newline at end of file diff --git a/Editor/Extensions/ReflectionExtensions.cs.meta b/Editor/Extensions/ReflectionExtensions.cs.meta index 868e29a..afc10ca 100644 --- a/Editor/Extensions/ReflectionExtensions.cs.meta +++ b/Editor/Extensions/ReflectionExtensions.cs.meta @@ -1,3 +1,3 @@ fileFormatVersion: 2 -guid: 4c316f199e5840488d11b6efd32de0e3 +guid: 39172b2494b0e454084f3be523ed224e timeCreated: 1618790046 \ No newline at end of file diff --git a/Editor/Gizmos.meta b/Editor/Gizmos.meta index f964760..cfad50e 100644 --- a/Editor/Gizmos.meta +++ b/Editor/Gizmos.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: fb14b973a32909f499d0d98467aae001 +guid: be26815a39722bd4ab4608729342f68e folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Editor/Gizmos/host_container_icon.png.meta b/Editor/Gizmos/host_container_icon.png.meta index bd943fd..68c149f 100644 --- a/Editor/Gizmos/host_container_icon.png.meta +++ b/Editor/Gizmos/host_container_icon.png.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: a03e91cef1d45774b9ea96a3f579f111 +guid: b59a5535de5a2ce4da5c0f2cd3f233c1 TextureImporter: internalIDToNameTable: [] externalObjects: {} diff --git a/Editor/Gizmos/host_service_icon.png.meta b/Editor/Gizmos/host_service_icon.png.meta index 4f6eada..d201adb 100644 --- a/Editor/Gizmos/host_service_icon.png.meta +++ b/Editor/Gizmos/host_service_icon.png.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 321274036afe9ed429daa4be5a24137b +guid: 068b8be04a3e3284aac59db74cde5eeb TextureImporter: internalIDToNameTable: [] externalObjects: {} diff --git a/Editor/MonoBehaviourHostRootEditor.cs b/Editor/MonoBehaviourHostRootEditor.cs index f0a4384..2bc9c4f 100644 --- a/Editor/MonoBehaviourHostRootEditor.cs +++ b/Editor/MonoBehaviourHostRootEditor.cs @@ -1,7 +1,29 @@ -namespace Editor +using System.Diagnostics; +using UnityEditor; + +namespace Microsoft.Extensions.Hosting.Unity.Editor { - public class MonoBehaviourHostRootEditor + [CustomEditor(typeof(MonoBehaviourHostRoot))] + public class MonoBehaviourHostRootEditor : UnityEditor.Editor { - + private const string GITHUB_URL = "https://github.com/amelkor/Microsoft.Extensions.Hosting.Unity"; + + public override void OnInspectorGUI() + { + EditorGUILayout.HelpBox( + "This script is controlled by HostManager component and keeps resolved MonoBehaviour services.", + MessageType.Info); + + // ReSharper disable once InvertIf + if (EditorGUILayout.LinkButton("For additional information visit the GitHub link")) + { + var ps = new ProcessStartInfo(GITHUB_URL) + { + UseShellExecute = true, + Verb = "open" + }; + Process.Start(ps); + } + } } } \ No newline at end of file diff --git a/Editor/MonoBehaviourHostRootEditor.cs.meta b/Editor/MonoBehaviourHostRootEditor.cs.meta new file mode 100644 index 0000000..593d1b5 --- /dev/null +++ b/Editor/MonoBehaviourHostRootEditor.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: ec99a40694b64413a7da815e7b2c88a9 +timeCreated: 1624484286 \ No newline at end of file diff --git a/LICENCE.md.meta b/LICENCE.md.meta index 081d30c..9bd2b86 100644 --- a/LICENCE.md.meta +++ b/LICENCE.md.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 896efd05bc625f240a52910f3f506587 +guid: 2970ced754a4c954496f85a8b84655b3 TextScriptImporter: externalObjects: {} userData: diff --git a/README.md b/README.md index f04ce35..eeb45d1 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,8 @@ Add the entry below to the project's manifest.json "name": "microsoft.extensions.hosting", "url": "https://registry.npmjs.org", "scopes": [ - "com.blacksmallriver.microsoft.extensions.hosting" + "com.blacksmallriver.hosting", + "com.blacksmallriver" ] } ] @@ -31,7 +32,7 @@ Or add it in Unity Editor: > > URL: https://registry.npmjs.org > -> scope: com.blacksmallriver.microsoft.extensions.hosting +> scope: com.blacksmallriver.hosting ### UPM Package install via git URL (no package updates will be available this way): diff --git a/README.md.meta b/README.md.meta index 4763f8e..7f1d1ca 100644 --- a/README.md.meta +++ b/README.md.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 7cd548058a75e5c4e8b293775871a570 +guid: 269c5f052f17e75459df9132a73ebc07 TextScriptImporter: externalObjects: {} userData: diff --git a/Runtime.meta b/Runtime.meta index 62554c0..9991e0d 100644 --- a/Runtime.meta +++ b/Runtime.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 0639570c5769f0b4bac6e6c5cc061b1a +guid: e668c52e77f49544aac81259d55b7e26 folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Runtime/Abstractions.meta b/Runtime/Abstractions.meta index 3daf03f..3ba36e2 100644 --- a/Runtime/Abstractions.meta +++ b/Runtime/Abstractions.meta @@ -1,3 +1,3 @@ fileFormatVersion: 2 -guid: 1808a5d772d3450ba1ef7f2cd794da94 +guid: 79ff3e098c36cf249abe09db3707a3b0 timeCreated: 1618749807 \ No newline at end of file diff --git a/Runtime/Abstractions/IUnityObjectServiceCollectionBuilder.cs b/Runtime/Abstractions/IUnityObjectServiceCollectionBuilder.cs index c577a70..bdb2319 100644 --- a/Runtime/Abstractions/IUnityObjectServiceCollectionBuilder.cs +++ b/Runtime/Abstractions/IUnityObjectServiceCollectionBuilder.cs @@ -3,20 +3,19 @@ namespace Microsoft.Extensions.Hosting.Unity { - public interface IMonoBehaviourServiceCollectionBuilder + public interface IUnityObjectServiceCollectionBuilder { - IMonoBehaviourServiceCollectionBuilder AddMonoBehaviourSingleton(MonoBehaviour component, Type type = default, bool useHostLifetime = false); - IMonoBehaviourServiceCollectionBuilder AddMonoBehaviourSingleton() where T : MonoBehaviour; - IMonoBehaviourServiceCollectionBuilder AddMonoBehaviourHostedService() where T : MonoBehaviour, IHostedService; - IMonoBehaviourServiceCollectionBuilder AddMonoBehaviourHostedService() where T : MonoBehaviour, IHostedService where TImpl : MonoBehaviour, T; - IMonoBehaviourServiceCollectionBuilder AddMonoBehaviourSingleton(TImpl component, bool useHostLifetime = false) where TImpl : MonoBehaviour, T where T : class; - IMonoBehaviourServiceCollectionBuilder AddMonoBehaviourSingleton() where T : class where TImpl : MonoBehaviour, T; - IMonoBehaviourServiceCollectionBuilder AddMonoBehaviourTransient() where T : MonoBehaviour; - IMonoBehaviourServiceCollectionBuilder AddMonoBehaviourTransient() where T : class where TImpl : MonoBehaviour, T; + IUnityObjectServiceCollectionBuilder AddMonoBehaviourSingleton(MonoBehaviour component, Type type = default, bool useHostLifetime = false); + IUnityObjectServiceCollectionBuilder AddMonoBehaviourSingleton() where T : MonoBehaviour; + IUnityObjectServiceCollectionBuilder AddMonoBehaviourHostedService() where T : MonoBehaviour, IHostedService; + IUnityObjectServiceCollectionBuilder AddMonoBehaviourHostedService() where T : MonoBehaviour, IHostedService where TImpl : MonoBehaviour, T; + IUnityObjectServiceCollectionBuilder AddMonoBehaviourSingleton(TImpl component, bool useHostLifetime = false) where TImpl : MonoBehaviour, T where T : class; + IUnityObjectServiceCollectionBuilder AddMonoBehaviourSingleton() where T : class where TImpl : MonoBehaviour, T; + IUnityObjectServiceCollectionBuilder AddMonoBehaviourTransient() where T : MonoBehaviour; + IUnityObjectServiceCollectionBuilder AddMonoBehaviourTransient() where T : class where TImpl : MonoBehaviour, T; - IMonoBehaviourServiceCollectionBuilder AddScriptableObjectSingleton() where T : ScriptableObject; - IMonoBehaviourServiceCollectionBuilder AddScriptableObjectSingleton() where T : ScriptableObject where TImpl : ScriptableObject, T; - IMonoBehaviourServiceCollectionBuilder AddScriptableObjectTransient() where T : ScriptableObject; - IMonoBehaviourServiceCollectionBuilder AddScriptableObjectTransient() where T : class where TImpl : ScriptableObject, T; + IUnityObjectServiceCollectionBuilder AddScriptableObjectSingleton(ScriptableObject scriptableObject, Type type); + IUnityObjectServiceCollectionBuilder AddScriptableObjectSingleton(T scriptableObject) where T : ScriptableObject; + IUnityObjectServiceCollectionBuilder AddScriptableObjectSingleton(TImpl scriptableObject) where T : ScriptableObject where TImpl : ScriptableObject, T; } } \ No newline at end of file diff --git a/Runtime/Bsr.Microsoft.Extensions.Hosting.Unity.Runtime.asmdef.meta b/Runtime/Bsr.Microsoft.Extensions.Hosting.Unity.Runtime.asmdef.meta index 1ca8111..ca4cece 100644 --- a/Runtime/Bsr.Microsoft.Extensions.Hosting.Unity.Runtime.asmdef.meta +++ b/Runtime/Bsr.Microsoft.Extensions.Hosting.Unity.Runtime.asmdef.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 71c6c6e852165ba4581c85f94bb30ef3 +guid: f02d2e96a369c224ba36e2b6953983a3 AssemblyDefinitionImporter: externalObjects: {} userData: diff --git a/Runtime/Configuration.meta b/Runtime/Configuration.meta new file mode 100644 index 0000000..ed24287 --- /dev/null +++ b/Runtime/Configuration.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: f43bb14c88144425b15a92155fd158d6 +timeCreated: 1625685723 \ No newline at end of file diff --git a/Runtime/Configuration/GlobalSettings.cs b/Runtime/Configuration/GlobalSettings.cs index b384887..f646180 100644 --- a/Runtime/Configuration/GlobalSettings.cs +++ b/Runtime/Configuration/GlobalSettings.cs @@ -7,13 +7,17 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Primitives; -namespace Microsoft.Extensions.Hosting.Unity +namespace Microsoft.Extensions.Hosting.Unity.Configuration { + /// + /// Configuration provider automatically creates Config/globalsettings.json under the Game's directory. + /// Inherit from this class and extend it with properties to use them as configuration keys. + /// [Serializable] - public class AppSettings : IConfigurationProvider + public abstract class GlobalSettings : IConfigurationProvider { internal const string ConfigDirPath = "Config"; - internal const string ConfigFilePath = "appsettings.json"; + internal const string ConfigFilePath = "globalsettings.json"; internal const string LocalFilePath = ConfigDirPath + "/" + ConfigFilePath; private static readonly System.Text.Json.JsonSerializerOptions _serializerOptions = new System.Text.Json.JsonSerializerOptions {Encoder = System.Text.Encodings.Web.JavaScriptEncoder.UnsafeRelaxedJsonEscaping, WriteIndented = true}; private readonly Type _type; @@ -21,7 +25,7 @@ public class AppSettings : IConfigurationProvider private IConfigurationRoot _configurationRoot; private ConfigurationReloadToken _reloadToken = new ConfigurationReloadToken(); - protected AppSettings() + protected GlobalSettings() { _type = GetType(); _properties = _type.GetProperties( @@ -32,6 +36,10 @@ protected AppSettings() .ToDictionary(p => p.Name, p => p); } + /// + /// For internal purpose. + /// + /// internal void SetConfiguration(IConfiguration configuration) { // ReSharper disable once InvertIf @@ -69,6 +77,9 @@ public void Set(string key, string value) public IChangeToken GetReloadToken() => _reloadToken; + /// + /// Read configuration from the config file. + /// public void Load() { var json = BeforeLoad(File.ReadAllText(LocalFilePath)); @@ -81,7 +92,6 @@ public void Load() } OnReload(); - _configurationRoot?.Reload(); } public virtual IEnumerable GetChildKeys(IEnumerable earlierKeys, string parentPath) @@ -101,14 +111,15 @@ private static string Segment(string key, int prefixLength) return indexOf < 0 ? key.Substring(prefixLength) : key.Substring(prefixLength, indexOf - prefixLength); } + /// + /// Save configuration to the config file. + /// public void Save() { var json = BeforeSave(System.Text.Json.JsonSerializer.Serialize(this, _type, _serializerOptions)); Directory.CreateDirectory(ConfigDirPath); File.WriteAllText(LocalFilePath, json); - - _configurationRoot?.Reload(); } private void OnReload() @@ -117,8 +128,20 @@ private void OnReload() previousToken.OnReload(); } - public virtual string BeforeLoad(string json) => json; - + /// + /// Override to perform extra actions onto the serialized data that just was loaded from the config file. + /// Could be used to decrypt or unzip the data before deserializing. + /// + /// Raw data that was read from the config file. + /// Should return a valid json. + public virtual string BeforeLoad(string content) => content; + + /// + /// Override to perform extra actions onto the serialized json. + /// Could be used to encrypt or zip the data before writing to the config file. + /// + /// Json serialized data. + /// A content to save into the config file. public virtual string BeforeSave(string json) => json; public override string ToString() => _type.Name; diff --git a/Runtime/Configuration/GlobalSettings.cs.meta b/Runtime/Configuration/GlobalSettings.cs.meta new file mode 100644 index 0000000..b314a24 --- /dev/null +++ b/Runtime/Configuration/GlobalSettings.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: e24e0475149e40aebccc989c8abb22ff +timeCreated: 1625612334 \ No newline at end of file diff --git a/Runtime/Configuration/GlobalSettingsConfigurationSource.cs b/Runtime/Configuration/GlobalSettingsConfigurationSource.cs index 1fc90cd..6aaf070 100644 --- a/Runtime/Configuration/GlobalSettingsConfigurationSource.cs +++ b/Runtime/Configuration/GlobalSettingsConfigurationSource.cs @@ -1,7 +1,23 @@ -namespace Microsoft.Extensions.Hosting.Unity.Configuration +using System.IO; +using Microsoft.Extensions.Configuration; + +namespace Microsoft.Extensions.Hosting.Unity.Configuration { - public class GlobalSettings + public class GlobalSettingsConfigurationSource : IConfigurationSource where TSettings : GlobalSettings, new() { + internal TSettings Provider { get; private set; } + public IConfigurationProvider Build(IConfigurationBuilder builder) + { + var settings = new TSettings(); + + if (!File.Exists(GlobalSettings.LocalFilePath)) + settings.Save(); + else + settings.Load(); + + Provider = settings; + return settings; + } } } \ No newline at end of file diff --git a/Runtime/Configuration/GlobalSettingsConfigurationSource.cs.meta b/Runtime/Configuration/GlobalSettingsConfigurationSource.cs.meta new file mode 100644 index 0000000..b705167 --- /dev/null +++ b/Runtime/Configuration/GlobalSettingsConfigurationSource.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 7668689008ac40dc898c66269a4a36c8 +timeCreated: 1625685773 \ No newline at end of file diff --git a/Runtime/Constants.cs b/Runtime/Constants.cs index ef711b1..7f0d1a5 100644 --- a/Runtime/Constants.cs +++ b/Runtime/Constants.cs @@ -3,5 +3,6 @@ internal static class Constants { public const string ThisAssetName = "Service Host"; + public const string MonoBehaviourHostRootInstanceKey = "MONO_BEHAVIOUR_HOST_ROOT_INSTANCE"; } } \ No newline at end of file diff --git a/Runtime/Constants.cs.meta b/Runtime/Constants.cs.meta index 95ff300..2f296af 100644 --- a/Runtime/Constants.cs.meta +++ b/Runtime/Constants.cs.meta @@ -1,3 +1,3 @@ fileFormatVersion: 2 -guid: 674590f87f22443e8faea3baa8e91ebe +guid: d3aaf70ddcea001468e7a53658c7eee6 timeCreated: 1618783584 \ No newline at end of file diff --git a/Runtime/Extensions.meta b/Runtime/Extensions.meta index c9b6294..57d7c7d 100644 --- a/Runtime/Extensions.meta +++ b/Runtime/Extensions.meta @@ -1,3 +1,3 @@ fileFormatVersion: 2 -guid: ec65b1fefe454da794af13e748bbe04a +guid: b6117417833c41b4dabae60776cf469e timeCreated: 1618724514 \ No newline at end of file diff --git a/Runtime/Extensions/HostBuilderExtensions.cs b/Runtime/Extensions/HostBuilderExtensions.cs index c13da9e..5edd17c 100644 --- a/Runtime/Extensions/HostBuilderExtensions.cs +++ b/Runtime/Extensions/HostBuilderExtensions.cs @@ -1,5 +1,9 @@ using System; +using System.IO; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Configuration.Json; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting.Unity.Configuration; using UnityEngine; namespace Microsoft.Extensions.Hosting.Unity @@ -11,7 +15,7 @@ public static class HostBuilderExtensions { private const string INJECTABLE_METHOD_NAME = "AwakeServices"; private const string MONO_BEHAVIOUR_BUILDER_KEY = "MonoBehaviourBuilder"; - + /// /// Add classes to this services. /// @@ -19,19 +23,19 @@ public static class HostBuilderExtensions /// /// /// - public static IHostBuilder ConfigureMonoBehaviours(this IHostBuilder builder, Action configure) + public static IHostBuilder ConfigureMonoBehaviours(this IHostBuilder builder, Action configure) { if (!builder.Properties.TryGetValue(MONO_BEHAVIOUR_BUILDER_KEY, out var monoCollectionObject)) { throw new ArgumentException("MonoBehaviour ServiceCollection Builder is not registered in HostBuilder. Add " + nameof(UseMonoBehaviourServiceCollection) + " to the IHostBuilder"); } - var monoCollection = (IMonoBehaviourServiceCollectionBuilder) monoCollectionObject; + var monoCollection = (IUnityObjectServiceCollectionBuilder) monoCollectionObject; configure?.Invoke(monoCollection); return builder; } - + /// /// Enable in this container. /// @@ -45,13 +49,13 @@ internal static IHostBuilder UseMonoBehaviourServiceCollection(this IHostBuilder { throw new InvalidOperationException(nameof(UseMonoBehaviourServiceCollection) + " can not be called twice"); } - - var monoCollection = new MonoBehaviourServiceCollectionBuilder(hostBuilder, monoBehaviourInjectMethodName); + + var monoCollection = new UnityObjectServiceCollectionBuilder(hostBuilder, monoBehaviourInjectMethodName); hostBuilder.Properties.Add(MONO_BEHAVIOUR_BUILDER_KEY, monoCollection); - + return hostBuilder; } - + /// /// Allows to register a specific implementation to be injected. /// @@ -66,7 +70,23 @@ public static IServiceCollection AddHostedService(thi services.AddHostedService>(); return services; } - + + /// + /// Allows to register a specific implementation to be injected. + /// + /// + /// The factory that creates the service. + /// + /// + public static IServiceCollection AddHostedService(this IServiceCollection services, Func implementationFactory) + where TService : class + where TImplementation : class, IHostedService, TService + { + services.AddSingleton(implementationFactory); + services.AddHostedService>(); + return services; + } + /// /// Will suppress host lifetime messages logging if is set to true. /// @@ -79,6 +99,62 @@ public static IServiceCollection SuppressStatusMessages(this IServiceCollection return services; } + /// + /// Sets ApplicationName for the HostingEnvironment. + /// + /// + /// + /// + public static IHostBuilder SetApplicationName(this IHostBuilder builder, string name) + { + builder.ConfigureAppConfiguration((context, _) => context.HostingEnvironment.ApplicationName = name); + return builder; + } + + /// + /// Sets EnvironmentName for the HostingEnvironment. + /// + /// + /// + /// + public static IHostBuilder SetEnvironmentName(this IHostBuilder builder, string name) + { + builder.ConfigureAppConfiguration((context, _) => context.HostingEnvironment.EnvironmentName = name); + return builder; + } + + /// + /// Use Config/appsettings.json to store settings. + /// + /// + /// + // ReSharper disable once CognitiveComplexity + public static void UseGlobalSettings(this IHostBuilder hostBuilder) where TSettings : GlobalSettings, new() + { + const string globalSettingsConfigured = "GLOBALSETTINGS_CONFIGURED"; + const string globalSettingsSource = "GLOBALSETTINGS_SOURCE"; + + if (hostBuilder.Properties.TryGetValue(globalSettingsSource, out _)) + throw new InvalidOperationException("GlobalSettings already configured"); + + hostBuilder.ConfigureAppConfiguration((context, builder) => + { + var source = new GlobalSettingsConfigurationSource(); + builder.Add(source); + + if (!context.Properties.ContainsKey(globalSettingsSource)) + hostBuilder.Properties.Add(globalSettingsSource, source); + }); + hostBuilder.ConfigureServices((context, collection) => + { + if (context.Properties.TryGetValue(globalSettingsSource, out var source)) + { + if (source is GlobalSettingsConfigurationSource s) + collection.AddSingleton(s.Provider); + } + }); + } + #region private methods private static void SetupUnityComponent(T component, IServiceProvider provider) where T : MonoBehaviour diff --git a/Runtime/Extensions/HostBuilderExtensions.cs.meta b/Runtime/Extensions/HostBuilderExtensions.cs.meta index a492094..8c25b1c 100644 --- a/Runtime/Extensions/HostBuilderExtensions.cs.meta +++ b/Runtime/Extensions/HostBuilderExtensions.cs.meta @@ -1,3 +1,3 @@ fileFormatVersion: 2 -guid: 1d74c8876fe14ebc8fbce0463005c43d +guid: 4f45da2060465694096b0dc340aeb536 timeCreated: 1618645667 \ No newline at end of file diff --git a/Runtime/HostManager.cs b/Runtime/HostManager.cs index 2b14a60..834fb28 100644 --- a/Runtime/HostManager.cs +++ b/Runtime/HostManager.cs @@ -1,5 +1,5 @@ using System; -using System.Collections.Generic; +using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; @@ -14,10 +14,15 @@ namespace Microsoft.Extensions.Hosting.Unity /// /// Base class for using in Unity. /// - [DefaultExecutionOrder(-9000)] public abstract class HostManager : MonoBehaviour { + private const string DEFAULT_HOST_APPLICATION_NAME = "Unity Application"; private const string DEFAULT_INJECTION_METHOD_NAME = "AwakeServices"; + private const int DEFAULT_GRACEFUL_SHUTDOWN_TIMEOUT_MS = 5000; + private const int MIN_GRACEFUL_SHUTDOWN_TIMEOUT_MS = 100; + + [Tooltip("Application name for the HostingEnvironment")] + [SerializeField] private string hostApplicationName; [Tooltip("The method name which will be used to inject Host services. Works like constructor injection in ordinary classes, but since MonoBehaviours can't use constructors, this method will be used instead")] [SerializeField] private string servicesInjectionMethodName = DEFAULT_INJECTION_METHOD_NAME; @@ -25,15 +30,25 @@ public abstract class HostManager : MonoBehaviour [Tooltip("If false, " + nameof(BuildManually) + "() method needs to be called to build the host")] [SerializeField] private bool buildOnAwake = true; - [SerializeField] private bool bindWithUnityLifetime = true; + [SerializeField] private bool controlUnityLifetime; + + [Tooltip("Timeout for the host to shutdown gracefully")] + [SerializeField] private int gracefulShutduwnTimeoutMs = DEFAULT_GRACEFUL_SHUTDOWN_TIMEOUT_MS; [Header("Logging")] [Tooltip("Use Unity Debug.Log to print log messages")] [SerializeField] private bool logToUnity = true; + + [Tooltip("Minimum log level")] + [SerializeField] private LogLevel logLevel = LogLevel.Information; [Tooltip("Will suppress host lifetime messages logging if set to true")] [SerializeField] private bool suppressStatusMessages; + [Header("Options")] + [Tooltip("Optional command line arguments to pass into the Host")] + [SerializeField] private string[] cmdArguments; + [Header("Events")] [SerializeField] private UnityEvent hostBuilt; [SerializeField] private UnityEvent hostStarted; @@ -41,24 +56,48 @@ public abstract class HostManager : MonoBehaviour [SerializeField] private UnityEvent hostStopped; private IHostBuilder _hostBuilder; + + // ReSharper disable once MemberCanBePrivate.Global protected IHost host; + private CancellationTokenSource _cts; + private bool _isBuilt; private bool _isStarted; + /// + /// Override to use Unity's Awake() method. + /// protected virtual void OnAwake() { } + /// + /// Override to use Unity's Start() method. + /// protected virtual void OnStart() { } + + /// + /// Allows to add an extra step to the host builder before it's built. + /// + /// Host builder. + protected virtual void ConfigureExtra(IHostBuilder hostBuilder) + { + } protected abstract void ConfigureAppConfiguration(IConfigurationBuilder builder); protected abstract void ConfigureLogging(ILoggingBuilder builder); protected abstract void ConfigureServices(IServiceCollection services); - protected abstract void ConfigureMonoBehaviours(IMonoBehaviourServiceCollectionBuilder services); + protected abstract void ConfigureUnityObjects(IUnityObjectServiceCollectionBuilder services); + + // ReSharper disable once MemberCanBeProtected.Global + /// + /// The service provider of the Host. + /// + /// when the Host is not built yet. public IServiceProvider Services { get @@ -72,7 +111,8 @@ public IServiceProvider Services private void Awake() { - _hostBuilder = UnityHost.CreateDefaultBuilder(servicesInjectionMethodName); + _hostBuilder = UnityHost.CreateDefaultBuilder(servicesInjectionMethodName, cmdArguments); + _hostBuilder.ConfigureLogging(builder => builder.SetMinimumLevel(logLevel)); _hostBuilder.ConfigureLogging(ConfigureLogging); if (logToUnity) @@ -82,14 +122,16 @@ private void Awake() _hostBuilder.ConfigureServices(services => { services.SuppressStatusMessages(suppressStatusMessages); }); _hostBuilder.ConfigureServices(ConfigureServices); - _hostBuilder.ConfigureMonoBehaviours(ConfigureMonoBehaviours); - + _hostBuilder.ConfigureMonoBehaviours(ConfigureUnityObjects); + ConfigureExtra(_hostBuilder); OnAwake(); if (buildOnAwake) BuildHost(); } + #region Public API methods + /// /// Build the if set to false. /// @@ -110,7 +152,34 @@ public void BuildManually() BuildHost(); } - #region Public API methods + /// + /// Start the Host manually. Call this after . + /// + /// when the Host is not build yet. + public void StartManually() + { + if (!_isBuilt) + throw new InvalidOperationException("Host must be build before start."); + + StartHost(); + } + + /// + /// Start the Host manually. + /// + /// when the Host was not build and started yet. + public void StopManually() + { + if (!_isBuilt && !_isStarted) + throw new InvalidOperationException("Host must be build and started before stop."); + + if (host != null) + { + _cts?.Cancel(); + } + } + + #endregion private void BuildHost() { @@ -121,22 +190,31 @@ private void BuildHost() var lifetime = host.Services.GetRequiredService(); + // host events occur only once per Host lifetime so remove them after invocation + if (hostStarted != null) - lifetime.ApplicationStarted.Register(hostStarted.Invoke); + lifetime.ApplicationStarted.Register(() => + { + hostStarted.Invoke(); + hostStarted.RemoveAllListeners(); + }); if (hostStopping != null) - lifetime.ApplicationStopping.Register(hostStopping.Invoke); + lifetime.ApplicationStopping.Register(() => + { + hostStopping.Invoke(); + hostStopping.RemoveAllListeners(); + }); if (hostStopped != null) - lifetime.ApplicationStopped.Register(hostStopped.Invoke); + lifetime.ApplicationStopped.Register(() => + { + hostStopped.Invoke(); + hostStopped.RemoveAllListeners(); + }); - if (bindWithUnityLifetime) + if (controlUnityLifetime) { - Application.wantsToQuit += () => - { - lifetime.StopApplication(); - return true; - }; lifetime.ApplicationStopped.Register(() => { Debug.Log("Application stopped"); @@ -147,7 +225,18 @@ private void BuildHost() }); } + Application.quitting += () => + { + _cts?.Cancel(); + using var cts = new CancellationTokenSource(gracefulShutduwnTimeoutMs); + host.StopAsync(cts.Token) + .GetAwaiter() + .GetResult(); + host?.Dispose(); + }; + hostBuilt?.Invoke(); + hostBuilt?.RemoveAllListeners(); } catch (Exception) { @@ -156,11 +245,9 @@ private void BuildHost() } } - #endregion - #region Host control by Unity events - public async void Start() + private async void Start() { OnStart(); @@ -174,12 +261,14 @@ public async void Start() } } - private async void OnDisable() + private void OnEnable() { - if (host != null && _isBuilt && _isStarted) - { - await host.StopAsync(); - } + _cts = new CancellationTokenSource(); + } + + private void OnDisable() + { + _cts?.Cancel(); } #endregion @@ -217,7 +306,7 @@ private async Task StartHostAsync() } _isStarted = true; - await host.StartAsync(); + await host.StartAsync(_cts.Token); } catch (Exception) { @@ -233,6 +322,16 @@ private void OnValidate() { if (string.IsNullOrEmpty(servicesInjectionMethodName)) servicesInjectionMethodName = DEFAULT_INJECTION_METHOD_NAME; + + if (string.IsNullOrEmpty(hostApplicationName)) + { + hostApplicationName = string.IsNullOrEmpty(Application.productName) + ? DEFAULT_HOST_APPLICATION_NAME + : Application.productName; + } + + if (gracefulShutduwnTimeoutMs <= MIN_GRACEFUL_SHUTDOWN_TIMEOUT_MS) + gracefulShutduwnTimeoutMs = DEFAULT_GRACEFUL_SHUTDOWN_TIMEOUT_MS; } #endif } diff --git a/Runtime/HostManager.cs.meta b/Runtime/HostManager.cs.meta index 2066b70..24d08db 100644 --- a/Runtime/HostManager.cs.meta +++ b/Runtime/HostManager.cs.meta @@ -1,11 +1,11 @@ fileFormatVersion: 2 -guid: c59d6d0f1ff2ad94a9b1077f891e58d7 +guid: 7f38427c758a6af4e88c26804325046a MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] executionOrder: 0 - icon: {fileID: 2800000, guid: 321274036afe9ed429daa4be5a24137b, type: 3} + icon: {fileID: 2800000, guid: 068b8be04a3e3284aac59db74cde5eeb, type: 3} userData: assetBundleName: assetBundleVariant: diff --git a/Runtime/Internals.meta b/Runtime/Internals.meta index 63cfa67..eb3a0c8 100644 --- a/Runtime/Internals.meta +++ b/Runtime/Internals.meta @@ -1,3 +1,3 @@ fileFormatVersion: 2 -guid: b4686b981c484a1085898934d571a9ed +guid: 6d719c625f444324c92211e33b69264f timeCreated: 1618724586 \ No newline at end of file diff --git a/Runtime/Internals/Extensions.meta b/Runtime/Internals/Extensions.meta new file mode 100644 index 0000000..cadfa94 --- /dev/null +++ b/Runtime/Internals/Extensions.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 37cccf70b47f49c78f2ece6c1e1b4237 +timeCreated: 1624245902 \ No newline at end of file diff --git a/Runtime/Internals/Extensions/ConfigurationBuilderExtensions.cs b/Runtime/Internals/Extensions/ConfigurationBuilderExtensions.cs index 6e62377..9fe783a 100644 --- a/Runtime/Internals/Extensions/ConfigurationBuilderExtensions.cs +++ b/Runtime/Internals/Extensions/ConfigurationBuilderExtensions.cs @@ -11,7 +11,7 @@ internal static class ConfigurationBuilderExtensions /// File system watcher drastically increases Unity Editor enter playmode time. Better keep ReloadOnChange turned off /// /// - public static void DisableFileSourcesReloadOnChange(this IConfigurationBuilder builder) + public static void DisableFileConfigurationSourceReloadOnChange(this IConfigurationBuilder builder) { foreach (var source in builder.Sources) { diff --git a/Runtime/Internals/Extensions/ConfigurationBuilderExtensions.cs.meta b/Runtime/Internals/Extensions/ConfigurationBuilderExtensions.cs.meta new file mode 100644 index 0000000..bfb5cb8 --- /dev/null +++ b/Runtime/Internals/Extensions/ConfigurationBuilderExtensions.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 41bcf8e4eb184ad7ab263bd61b44b244 +timeCreated: 1624245519 \ No newline at end of file diff --git a/Runtime/Internals/HostedServiceWrapper.cs.meta b/Runtime/Internals/HostedServiceWrapper.cs.meta index 7e6c06f..4566c66 100644 --- a/Runtime/Internals/HostedServiceWrapper.cs.meta +++ b/Runtime/Internals/HostedServiceWrapper.cs.meta @@ -1,3 +1,3 @@ fileFormatVersion: 2 -guid: bd3cf9247d5a485c86a5bd5acb73e736 +guid: b08bfff9be50916439eb9699b6da092d timeCreated: 1618879179 \ No newline at end of file diff --git a/Runtime/Internals/InjectMethod.cs.meta b/Runtime/Internals/InjectMethod.cs.meta index e561938..e68fe21 100644 --- a/Runtime/Internals/InjectMethod.cs.meta +++ b/Runtime/Internals/InjectMethod.cs.meta @@ -1,3 +1,3 @@ fileFormatVersion: 2 -guid: a9ba01b2d75944119a7bb921c29249de +guid: ca8ee7e49df9d8a47b5f9227c431d567 timeCreated: 1618724628 \ No newline at end of file diff --git a/Runtime/Internals/Reflection.cs.meta b/Runtime/Internals/Reflection.cs.meta index 154ad0b..f5a87e8 100644 --- a/Runtime/Internals/Reflection.cs.meta +++ b/Runtime/Internals/Reflection.cs.meta @@ -1,3 +1,3 @@ fileFormatVersion: 2 -guid: 18242f872eb24c75a9b04a5e70e12840 +guid: 17318ffca6b445244bbd279b4837cbfb timeCreated: 1618724534 \ No newline at end of file diff --git a/Runtime/Internals/UnityObjectServiceCollectionBuilder.cs b/Runtime/Internals/UnityObjectServiceCollectionBuilder.cs index dcc8bc5..457b571 100644 --- a/Runtime/Internals/UnityObjectServiceCollectionBuilder.cs +++ b/Runtime/Internals/UnityObjectServiceCollectionBuilder.cs @@ -5,19 +5,31 @@ namespace Microsoft.Extensions.Hosting.Unity { /// - internal class MonoBehaviourServiceCollectionBuilder : IMonoBehaviourServiceCollectionBuilder + internal class UnityObjectServiceCollectionBuilder : IUnityObjectServiceCollectionBuilder { private readonly IHostBuilder _hostBuilder; private readonly string _serviceInjectionMethodName; - public MonoBehaviourServiceCollectionBuilder(IHostBuilder hostBuilder, string serviceInjectionMethodName) + public UnityObjectServiceCollectionBuilder(IHostBuilder hostBuilder, string serviceInjectionMethodName) { _hostBuilder = hostBuilder; _serviceInjectionMethodName = serviceInjectionMethodName; } + + private static IMonoBehaviourHostRoot GetHostRoot(HostBuilderContext context) + { + // ReSharper disable once InvertIf + if (context.Properties.TryGetValue(Constants.MonoBehaviourHostRootInstanceKey, out var root)) + { + if (root is IMonoBehaviourHostRoot r) + return r; + } + + throw new ArgumentException("HostBuilderContext does not contain IMonoBehaviourHostRoot"); + } /// - public IMonoBehaviourServiceCollectionBuilder AddMonoBehaviourSingleton(MonoBehaviour component, Type type = default, bool useHostLifetime = false) + public IUnityObjectServiceCollectionBuilder AddMonoBehaviourSingleton(MonoBehaviour component, Type type = default, bool useHostLifetime = false) { _hostBuilder.ConfigureServices(services => { @@ -37,17 +49,21 @@ public IMonoBehaviourServiceCollectionBuilder AddMonoBehaviourSingleton(MonoBeha return this; } - public IMonoBehaviourServiceCollectionBuilder AddMonoBehaviourHostedService() where T : MonoBehaviour, IHostedService + public IUnityObjectServiceCollectionBuilder AddMonoBehaviourHostedService() where T : MonoBehaviour, IHostedService { - _hostBuilder.ConfigureServices(services => + _hostBuilder.ConfigureServices((context, services) => { services.AddHostedService(provider => { - var root = provider.GetRequiredService(); + var root = GetHostRoot(context); var component = root.AddComponent(); + component.enabled = false; + InjectServices(component, provider, _serviceInjectionMethodName); SetupLifetime(component, provider, _serviceInjectionMethodName); + component.enabled = true; + return component; }); }); @@ -55,13 +71,13 @@ public IMonoBehaviourServiceCollectionBuilder AddMonoBehaviourHostedService() return this; } - public IMonoBehaviourServiceCollectionBuilder AddMonoBehaviourHostedService() where T : MonoBehaviour, IHostedService where TImpl : MonoBehaviour, T + public IUnityObjectServiceCollectionBuilder AddMonoBehaviourHostedService() where T : MonoBehaviour, IHostedService where TImpl : MonoBehaviour, T { - _hostBuilder.ConfigureServices(services => + _hostBuilder.ConfigureServices((context, services) => { services.AddHostedService(provider => { - var root = provider.GetRequiredService(); + var root = GetHostRoot(context); var component = root.AddComponent(); InjectServices(component, provider, _serviceInjectionMethodName); SetupLifetime(component, provider, _serviceInjectionMethodName); @@ -74,7 +90,7 @@ public IMonoBehaviourServiceCollectionBuilder AddMonoBehaviourHostedService - public IMonoBehaviourServiceCollectionBuilder AddMonoBehaviourSingleton(TImpl component, bool useHostLifetime = false) where TImpl : MonoBehaviour, T where T : class + public IUnityObjectServiceCollectionBuilder AddMonoBehaviourSingleton(TImpl component, bool useHostLifetime = false) where TImpl : MonoBehaviour, T where T : class { _hostBuilder.ConfigureServices(services => { @@ -93,13 +109,13 @@ public IMonoBehaviourServiceCollectionBuilder AddMonoBehaviourSingleton - public IMonoBehaviourServiceCollectionBuilder AddMonoBehaviourSingleton() where T : MonoBehaviour + public IUnityObjectServiceCollectionBuilder AddMonoBehaviourSingleton() where T : MonoBehaviour { - _hostBuilder.ConfigureServices(services => + _hostBuilder.ConfigureServices((context, services) => { services.AddSingleton(provider => { - var root = provider.GetRequiredService(); + var root = GetHostRoot(context); var component = root.AddComponent(); InjectServices(component, provider, _serviceInjectionMethodName); SetupLifetime(component, provider, _serviceInjectionMethodName); @@ -112,13 +128,13 @@ public IMonoBehaviourServiceCollectionBuilder AddMonoBehaviourSingleton() whe } /// - public IMonoBehaviourServiceCollectionBuilder AddMonoBehaviourSingleton() where T : class where TImpl : MonoBehaviour, T + public IUnityObjectServiceCollectionBuilder AddMonoBehaviourSingleton() where T : class where TImpl : MonoBehaviour, T { - _hostBuilder.ConfigureServices(services => + _hostBuilder.ConfigureServices((context, services) => { services.AddSingleton(provider => { - var root = provider.GetRequiredService(); + var root = GetHostRoot(context); var component = root.AddComponent(); InjectServices(component, provider, _serviceInjectionMethodName); SetupLifetime(component, provider, _serviceInjectionMethodName); @@ -131,7 +147,7 @@ public IMonoBehaviourServiceCollectionBuilder AddMonoBehaviourSingleton - public IMonoBehaviourServiceCollectionBuilder AddMonoBehaviourTransient() where T : MonoBehaviour + public IUnityObjectServiceCollectionBuilder AddMonoBehaviourTransient() where T : MonoBehaviour { _hostBuilder.ConfigureServices(services => { @@ -150,7 +166,7 @@ public IMonoBehaviourServiceCollectionBuilder AddMonoBehaviourTransient() whe } /// - public IMonoBehaviourServiceCollectionBuilder AddMonoBehaviourTransient() where T : class where TImpl : MonoBehaviour, T + public IUnityObjectServiceCollectionBuilder AddMonoBehaviourTransient() where T : class where TImpl : MonoBehaviour, T { _hostBuilder.ConfigureServices(services => { @@ -168,64 +184,45 @@ public IMonoBehaviourServiceCollectionBuilder AddMonoBehaviourTransient() where T : ScriptableObject + public IUnityObjectServiceCollectionBuilder AddScriptableObjectSingleton(ScriptableObject scriptableObject, Type type) { _hostBuilder.ConfigureServices(services => { - services.AddSingleton(provider => + services.AddSingleton(type, provider => { - var component = ScriptableObject.CreateInstance(typeof(T)); - InjectServices(component, provider, _serviceInjectionMethodName); + InjectServices(scriptableObject, provider, _serviceInjectionMethodName); - return (T) component; + return scriptableObject; }); }); return this; } - public IMonoBehaviourServiceCollectionBuilder AddScriptableObjectSingleton() where T : ScriptableObject where TImpl : ScriptableObject, T + public IUnityObjectServiceCollectionBuilder AddScriptableObjectSingleton(T scriptableObject) where T : ScriptableObject { _hostBuilder.ConfigureServices(services => { services.AddSingleton(provider => { - var component = ScriptableObject.CreateInstance(typeof(TImpl)); - InjectServices(component, provider, _serviceInjectionMethodName); + InjectServices(scriptableObject, provider, _serviceInjectionMethodName); - return (TImpl) component; + return scriptableObject; }); }); return this; } - public IMonoBehaviourServiceCollectionBuilder AddScriptableObjectTransient() where T : ScriptableObject + public IUnityObjectServiceCollectionBuilder AddScriptableObjectSingleton(TImpl scriptableObject) where T : ScriptableObject where TImpl : ScriptableObject, T { _hostBuilder.ConfigureServices(services => { - services.AddTransient(provider => - { - var component = ScriptableObject.CreateInstance(typeof(T)); - InjectServices(component, provider, _serviceInjectionMethodName); - - return (T) component; - }); - }); - - return this; - } - - public IMonoBehaviourServiceCollectionBuilder AddScriptableObjectTransient() where T : class where TImpl : ScriptableObject, T - { - _hostBuilder.ConfigureServices(services => - { - services.AddTransient(provider => + services.AddSingleton(provider => { - var component = ScriptableObject.CreateInstance(typeof(TImpl)); - InjectServices(component, provider, _serviceInjectionMethodName); + InjectServices(scriptableObject, provider, _serviceInjectionMethodName); - return (TImpl) component; + return (TImpl) scriptableObject; }); }); @@ -255,15 +252,15 @@ private static void InjectServices(Type type, UnityEngine.Object component, ISer private static void SetupLifetime(T component, IServiceProvider provider, string injectionMethodName) where T : MonoBehaviour { - var lifetime = provider.GetRequiredService(); - lifetime.ApplicationStopping.Register(() => - { - if (!component) - return; - - component.StopAllCoroutines(); - component.CancelInvoke(); - }); + // var lifetime = provider.GetRequiredService(); + // lifetime.ApplicationStopping.Register(() => + // { + // if (!component) + // return; + // + // component.StopAllCoroutines(); + // component.CancelInvoke(); + // }); } #endregion diff --git a/Runtime/Internals/_InternalsVisibleTo.cs b/Runtime/Internals/_InternalsVisibleTo.cs index 748e638..6ad824a 100644 --- a/Runtime/Internals/_InternalsVisibleTo.cs +++ b/Runtime/Internals/_InternalsVisibleTo.cs @@ -1,7 +1 @@ -namespace Microsoft.Extensions.Hosting.Unity -{ - public class _InternalsVisibleTo - { - - } -} \ No newline at end of file +[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Bsr.Microsoft.Extensions.Hosting.Unity.Editor")] \ No newline at end of file diff --git a/Runtime/Internals/_InternalsVisibleTo.cs.meta b/Runtime/Internals/_InternalsVisibleTo.cs.meta new file mode 100644 index 0000000..79164c3 --- /dev/null +++ b/Runtime/Internals/_InternalsVisibleTo.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 23d77c4e15c34a62b7013f1498373dbe +timeCreated: 1624484439 \ No newline at end of file diff --git a/Runtime/Logging.meta b/Runtime/Logging.meta index a7e3690..60cfd8d 100644 --- a/Runtime/Logging.meta +++ b/Runtime/Logging.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: dd22d150a0c931e4287dc1cb496c3bd9 +guid: 796b10ab974f96542bdb5c245d122f46 folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Runtime/Logging/UnityLogger.cs.meta b/Runtime/Logging/UnityLogger.cs.meta index 7d93757..f7bab9c 100644 --- a/Runtime/Logging/UnityLogger.cs.meta +++ b/Runtime/Logging/UnityLogger.cs.meta @@ -1,3 +1,3 @@ fileFormatVersion: 2 -guid: 46c3d0f57e2d4c41899c759cd8f38414 +guid: 683a8ed9398d6084088bf47ab6de5500 timeCreated: 1618750799 \ No newline at end of file diff --git a/Runtime/Logging/UnityLoggerConfiguration.cs.meta b/Runtime/Logging/UnityLoggerConfiguration.cs.meta index a850d8d..3bb720f 100644 --- a/Runtime/Logging/UnityLoggerConfiguration.cs.meta +++ b/Runtime/Logging/UnityLoggerConfiguration.cs.meta @@ -1,3 +1,3 @@ fileFormatVersion: 2 -guid: 332041bb42b345ffbe48242572e4d4c6 +guid: 8e151a75829bf9c42b263a0ca07555fd timeCreated: 1618751029 \ No newline at end of file diff --git a/Runtime/Logging/UnityLoggerExtensions.cs.meta b/Runtime/Logging/UnityLoggerExtensions.cs.meta index 1ffc3aa..85e1f90 100644 --- a/Runtime/Logging/UnityLoggerExtensions.cs.meta +++ b/Runtime/Logging/UnityLoggerExtensions.cs.meta @@ -1,3 +1,3 @@ fileFormatVersion: 2 -guid: 79d0d48c1a874f2abeeb26e0f6a76588 +guid: 765967355b8e5f940af1a2007b2c51ea timeCreated: 1618751292 \ No newline at end of file diff --git a/Runtime/Logging/UnityLoggerProvider.cs.meta b/Runtime/Logging/UnityLoggerProvider.cs.meta index d490f4e..9366f27 100644 --- a/Runtime/Logging/UnityLoggerProvider.cs.meta +++ b/Runtime/Logging/UnityLoggerProvider.cs.meta @@ -1,3 +1,3 @@ fileFormatVersion: 2 -guid: 04c14cde79b34514bdc3aad3cfb9206b +guid: 6318b4f256b4fff419755a4881c1e1bc timeCreated: 1618750998 \ No newline at end of file diff --git a/Runtime/MonoBehaviourHostRoot.cs b/Runtime/MonoBehaviourHostRoot.cs index f2685a6..b8c30b7 100644 --- a/Runtime/MonoBehaviourHostRoot.cs +++ b/Runtime/MonoBehaviourHostRoot.cs @@ -17,6 +17,7 @@ internal class MonoBehaviourHostRoot : MonoBehaviour, IMonoBehaviourHostRoot private void Awake() { + DontDestroyOnLoad(this); _root = gameObject; } diff --git a/Runtime/MonoBehaviourHostRoot.cs.meta b/Runtime/MonoBehaviourHostRoot.cs.meta index 9ea1091..098fb5b 100644 --- a/Runtime/MonoBehaviourHostRoot.cs.meta +++ b/Runtime/MonoBehaviourHostRoot.cs.meta @@ -1,11 +1,11 @@ fileFormatVersion: 2 -guid: cc8d0edd153740d2a0d91bf845a189cc +guid: 50df0fabde121a648a1d6045d3bb3a6e MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: [] executionOrder: 0 - icon: {fileID: 2800000, guid: a03e91cef1d45774b9ea96a3f579f111, type: 3} + icon: {fileID: 2800000, guid: b59a5535de5a2ce4da5c0f2cd3f233c1, type: 3} userData: assetBundleName: assetBundleVariant: diff --git a/Runtime/UnityHost.cs b/Runtime/UnityHost.cs index 42307c7..b4e64a8 100644 --- a/Runtime/UnityHost.cs +++ b/Runtime/UnityHost.cs @@ -1,6 +1,8 @@ #define MICROSOFT_EXTENSIONS_HOSTING using System; +using System.Linq; +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using UnityEngine; @@ -9,33 +11,40 @@ namespace Microsoft.Extensions.Hosting.Unity { public static class UnityHost { - public static IHostBuilder CreateDefaultBuilder(string monoBehaviourInjectMethodName) + public static IHostBuilder CreateDefaultBuilder(string monoBehaviourInjectMethodName, string[] args = default) { if (string.IsNullOrEmpty(monoBehaviourInjectMethodName)) throw new ArgumentNullException(nameof(monoBehaviourInjectMethodName), "MonoBehaviour ingection method name should be specified"); - return Host.CreateDefaultBuilder() + return Host.CreateDefaultBuilder(args) + .ConfigureAppConfiguration(builder => { builder.DisableFileConfigurationSourceReloadOnChange(); }) .ConfigureLogging((_, loggingBuilder) => { loggingBuilder.ClearProviders(); }) .UseMonoBehaviourServiceCollection(monoBehaviourInjectMethodName) - .ConfigureServices(services => + .ConfigureServices((context, services) => { - services.AddSingleton(provider => - { - var lifetime = provider.GetRequiredService(); + var root = new GameObject($"{nameof(MonoBehaviourHostRoot)} (host root)"); + var component = root.AddComponent(); - var root = new GameObject($"{nameof(MonoBehaviourHostRoot)} (host root)"); - var component = root.AddComponent(); + context.Properties.Add(Constants.MonoBehaviourHostRootInstanceKey, component); - lifetime.ApplicationStopped.Register(() => - { - if (!root) - return; - - UnityEngine.Object.Destroy(root.gameObject); - }); - - return component; - }); + // todo handle lifetime ? + // services.AddSingleton(provider => + // { + // var lifetime = provider.GetRequiredService(); + // + // var root = new GameObject($"{nameof(MonoBehaviourHostRoot)} (host root)"); + // var component = root.AddComponent(); + // + // lifetime.ApplicationStopped.Register(() => + // { + // if (!root) + // return; + // + // UnityEngine.Object.Destroy(root.gameObject); + // }); + // + // return component; + // }); }); } } diff --git a/Runtime/UnityHost.cs.meta b/Runtime/UnityHost.cs.meta index fa2e9e4..463e79c 100644 --- a/Runtime/UnityHost.cs.meta +++ b/Runtime/UnityHost.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: c0b8b52e38a84ac5a8364fc3106e7c45 +guid: ad299964612e1454e91b6b6f83db31bb MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Runtime/lib.meta b/Runtime/lib.meta index 62018ec..3f6c8c7 100644 --- a/Runtime/lib.meta +++ b/Runtime/lib.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: aa38de3092ab2a14fbc40ddd7221bc7a +guid: 326608009b46a464b9106a7476e8c4be folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Runtime/lib/LICENSE.TXT.meta b/Runtime/lib/LICENSE.TXT.meta index 8bfaa34..8da3c3b 100644 --- a/Runtime/lib/LICENSE.TXT.meta +++ b/Runtime/lib/LICENSE.TXT.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 6e2aa0a69a737f14cac7a7d850891e32 +guid: 7206e345036882d4fa1b3a09c2428962 TextScriptImporter: externalObjects: {} userData: diff --git a/Runtime/lib/Microsoft.Bcl.AsyncInterfaces.dll.meta b/Runtime/lib/Microsoft.Bcl.AsyncInterfaces.dll.meta index a890522..fcccb9f 100644 --- a/Runtime/lib/Microsoft.Bcl.AsyncInterfaces.dll.meta +++ b/Runtime/lib/Microsoft.Bcl.AsyncInterfaces.dll.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: aa8136eb523cdfb49a6f977749c85568 +guid: 32c6cbb45040af543a319ea8c98583ed PluginImporter: externalObjects: {} serializedVersion: 2 diff --git a/Runtime/lib/Microsoft.Extensions.Configuration.Abstractions.dll.meta b/Runtime/lib/Microsoft.Extensions.Configuration.Abstractions.dll.meta index 28b3ad8..0278810 100644 --- a/Runtime/lib/Microsoft.Extensions.Configuration.Abstractions.dll.meta +++ b/Runtime/lib/Microsoft.Extensions.Configuration.Abstractions.dll.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 04ad80de85f8e8d4ca719060193453dd +guid: 85ffaeb71ab17024fb8a346217692163 PluginImporter: externalObjects: {} serializedVersion: 2 diff --git a/Runtime/lib/Microsoft.Extensions.Configuration.Binder.dll.meta b/Runtime/lib/Microsoft.Extensions.Configuration.Binder.dll.meta index 6f8556c..cca4e9c 100644 --- a/Runtime/lib/Microsoft.Extensions.Configuration.Binder.dll.meta +++ b/Runtime/lib/Microsoft.Extensions.Configuration.Binder.dll.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: c74b7ecfbd95f4044b56b5b46bbb1b75 +guid: 13a0b47079f223247a29b784d0bca36d PluginImporter: externalObjects: {} serializedVersion: 2 diff --git a/Runtime/lib/Microsoft.Extensions.Configuration.CommandLine.dll.meta b/Runtime/lib/Microsoft.Extensions.Configuration.CommandLine.dll.meta index 21ad1ff..4b7f2d9 100644 --- a/Runtime/lib/Microsoft.Extensions.Configuration.CommandLine.dll.meta +++ b/Runtime/lib/Microsoft.Extensions.Configuration.CommandLine.dll.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: f72a224a052752143afe99107b89a34c +guid: e35e9e443121ed248aae214ab0d2613c PluginImporter: externalObjects: {} serializedVersion: 2 diff --git a/Runtime/lib/Microsoft.Extensions.Configuration.EnvironmentVariables.dll.meta b/Runtime/lib/Microsoft.Extensions.Configuration.EnvironmentVariables.dll.meta index 9fb8ed2..0669fc9 100644 --- a/Runtime/lib/Microsoft.Extensions.Configuration.EnvironmentVariables.dll.meta +++ b/Runtime/lib/Microsoft.Extensions.Configuration.EnvironmentVariables.dll.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 506861f83145b4e43bb6b80e1a21ecef +guid: 14b8b2a093b04554986d09402872a2d5 PluginImporter: externalObjects: {} serializedVersion: 2 diff --git a/Runtime/lib/Microsoft.Extensions.Configuration.FileExtensions.dll.meta b/Runtime/lib/Microsoft.Extensions.Configuration.FileExtensions.dll.meta index 2e24434..ca24916 100644 --- a/Runtime/lib/Microsoft.Extensions.Configuration.FileExtensions.dll.meta +++ b/Runtime/lib/Microsoft.Extensions.Configuration.FileExtensions.dll.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: b83c9662b702ab24c948eca28b9bba74 +guid: e7924c2745e3c1140a2e22cbc694915c PluginImporter: externalObjects: {} serializedVersion: 2 diff --git a/Runtime/lib/Microsoft.Extensions.Configuration.Json.dll.meta b/Runtime/lib/Microsoft.Extensions.Configuration.Json.dll.meta index c3f12fd..50e4668 100644 --- a/Runtime/lib/Microsoft.Extensions.Configuration.Json.dll.meta +++ b/Runtime/lib/Microsoft.Extensions.Configuration.Json.dll.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: eb93622de40971e4d89f027cc5cf13a4 +guid: 0b3c5ab1f26dcf344a86ad9bf97a8c52 PluginImporter: externalObjects: {} serializedVersion: 2 diff --git a/Runtime/lib/Microsoft.Extensions.Configuration.UserSecrets.dll.meta b/Runtime/lib/Microsoft.Extensions.Configuration.UserSecrets.dll.meta index 5d2eddc..bed06e4 100644 --- a/Runtime/lib/Microsoft.Extensions.Configuration.UserSecrets.dll.meta +++ b/Runtime/lib/Microsoft.Extensions.Configuration.UserSecrets.dll.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: cd07355a00bc252409be644c9935463b +guid: c94b70884df93074cbb6d2a631c4ee55 PluginImporter: externalObjects: {} serializedVersion: 2 diff --git a/Runtime/lib/Microsoft.Extensions.Configuration.dll.meta b/Runtime/lib/Microsoft.Extensions.Configuration.dll.meta index 067b35b..f8f8989 100644 --- a/Runtime/lib/Microsoft.Extensions.Configuration.dll.meta +++ b/Runtime/lib/Microsoft.Extensions.Configuration.dll.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 8577c62d73c0991419ebbabdef17e33d +guid: 5e53bc6545d374945b7d7faf5215c223 PluginImporter: externalObjects: {} serializedVersion: 2 diff --git a/Runtime/lib/Microsoft.Extensions.DependencyInjection.Abstractions.dll.meta b/Runtime/lib/Microsoft.Extensions.DependencyInjection.Abstractions.dll.meta index 6d47dc6..880b6c4 100644 --- a/Runtime/lib/Microsoft.Extensions.DependencyInjection.Abstractions.dll.meta +++ b/Runtime/lib/Microsoft.Extensions.DependencyInjection.Abstractions.dll.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: faa97a0aeafb7eb4cb9a9ef2cc10a87d +guid: d68f756ee5aeeb54db88eb5cb34418f5 PluginImporter: externalObjects: {} serializedVersion: 2 diff --git a/Runtime/lib/Microsoft.Extensions.DependencyInjection.dll.meta b/Runtime/lib/Microsoft.Extensions.DependencyInjection.dll.meta index 031bfad..7bef2a8 100644 --- a/Runtime/lib/Microsoft.Extensions.DependencyInjection.dll.meta +++ b/Runtime/lib/Microsoft.Extensions.DependencyInjection.dll.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 8834ba25999754646ab1b0b948719c7f +guid: 7b6c61f971600da4ebd2c315d2f9ed29 PluginImporter: externalObjects: {} serializedVersion: 2 diff --git a/Runtime/lib/Microsoft.Extensions.FileProviders.Abstractions.dll.meta b/Runtime/lib/Microsoft.Extensions.FileProviders.Abstractions.dll.meta index 57c976f..a330b64 100644 --- a/Runtime/lib/Microsoft.Extensions.FileProviders.Abstractions.dll.meta +++ b/Runtime/lib/Microsoft.Extensions.FileProviders.Abstractions.dll.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: d37c0729953f2d74983ebd097b06c8ef +guid: a34a4db2cb5b82442b4807a830e7b250 PluginImporter: externalObjects: {} serializedVersion: 2 diff --git a/Runtime/lib/Microsoft.Extensions.FileProviders.Physical.dll.meta b/Runtime/lib/Microsoft.Extensions.FileProviders.Physical.dll.meta index 009a82f..f0ff9db 100644 --- a/Runtime/lib/Microsoft.Extensions.FileProviders.Physical.dll.meta +++ b/Runtime/lib/Microsoft.Extensions.FileProviders.Physical.dll.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: f0ec9ed727dd0cd48a453d00a7f7bda7 +guid: c3812f6dadd3aa549a3a6dccc9c06cb4 PluginImporter: externalObjects: {} serializedVersion: 2 diff --git a/Runtime/lib/Microsoft.Extensions.FileSystemGlobbing.dll.meta b/Runtime/lib/Microsoft.Extensions.FileSystemGlobbing.dll.meta index bcbc2b9..15392d6 100644 --- a/Runtime/lib/Microsoft.Extensions.FileSystemGlobbing.dll.meta +++ b/Runtime/lib/Microsoft.Extensions.FileSystemGlobbing.dll.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 68032a9afce1154468b71f83aa1106a7 +guid: b73f9f58480968c47905ee24d85b9b39 PluginImporter: externalObjects: {} serializedVersion: 2 diff --git a/Runtime/lib/Microsoft.Extensions.Hosting.Abstractions.dll.meta b/Runtime/lib/Microsoft.Extensions.Hosting.Abstractions.dll.meta index b3f1106..cbbadce 100644 --- a/Runtime/lib/Microsoft.Extensions.Hosting.Abstractions.dll.meta +++ b/Runtime/lib/Microsoft.Extensions.Hosting.Abstractions.dll.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 669eeda932fe85a47abc0643606f7326 +guid: 10f28a050c771b24dbf677f4db5ded31 PluginImporter: externalObjects: {} serializedVersion: 2 diff --git a/Runtime/lib/Microsoft.Extensions.Hosting.dll.meta b/Runtime/lib/Microsoft.Extensions.Hosting.dll.meta index ced5945..5c0fdcb 100644 --- a/Runtime/lib/Microsoft.Extensions.Hosting.dll.meta +++ b/Runtime/lib/Microsoft.Extensions.Hosting.dll.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: a00243ae3b8f4e44c967aa8d78cf10ec +guid: 62b54b44174897b41833d2aa1a7292af PluginImporter: externalObjects: {} serializedVersion: 2 diff --git a/Runtime/lib/Microsoft.Extensions.Logging.Abstractions.dll.meta b/Runtime/lib/Microsoft.Extensions.Logging.Abstractions.dll.meta index e0ff8b9..77acab2 100644 --- a/Runtime/lib/Microsoft.Extensions.Logging.Abstractions.dll.meta +++ b/Runtime/lib/Microsoft.Extensions.Logging.Abstractions.dll.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 3aa6e487eeb846b4e90d6c6aaf4984ec +guid: 024d32e3880e0ea4c95959dbcda0233f PluginImporter: externalObjects: {} serializedVersion: 2 diff --git a/Runtime/lib/Microsoft.Extensions.Logging.Configuration.dll.meta b/Runtime/lib/Microsoft.Extensions.Logging.Configuration.dll.meta index 41bfc43..a850493 100644 --- a/Runtime/lib/Microsoft.Extensions.Logging.Configuration.dll.meta +++ b/Runtime/lib/Microsoft.Extensions.Logging.Configuration.dll.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: aaf653cf763fe684091ee098c80b7ecd +guid: 14438271e4f6b1c4c8934bae19b1917f PluginImporter: externalObjects: {} serializedVersion: 2 diff --git a/Runtime/lib/Microsoft.Extensions.Logging.Console.dll.meta b/Runtime/lib/Microsoft.Extensions.Logging.Console.dll.meta index d132faa..02dc1a1 100644 --- a/Runtime/lib/Microsoft.Extensions.Logging.Console.dll.meta +++ b/Runtime/lib/Microsoft.Extensions.Logging.Console.dll.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: e40cee8088e94f348b87bfe971c96644 +guid: 55d63b1f068737c4ab2598fc64011b60 PluginImporter: externalObjects: {} serializedVersion: 2 diff --git a/Runtime/lib/Microsoft.Extensions.Logging.Debug.dll.meta b/Runtime/lib/Microsoft.Extensions.Logging.Debug.dll.meta index 58d6172..318223a 100644 --- a/Runtime/lib/Microsoft.Extensions.Logging.Debug.dll.meta +++ b/Runtime/lib/Microsoft.Extensions.Logging.Debug.dll.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: d74480876e1fb874282fb2f17e767a83 +guid: 3b3f314f128db4a4c9d20d5f7d1834ee PluginImporter: externalObjects: {} serializedVersion: 2 diff --git a/Runtime/lib/Microsoft.Extensions.Logging.EventLog.dll.meta b/Runtime/lib/Microsoft.Extensions.Logging.EventLog.dll.meta index b534a1b..93081fd 100644 --- a/Runtime/lib/Microsoft.Extensions.Logging.EventLog.dll.meta +++ b/Runtime/lib/Microsoft.Extensions.Logging.EventLog.dll.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 239d1551bc30e5d46988a4c5d88b3b2f +guid: 3e255968035512e4fbff31a45e9580b3 PluginImporter: externalObjects: {} serializedVersion: 2 diff --git a/Runtime/lib/Microsoft.Extensions.Logging.EventSource.dll.meta b/Runtime/lib/Microsoft.Extensions.Logging.EventSource.dll.meta index d83e112..9d73fa4 100644 --- a/Runtime/lib/Microsoft.Extensions.Logging.EventSource.dll.meta +++ b/Runtime/lib/Microsoft.Extensions.Logging.EventSource.dll.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 6a46c7f6640550742a48c07d908f1b86 +guid: 5a968f96a8b43de41b3c2ddc621c99de PluginImporter: externalObjects: {} serializedVersion: 2 diff --git a/Runtime/lib/Microsoft.Extensions.Logging.dll.meta b/Runtime/lib/Microsoft.Extensions.Logging.dll.meta index 1858525..a5feacb 100644 --- a/Runtime/lib/Microsoft.Extensions.Logging.dll.meta +++ b/Runtime/lib/Microsoft.Extensions.Logging.dll.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 452b640eaf21c734db5489eea9064a6d +guid: bba3a31cf15ad4742b588ffbdf4d93d5 PluginImporter: externalObjects: {} serializedVersion: 2 diff --git a/Runtime/lib/Microsoft.Extensions.Options.ConfigurationExtensions.dll.meta b/Runtime/lib/Microsoft.Extensions.Options.ConfigurationExtensions.dll.meta index 98a75ea..8bfb6c2 100644 --- a/Runtime/lib/Microsoft.Extensions.Options.ConfigurationExtensions.dll.meta +++ b/Runtime/lib/Microsoft.Extensions.Options.ConfigurationExtensions.dll.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 9b259093fa5a5944fa62f78d5f930b16 +guid: fa9ecd70c99e61547af19c61e6469c70 PluginImporter: externalObjects: {} serializedVersion: 2 diff --git a/Runtime/lib/Microsoft.Extensions.Options.dll.meta b/Runtime/lib/Microsoft.Extensions.Options.dll.meta index a71963d..e0f5688 100644 --- a/Runtime/lib/Microsoft.Extensions.Options.dll.meta +++ b/Runtime/lib/Microsoft.Extensions.Options.dll.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 6ffeff1a58d13324ebe1e98c8609bc85 +guid: 91754f62939582e4bb23ab7bbba0c2b1 PluginImporter: externalObjects: {} serializedVersion: 2 diff --git a/Runtime/lib/Microsoft.Extensions.Primitives.dll.meta b/Runtime/lib/Microsoft.Extensions.Primitives.dll.meta index ce2baf7..991dc33 100644 --- a/Runtime/lib/Microsoft.Extensions.Primitives.dll.meta +++ b/Runtime/lib/Microsoft.Extensions.Primitives.dll.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 646a63cc0ad0c4349bd84dd1f081efdc +guid: c2659c6c130e8d04c9783a7df66e1527 PluginImporter: externalObjects: {} serializedVersion: 2 diff --git a/Runtime/lib/System.Buffers.dll.meta b/Runtime/lib/System.Buffers.dll.meta index 70fddc2..c25db87 100644 --- a/Runtime/lib/System.Buffers.dll.meta +++ b/Runtime/lib/System.Buffers.dll.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 46c914171e32b834a90b4e2ece48d754 +guid: 54a117a5ebe8bab47af991da48c6c47d PluginImporter: externalObjects: {} serializedVersion: 2 diff --git a/Runtime/lib/System.Diagnostics.DiagnosticSource.dll.meta b/Runtime/lib/System.Diagnostics.DiagnosticSource.dll.meta index 8bf4018..3714b3e 100644 --- a/Runtime/lib/System.Diagnostics.DiagnosticSource.dll.meta +++ b/Runtime/lib/System.Diagnostics.DiagnosticSource.dll.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 0c0ad127ceebe454294f7b9ca3b7cd8c +guid: 778ce4d3dce6d964d89687e5118069fa PluginImporter: externalObjects: {} serializedVersion: 2 diff --git a/Runtime/lib/System.Diagnostics.EventLog.dll.meta b/Runtime/lib/System.Diagnostics.EventLog.dll.meta index 8f8f396..7be3aff 100644 --- a/Runtime/lib/System.Diagnostics.EventLog.dll.meta +++ b/Runtime/lib/System.Diagnostics.EventLog.dll.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 65934d610d067ff478cccfb8f9755c4f +guid: 9b199272171770c458283cb27d5091d7 PluginImporter: externalObjects: {} serializedVersion: 2 diff --git a/Runtime/lib/System.Memory.dll.meta b/Runtime/lib/System.Memory.dll.meta index 2d044ea..9738e1d 100644 --- a/Runtime/lib/System.Memory.dll.meta +++ b/Runtime/lib/System.Memory.dll.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: d40c945bb1eb2a248a4fd15fc41e059c +guid: ddc04b7a56ea50f4a8b13382de139730 PluginImporter: externalObjects: {} serializedVersion: 2 diff --git a/Runtime/lib/System.Numerics.Vectors.dll.meta b/Runtime/lib/System.Numerics.Vectors.dll.meta index e087501..9dc799b 100644 --- a/Runtime/lib/System.Numerics.Vectors.dll.meta +++ b/Runtime/lib/System.Numerics.Vectors.dll.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: b496f2120c50cbb498e826deff51d475 +guid: 1806d43c78e7d494aa627fe5f106478b PluginImporter: externalObjects: {} serializedVersion: 2 diff --git a/Runtime/lib/System.Runtime.CompilerServices.Unsafe.dll.meta b/Runtime/lib/System.Runtime.CompilerServices.Unsafe.dll.meta index 540067f..26512a5 100644 --- a/Runtime/lib/System.Runtime.CompilerServices.Unsafe.dll.meta +++ b/Runtime/lib/System.Runtime.CompilerServices.Unsafe.dll.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 36b463a28348dda4aaf5430021f38d62 +guid: 8ef08e728bb679549815a2020f2c6dc4 PluginImporter: externalObjects: {} serializedVersion: 2 diff --git a/Runtime/lib/System.Security.Principal.Windows.dll.meta b/Runtime/lib/System.Security.Principal.Windows.dll.meta index 7fde4ff..8a63f8b 100644 --- a/Runtime/lib/System.Security.Principal.Windows.dll.meta +++ b/Runtime/lib/System.Security.Principal.Windows.dll.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 7575afa71783c15478fbb27c9555d611 +guid: 5a459eb556f2e9646bfe01175566f227 PluginImporter: externalObjects: {} serializedVersion: 2 diff --git a/Runtime/lib/System.Text.Encodings.Web.dll.meta b/Runtime/lib/System.Text.Encodings.Web.dll.meta index ab44756..54e79eb 100644 --- a/Runtime/lib/System.Text.Encodings.Web.dll.meta +++ b/Runtime/lib/System.Text.Encodings.Web.dll.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 3298da25763eaa542b84907dc8f3854e +guid: 8c65f81be8d1e324eb289115c14ddee9 PluginImporter: externalObjects: {} serializedVersion: 2 diff --git a/Runtime/lib/System.Text.Json.dll.meta b/Runtime/lib/System.Text.Json.dll.meta index 13e50d1..220e4dd 100644 --- a/Runtime/lib/System.Text.Json.dll.meta +++ b/Runtime/lib/System.Text.Json.dll.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: aa66b285dac31ef40806d379dcec576d +guid: a13cd551a90dea043a8e270769f3c871 PluginImporter: externalObjects: {} serializedVersion: 2 diff --git a/Runtime/lib/System.Threading.Tasks.Extensions.dll.meta b/Runtime/lib/System.Threading.Tasks.Extensions.dll.meta index 613505e..8bb9e95 100644 --- a/Runtime/lib/System.Threading.Tasks.Extensions.dll.meta +++ b/Runtime/lib/System.Threading.Tasks.Extensions.dll.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 28bac0e0495f5524a90e1e45b4169aa6 +guid: f5bcbf2256a1d914293edc5932800789 PluginImporter: externalObjects: {} serializedVersion: 2 diff --git a/Third Party Notices.md.meta b/Third Party Notices.md.meta index 8304090..3d59b1e 100644 --- a/Third Party Notices.md.meta +++ b/Third Party Notices.md.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: c681672759441234b9d40d46bfc51fb2 +guid: 9eb0886c19f32b849a0a2e3c5b61782b TextScriptImporter: externalObjects: {} userData: diff --git a/package.json b/package.json index 0c92989..a7f8fc4 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,11 @@ { - "name": "com.blacksmallriver.microsoft.extensions.hosting", + "name": "com.blacksmallriver.hosting", "author": "Aleksei Melkor (https://docs.microsoft.com/ru-ru/dotnet/core/extensions/dependency-injection-usage)", "displayName": "Microsoft.Extensions.Hosting for Unity", "description": "Microsoft.Extensions.Hosting adopted for Unity", "unity": "2019.4", "release": "0f1", - "version": "1.0.4", + "version": "1.2.0", "keywords": [ "unity", "integration", diff --git a/package.json.meta b/package.json.meta index bed5b0b..256667c 100644 --- a/package.json.meta +++ b/package.json.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 4e3cea53b5627674aa6061d7c5d8d5f5 +guid: 1cfc2a00f6754814bab11ce5bbf24dd9 PackageManifestImporter: externalObjects: {} userData: