From 62f0f9630c96adcc5f0aa92d09a19c3371fcd960 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Tue, 15 Jun 2021 23:11:41 +0900 Subject: [PATCH 1/3] Add local code inspection scripts --- InspectCode.ps1 | 11 +++++++++++ InspectCode.sh | 6 ++++++ 2 files changed, 17 insertions(+) create mode 100644 InspectCode.ps1 create mode 100755 InspectCode.sh diff --git a/InspectCode.ps1 b/InspectCode.ps1 new file mode 100644 index 0000000000..1cf8de266d --- /dev/null +++ b/InspectCode.ps1 @@ -0,0 +1,11 @@ +dotnet tool restore + +# Temporarily disabled until the tool is upgraded to 5.0. + # The version specified in .config/dotnet-tools.json (3.1.37601) won't run on .NET hosts >=5.0.7. + # - cmd: dotnet format --dry-run --check + +dotnet CodeFileSanity +dotnet jb inspectcode "osu-framework.Desktop.slnf" --output="inspectcodereport.xml" --caches-home="inspectcode" --verbosity=WARN +dotnet nvika parsereport "inspectcodereport.xml" --treatwarningsaserrors + +exit $LASTEXITCODE diff --git a/InspectCode.sh b/InspectCode.sh new file mode 100755 index 0000000000..e6453c29ed --- /dev/null +++ b/InspectCode.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +dotnet tool restore +dotnet CodeFileSanity +dotnet jb inspectcode "osu-framework.Desktop.slnf" --output="inspectcodereport.xml" --caches-home="inspectcode" --verbosity=WARN +dotnet nvika parsereport "inspectcodereport.xml" --treatwarningsaserrors From a5c830a8a597ccfe89d394280b23a0c82b517d3b Mon Sep 17 00:00:00 2001 From: Jai Sharma Date: Tue, 15 Jun 2021 15:40:52 +0100 Subject: [PATCH 2/3] Add logging if Dynamic Compilation is disbled due to no Solution file --- osu.Framework/Testing/DynamicClassCompiler.cs | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/osu.Framework/Testing/DynamicClassCompiler.cs b/osu.Framework/Testing/DynamicClassCompiler.cs index f123f35358..f7968f2cd0 100644 --- a/osu.Framework/Testing/DynamicClassCompiler.cs +++ b/osu.Framework/Testing/DynamicClassCompiler.cs @@ -45,8 +45,6 @@ public void SetRecompilationTarget(T target) public void Start() { - var di = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory); - if (Debugger.IsAttached) { referenceBuilder = new EmptyTypeReferenceBuilder(); @@ -55,6 +53,17 @@ public void Start() return; } + var di = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory); + var basePath = getSolutionPath(di); + + if (!Directory.Exists(basePath)) + { + referenceBuilder = new EmptyTypeReferenceBuilder(); + + Logger.Log("Dynamic compilation disabled (no solution file found)."); + return; + } + #if NET5_0 referenceBuilder = new RoslynTypeReferenceBuilder(); #else @@ -65,12 +74,7 @@ public void Start() { Logger.Log("Initialising dynamic compilation..."); - var basePath = getSolutionPath(di); - - if (!Directory.Exists(basePath)) - return; - - await referenceBuilder.Initialise(Directory.GetFiles(getSolutionPath(di), "*.sln").First()).ConfigureAwait(false); + await referenceBuilder.Initialise(Directory.GetFiles(basePath, "*.sln").First()).ConfigureAwait(false); foreach (var dir in Directory.GetDirectories(basePath)) { From 5f5e79f2edfc72e433e0a365c15fe0ff6f926912 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 16 Jun 2021 11:02:32 +0900 Subject: [PATCH 3/3] Adjust readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 91837ff6e5..359bc20de6 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ Build configurations for the recommended IDEs (listed above) are included. You s ### Code analysis -Code analysis can be run with `powershell ./build.ps1` or `build.sh`. This is currently only supported under windows due to [resharper cli shortcomings](https://youtrack.jetbrains.com/issue/RSRP-410004). Alternatively, you can install resharper or use rider to get inline support in your IDE of choice. +Code analysis can be run with `powershell ./InspectCode.ps1` or `InspectCode.sh`. ## Contributing