diff --git a/.editorconfig b/.editorconfig index ccb1111..d547bcd 100644 --- a/.editorconfig +++ b/.editorconfig @@ -107,12 +107,12 @@ dotnet_style_prefer_conditional_expression_over_return = true:refactoring csharp_prefer_simple_default_expression = true:suggestion # Expression-bodied members -csharp_style_expression_bodied_methods = true:refactoring -csharp_style_expression_bodied_constructors = true:refactoring -csharp_style_expression_bodied_operators = true:refactoring -csharp_style_expression_bodied_properties = true:refactoring -csharp_style_expression_bodied_indexers = true:refactoring -csharp_style_expression_bodied_accessors = true:refactoring +csharp_style_expression_bodied_methods = true:suggestion +csharp_style_expression_bodied_constructors = true:suggestion +csharp_style_expression_bodied_operators = true:suggestion +csharp_style_expression_bodied_properties = true:suggestion +csharp_style_expression_bodied_indexers = true:suggestion +csharp_style_expression_bodied_accessors = true:suggestion csharp_style_expression_bodied_lambdas = true:refactoring csharp_style_expression_bodied_local_functions = true:refactoring diff --git a/.gitignore b/.gitignore index cb43218..058a2d9 100644 --- a/.gitignore +++ b/.gitignore @@ -31,6 +31,9 @@ bld/ [Ll]og/ [Ll]ogs/ +# Visual Studio Code cache/options directory +.vscode/ + # Visual Studio 2015/2017 cache/options directory .vs/ # Uncomment if you have tasks that create the project's static files in wwwroot diff --git a/CustomDictionary.xml b/CustomDictionary.xml deleted file mode 100644 index 83530a4..0000000 --- a/CustomDictionary.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - Api - Asc - Desc - Lite - - - - - - - - - - - - - - Db - - - \ No newline at end of file diff --git a/MicroLite.Extensions.WebApi.Tests/AutoManageTransactionAttributeTests.cs b/MicroLite.Extensions.WebApi.Tests/AutoManageTransactionAttributeTests.cs index 840e7cc..37e7512 100644 --- a/MicroLite.Extensions.WebApi.Tests/AutoManageTransactionAttributeTests.cs +++ b/MicroLite.Extensions.WebApi.Tests/AutoManageTransactionAttributeTests.cs @@ -14,7 +14,7 @@ public class AutoManageTransactionAttributeTests { public class WhenCallingOnActionExecuted_WithAMicroLiteApiController_AndAnActiveTransaction { - private readonly Mock _mockSession = new Mock(); + private readonly Mock _mockSession = new Mock(); private readonly Mock _mockTransaction = new Mock(); public WhenCallingOnActionExecuted_WithAMicroLiteApiController_AndAnActiveTransaction() @@ -60,7 +60,7 @@ public void TheTransactionIsNotRolledBack() public class WhenCallingOnActionExecuted_WithAMicroLiteApiController_AndAutoManageTransactionIsFalse { - private readonly Mock _mockSession = new Mock(); + private readonly Mock _mockSession = new Mock(); private readonly Mock _mockTransaction = new Mock(); public WhenCallingOnActionExecuted_WithAMicroLiteApiController_AndAutoManageTransactionIsFalse() @@ -109,7 +109,7 @@ public void TheTransactionIsNotRolledBack() public class WhenCallingOnActionExecuted_WithAMicroLiteApiController_AndCommittingAnActiveTransactionThrowsAnException { - private readonly Mock _mockSession = new Mock(); + private readonly Mock _mockSession = new Mock(); private readonly Mock _mockTransaction = new Mock(); public WhenCallingOnActionExecuted_WithAMicroLiteApiController_AndCommittingAnActiveTransactionThrowsAnException() @@ -157,7 +157,7 @@ public void TheTransactionIsNotRolledBack() public class WhenCallingOnActionExecuted_WithAMicroLiteApiController_AndNoActiveTransaction { - private readonly Mock _mockSession = new Mock(); + private readonly Mock _mockSession = new Mock(); private readonly Mock _mockTransaction = new Mock(); public WhenCallingOnActionExecuted_WithAMicroLiteApiController_AndNoActiveTransaction() @@ -203,7 +203,7 @@ public void TheTransactionIsNotRolledBack() public class WhenCallingOnActionExecuted_WithAMicroLiteApiController_AndNoCurrentTransaction { - private readonly Mock _mockSession = new Mock(); + private readonly Mock _mockSession = new Mock(); [Fact] public void OnActionExecutedDoesNotThrowAnException() @@ -228,7 +228,7 @@ public void OnActionExecutedDoesNotThrowAnException() public class WhenCallingOnActionExecuted_WithAMicroLiteApiController_AndTheContextContainsAnException_AndTheTransactionHasBeenRolledBack { - private readonly Mock _mockSession = new Mock(); + private readonly Mock _mockSession = new Mock(); private readonly Mock _mockTransaction = new Mock(); public WhenCallingOnActionExecuted_WithAMicroLiteApiController_AndTheContextContainsAnException_AndTheTransactionHasBeenRolledBack() @@ -275,7 +275,7 @@ public void TheTransactionIsNotRolledBackAgain() public class WhenCallingOnActionExecuted_WithAMicroLiteApiController_AndTheContextContainsAnException_AndTheTransactionHasNotBeenRolledBack { - private readonly Mock _mockSession = new Mock(); + private readonly Mock _mockSession = new Mock(); private readonly Mock _mockTransaction = new Mock(); public WhenCallingOnActionExecuted_WithAMicroLiteApiController_AndTheContextContainsAnException_AndTheTransactionHasNotBeenRolledBack() @@ -322,7 +322,7 @@ public void TheTransactionIsRolledBack() public class WhenCallingOnActionExecuted_WithAMicroLiteReadOnlyApiController_AndAnActiveTransaction { - private readonly Mock _mockSession = new Mock(); + private readonly Mock _mockSession = new Mock(); private readonly Mock _mockTransaction = new Mock(); public WhenCallingOnActionExecuted_WithAMicroLiteReadOnlyApiController_AndAnActiveTransaction() @@ -368,7 +368,7 @@ public void TheTransactionIsNotRolledBack() public class WhenCallingOnActionExecuted_WithAMicroLiteReadOnlyApiController_AndAutoManageTransactionIsFalse { - private readonly Mock _mockSession = new Mock(); + private readonly Mock _mockSession = new Mock(); private readonly Mock _mockTransaction = new Mock(); public WhenCallingOnActionExecuted_WithAMicroLiteReadOnlyApiController_AndAutoManageTransactionIsFalse() @@ -417,7 +417,7 @@ public void TheTransactionIsNotRolledBack() public class WhenCallingOnActionExecuted_WithAMicroLiteReadOnlyApiController_AndCommittingAnActiveTransactionThrowsAnException { - private readonly Mock _mockSession = new Mock(); + private readonly Mock _mockSession = new Mock(); private readonly Mock _mockTransaction = new Mock(); public WhenCallingOnActionExecuted_WithAMicroLiteReadOnlyApiController_AndCommittingAnActiveTransactionThrowsAnException() @@ -465,7 +465,7 @@ public void TheTransactionIsNotRolledBack() public class WhenCallingOnActionExecuted_WithAMicroLiteReadOnlyApiController_AndNoActiveTransaction { - private readonly Mock _mockSession = new Mock(); + private readonly Mock _mockSession = new Mock(); private readonly Mock _mockTransaction = new Mock(); public WhenCallingOnActionExecuted_WithAMicroLiteReadOnlyApiController_AndNoActiveTransaction() @@ -511,7 +511,7 @@ public void TheTransactionIsNotRolledBack() public class WhenCallingOnActionExecuted_WithAMicroLiteReadOnlyApiController_AndNoCurrentTransaction { - private readonly Mock _mockSession = new Mock(); + private readonly Mock _mockSession = new Mock(); [Fact] public void OnActionExecutedDoesNotThrowAnException() @@ -536,7 +536,7 @@ public void OnActionExecutedDoesNotThrowAnException() public class WhenCallingOnActionExecuted_WithAMicroLiteReadOnlyApiController_AndTheContextContainsAnException_AndTheTransactionHasBeenRolledBack { - private readonly Mock _mockSession = new Mock(); + private readonly Mock _mockSession = new Mock(); private readonly Mock _mockTransaction = new Mock(); public WhenCallingOnActionExecuted_WithAMicroLiteReadOnlyApiController_AndTheContextContainsAnException_AndTheTransactionHasBeenRolledBack() @@ -583,7 +583,7 @@ public void TheTransactionIsNotRolledBackAgain() public class WhenCallingOnActionExecuted_WithAMicroLiteReadOnlyApiController_AndTheContextContainsAnException_AndTheTransactionHasNotBeenRolledBack { - private readonly Mock _mockSession = new Mock(); + private readonly Mock _mockSession = new Mock(); private readonly Mock _mockTransaction = new Mock(); public WhenCallingOnActionExecuted_WithAMicroLiteReadOnlyApiController_AndTheContextContainsAnException_AndTheTransactionHasNotBeenRolledBack() @@ -630,7 +630,7 @@ public void TheTransactionIsRolledBack() public class WhenCallingOnActionExecuting_WithAMicroLiteApiController { - private readonly Mock _mockSession = new Mock(); + private readonly Mock _mockSession = new Mock(); public WhenCallingOnActionExecuting_WithAMicroLiteApiController() { @@ -657,7 +657,7 @@ public void ATransactionIsStarted() public class WhenCallingOnActionExecuting_WithAMicroLiteApiController_AndAutoManageTransactionIsFalse { - private readonly Mock _mockSession = new Mock(); + private readonly Mock _mockSession = new Mock(); public WhenCallingOnActionExecuting_WithAMicroLiteApiController_AndAutoManageTransactionIsFalse() { @@ -687,7 +687,7 @@ public void ATransactionIsNotStarted() public class WhenCallingOnActionExecuting_WithAMicroLiteReadOnlyApiController { - private readonly Mock _mockSession = new Mock(); + private readonly Mock _mockSession = new Mock(); public WhenCallingOnActionExecuting_WithAMicroLiteReadOnlyApiController() { @@ -714,7 +714,7 @@ public void ATransactionIsStarted() public class WhenCallingOnActionExecuting_WithAMicroLiteReadOnlyApiController_AndAutoManageTransactionIsFalse { - private readonly Mock _mockSession = new Mock(); + private readonly Mock _mockSession = new Mock(); public WhenCallingOnActionExecuting_WithAMicroLiteReadOnlyApiController_AndAutoManageTransactionIsFalse() { diff --git a/MicroLite.Extensions.WebApi.Tests/MicroLite.Extensions.WebApi.Tests.csproj b/MicroLite.Extensions.WebApi.Tests/MicroLite.Extensions.WebApi.Tests.csproj index 8455693..077de07 100644 --- a/MicroLite.Extensions.WebApi.Tests/MicroLite.Extensions.WebApi.Tests.csproj +++ b/MicroLite.Extensions.WebApi.Tests/MicroLite.Extensions.WebApi.Tests.csproj @@ -46,9 +46,10 @@ ..\packages\Castle.Core.4.4.0\lib\net45\Castle.Core.dll - - ..\packages\MicroLite.6.3.1\lib\net46\MicroLite.dll + + ..\packages\MicroLite.7.0.0\lib\net45\MicroLite.dll + ..\packages\Microsoft.CodeCoverage.16.5.0\lib\net45\Microsoft.VisualStudio.CodeCoverage.Shim.dll @@ -75,6 +76,8 @@ ..\packages\Microsoft.AspNet.WebApi.Core.5.2.7\lib\net45\System.Web.Http.dll + + ..\packages\xunit.abstractions.2.0.3\lib\net35\xunit.abstractions.dll @@ -103,17 +106,18 @@ MicroLite.snk + - - - {48714fd3-e87a-4a49-b8fb-2644bd1c577b} MicroLite.Extensions.WebApi + + + @@ -130,4 +134,4 @@ - + \ No newline at end of file diff --git a/MicroLite.Extensions.WebApi.Tests/MicroLiteApiControllerTests.cs b/MicroLite.Extensions.WebApi.Tests/MicroLiteApiControllerTests.cs index 87865ed..2e0335b 100644 --- a/MicroLite.Extensions.WebApi.Tests/MicroLiteApiControllerTests.cs +++ b/MicroLite.Extensions.WebApi.Tests/MicroLiteApiControllerTests.cs @@ -11,7 +11,7 @@ public class MicroLiteApiControllerTests public class WhenConstructedWithAnISession { private readonly MicroLiteApiController _controller; - private readonly IAsyncSession _session = new Mock().Object; + private readonly ISession _session = new Mock().Object; public WhenConstructedWithAnISession() { diff --git a/MicroLite.Extensions.WebApi.Tests/MicroLiteApiController{T}Tests.cs b/MicroLite.Extensions.WebApi.Tests/MicroLiteApiController{T}Tests.cs index b4fa241..c7f13cc 100644 --- a/MicroLite.Extensions.WebApi.Tests/MicroLiteApiController{T}Tests.cs +++ b/MicroLite.Extensions.WebApi.Tests/MicroLiteApiController{T}Tests.cs @@ -16,7 +16,7 @@ public class WhenCallingDeleteAndAnEntityIsDeleted { private readonly CustomerController _controller; private readonly int _identifier = 12345; - private readonly Mock _mockSession = new Mock(); + private readonly Mock _mockSession = new Mock(); private readonly HttpResponseMessage _response; public WhenCallingDeleteAndAnEntityIsDeleted() @@ -42,7 +42,7 @@ public class WhenCallingDeleteAndAnEntityIsNotDeleted { private readonly CustomerController _controller; private readonly int _identifier = 12345; - private readonly Mock _mockSession = new Mock(); + private readonly Mock _mockSession = new Mock(); private readonly HttpResponseMessage _response; public WhenCallingDeleteAndAnEntityIsNotDeleted() @@ -68,7 +68,7 @@ public class WhenCallingGetAndAnEntityIsNotReturned { private readonly CustomerController _controller; private readonly int _identifier = 12345; - private readonly Mock _mockSession = new Mock(); + private readonly Mock _mockSession = new Mock(); private readonly HttpResponseMessage _response; public WhenCallingGetAndAnEntityIsNotReturned() @@ -101,7 +101,7 @@ public class WhenCallingGetAndAnEntityIsReturned private readonly CustomerController _controller; private readonly Customer _customer = new Customer(); private readonly int _identifier = 12345; - private readonly Mock _mockSession = new Mock(); + private readonly Mock _mockSession = new Mock(); private readonly HttpResponseMessage _response; public WhenCallingGetAndAnEntityIsReturned() @@ -135,7 +135,7 @@ public class WhenCallingPost private readonly CustomerController _controller; private readonly Customer _customer = new Customer(); private readonly int _identifier = 12345; - private readonly Mock _mockSession = new Mock(); + private readonly Mock _mockSession = new Mock(); private readonly HttpResponseMessage _response; public WhenCallingPost() @@ -179,7 +179,7 @@ public class WhenCallingPutAndAnEntityIsNotReturned { private readonly CustomerController _controller; private readonly int _identifier = 12345; - private readonly Mock _mockSession = new Mock(); + private readonly Mock _mockSession = new Mock(); private readonly HttpResponseMessage _response; public WhenCallingPutAndAnEntityIsNotReturned() @@ -211,7 +211,7 @@ public class WhenCallingPutAndAnEntityIsNotUpdated { private readonly CustomerController _controller; private readonly int _identifier = 12345; - private readonly Mock _mockSession = new Mock(); + private readonly Mock _mockSession = new Mock(); private readonly HttpResponseMessage _response; public WhenCallingPutAndAnEntityIsNotUpdated() @@ -244,7 +244,7 @@ public class WhenCallingPutAndAnEntityIsUpdated { private readonly CustomerController _controller; private readonly int _identifier = 12345; - private readonly Mock _mockSession = new Mock(); + private readonly Mock _mockSession = new Mock(); private readonly HttpResponseMessage _response; private readonly Customer _updatedCustomer = new Customer @@ -287,7 +287,7 @@ public void TheUpdatedCustomerShouldHaveTheIdentifierSet() public class WhenConstructedWithAnISession { private readonly MicroLiteApiController _controller; - private readonly IAsyncSession _session = new Mock().Object; + private readonly ISession _session = new Mock().Object; public WhenConstructedWithAnISession() { @@ -308,7 +308,7 @@ public void TheSessionIsSet() private class CustomerController : MicroLiteApiController { - public CustomerController(IAsyncSession session) + public CustomerController(ISession session) : base(session) { GetEntityResourceUri = (int id) => diff --git a/MicroLite.Extensions.WebApi.Tests/MicroLiteReadOnlyApiControllerTests.cs b/MicroLite.Extensions.WebApi.Tests/MicroLiteReadOnlyApiControllerTests.cs index 2b9a723..610709f 100644 --- a/MicroLite.Extensions.WebApi.Tests/MicroLiteReadOnlyApiControllerTests.cs +++ b/MicroLite.Extensions.WebApi.Tests/MicroLiteReadOnlyApiControllerTests.cs @@ -11,7 +11,7 @@ public class MicroLiteReadOnlyApiControllerTests public class WhenConstructedWithAnIReadOnlySession { private readonly MicroLiteReadOnlyApiController _controller; - private readonly IAsyncReadOnlySession _session = new Mock().Object; + private readonly IReadOnlySession _session = new Mock().Object; public WhenConstructedWithAnIReadOnlySession() { diff --git a/MicroLite.Extensions.WebApi.Tests/Properties/AssemblyInfo.cs b/MicroLite.Extensions.WebApi.Tests/Properties/AssemblyInfo.cs index 0c91c1c..9e06419 100644 --- a/MicroLite.Extensions.WebApi.Tests/Properties/AssemblyInfo.cs +++ b/MicroLite.Extensions.WebApi.Tests/Properties/AssemblyInfo.cs @@ -8,7 +8,7 @@ [assembly: AssemblyTitle("MicroLite.Extensions.WebApi.Tests")] [assembly: AssemblyDescription("Unit Tests for the MicroLite.Extensions.WebApi library")] [assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] +[assembly: AssemblyCompany("Project Contributors")] [assembly: AssemblyProduct("MicroLite.Extensions.WebApi.Tests")] [assembly: AssemblyCopyright("Copyright Project Contributors all rights reserved.")] [assembly: AssemblyTrademark("")] @@ -28,6 +28,9 @@ // Minor Version // Build Number // Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")] -[assembly: CollectionBehavior(DisableTestParallelization = true)] +[assembly: CollectionBehavior(DisableTestParallelization = true)] \ No newline at end of file diff --git a/MicroLite.Extensions.WebApi.Tests/ValidateModelNotNullAttributeTests.cs b/MicroLite.Extensions.WebApi.Tests/ValidateModelNotNullAttributeTests.cs index 8139371..b2519db 100644 --- a/MicroLite.Extensions.WebApi.Tests/ValidateModelNotNullAttributeTests.cs +++ b/MicroLite.Extensions.WebApi.Tests/ValidateModelNotNullAttributeTests.cs @@ -3,7 +3,6 @@ using System.Web.Http; using System.Web.Http.Controllers; using System.Web.Http.Routing; -using MicroLite.Extensions.WebApi; using Moq; using Xunit; diff --git a/MicroLite.Extensions.WebApi.Tests/ValidateModelStateAttributeTests.cs b/MicroLite.Extensions.WebApi.Tests/ValidateModelStateAttributeTests.cs index 08a4078..3b86a02 100644 --- a/MicroLite.Extensions.WebApi.Tests/ValidateModelStateAttributeTests.cs +++ b/MicroLite.Extensions.WebApi.Tests/ValidateModelStateAttributeTests.cs @@ -3,7 +3,6 @@ using System.Web.Http; using System.Web.Http.Controllers; using System.Web.Http.Routing; -using MicroLite.Extensions.WebApi; using Moq; using Xunit; diff --git a/MicroLite.Extensions.WebApi.Tests/app.config b/MicroLite.Extensions.WebApi.Tests/app.config new file mode 100644 index 0000000..d331eb9 --- /dev/null +++ b/MicroLite.Extensions.WebApi.Tests/app.config @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/MicroLite.Extensions.WebApi.Tests/packages.config b/MicroLite.Extensions.WebApi.Tests/packages.config index 4de1244..c97ad8e 100644 --- a/MicroLite.Extensions.WebApi.Tests/packages.config +++ b/MicroLite.Extensions.WebApi.Tests/packages.config @@ -1,7 +1,7 @@  - + diff --git a/MicroLite.Extensions.WebApi/AutoManageTransactionAttribute.cs b/MicroLite.Extensions.WebApi/AutoManageTransactionAttribute.cs index ff36e5c..17f44a3 100644 --- a/MicroLite.Extensions.WebApi/AutoManageTransactionAttribute.cs +++ b/MicroLite.Extensions.WebApi/AutoManageTransactionAttribute.cs @@ -92,16 +92,15 @@ public override void OnActionExecuted(HttpActionExecutedContext actionExecutedCo throw new ArgumentNullException(nameof(actionExecutedContext)); } - if (actionExecutedContext.ActionContext.ControllerContext.Controller is IHaveAsyncSession controller) + if (actionExecutedContext.ActionContext.ControllerContext.Controller is IHaveSession controller) { OnActionExecuted(controller.Session, actionExecutedContext.Exception); return; } - if (actionExecutedContext.ActionContext.ControllerContext.Controller is IHaveAsyncReadOnlySession readOnlyController) + if (actionExecutedContext.ActionContext.ControllerContext.Controller is IHaveReadOnlySession readOnlyController) { OnActionExecuted(readOnlyController.Session, actionExecutedContext.Exception); - return; } } @@ -121,20 +120,19 @@ public override void OnActionExecuting(HttpActionContext actionContext) throw new ArgumentNullException(nameof(actionContext)); } - if (actionContext.ControllerContext.Controller is IHaveAsyncSession controller) + if (actionContext.ControllerContext.Controller is IHaveSession controller) { controller.Session.BeginTransaction(IsolationLevel); return; } - if (actionContext.ControllerContext.Controller is IHaveAsyncReadOnlySession readOnlyController) + if (actionContext.ControllerContext.Controller is IHaveReadOnlySession readOnlyController) { readOnlyController.Session.BeginTransaction(IsolationLevel); - return; } } - private static void OnActionExecuted(IAsyncReadOnlySession session, Exception exception) + private static void OnActionExecuted(IReadOnlySession session, Exception exception) { if (session.CurrentTransaction is null) { diff --git a/MicroLite.Extensions.WebApi/MicroLite.Extensions.WebApi.csproj b/MicroLite.Extensions.WebApi/MicroLite.Extensions.WebApi.csproj index 00f0c83..07ac6cc 100644 --- a/MicroLite.Extensions.WebApi/MicroLite.Extensions.WebApi.csproj +++ b/MicroLite.Extensions.WebApi/MicroLite.Extensions.WebApi.csproj @@ -5,7 +5,7 @@ 7.3 true ..\MicroLite.snk - 6.7.0 + 7.0.0 Trevor Pilley and Project Contributors A .NET 4.5 library which adds an extension for the MicroLite ORM Framework to integrate with ASP.NET WebApi. Copyright 2012 - 2020 Project Contributors @@ -30,17 +30,22 @@ + - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -58,8 +63,4 @@ - - - - diff --git a/MicroLite.Extensions.WebApi/MicroLiteApiController.cs b/MicroLite.Extensions.WebApi/MicroLiteApiController.cs index 84e95ae..7d0fd4f 100644 --- a/MicroLite.Extensions.WebApi/MicroLiteApiController.cs +++ b/MicroLite.Extensions.WebApi/MicroLiteApiController.cs @@ -19,23 +19,21 @@ namespace MicroLite.Extensions.WebApi /// /// Provides access to a MicroLite ISession in addition to the base ASP.NET WebApi controller. /// - public abstract class MicroLiteApiController : ApiController, IHaveAsyncSession + public abstract class MicroLiteApiController : ApiController, IHaveSession { /// /// Initialises a new instance of the class with an ISession. /// - /// The ISession for the current HTTP request. + /// The for the current HTTP request. /// - /// This constructor allows for an inheriting class to easily inject an ISession via an IOC container. + /// This constructor allows for an inheriting class to easily inject an via an IOC container. /// - protected MicroLiteApiController(IAsyncSession session) - { - Session = session ?? throw new ArgumentNullException(nameof(session)); - } + protected MicroLiteApiController(ISession session) + => Session = session ?? throw new ArgumentNullException(nameof(session)); /// - /// Gets or sets the for the current HTTP request. + /// Gets the for the current HTTP request. /// - public IAsyncSession Session { get; set; } + public ISession Session { get; } } } diff --git a/MicroLite.Extensions.WebApi/MicroLiteApiController{TEntity,TId}.cs b/MicroLite.Extensions.WebApi/MicroLiteApiController{TEntity,TId}.cs index b1b2d8a..d665dd2 100644 --- a/MicroLite.Extensions.WebApi/MicroLiteApiController{TEntity,TId}.cs +++ b/MicroLite.Extensions.WebApi/MicroLiteApiController{TEntity,TId}.cs @@ -35,11 +35,8 @@ public abstract class MicroLiteApiController : MicroLiteApiControl /// /// This constructor allows for an inheriting class to easily inject an ISession via an IOC container. /// - protected MicroLiteApiController(IAsyncSession session) - : base(session) - { - GetEntityResourceUri = (TId id) => new Uri(Url.Link("DefaultApi", new { id })); - } + protected MicroLiteApiController(ISession session) + : base(session) => GetEntityResourceUri = (TId id) => new Uri(Url.Link("DefaultApi", new { id })); /// /// Gets or sets a function which returns the entity resource URI for the entity with the supplied . diff --git a/MicroLite.Extensions.WebApi/MicroLiteReadOnlyApiController.cs b/MicroLite.Extensions.WebApi/MicroLiteReadOnlyApiController.cs index b0a91ec..16f64ac 100644 --- a/MicroLite.Extensions.WebApi/MicroLiteReadOnlyApiController.cs +++ b/MicroLite.Extensions.WebApi/MicroLiteReadOnlyApiController.cs @@ -19,7 +19,7 @@ namespace MicroLite.Extensions.WebApi /// /// Provides access to a MicroLite IReadOnlySession in addition to the base ASP.NET WebApi controller. /// - public abstract class MicroLiteReadOnlyApiController : ApiController, IHaveAsyncReadOnlySession + public abstract class MicroLiteReadOnlyApiController : ApiController, IHaveReadOnlySession { /// /// Initialises a new instance of the class with an IReadOnlySession. @@ -28,14 +28,12 @@ public abstract class MicroLiteReadOnlyApiController : ApiController, IHaveAsync /// /// This constructor allows for an inheriting class to easily inject an IReadOnlySession via an IOC container. /// - protected MicroLiteReadOnlyApiController(IAsyncReadOnlySession session) - { - Session = session ?? throw new ArgumentNullException(nameof(session)); - } + protected MicroLiteReadOnlyApiController(IReadOnlySession session) + => Session = session ?? throw new ArgumentNullException(nameof(session)); /// - /// Gets or sets the for the current HTTP request. + /// Gets the for the current HTTP request. /// - public IAsyncReadOnlySession Session { get; set; } + public IReadOnlySession Session { get; } } } diff --git a/README.md b/README.md index 1111501..68766e6 100644 --- a/README.md +++ b/README.md @@ -1,26 +1,30 @@ -MicroLite.Extensions.WebApi -=========================== - -|Service|Status| -|-------|------| -||[![NuGet version](https://badge.fury.io/nu/MicroLite.Extensions.WebApi.svg)](http://badge.fury.io/nu/MicroLite.Extensions.WebApi)| -|/develop|[![Build Status](https://dev.azure.com/trevorpilley/MicroLite-ORM/_apis/build/status/MicroLite-ORM.MicroLite.Extensions.WebApi?branchName=develop)](https://dev.azure.com/trevorpilley/MicroLite-ORM/_build/latest?definitionId=28&branchName=develop)| -|/master|[![Build Status](https://dev.azure.com/trevorpilley/MicroLite-ORM/_apis/build/status/MicroLite-ORM.MicroLite.Extensions.WebApi?branchName=master)](https://dev.azure.com/trevorpilley/MicroLite-ORM/_build/latest?definitionId=28&branchName=master)| +# MicroLite.Extensions.WebApi MicroLite.Extensions.WebAp is a .NET 4.5 library which adds an extension for the MicroLite ORM Framework to integrate with ASP.NET WebApi. -It is easy to use MicroLite with ASP.NET WebApi, simply supply your controller with a Session `IAsyncSession` or `IAsyncReadOnlySession` and use it in your controller actions. However, using the WebApi extension for MicroLite makes it even easier and contains some useful extras. +![Nuget](https://img.shields.io/nuget/dt/MicroLite.Extensions.WebApi) -To find out more, head over to the [Wiki](https://github.com/MicroLite-ORM/MicroLite.Extensions.WebApi/wiki). +|Branch|Status| +|------|------| +|/develop|![GitHub last commit (branch)](https://img.shields.io/github/last-commit/MicroLite-ORM/MicroLite.Extensions.WebApi/develop) [![Build Status](https://dev.azure.com/trevorpilley/MicroLite-ORM/_apis/build/status/MicroLite-ORM.MicroLite.Extensions.WebApi?branchName=develop)](https://dev.azure.com/trevorpilley/MicroLite-ORM/_build/latest?definitionId=28&branchName=develop) ![Nuget (with prereleases)](https://img.shields.io/nuget/vpre/MicroLite.Extensions.WebApi)| +|/master|![GitHub last commit](https://img.shields.io/github/last-commit/MicroLite-ORM/MicroLite.Extensions.WebApi/master) [![Build Status](https://dev.azure.com/trevorpilley/MicroLite-ORM/_apis/build/status/MicroLite-ORM.MicroLite.Extensions.WebApi?branchName=master)](https://dev.azure.com/trevorpilley/MicroLite-ORM/_build/latest?definitionId=28&branchName=master) ![Nuget](https://img.shields.io/nuget/v/MicroLite.Extensions.WebApi) ![GitHub Release Date](https://img.shields.io/github/release-date/MicroLite-ORM/MicroLite.Extensions.WebApi)| -Also, check out the [WebApi](http://microliteorm.wordpress.com/tag/WebApi/) tag on the MicroLite Blog. +## Installation -For OData support, check out the [MicroLite.Extensions.WebApi.OData](https://github.com/MicroLite-ORM/MicroLite.Extensions.WebApi.OData) add-on. +Install the nuget package `Install-Package MicroLite.Extensions.WebApi` + +## Configuration + +It is easy to use MicroLite with ASP.NET WebApi, simply supply your controller with a Session `ISession` or `IReadOnlySession` and use it in your controller actions. However, using the WebApi extension for MicroLite makes it even easier and contains some useful extras. -### Supported .NET Versions +## Supported .NET Versions -The NuGet Package contains binaries compiled against: +The NuGet Package contains binaries compiled against (dependencies indented): * .NET Framework 4.5 -* - MicroLite 6.3.1 -* - Microsoft.AspNet.WebApi.Core 5.2.7 + * MicroLite 7.0.0 + * Microsoft.AspNet.WebApi.Core 5.2.7 + +To find out more, head over to the [Wiki](https://github.com/MicroLite-ORM/MicroLite.Extensions.WebApi/wiki), or check out the [WebApi](http://microliteorm.wordpress.com/tag/WebApi/) tag on the MicroLite Blog. + +For OData support, check out the [MicroLite.Extensions.WebApi.OData](https://github.com/MicroLite-ORM/MicroLite.Extensions.WebApi.OData) add-on. diff --git a/azure-pipelines.yml b/azure-pipelines.yml index cabcb8d..8e6b283 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -3,6 +3,7 @@ trigger: include: - master - develop + - hotfix* paths: exclude: - .editorconfig @@ -49,7 +50,7 @@ steps: - script: dotnet pack "$(projectPath)" -o:$(Build.ArtifactStagingDirectory) -p:PackageVersion="$(buildVersion)-preview$(Build.BuildNumber)" displayName: 'dotnet pack (pre)' - condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/develop')) + condition: and(succeeded(), ne(variables['Build.SourceBranch'], 'refs/heads/master')) - script: dotnet pack "$(projectPath)" -o:$(Build.ArtifactStagingDirectory) -p:PackageVersion=$(buildVersion) displayName: 'dotnet pack'