From f3ee58f5240cf5014732c09114a48bfb4aef667f Mon Sep 17 00:00:00 2001 From: Nikolay Pianikov Date: Fri, 27 Dec 2024 12:10:38 +0300 Subject: [PATCH] #80 Error CS1061 : 'object' does not contain a definition for 'Enter'/'Exit' --- README.md | 20 ++++++++++--- readme/BlazorServerApp.md | 2 +- readme/BlazorWebAssemblyApp.md | 2 +- readme/FooterTemplate.md | 20 ++++++++++--- readme/GrpcService.md | 2 +- readme/Maui.md | 2 +- readme/MinimalWebAPI.md | 2 +- readme/WebAPI.md | 2 +- readme/WebApp.md | 2 +- ...osable-instances-per-a-composition-root.md | 11 ++++---- src/Pure.DI.Core/Components/Api.g.cs | 22 ++++++++++++++- .../Core/Code/BlockCodeBuilder.cs | 4 +-- src/Pure.DI.Core/Core/Code/BuildTools.cs | 5 ++-- .../Core/Code/DefaultConstructorBuilder.cs | 2 +- .../Core/Code/DisposeMethodBuilder.cs | 4 +-- src/Pure.DI.Core/Core/Code/FieldsBuilder.cs | 2 +- src/Pure.DI.Core/Core/Code/ILocks.cs | 6 ++-- src/Pure.DI.Core/Core/Code/Locks.cs | 28 +++++++++++++------ .../Code/ParameterizedConstructorBuilder.cs | 2 +- src/Pure.DI.Core/Core/Hints.cs | 3 ++ src/Pure.DI.Core/Core/IHints.cs | 2 ++ .../TrackingAsyncDisposableScenario.cs | 3 ++ 22 files changed, 105 insertions(+), 43 deletions(-) diff --git a/README.md b/README.md index 33d952b1a..b7c11c57a 100644 --- a/README.md +++ b/README.md @@ -587,18 +587,18 @@ DI.Setup("Composition") |------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------|------------|-----------| | [Resolve](#resolve-hint) | _On_ or _Off_ | | _On_ | | [OnNewInstance](#onnewinstance-hint) | _On_ or _Off_ | 9.0 | _Off_ | -| [OnNewInstancePartial](#onnewinstance-hint) | _On_ or _Off_ | | _On_ | +| [OnNewInstancePartial](#onnewinstance-hint) | _On_ or _Off_ | | _On_ | | [OnNewInstanceImplementationTypeNameRegularExpression](#onnewinstanceimplementationtypenameregularexpression-hint) | Regular expression | | .+ | | [OnNewInstanceTagRegularExpression](#onnewinstancetagregularexpression-hint) | Regular expression | | .+ | | [OnNewInstanceLifetimeRegularExpression](#onnewinstancelifetimeregularexpression-hint) | Regular expression | | .+ | | [OnDependencyInjection](#ondependencyinjection-hint) | _On_ or _Off_ | 9.0 | _Off_ | -| [OnDependencyInjectionPartial](#ondependencyinjectionpartial-hint) | _On_ or _Off_ | | _On_ | +| [OnDependencyInjectionPartial](#ondependencyinjectionpartial-hint) | _On_ or _Off_ | | _On_ | | [OnDependencyInjectionImplementationTypeNameRegularExpression](#OnDependencyInjectionImplementationTypeNameRegularExpression-Hint) | Regular expression | | .+ | | [OnDependencyInjectionContractTypeNameRegularExpression](#ondependencyinjectioncontracttypenameregularexpression-hint) | Regular expression | | .+ | | [OnDependencyInjectionTagRegularExpression](#ondependencyinjectiontagregularexpression-hint) | Regular expression | | .+ | | [OnDependencyInjectionLifetimeRegularExpression](#ondependencyinjectionlifetimeregularexpression-hint) | Regular expression | | .+ | | [OnCannotResolve](#oncannotresolve-hint) | _On_ or _Off_ | 9.0 | _Off_ | -| [OnCannotResolvePartial](#oncannotresolvepartial-hint) | _On_ or _Off_ | | _On_ | +| [OnCannotResolvePartial](#oncannotresolvepartial-hint) | _On_ or _Off_ | | _On_ | | [OnCannotResolveContractTypeNameRegularExpression](#oncannotresolvecontracttypenameregularexpression-hint) | Regular expression | | .+ | | [OnCannotResolveTagRegularExpression](#oncannotresolvetagregularexpression-hint) | Regular expression | | .+ | | [OnCannotResolveLifetimeRegularExpression](#oncannotresolvelifetimeregularexpression-hint) | Regular expression | | .+ | @@ -618,7 +618,8 @@ DI.Setup("Composition") | [DisposeAsyncMethodModifiers](#disposeasyncmethodmodifiers-hint) | Method modifier | | _public_ | | [FormatCode](#formatcode-hint) | _On_ or _Off_ | | _Off_ | | [SeverityOfNotImplementedContract](#severityofnotimplementedcontract-hint) | _Error_ or _Warning_ or _Info_ or _Hidden_ | | _Error_ | -| [Comments](#comments-hint) | _On_ or _Off_ | | _On_ | +| [Comments](#comments-hint) | _On_ or _Off_ | | _On_ | +| [SystemThreadingLock](#systemthreadinglock-hint) | _On_ or _Off_ | | _On_ | The list of hints will be gradually expanded to meet the needs and desires for fine-tuning code generation. Please feel free to add your ideas. @@ -854,6 +855,17 @@ DI.Setup(nameof(Composition)) Appropriate comments will be added to the generated ```Composition``` class and the documentation for the class, depending on the IDE used, will look something like this: +### SystemThreadingLock Hint + +Indicates whether `System.Threading.Lock` should be used whenever possible instead of the classic approach of synchronizing object access using `System.Threading.Monitor1. `On` by default. + +```c# +DI.Setup(nameof(Composition)) + .Hint(Hint.SystemThreadingLock, "Off") + .Bind().To() + .Root("MyService"); +``` + ![ReadmeDocumentation1.png](readme/ReadmeDocumentation1.png) Then documentation for the composition root: diff --git a/readme/BlazorServerApp.md b/readme/BlazorServerApp.md index 868820086..402a74d41 100644 --- a/readme/BlazorServerApp.md +++ b/readme/BlazorServerApp.md @@ -74,7 +74,7 @@ The [project file](/samples/BlazorServerApp/BlazorServerApp.csproj) looks like t all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/readme/BlazorWebAssemblyApp.md b/readme/BlazorWebAssemblyApp.md index 0d9352355..02b0d0eb2 100644 --- a/readme/BlazorWebAssemblyApp.md +++ b/readme/BlazorWebAssemblyApp.md @@ -73,7 +73,7 @@ The [project file](/samples/BlazorWebAssemblyApp/BlazorWebAssemblyApp.csproj) lo all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/readme/FooterTemplate.md b/readme/FooterTemplate.md index edf76848d..f86bef5b1 100644 --- a/readme/FooterTemplate.md +++ b/readme/FooterTemplate.md @@ -280,18 +280,18 @@ DI.Setup("Composition") |------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------|------------|-----------| | [Resolve](#resolve-hint) | _On_ or _Off_ | | _On_ | | [OnNewInstance](#onnewinstance-hint) | _On_ or _Off_ | 9.0 | _Off_ | -| [OnNewInstancePartial](#onnewinstance-hint) | _On_ or _Off_ | | _On_ | +| [OnNewInstancePartial](#onnewinstance-hint) | _On_ or _Off_ | | _On_ | | [OnNewInstanceImplementationTypeNameRegularExpression](#onnewinstanceimplementationtypenameregularexpression-hint) | Regular expression | | .+ | | [OnNewInstanceTagRegularExpression](#onnewinstancetagregularexpression-hint) | Regular expression | | .+ | | [OnNewInstanceLifetimeRegularExpression](#onnewinstancelifetimeregularexpression-hint) | Regular expression | | .+ | | [OnDependencyInjection](#ondependencyinjection-hint) | _On_ or _Off_ | 9.0 | _Off_ | -| [OnDependencyInjectionPartial](#ondependencyinjectionpartial-hint) | _On_ or _Off_ | | _On_ | +| [OnDependencyInjectionPartial](#ondependencyinjectionpartial-hint) | _On_ or _Off_ | | _On_ | | [OnDependencyInjectionImplementationTypeNameRegularExpression](#OnDependencyInjectionImplementationTypeNameRegularExpression-Hint) | Regular expression | | .+ | | [OnDependencyInjectionContractTypeNameRegularExpression](#ondependencyinjectioncontracttypenameregularexpression-hint) | Regular expression | | .+ | | [OnDependencyInjectionTagRegularExpression](#ondependencyinjectiontagregularexpression-hint) | Regular expression | | .+ | | [OnDependencyInjectionLifetimeRegularExpression](#ondependencyinjectionlifetimeregularexpression-hint) | Regular expression | | .+ | | [OnCannotResolve](#oncannotresolve-hint) | _On_ or _Off_ | 9.0 | _Off_ | -| [OnCannotResolvePartial](#oncannotresolvepartial-hint) | _On_ or _Off_ | | _On_ | +| [OnCannotResolvePartial](#oncannotresolvepartial-hint) | _On_ or _Off_ | | _On_ | | [OnCannotResolveContractTypeNameRegularExpression](#oncannotresolvecontracttypenameregularexpression-hint) | Regular expression | | .+ | | [OnCannotResolveTagRegularExpression](#oncannotresolvetagregularexpression-hint) | Regular expression | | .+ | | [OnCannotResolveLifetimeRegularExpression](#oncannotresolvelifetimeregularexpression-hint) | Regular expression | | .+ | @@ -311,7 +311,8 @@ DI.Setup("Composition") | [DisposeAsyncMethodModifiers](#disposeasyncmethodmodifiers-hint) | Method modifier | | _public_ | | [FormatCode](#formatcode-hint) | _On_ or _Off_ | | _Off_ | | [SeverityOfNotImplementedContract](#severityofnotimplementedcontract-hint) | _Error_ or _Warning_ or _Info_ or _Hidden_ | | _Error_ | -| [Comments](#comments-hint) | _On_ or _Off_ | | _On_ | +| [Comments](#comments-hint) | _On_ or _Off_ | | _On_ | +| [SystemThreadingLock](#systemthreadinglock-hint) | _On_ or _Off_ | | _On_ | The list of hints will be gradually expanded to meet the needs and desires for fine-tuning code generation. Please feel free to add your ideas. @@ -547,6 +548,17 @@ DI.Setup(nameof(Composition)) Appropriate comments will be added to the generated ```Composition``` class and the documentation for the class, depending on the IDE used, will look something like this: +### SystemThreadingLock Hint + +Indicates whether `System.Threading.Lock` should be used whenever possible instead of the classic approach of synchronizing object access using `System.Threading.Monitor1. `On` by default. + +```c# +DI.Setup(nameof(Composition)) + .Hint(Hint.SystemThreadingLock, "Off") + .Bind().To() + .Root("MyService"); +``` + ![ReadmeDocumentation1.png](readme/ReadmeDocumentation1.png) Then documentation for the composition root: diff --git a/readme/GrpcService.md b/readme/GrpcService.md index ce9fb3357..675ff31cb 100644 --- a/readme/GrpcService.md +++ b/readme/GrpcService.md @@ -59,7 +59,7 @@ The [project file](/samples/GrpcService/GrpcService.csproj) looks like this: all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/readme/Maui.md b/readme/Maui.md index c5db7bb30..171100695 100644 --- a/readme/Maui.md +++ b/readme/Maui.md @@ -215,7 +215,7 @@ The [project file](/samples/MAUIApp/MAUIApp.csproj) looks like this: all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/readme/MinimalWebAPI.md b/readme/MinimalWebAPI.md index 78c8f123e..57f145a78 100644 --- a/readme/MinimalWebAPI.md +++ b/readme/MinimalWebAPI.md @@ -82,7 +82,7 @@ The [project file](/samples/WebAPI/WebAPI.csproj) looks like this: all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/readme/WebAPI.md b/readme/WebAPI.md index f81b8c6b8..87d3c5576 100644 --- a/readme/WebAPI.md +++ b/readme/WebAPI.md @@ -57,7 +57,7 @@ The [project file](/samples/WebAPI/WebAPI.csproj) looks like this: all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/readme/WebApp.md b/readme/WebApp.md index 3da6371e7..df886041b 100644 --- a/readme/WebApp.md +++ b/readme/WebApp.md @@ -57,7 +57,7 @@ The [project file](/samples/WebApp/WebApp.csproj) looks like this: all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/readme/tracking-async-disposable-instances-per-a-composition-root.md b/readme/tracking-async-disposable-instances-per-a-composition-root.md index cf3563dd4..752213279 100644 --- a/readme/tracking-async-disposable-instances-per-a-composition-root.md +++ b/readme/tracking-async-disposable-instances-per-a-composition-root.md @@ -57,6 +57,7 @@ partial class Composition { static void Setup() => DI.Setup() + .Bind().To() .Bind().To() @@ -99,13 +100,13 @@ The following partial class will be generated: partial class Composition { private readonly Composition _root; - private readonly Lock _lock; + private readonly Object _lock; [OrdinalAttribute(256)] public Composition() { _root = this; - _lock = new Lock(); + _lock = new Object(); } internal Composition(Composition parentScope) @@ -121,7 +122,7 @@ partial class Composition { var accumulator46 = new Owned(); Dependency transientDependency3 = new Dependency(); - using (_lock.EnterScope()) + lock (_lock) { accumulator46.Add(transientDependency3); } @@ -130,14 +131,14 @@ partial class Composition Owned transientOwned1; Owned localOwned15 = accumulator46; transientOwned1 = localOwned15; - using (_lock.EnterScope()) + lock (_lock) { accumulator46.Add(transientOwned1); } IOwned localOwned13 = transientOwned1; IService localValue14 = new Service(transientDependency3); perBlockOwned0 = new Owned(localValue14, localOwned13); - using (_lock.EnterScope()) + lock (_lock) { accumulator46.Add(perBlockOwned0); } diff --git a/src/Pure.DI.Core/Components/Api.g.cs b/src/Pure.DI.Core/Components/Api.g.cs index fd8f3efa1..3b26124c8 100644 --- a/src/Pure.DI.Core/Components/Api.g.cs +++ b/src/Pure.DI.Core/Components/Api.g.cs @@ -798,7 +798,27 @@ internal enum Hint /// /// /// - Comments + Comments, + + /// + /// On or Off. Indicates whether should be used whenever possible instead of the classic approach of synchronizing object access using . On by default. + /// + /// + /// // SystemThreadingLock = Off + /// DI.Setup("Composition") + /// .Bind<IDependency>().To<Dependency>(); + /// + ///
+ /// or using the API call : + /// + /// DI.Setup("Composition") + /// .Hint(Hint.SystemThreadingLock, "Off") + /// .Bind<IDependency>().To<Dependency>(); + /// + ///
+ ///
+ /// + SystemThreadingLock } /// diff --git a/src/Pure.DI.Core/Core/Code/BlockCodeBuilder.cs b/src/Pure.DI.Core/Core/Code/BlockCodeBuilder.cs index 8da953e6b..df61a50c4 100644 --- a/src/Pure.DI.Core/Core/Code/BlockCodeBuilder.cs +++ b/src/Pure.DI.Core/Core/Code/BlockCodeBuilder.cs @@ -57,7 +57,7 @@ public void Build(BuildContext ctx, in Block block) code.AppendLine($"if ({checkExpression})"); code.AppendLine("{"); code.IncIndent(); - locks.AddLockStatements(compilation, code, false); + locks.AddLockStatements(ctx.DependencyGraph.Source, code, false); code.AppendLine("{"); code.IncIndent(); ctx = ctx with { LockIsRequired = false }; @@ -124,7 +124,7 @@ public void Build(BuildContext ctx, in Block block) code.AppendLine("}"); if (!lockIsRequired) { - locks.AddUnlockStatements(code, false); + locks.AddUnlockStatements(ctx.DependencyGraph.Source, code, false); code.AppendLine(); return; } diff --git a/src/Pure.DI.Core/Core/Code/BuildTools.cs b/src/Pure.DI.Core/Core/Code/BuildTools.cs index e3246d242..1ea34f694 100644 --- a/src/Pure.DI.Core/Core/Code/BuildTools.cs +++ b/src/Pure.DI.Core/Core/Code/BuildTools.cs @@ -105,10 +105,9 @@ public IEnumerable OnCreated(BuildContext ctx, Variable variable) .Select(i => new Line(0, $"{i.Name}.Add({variable.VariableName});")) .ToList(); - var compilation = variable.Node.Binding.SemanticModel.Compilation; if (lockIsRequired && accLines.Count > 0) { - locks.AddLockStatements(compilation, code, false); + locks.AddLockStatements(ctx.DependencyGraph.Source, code, false); code.AppendLine("{"); code.IncIndent(); } @@ -119,7 +118,7 @@ public IEnumerable OnCreated(BuildContext ctx, Variable variable) { code.DecIndent(); code.AppendLine("}"); - locks.AddUnlockStatements(code, false); + locks.AddUnlockStatements(ctx.DependencyGraph.Source, code, false); } if (!ctx.DependencyGraph.Source.Hints.IsOnNewInstanceEnabled) diff --git a/src/Pure.DI.Core/Core/Code/DefaultConstructorBuilder.cs b/src/Pure.DI.Core/Core/Code/DefaultConstructorBuilder.cs index 4ec6c8d95..0deb9f83d 100644 --- a/src/Pure.DI.Core/Core/Code/DefaultConstructorBuilder.cs +++ b/src/Pure.DI.Core/Core/Code/DefaultConstructorBuilder.cs @@ -32,7 +32,7 @@ public CompositionCode Build(CompositionCode composition) code.AppendLine($"{Names.RootFieldName} = this;"); if (composition.IsThreadSafe) { - code.AppendLine($"{Names.LockFieldName} = new {locks.GetLockType(composition.Compilation)}();"); + code.AppendLine($"{Names.LockFieldName} = new {locks.GetLockType(composition.Source.Source)}();"); } if (composition.TotalDisposablesCount > 0) diff --git a/src/Pure.DI.Core/Core/Code/DisposeMethodBuilder.cs b/src/Pure.DI.Core/Core/Code/DisposeMethodBuilder.cs index b95614fb4..cc4dfd61a 100644 --- a/src/Pure.DI.Core/Core/Code/DisposeMethodBuilder.cs +++ b/src/Pure.DI.Core/Core/Code/DisposeMethodBuilder.cs @@ -208,7 +208,7 @@ private void AddSyncPart(CompositionCode composition, LinesBuilder code, bool is { code.AppendLine("int disposeIndex;"); code.AppendLine("object[] disposables;"); - locks.AddLockStatements(composition.Compilation, code, isAsync); + locks.AddLockStatements(composition.Source.Source, code, isAsync); code.AppendLine("{"); using (code.Indent()) { @@ -226,6 +226,6 @@ private void AddSyncPart(CompositionCode composition, LinesBuilder code, bool is } code.AppendLine("}"); - locks.AddUnlockStatements(code, isAsync); + locks.AddUnlockStatements(composition.Source.Source, code, isAsync); } } \ No newline at end of file diff --git a/src/Pure.DI.Core/Core/Code/FieldsBuilder.cs b/src/Pure.DI.Core/Core/Code/FieldsBuilder.cs index 9015cb483..f3e5d4bf2 100644 --- a/src/Pure.DI.Core/Core/Code/FieldsBuilder.cs +++ b/src/Pure.DI.Core/Core/Code/FieldsBuilder.cs @@ -22,7 +22,7 @@ public CompositionCode Build(CompositionCode composition) if (composition.IsThreadSafe) { // _lock field - code.AppendLine($"private readonly {locks.GetLockType(compilation)} {Names.LockFieldName};"); + code.AppendLine($"private readonly {locks.GetLockType(composition.Source.Source)} {Names.LockFieldName};"); membersCounter++; } diff --git a/src/Pure.DI.Core/Core/Code/ILocks.cs b/src/Pure.DI.Core/Core/Code/ILocks.cs index 4dc39d518..0ef749d08 100644 --- a/src/Pure.DI.Core/Core/Code/ILocks.cs +++ b/src/Pure.DI.Core/Core/Code/ILocks.cs @@ -2,9 +2,9 @@ internal interface ILocks { - string GetLockType(Compilation compilation); + string GetLockType(MdSetup setup); - void AddLockStatements(Compilation compilation, LinesBuilder lines, bool isAsync); + void AddLockStatements(MdSetup setup, LinesBuilder lines, bool isAsync); - void AddUnlockStatements(LinesBuilder lines, bool isAsync); + void AddUnlockStatements(MdSetup setup, LinesBuilder lines, bool isAsync); } \ No newline at end of file diff --git a/src/Pure.DI.Core/Core/Code/Locks.cs b/src/Pure.DI.Core/Core/Code/Locks.cs index 9669ca1f2..50f45486b 100644 --- a/src/Pure.DI.Core/Core/Code/Locks.cs +++ b/src/Pure.DI.Core/Core/Code/Locks.cs @@ -1,32 +1,38 @@ // ReSharper disable ClassNeverInstantiated.Global namespace Pure.DI.Core.Code; -internal class Locks(ITypes types) : ILocks +internal class Locks( + ITypes types) + : ILocks { - public string GetLockType(Compilation compilation) => - types.TryGet(SpecialType.Lock, compilation) is not null + public string GetLockType(MdSetup setup) => + IsSystemThreadingLockEnabled(setup) ? Names.LockTypeName : Names.ObjectTypeName; - public void AddLockStatements(Compilation compilation, LinesBuilder lines, bool isAsync) + public void AddLockStatements(MdSetup setup, LinesBuilder lines, bool isAsync) { if (!isAsync) { lines.AppendLine( - types.TryGet(SpecialType.Lock, compilation) is not null + IsSystemThreadingLockEnabled(setup) ? $"using ({Names.LockFieldName}.EnterScope())" : $"lock ({Names.LockFieldName})"); } else { - lines.AppendLine($"{Names.LockFieldName}.Enter();"); - lines.AppendLine("try"); + // ReSharper disable once InvertIf + if (IsSystemThreadingLockEnabled(setup)) + { + lines.AppendLine($"{Names.LockFieldName}.Enter();"); + lines.AppendLine("try"); + } } } - public void AddUnlockStatements(LinesBuilder lines, bool isAsync) + public void AddUnlockStatements(MdSetup setup, LinesBuilder lines, bool isAsync) { - if (!isAsync) + if (!isAsync || !IsSystemThreadingLockEnabled(setup)) { return; } @@ -40,4 +46,8 @@ public void AddUnlockStatements(LinesBuilder lines, bool isAsync) lines.AppendLine("}"); } + + private bool IsSystemThreadingLockEnabled(MdSetup setup) => + setup.Hints.IsSystemThreadingLockEnabled + && types.TryGet(SpecialType.Lock, setup.SemanticModel.Compilation) is not null; } \ No newline at end of file diff --git a/src/Pure.DI.Core/Core/Code/ParameterizedConstructorBuilder.cs b/src/Pure.DI.Core/Core/Code/ParameterizedConstructorBuilder.cs index a93ddffc5..f6ddc44be 100644 --- a/src/Pure.DI.Core/Core/Code/ParameterizedConstructorBuilder.cs +++ b/src/Pure.DI.Core/Core/Code/ParameterizedConstructorBuilder.cs @@ -45,7 +45,7 @@ public CompositionCode Build(CompositionCode composition) code.AppendLine($"{Names.RootFieldName} = this;"); if (composition.IsThreadSafe) { - code.AppendLine($"{Names.LockFieldName} = new {locks.GetLockType(composition.Compilation)}();"); + code.AppendLine($"{Names.LockFieldName} = new {locks.GetLockType(composition.Source.Source)}();"); } if (composition.TotalDisposablesCount > 0) diff --git a/src/Pure.DI.Core/Core/Hints.cs b/src/Pure.DI.Core/Core/Hints.cs index a07401a57..77b63d9e7 100644 --- a/src/Pure.DI.Core/Core/Hints.cs +++ b/src/Pure.DI.Core/Core/Hints.cs @@ -41,6 +41,9 @@ internal sealed class Hints : Dictionary, IHints public bool IsResolveEnabled => IsEnabled(Hint.Resolve, SettingState.On); + public bool IsSystemThreadingLockEnabled => + IsEnabled(Hint.SystemThreadingLock, SettingState.On); + public string ResolveMethodName => GetValueOrDefault(Hint.ResolveMethodName, Names.ResolveMethodName); diff --git a/src/Pure.DI.Core/Core/IHints.cs b/src/Pure.DI.Core/Core/IHints.cs index 397dcecda..c3cd4fdd5 100644 --- a/src/Pure.DI.Core/Core/IHints.cs +++ b/src/Pure.DI.Core/Core/IHints.cs @@ -27,6 +27,8 @@ internal interface IHints : IReadOnlyDictionary bool IsFormatCodeEnabled { get; } bool IsResolveEnabled { get; } + + bool IsSystemThreadingLockEnabled { get; } string ResolveMethodName { get; } diff --git a/tests/Pure.DI.UsageTests/Advanced/TrackingAsyncDisposableScenario.cs b/tests/Pure.DI.UsageTests/Advanced/TrackingAsyncDisposableScenario.cs index 67639a0e0..5672636bf 100644 --- a/tests/Pure.DI.UsageTests/Advanced/TrackingAsyncDisposableScenario.cs +++ b/tests/Pure.DI.UsageTests/Advanced/TrackingAsyncDisposableScenario.cs @@ -80,6 +80,9 @@ partial class Composition { static void Setup() => DI.Setup() +// } + .Hint(Hint.SystemThreadingLock, "Off") +// { .Bind().To() .Bind().To()