Skip to content

Commit 8b925e2

Browse files
authored
Merge pull request #1 from Shuttle/v20
V20
2 parents 5f8e9e1 + eba9cbe commit 8b925e2

13 files changed

Lines changed: 155 additions & 185 deletions

Shuttle.Core.TransactionScope/.package/AssemblyInfo.cs.template

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
11
using System.Reflection;
22
using System.Runtime.InteropServices;
33

4-
#if NETSTANDARD
5-
[assembly: AssemblyTitle(".NET Standard")]
6-
#endif
7-
8-
#if NET6_0_OR_GREATER
9-
[assembly: AssemblyTitle(".NET 6.0 (or greater)")]
10-
#endif
11-
4+
[assembly: AssemblyTitle(".NET Unified Platform")]
125
[assembly: AssemblyVersion("#{SemanticVersionCore}#.0")]
136
[assembly: AssemblyCopyright("Copyright (c) #{Year}#, Eben Roux")]
147
[assembly: AssemblyProduct("Shuttle.Core.TransactionScope")]

Shuttle.Core.TransactionScope/.package/Shuttle.NuGetPackager.targets

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
<?xml version="1.0" encoding="utf-8" ?>
1+
<?xml version="1.0" encoding="utf-8"?>
2+
23
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
34
<PropertyGroup>
45
<PackageTasksPath Condition="'$(PackageTasksPath)' == ''">Shuttle.NuGetPackager.MSBuild.dll</PackageTasksPath>
@@ -9,4 +10,4 @@
910
<UsingTask AssemblyFile="$(PackageTasksPath)" TaskName="Shuttle.NuGetPackager.MSBuild.NuGet.SetNuGetPackageVersions" />
1011
<UsingTask AssemblyFile="$(PackageTasksPath)" TaskName="Shuttle.NuGetPackager.MSBuild.Zip" />
1112
<UsingTask AssemblyFile="$(PackageTasksPath)" TaskName="Shuttle.NuGetPackager.MSBuild.NuGet.SemanticVersion" />
12-
</Project>
13+
</Project>

Shuttle.Core.TransactionScope/.package/package.nuspec

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<package>
44
<metadata>
55
<id>Shuttle.Core.TransactionScope</id>
6-
<version>11.1.0</version>
6+
<version>20.0.0</version>
77
<authors>Eben Roux</authors>
88
<owners>Eben Roux</owners>
99
<license type="expression">BSD-3-Clause</license>
@@ -16,11 +16,11 @@
1616
<copyright>Copyright (c) 2024, Eben Roux</copyright>
1717
<tags>transactionscope</tags>
1818
<dependencies>
19-
<dependency id="Microsoft.Extensions.Configuration" version="7.0.0" />
20-
<dependency id="Microsoft.Extensions.DependencyInjection" version="7.0.0" />
21-
<dependency id="Microsoft.Extensions.Options" version="7.0.1" />
22-
<dependency id="Microsoft.Extensions.Options.ConfigurationExtensions" version="7.0.0" />
23-
<dependency id="Shuttle.Core.Contract" version="11.1.0" />
19+
<dependency id="Microsoft.Extensions.Configuration" version="8.0.0" />
20+
<dependency id="Microsoft.Extensions.DependencyInjection" version="8.0.1" />
21+
<dependency id="Microsoft.Extensions.Options" version="8.0.2" />
22+
<dependency id="Microsoft.Extensions.Options.ConfigurationExtensions" version="8.0.0" />
23+
<dependency id="Shuttle.Core.Contract" version="20.0.0" />
2424
</dependencies>
2525
</metadata>
2626
<files>
Lines changed: 33 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,50 @@
11
using System;
22
using System.Transactions;
33

