Skip to content

Commit

Permalink
Merge branch 'main' into badsyntax/diagnostics
Browse files Browse the repository at this point in the history
  • Loading branch information
shocklateboy92 authored Nov 20, 2024
2 parents f4ccac0 + 88e3d9b commit 78147bd
Show file tree
Hide file tree
Showing 13 changed files with 101 additions and 95 deletions.
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"csharpier": {
"version": "0.29.2",
"version": "0.30.1",
"commands": [
"dotnet-csharpier"
]
Expand Down
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# 0.30.0
# 0.30.1
## What's Changed
Revert tool command back to `dotnet-csharpier`, it was supposed to be changed to `csharpier` for 1.0.0

# 0.30.0
## Breaking Changes
The CSharpier dotnet tool no longer supports net6 & net7.
## What's Changed
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM mcr.microsoft.com/dotnet/aspnet:8.0.0-bookworm-slim-amd64 AS base
FROM mcr.microsoft.com/dotnet/aspnet:9.0.0-bookworm-slim-amd64 AS base
WORKDIR /app
ENV ASPNETCORE_URLS=http://+:80
EXPOSE 80

FROM mcr.microsoft.com/dotnet/sdk:8.0.100-bookworm-slim-amd64 AS build
FROM mcr.microsoft.com/dotnet/sdk:9.0.100-bookworm-slim-amd64 AS build

RUN set -uex \
&& apt-get update \
Expand Down
2 changes: 1 addition & 1 deletion Nuget/Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Version>0.30.0</Version>
<Version>0.30.1</Version>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<RepositoryUrl>https://github.com/belav/csharpier</RepositoryUrl>
<RepositoryType>git</RepositoryType>
Expand Down
1 change: 0 additions & 1 deletion Src/CSharpier.Cli/CSharpier.Cli.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
<AssemblyName>dotnet-csharpier</AssemblyName>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<PackAsTool>true</PackAsTool>
<ToolCommandName>csharpier</ToolCommandName>
<AssemblyOriginatorKeyFile>../../Nuget/csharpier.snk</AssemblyOriginatorKeyFile>
<RollForward>Major</RollForward>
<SignAssembly>True</SignAssembly>
Expand Down
19 changes: 9 additions & 10 deletions Src/CSharpier.Cli/EditorConfig/ConfigFileParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,15 @@ internal static class ConfigFileParser
// "Comment: starts with a ; or a #."
private static readonly Regex CommentRegex = new("^[;#].*$");

private static readonly IniParserConfiguration Configuration =
new()
{
CommentRegex = CommentRegex,
AllowDuplicateKeys = true,
AllowDuplicateSections = true,
OverrideDuplicateKeys = true,
SkipInvalidLines = true,
ThrowExceptionsOnError = false,
};
private static readonly IniParserConfiguration Configuration = new()
{
CommentRegex = CommentRegex,
AllowDuplicateKeys = true,
AllowDuplicateSections = true,
OverrideDuplicateKeys = true,
SkipInvalidLines = true,
ThrowExceptionsOnError = false,
};

public static ConfigFile Parse(string filePath, IFileSystem fileSystem)
{
Expand Down
15 changes: 7 additions & 8 deletions Src/CSharpier.Cli/EditorConfig/Globber.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ namespace CSharpier.Cli.EditorConfig;

internal static class Globber
{
private static readonly GlobMatcherOptions globOptions =
new()
{
MatchBase = true,
Dot = true,
AllowWindowsPaths = true,
AllowSingleBraceSets = true,
};
private static readonly GlobMatcherOptions globOptions = new()
{
MatchBase = true,
Dot = true,
AllowWindowsPaths = true,
AllowSingleBraceSets = true,
};

public static GlobMatcher Create(string files, string directory)
{
Expand Down
36 changes: 17 additions & 19 deletions Src/CSharpier.FakeGenerators/Ignored.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,22 @@ public static class Ignored

public static readonly Type[] Types = { typeof(TextSpan), typeof(SyntaxTree) };

public static readonly Dictionary<Type, string[]> PropertiesByType =
new()
{
{ typeof(PropertyDeclarationSyntax), new[] { "semicolon" } },
{ typeof(IndexerDeclarationSyntax), new[] { "semicolon" } },
{ typeof(SyntaxTrivia), new[] { "token" } },
{ typeof(SyntaxToken), new[] { "value", "valueText" } },
{ typeof(ParameterSyntax), new[] { "exclamationExclamationToken" } },
};
public static readonly Dictionary<Type, string[]> PropertiesByType = new()
{
{ typeof(PropertyDeclarationSyntax), new[] { "semicolon" } },
{ typeof(IndexerDeclarationSyntax), new[] { "semicolon" } },
{ typeof(SyntaxTrivia), new[] { "token" } },
{ typeof(SyntaxToken), new[] { "value", "valueText" } },
{ typeof(ParameterSyntax), new[] { "exclamationExclamationToken" } },
};

public static readonly HashSet<string> UnsupportedNodes =
new()
{
// if new versions of c# add node types, we need to ignore them in the generators
// until codeAnalysis + sdks are updated
// global.json doesn't seem to always be respected for builds (namely VS but rider started having the same problem)
// which causes the generators to generate code for the new node types
// but then the build fails because those types don't exist in the packages the actual project references
// "ListPatternSyntax", "SlicePatternSyntax"
};
public static readonly HashSet<string> UnsupportedNodes = new()
{
// if new versions of c# add node types, we need to ignore them in the generators
// until codeAnalysis + sdks are updated
// global.json doesn't seem to always be respected for builds (namely VS but rider started having the same problem)
// which causes the generators to generate code for the new node types
// but then the build fails because those types don't exist in the packages the actual project references
// "ListPatternSyntax", "SlicePatternSyntax"
};
}
4 changes: 3 additions & 1 deletion Src/CSharpier.MsBuild/build/CSharpier.MsBuild.targets
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
<CSharpier_FrameworkVersion Condition="'$(CSharpier_FrameworkVersion)' == '' and $([MSBuild]::VersionGreaterThanOrEquals($(NETCoreSdkVersion), '8.0'))">net8.0</CSharpier_FrameworkVersion>
<CSharpier_FrameworkVersion Condition="'$(CSharpier_FrameworkVersion)' == ''" Label="Fallback">net8.0</CSharpier_FrameworkVersion>
<CSharpierDllPath>$(MSBuildThisFileDirectory)../tools/csharpier/$(CSharpier_FrameworkVersion)/dotnet-csharpier.dll</CSharpierDllPath>
<CSharpier_dotnet_Path Condition="'$(CSharpier_dotnet_Path)' == ''">$(DOTNET_HOST_PATH)</CSharpier_dotnet_Path>
<CSharpier_dotnet_Path Condition="'$(CSharpier_dotnet_Path)' == ''">dotnet</CSharpier_dotnet_Path>
<CSharpierArgs Condition="'$(CSharpier_Check)' == 'true'">$(CSharpierArgs) --check</CSharpierArgs>
<CSharpierArgs Condition="'$(CSharpier_LogLevel)' != ''">$(CSharpierArgs) --loglevel $(CSharpier_LogLevel)</CSharpierArgs>
<FirstTargetFramework Condition=" '$(TargetFrameworks)' == '' ">$(TargetFramework)</FirstTargetFramework>
Expand All @@ -23,7 +25,7 @@
StdOutEncoding="utf-8"
StdErrEncoding="utf-8"
IgnoreExitCode="true"
Command="dotnet &quot;$(CSharpierDllPath)&quot; $(CSharpierArgs) --no-msbuild-check --compilation-errors-as-warnings &quot;$(MSBuildProjectDirectory)&quot; &gt; $(NullOutput) " />
Command="&quot;$(CSharpier_dotnet_Path)&quot; exec &quot;$(CSharpierDllPath)&quot; $(CSharpierArgs) --no-msbuild-check --compilation-errors-as-warnings &quot;$(MSBuildProjectDirectory)&quot; &gt; $(NullOutput) " />
</Target>

<!-- getting this to run a single time for projects that target multiple frameworks requires all of this
Expand Down
89 changes: 44 additions & 45 deletions Src/CSharpier.Tests/MissingTypeChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,49 +70,48 @@ public void Ensure_There_Are_No_Missing_Types()
missingTypes.Should().BeEmpty();
}

private readonly HashSet<string> ignored =
new()
{
"AccessorDeclarationSyntax",
"AccessorListSyntax",
"AttributeArgumentListSyntax",
"AttributeArgumentSyntax",
"AttributeSyntax",
"AttributeTargetSpecifierSyntax",
"BaseListSyntax",
"CatchDeclarationSyntax",
"CatchFilterClauseSyntax",
"ConstructorInitializerSyntax",
"ConversionOperatorMemberCrefSyntax",
"CrefBracketedParameterListSyntax",
"CrefParameterListSyntax",
"CrefParameterSyntax",
"ExplicitInterfaceSpecifierSyntax",
"FunctionPointerCallingConventionSyntax",
"FunctionPointerParameterListSyntax",
"FunctionPointerParameterSyntax",
"FunctionPointerUnmanagedCallingConventionListSyntax",
"FunctionPointerUnmanagedCallingConventionSyntax",
"IndexerMemberCrefSyntax",
"InterpolationAlignmentClauseSyntax",
"InterpolationFormatClauseSyntax",
"JoinIntoClauseSyntax",
"LineDirectivePositionSyntax",
"NameMemberCrefSyntax",
"OperatorMemberCrefSyntax",
"OrderingSyntax",
"PositionalPatternClauseSyntax",
"PropertyPatternClauseSyntax",
"QualifiedCrefSyntax",
"SubpatternSyntax",
"SwitchExpressionArmSyntax",
"TypeCrefSyntax",
"XmlCrefAttributeSyntax",
"XmlElementEndTagSyntax",
"XmlElementStartTagSyntax",
"XmlNameAttributeSyntax",
"XmlNameSyntax",
"XmlPrefixSyntax",
"XmlTextAttributeSyntax",
};
private readonly HashSet<string> ignored = new()
{
"AccessorDeclarationSyntax",
"AccessorListSyntax",
"AttributeArgumentListSyntax",
"AttributeArgumentSyntax",
"AttributeSyntax",
"AttributeTargetSpecifierSyntax",
"BaseListSyntax",
"CatchDeclarationSyntax",
"CatchFilterClauseSyntax",
"ConstructorInitializerSyntax",
"ConversionOperatorMemberCrefSyntax",
"CrefBracketedParameterListSyntax",
"CrefParameterListSyntax",
"CrefParameterSyntax",
"ExplicitInterfaceSpecifierSyntax",
"FunctionPointerCallingConventionSyntax",
"FunctionPointerParameterListSyntax",
"FunctionPointerParameterSyntax",
"FunctionPointerUnmanagedCallingConventionListSyntax",
"FunctionPointerUnmanagedCallingConventionSyntax",
"IndexerMemberCrefSyntax",
"InterpolationAlignmentClauseSyntax",
"InterpolationFormatClauseSyntax",
"JoinIntoClauseSyntax",
"LineDirectivePositionSyntax",
"NameMemberCrefSyntax",
"OperatorMemberCrefSyntax",
"OrderingSyntax",
"PositionalPatternClauseSyntax",
"PropertyPatternClauseSyntax",
"QualifiedCrefSyntax",
"SubpatternSyntax",
"SwitchExpressionArmSyntax",
"TypeCrefSyntax",
"XmlCrefAttributeSyntax",
"XmlElementEndTagSyntax",
"XmlElementStartTagSyntax",
"XmlNameAttributeSyntax",
"XmlNameSyntax",
"XmlPrefixSyntax",
"XmlTextAttributeSyntax",
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@ protected void LoadFrom(CSharpierOptions newInstance)
this.DisableCSharpierServer = newInstance.DisableCSharpierServer;
}

private static readonly AsyncLazy<CSharpierOptions> liveModel =
new(CreateAsync, ThreadHelper.JoinableTaskFactory);
private static readonly AsyncLazy<CSharpierOptions> liveModel = new(
CreateAsync,
ThreadHelper.JoinableTaskFactory
);

private static FileSystemWatcher _hotReloadWatcher;

Expand Down
6 changes: 4 additions & 2 deletions Src/CSharpier/DocTypes/Doc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ public static implicit operator Doc(string value)

public static readonly HardLine HardLineIfNoPreviousLine = new(true);

public static readonly HardLine HardLineIfNoPreviousLineSkipBreakIfFirstInGroup =
new(true, true);
public static readonly HardLine HardLineIfNoPreviousLineSkipBreakIfFirstInGroup = new(
true,
true
);

public static readonly LiteralLine LiteralLine = new();

Expand Down
6 changes: 4 additions & 2 deletions Src/CSharpier/Formatters/CSharp/PreprocessorSymbols.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ internal class PreprocessorSymbols : CSharpSyntaxWalker
{
private readonly List<string[]> symbolSets = new();
private readonly HashSet<string> squashedSymbolSets = new();
private SymbolContext CurrentContext =
new() { ParentContext = new SymbolContext { ParentContext = null! } };
private SymbolContext CurrentContext = new()
{
ParentContext = new SymbolContext { ParentContext = null! },
};

private PreprocessorSymbols()
: base(SyntaxWalkerDepth.Trivia) { }
Expand Down

0 comments on commit 78147bd

Please sign in to comment.