Skip to content

Commit

Permalink
#80 Error CS1061 : 'object' does not contain a definition for 'Enter'…
Browse files Browse the repository at this point in the history
…/'Exit'
  • Loading branch information
NikolayPianikov committed Dec 27, 2024
1 parent a48aea7 commit f3ee58f
Show file tree
Hide file tree
Showing 22 changed files with 105 additions and 43 deletions.
20 changes: 16 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 | | .+ |
Expand All @@ -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.

Expand Down Expand Up @@ -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<Service>()
.Root<Service>("MyService");
```

![ReadmeDocumentation1.png](readme/ReadmeDocumentation1.png)

Then documentation for the composition root:
Expand Down
2 changes: 1 addition & 1 deletion readme/BlazorServerApp.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ The [project file](/samples/BlazorServerApp/BlazorServerApp.csproj) looks like t
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Pure.DI.MS" Version="2.1.45" />
<PackageReference Include="Pure.DI.MS" Version="2.1.46" />
</ItemGroup>

</Project>
Expand Down
2 changes: 1 addition & 1 deletion readme/BlazorWebAssemblyApp.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ The [project file](/samples/BlazorWebAssemblyApp/BlazorWebAssemblyApp.csproj) lo
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Pure.DI.MS" Version="2.1.45" />
<PackageReference Include="Pure.DI.MS" Version="2.1.46" />
</ItemGroup>

</Project>
Expand Down
20 changes: 16 additions & 4 deletions readme/FooterTemplate.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 | | .+ |
Expand All @@ -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.

Expand Down Expand Up @@ -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<Service>()
.Root<Service>("MyService");
```

![ReadmeDocumentation1.png](readme/ReadmeDocumentation1.png)

Then documentation for the composition root:
Expand Down
2 changes: 1 addition & 1 deletion readme/GrpcService.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ The [project file](/samples/GrpcService/GrpcService.csproj) looks like this:
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Pure.DI.MS" Version="2.1.45" />
<PackageReference Include="Pure.DI.MS" Version="2.1.46" />
</ItemGroup>

</Project>
Expand Down
2 changes: 1 addition & 1 deletion readme/Maui.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ The [project file](/samples/MAUIApp/MAUIApp.csproj) looks like this:
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Pure.DI.MS" Version="2.1.45" />
<PackageReference Include="Pure.DI.MS" Version="2.1.46" />
</ItemGroup>

</Project>
Expand Down
2 changes: 1 addition & 1 deletion readme/MinimalWebAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ The [project file](/samples/WebAPI/WebAPI.csproj) looks like this:
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Pure.DI.MS" Version="2.1.45" />
<PackageReference Include="Pure.DI.MS" Version="2.1.46" />
</ItemGroup>

</Project>
Expand Down
2 changes: 1 addition & 1 deletion readme/WebAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ The [project file](/samples/WebAPI/WebAPI.csproj) looks like this:
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Pure.DI.MS" Version="2.1.45" />
<PackageReference Include="Pure.DI.MS" Version="2.1.46" />
</ItemGroup>

</Project>
Expand Down
2 changes: 1 addition & 1 deletion readme/WebApp.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ The [project file](/samples/WebApp/WebApp.csproj) looks like this:
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Pure.DI.MS" Version="2.1.45" />
<PackageReference Include="Pure.DI.MS" Version="2.1.46" />
</ItemGroup>

</Project>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ partial class Composition
{
static void Setup() =>
DI.Setup()

.Bind().To<Dependency>()
.Bind().To<Service>()

Expand Down Expand Up @@ -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)
Expand All @@ -121,7 +122,7 @@ partial class Composition
{
var accumulator46 = new Owned();
Dependency transientDependency3 = new Dependency();
using (_lock.EnterScope())
lock (_lock)
{
accumulator46.Add(transientDependency3);
}
Expand All @@ -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<IService>(localValue14, localOwned13);
using (_lock.EnterScope())
lock (_lock)
{
accumulator46.Add(perBlockOwned0);
}
Expand Down
22 changes: 21 additions & 1 deletion src/Pure.DI.Core/Components/Api.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,27 @@ internal enum Hint
/// </example>
/// </summary>
/// <seealso cref="IConfiguration.Hint"/>
Comments
Comments,

/// <summary>
/// <c>On</c> or <c>Off</c>. Indicates whether <see cref="System.Threading.Lock"/> should be used whenever possible instead of the classic approach of synchronizing object access using <see cref="System.Threading.Monitor"/>. <c>On</c> by default.
/// <example>
/// <code>
/// // SystemThreadingLock = Off
/// DI.Setup("Composition")
/// .Bind&lt;IDependency&gt;().To&lt;Dependency&gt;();
/// </code>
/// <br/>
/// or using the API call <see cref="IConfiguration.Hint"/>:
/// <code>
/// DI.Setup("Composition")
/// .Hint(Hint.SystemThreadingLock, "Off")
/// .Bind&lt;IDependency&gt;().To&lt;Dependency&gt;();
/// </code>
/// </example>
/// </summary>
/// <seealso cref="IConfiguration.Hint"/>
SystemThreadingLock
}

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions src/Pure.DI.Core/Core/Code/BlockCodeBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down Expand Up @@ -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;
}
Expand Down
Loading

0 comments on commit f3ee58f

Please sign in to comment.