Skip to content

Commit

Permalink
feat: support for Roslyn 4.7
Browse files Browse the repository at this point in the history
  • Loading branch information
latonz committed Sep 13, 2023
1 parent 1fed304 commit 2233d21
Show file tree
Hide file tree
Showing 18 changed files with 41 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
name: ${{ matrix.BENCHMARK_NAME }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v3.2.0
- uses: actions/setup-dotnet@v3
- name: Run ${{ matrix.BENCHMARK_NAME }}
working-directory: ${{ env.BENCHMARKS_PATH }}
run: dotnet run --exporters json --configuration Release --filter '*${{ matrix.BENCHMARK_NAME }}*'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/code-ql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ jobs:
- uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
- uses: actions/setup-dotnet@v3.2.0
- uses: actions/setup-dotnet@v3
- run: dotnet build
- uses: github/codeql-action/analyze@v2
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: actions/configure-pages@v3
- uses: actions/setup-dotnet@v3.2.0
- uses: actions/setup-dotnet@v3
- run: dotnet tool restore
- run: dotnet build
- uses: actions/setup-node@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v3.2.0
- uses: actions/setup-dotnet@v3
- run: dotnet tool restore
- run: dotnet csharpier --check .
# don't run dotnet format for whitespace formatting as this is done by csharpier
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ on:
description: 'The created version'
value: ${{ jobs.release.outputs.version }}

env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
DOTNET_NOLOGO: true

jobs:
release:
runs-on: ubuntu-latest
Expand All @@ -28,7 +32,7 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-dotnet@v3.2.0
- uses: actions/setup-dotnet@v3
- uses: actions/setup-node@v3
with:
node-version: '18'
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v3.2.0
- uses: actions/setup-dotnet@v3
- run: dotnet run --project ./samples/Riok.Mapperly.Sample
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v3.2.0
- uses: actions/setup-dotnet@v3
- run: dotnet build /p:TreatWarningsAsErrors=true
- run: dotnet test --no-build /p:CollectCoverage=true /p:CoverletOutputFormat=opencover
- uses: codecov/codecov-action@v3
Expand All @@ -39,7 +39,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- run: sudo apt update && sudo apt -y install zipmerge # zipmerge is used to merge the multi target nupkg
- uses: actions/setup-dotnet@v3.2.0
- uses: actions/setup-dotnet@v3
- run: dotnet tool restore
- run: RELEASE_VERSION="0.0.1-dev.$GITHUB_RUN_ID" ./build/package.sh
- uses: actions/upload-artifact@v3
Expand All @@ -56,7 +56,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v3.2.0
- uses: actions/setup-dotnet@v3
- run: dotnet tool restore
- uses: actions/download-artifact@v3
with:
Expand Down Expand Up @@ -84,7 +84,7 @@ jobs:
- run: apk add --no-cache bash icu-libs krb5-libs libgcc libintl libssl1.1 libstdc++ zlib
# delete global.json since we want to use custom versions here
- run: rm global.json
- uses: actions/setup-dotnet@v3.2.0
- uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ matrix.dotnet }}
- run: dotnet --list-sdks
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<DebugSymbols>true</DebugSymbols>
<DebugType>embedded</DebugType>
<Nullable>enable</Nullable>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.8" />
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.Common" Version="4.6.0" />
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="4.6.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.6.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.6.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.6.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.Common" Version="4.7.0" />
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="4.7.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.7.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.7.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.7.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4" PrivateAssets="all" />
<PackageReference Include="Microsoft.Build.Locator" Version="1.6.1" />
<PackageReference Include="NuGet.Frameworks" Version="6.7.0" />
Expand Down
2 changes: 1 addition & 1 deletion build/package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -Eeuo pipefail
# pack a nupkg for each roslyn version that is supported by Mapperly
# and merge them together into one nupkg

roslyn_versions=('4.0' '4.4' '4.5')
roslyn_versions=('4.0' '4.4' '4.5' '4.7')

