Skip to content

Commit

Permalink
Merge pull request #39 from nventive/feature/net7
Browse files Browse the repository at this point in the history
feat: Upgrades to net7.0
  • Loading branch information
DamienLaffond committed Nov 2, 2023
2 parents 2ec4cb9 + 402965b commit 37c4807
Show file tree
Hide file tree
Showing 25 changed files with 147 additions and 157 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
dotnet-version: 7.0.x

- name: Restore dependencies
run: dotnet restore src/Content/Backend
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"sdk": {
"version": "6.0.407"
"version": "7.0.305"
}
}
2 changes: 1 addition & 1 deletion src/Content/Backend/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="6.0.0">
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="7.0.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<IsPackable>false</IsPackable>
<UserSecretsId>20403522-635f-44fd-ab82-8a754fe59c64</UserSecretsId>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.4">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.2" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.2">
<PackageReference Include="coverlet.collector" Version="6.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand All @@ -24,5 +24,4 @@
<ProjectReference Include="..\NV.Templates.Backend.Core.Tests\NV.Templates.Backend.Core.Tests.csproj" />
<ProjectReference Include="..\NV.Templates.Backend.Core\NV.Templates.Backend.Core.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<UserSecretsId>20403522-635f-44fd-ab82-8a754fe59c64</UserSecretsId>
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="McMaster.Extensions.Hosting.CommandLine" Version="4.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="6.0.4" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.1" />
<PackageReference Include="McMaster.Extensions.Hosting.CommandLine" Version="4.0.2" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="7.0.8" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
</ItemGroup>

