Skip to content

Commit

Permalink
Supporting c# 12 (#916)
Browse files Browse the repository at this point in the history
* Supporting C# 12

closes #883

* Getting actions working
  • Loading branch information
belav authored Jun 24, 2023
1 parent f54a490 commit 0a82045
Show file tree
Hide file tree
Showing 17 changed files with 78 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/format_repositories.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
path: csharpier
- uses: actions/setup-dotnet@v1
with:
dotnet-version: '7.0.100'
dotnet-version: '7.0.304'
- uses: actions/checkout@v2
with:
repository: belav/csharpier-repos
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish_nuget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- uses: actions/setup-dotnet@v1
with:
dotnet-version: |
7.0.100
7.0.304
6.0.300
- run: dotnet test Src/CSharpier.Tests/CSharpier.Tests.csproj
publish-nuget:
Expand All @@ -26,7 +26,7 @@ jobs:
- uses: actions/setup-dotnet@v1
with:
dotnet-version: |
7.0.100
7.0.304
6.0.300
- name: Publish CSharpier.Core library on version change
uses: alirezanet/[email protected]
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/validate_pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- uses: actions/setup-dotnet@v1
with:
dotnet-version: |
7.0.100
7.0.304
6.0.300
- run: |
dotnet build CSharpier.sln -c release
Expand All @@ -24,7 +24,7 @@ jobs:
- uses: actions/setup-dotnet@v1
with:
dotnet-version: |
7.0.100
7.0.304
6.0.300
- run: |
dotnet tool restore
Expand All @@ -37,7 +37,7 @@ jobs:
- uses: actions/setup-dotnet@v1
with:
dotnet-version: |
7.0.100
7.0.304
6.0.300
- run: |
dotnet build Src/CSharpier.MsBuild/CSharpier.MsBuild.csproj
8 changes: 4 additions & 4 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@
<PackageVersion Include="FluentAssertions" Version="5.10.3" />
<PackageVersion Include="Ignore" Version="0.1.42" />
<PackageVersion Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="5.0.1" />
<PackageVersion Include="Microsoft.CodeAnalysis.Common" Version="4.4.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.4.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Common" Version="4.6.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.6.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" Version="3.3.4" />
<PackageVersion Include="Microsoft.CSharp" Version="4.5.0" />
<PackageVersion Include="Microsoft.Extensions.Logging" Version="5.0.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
<PackageVersion Include="NUnit" Version="3.12.0" />
<PackageVersion Include="NUnit3TestAdapter" Version="4.0.0" />
<PackageVersion Include="PolySharp" Version="1.13.1" />
<PackageVersion Include="Scriban" Version="4.0.1" />
<PackageVersion Include="Scriban" Version="5.7.0" />
<PackageVersion Include="Serilog.Extensions.Logging.File" Version="2.0.0" />
<PackageVersion Include="System.CommandLine" Version="2.0.0-beta1.21308.1" />
<PackageVersion Include="System.IO.Abstractions" Version="13.2.29" />
<PackageVersion Include="System.IO.Abstractions.TestingHelpers" Version="13.2.29" />
<PackageVersion Include="System.IO.Hashing" Version="7.0.0-preview.7.22375.6" />
<PackageVersion Include="System.Text.Encoding.CodePages" Version="6.0.0" />
<PackageVersion Include="System.Text.Encoding.CodePages" Version="7.0.0" />
<PackageVersion Include="System.Text.Json" Version="7.0.0" />
<PackageVersion Include="System.Threading.Tasks.Extensions" Version="4.5.4" />
<PackageVersion Include="YamlDotNet" Version="11.1.1" />
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
WORKDIR /app
EXPOSE 80

FROM mcr.microsoft.com/dotnet/sdk:7.0.100 AS build
FROM mcr.microsoft.com/dotnet/sdk:7.0.304 AS build

RUN apt-get update && \
apt-get install curl gnupg -yq && \
Expand Down
4 changes: 2 additions & 2 deletions Src/CSharpier.FakeGenerators/CSharpier.FakeGenerators.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<OutputType>Exe</OutputType>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.Common"/>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp"/>
<PackageReference Include="Microsoft.CodeAnalysis.Common" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" />
</ItemGroup>
</Project>
1 change: 1 addition & 0 deletions Src/CSharpier.Generators/CSharpier.Generators.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<PropertyGroup>
<TargetFrameworks>net6.0;net7.0;netstandard2.0</TargetFrameworks>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
<PackageScribanIncludeSource>true</PackageScribanIncludeSource>
<LangVersion>10</LangVersion>
<NoWarn>SYSLIB0013</NoWarn>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
<PropertyGroup>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<PackageScribanIncludeSource>true</PackageScribanIncludeSource>
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
<NoWarn>SYSLIB0013</NoWarn>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.Common"/>
<PackageReference Include="Scriban" IncludeAssets="Build"/>
<PackageReference Include="Microsoft.CodeAnalysis.Common" />
<PackageReference Include="Scriban" IncludeAssets="Build" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="@(None -&gt; WithMetadataValue('Extension', '.sbntxt'))"/>
<EmbeddedResource Include="@(None -&gt; WithMetadataValue('Extension', '.sbntxt'))" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\CSharpier.Generators\TemplatedGenerator.cs">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,17 @@ public class IdentityDbContext<TUser, TRole, TKey>
where TKey : IEquatable<TKey> { }

