Skip to content

Commit

Permalink
Merge branch 'main' into 1.0.0
Browse files Browse the repository at this point in the history
# Conflicts:
#	.config/dotnet-tools.json
#	CHANGELOG.md
#	Nuget/Build.props
#	Src/CSharpier.MsBuild/build/CSharpier.MsBuild.targets
#	Src/CSharpier.Tests/CSharpier.Tests.csproj
#	Src/CSharpier.VSCode/CHANGELOG.md
#	Src/CSharpier.VSCode/package.json
#	Src/CSharpier.VSCode/src/DiagnosticsService.ts
#	Src/CSharpier.VisualStudio/CSharpier.VisualStudio/CSharpier.VisualStudio.csproj
#	Src/CSharpier.VisualStudio/CSharpier.VisualStudio/source.extension.vsixmanifest
#	Src/CSharpier.VisualStudio/CSharpier.VisualStudio2019/CSharpier.VisualStudio2019.csproj
#	Src/CSharpier.VisualStudio/CSharpier.VisualStudio2019/source.extension.vsixmanifest
#	Src/CSharpier.VisualStudio/ChangeLog.md
#	Src/CSharpier/SyntaxPrinter/SyntaxNodePrinters/CompilationUnit.cs
  • Loading branch information
belav committed Jan 20, 2025
2 parents af683e2 + 2d852d1 commit 577a393
Show file tree
Hide file tree
Showing 128 changed files with 1,903 additions and 812 deletions.
4 changes: 2 additions & 2 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"isRoot": true,
"tools": {
"csharpier": {
"version": "0.30.1",
"version": "1.0.0-alpha10",
"commands": [
"dotnet-csharpier"
"csharpier"
]
}
}
Expand Down
2 changes: 2 additions & 0 deletions .csharpierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
build

Uploads/

Tests/MsBuild/TestCases/
3 changes: 1 addition & 2 deletions .github/Github.csproj
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
<Project Sdk="Microsoft.Build.NoTargets/3.1.0">
</Project>
<Project Sdk="Microsoft.Build.NoTargets/3.1.0"></Project>
2 changes: 1 addition & 1 deletion .github/workflows/validate_pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- run: |
rm -r -f ./Tests/CSharpier.MsBuild.Test
dotnet tool restore
dotnet csharpier . --check
dotnet csharpier check .
test_msbuild:
strategy:
matrix:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,4 @@ Src/CSharpier.VSCode/.idea/prettier.xml
/Src/CSharpier.Tests/TestResults
/Src/CSharpier.MsBuild.Test/.idea
/Tests/MsBuild/GeneratedScenarios
Src/CSharpier.Rider/.intellijPlatform/self-update.lock
2 changes: 1 addition & 1 deletion .idea/.idea.CSharpier/.idea/CSharpierPlugin.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/.idea.CSharpier/.idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/.idea.CSharpier/.idea/indexLayout.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/.idea.CSharpier/.idea/prettier.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/.idea.CSharpier/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/prettier.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 11 additions & 3 deletions .run/Playground.run.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Playground" type="LaunchSettings" factoryName=".NET Launch Settings Profile">
<option name="LAUNCH_PROFILE_PROJECT_FILE_PATH" value="$PROJECT_DIR$/Src/CSharpier.Playground/CSharpier.Playground.csproj" />
<configuration
default="false"
name="Playground"
type="LaunchSettings"
factoryName=".NET Launch Settings Profile"
>
<option
name="LAUNCH_PROFILE_PROJECT_FILE_PATH"
value="$PROJECT_DIR$/Src/CSharpier.Playground/CSharpier.Playground.csproj"
/>
<option name="LAUNCH_PROFILE_TFM" value="net9.0" />
<option name="LAUNCH_PROFILE_NAME" value="Watch" />
<option name="USE_EXTERNAL_CONSOLE" value="0" />
Expand All @@ -14,4 +22,4 @@
<option name="Build" />
</method>
</configuration>
</component>
</component>
60 changes: 57 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,57 @@
# 0.30.4
# 0.30.6
## What's Changed
### Trailing comma is placed on new line if last enum value is followed by a comment [#1429](https://github.com/belav/csharpier/issues/1429)
```c#
// input
enum MyEnum
{
First,
Second // the second value
}

// 0.30.5
enum MyEnum
{
First,
Second // the second value
,
}

// 0.30.6
enum MyEnum
{
First,
Second, // the second value
}
```

