From 856c47daccab66f85524bb750f8e3589f3969273 Mon Sep 17 00:00:00 2001 From: mob-sakai Date: Wed, 10 Nov 2021 21:34:06 +0900 Subject: [PATCH] refactor --- Plugins/CSharpCompilerSettings/Core.cs | 4 ++-- .../CSharpCompilerSettings/CscSettingsAsset.cs | 18 +++++++----------- Plugins/CSharpCompilerSettings/Utils.cs | 12 ++++++------ 3 files changed, 15 insertions(+), 19 deletions(-) diff --git a/Plugins/CSharpCompilerSettings/Core.cs b/Plugins/CSharpCompilerSettings/Core.cs index 2b992f8..d9d6000 100644 --- a/Plugins/CSharpCompilerSettings/Core.cs +++ b/Plugins/CSharpCompilerSettings/Core.cs @@ -152,9 +152,9 @@ public static string ModifyResponseFile(CscSettingsAsset setting, string assembl } // Ruleset. - var rulesets = new[] {"Assets/Default.ruleset"} + var rulesets = new[] { "Assets/Default.ruleset" } .Concat(string.IsNullOrEmpty(asmdefDir) - ? new[] {"Assets/" + assemblyName + ".ruleset"} + ? new[] { "Assets/" + assemblyName + ".ruleset" } : Directory.GetFiles(asmdefDir, "*.ruleset")) .Where(File.Exists); diff --git a/Plugins/CSharpCompilerSettings/CscSettingsAsset.cs b/Plugins/CSharpCompilerSettings/CscSettingsAsset.cs index d04c48f..50a560b 100644 --- a/Plugins/CSharpCompilerSettings/CscSettingsAsset.cs +++ b/Plugins/CSharpCompilerSettings/CscSettingsAsset.cs @@ -77,10 +77,12 @@ public override string ToString() [Serializable] public struct AssemblyFilter { - [Tooltip("Include predefined assemblies (Assembly-CSharp-firstpass.dll, Assembly-CSharp-Editor-firstpass.dll, Assembly-CSharp.dll and Assembly-CSharp-Editor.dll)")] [SerializeField] + [Tooltip("Include predefined assemblies (Assembly-CSharp-firstpass.dll, Assembly-CSharp-Editor-firstpass.dll, Assembly-CSharp.dll and Assembly-CSharp-Editor.dll)")] + [SerializeField] private bool m_PredefinedAssemblies; - [Tooltip("Assemblies filter. Prefix '!' to exclude. (e.g. 'Assets/', '!Packages/')")] [SerializeField] + [Tooltip("Assemblies filter. Prefix '!' to exclude. (e.g. 'Assets/', '!Packages/')")] + [SerializeField] private string[] m_IncludedAssemblies; public AssemblyFilter(bool predefinedAssemblies, string[] includedAssemblies) @@ -107,11 +109,10 @@ internal class CscSettingsAsset : ScriptableObject, ISerializationCallbackReceiv [SerializeField] private bool m_EnableLogging = false; [SerializeField] private Nullable m_Nullable = Nullable.Disable; [SerializeField] private NugetPackage m_CompilerPackage = new NugetPackage("Microsoft.Net.Compilers", "3.5.0", NugetPackage.CategoryType.Compiler); - [SerializeField] private AssemblyFilter m_CompilerFilter = new AssemblyFilter(true, new[] {"Assets/", "!Assets/Standard Assets/", "!Packages/"}); + [SerializeField] private AssemblyFilter m_CompilerFilter = new AssemblyFilter(true, new[] { "Assets/", "!Assets/Standard Assets/", "!Packages/" }); [SerializeField] private NugetPackage[] m_AnalyzerPackages = new NugetPackage[0]; - [SerializeField] private AssemblyFilter m_AnalyzerFilter = new AssemblyFilter(true, new[] {"Assets/", "!Assets/Standard Assets/", "!Packages/"}); + [SerializeField] private AssemblyFilter m_AnalyzerFilter = new AssemblyFilter(true, new[] { "Assets/", "!Assets/Standard Assets/", "!Packages/" }); [SerializeField] private string[] m_SymbolModifier = new string[0]; - [SerializeField] [Obsolete] private bool m_UseDefaultCompiler = true; [SerializeField] [Obsolete] private string m_PackageName = "Microsoft.Net.Compilers"; [SerializeField] [Obsolete] private string m_PackageVersion = "3.5.0"; @@ -128,18 +129,13 @@ private static CscSettingsAsset CreateFromProjectSettings() } public bool IsProjectSetting { get; private set; } - private static CscSettingsAsset s_Instance; public static CscSettingsAsset instance => s_Instance ? s_Instance : s_Instance = CreateFromProjectSettings(); public NugetPackage CompilerPackage => m_CompilerPackage; public Nullable Nullable => m_Nullable; public NugetPackage[] AnalyzerPackages => m_AnalyzerPackages; public bool EnableDebugLog => m_EnableLogging; - - public bool UseDefaultCompiler - { - get { return m_CompilerType == CompilerType.BuiltIn || !m_CompilerPackage.IsValid; } - } + public bool UseDefaultCompiler => m_CompilerType == CompilerType.BuiltIn || !m_CompilerPackage.IsValid; public string LanguageVersion { diff --git a/Plugins/CSharpCompilerSettings/Utils.cs b/Plugins/CSharpCompilerSettings/Utils.cs index ebd55aa..48986e5 100644 --- a/Plugins/CSharpCompilerSettings/Utils.cs +++ b/Plugins/CSharpCompilerSettings/Utils.cs @@ -172,11 +172,11 @@ public static string[] GetDownloadCommand(string url, string downloadPath, Runti switch (platform) { case RuntimePlatform.WindowsEditor: - return new []{"PowerShell.exe", string.Format("curl -O {0} {1}", downloadPath, url)}; + return new[] { "PowerShell.exe", string.Format("curl -O {0} {1}", downloadPath, url) }; case RuntimePlatform.OSXEditor: - return new []{"curl", string.Format("-o {0} -L {1}", downloadPath, url)}; + return new[] { "curl", string.Format("-o {0} -L {1}", downloadPath, url) }; case RuntimePlatform.LinuxEditor: - return new []{"wget", string.Format("-O {0} {1}", downloadPath, url)}; + return new[] { "wget", string.Format("-O {0} {1}", downloadPath, url) }; default: throw new NotSupportedException($"{Application.platform} is not supported"); @@ -198,18 +198,18 @@ public static string[] GetExtractArchiveCommand(string archivePath, string extra { case RuntimePlatform.WindowsEditor: Directory.CreateDirectory(Path.GetDirectoryName(extractTo)); - return new[] {PathCombine(contentsPath, "Tools", "7z.exe"), string.Format("x {0} -o{1}", archivePath, extractTo)}; + return new[] { PathCombine(contentsPath, "Tools", "7z.exe"), string.Format("x {0} -o{1}", archivePath, extractTo) }; case RuntimePlatform.OSXEditor: case RuntimePlatform.LinuxEditor: if (archivePath.EndsWith("tar.gz")) { Directory.CreateDirectory(extractTo); - return new[] {"tar", string.Format("-pzxf {0} -C {1}", archivePath, extractTo)}; + return new[] { "tar", string.Format("-pzxf {0} -C {1}", archivePath, extractTo) }; } else { Directory.CreateDirectory(Path.GetDirectoryName(extractTo)); - return new[] {PathCombine(contentsPath, "Tools", "7za"), string.Format("x {0} -o{1}", archivePath, extractTo)}; + return new[] { PathCombine(contentsPath, "Tools", "7za"), string.Format("x {0} -o{1}", archivePath, extractTo) }; } default: throw new NotSupportedException($"{Application.platform} is not supported");