Skip to content

Commit 4bf3f68

Browse files
Merge pull request #385 from martincostello/DotNet-6
Update to .NET 6
2 parents f82664a + 1869091 commit 4bf3f68

File tree

84 files changed

+7697
-7958
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+7697
-7958
lines changed

.editorconfig

+3
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ csharp_prefer_simple_default_expression = true:suggestion
103103
csharp_style_pattern_local_over_anonymous_function = true:suggestion
104104
csharp_style_inlined_variable_declaration = true:suggestion
105105

106+
# Namespace preferences
107+
csharp_style_namespace_declarations = file_scoped
108+
106109
###############################
107110
# C# Formatting Rules #
108111
###############################

.github/workflows/build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
- uses: codecov/codecov-action@v1
4545
name: Upload coverage to Codecov
4646
with:
47-
file: ./artifacts/coverage.net5.0.cobertura.xml
47+
file: ./artifacts/coverage.net6.0.cobertura.xml
4848
flags: ${{ matrix.os_name }}
4949

5050
- name: Publish artifacts

.vsconfig

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"components": [
44
"Microsoft.VisualStudio.Component.CoreEditor",
55
"Microsoft.VisualStudio.Workload.CoreEditor",
6-
"Microsoft.NetCore.Component.Runtime.5.0",
6+
"Microsoft.NetCore.Component.Runtime.6.0",
77
"Microsoft.NetCore.Component.SDK",
88
"Microsoft.VisualStudio.Component.Roslyn.Compiler",
99
"Microsoft.VisualStudio.Component.Roslyn.LanguageServices"

CHANGELOG

+5
Original file line numberDiff line numberDiff line change
@@ -200,3 +200,8 @@ Added overloads to support specifying the name of the Initial Catalog using the
200200
* Publish symbol packages to NuGet.org.
201201
* Use GitHub Actions for CI.
202202
* Prepare for .NET 6.
203+
204+
# SqlLocalDb v3.1.0
205+
206+
## Added
207+
* Add `net6.0` Target Framework Moniker.

CommonAssemblyInfo.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
// Copyright (c) Martin Costello, 2012-2018. All rights reserved.
1+
// Copyright (c) Martin Costello, 2012-2018. All rights reserved.
22
// Licensed under the Apache 2.0 license. See the LICENSE file in the project root for full license information.
33

4-
using System;
54
using System.Reflection;
65
using System.Runtime.InteropServices;
76

Directory.Build.props

+11-2
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@
1919
<EnableNETAnalyzers>true</EnableNETAnalyzers>
2020
<GenerateDocumentationFile>false</GenerateDocumentationFile>
2121
<GenerateGitMetadata Condition=" '$(CI)' != '' and '$(GenerateGitMetadata)' == '' ">true</GenerateGitMetadata>
22+
<ImplicitUsings>enable</ImplicitUsings>
2223
<LangVersion>latest</LangVersion>
2324
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
2425
<NeutralLanguage>en-US</NeutralLanguage>
25-
<NoWarn>$(NoWarn);CA1054;CA2234</NoWarn>
26+
<NoWarn>$(NoWarn);CA1054;CA1848;CA2234</NoWarn>
2627
<NoWarn Condition=" '$(GenerateDocumentationFile)' != 'true' ">$(NoWarn);SA0001</NoWarn>
2728
<Nullable>enable</Nullable>
2829
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
@@ -37,7 +38,7 @@
3738
<SignAssembly>true</SignAssembly>
3839
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
3940
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
40-
<VersionPrefix>3.0.2</VersionPrefix>
41+
<VersionPrefix>3.1.0</VersionPrefix>
4142
<VersionSuffix Condition=" '$(VersionSuffix)' == '' AND '$(GITHUB_ACTIONS)' != '' ">beta$([System.Convert]::ToInt32(`$(GITHUB_RUN_NUMBER)`).ToString(`0000`))</VersionSuffix>
4243
<VersionPrefix Condition=" $(GITHUB_REF.StartsWith(`refs/tags/v`)) ">$(GITHUB_REF.Replace('refs/tags/v', ''))</VersionPrefix>
4344
<VersionSuffix Condition=" $(GITHUB_REF.StartsWith(`refs/tags/v`)) "></VersionSuffix>
@@ -53,4 +54,12 @@
5354
<Threshold Condition=" '$(OS)' == 'Windows_NT' ">80</Threshold>
5455
<Threshold Condition=" '$(OS)' != 'Windows_NT' ">40</Threshold>
5556
</PropertyGroup>
57+
<ItemGroup>
58+
<Using Include="System.Globalization" />
59+
</ItemGroup>
60+
<ItemGroup Condition=" '$(IsTestProject)' == 'true' ">
61+
<Using Include="Shouldly" />
62+
<Using Include="Xunit" />
63+
<Using Include="Xunit.Abstractions" />
64+
</ItemGroup>
5665
</Project>

Directory.Packages.props

+8-9
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
<PackageVersion Include="Humanizer" Version="2.11.10" />
88
<PackageVersion Include="MartinCostello.Logging.XUnit" Version="0.2.0" />
99
<PackageVersion Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" Version="3.3.3" />
10-
<PackageVersion Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.11" />
10+
<PackageVersion Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.0" />
1111
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
1212
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="1.0.0" />
1313
<PackageVersion Include="Moq" Version="4.16.1" />
1414
<PackageVersion Include="NodaTime" Version="$(NodaTimeVersion)" />
1515
<PackageVersion Include="NodaTime.Testing" Version="$(NodaTimeVersion)" />
1616
<PackageVersion Include="ReportGenerator" Version="4.8.13" />
1717
<PackageVersion Include="Shouldly" Version="4.0.3" />
18-
<PackageVersion Include="StyleCop.Analyzers" Version="1.1.118" />
18+
<PackageVersion Include="StyleCop.Analyzers" Version="1.2.0-beta.354" />
1919
<PackageVersion Include="xunit" Version="2.4.1" />
2020
<PackageVersion Include="xunit.runner.visualstudio" Version="2.4.3" />
2121
<PackageVersion Include="Xunit.SkippableFact" Version="1.4.13" />
@@ -26,17 +26,16 @@
2626
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="2.0.0" />
2727
<PackageVersion Include="Microsoft.Win32.Registry" Version="4.5.0" />
2828
</ItemGroup>
29-
<ItemGroup Condition=" '$(AssemblyName)' == 'MartinCostello.SqlLocalDb' and '$(TargetFramework)' == 'net5.0' ">
29+
<ItemGroup Condition=" '$(AssemblyName)' == 'MartinCostello.SqlLocalDb' and '$(TargetFramework)' == 'net6.0' ">
3030
<PackageVersion Include="Microsoft.Data.SqlClient" Version="2.0.1" />
31-
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="5.0.0" />
32-
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="5.0.0" />
33-
<PackageVersion Include="Microsoft.Win32.Registry" Version="5.0.0" />
31+
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0" />
32+
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.0" />
3433
</ItemGroup>
3534
<ItemGroup Condition=" '$(AssemblyName)' != 'MartinCostello.SqlLocalDb' ">
3635
<PackageVersion Include="Microsoft.Data.SqlClient" Version="3.0.1" />
37-
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="5.0.2" />
38-
<PackageVersion Include="Microsoft.Extensions.Logging" Version="5.0.0" />
39-
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="5.0.0" />
36+
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" />
37+
<PackageVersion Include="Microsoft.Extensions.Logging" Version="6.0.0" />
38+
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="6.0.0" />
4039
</ItemGroup>
4140
<ItemGroup>
4241
<PackageReference Include="Microsoft.SourceLink.GitHub" PrivateAssets="All" />

SqlLocalDb.sln

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio Version 16
4-
VisualStudioVersion = 16.0.28922.388
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.0.31612.314
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{E207A447-68A1-4D72-B24F-89FB7890AE12}"
77
ProjectSection(SolutionItems) = preProject

build.ps1

+4-2
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,13 @@ function DotNetBuild {
101101
function DotNetPack {
102102
param([string]$Project)
103103

104+
$PackageOutputPath = (Join-Path $OutputPath "packages")
105+
104106
if ($VersionSuffix) {
105-
& $dotnet pack $Project --output (Join-Path $OutputPath "packages") --configuration $Configuration --version-suffix "$VersionSuffix" --include-symbols --include-source
107+
& $dotnet pack $Project --output $PackageOutputPath --configuration $Configuration --version-suffix "$VersionSuffix" --include-symbols --include-source
106108
}
107109
else {
108-
& $dotnet pack $Project --output (Join-Path $OutputPath "packages") --configuration $Configuration --include-symbols --include-source
110+
& $dotnet pack $Project --output $PackageOutputPath --configuration $Configuration --include-symbols --include-source
109111
}
110112
if ($LASTEXITCODE -ne 0) {
111113
throw "dotnet pack failed with exit code $LASTEXITCODE"

global.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"sdk": {
3-
"version": "5.0.402",
3+
"version": "6.0.100",
44
"allowPrerelease": false,
55
"rollForward": "latestMajor"
66
}

readme.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ This project is licensed under the [Apache 2.0](http://www.apache.org/licenses/L
8080

8181
## Building and Testing
8282

83-
Compiling the library yourself requires Git and the [.NET SDK](https://www.microsoft.com/net/download/core "Download the .NET SDK") to be installed (version `5.0.100` or later).
83+
Compiling the library yourself requires Git and the [.NET SDK](https://www.microsoft.com/net/download/core "Download the .NET SDK") to be installed (version `6.0.100` or later).
8484

8585
For all of the tests to be functional you must also have at least one version of SQL LocalDB installed.
8686

samples/TodoApp.Tests/TodoApp.Tests.csproj

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
<IsPackable>false</IsPackable>
44
<NoWarn>$(NoWarn);CA1303;CA1707;CA2007;SA1600</NoWarn>
55
<RootNamespace>TodoApp</RootNamespace>
6-
<TargetFrameworks>net5.0</TargetFrameworks>
6+
<TargetFrameworks>net6.0</TargetFrameworks>
77
<IsPackable>false</IsPackable>
88
</PropertyGroup>
99
<ItemGroup>
1010
<FrameworkReference Include="Microsoft.AspNetCore.App" />
1111
<PackageReference Include="MartinCostello.Logging.XUnit" />
1212
<PackageReference Include="Microsoft.NET.Test.Sdk" />
1313
<PackageReference Include="NodaTime.Testing" />
14+
<PackageReference Include="Shouldly" />
1415
<PackageReference Include="xunit" />
1516
<PackageReference Include="xunit.runner.visualstudio" />
1617
<PackageReference Include="Xunit.SkippableFact" />
+71-77
Original file line numberDiff line numberDiff line change
@@ -1,114 +1,108 @@
11
// Copyright (c) Martin Costello, 2012-2018. All rights reserved.
22
// Licensed under the Apache 2.0 license. See the LICENSE file in the project root for full license information.
33

4-
using System;
5-
using System.Collections.Generic;
6-
using System.Threading.Tasks;
74
using MartinCostello.SqlLocalDb;
85
using Microsoft.EntityFrameworkCore;
96
using Microsoft.Extensions.Logging;
107
using NodaTime;
118
using NodaTime.Testing;
129
using TodoApp.Data;
13-
using Xunit;
14-
using Xunit.Abstractions;
1510

16-
namespace TodoApp.Tests
11+
namespace TodoApp.Tests;
12+
13+
public class TodoRepositoryTests
1714
{
18-
public class TodoRepositoryTests
15+
public TodoRepositoryTests(ITestOutputHelper outputHelper)
1916
{
20-
public TodoRepositoryTests(ITestOutputHelper outputHelper)
21-
{
22-
LoggerFactory = outputHelper.ToLoggerFactory();
23-
}
17+
LoggerFactory = outputHelper.ToLoggerFactory();
18+
}
2419

25-
private ILoggerFactory LoggerFactory { get; }
20+
private ILoggerFactory LoggerFactory { get; }
2621

27-
[SkippableFact]
28-
public async Task Can_Create_Update_And_Delete_Todo_Items()
29-
{
30-
// Arrange
31-
Skip.IfNot(
32-
OperatingSystem.IsWindows(),
33-
"This test can only be run on Windows.");
22+
[SkippableFact]
23+
public async Task Can_Create_Update_And_Delete_Todo_Items()
24+
{
25+
// Arrange
26+
Skip.IfNot(
27+
OperatingSystem.IsWindows(),
28+
"This test can only be run on Windows.");
3429

35-
var now = new DateTimeOffset(2018, 08, 12, 10, 41, 0, TimeSpan.Zero);
36-
var clock = new FakeClock(Instant.FromDateTimeOffset(now));
30+
var now = new DateTimeOffset(2018, 08, 12, 10, 41, 0, TimeSpan.Zero);
31+
var clock = new FakeClock(Instant.FromDateTimeOffset(now));
3732

38-
var options = new SqlLocalDbOptions()
39-
{
40-
AutomaticallyDeleteInstanceFiles = true,
41-
StopOptions = StopInstanceOptions.NoWait,
42-
StopTimeout = TimeSpan.FromSeconds(1),
43-
};
33+
var options = new SqlLocalDbOptions()
34+
{
35+
AutomaticallyDeleteInstanceFiles = true,
36+
StopOptions = StopInstanceOptions.NoWait,
37+
StopTimeout = TimeSpan.FromSeconds(1),
38+
};
4439

45-
using var localDB = new SqlLocalDbApi(options, LoggerFactory);
46-
using TemporarySqlLocalDbInstance instance = localDB.CreateTemporaryInstance(deleteFiles: true);
40+
using var localDB = new SqlLocalDbApi(options, LoggerFactory);
41+
using TemporarySqlLocalDbInstance instance = localDB.CreateTemporaryInstance(deleteFiles: true);
4742

48-
var builder = new DbContextOptionsBuilder<TodoContext>()
49-
.UseSqlServer(instance.ConnectionString);
43+
var builder = new DbContextOptionsBuilder<TodoContext>()
44+
.UseSqlServer(instance.ConnectionString);
5045

51-
using var context = new TodoContext(builder.Options);
52-
await context.Database.MigrateAsync();
46+
using var context = new TodoContext(builder.Options);
47+
await context.Database.MigrateAsync();
5348

54-
var target = new TodoRepository(clock, context);
49+
var target = new TodoRepository(clock, context);
5550

56-
// Act - Verify the repository is empty
57-
IList<TodoItem> items = await target.GetItemsAsync();
51+
// Act - Verify the repository is empty
52+
IList<TodoItem> items = await target.GetItemsAsync();
5853

59-
// Assert
60-
Assert.NotNull(items);
61-
Assert.Empty(items);
54+
// Assert
55+
Assert.NotNull(items);
56+
Assert.Empty(items);
6257

63-
// Arrange - Add a new item
64-
string text = "Buy cheese";
58+
// Arrange - Add a new item
59+
string text = "Buy cheese";
6560

66-
// Act
67-
TodoItem item = await target.AddItemAsync(text);
61+
// Act
62+
TodoItem item = await target.AddItemAsync(text);
6863

69-
// Assert
70-
Assert.NotNull(item);
71-
Assert.NotEqual(Guid.Empty, item.Id);
72-
Assert.Equal(text, item.Text);
73-
Assert.Equal(now, item.CreatedAt);
74-
Assert.Null(item.CompletedAt);
64+
// Assert
65+
Assert.NotNull(item);
66+
Assert.NotEqual(Guid.Empty, item.Id);
67+
Assert.Equal(text, item.Text);
68+
Assert.Equal(now, item.CreatedAt);
69+
Assert.Null(item.CompletedAt);
7570

76-
// Arrange - Mark the item as completed
77-
Guid id = item.Id;
71+
// Arrange - Mark the item as completed
72+
Guid id = item.Id;
7873

79-
// Act
80-
bool? completeResult = await target.CompleteItemAsync(id);
74+
// Act
75+
bool? completeResult = await target.CompleteItemAsync(id);
8176

82-
// Assert
83-
Assert.True(completeResult);
77+
// Assert
78+
Assert.True(completeResult);
8479

85-
// Act - Verify the repository has one item that is completed
86-
items = await target.GetItemsAsync();
80+
// Act - Verify the repository has one item that is completed
81+
items = await target.GetItemsAsync();
8782

88-
// Assert
89-
Assert.NotNull(items);
90-
Assert.NotEmpty(items);
91-
Assert.Equal(1, items.Count);
83+
// Assert
84+
Assert.NotNull(items);
85+
Assert.NotEmpty(items);
86+
Assert.Equal(1, items.Count);
9287

93-
item = items[0];
94-
Assert.NotNull(item);
95-
Assert.NotEqual(Guid.Empty, item.Id);
96-
Assert.Equal(text, item.Text);
97-
Assert.Equal(now, item.CreatedAt);
98-
Assert.Equal(now, item.CompletedAt);
88+
item = items[0];
89+
Assert.NotNull(item);
90+
Assert.NotEqual(Guid.Empty, item.Id);
91+
Assert.Equal(text, item.Text);
92+
Assert.Equal(now, item.CreatedAt);
93+
Assert.Equal(now, item.CompletedAt);
9994

100-
// Act - Delete the item
101-
bool deleteResult = await target.DeleteItemAsync(id);
95+
// Act - Delete the item
96+
bool deleteResult = await target.DeleteItemAsync(id);
10297

103-
// Assert
104-
Assert.True(deleteResult);
98+
// Assert
99+
Assert.True(deleteResult);
105100

106-
// Act - Verify the repository is empty again
107-
items = await target.GetItemsAsync();
101+
// Act - Verify the repository is empty again
102+
items = await target.GetItemsAsync();
108103

109-
// Assert
110-
Assert.NotNull(items);
111-
Assert.Empty(items);
112-
}
104+
// Assert
105+
Assert.NotNull(items);
106+
Assert.Empty(items);
113107
}
114108
}

0 commit comments

Comments
 (0)