Skip to content

Commit 1a7a9eb

Browse files
authored
Merge pull request #39 from autofac/feature/nullable-fix
Update nullable annotations to correct handling of tenant ID
2 parents 39f9710 + 3ea67e1 commit 1a7a9eb

12 files changed

+29
-28
lines changed

.vscode/extensions.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
"bierner.markdown-emoji",
44
"davidanson.vscode-markdownlint",
55
"editorconfig.editorconfig",
6-
"formulahendry.dotnet-test-explorer",
76
"gruntfuggly.todo-tree",
8-
"ms-dotnettools.csharp",
7+
"ms-dotnettools.csdevkit",
98
"ryanluker.vscode-coverage-gutters",
109
"stkb.rewrap",
1110
"travisillig.vscode-json-stable-stringify"

appveyor.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
image: Ubuntu
22

3-
version: '8.0.1.{build}'
3+
version: '8.0.2.{build}'
44

55
dotnet_csproj:
6-
version_prefix: '8.0.1'
6+
version_prefix: '8.0.2'
77
patch: true
88
file: 'src\**\*.csproj'
99

src/Autofac.Multitenant/ITenantIdentificationStrategy.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ public interface ITenantIdentificationStrategy
2020
/// if not.
2121
/// </returns>
2222
[SuppressMessage("Microsoft.Design", "CA1007:UseGenericsWhereAppropriate", Justification = "Tenant identifiers are objects.")]
23-
bool TryIdentifyTenant(out object tenantId);
23+
bool TryIdentifyTenant(out object? tenantId);
2424
}

