Skip to content

Commit

Permalink
Update Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolayPianikov committed Apr 26, 2024
1 parent 0e8ee70 commit 531dc8f
Show file tree
Hide file tree
Showing 20 changed files with 43 additions and 52 deletions.
2 changes: 1 addition & 1 deletion readme/Avalonia.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ The [project file](/samples/AvaloniaApp/AvaloniaApp.csproj) looks like this:
</PropertyGroup>

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

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

<ItemGroup>
<PackageReference Include="Pure.DI" Version="2.1.10">
<PackageReference Include="Pure.DI" Version="2.1.11">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
2 changes: 1 addition & 1 deletion readme/Console.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ The [project file](/samples/ShroedingersCat/ShroedingersCat.csproj) looks like t
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Pure.DI" Version="2.1.10">
<PackageReference Include="Pure.DI" Version="2.1.11">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
2 changes: 1 addition & 1 deletion readme/ConsoleNativeAOT.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The [project file](/samples/ShroedingersCatNativeAOT/ShroedingersCatNativeAOT.cs
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Pure.DI" Version="2.1.10">
<PackageReference Include="Pure.DI" Version="2.1.11">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
2 changes: 1 addition & 1 deletion readme/ConsoleTopLevelStatements.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ The [project file](/samples/ShroedingersCatTopLevelStatements/ShroedingersCatTop
</PropertyGroup>

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

<ItemGroup>
<PackageReference Include="Pure.DI" Version="2.1.10">
<PackageReference Include="Pure.DI" Version="2.1.11">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
2 changes: 1 addition & 1 deletion readme/Maui.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ The [project file](/samples/MAUIApp/MAUIApp.csproj) looks like this:
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)"/>
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="$(MauiVersion)"/>
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0"/>
<PackageReference Include="Pure.DI" Version="2.1.10">
<PackageReference Include="Pure.DI" Version="2.1.11">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
2 changes: 1 addition & 1 deletion readme/MinimalWebAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ The [project file](/samples/WebAPI/WebAPI.csproj) looks like this:
</PropertyGroup>

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

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

<ItemGroup>
<PackageReference Include="Pure.DI" Version="2.1.10">
<PackageReference Include="Pure.DI" Version="2.1.11">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
2 changes: 1 addition & 1 deletion readme/WinFormsApp.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ The [project file](/samples/WinFormsApp/WinFormsApp.csproj) looks like this:
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

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

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

<ItemGroup>
<PackageReference Include="Pure.DI" Version="2.1.10">
<PackageReference Include="Pure.DI" Version="2.1.11">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
9 changes: 4 additions & 5 deletions readme/async-disposable-scope.md
Original file line number Diff line number Diff line change
Expand Up @@ -299,11 +299,11 @@ partial class Composition: global::System.IDisposable, global::System.IAsyncDisp
{
OnAsyncDisposeException(asyncDisposableInstance, exception);
}
continue;
continue;
}
}

}

public async global::System.Threading.Tasks.ValueTask DisposeAsync()
{
int disposeIndex;
Expand All @@ -320,7 +320,6 @@ partial class Composition: global::System.IDisposable, global::System.IAsyncDisp
while (disposeIndex > 0)
{
var instance = disposables[--disposeIndex];

var asyncDisposableInstance = instance as global::System.IAsyncDisposable;
if (asyncDisposableInstance != null)
{
Expand All @@ -332,8 +331,9 @@ partial class Composition: global::System.IDisposable, global::System.IAsyncDisp
{
OnAsyncDisposeException(asyncDisposableInstance, exception);
}
continue;
continue;
}

var disposableInstance = instance as global::System.IDisposable;
if (disposableInstance != null)
{
Expand All @@ -348,7 +348,6 @@ partial class Composition: global::System.IDisposable, global::System.IAsyncDisp
continue;
}
}

}

partial void OnDisposeException<T>(T disposableInstance, Exception exception) where T : global::System.IDisposable;
Expand Down
9 changes: 4 additions & 5 deletions readme/async-disposable-singleton.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,11 @@ partial class Composition: global::System.IDisposable, global::System.IAsyncDisp
{
OnAsyncDisposeException(asyncDisposableInstance, exception);
}
continue;
continue;
}
}

}

public async global::System.Threading.Tasks.ValueTask DisposeAsync()
{
int disposeIndex;
Expand All @@ -255,7 +255,6 @@ partial class Composition: global::System.IDisposable, global::System.IAsyncDisp
while (disposeIndex > 0)
{
var instance = disposables[--disposeIndex];

var asyncDisposableInstance = instance as global::System.IAsyncDisposable;
if (asyncDisposableInstance != null)
{
Expand All @@ -267,8 +266,9 @@ partial class Composition: global::System.IDisposable, global::System.IAsyncDisp
{
OnAsyncDisposeException(asyncDisposableInstance, exception);
}
continue;
continue;
}

var disposableInstance = instance as global::System.IDisposable;
if (disposableInstance != null)
{
Expand All @@ -283,7 +283,6 @@ partial class Composition: global::System.IDisposable, global::System.IAsyncDisp
continue;
}
}

}