file class FileScopedType { }

public class NamedItem(string name)
{
public string Name => name;
}

public class NamedItem2(
string name1________________________________,
string name2________________________________
)
{
public string Name1 => name1;
public string Name2 => name1;
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ static // static trailing
Third;

using M = System.Math;
using Point = (int x, int y);

using static System.Math;

Expand Down
2 changes: 1 addition & 1 deletion Src/CSharpier/CSharpier.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="../../Nuget/Build.props"/>
<Import Project="../../Nuget/Build.props" />
<PropertyGroup>
<PackageId>CSharpier.Core</PackageId>
<TargetFrameworks>net6.0;net7.0;netstandard2.0</TargetFrameworks>
Expand Down
10 changes: 10 additions & 0 deletions Src/CSharpier/SyntaxNodeComparer.generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1023,6 +1023,8 @@ private CompareResult CompareClassDeclarationSyntax(ClassDeclarationSyntax origi
if (result.IsInvalid) return result;
result = this.Compare(originalNode.OpenBraceToken, formattedNode.OpenBraceToken, originalNode, formattedNode);
if (result.IsInvalid) return result;
originalStack.Push((originalNode.ParameterList, originalNode));
formattedStack.Push((formattedNode.ParameterList, formattedNode));
result = this.Compare(originalNode.SemicolonToken, formattedNode.SemicolonToken, originalNode, formattedNode);
if (result.IsInvalid) return result;
originalStack.Push((originalNode.TypeParameterList, originalNode));
Expand Down Expand Up @@ -2130,6 +2132,8 @@ private CompareResult CompareInterfaceDeclarationSyntax(InterfaceDeclarationSynt
if (result.IsInvalid) return result;
result = this.Compare(originalNode.OpenBraceToken, formattedNode.OpenBraceToken, originalNode, formattedNode);
if (result.IsInvalid) return result;
originalStack.Push((originalNode.ParameterList, originalNode));
formattedStack.Push((formattedNode.ParameterList, formattedNode));
result = this.Compare(originalNode.SemicolonToken, formattedNode.SemicolonToken, originalNode, formattedNode);
if (result.IsInvalid) return result;
originalStack.Push((originalNode.TypeParameterList, originalNode));
Expand Down Expand Up @@ -3325,6 +3329,8 @@ private CompareResult CompareStructDeclarationSyntax(StructDeclarationSyntax ori
if (result.IsInvalid) return result;
result = this.Compare(originalNode.OpenBraceToken, formattedNode.OpenBraceToken, originalNode, formattedNode);
if (result.IsInvalid) return result;
originalStack.Push((originalNode.ParameterList, originalNode));
formattedStack.Push((formattedNode.ParameterList, formattedNode));
result = this.Compare(originalNode.SemicolonToken, formattedNode.SemicolonToken, originalNode, formattedNode);
if (result.IsInvalid) return result;
originalStack.Push((originalNode.TypeParameterList, originalNode));
Expand Down Expand Up @@ -3641,10 +3647,14 @@ private CompareResult CompareUsingDirectiveSyntax(UsingDirectiveSyntax originalN
if (originalNode.IsMissing != formattedNode.IsMissing) return NotEqual(originalNode, formattedNode);
originalStack.Push((originalNode.Name, originalNode));
formattedStack.Push((formattedNode.Name, formattedNode));
originalStack.Push((originalNode.NamespaceOrType, originalNode));
formattedStack.Push((formattedNode.NamespaceOrType, formattedNode));
result = this.Compare(originalNode.SemicolonToken, formattedNode.SemicolonToken, originalNode, formattedNode);
if (result.IsInvalid) return result;
result = this.Compare(originalNode.StaticKeyword, formattedNode.StaticKeyword, originalNode, formattedNode);
if (result.IsInvalid) return result;
result = this.Compare(originalNode.UnsafeKeyword, formattedNode.UnsafeKeyword, originalNode, formattedNode);
if (result.IsInvalid) return result;
result = this.Compare(originalNode.UsingKeyword, formattedNode.UsingKeyword, originalNode, formattedNode);
if (result.IsInvalid) return result;
return Equal;
Expand Down
30 changes: 30 additions & 0 deletions Src/CSharpier/SyntaxNodeJsonWriter.generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1505,6 +1505,12 @@ public static void WriteClassDeclarationSyntax(StringBuilder builder, ClassDecla
WriteSyntaxToken(openBraceTokenBuilder, syntaxNode.OpenBraceToken);
properties.Add($"\"openBraceToken\":{openBraceTokenBuilder.ToString()}");
}
if (syntaxNode.ParameterList != default(ParameterListSyntax))
{
var parameterListBuilder = new StringBuilder();
WriteParameterListSyntax(parameterListBuilder, syntaxNode.ParameterList);
properties.Add($"\"parameterList\":{parameterListBuilder.ToString()}");
}
if (syntaxNode.SemicolonToken != default(SyntaxToken))
{
var semicolonTokenBuilder = new StringBuilder();
Expand Down Expand Up @@ -4400,6 +4406,12 @@ public static void WriteInterfaceDeclarationSyntax(StringBuilder builder, Interf
WriteSyntaxToken(openBraceTokenBuilder, syntaxNode.OpenBraceToken);
properties.Add($"\"openBraceToken\":{openBraceTokenBuilder.ToString()}");
}
if (syntaxNode.ParameterList != default(ParameterListSyntax))
{
var parameterListBuilder = new StringBuilder();
WriteParameterListSyntax(parameterListBuilder, syntaxNode.ParameterList);
properties.Add($"\"parameterList\":{parameterListBuilder.ToString()}");
}
if (syntaxNode.SemicolonToken != default(SyntaxToken))
{
var semicolonTokenBuilder = new StringBuilder();
Expand Down Expand Up @@ -7465,6 +7477,12 @@ public static void WriteStructDeclarationSyntax(StringBuilder builder, StructDec
WriteSyntaxToken(openBraceTokenBuilder, syntaxNode.OpenBraceToken);
properties.Add($"\"openBraceToken\":{openBraceTokenBuilder.ToString()}");
}
if (syntaxNode.ParameterList != default(ParameterListSyntax))
{
var parameterListBuilder = new StringBuilder();
WriteParameterListSyntax(parameterListBuilder, syntaxNode.ParameterList);
properties.Add($"\"parameterList\":{parameterListBuilder.ToString()}");
}
if (syntaxNode.SemicolonToken != default(SyntaxToken))
{
var semicolonTokenBuilder = new StringBuilder();
Expand Down Expand Up @@ -8251,6 +8269,12 @@ public static void WriteUsingDirectiveSyntax(StringBuilder builder, UsingDirecti
WriteSyntaxNode(nameBuilder, syntaxNode.Name);
properties.Add($"\"name\":{nameBuilder.ToString()}");
}
if (syntaxNode.NamespaceOrType != default(TypeSyntax))
{
var namespaceOrTypeBuilder = new StringBuilder();
WriteSyntaxNode(namespaceOrTypeBuilder, syntaxNode.NamespaceOrType);
properties.Add($"\"namespaceOrType\":{namespaceOrTypeBuilder.ToString()}");
}
if (syntaxNode.SemicolonToken != default(SyntaxToken))
{
var semicolonTokenBuilder = new StringBuilder();
Expand All @@ -8263,6 +8287,12 @@ public static void WriteUsingDirectiveSyntax(StringBuilder builder, UsingDirecti
WriteSyntaxToken(staticKeywordBuilder, syntaxNode.StaticKeyword);
properties.Add($"\"staticKeyword\":{staticKeywordBuilder.ToString()}");
}
if (syntaxNode.UnsafeKeyword != default(SyntaxToken))
{
var unsafeKeywordBuilder = new StringBuilder();
WriteSyntaxToken(unsafeKeywordBuilder, syntaxNode.UnsafeKeyword);
properties.Add($"\"unsafeKeyword\":{unsafeKeywordBuilder.ToString()}");
}
if (syntaxNode.UsingKeyword != default(SyntaxToken))
{
var usingKeywordBuilder = new StringBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public static Doc Print(BaseTypeDeclarationSyntax node, FormattingContext contex
if (node is ClassDeclarationSyntax classDeclarationSyntax)
{
keyword = classDeclarationSyntax.Keyword;
parameterList = classDeclarationSyntax.ParameterList;
}
else if (node is StructDeclarationSyntax structDeclarationSyntax)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public static Doc Print(
Token.PrintWithSuffix(node.UsingKeyword, " ", context),
Token.PrintWithSuffix(node.StaticKeyword, " ", context),
node.Alias == null ? Doc.Null : NameEquals.Print(node.Alias, context),
Node.Print(node.Name, context),
Node.Print(node.NamespaceOrType, context),
Token.Print(node.SemicolonToken, context)
);
}
Expand Down
2 changes: 1 addition & 1 deletion Src/SyntaxFinder/SyntaxFinder.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
<OutputType>Exe</OutputType>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp"/>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" />
</ItemGroup>
</Project>
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.100",
"version": "7.0.304",
"rollForward": "latestFeature"
}
}

0 comments on commit 0a82045

Please sign in to comment.