Merge pull request #64956 from raulsntos/dotnet/format-ci

Add `dotnet format` to CI to check C# style
This commit is contained in:
Rémi Verschelde 2022-08-29 07:03:20 +02:00 committed by GitHub
commit 4333f785f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 190 additions and 139 deletions

View File

@ -63,3 +63,7 @@ jobs:
- name: Style checks via clang-format (clang_format.sh)
run: |
bash ./misc/scripts/clang_format.sh
- name: Style checks via dotnet format (dotnet_format.sh)
run: |
bash ./misc/scripts/dotnet_format.sh

28
misc/scripts/dotnet_format.sh Executable file
View File

@ -0,0 +1,28 @@
#!/usr/bin/env bash
# This script runs dotnet format on all relevant files in the repo.
# This is the primary script responsible for fixing style violations in C# files.
set -uo pipefail
# Loops through all C# projects tracked by Git.
git ls-files -- '*.csproj' \
':!:.git/*' ':!:thirdparty/*' ':!:platform/android/java/lib/src/com/google/*' ':!:*-so_wrap.*' |
while read -r f; do
# Run dotnet format.
dotnet format "$f"
done
diff=$(git diff --color)
# If no diff has been generated all is OK, clean up, and exit.
if [ -z "$diff" ] ; then
printf "Files in this commit comply with the dotnet format style rules.\n"
exit 0
fi
# A diff has been created, notify the user, clean up, and exit.
printf "\n*** The following changes have been made to comply with the formatting rules:\n\n"
echo "$diff"
printf "\n*** Please fix your commit(s) with 'git commit --amend' or 'git rebase -i <hash>'\n"
exit 1

View File

@ -94,16 +94,20 @@ namespace Godot.SourceGenerators.Sample
[Export] private NodePath field_NodePath = new NodePath("foo");
[Export] private RID field_RID;
[Export] private Godot.Collections.Dictionary field_GodotDictionary =
[Export]
private Godot.Collections.Dictionary field_GodotDictionary =
new() { { "foo", 10 }, { Vector2.Up, Colors.Chocolate } };
[Export] private Godot.Collections.Array field_GodotArray =
[Export]
private Godot.Collections.Array field_GodotArray =
new() { "foo", 10, Vector2.Up, Colors.Chocolate };
[Export] private Godot.Collections.Dictionary<string, bool> field_GodotGenericDictionary =
[Export]
private Godot.Collections.Dictionary<string, bool> field_GodotGenericDictionary =
new() { { "foo", true }, { "bar", false } };
[Export] private Godot.Collections.Array<int> field_GodotGenericArray =
[Export]
private Godot.Collections.Array<int> field_GodotGenericArray =
new() { 0, 1, 2, 3, 4, 5, 6 };
}
}

View File

@ -94,16 +94,20 @@ namespace Godot.SourceGenerators.Sample
[Export] private NodePath property_NodePath { get; set; } = new NodePath("foo");
[Export] private RID property_RID { get; set; }
[Export] private Godot.Collections.Dictionary property_GodotDictionary { get; set; } =
[Export]
private Godot.Collections.Dictionary property_GodotDictionary { get; set; } =
new() { { "foo", 10 }, { Vector2.Up, Colors.Chocolate } };
[Export] private Godot.Collections.Array property_GodotArray { get; set; } =
[Export]
private Godot.Collections.Array property_GodotArray { get; set; } =
new() { "foo", 10, Vector2.Up, Colors.Chocolate };
[Export] private Godot.Collections.Dictionary<string, bool> property_GodotGenericDictionary { get; set; } =
[Export]
private Godot.Collections.Dictionary<string, bool> property_GodotGenericDictionary { get; set; } =
new() { { "foo", true }, { "bar", false } };
[Export] private Godot.Collections.Array<int> property_GodotGenericArray { get; set; } =
[Export]
private Godot.Collections.Array<int> property_GodotGenericArray { get; set; } =
new() { 0, 1, 2, 3, 4, 5, 6 };
}
}

View File

@ -123,12 +123,16 @@ namespace GodotTools.IdeMessaging
string projectMetadataDir = Path.Combine(godotProjectDir, ".godot", "mono", "metadata");
// FileSystemWatcher requires an existing directory
if (!Directory.Exists(projectMetadataDir)) {
if (!Directory.Exists(projectMetadataDir))
{
// Check if the non hidden version exists
string nonHiddenProjectMetadataDir = Path.Combine(godotProjectDir, "godot", "mono", "metadata");
if (Directory.Exists(nonHiddenProjectMetadataDir)) {
if (Directory.Exists(nonHiddenProjectMetadataDir))
{
projectMetadataDir = nonHiddenProjectMetadataDir;
} else {
}
else
{
Directory.CreateDirectory(projectMetadataDir);
}
}

View File

@ -249,8 +249,8 @@ namespace GodotTools.OpenVisualStudio
// Thread call was rejected, so try again.
int IOleMessageFilter.RetryRejectedCall(IntPtr hTaskCallee, int dwTickCount, int dwRejectType)
{
if (dwRejectType == 2)
// flag = SERVERCALL_RETRYLATER
if (dwRejectType == 2)
{
// Retry the thread call immediately if return >= 0 & < 100
return 99;

View File

@ -76,13 +76,20 @@ namespace GodotTools.Export
else
{
string arch = "";
if (features.Contains("x86_64")) {
if (features.Contains("x86_64"))
{
arch = "x86_64";
} else if (features.Contains("x86_32")) {
}
else if (features.Contains("x86_32"))
{
arch = "x86_32";
} else if (features.Contains("arm64")) {
}
else if (features.Contains("arm64"))
{
arch = "arm64";
} else if (features.Contains("arm32")) {
}
else if (features.Contains("arm32"))
{
arch = "arm32";
}
CompileAssembliesForDesktop(exporter, platform, isDebug, arch, aotOpts, aotTempDir, outputDataDir, assembliesPrepared, bclDir);