partial void OnDisposeException<T>(T disposableInstance, Exception exception) where T : global::System.IDisposable;
Expand Down
3 changes: 1 addition & 2 deletions readme/disposable-singleton.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,9 @@ partial class Composition: global::System.IDisposable
{
OnAsyncDisposeException(asyncDisposableInstance, exception);
}
continue;
continue;
}
}

}

partial void OnDisposeException<T>(T disposableInstance, Exception exception) where T : global::System.IDisposable;
Expand Down
3 changes: 1 addition & 2 deletions readme/scope.md
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,9 @@ partial class Composition: global::System.IDisposable
{
OnAsyncDisposeException(asyncDisposableInstance, exception);
}
continue;
continue;
}
}

}

partial void OnDisposeException<T>(T disposableInstance, Exception exception) where T : global::System.IDisposable;
Expand Down
3 changes: 1 addition & 2 deletions readme/service-provider-with-scope.md
Original file line number Diff line number Diff line change
Expand Up @@ -283,10 +283,9 @@ partial class Composition: global::System.IDisposable
{
OnAsyncDisposeException(asyncDisposableInstance, exception);
}
continue;
continue;
}
}

}

partial void OnDisposeException<T>(T disposableInstance, Exception exception) where T : global::System.IDisposable;
Expand Down
40 changes: 18 additions & 22 deletions src/Pure.DI.Core/Core/Code/DisposeMethodBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,25 @@ public CompositionCode Build(CompositionCode composition)
{
code.AppendLine("var instance = disposables[--disposeIndex];");
AddDisposePart(code);
code.AppendLine();
AddAsyncDisposePart(composition, code, false);
}

code.AppendLine("}");
code.AppendLine();
}

code.AppendLine("}");
code.AppendLine();
membersCounter++;

code.AppendLine("/// <summary>");
code.AppendLine("/// Implement this partial method to handle the exception on disposing.");
code.AppendLine("/// <summary>");
code.AppendLine("/// <param name=\"disposableInstance\">The disposable instance.</param>");
code.AppendLine("/// <param name=\"exception\">Exception occurring during disposal.</param>");
code.AppendLine("/// <typeparam name=\"T\">The actual type of instance being disposed of.</typeparam>");
code.AppendLine($"partial void {Names.OnDisposeExceptionMethodName}<T>(T disposableInstance, Exception exception) where T : {Names.IDisposableInterfaceName};");
code.AppendLine();
membersCounter++;

if (composition.AsyncDisposableCount > 0 && asyncDisposableSettings.IsEnabled(composition.Source.Source.SemanticModel.Compilation))
Expand All @@ -71,31 +82,17 @@ public CompositionCode Build(CompositionCode composition)
{
code.AppendLine("var instance = disposables[--disposeIndex];");
AddAsyncDisposePart(composition, code, true);
code.AppendLine();
AddDisposePart(code);
}

code.AppendLine("}");
code.AppendLine();
}

code.AppendLine("}");
code.AppendLine();
membersCounter++;
}

code.AppendLine();
code.AppendLine("/// <summary>");
code.AppendLine("/// Implement this partial method to handle the exception on disposing.");
code.AppendLine("/// <summary>");
code.AppendLine("/// <param name=\"disposableInstance\">The disposable instance.</param>");
code.AppendLine("/// <param name=\"exception\">Exception occurring during disposal.</param>");
code.AppendLine("/// <typeparam name=\"T\">The actual type of instance being disposed of.</typeparam>");
code.AppendLine($"partial void {Names.OnDisposeExceptionMethodName}<T>(T disposableInstance, Exception exception) where T : {Names.IDisposableInterfaceName};");
code.AppendLine();
membersCounter++;

// ReSharper disable once InvertIf
if (asyncDisposableSettings.IsEnabled(composition.Source.Source.SemanticModel.Compilation))
{

code.AppendLine();
code.AppendLine("/// <summary>");
code.AppendLine("/// Implement this partial method to handle the exception on async disposing.");
Expand All @@ -107,7 +104,7 @@ public CompositionCode Build(CompositionCode composition)
code.AppendLine();
membersCounter++;
}

return composition with { MembersCount = membersCounter };
}

Expand All @@ -118,7 +115,6 @@ private void AddAsyncDisposePart(CompositionCode composition, LinesBuilder code,
return;
}

code.AppendLine();
code.AppendLine($"var asyncDisposableInstance = instance as {Names.IAsyncDisposableInterfaceName};");
code.AppendLine("if (asyncDisposableInstance != null)");
code.AppendLine("{");
Expand Down Expand Up @@ -154,9 +150,9 @@ private void AddAsyncDisposePart(CompositionCode composition, LinesBuilder code,
}

code.AppendLine("}");
code.AppendLine("continue;");
}

code.AppendLine("continue;");

code.AppendLine("}");
}

Expand Down

0 comments on commit 531dc8f

Please sign in to comment.