From 5034e1ceb47643eb76cbdd5e7f2177bda95e8c15 Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Sun, 19 Apr 2020 14:13:46 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=8D=20CLSCompliant=20assemblies?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- X10D.Tests/src/Assembly.cs | 3 +++ X10D/src/Assembly.cs | 3 +++ X10D/src/ByteExtensions.cs | 3 +++ X10D/src/ConvertibleExtensions.cs | 7 +++++++ X10D/src/Int16Extensions.cs | 6 ++++++ X10D/src/Int32Extensions.cs | 5 +++++ X10D/src/Int64Extensions.cs | 6 ++++++ 7 files changed, 33 insertions(+) create mode 100644 X10D.Tests/src/Assembly.cs create mode 100644 X10D/src/Assembly.cs diff --git a/X10D.Tests/src/Assembly.cs b/X10D.Tests/src/Assembly.cs new file mode 100644 index 0000000..8c11453 --- /dev/null +++ b/X10D.Tests/src/Assembly.cs @@ -0,0 +1,3 @@ +using System; + +[assembly: CLSCompliant(true)] diff --git a/X10D/src/Assembly.cs b/X10D/src/Assembly.cs new file mode 100644 index 0000000..8c11453 --- /dev/null +++ b/X10D/src/Assembly.cs @@ -0,0 +1,3 @@ +using System; + +[assembly: CLSCompliant(true)] diff --git a/X10D/src/ByteExtensions.cs b/X10D/src/ByteExtensions.cs index f1d81a4..e84264d 100644 --- a/X10D/src/ByteExtensions.cs +++ b/X10D/src/ByteExtensions.cs @@ -55,6 +55,7 @@ /// /// The bytes to convert. /// Returns an . + [CLSCompliant(false)] public static ushort GetUInt16(this IEnumerable bytes) { return BitConverter.ToUInt16(bytes.ToArray(), 0); @@ -65,6 +66,7 @@ /// /// The bytes to convert. /// Returns an . + [CLSCompliant(false)] public static uint GetUInt32(this IEnumerable bytes) { return BitConverter.ToUInt32(bytes.ToArray(), 0); @@ -75,6 +77,7 @@ /// /// The bytes to convert. /// Returns an . + [CLSCompliant(false)] public static ulong GetUInt64(this IEnumerable bytes) { return BitConverter.ToUInt64(bytes.ToArray(), 0); diff --git a/X10D/src/ConvertibleExtensions.cs b/X10D/src/ConvertibleExtensions.cs index 316a293..6dad8b9 100644 --- a/X10D/src/ConvertibleExtensions.cs +++ b/X10D/src/ConvertibleExtensions.cs @@ -17,6 +17,7 @@ /// This conversion is not supported. /// -or- /// is and is a value type. + [CLSCompliant(false)] public static T To(this IConvertible value, IFormatProvider provider = null) { if (value is null) @@ -35,6 +36,7 @@ /// The format provider. /// Returns the value converted to . /// This conversion is not supported. + [CLSCompliant(false)] public static T ToOrDefault(this IConvertible value, IFormatProvider provider = null) { return value is null ? default : To(value, provider); @@ -48,6 +50,7 @@ /// The parameter where the result should be sent. /// An object that supplies culture-specific formatting information. /// Returns on success, on failure. + [CLSCompliant(false)] public static bool ToOrDefault(this IConvertible value, out T newObj, IFormatProvider provider = null) { if (value is null) @@ -76,6 +79,7 @@ /// The backup value. /// An object that supplies culture-specific formatting information. /// Returns the value converted to . + [CLSCompliant(false)] public static T ToOrOther(this IConvertible value, T other, IFormatProvider provider = null) { if (value is null) @@ -102,6 +106,7 @@ /// The backup value. /// An object that supplies culture-specific formatting information. /// Returns on success, on failure. + [CLSCompliant(false)] public static bool ToOrOther(this IConvertible value, out T newObj, T other, IFormatProvider provider = null) { if (value is null) @@ -129,6 +134,7 @@ /// The object to convert. /// An object that supplies culture-specific formatting information. /// Returns a or . + [CLSCompliant(false)] public static T ToOrNull(this IConvertible value, IFormatProvider provider = null) where T : class { @@ -143,6 +149,7 @@ /// The parameter where the result should be sent. /// An object that supplies culture-specific formatting information. /// Returns a or . + [CLSCompliant(false)] public static bool ToOrNull(this IConvertible value, out T newObj, IFormatProvider provider = null) where T : class { diff --git a/X10D/src/Int16Extensions.cs b/X10D/src/Int16Extensions.cs index 86d52f7..205ef05 100644 --- a/X10D/src/Int16Extensions.cs +++ b/X10D/src/Int16Extensions.cs @@ -30,6 +30,7 @@ /// Returns if is greater than it, /// if is less than it, /// or itself otherwise. + [CLSCompliant(false)] public static ushort Clamp(this ushort value, ushort min, ushort max) { return Math.Min(Math.Max(value, min), max); @@ -53,6 +54,7 @@ /// /// The number to convert. /// Returns a []. + [CLSCompliant(false)] public static byte[] GetBytes(this ushort number) { return BitConverter.GetBytes(number); @@ -85,6 +87,7 @@ /// The number. /// Returns if is even, /// otherwise. + [CLSCompliant(false)] public static bool IsEven(this ushort number) { return ((ulong)number).IsEven(); @@ -107,6 +110,7 @@ /// The number. /// Returns if is odd, /// otherwise. + [CLSCompliant(false)] public static bool IsOdd(this ushort number) { return !number.IsEven(); @@ -129,6 +133,7 @@ /// The number. /// Returns if is prime, /// otherwise. + [CLSCompliant(false)] public static bool IsPrime(this ushort number) { return ((ulong)number).IsPrime(); @@ -151,6 +156,7 @@ /// The integer. /// Returns if is 0, /// otherwise. + [CLSCompliant(false)] public static bool ToBoolean(this ushort value) { return ((ulong)value).ToBoolean(); diff --git a/X10D/src/Int32Extensions.cs b/X10D/src/Int32Extensions.cs index 9d6554b..5c0c633 100644 --- a/X10D/src/Int32Extensions.cs +++ b/X10D/src/Int32Extensions.cs @@ -30,6 +30,7 @@ /// Returns if is greater than it, /// if is less than it, /// or itself otherwise. + [CLSCompliant(false)] public static uint Clamp(this uint value, uint min, uint max) { return Math.Min(Math.Max(value, min), max); @@ -53,6 +54,7 @@ /// /// The number to convert. /// Returns a []. + [CLSCompliant(false)] public static byte[] GetBytes(this uint number) { return BitConverter.GetBytes(number); @@ -85,6 +87,7 @@ /// The number. /// Returns if is even, /// otherwise. + [CLSCompliant(false)] public static bool IsEven(this uint number) { return ((ulong)number).IsEven(); @@ -107,6 +110,7 @@ /// The number. /// Returns if is odd, /// otherwise. + [CLSCompliant(false)] public static bool IsOdd(this uint number) { return !number.IsEven(); @@ -140,6 +144,7 @@ /// The integer. /// Returns if is 0, /// otherwise. + [CLSCompliant(false)] public static bool ToBoolean(this uint value) { return ((ulong)value).ToBoolean(); diff --git a/X10D/src/Int64Extensions.cs b/X10D/src/Int64Extensions.cs index e2b7d93..579f353 100644 --- a/X10D/src/Int64Extensions.cs +++ b/X10D/src/Int64Extensions.cs @@ -30,6 +30,7 @@ /// Returns if is greater than it, /// if is less than it, /// or itself otherwise. + [CLSCompliant(false)] public static ulong Clamp(this ulong value, ulong min, ulong max) { return Math.Min(Math.Max(value, min), max); @@ -57,6 +58,7 @@ /// /// The number to convert. /// Returns a []. + [CLSCompliant(false)] public static byte[] GetBytes(this ulong number) { return BitConverter.GetBytes(number); @@ -89,6 +91,7 @@ /// The number. /// Returns if is even, /// otherwise. + [CLSCompliant(false)] public static bool IsEven(this ulong number) { return Math.Abs(number % 2.0) < double.Epsilon; @@ -111,6 +114,7 @@ /// The number. /// Returns if is odd, /// otherwise. + [CLSCompliant(false)] public static bool IsOdd(this ulong number) { return !IsEven(number); @@ -157,6 +161,7 @@ /// The number. /// Returns if is prime, /// otherwise. + [CLSCompliant(false)] public static bool IsPrime(this ulong number) { if (number <= 1) @@ -203,6 +208,7 @@ /// The integer. /// Returns if is 0, /// otherwise. + [CLSCompliant(false)] public static bool ToBoolean(this ulong value) { return value != 0;