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

feat: support csharp 12 #9208

Merged
merged 2 commits into from
Sep 18, 2023
Merged
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
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,20 @@ jobs:
if: matrix.os == 'windows-latest'

- run: dotnet test -c Release -f net8.0 --no-build --collect:"XPlat Code Coverage"
if: matrix.os == 'ubuntu-latest'

- run: dotnet test -c Release -f net7.0 --no-build --collect:"XPlat Code Coverage"
if: matrix.os == 'ubuntu-latest'

- run: dotnet test -c Release -f net6.0 --no-build --collect:"XPlat Code Coverage"
if: matrix.os == 'ubuntu-latest'

- uses: codecov/codecov-action@v3
if: matrix.os == 'ubuntu-latest'

- run: dotnet run -c Release --no-build -f net7.0 --project src/docfx -- docs/docfx.json
- run: dotnet run -c Release --no-build -f net8.0 --project src/docfx -- docs/docfx.json

- run: dotnet run -c Release --no-build -f net7.0 --project src/docfx -- metadata samples/seed/docfx.json
- run: dotnet run -c Release --no-build -f net7.0 --project src/docfx -- build samples/seed/docfx.json --output docs/_site/seed
- run: dotnet run -c Release --no-build -f net8.0 --project src/docfx -- metadata samples/seed/docfx.json
- run: dotnet run -c Release --no-build -f net8.0 --project src/docfx -- build samples/seed/docfx.json --output docs/_site/seed

- uses: actions/upload-artifact@v3
if: matrix.os == 'ubuntu-latest'
Expand All @@ -64,7 +64,7 @@ jobs:
- uses: ./.github/actions/build

- run: dotnet build -c Release samples/extensions/build
- run: dotnet test -c Release -f net7.0 --no-build --filter Stage=Snapshot
- run: dotnet test -c Release -f net8.0 --no-build --filter Stage=Snapshot
working-directory: test/docfx.Snapshot.Tests
env:
SNAPSHOT_TEST: true
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ jobs:

- name: dotnet publish
run: |
dotnet publish src/docfx -f net7.0 -c Release /p:Version=${GITHUB_REF_NAME#v} --self-contained -r win-x64 -o drop/publish/win-x64
dotnet publish src/docfx -f net7.0 -c Release /p:Version=${GITHUB_REF_NAME#v} --self-contained -r linux-x64 -o drop/publish/linux-x64
dotnet publish src/docfx -f net7.0 -c Release /p:Version=${GITHUB_REF_NAME#v} --self-contained -r osx-x64 -o drop/publish/osx-x64
dotnet publish src/docfx -f net8.0 -c Release /p:Version=${GITHUB_REF_NAME#v} --self-contained -r win-x64 -o drop/publish/win-x64
dotnet publish src/docfx -f net8.0 -c Release /p:Version=${GITHUB_REF_NAME#v} --self-contained -r linux-x64 -o drop/publish/linux-x64
dotnet publish src/docfx -f net8.0 -c Release /p:Version=${GITHUB_REF_NAME#v} --self-contained -r osx-x64 -o drop/publish/osx-x64
mkdir -p drop/bin

- run: zip -r ../../bin/docfx-win-x64-${GITHUB_REF_NAME}.zip .
Expand Down
3 changes: 2 additions & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
<PackageVersion Include="Magick.NET-Q16-AnyCPU" Version="13.2.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.7.1" />
<PackageVersion Include="Microsoft.Playwright" Version="1.37.1" />
<PackageVersion Include="NuGet.Frameworks" Version="6.7.0" />
<PackageVersion Include="NuGet.Frameworks" Version="6.7.0" Condition="'$(TargetFramework)' != 'net8.0'" />
<PackageVersion Include="NuGet.Frameworks" Version="6.8.0-rc.112" Condition="'$(TargetFramework)' == 'net8.0'" />
<PackageVersion Include="Verify.DiffPlex" Version="2.2.1" />
<PackageVersion Include="Verify.Xunit" Version="21.1.3" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.5.0" />
Expand Down
5 changes: 0 additions & 5 deletions NuGet.config
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,4 @@
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
<add key="dotnet-tools" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json" />
</packageSources>
<packageSourceMapping>
<packageSource key="nuget.org">
<package pattern="*" />
</packageSource>
</packageSourceMapping>
</configuration>
4 changes: 2 additions & 2 deletions samples/csharp/src/CSharp.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net7.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
<TargetFrameworks>net8.0</TargetFrameworks>
<LangVersion>preview</LangVersion>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
Expand Down
78 changes: 78 additions & 0 deletions samples/csharp/src/CSharp12.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
namespace CSharp12;

using Markdown = string;

public class PrimaryConstructors
{
public readonly struct Distance(double dx, double dy)
{
public readonly double Magnitude = Math.Sqrt(dx * dx + dy * dy);
public readonly double Direction = Math.Atan2(dy, dx);
}

public class BankAccount(string accountID, string owner)
{
public string AccountID { get; } = accountID;
public string Owner { get; } = owner;

public override string ToString() => $"Account ID: {AccountID}, Owner: {Owner}";
}

public class CheckAccount(string accountID, string owner, decimal overdraftLimit = 0) : BankAccount(accountID, owner)
{
public decimal CurrentBalance { get; private set; } = 0;

public void Deposit(decimal amount)
{
if (amount < 0)
{
throw new ArgumentOutOfRangeException(nameof(amount), "Deposit amount must be positive");
}
CurrentBalance += amount;
}

public void Withdrawal(decimal amount)
{
if (amount < 0)
{
throw new ArgumentOutOfRangeException(nameof(amount), "Withdrawal amount must be positive");
}
if (CurrentBalance - amount < -overdraftLimit)
{
throw new InvalidOperationException("Insufficient funds for withdrawal");
}
CurrentBalance -= amount;
}

public override string ToString() => $"Account ID: {AccountID}, Owner: {Owner}, Balance: {CurrentBalance}";
}
}

public class CollectionExpressions
{
public static int[] a = [1, 2, 3, 4, 5, 6, 7, 8];

public static Span<int> b => ['a', 'b', 'c', 'd', 'e', 'f', 'h', 'i'];

public static int[][] twoD = [[1, 2, 3], [4, 5, 6], [7, 8, 9]];
}

public class DefaultLambdaParameters
{
public void Foo()
{
var addWithDefault = (int addTo = 2) => addTo + 1;
addWithDefault(); // 3
addWithDefault(5); // 6

var counter = (params int[] xs) => xs.Length;
counter(); // 0
counter(1, 2, 3); // 3
}
}

[System.Runtime.CompilerServices.InlineArray(10)]
public struct InlineArrays
{
private int _element0;
}
Loading