Skip to content

Commit 0fba930

Browse files
authored
build: build projects using dotnet 8.0. (#38)
- Update all projects' target framework in `.NET8.0` (from `standard2.0`) - Update all projects' C# version to 12 (from 10) - Updated NuGet packages - Fixes for compilation: 1. `ConcertoConverter.deserializeWithGenericType` chose the wrong overloaded method. Added expected parameters to choose the correct method. 2. Added `Decorator.cs` to declare the existence of `AccordProject.Concerto.Decorator` namespace, because the code generation script added `using AccordProject.Concerto.Decorator` for some reason and the compilation failed. Signed-off-by: Yuval Bavli <[email protected]>
1 parent 45113ce commit 0fba930

File tree

11 files changed

+46
-28
lines changed

11 files changed

+46
-28
lines changed

AccordProject.Concerto.Tests/AccordProject.Concerto.Tests.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFramework>net8.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
7-
<LangVersion>10</LangVersion>
7+
<LangVersion>12</LangVersion>
88
<IsPackable>false</IsPackable>
99
</PropertyGroup>
1010

1111
<ItemGroup>
1212
<PackageReference Include="ExpectedObjects" Version="3.5.4" />
13-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
13+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
1414
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
15-
<PackageReference Include="xunit" Version="2.6.2" />
16-
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.4">
15+
<PackageReference Include="xunit" Version="2.9.3" />
16+
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.2">
1717
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1818
<PrivateAssets>all</PrivateAssets>
1919
</PackageReference>

AccordProject.Concerto.Validate.Tests/AccordProject.Concerto.Validate.Tests.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFramework>net8.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77

@@ -10,9 +10,9 @@
1010
</PropertyGroup>
1111

1212
<ItemGroup>
13-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.1" />
14-
<PackageReference Include="xunit" Version="2.4.2" />
15-
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
13+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
14+
<PackageReference Include="xunit" Version="2.9.3" />
15+
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.2">
1616
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1717
<PrivateAssets>all</PrivateAssets>
1818
</PackageReference>

AccordProject.Concerto.Validate/AccordProject.Concerto.Validate.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netstandard2.0</TargetFramework>
4+
<TargetFramework>net8.0</TargetFramework>
55
</PropertyGroup>
66
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
7-
<LangVersion>10.0</LangVersion>
7+
<LangVersion>12.0</LangVersion>
88
</PropertyGroup>
99
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
10-
<LangVersion>10.0</LangVersion>
10+
<LangVersion>12.0</LangVersion>
1111
</PropertyGroup>
1212
<Target Name="WebPack" BeforeTargets="CoreCompile" DependsOnTargets="PrepareForBuild">
1313
<Exec Command="npm run build" WorkingDirectory="./concerto-validate" />

AccordProject.Concerto.Validate/concerto-validate/package-lock.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

AccordProject.Concerto/AccordProject.Concerto.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netstandard2.0</TargetFramework>
4+
<TargetFramework>net8.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77
<PublishRepositoryUrl>true</PublishRepositoryUrl>
88
<EmbedUntrackedSources>true</EmbedUntrackedSources>
99
<IncludeSymbols>true</IncludeSymbols>
1010
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
11-
<LangVersion>10</LangVersion>
11+
<LangVersion>12</LangVersion>
1212
</PropertyGroup>
1313

1414
<ItemGroup>

AccordProject.Concerto/ConcertoMetamodelTypes.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,16 @@ public class LongDomainValidator : Concept {
431431
[Newtonsoft.Json.JsonProperty("upper")]
432432
public long? Upper { get; set; }
433433
}
434+
[AccordProject.Concerto.Type(Namespace = "concerto.metamodel", Version = "1.0.0", Name = "AliasedType")]
435+
[Newtonsoft.Json.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterNewtonsoft))]
436+
public class AliasedType : Concept {
437+
[Newtonsoft.Json.JsonProperty("$class")]
438+
public override string _Class { get; } = "[email protected]";
439+
[Newtonsoft.Json.JsonProperty("name")]
440+
public string Name { get; set; }
441+
[Newtonsoft.Json.JsonProperty("aliasedName")]
442+
public string AliasedName { get; set; }
443+
}
434444
[AccordProject.Concerto.Type(Namespace = "concerto.metamodel", Version = "1.0.0", Name = "Import")]
435445
[Newtonsoft.Json.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterNewtonsoft))]
436446
public abstract class Import : Concept {
@@ -462,6 +472,8 @@ public class ImportTypes : Import {
462472
public override string _Class { get; } = "[email protected]";
463473
[Newtonsoft.Json.JsonProperty("types")]
464474
public string[] Types { get; set; }
475+
[Newtonsoft.Json.JsonProperty("aliasedTypes")]
476+
public AliasedType?[] AliasedTypes { get; set; }
465477
}
466478
[AccordProject.Concerto.Type(Namespace = "concerto.metamodel", Version = "1.0.0", Name = "Model")]
467479
[Newtonsoft.Json.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterNewtonsoft))]

AccordProject.Concerto/ConcertoTypes.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
*/
1414

1515
namespace AccordProject.Concerto;
16+
using Concerto.Decorator;
1617
[AccordProject.Concerto.Type(Namespace = "concerto", Version = "1.0.0", Name = "Concept")]
1718
[Newtonsoft.Json.JsonConverter(typeof(AccordProject.Concerto.ConcertoConverterNewtonsoft))]
1819
public abstract class Concept {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
namespace AccordProject.Concerto.Decorator;

ConcertoJsonConverter.Tests/ConcertoJsonConverter.Tests.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFramework>net8.0</TargetFramework>
55
<Nullable>enable</Nullable>
66

77
<IsPackable>false</IsPackable>
8-
<LangVersion>10</LangVersion>
8+
<LangVersion>12</LangVersion>
99
</PropertyGroup>
1010

1111
<ItemGroup>
1212
<PackageReference Include="ExpectedObjects" Version="3.5.4" />
13-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
14-
<PackageReference Include="xunit" Version="2.4.1" />
15-
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
13+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
14+
<PackageReference Include="xunit" Version="2.9.3" />
15+
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.2">
1616
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1717
<PrivateAssets>all</PrivateAssets>
1818
</PackageReference>

ConcertoJsonConverter/ConcertoConverter.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
*/
1414

1515
using System;
16+
using System.Collections.Generic;
17+
using System.Linq;
18+
using System.Reflection;
1619
using System.Text.Json;
1720
using System.Text.Json.Serialization;
18-
using System.Reflection;
19-
using System.Linq;
20-
using System.Collections.Generic;
2121
using Concerto.Models.concerto;
2222

2323
namespace Concerto.Serialization;
@@ -62,9 +62,12 @@ public ConcertoJsonConverter(){
6262

6363
private object deserializeWithGenericType(Type type, String rawText, object options)
6464
{
65-
MethodInfo method = typeof(JsonSerializer).GetMethods()
65+
string[] expectedTypes = [typeof(string).FullName, typeof(JsonSerializerOptions).FullName];
66+
var method = typeof(JsonSerializer).GetMethods()
6667
.Where(x => x.Name == nameof(JsonSerializer.Deserialize))
67-
.FirstOrDefault(x => x.IsGenericMethod);
68+
.FirstOrDefault(
69+
x => x.IsGenericMethod && x.GetParameters().Select(p => p.ParameterType.FullName)
70+
.SequenceEqual(expectedTypes));
6871
return method.MakeGenericMethod(type).Invoke(null, new object[] { rawText, options});
6972
}
7073

0 commit comments

Comments
 (0)