diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml new file mode 100644 index 00000000..01274084 --- /dev/null +++ b/.github/workflows/dotnet.yml @@ -0,0 +1,36 @@ +# This workflow will build a .NET project +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net + +name: .NET + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + workflow_dispatch: + + +jobs: + build: + + runs-on: windows-latest + + steps: + - uses: actions/checkout@v3 + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 8.0.x + node-version: 20.7.x + - name: Restore dependencies + run: dotnet restore + - name: Build front-end app + run: | + cd ./KenticoInspector.WebApplication/ClientApp + npm i + npm run build + - name: Build dotnet app + run: dotnet build --no-restore + - name: Test + run: dotnet test --no-build --verbosity normal diff --git a/KenticoInspector.Actions/KenticoInspector.Actions.csproj b/KenticoInspector.Actions/KenticoInspector.Actions.csproj index cb1072d5..aea96db5 100644 --- a/KenticoInspector.Actions/KenticoInspector.Actions.csproj +++ b/KenticoInspector.Actions/KenticoInspector.Actions.csproj @@ -1,11 +1,12 @@  - netcoreapp2.2 + net8.0 + 9.0 - + diff --git a/KenticoInspector.Core.Tests/KenticoInspector.Core.Tests.csproj b/KenticoInspector.Core.Tests/KenticoInspector.Core.Tests.csproj index 33a955c2..a79cc967 100644 --- a/KenticoInspector.Core.Tests/KenticoInspector.Core.Tests.csproj +++ b/KenticoInspector.Core.Tests/KenticoInspector.Core.Tests.csproj @@ -1,11 +1,9 @@  - netcoreapp2.2 - + net8.0 false - - 7.1 + 9.0 diff --git a/KenticoInspector.Core/Converters/VersionListConverter.cs b/KenticoInspector.Core/Converters/VersionListConverter.cs new file mode 100644 index 00000000..2982cc5f --- /dev/null +++ b/KenticoInspector.Core/Converters/VersionListConverter.cs @@ -0,0 +1,28 @@ +using Newtonsoft.Json; +using System.Collections.Generic; +using System; + +namespace KenticoInspector.Core.Converters +{ + public class VersionListConverter : JsonConverter + { + public override bool CanConvert(Type objectType) + { + return (objectType == typeof(List)); + } + + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + { + serializer.Converters.Add(new VersionObjectConverter()); + + serializer.Serialize(writer, value); + } + + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + { + serializer.Converters.Add(new VersionObjectConverter()); + + return serializer.Deserialize(reader, typeof(Version)); + } + } +} \ No newline at end of file diff --git a/KenticoInspector.Core/Converters/VersionObjectConverter.cs b/KenticoInspector.Core/Converters/VersionObjectConverter.cs new file mode 100644 index 00000000..0cad0a83 --- /dev/null +++ b/KenticoInspector.Core/Converters/VersionObjectConverter.cs @@ -0,0 +1,26 @@ +using Newtonsoft.Json.Linq; +using Newtonsoft.Json; +using System; + +namespace KenticoInspector.Core.Converters +{ + public class VersionObjectConverter : JsonConverter + { + public override void WriteJson(JsonWriter writer, Version value, JsonSerializer serializer) + { + JObject jsonVersion = new JObject + { + { "major", value.Major }, + { "minor", value.Minor }, + { "build", value.Build }, + }; + jsonVersion.WriteTo(writer); + } + + public override Version ReadJson(JsonReader reader, Type objectType, Version existingValue, bool hasExistingValue, JsonSerializer serializer) + { + JObject jsonVersion = JObject.Load(reader); + return new Version((int)jsonVersion["major"], (int)jsonVersion["minor"], (int)jsonVersion["build"]); + } + } +} \ No newline at end of file diff --git a/KenticoInspector.Core/Helpers/DirectoryHelper.cs b/KenticoInspector.Core/Helpers/DirectoryHelper.cs index 708332f4..631038aa 100644 --- a/KenticoInspector.Core/Helpers/DirectoryHelper.cs +++ b/KenticoInspector.Core/Helpers/DirectoryHelper.cs @@ -5,18 +5,14 @@ namespace KenticoInspector.Core.Helpers { public static class DirectoryHelper { - private const string filePrefix = "file:\\"; - /// /// Gets the executing directory of the application. /// /// A string that contains the path of the executing directory, and does not end with a backslash (\). public static string GetExecutingDirectory() { - var assemblyPath = Assembly.GetExecutingAssembly().CodeBase; - var assemblyDirectory = Path.GetDirectoryName(assemblyPath); - - return assemblyDirectory.Substring(filePrefix.Length); + var assemblyPath = Assembly.GetExecutingAssembly().Location; + return Path.GetDirectoryName(assemblyPath); } } } \ No newline at end of file diff --git a/KenticoInspector.Core/KenticoInspector.Core.csproj b/KenticoInspector.Core/KenticoInspector.Core.csproj index 8fae0dc1..be5f6cc5 100644 --- a/KenticoInspector.Core/KenticoInspector.Core.csproj +++ b/KenticoInspector.Core/KenticoInspector.Core.csproj @@ -1,8 +1,8 @@ - + - netcoreapp2.2 - 7.1 + net8.0 + 9.0 @@ -11,9 +11,9 @@ - - - + + + diff --git a/KenticoInspector.Core/Models/InstanceDetails.cs b/KenticoInspector.Core/Models/InstanceDetails.cs index c76f340c..eb7fffcf 100644 --- a/KenticoInspector.Core/Models/InstanceDetails.cs +++ b/KenticoInspector.Core/Models/InstanceDetails.cs @@ -1,4 +1,6 @@ -using System; +using KenticoInspector.Core.Converters; +using Newtonsoft.Json; +using System; using System.Collections.Generic; namespace KenticoInspector.Core.Models @@ -7,8 +9,10 @@ public class InstanceDetails { public Guid Guid { get; set; } + [JsonConverter(typeof(VersionObjectConverter))] public Version AdministrationVersion { get; set; } + [JsonConverter(typeof(VersionObjectConverter))] public Version DatabaseVersion { get; set; } public IEnumerable Sites { get; set; } diff --git a/KenticoInspector.Core/Modules/IModule.cs b/KenticoInspector.Core/Modules/IModule.cs index 740d316b..74d31df2 100644 --- a/KenticoInspector.Core/Modules/IModule.cs +++ b/KenticoInspector.Core/Modules/IModule.cs @@ -1,7 +1,8 @@ -using System; +using Newtonsoft.Json; +using System; using System.Collections.Generic; -using KenticoInspector.Core.Models; +using KenticoInspector.Core.Converters; namespace KenticoInspector.Core.Modules { @@ -9,8 +10,10 @@ public interface IModule { string Codename { get; } + [JsonConverter(typeof(VersionListConverter))] IList CompatibleVersions { get; } + [JsonConverter(typeof(VersionListConverter))] IList IncompatibleVersions { get; } IList Tags { get; } diff --git a/KenticoInspector.Core/Tokens/TokenExpressionResolver.cs b/KenticoInspector.Core/Tokens/TokenExpressionResolver.cs index 429e3fbf..f2fa0502 100644 --- a/KenticoInspector.Core/Tokens/TokenExpressionResolver.cs +++ b/KenticoInspector.Core/Tokens/TokenExpressionResolver.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; -using System.Runtime.Serialization; +using System.Runtime.CompilerServices; using System.Text.RegularExpressions; namespace KenticoInspector.Core.Tokens @@ -86,7 +86,7 @@ private static string ResolveTokenExpression(string tokenExpression, IDictionary { if (Regex.IsMatch(innerTokenExpression, pattern)) { - var expressionObject = FormatterServices.GetUninitializedObject(tokenExpressionType) as ITokenExpression; + var expressionObject = RuntimeHelpers.GetUninitializedObject(tokenExpressionType) as ITokenExpression; resolvedExpression = expressionObject.Resolve(innerTokenExpression, tokenDictionary); diff --git a/KenticoInspector.Infrastructure.Tests/KenticoInspector.Infrastructure.Tests.csproj b/KenticoInspector.Infrastructure.Tests/KenticoInspector.Infrastructure.Tests.csproj index 95c497d4..e66d4c81 100644 --- a/KenticoInspector.Infrastructure.Tests/KenticoInspector.Infrastructure.Tests.csproj +++ b/KenticoInspector.Infrastructure.Tests/KenticoInspector.Infrastructure.Tests.csproj @@ -1,8 +1,8 @@  - netcoreapp2.2 - + net8.0 + 9.0 false diff --git a/KenticoInspector.Infrastructure/KenticoInspector.Infrastructure.csproj b/KenticoInspector.Infrastructure/KenticoInspector.Infrastructure.csproj index 4253e5dc..7b512d7f 100644 --- a/KenticoInspector.Infrastructure/KenticoInspector.Infrastructure.csproj +++ b/KenticoInspector.Infrastructure/KenticoInspector.Infrastructure.csproj @@ -1,8 +1,8 @@  - netcoreapp2.2 - 7.1 + net8.0 + 9.0 @@ -11,11 +11,11 @@ - + - - + + diff --git a/KenticoInspector.Reports.Tests/KenticoInspector.Reports.Tests.csproj b/KenticoInspector.Reports.Tests/KenticoInspector.Reports.Tests.csproj index 4303f4ec..46f86c99 100644 --- a/KenticoInspector.Reports.Tests/KenticoInspector.Reports.Tests.csproj +++ b/KenticoInspector.Reports.Tests/KenticoInspector.Reports.Tests.csproj @@ -1,11 +1,9 @@  - netcoreapp2.2 - + net8.0 false - - 7.1 + 9.0 diff --git a/KenticoInspector.Reports/KenticoInspector.Reports.csproj b/KenticoInspector.Reports/KenticoInspector.Reports.csproj index 5e25c3f1..a05c2b57 100644 --- a/KenticoInspector.Reports/KenticoInspector.Reports.csproj +++ b/KenticoInspector.Reports/KenticoInspector.Reports.csproj @@ -1,8 +1,8 @@ - + - netcoreapp2.2 - 7.1 + net8.0 + 9.0 @@ -11,7 +11,7 @@ - + diff --git a/KenticoInspector.WebApplication/Controllers/ActionsController.cs b/KenticoInspector.WebApplication/Controllers/ActionsController.cs index 42f9d831..21137dc4 100644 --- a/KenticoInspector.WebApplication/Controllers/ActionsController.cs +++ b/KenticoInspector.WebApplication/Controllers/ActionsController.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.IO; using System.Text; +using System.Threading.Tasks; using KenticoInspector.Core.Models; using KenticoInspector.Core.Modules; @@ -23,20 +24,17 @@ public ActionsController(IModuleService moduleService) } [HttpGet("{instanceGuid}")] - public ActionResult> Get(Guid instanceGuid) + public Task> Get(Guid instanceGuid) { - return Ok(moduleService.GetActions(instanceGuid)); + return Task.FromResult(moduleService.GetActions(instanceGuid)); } - // POST api/values [HttpPost("{codename}/execute/{instanceGuid}")] - public ActionResult Excecute(string codename, Guid instanceGuid) + public async Task Excecute(string codename, Guid instanceGuid) { - using (StreamReader reader = new StreamReader(Request.Body, Encoding.UTF8)) - { - var optionsJson = reader.ReadToEnd(); - return moduleService.ExecuteAction(codename, instanceGuid, optionsJson); - } + using StreamReader reader = new(Request.Body, Encoding.UTF8); + var optionsJson = await reader.ReadToEndAsync(); + return moduleService.ExecuteAction(codename, instanceGuid, optionsJson); } } } \ No newline at end of file diff --git a/KenticoInspector.WebApplication/Controllers/InstancesController.cs b/KenticoInspector.WebApplication/Controllers/InstancesController.cs index a3bed60d..98bc21d1 100644 --- a/KenticoInspector.WebApplication/Controllers/InstancesController.cs +++ b/KenticoInspector.WebApplication/Controllers/InstancesController.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Threading.Tasks; using KenticoInspector.Core.Models; using KenticoInspector.Core.Services.Interfaces; @@ -21,9 +22,9 @@ public InstancesController(IInstanceService instanceService) } [HttpGet("details/{instanceGuid}")] - public ActionResult Details(Guid instanceGuid) + public Task Details(Guid instanceGuid) { - return _instanceService.GetInstanceDetails(instanceGuid); + return Task.FromResult(_instanceService.GetInstanceDetails(instanceGuid)); } [HttpDelete("{instanceGuid}")] @@ -33,22 +34,22 @@ public void Delete(Guid instanceGuid) } [HttpGet] - public ActionResult> Get() + public Task> Get() { var instances = _instanceService.GetInstances(); - return instances.ToList(); + return Task.FromResult(instances.ToList()); } [HttpGet("{instanceGuid}")] - public ActionResult Get(Guid instanceGuid) + public Task Get(Guid instanceGuid) { - return _instanceService.GetInstance(instanceGuid); + return Task.FromResult(_instanceService.GetInstance(instanceGuid)); } [HttpPost] - public Instance Post([FromBody] Instance instance) + public Task Post([FromBody] Instance instance) { - return _instanceService.UpsertInstance(instance); + return Task.FromResult(_instanceService.UpsertInstance(instance)); } } } \ No newline at end of file diff --git a/KenticoInspector.WebApplication/Controllers/ReportsController.cs b/KenticoInspector.WebApplication/Controllers/ReportsController.cs index b694cee0..df585185 100644 --- a/KenticoInspector.WebApplication/Controllers/ReportsController.cs +++ b/KenticoInspector.WebApplication/Controllers/ReportsController.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Threading.Tasks; using KenticoInspector.Core.Models; using KenticoInspector.Core.Modules; @@ -21,16 +22,15 @@ public ReportsController(IModuleService moduleService) } [HttpGet("{instanceGuid}")] - public ActionResult> Get(Guid instanceGuid) + public Task> Get(Guid instanceGuid) { - return Ok(moduleService.GetReports(instanceGuid)); + return Task.FromResult(moduleService.GetReports(instanceGuid)); } - // POST api/values [HttpGet("{codename}/results/{instanceGuid}")] - public ActionResult Get(string codename, Guid instanceGuid) + public Task Get(string codename, Guid instanceGuid) { - return moduleService.GetReportResults(codename, instanceGuid); + return Task.FromResult(moduleService.GetReportResults(codename, instanceGuid)); } } } \ No newline at end of file diff --git a/KenticoInspector.WebApplication/KenticoInspector.WebApplication.csproj b/KenticoInspector.WebApplication/KenticoInspector.WebApplication.csproj index e6fead5b..88acef50 100644 --- a/KenticoInspector.WebApplication/KenticoInspector.WebApplication.csproj +++ b/KenticoInspector.WebApplication/KenticoInspector.WebApplication.csproj @@ -1,10 +1,10 @@  - netcoreapp2.2 + net8.0 InProcess - 7.1 + 9.0 @@ -13,12 +13,11 @@ - - - - + + + - + diff --git a/KenticoInspector.WebApplication/Startup.cs b/KenticoInspector.WebApplication/Startup.cs index 7afe9003..d1c121a3 100644 --- a/KenticoInspector.WebApplication/Startup.cs +++ b/KenticoInspector.WebApplication/Startup.cs @@ -7,9 +7,9 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; using System; @@ -26,7 +26,8 @@ public Startup(IConfiguration configuration) public IServiceProvider ConfigureServices(IServiceCollection services) { - services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); + services.AddMvc(options => options.EnableEndpointRouting = false) + .AddNewtonsoftJson(options => options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore); services.AddSpaStaticFiles(configuration => { @@ -36,7 +37,7 @@ public IServiceProvider ConfigureServices(IServiceCollection services) return ConfigureAutofac(services); } - private IServiceProvider ConfigureAutofac(IServiceCollection services) + private AutofacServiceProvider ConfigureAutofac(IServiceCollection services) { var containerBuilder = new ContainerBuilder(); @@ -51,7 +52,7 @@ private IServiceProvider ConfigureAutofac(IServiceCollection services) return new AutofacServiceProvider(container); } - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { diff --git a/README.md b/README.md index d252dd23..a96efab1 100644 --- a/README.md +++ b/README.md @@ -42,9 +42,9 @@ If anything feels wrong or incomplete, please let us know. Create a new [issue]( All versions below are from a known working environment. Lower versions may work but are not tested. - [Visual Studio 2017 updated to 15.9.11 or later](https://visualstudio.microsoft.com/vs/) -- [.NET Core 2.2 SDK](https://dotnet.microsoft.com/download/dotnet-core/2.2) -- [Node for Windows (10.15.X+)](https://nodejs.org/en/) -- [NPM (6.4.X+) (included with Node)](https://www.npmjs.com/) +- [.NET Core 8.0 SDK](https://dotnet.microsoft.com/download/dotnet/8.0) +- [Node for Windows (10.15.X - 20.7.0)](https://nodejs.org/en/) +- [NPM (6.4.X - 10.1.0) (included with Node)](https://www.npmjs.com/) - [Vue CLI (3.x)](https://cli.vuejs.org/) ### First run