Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update app-lib-dotnet to multi-target dotnet6 and dotnet8 with c# 12 #342

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,17 @@ jobs:
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

steps:
# The following step is required in order to use .NET 8 pre-release.
# We can remove if using an officially supported .NET version.
# See https://github.com/github/codeql-action/issues/757#issuecomment-977546999
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
6.0.x
8.0.x
include-prerelease: true

- name: Checkout repository
uses: actions/checkout@v4

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dotnet-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
with:
dotnet-version: |
6.0.x
5.0.x
8.0.x
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
with:
dotnet-version: |
6.0.x
8.0.x
- name: Install deps
run: |
dotnet restore
Expand Down Expand Up @@ -49,6 +50,7 @@ jobs:
with:
dotnet-version: |
6.0.x
8.0.x
- name: Build bundles
run: |
make bundles
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-and-analyze-fork.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
with:
dotnet-version: |
6.0.x
5.0.x
8.0.x
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-and-analyze.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
with:
dotnet-version: |
6.0.x
5.0.x
8.0.x
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
Expand Down
7 changes: 5 additions & 2 deletions src/Altinn.App.Api/Altinn.App.Api.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFrameworks>net6.0</TargetFrameworks>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<OutputType>Library</OutputType>
<PackageId>Altinn.App.Api</PackageId>
<PackageTags>Altinn;Studio;App;Api;Controllers</PackageTags>
Expand All @@ -22,7 +22,7 @@
<ItemGroup>
<PackageReference Include="Altinn.Common.PEP" Version="1.3.0" />
<PackageReference Include="Altinn.Platform.Storage.Interface" Version="3.24.0" />
<PackageReference Include="Microsoft.FeatureManagement.AspNetCore" Version="3.0.0-preview" />
<PackageReference Include="Microsoft.FeatureManagement.AspNetCore" Version="3.0.0" />
</ItemGroup>

<ItemGroup Condition="'$(Configuration)'=='Debug'">
Expand All @@ -47,5 +47,8 @@
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>$(NoWarn);1591</NoWarn>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)'=='net6.0'">
<NoWarn>$(NoWarn);8618</NoWarn>
</PropertyGroup>

</Project>
9 changes: 7 additions & 2 deletions src/Altinn.App.Core/Altinn.App.Core.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)'=='net6.0'">
<NoWarn>$(NoWarn);8618</NoWarn>
</PropertyGroup>

<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>
Expand All @@ -18,7 +23,7 @@
<PackageReference Include="JWTCookieAuthentication" Version="3.0.1" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.21.0" />
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.9" />
<PackageReference Include="Microsoft.FeatureManagement.AspNetCore" Version="3.0.0-preview" />
<PackageReference Include="Microsoft.FeatureManagement.AspNetCore" Version="3.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Scrutor" Version="4.2.2" />
<PackageReference Include="prometheus-net" Version="8.0.0" />
Expand Down
18 changes: 18 additions & 0 deletions src/Altinn.App.Core/Helpers/RequiredNet6Hacks.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// This file is a hack for required properties to work in net6.0
// Should be removed when support for targeting net6.0 is removed

#if NET6_0
#pragma warning disable
namespace System.Runtime.CompilerServices;

[AttributeUsage(AttributeTargets.Property)]
public class RequiredMemberAttribute : Attribute { }

[AttributeUsage(AttributeTargets.All)]
public class CompilerFeatureRequiredAttribute : Attribute
{
public CompilerFeatureRequiredAttribute(string name) { }
}
[System.AttributeUsage(System.AttributeTargets.Constructor, AllowMultiple = false, Inherited = false)]
public sealed class SetsRequiredMembersAttribute : Attribute { }
#endif
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<MinVerDefaultPreReleaseIdentifiers>preview.0</MinVerDefaultPreReleaseIdentifiers>
<MinVerTagPrefix>v</MinVerTagPrefix>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<LangVersion>10.0</LangVersion>
<LangVersion>12</LangVersion>
</PropertyGroup>

<Target Name="AssemblyVersionTarget" AfterTargets="MinVer" Condition="'$(MinVerVersion)'!='' AND '$(BuildNumber)' != ''">
Expand Down
2 changes: 1 addition & 1 deletion test/Altinn.App.Api.Tests/Altinn.App.Api.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0</TargetFrameworks>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<IsPackable>false</IsPackable>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
Expand Down
4 changes: 2 additions & 2 deletions test/Altinn.App.Core.Tests/Altinn.App.Core.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0</TargetFrameworks>
<TargetFramework>net8.0</TargetFramework>

<IsPackable>false</IsPackable>

Expand Down Expand Up @@ -42,7 +42,7 @@

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="Microsoft.FeatureManagement.AspNetCore" Version="3.0.0-preview" />
<PackageReference Include="Microsoft.FeatureManagement.AspNetCore" Version="3.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="Moq" Version="4.20.69" />
<PackageReference Include="xunit" Version="2.5.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public async Task GetFeatures_returns_list_of_enabled_features_when_feature_flag
{ "jsonObjectInDataResponse", true },
};
var featureManagerMock = new Mock<IFeatureManager>();
featureManagerMock.Setup(f => f.IsEnabledAsync(FeatureFlags.JsonObjectInDataResponse, default)).ReturnsAsync(true);
featureManagerMock.Setup(f => f.IsEnabledAsync(FeatureFlags.JsonObjectInDataResponse)).ReturnsAsync(true);
IFrontendFeatures frontendFeatures = new FrontendFeatures(featureManagerMock.Object);
var actual = await frontendFeatures.GetFrontendFeatures();
actual.Should().BeEquivalentTo(expected);
Expand Down
Loading