src/Autofac.Multitenant/MultitenantContainer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ public ILifetimeScope BeginLoadContextLifetimeScope(object tag, AssemblyLoadCont
320320
/// </exception>
321321
/// <seealso cref="ConfigurationActionBuilder"/>
322322
/// <seealso cref="ReconfigureTenant(object, Action{ContainerBuilder})"/>
323-
public void ConfigureTenant(object tenantId, Action<ContainerBuilder> configuration)
323+
public void ConfigureTenant(object? tenantId, Action<ContainerBuilder> configuration)
324324
{
325325
if (configuration == null)
326326
{

src/Autofac.Multitenant/TenantIdentificationStrategyExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ public static class TenantIdentificationStrategyExtensions
3131
throw new ArgumentNullException(nameof(strategy));
3232
}
3333

34-
if (strategy.TryIdentifyTenant(out object id))
34+
if (strategy.TryIdentifyTenant(out var id))
3535
{
36-
return (T)id;
36+
return (T?)id;
3737
}
3838

3939
return default;

test/Autofac.Multitenant.AspNetCore.Test/Autofac.Multitenant.AspNetCore.Test.csproj

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<LangVersion>latest</LangVersion>
1313
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
1414
<ImplicitUsings>enable</ImplicitUsings>
15+
<Nullable>enable</Nullable>
1516
</PropertyGroup>
1617

1718
<ItemGroup>
@@ -29,22 +30,22 @@
2930

3031
<ItemGroup>
3132
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="9.0.0" />
32-
<PackageReference Include="coverlet.collector" Version="6.0.0">
33+
<PackageReference Include="coverlet.collector" Version="6.0.1">
3334
<PrivateAssets>all</PrivateAssets>
3435
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
3536
</PackageReference>
36-
<PackageReference Include="coverlet.msbuild" Version="6.0.0">
37+
<PackageReference Include="coverlet.msbuild" Version="6.0.1">
3738
<PrivateAssets>all</PrivateAssets>
3839
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
3940
</PackageReference>
4041
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
41-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
42+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
4243
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556">
4344
<PrivateAssets>all</PrivateAssets>
4445
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
4546
</PackageReference>
46-
<PackageReference Include="xunit" Version="2.6.6" />
47-
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.6">
47+
<PackageReference Include="xunit" Version="2.7.0" />
48+
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.7">
4849
<PrivateAssets>all</PrivateAssets>
4950
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
5051
</PackageReference>

test/Autofac.Multitenant.AspNetCore.Test/Stubs/StubTenantIdentificationStrategy.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ public StubTenantIdentificationStrategy()
1212

1313
public bool IdentificationSuccess { get; set; }
1414

15-
public object TenantId { get; set; }
15+
public object? TenantId { get; set; }
1616

17-
public bool TryIdentifyTenant(out object tenantId)
17+
public bool TryIdentifyTenant(out object? tenantId)
1818
{
1919
tenantId = TenantId;
2020
return IdentificationSuccess;

test/Autofac.Multitenant.Test/Autofac.Multitenant.Test.csproj

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<LangVersion>latest</LangVersion>
1313
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
1414
<ImplicitUsings>enable</ImplicitUsings>
15+
<Nullable>enable</Nullable>
1516
</PropertyGroup>
1617

1718
<ItemGroup>
@@ -28,21 +29,21 @@
2829
</ItemGroup>
2930

3031
<ItemGroup>
31-
<PackageReference Include="coverlet.collector" Version="6.0.0">
32+
<PackageReference Include="coverlet.collector" Version="6.0.1">
3233
<PrivateAssets>all</PrivateAssets>
3334
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
3435
</PackageReference>
35-
<PackageReference Include="coverlet.msbuild" Version="6.0.0">
36+
<PackageReference Include="coverlet.msbuild" Version="6.0.1">
3637
<PrivateAssets>all</PrivateAssets>
3738
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
3839
</PackageReference>
39-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
40+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
4041
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556">
4142
<PrivateAssets>all</PrivateAssets>
4243
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
4344
</PackageReference>
44-
<PackageReference Include="xunit" Version="2.6.6" />
45-
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.6">
45+
<PackageReference Include="xunit" Version="2.7.0" />
46+
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.7">
4647
<PrivateAssets>all</PrivateAssets>
4748
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
4849
</PackageReference>

test/Autofac.Multitenant.Test/MultitenantContainerFixture.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public void ConfigureTenant_RequiresConfiguration()
123123
TenantId = "tenant1",
124124
};
125125
using var mtc = new MultitenantContainer(strategy, builder.Build());
126-
Assert.Throws<ArgumentNullException>(() => mtc.ConfigureTenant("tenant1", null));
126+
Assert.Throws<ArgumentNullException>(() => mtc.ConfigureTenant("tenant1", null!));
127127
}
128128

129129
[Fact]
@@ -142,13 +142,13 @@ public void ConfigureTenant_ThrowsAfterDisposal()
142142
[Fact]
143143
public void Ctor_NullApplicationContainer()
144144
{
145-
Assert.Throws<ArgumentNullException>(() => new MultitenantContainer(new StubTenantIdentificationStrategy(), null));
145+
Assert.Throws<ArgumentNullException>(() => new MultitenantContainer(new StubTenantIdentificationStrategy(), null!));
146146
}
147147

148148
[Fact]
149149
public void Ctor_NullTenantIdentificationStrategy()
150150
{
151-
Assert.Throws<ArgumentNullException>(() => new MultitenantContainer(null, new ContainerBuilder().Build()));
151+
Assert.Throws<ArgumentNullException>(() => new MultitenantContainer(null!, new ContainerBuilder().Build()));
152152
}
153153

154154
[Fact]
@@ -578,7 +578,7 @@ public void ReconfigureTenant_RequiresConfiguration()
578578
using var mtc = new MultitenantContainer(strategy, builder.Build());
579579
mtc.ConfigureTenant("tenant1", b => b.RegisterType<StubDependency1Impl2>().AsImplementedInterfaces().SingleInstance());
580580

581-
Assert.Throws<ArgumentNullException>(() => mtc.ReconfigureTenant("tenant1", null));
581+
Assert.Throws<ArgumentNullException>(() => mtc.ReconfigureTenant("tenant1", null!));
582582
}
583583

584584
[Fact]

test/Autofac.Multitenant.Test/RegistrationExtensionsFixture.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class RegistrationExtensionsFixture
1111
[Fact]
1212
public void InstancePerTenant_NullRegistration()
1313
{
14-
IRegistrationBuilder<StubDependency1Impl1, ConcreteReflectionActivatorData, SingleRegistrationStyle> registration = null;
14+
IRegistrationBuilder<StubDependency1Impl1, ConcreteReflectionActivatorData, SingleRegistrationStyle> registration = null!;
1515
Assert.Throws<ArgumentNullException>(() => registration.InstancePerTenant());
1616
}
1717

0 commit comments

Comments
 (0)