**Full Changelog**: https://github.com/belav/csharpier/compare/0.30.5...0.30.6
# 0.30.5
## What's Changed
### Extra blank line added to file each time csharpier runs on this file [#1426](https://github.com/belav/csharpier/issues/1426)
When a file ended in a comment and that comment had multiple blank lines before it, a new blank line was being added each time it was formatted.
// input
```c#
// input
namespace MyCompany.MyNamespace;


// Comment block
// 0.30.4
namespace MyCompany.MyNamespace;



// Comment block
// 0.30.5
namespace MyCompany.MyNamespace;

// Comment block
**Full Changelog**: https://github.com/belav/csharpier/compare/0.30.4...0.30.5
# 0.30.4
## What's Changed
### Formatting deletes `unsafe` modifier [#1416](https://github.com/belav/csharpier/issues/1416)
Formatting a using directive with an unsafe modifier resulted in the lose of the unsafe keyword
Expand Down Expand Up @@ -1194,7 +1247,7 @@ host.AddSection(
tags: Tags.SamplesUsed,
tasks:
[
// TO-DO: Add any used third party instruments below as you discover them.
// TODO: Add any used third party instruments below as you discover them.
]
);

Expand All @@ -1204,7 +1257,7 @@ host.AddSection(
tags: Tags.SamplesUsed,
tasks:
[
// TO-DO: Add any used third party instruments below as you discover them.
// TODO: Add any used third party instruments below as you discover them.
]
);
```
Expand Down Expand Up @@ -2866,5 +2919,6 @@ Thanks go to @pingzing
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@
<PackageVersion Include="System.Threading.Tasks.Extensions" Version="4.5.4" />
<PackageVersion Include="YamlDotNet" Version="16.1.2" />
</ItemGroup>
</Project>
</Project>
4 changes: 2 additions & 2 deletions Nuget/Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Version>0.30.4</Version>
<Version>0.30.6</Version>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<RepositoryUrl>https://github.com/belav/csharpier</RepositoryUrl>
<RepositoryType>git</RepositoryType>
Expand All @@ -12,4 +12,4 @@
<ItemGroup>
<None Include="$(MSBuildThisFileDirectory)\README.md" Pack="true" PackagePath="\" />
</ItemGroup>
</Project>
</Project>
3 changes: 1 addition & 2 deletions Scripts/Scripts.csproj
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
<Project Sdk="Microsoft.Build.NoTargets/3.1.0">
</Project>
<Project Sdk="Microsoft.Build.NoTargets/3.1.0"></Project>
3 changes: 1 addition & 2 deletions Shell/Shell.csproj
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
<Project Sdk="Microsoft.Build.NoTargets/3.1.0">
</Project>
<Project Sdk="Microsoft.Build.NoTargets/3.1.0"></Project>
18 changes: 18 additions & 0 deletions Src/CSharpier.Cli.Tests/CliTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,24 @@ public async Task Should_Respect_Ignore_File_With_Subdirectory_When_DirectorOrFi
.Be(unformattedContent, $"The file at {filePath} should have been ignored");
}

[TestCase(".git")]
[TestCase("subdirectory/.git")]
[TestCase("node_modules")]
[TestCase("subdirectory/node_modules")]
[TestCase("obj")]
[TestCase("subdirectory/obj")]
public async Task Should_Ignore_Special_Case_Files(string path)
{
var unformattedContent = "public class Unformatted { }";
var filePath = $"{path}/IgnoredFile.cs";
await this.WriteFileAsync(filePath, unformattedContent);

await new CsharpierProcess().WithArguments(".").ExecuteAsync();
var result = await this.ReadAllTextAsync(filePath);

result.Should().Be(unformattedContent, $"The file at {filePath} should have been ignored");
}