<ItemGroup>
Expand All @@ -20,5 +21,4 @@
<ItemGroup>
<ProjectReference Include="..\NV.Templates.Backend.Core\NV.Templates.Backend.Core.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static Task<int> Main(string[] args) => new HostBuilder()
config.AddCommandLine(args);
}
hostBuilderContext.HostingEnvironment.ApplicationName = typeof(Program).Assembly.GetName().Name;
hostBuilderContext.HostingEnvironment.ApplicationName = typeof(Program).Assembly.GetName().Name !;
})
.ConfigureLogging((_, builder) =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ private IHost GetTestHost()
logging.AddXUnit(OutputHelper);
}
logging.AddFilter((category, level) => category.EndsWith("TraceHandler", StringComparison.OrdinalIgnoreCase));
logging.AddFilter((category, level) => category!.EndsWith("TraceHandler", StringComparison.OrdinalIgnoreCase));
})
.ConfigureServices((context, services) =>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<IsPackable>false</IsPackable>
<UserSecretsId>20403522-635f-44fd-ab82-8a754fe59c64</UserSecretsId>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Bogus" Version="34.0.2" />
<PackageReference Include="FluentAssertions" Version="6.6.0" />
<PackageReference Include="FluentAssertions" Version="6.11.0" />
<PackageReference Include="HttpRecorder" Version="2.0.0" />
<PackageReference Include="MartinCostello.Logging.XUnit" Version="0.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
<PackageReference Include="Moq" Version="4.17.2" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.4">
<PackageReference Include="MartinCostello.Logging.XUnit" Version="0.3.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.2" />
<PackageReference Include="Moq" Version="4.18.4" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.2">
<PackageReference Include="coverlet.collector" Version="6.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand All @@ -31,5 +31,4 @@
<ItemGroup>
<ProjectReference Include="..\NV.Templates.Backend.Core\NV.Templates.Backend.Core.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand All @@ -10,24 +10,18 @@

<ItemGroup>
<PackageReference Include="Azure.Extensions.AspNetCore.Configuration.Secrets" Version="1.2.2" />
<PackageReference Include="Azure.Identity" Version="1.6.0" />
<PackageReference Include="Azure.Identity" Version="1.10.3" />
<PackageReference Include="HttpTracing" Version="1.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="6.0.4" />
<PackageReference Include="Microsoft.Extensions.Configuration.AzureAppConfiguration" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks" Version="6.0.4" />
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="6.0.4" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Options.DataAnnotations" Version="6.0.0" />
<PackageReference Include="NSwag.AspNetCore" Version="13.15.10" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="7.0.8" />
<PackageReference Include="Microsoft.Extensions.Configuration.AzureAppConfiguration" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="7.0.8" />
<PackageReference Include="NSwag.AspNetCore" Version="13.19.0" />
<PackageReference Include="Refit" Version="6.3.2" />
<PackageReference Include="Refit.Xml" Version="6.3.2" />
<PackageReference Include="Scrutor" Version="4.1.0" />
<PackageReference Include="System.Text.Json" Version="6.0.3" />
<PackageReference Include="Scrutor" Version="4.2.2" />
<PackageReference Include="System.Text.Json" Version="7.0.3" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
using FluentAssertions;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.Functions.Worker;
using Microsoft.Azure.Functions.Worker.Http;
using Moq;
using NV.Templates.Backend.Core.General;
using Xunit;

namespace NV.Templates.Backend.Functions.Tests
Expand All @@ -14,13 +14,19 @@ public class GeneralTests
[Fact]
public async Task ItShouldGetInfo()
{
var function = new GeneralFunctions(
Mock.Of<IApplicationInfo>(),
Mock.Of<IOperationContext>());
// Arrange
var applicationInfoMock = Mock.Of<IApplicationInfo>();
var httpRequestMock = new Mock<HttpRequest>();
var functionContextMock = new Mock<FunctionContext>();

var result = await function.GetInfo(Mock.Of<HttpRequest>(), new ExecutionContext());
// Create an instance of GeneralFunctions
var generalFunctions = new GeneralFunctions(applicationInfoMock);

result.Should().BeOfType<JsonResult>();
// Act
var result = await generalFunctions.GetInfo(httpRequestMock.Object, functionContextMock.Object);

// Assert
result.Should().BeAssignableTo<JsonResult>();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<IsPackable>false</IsPackable>
<UserSecretsId>20403522-635f-44fd-ab82-8a754fe59c64</UserSecretsId>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MartinCostello.Logging.XUnit" Version="0.2.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.4">
<PackageReference Include="MartinCostello.Logging.XUnit" Version="0.3.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.2" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.2">
<PackageReference Include="coverlet.collector" Version="6.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand All @@ -25,5 +25,4 @@
<ProjectReference Include="..\NV.Templates.Backend.Core\NV.Templates.Backend.Core.csproj" />
<ProjectReference Include="..\NV.Templates.Backend.Functions\NV.Templates.Backend.Functions.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,40 +1,38 @@
using System;
using System.Threading.Tasks;
using System.IO;
using System.Net;
using System.Text;
using System.Text.Json;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.Azure.Functions.Worker;
using Microsoft.Azure.Functions.Worker.Http;
using Newtonsoft.Json;

namespace NV.Templates.Backend.Functions
{
public class GeneralFunctions
{
private readonly IApplicationInfo _applicationInfo;
private readonly IOperationContext _operationContext;

public GeneralFunctions(
IApplicationInfo applicationInfo,
IOperationContext operationContext)
IApplicationInfo applicationInfo)
{
_applicationInfo = applicationInfo;
_operationContext = operationContext;
}

/// <summary>
/// Get System Information.
/// </summary>
[FunctionName("GetInfo")]
public async Task<JsonResult> GetInfo(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "info")] HttpRequest request,
ExecutionContext executionContext)
[Function("GetInfo")]
public async Task<IActionResult> GetInfo(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "info")] HttpRequest request, FunctionContext context)
{
if (request == null)
{
throw new ArgumentNullException(nameof(request));
}

_operationContext.Id = executionContext?.InvocationId.ToString() ?? $"{Guid.NewGuid()}";
return new JsonResult(_applicationInfo) { StatusCode = StatusCodes.Status200OK };
return new JsonResult(_applicationInfo);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
<UserSecretsId>20403522-635f-44fd-ab82-8a754fe59c64</UserSecretsId>
<OutputType>Exe</OutputType>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.1.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="6.0.1" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.1.0" />
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.19.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.15.1" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore" Version="1.0.0" />
<PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.21.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.ApplicationInsights" Version="1.0.0" />
</ItemGroup>
<ItemGroup>
<Using Include="System.Threading.ExecutionContext" Alias="ExecutionContext"/>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\NV.Templates.Backend.Core\NV.Templates.Backend.Core.csproj" />
Expand Down
23 changes: 23 additions & 0 deletions src/Content/Backend/NV.Templates.Backend.Functions/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using Microsoft.Azure.Functions.Worker;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

var host = new HostBuilder()
.ConfigureFunctionsWebApplication()
.ConfigureServices(services =>
{
var rootProjectPath = Path.GetFullPath(Path.Combine("..", "..", "..", ".."));
var hostingEnvironment = services.BuildServiceProvider().GetService<IHostEnvironment>();
var configuration = new ConfigurationBuilder()
.AddLocalSettings(rootProjectPath)
.AddAzureKeyVaultWhenPresent(hostingEnvironment!)
.AddEnvironmentVariables()
.AddUserSecrets<Program>(true)
.Build();
services.AddSingleton(configuration);
services.AddCore(configuration);
})
.Build();

await host.RunAsync();
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"profiles": {
"NV.Templates.Backend.Functions": {
"commandName": "Project",
"commandLineArgs": "--port 7096",
"launchBrowser": false
}
}
}
Loading

0 comments on commit 37c4807

Please sign in to comment.