RELEASE_VERSION=${RELEASE_VERSION:-"0.0.1-dev.$(date +%s)"}
RELEASE_NOTES=${RELEASE_NOTES:-''}
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/configuration/generated-source.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ dotnet build /p:EmitCompilerGeneratedFiles=true
</Tabs>

By default the files are written to `{BaseIntermediateOutpath}/generated/{Assembly}/Riok.Mapperly/{GeneratedFile}`.
With `BaseIntermediateOutpath` for example being `obj/Debug/net7.0`.
With `BaseIntermediateOutpath` for example being `obj/Debug/net8.0`.

The output path can be customized via the `CompilerGeneratedFilesOutputPath` property.
This can be used to check the generated files into VCS.
Expand Down
2 changes: 1 addition & 1 deletion docs/prebuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ async function buildSamples(): Promise<void> {
const projectFilesToCopy = ['CarMapper.cs', 'Car.cs', 'CarDto.cs'];
const generatedMapperFile = join(
sampleProject,
'obj/Debug/net7.0/generated/Riok.Mapperly/Riok.Mapperly.MapperGenerator/CarMapper.g.cs',
'obj/Debug/net8.0/generated/Riok.Mapperly/Riok.Mapperly.MapperGenerator/CarMapper.g.cs',
);

// Copy generated mapper to target dir
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "7.0.200",
"version": "8.0.100-rc.1.23455.8",
"rollForward": "latestPatch"
}
}
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
(a lot of features get polyfilled by Meziantou.Polyfill)
however we need to be careful with the available features!
-->
<LangVersion>11</LangVersion>
<LangVersion>preview</LangVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,4 @@ public interface IDelegateUserMapping : IUserMapping
/// Gets the delegate mapping or <c>null</c> if none is set (yet).
/// </summary>
INewInstanceMapping? DelegateMapping { get; }

/// <summary>
/// Sets the delegate mapping.
/// </summary>
/// <param name="mapping">The mapping.</param>
void SetDelegateMapping(INewInstanceMapping mapping);
}
11 changes: 11 additions & 0 deletions src/Riok.Mapperly/Riok.Mapperly.Roslyn4.7.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Project>

<PropertyGroup>
<DefineConstants>$(DefineConstants);ROSLYN4_4_OR_GREATER</DefineConstants>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.7.0" PrivateAssets="all" />
</ItemGroup>

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

<PropertyGroup>
<!-- setting the TargetFramework directly from the cli via -p:TargetFramework=netA.B does not work using a custom msbuild property seems to work -->
<MapperlyIntegrationTestsTargetFramework Condition="'$(MapperlyIntegrationTestsTargetFramework)' == ''">net7.0</MapperlyIntegrationTestsTargetFramework>
<MapperlyIntegrationTestsTargetFramework Condition="'$(MapperlyIntegrationTestsTargetFramework)' == ''">net8.0</MapperlyIntegrationTestsTargetFramework>
<TargetFramework>$(MapperlyIntegrationTestsTargetFramework)</TargetFramework>

<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
Expand All @@ -11,6 +11,8 @@
<!-- Not supported in .NET Framework -->
<ImplicitUsings>disable</ImplicitUsings>

<LangVersion>preview</LangVersion>

<!-- .NET Framework 4.8 defaults to lang version 7.3, but we want to test nullable features. These are available in 8.0.
To also use init-only properties, we upgrade to lang version 9.0, which is works, but is not officially supported. -->
<LangVersion Condition="'$(TargetFramework)' == 'net48'">9.0</LangVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class PreserveReferenceHandlerTest
[Fact]
public void EmptyReferenceHandlerShouldReturnFalse()
{
_handler.TryGetReference(new MyObj(), out MyDto _).Should().BeFalse();
_handler.TryGetReference(new MyObj(), out MyDto? _).Should().BeFalse();
}

[Fact]
Expand Down
2 changes: 1 addition & 1 deletion test/Riok.Mapperly.Tests/Riok.Mapperly.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.5.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.7.0" />
<PackageReference Include="Verify.SourceGenerators" Version="2.1.0" />
</ItemGroup>

Expand Down

0 comments on commit 2233d21

Please sign in to comment.