Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
mob-sakai committed Dec 2, 2021
1 parent 745ecd9 commit 856c47d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 19 deletions.
4 changes: 2 additions & 2 deletions Plugins/CSharpCompilerSettings/Core.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
18 changes: 7 additions & 11 deletions Plugins/CSharpCompilerSettings/CscSettingsAsset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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";
Expand All @@ -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
{
Expand Down
12 changes: 6 additions & 6 deletions Plugins/CSharpCompilerSettings/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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");
Expand Down

0 comments on commit 856c47d

Please sign in to comment.