4-
namespace Shuttle.Core.TransactionScope
4+
namespace Shuttle.Core.TransactionScope;
5+
6+
public class DefaultTransactionScope : ITransactionScope
57
{
6-
public class DefaultTransactionScope : ITransactionScope
7-
{
8-
private readonly bool _ignore;
8+
private readonly bool _ignore;
99

10-
private readonly System.Transactions.TransactionScope _scope;
10+
private readonly System.Transactions.TransactionScope _scope;
1111

12-
public DefaultTransactionScope(IsolationLevel isolationLevel, TimeSpan timeout)
13-
{
14-
Id = Guid.NewGuid();
12+
public DefaultTransactionScope(IsolationLevel isolationLevel, TimeSpan timeout)
13+
{
14+
Id = Guid.NewGuid();
1515

16-
_ignore = Transaction.Current != null;
16+
_ignore = Transaction.Current != null;
1717

18-
_scope = new System.Transactions.TransactionScope(TransactionScopeOption.RequiresNew,
19-
new TransactionOptions
20-
{
21-
IsolationLevel = isolationLevel,
22-
Timeout = timeout
23-
},
24-
TransactionScopeAsyncFlowOption.Enabled);
25-
}
18+
_scope = new(TransactionScopeOption.RequiresNew,
19+
new TransactionOptions
20+
{
21+
IsolationLevel = isolationLevel,
22+
Timeout = timeout
23+
},
24+
TransactionScopeAsyncFlowOption.Enabled);
25+
}
2626

27-
public void Dispose()
27+
public void Dispose()
28+
{
29+
try
2830
{
29-
try
30-
{
31-
_scope?.Dispose();
32-
}
33-
catch
34-
{
35-
// _ignore --- may be a bug in TransactionScope
36-
}
31+
_scope?.Dispose();
32+
}
33+
catch
34+
{
35+
// _ignore --- may be a bug in TransactionScope
3736
}
37+
}
3838

39-
public Guid Id { get; }
39+
public Guid Id { get; }
4040

41-
public void Complete()
41+
public void Complete()
42+
{
43+
if (_ignore)
4244
{
43-
if (_ignore)
44-
{
45-
return;
46-
}
47-
48-
_scope?.Complete();
45+
return;
4946
}
47+
48+
_scope?.Complete();
5049
}
5150
}
Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
using System;
22

3-
namespace Shuttle.Core.TransactionScope
3+
namespace Shuttle.Core.TransactionScope;
4+
5+
public interface ITransactionScope : IDisposable
46
{
5-
public interface ITransactionScope : IDisposable
6-
{
7-
Guid Id { get; }
8-
void Complete();
9-
}
7+
Guid Id { get; }
8+
void Complete();
109
}
Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
using System;
22
using System.Transactions;
33

4-
namespace Shuttle.Core.TransactionScope
4+
namespace Shuttle.Core.TransactionScope;
5+
6+
public interface ITransactionScopeFactory
57
{
6-
public interface ITransactionScopeFactory
7-
{
8-
ITransactionScope Create();
9-
ITransactionScope Create(IsolationLevel isolationLevel, TimeSpan timeout);
10-
}
8+
ITransactionScope Create();
9+
ITransactionScope Create(IsolationLevel isolationLevel, TimeSpan timeout);
1110
}
Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
using System;
22

3-
namespace Shuttle.Core.TransactionScope
3+
namespace Shuttle.Core.TransactionScope;
4+
5+
public class NullTransactionScope : ITransactionScope
46
{
5-
public class NullTransactionScope : ITransactionScope
6-
{
7-
public Guid Id => Guid.Empty;
7+
public Guid Id => Guid.Empty;
88

9-
public void Complete()
10-
{
11-
}
9+
public void Complete()
10+
{
11+
}
1212

13-
public void Dispose()
14-
{
15-
}
13+
public void Dispose()
14+
{
1615
}
1716
}
Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
11
using System.Reflection;
22
using System.Runtime.InteropServices;
33

4-
#if NETSTANDARD
5-
[assembly: AssemblyTitle(".NET Standard")]
6-
#endif
7-
8-
#if NET6_0_OR_GREATER
9-
[assembly: AssemblyTitle(".NET 6.0 (or greater)")]
10-
#endif
11-
12-
[assembly: AssemblyVersion("11.1.0.0")]
4+
[assembly: AssemblyTitle(".NET Unified Platform")]
5+
[assembly: AssemblyVersion("20.0.0.0")]
136
[assembly: AssemblyCopyright("Copyright (c) 2024, Eben Roux")]
147
[assembly: AssemblyProduct("Shuttle.Core.TransactionScope")]
158
[assembly: AssemblyCompany("Eben Roux")]
169
[assembly: AssemblyConfiguration("Release")]
17-
[assembly: AssemblyInformationalVersion("11.1.0")]
10+
[assembly: AssemblyInformationalVersion("20.0.0")]
1811
[assembly: ComVisible(false)]
Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
11
using System;
22
using Microsoft.Extensions.DependencyInjection;
3+
using Microsoft.Extensions.Options;
34
using Shuttle.Core.Contract;
45

5-
namespace Shuttle.Core.TransactionScope
6+
namespace Shuttle.Core.TransactionScope;
7+
8+
public static class ServiceCollectionExtensions
69
{
7-
public static class ServiceCollectionExtensions
10+
public static IServiceCollection AddTransactionScope(this IServiceCollection services, Action<TransactionScopeBuilder>? builder = null)
811
{
9-
public static IServiceCollection AddTransactionScope(this IServiceCollection services, Action<TransactionScopeBuilder> builder = null)
10-
{
11-
Guard.AgainstNull(services, nameof(services));
12+
Guard.AgainstNull(services);
1213

13-
var transactionScopeBuilder = new TransactionScopeBuilder(services);
14+
var transactionScopeBuilder = new TransactionScopeBuilder(services);
1415

15-
builder?.Invoke(transactionScopeBuilder);
16+
builder?.Invoke(transactionScopeBuilder);
1617

17-
services.AddOptions<TransactionScopeOptions>().Configure(options =>
18-
{
19-
options.IsolationLevel = transactionScopeBuilder.Options.IsolationLevel;
20-
options.Timeout = transactionScopeBuilder.Options.Timeout;
21-
options.Enabled = transactionScopeBuilder.Options.Enabled;
22-
});
18+
services.AddOptions<TransactionScopeOptions>().Configure(options =>
19+
{
20+
options.IsolationLevel = transactionScopeBuilder.Options.IsolationLevel;
21+
options.Timeout = transactionScopeBuilder.Options.Timeout;
22+
options.Enabled = transactionScopeBuilder.Options.Enabled;
23+
});
2324

24-
if (services.Contains(ServiceDescriptor.Singleton<ITransactionScopeFactory, TransactionScopeFactory>()))
25-
{
26-
throw new InvalidOperationException(Resources.AddTransactionScopeFactoryException);
27-
}
25+
if (services.Contains(ServiceDescriptor.Singleton<ITransactionScopeFactory, TransactionScopeFactory>()))
26+
{
27+
throw new InvalidOperationException(Resources.AddTransactionScopeFactoryException);
28+
}
2829

29-
services.AddSingleton<ITransactionScopeFactory, TransactionScopeFactory>();
30+
services.AddSingleton<ITransactionScopeFactory, TransactionScopeFactory>();
3031

31-
return services;
32-
}
32+
return services;
3333
}
3434
}
Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,40 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

3-
<PropertyGroup>
4-
<TargetFrameworks>netstandard2.1;net6.0</TargetFrameworks>
5-
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
6-
</PropertyGroup>
3+
<PropertyGroup>
4+
<TargetFramework>net8.0</TargetFramework>
5+
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
6+
<Nullable>enable</Nullable>
7+
</PropertyGroup>
78

8-
<ItemGroup>
9-
<None Include=".package\AssemblyInfo.cs.template" />
10-
<None Include=".package\package.msbuild" />
11-
<None Include=".package\package.nuspec.template" />
12-
<None Include=".package\Shuttle.NuGetPackager.MSBuild.dll" />
13-
<None Include=".package\Shuttle.NuGetPackager.targets" />
14-
</ItemGroup>
9+
<ItemGroup>
10+
<None Include=".package\AssemblyInfo.cs.template" />
11+
<None Include=".package\package.msbuild" />
12+
<None Include=".package\package.nuspec.template" />
13+
<None Include=".package\Shuttle.NuGetPackager.MSBuild.dll" />
14+
<None Include=".package\Shuttle.NuGetPackager.targets" />
15+
</ItemGroup>
1516

16-
<ItemGroup>
17-
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
18-
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
19-
<PackageReference Include="Microsoft.Extensions.Options" Version="7.0.1" />
20-
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="7.0.0" />
21-
<PackageReference Include="Shuttle.Core.Contract" Version="11.1.0" />
22-
</ItemGroup>
17+
<ItemGroup>
18+
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
19+
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.1" />
20+
<PackageReference Include="Microsoft.Extensions.Options" Version="8.0.2" />
21+
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.0.0" />
22+
<PackageReference Include="Shuttle.Core.Contract" Version="20.0.0" />
23+
</ItemGroup>
2324

24-
<ItemGroup>
25-
<Compile Update="Resources.Designer.cs">
26-
<DesignTime>True</DesignTime>
27-
<AutoGen>True</AutoGen>
28-
<DependentUpon>Resources.resx</DependentUpon>
29-
</Compile>
30-
</ItemGroup>
25+
<ItemGroup>
26+
<Compile Update="Resources.Designer.cs">
27+
<DesignTime>True</DesignTime>
28+
<AutoGen>True</AutoGen>
29+
<DependentUpon>Resources.resx</DependentUpon>
30+
</Compile>
31+
</ItemGroup>
3132

32-
<ItemGroup>
33-
<EmbeddedResource Update="Resources.resx">
34-
<Generator>PublicResXFileCodeGenerator</Generator>
35-
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
36-
</EmbeddedResource>
37-
</ItemGroup>
33+
<ItemGroup>
34+
<EmbeddedResource Update="Resources.resx">
35+
<Generator>PublicResXFileCodeGenerator</Generator>
36+
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
37+
</EmbeddedResource>
38+
</ItemGroup>
3839

3940
</Project>

0 commit comments

Comments
 (0)