From 292edea6b71ec3cb94bd6bfd3a82639659b92f77 Mon Sep 17 00:00:00 2001 From: SteveGilham Date: Mon, 20 Jan 2025 16:53:36 +0000 Subject: [PATCH] C# liniting --- AltCover.Cake/Cake.cs | 8 ++++++++ AltCover.Cake/CakeMix.cs | 17 ++++++++++++----- AltCover.Cake/DotNet.cs | 8 ++++++++ AltCover.Cake/Options.cs | 8 ++++++++ 4 files changed, 36 insertions(+), 5 deletions(-) diff --git a/AltCover.Cake/Cake.cs b/AltCover.Cake/Cake.cs index 83d933f31..ee030846d 100644 --- a/AltCover.Cake/Cake.cs +++ b/AltCover.Cake/Cake.cs @@ -79,7 +79,11 @@ public static int Collect(this ICakeContext context, Abstract.ICollectOptions co [CakeMethodAlias] public static string ImportModule(this ICakeContext context) { +#if NET8_0_OR_GREATER + ArgumentNullException.ThrowIfNull(context, nameof(context)); +#else if (context == null) throw new System.ArgumentNullException(nameof(context)); +#endif return FSCommand.ImportModule(); } @@ -92,7 +96,11 @@ public static string ImportModule(this ICakeContext context) [CakeMethodAlias] public static System.Version Version(this ICakeContext context) { +#if NET8_0_OR_GREATER + ArgumentNullException.ThrowIfNull(context, nameof(context)); +#else if (context == null) throw new System.ArgumentNullException(nameof(context)); +#endif return FSCommand.Version(); } } diff --git a/AltCover.Cake/CakeMix.cs b/AltCover.Cake/CakeMix.cs index b33071d06..63d50397a 100644 --- a/AltCover.Cake/CakeMix.cs +++ b/AltCover.Cake/CakeMix.cs @@ -6,6 +6,7 @@ #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member +#pragma warning disable IDE0130 // Namespace does not match folder structure namespace Cake.Core { [EditorBrowsable(EditorBrowsableState.Never)] @@ -45,17 +46,19 @@ namespace Cake.Core.IO [EditorBrowsable(EditorBrowsableState.Never)] public class ProcessArgumentBuilder { - public void Append(string s) +#pragma warning disable CA1822 // Mark members as static + public void Append(string _) { } - public void Append(IProcessArgument s) + public void Append(IProcessArgument _) { } - public IEnumerable Skip(int n) + public IEnumerable Skip(int _) { return null; } - public IEnumerable Take(int n) + public IEnumerable Take(int _) { return null; } +#pragma warning restore CA1822 // Mark members as static } [EditorBrowsable(EditorBrowsableState.Never)] @@ -65,11 +68,13 @@ public interface IProcessArgument [EditorBrowsable(EditorBrowsableState.Never)] public class FilePath { +#pragma warning disable CA1822 // Mark members as static public FilePath GetFilename() { return null; } public string FullPath { get { return String.Empty; } } +#pragma warning restore CA1822 // Mark members as static } } @@ -84,7 +89,7 @@ public class CakeMethodAliasAttribute : Attribute [AttributeUsage(AttributeTargets.All)] public class CakeAliasCategoryAttribute : Attribute { - public CakeAliasCategoryAttribute(string s) + public CakeAliasCategoryAttribute(string _) { } } } @@ -95,9 +100,11 @@ namespace Cake.Common.Tools.DotNet public static class DotNetAliases { public static void DotNetTest( +#pragma warning disable IDE0060 // Remove unused parameter Cake.Core.ICakeContext context, string fullPath, Cake.Common.Tools.DotNet.Test.DotNetTestSettings testSettings) +#pragma warning restore IDE0060 // Remove unused parameter { } } } diff --git a/AltCover.Cake/DotNet.cs b/AltCover.Cake/DotNet.cs index 1590376dd..571e156c3 100644 --- a/AltCover.Cake/DotNet.cs +++ b/AltCover.Cake/DotNet.cs @@ -48,7 +48,9 @@ public AltCover.ValidatedCommandLine WhatIf() return collect; } +#pragma warning disable IDE0301 // Collection initialization return new AltCover.ValidatedCommandLine(FSharpList.Empty, Enumerable.Empty()); +#pragma warning restore IDE0301 // Collection initialization } /// @@ -141,9 +143,15 @@ public static void DotNetTest( DotNetTestSettings testSettings, CoverageSettings coverageSettings) { +#if NET8_0_OR_GREATER + ArgumentNullException.ThrowIfNull(project, nameof(project)); + ArgumentNullException.ThrowIfNull(testSettings, nameof(testSettings)); + ArgumentNullException.ThrowIfNull(coverageSettings, nameof(coverageSettings)); +#else if (project == null) throw new ArgumentNullException(nameof(project)); if (testSettings == null) throw new ArgumentNullException(nameof(testSettings)); if (coverageSettings == null) throw new ArgumentNullException(nameof(coverageSettings)); +#endif testSettings.ArgumentCustomization = coverageSettings.Concatenate(testSettings.ArgumentCustomization); diff --git a/AltCover.Cake/Options.cs b/AltCover.Cake/Options.cs index b1bebfbad..276c7a21c 100644 --- a/AltCover.Cake/Options.cs +++ b/AltCover.Cake/Options.cs @@ -62,6 +62,8 @@ public class PrepareOptions : Abstract.IPrepareOptions Justification = "Property name")] public IEnumerable OutputDirectories => throw new NotImplementedException("OutputDirectories not used"); +#pragma warning disable IDE0301 // Collection initialization + /// /// Corresponds to command line option `-y, --symbolDirectory=VALUE` /// @@ -263,6 +265,8 @@ public class PrepareOptions : Abstract.IPrepareOptions /// Corresponds to command line option `--portable` /// public virtual bool Portable => false; + +#pragma warning restore IDE0301 // Collection initialization } /// @@ -326,11 +330,15 @@ public class CollectOptions : Abstract.ICollectOptions Justification = "Lcov is a name")] public virtual string Cobertura => String.Empty; +#pragma warning disable IDE0301 // Collection initialization + /// /// Corresponds to command line option `-p, --package=VALUE` /// public IEnumerable Packages => Enumerable.Empty(); +#pragma warning restore IDE0301 // Collection initialization + /// /// Corresponds to command line option `-o, --outputFile=VALUE` ///