diff --git a/.editorconfig b/.editorconfig index 882db3b8d..901b01d4d 100644 --- a/.editorconfig +++ b/.editorconfig @@ -2,10 +2,16 @@ root=true [*] -trim_trailing_whitespace = true +end_of_line = crlf +indent_size = 4 +indent_style = space insert_final_newline = true +trim_trailing_whitespace = true + +[*.cake] indent_style = space indent_size = 4 +tab_width = 4 [*.{config,xml,js,json,html,css,sql,csproj,props,yml}] indent_size = 2 @@ -17,26 +23,30 @@ end_of_line = lf end_of_line = crlf [{**/tests/**,**/Tests/**,**/*.Tests/**}.cs] -resharper_class_never_instantiated_global_highlighting=do_not_show -resharper_consider_using_configure_await_highlighting=do_not_show -resharper_event_exception_not_documented_highlighting=do_not_show -resharper_exception_not_documented_highlighting=do_not_show -resharper_exception_not_documented_optional_highlighting=do_not_show -resharper_heap_view_boxing_allocation=do_not_show -resharper_heap_view_boxing_allocation_highlighting=do_not_show -resharper_heap_view_closure_allocation_highlighting=do_not_show -resharper_heap_view_delegate_allocation_highlighting=do_not_show -resharper_heap_view_object_allocation_highlighting=do_not_show -resharper_heap_view_object_allocation_evident_highlighting=do_not_show -resharper_possible_null_reference_exception_highlighting=do_not_show -resharper_private_field_can_be_converted_to_local_variable_highlighting=do_not_show -resharper_return_value_of_pure_method_is_not_used_highlighting=do_not_show -resharper_suggest_base_type_for_parameter_highlighting=do_not_show -resharper_class_with_virtual_members_never_inherited_local_highlighting=do_not_show -resharper_class_with_virtual_members_never_inherited_global_highlighting=do_not_show +resharper_async_converter_async_await_may_be_elided_highlighting=do_not_show +resharper_class_never_instantiated_global_highlighting = do_not_show +resharper_class_with_virtual_members_never_inherited_global_highlighting = do_not_show +resharper_class_with_virtual_members_never_inherited_local_highlighting = do_not_show +resharper_consider_using_configure_await_highlighting = do_not_show +resharper_event_exception_not_documented_highlighting = do_not_show +resharper_exception_not_documented_highlighting = do_not_show +resharper_exception_not_documented_optional_highlighting = do_not_show +resharper_heap_view_boxing_allocation_highlighting = do_not_show +resharper_heap_view_closure_allocation_highlighting = do_not_show +resharper_heap_view_delegate_allocation_highlighting = do_not_show +resharper_heap_view_object_allocation_evident_highlighting = do_not_show +resharper_heap_view_object_allocation_highlighting = do_not_show +resharper_inconsistent_naming_highlighting = do_not_show +resharper_missing_annotation_highlighting = do_not_show +resharper_missing_xml_doc_highlighting = do_not_show +resharper_possible_null_reference_exception_highlighting = do_not_show +resharper_private_field_can_be_converted_to_local_variable_highlighting = do_not_show +resharper_return_value_of_pure_method_is_not_used_highlighting = do_not_show +resharper_suggest_base_type_for_parameter_highlighting = do_not_show [**/{Startup,Program}.cs] resharper_event_exception_not_documented_highlighting=do_not_show resharper_exception_not_documented_highlighting=do_not_show resharper_exception_not_documented_optional_highlighting=do_not_show resharper_heap_view_object_allocation_evident_highlighting=do_not_show +resharper_missing_xml_doc_highlighting=do_not_show diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 000000000..eac5395d6 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,8 @@ +{ + // Use IntelliSense to find out which attributes exist for C# debugging + // Use hover for the description of the existing attributes + // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md + "version": "0.2.0", + "configurations": [ + ] +} \ No newline at end of file diff --git a/.vscode/solution-explorer/class.cs-template b/.vscode/solution-explorer/class.cs-template new file mode 100644 index 000000000..85ec1cd40 --- /dev/null +++ b/.vscode/solution-explorer/class.cs-template @@ -0,0 +1,11 @@ +namespace {{namespace}} +{ + using System; + + /// + /// {{name}} description. + /// + public class {{name}} + { + } +} diff --git a/.vscode/solution-explorer/class.ts-template b/.vscode/solution-explorer/class.ts-template new file mode 100644 index 000000000..ff2edefb8 --- /dev/null +++ b/.vscode/solution-explorer/class.ts-template @@ -0,0 +1,3 @@ +export class {{name}} { + +} \ No newline at end of file diff --git a/.vscode/solution-explorer/class.vb-template b/.vscode/solution-explorer/class.vb-template new file mode 100644 index 000000000..38ef67fe7 --- /dev/null +++ b/.vscode/solution-explorer/class.vb-template @@ -0,0 +1,9 @@ +Imports System + +Namespace {{namespace}} + + Public Class {{name}} + + End Class + +End Namespace diff --git a/.vscode/solution-explorer/default.ts-template b/.vscode/solution-explorer/default.ts-template new file mode 100644 index 000000000..04af87028 --- /dev/null +++ b/.vscode/solution-explorer/default.ts-template @@ -0,0 +1,3 @@ +export default {{name}} { + +} \ No newline at end of file diff --git a/.vscode/solution-explorer/enum.cs-template b/.vscode/solution-explorer/enum.cs-template new file mode 100644 index 000000000..ddadb7848 --- /dev/null +++ b/.vscode/solution-explorer/enum.cs-template @@ -0,0 +1,11 @@ +namespace {{namespace}} +{ + using System; + + /// + /// {{name}} description. + /// + public enum {{name}} + { + } +} diff --git a/.vscode/solution-explorer/interface.cs-template b/.vscode/solution-explorer/interface.cs-template new file mode 100644 index 000000000..80f99894d --- /dev/null +++ b/.vscode/solution-explorer/interface.cs-template @@ -0,0 +1,11 @@ +namespace {{namespace}} +{ + using System; + + /// + /// {{name}} description. + /// + public interface {{name}} + { + } +} diff --git a/.vscode/solution-explorer/interface.ts-template b/.vscode/solution-explorer/interface.ts-template new file mode 100644 index 000000000..3ea404b4f --- /dev/null +++ b/.vscode/solution-explorer/interface.ts-template @@ -0,0 +1,3 @@ +export interface {{name}} { + +} \ No newline at end of file diff --git a/.vscode/solution-explorer/template-list.json b/.vscode/solution-explorer/template-list.json new file mode 100644 index 000000000..284962284 --- /dev/null +++ b/.vscode/solution-explorer/template-list.json @@ -0,0 +1,46 @@ +{ + "templates": [ + { + "name": "Class", + "extension": "cs", + "file": "./class.cs-template", + "parameters": "./template-parameters.js" + }, + { + "name": "Interface", + "extension": "cs", + "file": "./interface.cs-template", + "parameters": "./template-parameters.js" + }, + { + "name": "Enum", + "extension": "cs", + "file": "./enum.cs-template", + "parameters": "./template-parameters.js" + }, + { + "name": "Class", + "extension": "ts", + "file": "./class.ts-template", + "parameters": "./template-parameters.js" + }, + { + "name": "Interface", + "extension": "ts", + "file": "./interface.ts-template", + "parameters": "./template-parameters.js" + }, + { + "name": "Default", + "extension": "ts", + "file": "./default.ts-template", + "parameters": "./template-parameters.js" + }, + { + "name": "Class", + "extension": "vb", + "file": "./class.vb-template", + "parameters": "./template-parameters.js" + } + ] +} \ No newline at end of file diff --git a/.vscode/solution-explorer/template-parameters.js b/.vscode/solution-explorer/template-parameters.js new file mode 100644 index 000000000..daba8b267 --- /dev/null +++ b/.vscode/solution-explorer/template-parameters.js @@ -0,0 +1,17 @@ +var path = require("path"); + +module.exports = function(filename, projectPath, folderPath) { + var namespace = "Unknown"; + if (projectPath) { + namespace = path.basename(projectPath, path.extname(projectPath)); + if (folderPath) { + namespace += "." + folderPath.replace(path.dirname(projectPath), "").substring(1).replace(/[\\\/]/g, "."); + } + namespace = namespace.replace(/[\\\-]/g, "_"); + } + + return { + namespace: namespace, + name: path.basename(filename, path.extname(filename)) + } +}; \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 5e3cc0490..d01dd2ca1 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -1,12 +1,31 @@ { - // See https://go.microsoft.com/fwlink/?LinkId=733558 - // for the documentation about the tasks.json format "version": "2.0.0", "tasks": [ { - "type": "cake", - "script": "RunUnitTests", - "problemMatcher": [] + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/Src/SharpArch.sln", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "test", + "command": "dotnet", + "type": "shell", + "group": "test", + "args": [ + "test", + "${workspaceFolder}/Src/SharpArch.sln" + ], + "presentation": { + "reveal": "silent" + }, + "problemMatcher": "$msCompile" } ] -} \ No newline at end of file +} diff --git a/Directory.Build.props b/Directory.Build.props index ab92713c9..99df64465 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -3,20 +3,20 @@ Sharp Architecture Sharp Architecture Dev Team - netstandard2.0;netstandard2.1 + netstandard2.0;netstandard2.1;net5 false false true true portable - 8.0 + 9.0 false - + - netcoreapp2.1;netcoreapp2.2;netcoreapp3.1 + netcoreapp2.1;netcoreapp2.2;netcoreapp3.1;net5 @@ -43,7 +43,8 @@ true true - $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb + true + snupkg diff --git a/Samples/TardisBank/Database/UnitTestGeneratedSchema.sql b/Samples/TardisBank/Database/UnitTestGeneratedSchema.sql index 667f8419e..09c1c8b15 100644 --- a/Samples/TardisBank/Database/UnitTestGeneratedSchema.sql +++ b/Samples/TardisBank/Database/UnitTestGeneratedSchema.sql @@ -62,29 +62,29 @@ alter table Parents drop constraint FK_Parents_Join_Users create table Messages ( MessageId INT not null, + UserId INT null, Date DATETIME2 null, Text NVARCHAR(255) null, HasBeenRead BIT null, - UserId INT null, primary key (MessageId) ) create table PaymentSchedules ( PaymentScheduleId INT not null, + AccountId INT null, NextRun DATETIME2 null, Interval NVARCHAR(255) null, Amount DECIMAL(19,5) null, Description NVARCHAR(255) null, - AccountId INT null, primary key (PaymentScheduleId) ) create table Transactions ( TransactionId INT not null, + AccountId INT null, Description NVARCHAR(255) null, Amount DECIMAL(19,5) null, Date DATETIME2 null, - AccountId INT null, primary key (TransactionId) ) @@ -99,8 +99,8 @@ alter table Parents drop constraint FK_Parents_Join_Users create table Children ( UserId INT not null, - ParentId INT null, AccountId INT null, + ParentId INT null, primary key (UserId) ) diff --git a/Samples/TardisBank/Src/Suteki.TardisBank.Api/Suteki.TardisBank.Api.csproj b/Samples/TardisBank/Src/Suteki.TardisBank.Api/Suteki.TardisBank.Api.csproj index f34997bc0..3a7f5eeb5 100644 --- a/Samples/TardisBank/Src/Suteki.TardisBank.Api/Suteki.TardisBank.Api.csproj +++ b/Samples/TardisBank/Src/Suteki.TardisBank.Api/Suteki.TardisBank.Api.csproj @@ -1,9 +1,20 @@ + + + + + + + + + + + + - + - diff --git a/Samples/TardisBank/Src/Suteki.TardisBank.Domain/Suteki.TardisBank.Domain.csproj b/Samples/TardisBank/Src/Suteki.TardisBank.Domain/Suteki.TardisBank.Domain.csproj index 46065f75e..eb369f047 100644 --- a/Samples/TardisBank/Src/Suteki.TardisBank.Domain/Suteki.TardisBank.Domain.csproj +++ b/Samples/TardisBank/Src/Suteki.TardisBank.Domain/Suteki.TardisBank.Domain.csproj @@ -1,8 +1,12 @@  + + $(AppTargetFrameworks) + + - - + + diff --git a/Samples/TardisBank/Src/Suteki.TardisBank.Infrastructure/Suteki.TardisBank.Infrastructure.csproj b/Samples/TardisBank/Src/Suteki.TardisBank.Infrastructure/Suteki.TardisBank.Infrastructure.csproj index bb84090bd..1e91fb1a9 100644 --- a/Samples/TardisBank/Src/Suteki.TardisBank.Infrastructure/Suteki.TardisBank.Infrastructure.csproj +++ b/Samples/TardisBank/Src/Suteki.TardisBank.Infrastructure/Suteki.TardisBank.Infrastructure.csproj @@ -1,12 +1,16 @@  + + $(AppTargetFrameworks) + + - - + + - - + + diff --git a/Samples/TardisBank/Src/Suteki.TardisBank.Tasks/Suteki.TardisBank.Tasks.csproj b/Samples/TardisBank/Src/Suteki.TardisBank.Tasks/Suteki.TardisBank.Tasks.csproj index d5f409e9e..a54f5cc11 100644 --- a/Samples/TardisBank/Src/Suteki.TardisBank.Tasks/Suteki.TardisBank.Tasks.csproj +++ b/Samples/TardisBank/Src/Suteki.TardisBank.Tasks/Suteki.TardisBank.Tasks.csproj @@ -1,10 +1,14 @@  + + $(AppTargetFrameworks) + + - - - + + + diff --git a/Samples/TardisBank/Src/Suteki.TardisBank.Tests/Functional/Setup/TestServerSetup.cs b/Samples/TardisBank/Src/Suteki.TardisBank.Tests/Functional/Setup/TestServerSetup.cs index ac42319ec..2f3c53b94 100644 --- a/Samples/TardisBank/Src/Suteki.TardisBank.Tests/Functional/Setup/TestServerSetup.cs +++ b/Samples/TardisBank/Src/Suteki.TardisBank.Tests/Functional/Setup/TestServerSetup.cs @@ -15,7 +15,7 @@ public class TestServerSetup : IDisposable public TestServerSetup() { Server = new TestServer(Program.CreateHostBuilder(Array.Empty()) -#if NETCOREAPP3_1 || NETCOREAPP3_0 +#if NETCOREAPP3_1 || NET5_0 .UseTestServer() #endif .UseStartup() diff --git a/Samples/TardisBank/Src/Suteki.TardisBank.Tests/Suteki.TardisBank.Tests.csproj b/Samples/TardisBank/Src/Suteki.TardisBank.Tests/Suteki.TardisBank.Tests.csproj index 065b6566d..b23d21ccd 100644 --- a/Samples/TardisBank/Src/Suteki.TardisBank.Tests/Suteki.TardisBank.Tests.csproj +++ b/Samples/TardisBank/Src/Suteki.TardisBank.Tests/Suteki.TardisBank.Tests.csproj @@ -4,16 +4,16 @@ - - + + - - + + - - + + - + all runtime; build; native; contentfiles; analyzers @@ -21,18 +21,22 @@ - + - + + + + + diff --git a/Samples/TardisBank/Src/Suteki.TardisBank.WebApi/Controllers/AnnouncementsController.cs b/Samples/TardisBank/Src/Suteki.TardisBank.WebApi/Controllers/AnnouncementsController.cs index 470958b2d..11b6d830d 100644 --- a/Samples/TardisBank/Src/Suteki.TardisBank.WebApi/Controllers/AnnouncementsController.cs +++ b/Samples/TardisBank/Src/Suteki.TardisBank.WebApi/Controllers/AnnouncementsController.cs @@ -23,23 +23,23 @@ public class AnnouncementsController : ControllerBase { readonly ILinqRepository _announcementRepository; -#if NETCOREAPP3_1 - readonly LinkGenerator _linkGenerator; +#if NETCOREAPP3_1 || NET5_0 + [NotNull] readonly LinkGenerator _linkGenerator; #endif - readonly IMapper _mapper; + [NotNull] readonly IMapper _mapper; /// /// Creates AnnouncementController. /// /// Announcements repository. public AnnouncementsController([NotNull] ILinqRepository announcementRepository, -#if NETCOREAPP3_1 +#if NETCOREAPP3_1 || NET5_0 LinkGenerator linkGenerator, #endif [NotNull] IMapper mapper) { _announcementRepository = announcementRepository ?? throw new ArgumentNullException(nameof(announcementRepository)); -#if NETCOREAPP3_1 +#if NETCOREAPP3_1 || NET5_0 _linkGenerator = linkGenerator ?? throw new ArgumentNullException(nameof(linkGenerator)); #endif _mapper = mapper ?? throw new ArgumentNullException(nameof(mapper)); @@ -78,7 +78,7 @@ public async Task Post(NewAnnouncement model) { var announcement = _mapper.Map(model); await _announcementRepository.SaveAsync(announcement, HttpContext.RequestAborted).ConfigureAwait(false); -#if NETCOREAPP3_1 +#if NETCOREAPP3_1 || NET5_0 var location = _linkGenerator.GetPathByName("GetAnnouncement", new {id = announcement.Id}); #else var location = Url.RouteUrl("GetAnnouncement", new {id = announcement.Id}); diff --git a/Samples/TardisBank/Src/Suteki.TardisBank.WebApi/Program.cs b/Samples/TardisBank/Src/Suteki.TardisBank.WebApi/Program.cs index 761b93e32..324c202dd 100644 --- a/Samples/TardisBank/Src/Suteki.TardisBank.WebApi/Program.cs +++ b/Samples/TardisBank/Src/Suteki.TardisBank.WebApi/Program.cs @@ -10,7 +10,7 @@ namespace Suteki.TardisBank.WebApi using Serilog.Exceptions; using Serilog.Formatting.Json; using Serilog.Sinks.SystemConsole.Themes; -#if NETCOREAPP3_1 +#if NETCOREAPP3_1 || NET5_0 using Microsoft.Extensions.Hosting; #endif diff --git a/Samples/TardisBank/Src/Suteki.TardisBank.WebApi/Startup.cs b/Samples/TardisBank/Src/Suteki.TardisBank.WebApi/Startup.cs index ef5394929..82d731f93 100644 --- a/Samples/TardisBank/Src/Suteki.TardisBank.WebApi/Startup.cs +++ b/Samples/TardisBank/Src/Suteki.TardisBank.WebApi/Startup.cs @@ -41,7 +41,7 @@ public Startup(IConfiguration configuration) /// public void ConfigureServices(IServiceCollection services) { -#if NETCOREAPP3_1 +#if NETCOREAPP3_1 || NET5_0 services.AddControllers(options => { options.Filters.Add(new AutoTransactionHandler()); }) .AddNewtonsoftJson(); @@ -87,7 +87,7 @@ public void ConfigureServices(IServiceCollection services) /// public void Configure(IApplicationBuilder app) { -#if NETCOREAPP3_1 +#if NETCOREAPP3_1 || NET5_0 app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); diff --git a/Samples/TardisBank/Src/Suteki.TardisBank.WebApi/Suteki.TardisBank.WebApi.csproj b/Samples/TardisBank/Src/Suteki.TardisBank.WebApi/Suteki.TardisBank.WebApi.csproj index 0e9fcfa35..ca88f8b1b 100644 --- a/Samples/TardisBank/Src/Suteki.TardisBank.WebApi/Suteki.TardisBank.WebApi.csproj +++ b/Samples/TardisBank/Src/Suteki.TardisBank.WebApi/Suteki.TardisBank.WebApi.csproj @@ -5,29 +5,36 @@ - - - - - - - + + + + + + - + + + - + + + + + + + diff --git a/Samples/TransactionAttribute/App/Controllers/GlobalController.cs b/Samples/TransactionAttribute/App/Controllers/GlobalController.cs index 2239ad190..4f99ddd0d 100644 --- a/Samples/TransactionAttribute/App/Controllers/GlobalController.cs +++ b/Samples/TransactionAttribute/App/Controllers/GlobalController.cs @@ -1,4 +1,4 @@ -namespace SharpArch.WebApi.Sample.Controllers +namespace TransactionAttribute.WebApi.Controllers { using Microsoft.AspNetCore.Mvc; using Serilog; diff --git a/Samples/TransactionAttribute/App/Controllers/OverridesController.cs b/Samples/TransactionAttribute/App/Controllers/OverridesController.cs index 42ca961d7..e0b210989 100644 --- a/Samples/TransactionAttribute/App/Controllers/OverridesController.cs +++ b/Samples/TransactionAttribute/App/Controllers/OverridesController.cs @@ -1,11 +1,11 @@ -namespace SharpArch.WebApi.Sample.Controllers +namespace TransactionAttribute.WebApi.Controllers { using System; using System.Data; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using Serilog; - using Web.AspNetCore.Transaction; + using SharpArch.Web.AspNetCore.Transaction; [Route("api/[controller]")] diff --git a/Samples/TransactionAttribute/App/Program.cs b/Samples/TransactionAttribute/App/Program.cs index 83e983e6b..a6be726f6 100644 --- a/Samples/TransactionAttribute/App/Program.cs +++ b/Samples/TransactionAttribute/App/Program.cs @@ -1,16 +1,16 @@ -namespace SharpArch.WebApi.Sample +namespace TransactionAttribute.WebApi { -#if NETCOREAPP3_1 +#if NETCOREAPP3_1 || NET5_0 using Microsoft.Extensions.Hosting; using Microsoft.AspNetCore.Hosting; #else using Microsoft.AspNetCore.Hosting; #endif - using System; using System.IO; using Autofac.Extensions.DependencyInjection; + using JetBrains.Annotations; using Microsoft.Extensions.Configuration; using Serilog; using Serilog.Events; @@ -19,9 +19,10 @@ using Serilog.Sinks.SystemConsole.Themes; #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member + [UsedImplicitly] public class Program { - public static int Main(string[] args) + public static int Main([NotNull] string[] args) { try { @@ -41,6 +42,7 @@ public static int Main(string[] args) } } + [NotNull] public static IWebHostBuilder CreateHostBuilder() { return new WebHostBuilder() diff --git a/Samples/TransactionAttribute/App/Startup.cs b/Samples/TransactionAttribute/App/Startup.cs index 6d9d11a8c..1d69eb0fc 100644 --- a/Samples/TransactionAttribute/App/Startup.cs +++ b/Samples/TransactionAttribute/App/Startup.cs @@ -1,18 +1,18 @@ -namespace SharpArch.WebApi.Sample +namespace TransactionAttribute.WebApi { using System.Data; using Autofac; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; + using Microsoft.Extensions.Configuration; + using Microsoft.Extensions.DependencyInjection; + using SharpArch.Web.AspNetCore.Transaction; + using Stubs; #if NETCOREAPP2_1 || NETCOREAPP2_2 using System.Globalization; using Microsoft.AspNetCore.Mvc; using Newtonsoft.Json; #endif - using Microsoft.Extensions.Configuration; - using Microsoft.Extensions.DependencyInjection; - using Stubs; - using Web.AspNetCore.Transaction; public class Startup @@ -30,13 +30,13 @@ public Startup(IConfiguration configuration) /// public void ConfigureServices(IServiceCollection services) { -#if NETCOREAPP3_1 +#if NETCOREAPP3_1 || NET5_0 services.AddControllers(options => { options.Filters.Add(new AutoTransactionHandler()); options.Filters.Add(new TransactionAttribute(isolationLevel: IsolationLevel.Chaos)); }) - .AddNewtonsoftJson(); + ; #else // Add framework services. @@ -71,7 +71,7 @@ public void ConfigureServices(IServiceCollection services) /// public void Configure(IApplicationBuilder app) { -#if NETCOREAPP3_1 +#if NETCOREAPP3_1 || NET5_0 app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => diff --git a/Samples/TransactionAttribute/App/Stubs/TransactionManagerStub.cs b/Samples/TransactionAttribute/App/Stubs/TransactionManagerStub.cs index c020956fe..776809c35 100644 --- a/Samples/TransactionAttribute/App/Stubs/TransactionManagerStub.cs +++ b/Samples/TransactionAttribute/App/Stubs/TransactionManagerStub.cs @@ -1,13 +1,13 @@ -namespace SharpArch.WebApi.Sample.Stubs +namespace TransactionAttribute.WebApi.Stubs { using System; using System.Data; using System.Threading; using System.Threading.Tasks; - using Domain.PersistenceSupport; using JetBrains.Annotations; using Microsoft.AspNetCore.Http; using Serilog; + using SharpArch.Domain.PersistenceSupport; public class TransactionManagerStub : ITransactionManager, IDisposable, ISupportsTransactionStatus diff --git a/Samples/TransactionAttribute/App/TransactionAttribute.WebApi.csproj b/Samples/TransactionAttribute/App/TransactionAttribute.WebApi.csproj index 30f554c84..9dea86139 100644 --- a/Samples/TransactionAttribute/App/TransactionAttribute.WebApi.csproj +++ b/Samples/TransactionAttribute/App/TransactionAttribute.WebApi.csproj @@ -5,11 +5,11 @@ - - - - - + + + + + @@ -22,10 +22,6 @@ - - - - diff --git a/Samples/TransactionAttribute/Tests/Setup/TestServerSetup.cs b/Samples/TransactionAttribute/Tests/Setup/TestServerSetup.cs index ad488befe..45c97d54d 100644 --- a/Samples/TransactionAttribute/Tests/Setup/TestServerSetup.cs +++ b/Samples/TransactionAttribute/Tests/Setup/TestServerSetup.cs @@ -1,10 +1,10 @@ -namespace SharpArch.WebApi.Tests.Setup +namespace TransactionAttribute.Tests.Setup { using System; using System.Net.Http; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.TestHost; - using Sample; + using WebApi; public class TestServerSetup : IDisposable diff --git a/Samples/TransactionAttribute/Tests/TransactionAttribute.Tests.csproj b/Samples/TransactionAttribute/Tests/TransactionAttribute.Tests.csproj index a308d6764..a86e8d86b 100644 --- a/Samples/TransactionAttribute/Tests/TransactionAttribute.Tests.csproj +++ b/Samples/TransactionAttribute/Tests/TransactionAttribute.Tests.csproj @@ -7,11 +7,11 @@ - - - + + + - + all runtime; build; native; contentfiles; analyzers @@ -32,6 +32,10 @@ + + + + diff --git a/Samples/TransactionAttribute/Tests/UnitOfWorkAttributeOverrideTests.cs b/Samples/TransactionAttribute/Tests/UnitOfWorkAttributeOverrideTests.cs index 9974c7732..48a79fe98 100644 --- a/Samples/TransactionAttribute/Tests/UnitOfWorkAttributeOverrideTests.cs +++ b/Samples/TransactionAttribute/Tests/UnitOfWorkAttributeOverrideTests.cs @@ -1,21 +1,20 @@ -using System; -using System.Data; -using System.Net; -using System.Net.Http; -using System.Threading.Tasks; -using FluentAssertions; -using JetBrains.Annotations; -using SharpArch.WebApi.Tests.Setup; -using Xunit; - -namespace SharpArch.WebApi.Tests +namespace TransactionAttribute.Tests { - using Sample.Stubs; + using System; + using System.Data; + using System.Net; + using System.Net.Http; + using System.Threading.Tasks; + using FluentAssertions; + using JetBrains.Annotations; + using Setup; + using WebApi.Stubs; + using Xunit; public class UnitOfWorkAttributeOverrideTests : IClassFixture { - private readonly TestServerSetup _setup; + readonly TestServerSetup _setup; public UnitOfWorkAttributeOverrideTests([NotNull] TestServerSetup setup) { @@ -43,7 +42,7 @@ public async Task CanUseLocalOverride(string method, HttpStatusCode statusCode, } } - private Task GetAsync(string relativePath) + Task GetAsync(string relativePath) { return _setup.Client.GetAsync(new Uri(_setup.Client.BaseAddress, relativePath)); } diff --git a/SharpArch.AutoLoad.DotSettings b/SharpArch.AutoLoad.DotSettings index 39b50736a..d6f4e079b 100644 --- a/SharpArch.AutoLoad.DotSettings +++ b/SharpArch.AutoLoad.DotSettings @@ -422,6 +422,7 @@ FluentAssertions.AssertionExtensions.Should($EXPR$).NotBeNull() False ALWAYS True + True True True diff --git a/SharpArchitecture.code-workspace b/SharpArchitecture.code-workspace new file mode 100644 index 000000000..362d7c25b --- /dev/null +++ b/SharpArchitecture.code-workspace @@ -0,0 +1,7 @@ +{ + "folders": [ + { + "path": "." + } + ] +} \ No newline at end of file diff --git a/Src/SharpArch.Domain/PersistenceSupport/ISupportsTransactionStatus.cs b/Src/SharpArch.Domain/PersistenceSupport/ISupportsTransactionStatus.cs index e8de21edc..d8190fce9 100644 --- a/Src/SharpArch.Domain/PersistenceSupport/ISupportsTransactionStatus.cs +++ b/Src/SharpArch.Domain/PersistenceSupport/ISupportsTransactionStatus.cs @@ -1,4 +1,4 @@ -namespace SharpArch.Domain.PersistenceSupport +namespace SharpArch.Domain.PersistenceSupport { using JetBrains.Annotations; diff --git a/Src/SharpArch.Domain/SharpArch.Domain.csproj b/Src/SharpArch.Domain/SharpArch.Domain.csproj index b60cd6538..0b065920a 100644 --- a/Src/SharpArch.Domain/SharpArch.Domain.csproj +++ b/Src/SharpArch.Domain/SharpArch.Domain.csproj @@ -15,11 +15,22 @@ + + + + + + + + + + + + - + - diff --git a/Src/SharpArch.Infrastructure/Caching/DependencyList.cs b/Src/SharpArch.Infrastructure/Caching/DependencyList.cs index 2d12ccc97..645e4d92d 100644 --- a/Src/SharpArch.Infrastructure/Caching/DependencyList.cs +++ b/Src/SharpArch.Infrastructure/Caching/DependencyList.cs @@ -126,7 +126,11 @@ private string GetCodeBasePath() public static string GetAssemblyCodeBasePath([NotNull] Assembly assembly) { if (assembly == null) throw new ArgumentNullException(nameof(assembly)); +#if NET5_0 + var uri = new UriBuilder(assembly.Location); +#else var uri = new UriBuilder(assembly.CodeBase); +#endif var uriPath = Uri.UnescapeDataString(uri.Path); return Path.GetDirectoryName(uriPath); } diff --git a/Src/SharpArch.Infrastructure/SharpArch.Infrastructure.csproj b/Src/SharpArch.Infrastructure/SharpArch.Infrastructure.csproj index 9ce0c0150..d83e240c2 100644 --- a/Src/SharpArch.Infrastructure/SharpArch.Infrastructure.csproj +++ b/Src/SharpArch.Infrastructure/SharpArch.Infrastructure.csproj @@ -24,7 +24,7 @@ - + runtime; build; native; contentfiles; analyzers all diff --git a/Src/SharpArch.NHibernate.DependencyInjection/SharpArch.NHibernate.Extensions.DependencyInjection.csproj b/Src/SharpArch.NHibernate.DependencyInjection/SharpArch.NHibernate.Extensions.DependencyInjection.csproj index 6de40c5d3..40d12dc75 100644 --- a/Src/SharpArch.NHibernate.DependencyInjection/SharpArch.NHibernate.Extensions.DependencyInjection.csproj +++ b/Src/SharpArch.NHibernate.DependencyInjection/SharpArch.NHibernate.Extensions.DependencyInjection.csproj @@ -16,7 +16,7 @@ - + @@ -28,6 +28,10 @@ + + + + diff --git a/Src/SharpArch.NHibernate/SharpArch.NHibernate.csproj b/Src/SharpArch.NHibernate/SharpArch.NHibernate.csproj index 84a3afbc8..9f3eb1bb6 100644 --- a/Src/SharpArch.NHibernate/SharpArch.NHibernate.csproj +++ b/Src/SharpArch.NHibernate/SharpArch.NHibernate.csproj @@ -16,10 +16,10 @@ - - + + - + diff --git a/Src/SharpArch.NHibernate/TransactionManager.cs b/Src/SharpArch.NHibernate/TransactionManager.cs index ad0b17524..dcd9098c5 100644 --- a/Src/SharpArch.NHibernate/TransactionManager.cs +++ b/Src/SharpArch.NHibernate/TransactionManager.cs @@ -15,6 +15,8 @@ [PublicAPI] public class TransactionManager : INHibernateTransactionManager, ISupportsTransactionStatus { + private static readonly string NoTransactionAvailable = "No transaction is currently active."; + /// /// Creates instance of transaction manager. /// @@ -27,13 +29,19 @@ public TransactionManager([NotNull] ISession session) /// public ISession Session { get; } + /// + /// Returns current transaction or null if no transaction was open. + /// + protected ITransaction GetTransaction() + => Session.GetCurrentTransaction(); + /// public Task CommitTransactionAsync(CancellationToken cancellationToken) - => Session.Transaction.CommitAsync(cancellationToken); + => GetTransaction()?.CommitAsync(cancellationToken) ?? throw new InvalidOperationException(NoTransactionAvailable); /// public Task RollbackTransactionAsync(CancellationToken cancellationToken) - => Session.Transaction.RollbackAsync(cancellationToken); + => GetTransaction()?.RollbackAsync(cancellationToken) ?? throw new InvalidOperationException(NoTransactionAvailable); /// public IDisposable BeginTransaction(IsolationLevel isolationLevel) @@ -44,6 +52,6 @@ public Task FlushChangesAsync(CancellationToken cancellationToken) => Session.FlushAsync(cancellationToken); /// - public bool IsActive => Session.Transaction.IsActive; + public bool IsActive => GetTransaction()?.IsActive ?? false; } } diff --git a/Src/SharpArch.RavenDb/SharpArch.RavenDb.csproj b/Src/SharpArch.RavenDb/SharpArch.RavenDb.csproj index 02d98d413..82fe5ca3d 100644 --- a/Src/SharpArch.RavenDb/SharpArch.RavenDb.csproj +++ b/Src/SharpArch.RavenDb/SharpArch.RavenDb.csproj @@ -16,9 +16,9 @@ - + - + diff --git a/Src/SharpArch.Testing.NUnit/NHibernate/DatabaseRepositoryTestsBase.cs b/Src/SharpArch.Testing.NUnit/NHibernate/DatabaseRepositoryTestsBase.cs index e698e0d71..c3f14ff4a 100644 --- a/Src/SharpArch.Testing.NUnit/NHibernate/DatabaseRepositoryTestsBase.cs +++ b/Src/SharpArch.Testing.NUnit/NHibernate/DatabaseRepositoryTestsBase.cs @@ -100,7 +100,9 @@ public virtual void TearDown() { if (Session != null) { - if (Session.Transaction.IsActive) Session.Transaction.Rollback(); + var currentTransaction = Session.GetCurrentTransaction(); + if (currentTransaction != null && currentTransaction.IsActive) + currentTransaction.Rollback(); Session.Dispose(); Session = null; } diff --git a/Src/SharpArch.Testing.NUnit/SharpArch.Testing.NUnit.csproj b/Src/SharpArch.Testing.NUnit/SharpArch.Testing.NUnit.csproj index 6f3744a63..d5dd2f81b 100644 --- a/Src/SharpArch.Testing.NUnit/SharpArch.Testing.NUnit.csproj +++ b/Src/SharpArch.Testing.NUnit/SharpArch.Testing.NUnit.csproj @@ -18,7 +18,7 @@ - + diff --git a/Src/SharpArch.Testing.Xunit.NHibernate/LiveDatabaseTests.cs b/Src/SharpArch.Testing.Xunit.NHibernate/LiveDatabaseTests.cs index b75793d19..831d030d1 100644 --- a/Src/SharpArch.Testing.Xunit.NHibernate/LiveDatabaseTests.cs +++ b/Src/SharpArch.Testing.Xunit.NHibernate/LiveDatabaseTests.cs @@ -50,8 +50,9 @@ protected LiveDatabaseTests([NotNull] TDatabaseSetup setup) public virtual void Dispose() { if (Session != null) { - if (Session.Transaction.IsActive) - Session.Transaction.Rollback(); + var currentTransaction = Session.GetCurrentTransaction(); + if (currentTransaction != null && currentTransaction.IsActive) + currentTransaction.Rollback(); Session.Dispose(); Session = null; } diff --git a/Src/SharpArch.Testing.Xunit.NHibernate/SharpArch.Testing.Xunit.NHibernate.csproj b/Src/SharpArch.Testing.Xunit.NHibernate/SharpArch.Testing.Xunit.NHibernate.csproj index ce710ea6c..c86f850d6 100644 --- a/Src/SharpArch.Testing.Xunit.NHibernate/SharpArch.Testing.Xunit.NHibernate.csproj +++ b/Src/SharpArch.Testing.Xunit.NHibernate/SharpArch.Testing.Xunit.NHibernate.csproj @@ -18,7 +18,7 @@ - + diff --git a/Src/SharpArch.Testing.Xunit/SharpArch.Testing.Xunit.csproj b/Src/SharpArch.Testing.Xunit/SharpArch.Testing.Xunit.csproj index 0d1d7aca1..f947da98d 100644 --- a/Src/SharpArch.Testing.Xunit/SharpArch.Testing.Xunit.csproj +++ b/Src/SharpArch.Testing.Xunit/SharpArch.Testing.Xunit.csproj @@ -16,7 +16,7 @@ - + diff --git a/Src/SharpArch.Testing/SharpArch.Testing.csproj b/Src/SharpArch.Testing/SharpArch.Testing.csproj index d9d81ced1..bc11f0468 100644 --- a/Src/SharpArch.Testing/SharpArch.Testing.csproj +++ b/Src/SharpArch.Testing/SharpArch.Testing.csproj @@ -16,7 +16,7 @@ - + diff --git a/Src/SharpArch.Web.AspNetCore/SharpArch.Web.AspNetCore.csproj b/Src/SharpArch.Web.AspNetCore/SharpArch.Web.AspNetCore.csproj index 187f32f1c..5067d1cb0 100644 --- a/Src/SharpArch.Web.AspNetCore/SharpArch.Web.AspNetCore.csproj +++ b/Src/SharpArch.Web.AspNetCore/SharpArch.Web.AspNetCore.csproj @@ -21,20 +21,20 @@ - + - + - + @@ -42,6 +42,10 @@ + + + + diff --git a/Src/Tests/SharpArch.Tests.NHibernate/SharpArch.Tests.NHibernate.csproj b/Src/Tests/SharpArch.Tests.NHibernate/SharpArch.Tests.NHibernate.csproj index 553885027..513bc71cb 100644 --- a/Src/Tests/SharpArch.Tests.NHibernate/SharpArch.Tests.NHibernate.csproj +++ b/Src/Tests/SharpArch.Tests.NHibernate/SharpArch.Tests.NHibernate.csproj @@ -11,12 +11,12 @@ - - - + + + - - + + diff --git a/Src/Tests/SharpArch.XunitTests.NHibernate/SharpArch.XunitTests.NHibernate.csproj b/Src/Tests/SharpArch.XunitTests.NHibernate/SharpArch.XunitTests.NHibernate.csproj index 3d3a52fab..797145346 100644 --- a/Src/Tests/SharpArch.XunitTests.NHibernate/SharpArch.XunitTests.NHibernate.csproj +++ b/Src/Tests/SharpArch.XunitTests.NHibernate/SharpArch.XunitTests.NHibernate.csproj @@ -7,14 +7,14 @@ - - - - - - + + + + + + - + all runtime; build; native; contentfiles; analyzers diff --git a/Src/Tests/SharpArch.XunitTests/SharpArch.XunitTests.csproj b/Src/Tests/SharpArch.XunitTests/SharpArch.XunitTests.csproj index 8a819564c..10998b8fb 100644 --- a/Src/Tests/SharpArch.XunitTests/SharpArch.XunitTests.csproj +++ b/Src/Tests/SharpArch.XunitTests/SharpArch.XunitTests.csproj @@ -8,11 +8,11 @@ - - - + + + - + all runtime; build; native; contentfiles; analyzers diff --git a/VersionHistory.txt b/VersionHistory.txt index ae0033d25..f8816fccb 100644 --- a/VersionHistory.txt +++ b/VersionHistory.txt @@ -1,3 +1,14 @@ +======================== +S#arp 6.1 +======================== +NEW FEATURES: +* .NET 5 support. + +IMPROVEMENTS: +* Debug information now published as a symbol package to reduce build time and space used. +* Use tokens instead of credentials in build script. + + ======================== S#arp 6.0 ======================== @@ -16,6 +27,10 @@ NEW FEATURES: IMPROVEMENTS: * More control over NHibernate configuration. +NEW FEATURES: +* SharpArch.NHibernate.DependencyInjection package; +* ASP.NET 3 / NetStandard2.1 support; + ======================== S#arp 5.0 diff --git a/appveyor.yml b/appveyor.yml index 990f6b0a6..3641c5933 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -23,10 +23,8 @@ environment: CAKE_SETTINGS_SKIPPACKAGEVERSIONCHECK: true DOTNET_CLI_TELEMETRY_OPTOUT: true DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true - GITHUB_USER: - secure: Qxe33R53rrB5/Rc2Vf9oRkSaB9h0XL1ugKwrqJo2eSU= - GITHUB_PASSWORD: - secure: pHWfnPX0taxUzXTHaLImDJpVrG0tc4mv0xX59KZ7ct8= + GITHUB_TOKEN: + secure: FgP/dEF7lumDgbjt3tzPSDqDTM16uoiPfKZPQSLJO+/GaIR2zSquSh0pXP8znx+c cache: # - c:\work\sharp-arch\tmp\ResharperCaches @@ -43,8 +41,12 @@ build_script: test: off artifacts: - - path: Drops/Packages/*.*nupkg - name: Nugets + - path: Drops/Packages/*.nupkg + name: NuGet packages + + - path: Drops/Packages/*.snupkg + name: NuGet symbol packages + type: NuGetPackage # - path: Drops/Inspections/CodeDuplicates.html # name: CodeDuplicates # - path: Drops/Inspections/CodeInspections.html @@ -54,7 +56,7 @@ deploy: - provider: NuGet name: Pre-release api_key: - secure: F8fjiNU1lblIU8Jjw5Mt0TDr9zpZW7p/zi/COlHaFqZdPGkrui0Sshq5MMMHc9uU + secure: kvGBJqOLM4uyxv3IVpAC9ZjMSPaL0bnvAXJeK0t1TbL3wpBa7raxKLETd4px1/LY on: branch: - develop @@ -65,6 +67,6 @@ deploy: - provider: NuGet name: Tagged release api_key: - secure: F8fjiNU1lblIU8Jjw5Mt0TDr9zpZW7p/zi/COlHaFqZdPGkrui0Sshq5MMMHc9uU + secure: kvGBJqOLM4uyxv3IVpAC9ZjMSPaL0bnvAXJeK0t1TbL3wpBa7raxKLETd4px1/LY on: appveyor_repo_tag: true diff --git a/build.cake b/build.cake index ed401b8eb..d37241ec0 100644 --- a/build.cake +++ b/build.cake @@ -1,17 +1,17 @@ // ADDINS -#addin nuget:?package=Cake.Coveralls&version=0.10.0 -#addin nuget:?package=Cake.FileHelpers&version=3.2.1 +#addin nuget:?package=Cake.Coveralls&version=0.10.2 +#addin nuget:?package=Cake.FileHelpers&version=3.3.0 #addin nuget:?package=Cake.Incubator&version=5.1.0 -#addin nuget:?package=Cake.Issues&version=0.7.1 +#addin nuget:?package=Cake.Issues&version=0.9.1 #addin nuget:?package=Cake.AppVeyor&version=4.0.0 #addin nuget:?package=Cake.ReSharperReports&version=0.11.1 // TOOLS -#tool nuget:?package=GitReleaseManager&version=0.8.0 -#tool nuget:?package=GitVersion.CommandLine&version=5.0.1 +#tool nuget:?package=GitReleaseManager&version=0.11.0 +#tool nuget:?package=GitVersion.CommandLine&version=5.5.1 #tool nuget:?package=coveralls.io&version=1.4.2 #tool nuget:?package=OpenCover&version=4.7.922 -#tool nuget:?package=ReportGenerator&version=4.2.17 +#tool nuget:?package=ReportGenerator&version=4.8.1 //#tool nuget:?package=JetBrains.ReSharper.CommandLineTools&version=2018.3.4 // ARGUMENTS @@ -72,18 +72,7 @@ var solutionFile = srcDir + "/SharpArch.sln"; var samplesDir = "./Samples"; var coverageFilter="+[SharpArch*]* -[SharpArch.Tests*]* -[SharpArch.Xunit*]* -[SharpArch.Infrastructure]SharpArch.Infrastructure.Logging.*"; -Credentials githubCredentials = null; - -public class Credentials { - public string UserName { get; set; } - public string Password { get; set; } - - public Credentials(string userName, string password) { - UserName = userName; - Password = password; - } -} - +string githubToken = null; // SETUP / TEARDOWN @@ -92,10 +81,7 @@ Setup((context) => Information("Building version {0} (tagged: {1}, local: {2}, release branch: {3})...", nugetVersion, isTagged, local, isReleaseBranch); CreateDirectory(artifactsDir); CleanDirectory(artifactsDir); - githubCredentials = new Credentials( - context.EnvironmentVariable("GITHUB_USER"), - context.EnvironmentVariable("GITHUB_PASSWORD") - ); + githubToken = context.EnvironmentVariable("GITHUB_TOKEN"); }); Teardown((context) => @@ -169,7 +155,7 @@ Task("InspectCode") Task("RunXunitTests") - .DoesForEach(GetFiles(solutionFile).Union(GetFiles($"{samplesDir}/**/*.sln")), + .DoesForEach(GetFiles(solutionFile).Union(GetFiles($"{samplesDir}/**/*.sln")), (testProj) => { var projectPath = testProj.GetDirectory(); var projectFilename = testProj.GetFilenameWithoutExtension(); @@ -260,7 +246,7 @@ Task("Build") .IsDependentOn("SetVersion") .IsDependentOn("UpdateAppVeyorBuildNumber") .IsDependentOn("Restore") - .DoesForEach(GetFiles($"{srcDir}/**/*.sln").Union(GetFiles($"{samplesDir}/**/*.sln")), + .DoesForEach(GetFiles($"{srcDir}/**/*.sln").Union(GetFiles($"{samplesDir}/**/*.sln")), (solutionFile) => { var slnPath = solutionFile.GetDirectory().FullPath; var sln = solutionFile.GetFilenameWithoutExtension(); @@ -313,7 +299,7 @@ Task("CreateNugetPackages") Task("CreateRelease") .WithCriteria(() => isRepository && isReleaseBranch && !isPullRequest) .Does(() => { - GitReleaseManagerCreate(githubCredentials.UserName, githubCredentials.Password, repoOwner, repoName, + GitReleaseManagerCreate(githubToken, repoOwner, repoName, new GitReleaseManagerCreateSettings { Milestone = milestone, TargetCommitish = "master" @@ -324,7 +310,7 @@ Task("CreateRelease") Task("CloseMilestone") .WithCriteria(() => isRepository && isTagged && !isPullRequest) .Does(() => { - GitReleaseManagerClose(githubCredentials.UserName, githubCredentials.Password, repoOwner, repoName, milestone); + GitReleaseManagerClose(githubToken, repoOwner, repoName, milestone); });