From bc13247a89ca48f0f90decd1d09c711e2dc744c8 Mon Sep 17 00:00:00 2001 From: Emik03 Date: Tue, 24 Aug 2021 16:34:29 +0200 Subject: [PATCH] Changed library to be mostly CLS-Compliant --- Source/Abstracts/RoutineBase.cs | 2 + Source/Abstracts/WorkBase.cs | 11 +-- Source/Editors/ModuleScriptEditor.cs | 2 +- Source/Editors/TPScriptEditor.cs | 5 +- Source/Global.cs | 3 + Source/Helpers/EventHelper.cs | 8 ++ Source/Helpers/Helper.cs | 25 +++++- Source/Helpers/TypeHelper.cs | 84 ++++++++++++++++----- Source/Instances/CustomEqualityComparer.cs | 4 +- Source/Instances/Logger.cs | 1 + Source/Instances/ModuleContainer.cs | 12 ++- Source/Instances/Profiler.cs | 1 + Source/Instances/Routine.cs | 5 ++ Source/Instances/Sound.cs | 9 +++ Source/Instances/Work.cs | 12 +-- Source/Interfaces/ILog.cs | 5 +- Source/Interfaces/ITP.cs | 4 +- Source/MonoBehaviours/AudioScript.cs | 1 + Source/MonoBehaviours/CacheableBehaviour.cs | 1 + Source/MonoBehaviours/ModuleScript.cs | 1 + Source/MonoBehaviours/ReflectionScript.cs | 1 + Source/MonoBehaviours/TPScript.cs | 2 +- 22 files changed, 155 insertions(+), 44 deletions(-) create mode 100644 Source/Global.cs diff --git a/Source/Abstracts/RoutineBase.cs b/Source/Abstracts/RoutineBase.cs index ac640070..d304f115 100644 --- a/Source/Abstracts/RoutineBase.cs +++ b/Source/Abstracts/RoutineBase.cs @@ -138,6 +138,7 @@ public abstract class RoutineBase : IEnumerable, IEnumerable /// The index to index into . /// The parameter is out of range from . /// The coroutine from . + [CLSCompliant(false)] public Coroutine this[int index] => Coroutines[index]; /// @@ -303,6 +304,7 @@ public abstract class RoutineBase : IEnumerable, IEnumerable /// /// /// + [CLSCompliant(false)] public List Coroutines { get; private protected set; } = new List(); /// diff --git a/Source/Abstracts/WorkBase.cs b/Source/Abstracts/WorkBase.cs index 1e3e595d..5ae5cb91 100644 --- a/Source/Abstracts/WorkBase.cs +++ b/Source/Abstracts/WorkBase.cs @@ -1,4 +1,5 @@ -using System.Collections; +using System; +using System.Collections; using System.Threading; using UnityEngine; @@ -9,11 +10,11 @@ namespace KeepCoding.Internal /// public abstract class WorkBase { - private readonly uint _maximumThreadsActive; + private readonly int _maximumThreadsActive; - internal WorkBase() : this(true, 1) { } + private protected WorkBase() : this(true, 1) { } - internal WorkBase(in bool allowSimultaneousActive, in uint maximumThreadsActive) + private protected WorkBase(in bool allowSimultaneousActive, in int maximumThreadsActive) { AllowSimultaneousActive = allowSimultaneousActive; _maximumThreadsActive = maximumThreadsActive; @@ -32,7 +33,7 @@ internal WorkBase(in bool allowSimultaneousActive, in uint maximumThreadsActive) /// /// Counts the number of threads currently active within this class, and all of its overloads. /// - public static uint ThreadsActive { get; private protected set; } + public static int ThreadsActive { get; private protected set; } /// /// The thread of the class. diff --git a/Source/Editors/ModuleScriptEditor.cs b/Source/Editors/ModuleScriptEditor.cs index f93b0606..483f60bf 100644 --- a/Source/Editors/ModuleScriptEditor.cs +++ b/Source/Editors/ModuleScriptEditor.cs @@ -18,7 +18,7 @@ namespace KeepCoding.Internal /// /// Custom inspector for . /// - [CanEditMultipleObjects, CustomEditor(typeof(ModuleScript), true)] + [CanEditMultipleObjects, CLSCompliant(false), CustomEditor(typeof(ModuleScript), true)] public sealed class ModuleScriptEditor : Editor { private static string SelfPath => UnescapeDataString(new UriBuilder(GetExecutingAssembly().CodeBase).Path); diff --git a/Source/Editors/TPScriptEditor.cs b/Source/Editors/TPScriptEditor.cs index ad8600bc..bbaa70d7 100644 --- a/Source/Editors/TPScriptEditor.cs +++ b/Source/Editors/TPScriptEditor.cs @@ -1,4 +1,5 @@ -using System.Collections; +using System; +using System.Collections; using System.Linq; using UnityEditor; using static UnityEngine.GUILayout; @@ -9,7 +10,7 @@ namespace KeepCoding.Internal /// /// Custom inspector for . /// - [CanEditMultipleObjects, CustomEditor(typeof(TPScript<>), true)] + [CanEditMultipleObjects, CLSCompliant(false), CustomEditor(typeof(TPScript<>), true)] public sealed class TPScriptEditor : Editor { /// diff --git a/Source/Global.cs b/Source/Global.cs new file mode 100644 index 00000000..8c114539 --- /dev/null +++ b/Source/Global.cs @@ -0,0 +1,3 @@ +using System; + +[assembly: CLSCompliant(true)] diff --git a/Source/Helpers/EventHelper.cs b/Source/Helpers/EventHelper.cs index 3322ca2a..94ff24d0 100644 --- a/Source/Helpers/EventHelper.cs +++ b/Source/Helpers/EventHelper.cs @@ -24,6 +24,7 @@ public static class EventHelper /// The bomb info instance to assign events to. /// Called when the bomb explodes. /// Called when the bomb is defused. + [CLSCompliant(false)] public static KMBombInfo Assign(this KMBombInfo bombInfo, Action onBombExploded = null, Action onBombSolved = null) { AssertDefault(bombInfo); @@ -44,6 +45,7 @@ public static KMBombInfo Assign(this KMBombInfo bombInfo, Action onBombExploded /// Called when the lights turn on. /// Called when the module is solved. /// Called when the module strikes. + [CLSCompliant(false)] public static KMBombModule Assign(this KMBombModule bombModule, Action onActivate = null, Action onPass = null, Action onStrike = null) { AssertDefault(bombModule); @@ -66,6 +68,7 @@ public static KMBombModule Assign(this KMBombModule bombModule, Action onActivat /// Called when the state of the game changes. /// Called when the alarm clock changes state, and passes in whether it's on or off. /// Called when the lights change state, and passes in whether it's on or off. + [CLSCompliant(false)] public static KMGameInfo Assign(this KMGameInfo gameInfo, Action onStateChange = null, Action onAlarmClockChange = null, Action onLightsChange = null) { AssertDefault(gameInfo); @@ -90,6 +93,7 @@ public static KMGameInfo Assign(this KMGameInfo gameInfo, Action onStateC /// Called when the needy is solved. /// Called when the needy strikes. /// Called when the timer runs out of time. + [CLSCompliant(false)] public static KMNeedyModule Assign(this KMNeedyModule needyModule, Action onActivate = null, Action onNeedyActivation = null, Action onNeedyDeactivation = null, Action onPass = null, Action onStrike = null, Action onTimerExpired = null) { AssertDefault(needyModule); @@ -126,6 +130,7 @@ public static KMNeedyModule Assign(this KMNeedyModule needyModule, Action onActi /// Called when the right controller stick is pulled while selected. /// Called whenever the selectable becomes the current selectable. /// Called when the selectable updates its children. + [CLSCompliant(false)] public static KMSelectable Assign(this KMSelectable selectable, bool? overrideReturn = null, Action onCancel = null, Action onDefocus = null, Action onDeselect = null, Action onFocus = null, Action onHighlight = null, Action onHighlightEnded = null, Action onInteract = null, Action onInteractEnded = null, Action onInteractionPunch = null, Action onLeft = null, Action onRight = null, Action onSelect = null, Action onUpdateChildren = null) { AssertDefault(selectable); @@ -173,6 +178,7 @@ public static KMSelectable Assign(this KMSelectable selectable, bool? overrideRe /// Called when the right controller stick is pulled while selected. /// Called whenever the selectable becomes the current selectable. /// Called when the selectable updates its children. + [CLSCompliant(false)] public static KMSelectable[] Assign(this KMSelectable[] selectable, bool? overrideReturn = null, Action onCancel = null, Action onDefocus = null, Action onDeselect = null, Action onFocus = null, Action onHighlight = null, Action onHighlightEnded = null, Action onInteract = null, Action onInteractEnded = null, Action onInteractionPunch = null, Action onLeft = null, Action onRight = null, Action onSelect = null, Action onUpdateChildren = null) => selectable.NullOrEmptyCheck("The array is not populated. Please check your public fields in Unity.").ToArray().Call((s, i) => s.Assign( overrideReturn, @@ -214,6 +220,7 @@ public static KMSelectable[] Assign(this KMSelectable[] selectable, bool? overri /// Called when the right controller stick is pulled while selected. /// Called whenever the selectable becomes the current selectable. /// Called when the selectable updates its children. + [CLSCompliant(false)] public static KMSelectable[] Assign(this KMSelectable[] selectable, bool? overrideReturn = null, Action onCancel = null, Action onDefocus = null, Action onDeselect = null, Action onFocus = null, Action onHighlight = null, Action onHighlightEnded = null, Action onInteract = null, Action onInteractEnded = null, Action onInteractionPunch = null, Action onLeft = null, Action onRight = null, Action onSelect = null, Action onUpdateChildren = null) => selectable.NullOrEmptyCheck("The array is not populated. Please check your public fields in Unity.").ToArray().ForEach(s => s.Assign( overrideReturn, @@ -235,6 +242,7 @@ public static KMSelectable[] Assign(this KMSelectable[] selectable, bool? overri /// Stops all sounds for the entire . /// /// The to mute all sounds from, using . + [CLSCompliant(false)] public static KMAudioRef[] StopSound(this KMAudioRef[] audioRefs) => audioRefs.ForEach(a => a.StopSound()); /// diff --git a/Source/Helpers/Helper.cs b/Source/Helpers/Helper.cs index 8230baaa..7e9db456 100644 --- a/Source/Helpers/Helper.cs +++ b/Source/Helpers/Helper.cs @@ -63,6 +63,7 @@ public static class Helper /// The game object to search with. /// The variable to store the component in. /// True if a component has been found of type from . + [CLSCompliant(false)] public static bool HasComponent(this GameObject obj, out T component) where T : Component => (component = obj.GetComponent()) is T; /// @@ -186,6 +187,7 @@ public static class Helper /// The minimum value required to return . /// The maximum value required to return . /// True if is more than or equal and less than or equal . + [CLSCompliant(false)] public static bool IsBetween(this uint comparison, uint min, uint max) => comparison >= min && comparison <= max; /// @@ -194,6 +196,7 @@ public static class Helper /// The number to use as comparison. /// The minimum and maximum value required to return . /// True if is more than or equal and less than or equal . + [CLSCompliant(false)] public static bool IsBetween(this uint comparison, Tuple range) => comparison >= range.Item1 && comparison <= range.Item2; /// @@ -203,6 +206,7 @@ public static class Helper /// The minimum value required to return . /// The maximum value required to return . /// True if is more than or equal and less than or equal . + [CLSCompliant(false)] public static bool IsBetween(this ulong comparison, ulong min, ulong max) => comparison >= min && comparison <= max; /// @@ -211,6 +215,7 @@ public static class Helper /// The number to use as comparison. /// The minimum and maximum value required to return . /// True if is more than or equal and less than or equal . + [CLSCompliant(false)] public static bool IsBetween(this ulong comparison, Tuple range) => comparison >= range.Item1 && comparison <= range.Item2; /// @@ -254,6 +259,7 @@ public static class Helper /// /// This is required to check the children field. /// True if is empty. + [CLSCompliant(false)] public static bool IsParent(this KMSelectable kmSelectable) => !kmSelectable.Children.IsNullOrEmpty(); /// @@ -332,8 +338,8 @@ public static class Helper /// Counts the number of members in an enum. /// /// The enum to check the length for. - /// The number of members in . - public static int MemberCount() where T : struct, Enum, IConvertible => Enum.GetNames(typeof(T)).Length; + /// The number of members in . + public static int MemberCount() where T : struct, Enum => Enum.GetNames(typeof(T)).Length; /// /// Calculates the rem-euclid modulo, which allows negative numbers to be properly calculated. @@ -521,12 +527,17 @@ public static long BaseToLong(this string value, string baseChars = Binary) /// /// This can be useful to prevent a from going outside its boundaries. A monospaced font is recommended in this case. /// + /// + /// /// The string to insert line breaks with. /// The maximum number of characters in one line. /// with a line break every or less characters. - public static string InsertNewlines(this string condition, ushort maxLineLength) + public static string InsertNewlines(this string condition, int maxLineLength) { - if (maxLineLength == 0) + if (maxLineLength < 0) + throw new NegativeNumberException($"{nameof(maxLineLength)} must be a positive integer."); + + if (maxLineLength is 0) throw new FormatException($"{nameof(maxLineLength)} cannot be 0 because that would insert infinite linebreaks for each character."); condition = condition.NullCheck("Line breaks cannot be inserted in a null string.").Replace('\n', ' '); @@ -689,6 +700,7 @@ static string Recursion(IEnumerable enumerable, string join, StringifyFormat for /// /// The type of method to get. /// The log method representing the enum . + [CLSCompliant(false)] public static Action Method(this LogType logType) => logType switch { LogType.Error => LogError, @@ -705,6 +717,7 @@ static string Recursion(IEnumerable enumerable, string join, StringifyFormat for /// The instance needed to stop coroutines. /// The s to stop. /// The array of s given. + [CLSCompliant(false)] public static Coroutine[] Stop(this MonoBehaviour monoBehaviour, params Coroutine[] coroutines) => coroutines?.ForEach(c => { if (c is { }) @@ -964,6 +977,7 @@ public static IEnumerator Flatten(this IEnumerator source, Predicate /// The instance of needed to get the modules. /// A list of unsolved module names. + [CLSCompliant(false)] public static List GetUnsolvedModuleIDs(this KMBombInfo bombInfo) { List modules = bombInfo.GetSolvableModuleIDs(); @@ -976,6 +990,7 @@ public static List GetUnsolvedModuleIDs(this KMBombInfo bombInfo) /// /// The instance of needed to get the modules. /// A list of unsolved modules. + [CLSCompliant(false)] public static List GetUnsolvedModuleNames(this KMBombInfo bombInfo) { List modules = bombInfo.GetSolvableModuleNames(); @@ -1044,6 +1059,7 @@ public static Tuple, IEnumerable> SplitBy(this IEnumerable< /// The to do a null check on. /// The message of the exception. /// The component . + [CLSCompliant(false)] public static T Assert(this T obj, string message = "While asserting for null, the variable ended up null.") where T : Object => obj ? obj : throw new MissingComponentException(message); /// @@ -1069,6 +1085,7 @@ public static T Call(this T item, Action action) /// The item to log /// The type of logging. /// The item . + [CLSCompliant(false)] public static T Call(this T item, LogType logType = LogType.Log) => item.Call(t => logType.Method()(t.Stringify())); /// diff --git a/Source/Helpers/TypeHelper.cs b/Source/Helpers/TypeHelper.cs index 653bd385..abab11fe 100644 --- a/Source/Helpers/TypeHelper.cs +++ b/Source/Helpers/TypeHelper.cs @@ -19,6 +19,7 @@ public static class TypeHelper /// The first color. /// The second color. /// Boolean, true only if both colors have the same R, G, B, and A values. + [CLSCompliant(false)] public static bool IsEqual(this Color32 colorA, Color32 colorB) => colorA.r == colorB.r && colorA.g == colorB.g && colorA.b == colorB.b && colorA.a == colorB.a; /// @@ -27,6 +28,7 @@ public static class TypeHelper /// The first color. /// The second color. /// Boolean, true only if both colors have the same R, G, B, and A values. + [CLSCompliant(false)] public static bool IsEqual(this Color colorA, Color colorB) => colorA.r == colorB.r && colorA.g == colorB.g && colorA.b == colorB.b && colorA.a == colorB.a; /// @@ -35,6 +37,7 @@ public static class TypeHelper /// The array of colors to compare to . /// The color to compare it to. /// Boolean, true only if any color in is the exact same as 's R, G, B, and A values. + [CLSCompliant(false)] public static bool IsAnyEqual(this Color32[] colors, Color32 color) => colors.NullCheck("You cannot iterate over a null array.").Any(c => c.IsEqual(color)); /// @@ -44,6 +47,7 @@ public static class TypeHelper /// The array of colors to compare to . /// The color to compare it to. /// Boolean, true only if any color in is the exact same as 's R, G, B, and A values. + [CLSCompliant(false)] public static bool IsAnyEqual(this Color[] colors, Color color) => colors.NullCheck("You cannot iterate over a null array.").Any(c => c.IsEqual(color)); /// @@ -58,6 +62,7 @@ public static class TypeHelper /// The green component. /// The alpha component; opacity. /// A new instance of the , with the arguments replacing the values. + [CLSCompliant(false)] public static Color Add(this Color color, float r = 0, float g = 0, float b = 0, float a = 0) => new Color( r + color.r, @@ -77,12 +82,13 @@ public static Color Add(this Color color, float r = 0, float g = 0, float b = 0, /// The green component. /// The alpha component; opacity. /// A new instance of the , with the arguments replacing the values. + [CLSCompliant(false)] public static Color Add(this Color color, byte r = 0, byte g = 0, byte b = 0, byte a = 0) => new Color( - (float)r / byte.MaxValue + color.r, - (float)g / byte.MaxValue + color.g, - (float)b / byte.MaxValue + color.b, - (float)a / byte.MaxValue + color.a); + (float)r / MaxValue + color.r, + (float)g / MaxValue + color.g, + (float)b / MaxValue + color.b, + (float)a / MaxValue + color.a); /// /// Creates an in-between color between 2 different colors. @@ -91,6 +97,7 @@ public static Color Add(this Color color, byte r = 0, byte g = 0, byte b = 0, by /// The second color, with 1 being biased towards this color. /// The bias towards either color, between 0-1. 0.5 blends both colors equally. /// A blended color of the 2 provided. + [CLSCompliant(false)] public static Color IntertwineColor(this Color colorA, Color colorB, float concentrationOfB = 0.5f) => new Color( colorA.r * (1 - concentrationOfB) + colorB.r * concentrationOfB, @@ -106,6 +113,7 @@ public static Color IntertwineColor(this Color colorA, Color colorB, float conce /// The second color, with 1 being biased towards this color. /// The bias towards either color, between 0-1. 0.5 blends both colors equally. /// The resulting color that the becomes. + [CLSCompliant(false)] public static Color IntertwineColor(this Renderer renderer, Color colorA, Color colorB, float concentrationOfB = 0.5f) => renderer.material.color = colorA.IntertwineColor(colorB, concentrationOfB); @@ -118,6 +126,7 @@ public static Color IntertwineColor(this Renderer renderer, Color colorA, Color /// The green component. /// The alpha component; opacity. /// A new instance of the , with the arguments replacing the values. + [CLSCompliant(false)] public static Color Set(this Color color, float? r = null, float? g = null, float? b = null, float? a = null) => new Color( r ?? color.r, @@ -134,12 +143,13 @@ public static Color Set(this Color color, float? r = null, float? g = null, floa /// The green component. /// The alpha component; opacity. /// A new instance of the , with the arguments replacing the values. + [CLSCompliant(false)] public static Color Set(this Color color, byte? r = null, byte? g = null, byte? b = null, byte? a = null) => new Color( - r.HasValue ? (float)r.Value / byte.MaxValue : color.r, - g.HasValue ? (float)g.Value / byte.MaxValue : color.g, - b.HasValue ? (float)b.Value / byte.MaxValue : color.b, - a.HasValue ? (float)a.Value / byte.MaxValue : color.a); + r.HasValue ? (float)r.Value / MaxValue : color.r, + g.HasValue ? (float)g.Value / MaxValue : color.g, + b.HasValue ? (float)b.Value / MaxValue : color.b, + a.HasValue ? (float)a.Value / MaxValue : color.a); /// /// Duplicates the color, and adds the RGBA components only if they are specified. @@ -153,12 +163,13 @@ public static Color Set(this Color color, byte? r = null, byte? g = null, byte? /// The green component. /// The alpha component; opacity. /// A new instance of the , with the arguments replacing the values. + [CLSCompliant(false)] public static Color32 Add(this Color32 color, float r = 0, float g = 0, float b = 0, float a = 0) => new Color32( - (byte)(r * byte.MaxValue + color.r), - (byte)(g * byte.MaxValue + color.g), - (byte)(b * byte.MaxValue + color.b), - (byte)(a * byte.MaxValue + color.a)); + (byte)(r * MaxValue + color.r), + (byte)(g * MaxValue + color.g), + (byte)(b * MaxValue + color.b), + (byte)(a * MaxValue + color.a)); /// /// Duplicates the color, and adds the RGBA components only if they are specified. @@ -172,6 +183,7 @@ public static Color32 Add(this Color32 color, float r = 0, float g = 0, float b /// The green component. /// The alpha component; opacity. /// A new instance of the , with the arguments replacing the values. + [CLSCompliant(false)] public static Color32 Add(this Color32 color, byte r = 0, byte g = 0, byte b = 0, byte a = 0) => new Color32( (byte)(r + color.r), @@ -185,11 +197,12 @@ public static Color32 Add(this Color32 color, byte r = 0, byte g = 0, byte b = 0 /// /// A string of hexadecimal, which can be formatted as "FFFFFF", "#FFFFFF", or "0xFFFFFF" /// converted from hexadecimal string. + [CLSCompliant(false)] public static Color32 HexToColor(this string hex) { hex = hex.Replace("0x", "").Replace("#", ""); - return hex.Length != 6 && hex.Length != 8 + return !(hex.Length is 6 || hex.Length is 8) ? throw new FormatException($"The hexadecimal code provided has the wrong length: {hex}") : hex.Any(c => !"0123456789ABCDEFabcdef".Contains(c.ToString())) ? throw new FormatException($"The hexadecimal code provided has invalid characters: {hex}") @@ -203,6 +216,7 @@ public static Color32 HexToColor(this string hex) /// The second color, with 1 being biased towards this color. /// The bias towards either color, between 0-1. 0.5 blends both colors equally. /// A blended color of the 2 provided. + [CLSCompliant(false)] public static Color32 IntertwineColor(this Color32 colorA, Color32 colorB, float concentrationOfB = 0.5f) => new Color32( (byte)(colorA.r * (1 - concentrationOfB) + colorB.r * concentrationOfB), @@ -218,6 +232,7 @@ public static Color32 IntertwineColor(this Color32 colorA, Color32 colorB, float /// The second color, with 1 being biased towards this color. /// The bias towards either color, between 0-1. 0.5 blends both colors equally. /// The resulting color that the becomes. + [CLSCompliant(false)] public static Color32 IntertwineColor(this Renderer renderer, Color32 colorA, Color32 colorB, float concentrationOfB = 0.5f) => renderer.material.color = colorA.IntertwineColor(colorB, concentrationOfB); @@ -230,6 +245,7 @@ public static Color32 IntertwineColor(this Renderer renderer, Color32 colorA, Co /// The green component. /// The alpha component; opacity. /// A new instance of the , with the arguments replacing the values. + [CLSCompliant(false)] public static Color32 Set(this Color32 color, float? r = null, float? g = null, float? b = null, float? a = null) => new Color32( r.HasValue ? (byte)(r.Value * MaxValue) : color.r, @@ -246,6 +262,7 @@ public static Color32 Set(this Color32 color, float? r = null, float? g = null, /// The green component. /// The alpha component; opacity. /// A new instance of the , with the arguments replacing the values. + [CLSCompliant(false)] public static Color32 Set(this Color32 color, byte? r = null, byte? g = null, byte? b = null, byte? a = null) => new Color32( r ?? color.r, @@ -260,8 +277,9 @@ public static Color32 Set(this Color32 color, byte? r = null, byte? g = null, by /// The discard which is only needed for the type. /// The name of the value. /// Determines whether to show the unique identifier when logging. + /// Determines whether the formatting should be compliant with the Logfile Analyzer. /// A new containing the arguments specified. - public static Logger ToLogger(this T _, string name = null, bool showId = false) => new Logger(name ?? typeof(T).Name, showId); + public static Logger ToLogger(this T _, string name = null, bool showId = false, bool showInLfa = true) => new Logger(name ?? typeof(T).Name, showId, showInLfa); /// /// Converts arguments to a new . @@ -269,6 +287,7 @@ public static Color32 Set(this Color32 color, byte? r = null, byte? g = null, by /// The function to call when the is called. /// The instance of the to start the from. /// A new containing the arguments provided. + [CLSCompliant(false)] public static Routine ToRoutine(this MonoBehaviour monoBehaviour, Func func) => new Routine(func, monoBehaviour); /// @@ -277,6 +296,7 @@ public static Color32 Set(this Color32 color, byte? r = null, byte? g = null, by /// The function to call when the is called. /// The instance of the to start the from. /// A new containing the arguments provided. + [CLSCompliant(false)] public static Routine ToRoutine(this MonoBehaviour monoBehaviour, Func func) => new Routine(func, monoBehaviour); /// @@ -285,6 +305,7 @@ public static Color32 Set(this Color32 color, byte? r = null, byte? g = null, by /// The function to call when the is called. /// The instance of the to start the from. /// A new containing the arguments provided. + [CLSCompliant(false)] public static Routine ToRoutine(this MonoBehaviour monoBehaviour, Func func) => new Routine(func, monoBehaviour); /// @@ -293,6 +314,7 @@ public static Color32 Set(this Color32 color, byte? r = null, byte? g = null, by /// The function to call when the is called. /// The instance of the to start the from. /// A new containing the arguments provided. + [CLSCompliant(false)] public static Routine ToRoutine(this MonoBehaviour monoBehaviour, Func func) => new Routine(func, monoBehaviour); /// @@ -301,6 +323,7 @@ public static Color32 Set(this Color32 color, byte? r = null, byte? g = null, by /// The function to call when the is called. /// The instance of the to start the from. /// A new containing the arguments provided. + [CLSCompliant(false)] public static Routine ToRoutine(this MonoBehaviour monoBehaviour, Func func) => new Routine(func, monoBehaviour); /// @@ -354,6 +377,7 @@ public static Color32 Set(this Color32 color, byte? r = null, byte? g = null, by /// The x value. /// The y value. /// A new instance of , with the arguments replacing the values. + [CLSCompliant(false)] public static Vector2 Add(ref Vector2 vector, float x = 0, float y = 0) => vector = new Vector2( x + vector.x, @@ -366,6 +390,7 @@ public static Vector2 Add(ref Vector2 vector, float x = 0, float y = 0) /// The x value. /// The y value. /// A new instance of , with the arguments replacing the values. + [CLSCompliant(false)] public static Vector2 Add(this Vector2 vector, float x = 0, float y = 0) => new Vector2( x + vector.x, @@ -378,6 +403,7 @@ public static Vector2 Add(this Vector2 vector, float x = 0, float y = 0) /// The x value. /// The y value. /// A new instance of , with the arguments replacing the values. + [CLSCompliant(false)] public static Vector2Int Add(ref Vector2Int vector, int x = 0, int y = 0) => vector = new Vector2Int( x + vector.x, @@ -390,6 +416,7 @@ public static Vector2Int Add(ref Vector2Int vector, int x = 0, int y = 0) /// The x value. /// The y value. /// A new instance of , with the arguments replacing the values. + [CLSCompliant(false)] public static Vector2Int Add(this Vector2Int vector, int x = 0, int y = 0) => new Vector2Int( x + vector.x, @@ -403,6 +430,7 @@ public static Vector2Int Add(this Vector2Int vector, int x = 0, int y = 0) /// The y value. /// The z value. /// A new instance of , with the arguments replacing the values. + [CLSCompliant(false)] public static Vector3 Add(ref Vector3 vector, float x = 0, float y = 0, float z = 0) => vector = new Vector3( x + vector.x, @@ -417,6 +445,7 @@ public static Vector3 Add(ref Vector3 vector, float x = 0, float y = 0, float z /// The y value. /// The z value. /// A new instance of , with the arguments replacing the values. + [CLSCompliant(false)] public static Vector3 Add(this Vector3 vector, float x = 0, float y = 0, float z = 0) => new Vector3( x + vector.x, @@ -431,6 +460,7 @@ public static Vector3 Add(this Vector3 vector, float x = 0, float y = 0, float z /// The y value. /// The z value. /// A new instance of , with the arguments replacing the values. + [CLSCompliant(false)] public static Vector3Int Add(ref Vector3Int vector, int x = 0, int y = 0, int z = 0) => vector = new Vector3Int( x + vector.x, @@ -445,6 +475,7 @@ public static Vector3Int Add(ref Vector3Int vector, int x = 0, int y = 0, int z /// The y value. /// The z value. /// A new instance of , with the arguments replacing the values. + [CLSCompliant(false)] public static Vector3Int Add(this Vector3Int vector, int x = 0, int y = 0, int z = 0) => new Vector3Int( x + vector.x, @@ -460,6 +491,7 @@ public static Vector3Int Add(this Vector3Int vector, int x = 0, int y = 0, int z /// The z value. /// The w value. /// A new instance of , with the arguments replacing the values. + [CLSCompliant(false)] public static Vector4 Add(ref Vector4 vector, float x = 0, float y = 0, float z = 0, float w = 0) => vector = new Vector4( x + vector.x, @@ -476,6 +508,7 @@ public static Vector4 Add(ref Vector4 vector, float x = 0, float y = 0, float z /// The z value. /// The w value. /// A new instance of , with the arguments replacing the values. + [CLSCompliant(false)] public static Vector4 Add(this Vector4 vector, float x = 0, float y = 0, float z = 0, float w = 0) => new Vector4( x + vector.x, @@ -490,6 +523,7 @@ public static Vector4 Add(this Vector4 vector, float x = 0, float y = 0, float z /// The x value. /// The y value. /// A new instance of , with the arguments replacing the values. + [CLSCompliant(false)] public static Vector2 Set(ref Vector2 vector, float? x = null, float? y = null) => vector = new Vector2( x ?? vector.x, @@ -502,6 +536,7 @@ public static Vector2 Set(ref Vector2 vector, float? x = null, float? y = null) /// The x value. /// The y value. /// A new instance of , with the arguments replacing the values. + [CLSCompliant(false)] public static Vector2 Set(this Vector2 vector, float? x = null, float? y = null) => new Vector2( x ?? vector.x, @@ -514,6 +549,7 @@ public static Vector2 Set(this Vector2 vector, float? x = null, float? y = null) /// The x value. /// The y value. /// A new instance of , with the arguments replacing the values. + [CLSCompliant(false)] public static Vector2Int Set(ref Vector2Int vector, int? x = null, int? y = null) => vector = new Vector2Int( x ?? vector.x, @@ -526,6 +562,7 @@ public static Vector2Int Set(ref Vector2Int vector, int? x = null, int? y = null /// The x value. /// The y value. /// A new instance of , with the arguments replacing the values. + [CLSCompliant(false)] public static Vector2Int Set(this Vector2Int vector, int? x = null, int? y = null) => new Vector2Int( x ?? vector.x, @@ -539,6 +576,7 @@ public static Vector2Int Set(this Vector2Int vector, int? x = null, int? y = nul /// The y value. /// The z value. /// A new instance of , with the arguments replacing the values. + [CLSCompliant(false)] public static Vector3 Set(ref Vector3 vector, float? x = null, float? y = null, float? z = null) => vector = new Vector3( x ?? vector.x, @@ -553,6 +591,7 @@ public static Vector3 Set(ref Vector3 vector, float? x = null, float? y = null, /// The y value. /// The z value. /// A new instance of , with the arguments replacing the values. + [CLSCompliant(false)] public static Vector3 Set(this Vector3 vector, float? x = null, float? y = null, float? z = null) => new Vector3( x ?? vector.x, @@ -567,6 +606,7 @@ public static Vector3 Set(this Vector3 vector, float? x = null, float? y = null, /// The y value. /// The z value. /// A new instance of , with the arguments replacing the values. + [CLSCompliant(false)] public static Vector3Int Set(ref Vector3Int vector, int? x = null, int? y = null, int? z = null) => vector = new Vector3Int( x ?? vector.x, @@ -581,6 +621,7 @@ public static Vector3Int Set(ref Vector3Int vector, int? x = null, int? y = null /// The y value. /// The z value. /// A new instance of , with the arguments replacing the values. + [CLSCompliant(false)] public static Vector3Int Set(this Vector3Int vector, int? x = null, int? y = null, int? z = null) => new Vector3Int( x ?? vector.x, @@ -596,6 +637,7 @@ public static Vector3Int Set(this Vector3Int vector, int? x = null, int? y = nul /// The z value. /// The w value. /// A new instance of , with the arguments replacing the values. + [CLSCompliant(false)] public static Vector4 Set(ref Vector4 vector, float? x = null, float? y = null, float? z = null, float? w = null) => vector = new Vector4( x ?? vector.x, @@ -612,6 +654,7 @@ public static Vector4 Set(ref Vector4 vector, float? x = null, float? y = null, /// The z value. /// The w value. /// A new instance of , with the arguments replacing the values. + [CLSCompliant(false)] public static Vector4 Set(this Vector4 vector, float? x = null, float? y = null, float? z = null, float? w = null) => new Vector4( x ?? vector.x, @@ -640,7 +683,7 @@ public static Vector4 Set(this Vector4 vector, float? x = null, float? y = null, /// Whether it should allow multiple of itself to be running at once. /// The amount of threads this class, and all of its overloads can run at once. /// A new consisting of the arguments provided. - public static Work ToWork(this uint maximumThreadsActive, Action action, bool allowSimultaneousActive = false) => new Work(action, allowSimultaneousActive, maximumThreadsActive); + public static Work ToWork(this int maximumThreadsActive, Action action, bool allowSimultaneousActive = false) => new Work(action, allowSimultaneousActive, maximumThreadsActive); /// /// Converts argument to a new @@ -656,7 +699,7 @@ public static Vector4 Set(this Vector4 vector, float? x = null, float? y = null, /// Whether it should allow multiple of itself to be running at once. /// The amount of threads this class, and all of its overloads can run at once. /// A new consisting of the arguments provided. - public static Work ToWork(this uint maximumThreadsActive, Func func, bool allowSimultaneousActive = false) => new Work(func, allowSimultaneousActive, maximumThreadsActive); + public static Work ToWork(this int maximumThreadsActive, Func func, bool allowSimultaneousActive = false) => new Work(func, allowSimultaneousActive, maximumThreadsActive); /// /// Converts argument to a new @@ -672,7 +715,7 @@ public static Vector4 Set(this Vector4 vector, float? x = null, float? y = null, /// Whether it should allow multiple of itself to be running at once. /// The amount of threads this class, and all of its overloads can run at once. /// A new consisting of the arguments provided. - public static Work ToWork(this uint maximumThreadsActive, Func func, bool allowSimultaneousActive = false) => new Work(func, allowSimultaneousActive, maximumThreadsActive); + public static Work ToWork(this int maximumThreadsActive, Func func, bool allowSimultaneousActive = false) => new Work(func, allowSimultaneousActive, maximumThreadsActive); /// /// Converts argument to a new @@ -688,7 +731,7 @@ public static Vector4 Set(this Vector4 vector, float? x = null, float? y = null, /// Whether it should allow multiple of itself to be running at once. /// The amount of threads this class, and all of its overloads can run at once. /// A new consisting of the arguments provided. - public static Work ToWork(this uint maximumThreadsActive, Func func, bool allowSimultaneousActive = false) => new Work(func, allowSimultaneousActive, maximumThreadsActive); + public static Work ToWork(this int maximumThreadsActive, Func func, bool allowSimultaneousActive = false) => new Work(func, allowSimultaneousActive, maximumThreadsActive); /// /// Converts argument to a new @@ -704,13 +747,14 @@ public static Vector4 Set(this Vector4 vector, float? x = null, float? y = null, /// Whether it should allow multiple of itself to be running at once. /// The amount of threads this class, and all of its overloads can run at once. /// A new consisting of the arguments provided. - public static Work ToWork(this uint maximumThreadsActive, Func func, bool allowSimultaneousActive = false) => new Work(func, allowSimultaneousActive, maximumThreadsActive); + public static Work ToWork(this int maximumThreadsActive, Func func, bool allowSimultaneousActive = false) => new Work(func, allowSimultaneousActive, maximumThreadsActive); /// /// Converts argument to a new /// /// The action to run when the thread is active. /// A new consisting of the arguments provided. + [CLSCompliant(true)] public static Work ToWork(this Func func) => new Work(func); /// @@ -720,6 +764,6 @@ public static Vector4 Set(this Vector4 vector, float? x = null, float? y = null, /// Whether it should allow multiple of itself to be running at once. /// The amount of threads this class, and all of its overloads can run at once. /// A new consisting of the arguments provided. - public static Work ToWork(this uint maximumThreadsActive, Func func, bool allowSimultaneousActive = false) => new Work(func, allowSimultaneousActive, maximumThreadsActive); + public static Work ToWork(this int maximumThreadsActive, Func func, bool allowSimultaneousActive = false) => new Work(func, allowSimultaneousActive, maximumThreadsActive); } } diff --git a/Source/Instances/CustomEqualityComparer.cs b/Source/Instances/CustomEqualityComparer.cs index 322eccf6..fe6cb030 100644 --- a/Source/Instances/CustomEqualityComparer.cs +++ b/Source/Instances/CustomEqualityComparer.cs @@ -68,11 +68,11 @@ public static CustomEqualityComparer By(Func selector, Func default_ = EqualityComparer.Default; - Func cmp = comparison == null + Func cmp = comparison is null ? new Func((T a, T b) => default_.Equals(selector(a), selector(b))) : new Func((T a, T b) => comparison(selector(a), selector(b))); - Func ghc = getHashCode == null + Func ghc = getHashCode is null ? new Func((T a) => default_.GetHashCode(selector(a))) : new Func((T a) => getHashCode(selector(a))); diff --git a/Source/Instances/Logger.cs b/Source/Instances/Logger.cs index d26f53d4..883513a7 100644 --- a/Source/Instances/Logger.cs +++ b/Source/Instances/Logger.cs @@ -104,6 +104,7 @@ public void Dump(T obj, bool getVariables = false) /// /// The message to log. /// The type of logging. Different logging types have different icons within the editor. + [CLSCompliant(false)] public void Log(T message, LogType logType = LogType.Log) => logType.Method()(_format.Form($"{Name}{(_showId ? $" #{Id}" : "")}", message.Combine())); /// diff --git a/Source/Instances/ModuleContainer.cs b/Source/Instances/ModuleContainer.cs index f43ae139..73c6325f 100644 --- a/Source/Instances/ModuleContainer.cs +++ b/Source/Instances/ModuleContainer.cs @@ -4,7 +4,6 @@ using UnityEngine; using static KeepCoding.Game; using static KeepCoding.Game.References; -using static UnityEngine.Application; namespace KeepCoding { @@ -33,6 +32,7 @@ public ModuleContainer(CacheableBehaviour behaviour) : this(behaviour.Get. /// /// The component to get the modules from. + [CLSCompliant(false)] public ModuleContainer(Component component) { if (Reference is Ktane) @@ -46,12 +46,14 @@ public ModuleContainer(Component component) /// Encapsulates a solvable module. /// /// The instance of a normal module. + [CLSCompliant(false)] public ModuleContainer(KMBombModule solvable) : this(solvable, null) { } /// /// Encapsulates a needy module. /// /// The instance of a needy module. + [CLSCompliant(false)] public ModuleContainer(KMNeedyModule needy) : this(null, needy) { } /// @@ -60,6 +62,7 @@ public ModuleContainer(KMNeedyModule needy) : this(null, needy) { } /// /// The instance of a normal module. /// The instance of a needy module. + [CLSCompliant(false)] public ModuleContainer(KMBombModule solvable, KMNeedyModule needy) { if ((bool)solvable == needy) @@ -149,17 +152,20 @@ public ModuleContainer(KMBombModule solvable, KMNeedyModule needy) /// Returns , or if null, throws a . /// /// + [CLSCompliant(false)] public KMBombModule Solvable => _bombModule.NullCheck("KMBombModule is null, yet you are trying to access it."); /// /// Returns , or if null, throws a . /// /// + [CLSCompliant(false)] public KMNeedyModule Needy => _needyModule.NullCheck("KMNeedyModule is null, yet you are trying to access it."); /// /// Returns , or if null, . /// + [CLSCompliant(false)] public MonoBehaviour Module => _bombModule ?? (MonoBehaviour)_needyModule; /// @@ -167,6 +173,7 @@ public ModuleContainer(KMBombModule solvable, KMNeedyModule needy) /// /// The solvable module to create a new of. /// A with parameter . + [CLSCompliant(false)] public static implicit operator ModuleContainer(KMBombModule solvable) => new ModuleContainer(solvable: solvable); /// @@ -174,6 +181,7 @@ public ModuleContainer(KMBombModule solvable, KMNeedyModule needy) /// /// The needy module to create a new of. /// A with parameter . + [CLSCompliant(false)] public static implicit operator ModuleContainer(KMNeedyModule needy) => new ModuleContainer(needy: needy); /// @@ -181,6 +189,7 @@ public ModuleContainer(KMBombModule solvable, KMNeedyModule needy) /// /// The to get the from. /// A from . + [CLSCompliant(false)] public static explicit operator KMBombModule(ModuleContainer container) => container.Solvable; /// @@ -188,6 +197,7 @@ public ModuleContainer(KMBombModule solvable, KMNeedyModule needy) /// /// The to get the from. /// A from . + [CLSCompliant(false)] public static explicit operator KMNeedyModule(ModuleContainer container) => container.Needy; /// diff --git a/Source/Instances/Profiler.cs b/Source/Instances/Profiler.cs index 2886bb90..cb522f88 100644 --- a/Source/Instances/Profiler.cs +++ b/Source/Instances/Profiler.cs @@ -32,6 +32,7 @@ public sealed class Profiler : IDisposable /// /// The action to run when disposed. /// The type of logging to perform. + [CLSCompliant(false)] public Profiler(Action action, LogType type = Log) : this() => _action = (s, _) => action?.Invoke(s, type); /// diff --git a/Source/Instances/Routine.cs b/Source/Instances/Routine.cs index ec2d98da..a58895bf 100644 --- a/Source/Instances/Routine.cs +++ b/Source/Instances/Routine.cs @@ -15,6 +15,7 @@ public sealed class Routine : RoutineBase /// /// The enumerator to call when initiated. /// The MonoBehaviour to reference when calling the method. + [CLSCompliant(false)] public Routine(Func enumerator, MonoBehaviour monoBehaviour) : base(monoBehaviour) => _enumerator = enumerator; /// @@ -95,6 +96,7 @@ public sealed class Routine : RoutineBase /// /// The enumerator to call when initiated. /// The MonoBehaviour to reference when calling the method. + [CLSCompliant(false)] public Routine(Func enumerator, MonoBehaviour monoBehaviour) : base(monoBehaviour) => _enumerator = enumerator; /// @@ -179,6 +181,7 @@ public sealed class Routine : RoutineBase /// /// The enumerator to call when initiated. /// The MonoBehaviour to reference when calling the method. + [CLSCompliant(false)] public Routine(Func enumerator, MonoBehaviour monoBehaviour) : base(monoBehaviour) => _enumerator = enumerator; /// @@ -267,6 +270,7 @@ public sealed class Routine : RoutineBase /// /// The enumerator to call when initiated. /// The MonoBehaviour to reference when calling the method. + [CLSCompliant(false)] public Routine(Func enumerator, MonoBehaviour monoBehaviour) : base(monoBehaviour) => _enumerator = enumerator; /// @@ -359,6 +363,7 @@ public sealed class Routine : RoutineBase /// /// The enumerator to call when initiated. /// The MonoBehaviour to reference when calling the method. + [CLSCompliant(false)] public Routine(Func enumerator, MonoBehaviour monoBehaviour) : base(monoBehaviour) => _enumerator = enumerator; /// diff --git a/Source/Instances/Sound.cs b/Source/Instances/Sound.cs index 3978c344..60d26c86 100644 --- a/Source/Instances/Sound.cs +++ b/Source/Instances/Sound.cs @@ -22,12 +22,14 @@ public sealed class Sound : IEquatable /// An instance of Sound where is defined. /// /// The sound to insert. + [CLSCompliant(false)] public Sound(AudioClip sound) => Custom = sound.NullCheck("The AudioClip provided is null!").name; /// /// An instance of sound where is defined. /// /// The sound to insert. + [CLSCompliant(false)] public Sound(SoundEffect sound) => Game = sound; /// @@ -38,11 +40,13 @@ public sealed class Sound : IEquatable /// /// The in-game sound. /// + [CLSCompliant(false)] public SoundEffect? Game { get; } /// /// The audio reference that is playing the sound. /// + [CLSCompliant(false)] public KMAudioRef Reference { get; internal set; } /// @@ -237,6 +241,7 @@ public sealed class Sound : IEquatable /// /// The variable to grab the property from. /// 's . + [CLSCompliant(false)] public static explicit operator SoundEffect?(Sound sound) => sound.Game; /// @@ -245,6 +250,7 @@ public sealed class Sound : IEquatable /// /// The variable to grab the property from. /// 's . + [CLSCompliant(false)] public static explicit operator SoundEffect(Sound sound) => sound?.Game ?? throw new InvalidOperationException($"You cannot cast a null value of {nameof(Sound)} or {nameof(Game)} into a non-nullable {nameof(SoundEffect)}."); /// @@ -259,6 +265,7 @@ public sealed class Sound : IEquatable /// /// The sound to insert. /// with argument . + [CLSCompliant(false)] public static implicit operator Sound(AudioClip sound) => new Sound(sound); /// @@ -266,6 +273,7 @@ public sealed class Sound : IEquatable /// /// The sound to insert. /// with argument . + [CLSCompliant(false)] public static implicit operator Sound(SoundEffect sound) => new Sound(sound); /// @@ -311,6 +319,7 @@ public override int GetHashCode() /// /// The instance of to play from. /// A method that when called, will play the sound and return the instance. + [CLSCompliant(false)] public Func Method(KMAudio audio) => Custom is { } ? ((t, b) => KeyHelper.Catch(() => audio.HandlePlaySoundAtTransformWithRef?.Invoke(Custom, t, b), null)()) : Game is { } ? (Func)((t, b) => b ? throw new ArgumentException("The game doesn't support looping in-game sounds.") : KeyHelper.Catch(() => audio.HandlePlayGameSoundAtTransformWithRef?.Invoke(Game.Value, t), null)()) : diff --git a/Source/Instances/Work.cs b/Source/Instances/Work.cs index a7f49d2d..9fa0bfa6 100644 --- a/Source/Instances/Work.cs +++ b/Source/Instances/Work.cs @@ -23,7 +23,7 @@ public Work(Action work) : this(work, true, 1) { } /// The method to call when thread starts. /// Whether it should allow multiple of itself to be running at once. /// The amount of threads this class, and all of its overloads can run at once. - public Work(Action work, bool allowSimultaneousActive, uint maximumThreadsActive) + public Work(Action work, bool allowSimultaneousActive, int maximumThreadsActive) : base(allowSimultaneousActive, maximumThreadsActive) => Thread = new Thread(() => { @@ -71,7 +71,7 @@ public Work(Func work) : this(work, true, 1) { } /// The method to call when thread starts. /// Whether it should allow multiple of itself to be running at once. /// The amount of threads this class, and all of its overloads can run at once. - public Work(Func work, bool allowSimultaneousActive, uint maximumThreadsActive) + public Work(Func work, bool allowSimultaneousActive, int maximumThreadsActive) : base(allowSimultaneousActive, maximumThreadsActive) => Thread = new Thread(() => { @@ -124,7 +124,7 @@ public Work(Func work) : this(work, true, 1) { } /// The method to call when thread starts. /// Whether it should allow multiple of itself to be running at once. /// The amount of threads this class, and all of its overloads can run at once. - public Work(Func work, bool allowSimultaneousActive, uint maximumThreadsActive) + public Work(Func work, bool allowSimultaneousActive, int maximumThreadsActive) : base(allowSimultaneousActive, maximumThreadsActive) => _work = work; /// @@ -180,7 +180,7 @@ public Work(Func work) : this(work, true, 1) { } /// The method to call when thread starts. /// Whether it should allow multiple of itself to be running at once. /// The amount of threads this class, and all of its overloads can run at once. - public Work(Func work, bool allowSimultaneousActive, uint maximumThreadsActive) + public Work(Func work, bool allowSimultaneousActive, int maximumThreadsActive) : base(allowSimultaneousActive, maximumThreadsActive) => _work = work; /// @@ -236,7 +236,7 @@ public Work(Func work) : this(work, true, 1) { } /// The method to call when thread starts. /// Whether it should allow multiple of itself to be running at once. /// The amount of threads this class, and all of its overloads can run at once. - public Work(Func work, bool allowSimultaneousActive, uint maximumThreadsActive) + public Work(Func work, bool allowSimultaneousActive, int maximumThreadsActive) : base(allowSimultaneousActive, maximumThreadsActive) => _work = work; /// @@ -292,7 +292,7 @@ public Work(Func work) : this(work, true, 1) { } /// The method to call when thread starts. /// Whether it should allow multiple of itself to be running at once. /// The amount of threads this class, and all of its overloads can run at once. - public Work(Func work, bool allowSimultaneousActive, uint maximumThreadsActive) + public Work(Func work, bool allowSimultaneousActive, int maximumThreadsActive) : base(allowSimultaneousActive, maximumThreadsActive) => _work = work; /// diff --git a/Source/Interfaces/ILog.cs b/Source/Interfaces/ILog.cs index c408c8eb..58f089ee 100644 --- a/Source/Interfaces/ILog.cs +++ b/Source/Interfaces/ILog.cs @@ -1,4 +1,5 @@ -using KeepCoding.Internal; +using System; +using KeepCoding.Internal; using UnityEngine; namespace KeepCoding @@ -6,6 +7,7 @@ namespace KeepCoding /// /// An interface to implement log methods. Make each method return the same method in your instance. /// + [CLSCompliant(false)] public interface ILog { /// @@ -14,6 +16,7 @@ public interface ILog /// /// The message to log. /// The type of logging. Different logging types have different icons within the editor. + [CLSCompliant(false)] public void Log(T message, LogType logType = LogType.Log); /// diff --git a/Source/Interfaces/ITP.cs b/Source/Interfaces/ITP.cs index fc68ee51..89076bd0 100644 --- a/Source/Interfaces/ITP.cs +++ b/Source/Interfaces/ITP.cs @@ -1,4 +1,5 @@ -using System.Collections; +using System; +using System.Collections; using System.Collections.Generic; namespace KeepCoding @@ -6,6 +7,7 @@ namespace KeepCoding /// /// Interface for Twitch Plays support. /// + [CLSCompliant(false)] public interface ITP { /// diff --git a/Source/MonoBehaviours/AudioScript.cs b/Source/MonoBehaviours/AudioScript.cs index c53b46da..03800cbb 100644 --- a/Source/MonoBehaviours/AudioScript.cs +++ b/Source/MonoBehaviours/AudioScript.cs @@ -9,6 +9,7 @@ /// /// Encapsulates an and scales it with the game's volume using and . /// +[CLSCompliant(false)] #pragma warning disable CA1050 // Declare types in namespaces public sealed class AudioScript : CacheableBehaviour #pragma warning restore CA1050 // Declare types in namespaces diff --git a/Source/MonoBehaviours/CacheableBehaviour.cs b/Source/MonoBehaviours/CacheableBehaviour.cs index 24dbcde3..8f6c33e2 100644 --- a/Source/MonoBehaviours/CacheableBehaviour.cs +++ b/Source/MonoBehaviours/CacheableBehaviour.cs @@ -9,6 +9,7 @@ namespace KeepCoding /// /// A with additional caching capabilities. /// + [CLSCompliant(false)] public abstract class CacheableBehaviour : MonoBehaviour { private readonly Dictionary _components = new Dictionary(); diff --git a/Source/MonoBehaviours/ModuleScript.cs b/Source/MonoBehaviours/ModuleScript.cs index 50279a71..986596e5 100644 --- a/Source/MonoBehaviours/ModuleScript.cs +++ b/Source/MonoBehaviours/ModuleScript.cs @@ -27,6 +27,7 @@ namespace KeepCoding /// /// Base class for solvable and needy modded modules in Keep Talking and Nobody Explodes. /// + [CLSCompliant(false)] public abstract class ModuleScript : CacheableBehaviour, IDump, ILog { private bool _hasException; diff --git a/Source/MonoBehaviours/ReflectionScript.cs b/Source/MonoBehaviours/ReflectionScript.cs index 4d897245..76bf0641 100644 --- a/Source/MonoBehaviours/ReflectionScript.cs +++ b/Source/MonoBehaviours/ReflectionScript.cs @@ -15,6 +15,7 @@ namespace KeepCoding.Internal /// /// Editor-only behaviour that gets values from s in real-time. /// + [CLSCompliant(false)] public sealed class ReflectionScript : MonoBehaviour, ILog { private class NullableObject diff --git a/Source/MonoBehaviours/TPScript.cs b/Source/MonoBehaviours/TPScript.cs index d7535f24..230de985 100644 --- a/Source/MonoBehaviours/TPScript.cs +++ b/Source/MonoBehaviours/TPScript.cs @@ -12,7 +12,7 @@ namespace KeepCoding /// /// Base class for TwitchPlays support for solvable and needy modded modules in Keep Talking and Nobody Explodes. /// - [RequireComponent(typeof(ModuleScript))] + [CLSCompliant(false), RequireComponent(typeof(ModuleScript))] public abstract class TPScript : CacheableBehaviour, ITP where TModule : ModuleScript { ///