[Test]
public async Task Should_Support_Config_Path()
{
Expand Down
2 changes: 1 addition & 1 deletion Src/CSharpier.Cli/IgnoreFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ internal class IgnoreFile
{
protected Ignore.Ignore Ignore { get; }
protected string IgnoreBaseDirectoryPath { get; }
private static readonly string[] alwaysIgnored = ["**/node_modules/**/*.cs", "**/obj/**/*.cs"];
private static readonly string[] alwaysIgnored = ["**/node_modules", "**/obj", "**/.git"];

protected IgnoreFile(Ignore.Ignore ignore, string ignoreBaseDirectoryPath)
{
Expand Down
8 changes: 8 additions & 0 deletions Src/CSharpier.Cli/Server/CSharpierServiceImplementation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ CancellationToken cancellationToken
try
{
logger.LogInformation("Received request to format " + formatFileParameter.fileName);
if (formatFileParameter.fileContents.StartsWith("// csh-slow"))
{
Thread.Sleep(TimeSpan.FromSeconds(5));
}
if (formatFileParameter.fileContents.StartsWith("// csh-throw"))
{
throw new Exception("Throwing because of // csh-throw comment");
}
var directoryName = this.fileSystem.Path.GetDirectoryName(formatFileParameter.fileName);
DebugLogger.Log(directoryName ?? string.Empty);
if (directoryName == null)
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 20 additions & 23 deletions Src/CSharpier.MsBuild/CSharpier.MsBuild.csproj
Original file line number Diff line number Diff line change
@@ -1,29 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="../../Nuget/Build.props"/>
<PropertyGroup>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<PackageId>CSharpier.MsBuild</PackageId>
<DevelopmentDependency>true</DevelopmentDependency>
<CSharpierOutputDir>../CSharpier.Cli/bin/$(Configuration)/$(TargetFramework)</CSharpierOutputDir>
</PropertyGroup>

<!--
<Import Project="../../Nuget/Build.props" />
<PropertyGroup>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<PackageId>CSharpier.MsBuild</PackageId>
<DevelopmentDependency>true</DevelopmentDependency>
<CSharpierOutputDir>../CSharpier.Cli/bin/$(Configuration)/$(TargetFramework)</CSharpierOutputDir>
</PropertyGroup>
<!--
Note: There is no <ProjectReference /> here because that would cause msbuild to
make it a dependency in the output package, which causes all sorts of issues as
CSharpier is a net9.0 project with <PackAsTool> and this is neither.
-->
<Target Name="BuildCSharpier" BeforeTargets="Restore">
<Exec command="dotnet build -c $(Configuration)" WorkingDirectory="../CSharpier.Cli" />
</Target>

<ItemGroup>
<None Include="..\..\logo.png" Pack="true" PackagePath="">
<Link>logo.png</Link>
</None>
</ItemGroup>

<ItemGroup>
<Content Include="build/*" PackagePath="build/" />
<Content Include="$(CSharpierOutputDir)/**" PackagePath="tools/csharpier" />
</ItemGroup>
<Target Name="BuildCSharpier" BeforeTargets="Restore">
<Exec command="dotnet build -c $(Configuration)" WorkingDirectory="../CSharpier.Cli" />
</Target>
<ItemGroup>
<None Include="..\..\logo.png" Pack="true" PackagePath="">
<Link>logo.png</Link>
</None>
</ItemGroup>
<ItemGroup>
<Content Include="build/*" PackagePath="build/" />
<Content Include="$(CSharpierOutputDir)/**" PackagePath="tools/csharpier" />
</ItemGroup>
</Project>
6 changes: 3 additions & 3 deletions Src/CSharpier.MsBuild/MsBuild.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Project Sdk="Microsoft.Build.NoTargets/3.1.0">
<ItemGroup>
<Content Include="CSharpier.MsBuild.csproj"/>
</ItemGroup>
<ItemGroup>
<Content Include="CSharpier.MsBuild.csproj" />
</ItemGroup>
</Project>
10 changes: 5 additions & 5 deletions Src/CSharpier.MsBuild/build/CSharpier.MsBuild.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>
<PropertyGroup Condition=" '$(CSharpier_Check)' == '' ">
<!-- Setting default value here, so it can be overwritten by caller -->
<CSharpier_Check>false</CSharpier_Check>
<CSharpier_Check Condition=" '$(Configuration)' == 'Release' ">true</CSharpier_Check>
</PropertyGroup>
<PropertyGroup Condition=" '$(CSharpier_Check)' == '' ">
<!-- Setting default value here, so it can be overwritten by caller -->
<CSharpier_Check>false</CSharpier_Check>
<CSharpier_Check Condition=" '$(Configuration)' == 'Release' ">true</CSharpier_Check>
</PropertyGroup>
</Project>
7 changes: 5 additions & 2 deletions Src/CSharpier.Playground/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 577a393

Please sign in to comment.