mirror of
https://github.com/oliverbooth/X10D
synced 2024-11-09 23:45:42 +00:00
👍 CLSCompliant assemblies
This commit is contained in:
parent
1780ae3a40
commit
5034e1ceb4
3
X10D.Tests/src/Assembly.cs
Normal file
3
X10D.Tests/src/Assembly.cs
Normal file
@ -0,0 +1,3 @@
|
||||
using System;
|
||||
|
||||
[assembly: CLSCompliant(true)]
|
3
X10D/src/Assembly.cs
Normal file
3
X10D/src/Assembly.cs
Normal file
@ -0,0 +1,3 @@
|
||||
using System;
|
||||
|
||||
[assembly: CLSCompliant(true)]
|
@ -55,6 +55,7 @@
|
||||
/// </summary>
|
||||
/// <param name="bytes">The bytes to convert.</param>
|
||||
/// <returns>Returns an <see cref="ushort"/>.</returns>
|
||||
[CLSCompliant(false)]
|
||||
public static ushort GetUInt16(this IEnumerable<byte> bytes)
|
||||
{
|
||||
return BitConverter.ToUInt16(bytes.ToArray(), 0);
|
||||
@ -65,6 +66,7 @@
|
||||
/// </summary>
|
||||
/// <param name="bytes">The bytes to convert.</param>
|
||||
/// <returns>Returns an <see cref="uint"/>.</returns>
|
||||
[CLSCompliant(false)]
|
||||
public static uint GetUInt32(this IEnumerable<byte> bytes)
|
||||
{
|
||||
return BitConverter.ToUInt32(bytes.ToArray(), 0);
|
||||
@ -75,6 +77,7 @@
|
||||
/// </summary>
|
||||
/// <param name="bytes">The bytes to convert.</param>
|
||||
/// <returns>Returns an <see cref="ulong"/>.</returns>
|
||||
[CLSCompliant(false)]
|
||||
public static ulong GetUInt64(this IEnumerable<byte> bytes)
|
||||
{
|
||||
return BitConverter.ToUInt64(bytes.ToArray(), 0);
|
||||
|
@ -17,6 +17,7 @@
|
||||
/// <exception cref="InvalidCastException">This conversion is not supported.
|
||||
/// -or-
|
||||
/// <paramref name="value"/> is <see langword="null"/> and <typeparamref name="T"/> is a value type.</exception>
|
||||
[CLSCompliant(false)]
|
||||
public static T To<T>(this IConvertible value, IFormatProvider provider = null)
|
||||
{
|
||||
if (value is null)
|
||||
@ -35,6 +36,7 @@
|
||||
/// <param name="provider">The format provider.</param>
|
||||
/// <returns>Returns the value converted to <see cref="T"/>.</returns>
|
||||
/// <exception cref="InvalidCastException">This conversion is not supported.</exception>
|
||||
[CLSCompliant(false)]
|
||||
public static T ToOrDefault<T>(this IConvertible value, IFormatProvider provider = null)
|
||||
{
|
||||
return value is null ? default : To<T>(value, provider);
|
||||
@ -48,6 +50,7 @@
|
||||
/// <param name="newObj">The parameter where the result should be sent.</param>
|
||||
/// <param name="provider">An object that supplies culture-specific formatting information.</param>
|
||||
/// <returns>Returns <see langword="true"/> on success, <see langword="true"/> on failure.</returns>
|
||||
[CLSCompliant(false)]
|
||||
public static bool ToOrDefault<T>(this IConvertible value, out T newObj, IFormatProvider provider = null)
|
||||
{
|
||||
if (value is null)
|
||||
@ -76,6 +79,7 @@
|
||||
/// <param name="other">The backup value.</param>
|
||||
/// <param name="provider">An object that supplies culture-specific formatting information.</param>
|
||||
/// <returns>Returns the value converted to <see cref="T"/>.</returns>
|
||||
[CLSCompliant(false)]
|
||||
public static T ToOrOther<T>(this IConvertible value, T other, IFormatProvider provider = null)
|
||||
{
|
||||
if (value is null)
|
||||
@ -102,6 +106,7 @@
|
||||
/// <param name="other">The backup value.</param>
|
||||
/// <param name="provider">An object that supplies culture-specific formatting information.</param>
|
||||
/// <returns>Returns <see langword="true"/> on success, <see langword="true"/> on failure.</returns>
|
||||
[CLSCompliant(false)]
|
||||
public static bool ToOrOther<T>(this IConvertible value, out T newObj, T other, IFormatProvider provider = null)
|
||||
{
|
||||
if (value is null)
|
||||
@ -129,6 +134,7 @@
|
||||
/// <param name="value">The object to convert.</param>
|
||||
/// <param name="provider">An object that supplies culture-specific formatting information.</param>
|
||||
/// <returns>Returns a <see cref="T"/> or <see langword="null"/>.</returns>
|
||||
[CLSCompliant(false)]
|
||||
public static T ToOrNull<T>(this IConvertible value, IFormatProvider provider = null)
|
||||
where T : class
|
||||
{
|
||||
@ -143,6 +149,7 @@
|
||||
/// <param name="newObj">The parameter where the result should be sent.</param>
|
||||
/// <param name="provider">An object that supplies culture-specific formatting information.</param>
|
||||
/// <returns>Returns a <see cref="T"/> or <see langword="null"/>.</returns>
|
||||
[CLSCompliant(false)]
|
||||
public static bool ToOrNull<T>(this IConvertible value, out T newObj, IFormatProvider provider = null)
|
||||
where T : class
|
||||
{
|
||||
|
@ -30,6 +30,7 @@
|
||||
/// <returns>Returns <paramref name="max"/> if <paramref name="value"/> is greater than it,
|
||||
/// <paramref name="min"/> if <paramref name="value"/> is less than it,
|
||||
/// or <paramref name="value"/> itself otherwise.</returns>
|
||||
[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 @@
|
||||
/// </summary>
|
||||
/// <param name="number">The number to convert.</param>
|
||||
/// <returns>Returns a <see cref="byte"/>[].</returns>
|
||||
[CLSCompliant(false)]
|
||||
public static byte[] GetBytes(this ushort number)
|
||||
{
|
||||
return BitConverter.GetBytes(number);
|
||||
@ -85,6 +87,7 @@
|
||||
/// <param name="number">The number.</param>
|
||||
/// <returns>Returns <see langword="true"/> if <paramref name="number"/> is even, <see langword="false"/>
|
||||
/// otherwise.</returns>
|
||||
[CLSCompliant(false)]
|
||||
public static bool IsEven(this ushort number)
|
||||
{
|
||||
return ((ulong)number).IsEven();
|
||||
@ -107,6 +110,7 @@
|
||||
/// <param name="number">The number.</param>
|
||||
/// <returns>Returns <see langword="true"/> if <paramref name="number"/> is odd, <see langword="false"/>
|
||||
/// otherwise.</returns>
|
||||
[CLSCompliant(false)]
|
||||
public static bool IsOdd(this ushort number)
|
||||
{
|
||||
return !number.IsEven();
|
||||
@ -129,6 +133,7 @@
|
||||
/// <param name="number">The number.</param>
|
||||
/// <returns>Returns <see langword="true"/> if <paramref name="number"/> is prime, <see langword="false"/>
|
||||
/// otherwise.</returns>
|
||||
[CLSCompliant(false)]
|
||||
public static bool IsPrime(this ushort number)
|
||||
{
|
||||
return ((ulong)number).IsPrime();
|
||||
@ -151,6 +156,7 @@
|
||||
/// <param name="value">The integer.</param>
|
||||
/// <returns>Returns <see langword="false"/> if <paramref name="value"/> is 0,
|
||||
/// <see langword="true"/> otherwise.</returns>
|
||||
[CLSCompliant(false)]
|
||||
public static bool ToBoolean(this ushort value)
|
||||
{
|
||||
return ((ulong)value).ToBoolean();
|
||||
|
@ -30,6 +30,7 @@
|
||||
/// <returns>Returns <paramref name="max"/> if <paramref name="value"/> is greater than it,
|
||||
/// <paramref name="min"/> if <paramref name="value"/> is less than it,
|
||||
/// or <paramref name="value"/> itself otherwise.</returns>
|
||||
[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 @@
|
||||
/// </summary>
|
||||
/// <param name="number">The number to convert.</param>
|
||||
/// <returns>Returns a <see cref="byte"/>[].</returns>
|
||||
[CLSCompliant(false)]
|
||||
public static byte[] GetBytes(this uint number)
|
||||
{
|
||||
return BitConverter.GetBytes(number);
|
||||
@ -85,6 +87,7 @@
|
||||
/// <param name="number">The number.</param>
|
||||
/// <returns>Returns <see langword="true"/> if <paramref name="number"/> is even, <see langword="false"/>
|
||||
/// otherwise.</returns>
|
||||
[CLSCompliant(false)]
|
||||
public static bool IsEven(this uint number)
|
||||
{
|
||||
return ((ulong)number).IsEven();
|
||||
@ -107,6 +110,7 @@
|
||||
/// <param name="number">The number.</param>
|
||||
/// <returns>Returns <see langword="true"/> if <paramref name="number"/> is odd, <see langword="false"/>
|
||||
/// otherwise.</returns>
|
||||
[CLSCompliant(false)]
|
||||
public static bool IsOdd(this uint number)
|
||||
{
|
||||
return !number.IsEven();
|
||||
@ -140,6 +144,7 @@
|
||||
/// <param name="value">The integer.</param>
|
||||
/// <returns>Returns <see langword="false"/> if <paramref name="value"/> is 0,
|
||||
/// <see langword="true"/> otherwise.</returns>
|
||||
[CLSCompliant(false)]
|
||||
public static bool ToBoolean(this uint value)
|
||||
{
|
||||
return ((ulong)value).ToBoolean();
|
||||
|
@ -30,6 +30,7 @@
|
||||
/// <returns>Returns <paramref name="max"/> if <paramref name="value"/> is greater than it,
|
||||
/// <paramref name="min"/> if <paramref name="value"/> is less than it,
|
||||
/// or <paramref name="value"/> itself otherwise.</returns>
|
||||
[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 @@
|
||||
/// </summary>
|
||||
/// <param name="number">The number to convert.</param>
|
||||
/// <returns>Returns a <see cref="byte"/>[].</returns>
|
||||
[CLSCompliant(false)]
|
||||
public static byte[] GetBytes(this ulong number)
|
||||
{
|
||||
return BitConverter.GetBytes(number);
|
||||
@ -89,6 +91,7 @@
|
||||
/// <param name="number">The number.</param>
|
||||
/// <returns>Returns <see langword="true"/> if <paramref name="number"/> is even, <see langword="false"/>
|
||||
/// otherwise.</returns>
|
||||
[CLSCompliant(false)]
|
||||
public static bool IsEven(this ulong number)
|
||||
{
|
||||
return Math.Abs(number % 2.0) < double.Epsilon;
|
||||
@ -111,6 +114,7 @@
|
||||
/// <param name="number">The number.</param>
|
||||
/// <returns>Returns <see langword="true"/> if <paramref name="number"/> is odd, <see langword="false"/>
|
||||
/// otherwise.</returns>
|
||||
[CLSCompliant(false)]
|
||||
public static bool IsOdd(this ulong number)
|
||||
{
|
||||
return !IsEven(number);
|
||||
@ -157,6 +161,7 @@
|
||||
/// <param name="number">The number.</param>
|
||||
/// <returns>Returns <see langword="true"/> if <paramref name="number"/> is prime, <see langword="false"/>
|
||||
/// otherwise.</returns>
|
||||
[CLSCompliant(false)]
|
||||
public static bool IsPrime(this ulong number)
|
||||
{
|
||||
if (number <= 1)
|
||||
@ -203,6 +208,7 @@
|
||||
/// <param name="value">The integer.</param>
|
||||
/// <returns>Returns <see langword="false"/> if <paramref name="value"/> is 0,
|
||||
/// <see langword="true"/> otherwise.</returns>
|
||||
[CLSCompliant(false)]
|
||||
public static bool ToBoolean(this ulong value)
|
||||
{
|
||||
return value != 0;
|
||||
|
Loading…
Reference in New Issue
Block a user