diff --git a/src/Aardvark.Base.IO/Annotations.cs b/src/Aardvark.Base.IO/Annotations.cs index 866f6bf9b..5ccb51a41 100644 --- a/src/Aardvark.Base.IO/Annotations.cs +++ b/src/Aardvark.Base.IO/Annotations.cs @@ -45,7 +45,7 @@ internal readonly struct Annotated { private readonly T m_value; private readonly IEnumerable m_tags; - private static readonly IEnumerable s_empty = new Annotation[0]; + private static readonly IEnumerable s_empty = System.Array.Empty(); public Annotated(T value) { diff --git a/src/Aardvark.Base.IO/Converter.cs b/src/Aardvark.Base.IO/Converter.cs index add94abad..2c6cb8e6a 100644 --- a/src/Aardvark.Base.IO/Converter.cs +++ b/src/Aardvark.Base.IO/Converter.cs @@ -49,8 +49,8 @@ public Convertible(string descriptor, object data) #region Properties public string Descriptor { get { return m_descriptor; } } - - public object Data + + public object Data { get { return m_data; } set { m_data = value; } @@ -76,7 +76,7 @@ public static Convertible FromFile(string fileName) } /// - /// Creates a file convertible given a file name and a preferrable target used to + /// Creates a file convertible given a file name and a preferrable target used to /// determine the shortest possible path (a matching creator must be registered). /// public static Convertible FromFile(string fileName, Convertible preferrableTarget) @@ -103,8 +103,8 @@ public static Convertible FindMatchingRaw(Convertible c) } /// - /// Creates a matching raw convertible from a given convertible and a preferrable target - /// used to the determine the shortest possible path (a matching raw convertible creator + /// Creates a matching raw convertible from a given convertible and a preferrable target + /// used to the determine the shortest possible path (a matching raw convertible creator /// must be registered). /// public static Convertible FindMatchingRaw(Convertible c, Convertible preferrableTarget) @@ -113,8 +113,8 @@ public static Convertible FindMatchingRaw(Convertible c, Convertible preferrable } /// - /// Creates a matching raw convertible from a given convertible and a preferrable target - /// used to the determine the shortest possible path (a matching raw convertible creator + /// Creates a matching raw convertible from a given convertible and a preferrable target + /// used to the determine the shortest possible path (a matching raw convertible creator /// must be registered). /// public static Convertible FindMatchingRaw(Convertible c, string preferrableTargetDescriptor) @@ -169,7 +169,7 @@ public Convertible ConvertedTo(Convertible target) #endregion #region Query Methods - + /// /// Returns whether a convertible is directly convertible into the target. /// @@ -398,14 +398,14 @@ public void Convert(Convertible source, Convertible target) /// Private helper for public Convert method above. /// private void Convert( - Convertible source, Convertible target, + Convertible source, Convertible target, Dictionary> routingMap, List tempConvertibles) { var sourceDescr = source.Descriptor; var targetDescr = target.Descriptor; - if (sourceDescr == targetDescr) + if (sourceDescr == targetDescr) { DirectConvert(source, target); return; @@ -1029,7 +1029,7 @@ orderby distance ascending /// /// Sets whether a resource is available or not. By default, resources are - /// not available. If this is done after the routing table has been + /// not available. If this is done after the routing table has been /// initialized once, the routing table will be rebuilt (therefore, use /// SetResourceAvailability(List{string} resources, bool available) if you need /// to set the availability of multiple resources). @@ -1055,7 +1055,7 @@ public void SetResourceAvailability(string resource, bool available) /// /// Sets whether resources are available or not. By default, resources are - /// not available. If this is done after the routing table has been + /// not available. If this is done after the routing table has been /// initialized once, the routing table will be rebuilt. /// public void SetResourceAvailability(List resources, bool available) @@ -1114,7 +1114,7 @@ private bool AreAllResourcesAvailable(string descriptor) { var reqResources = RequiredResources(descriptor); - if (reqResources == null) + if (reqResources == null) return true; foreach (var res in reqResources) @@ -1168,7 +1168,7 @@ public Entry GetConversion(string sourceDescription, string targetDescription) } throw new ArgumentException(); } - + /// /// Enumerates all conversions in the specified conversion chain, /// or returns null if no conversion exists. @@ -1192,7 +1192,7 @@ public IEnumerable GetAnnotations(string source, string target) { var key = (source, target); if (m_annotationsMap.ContainsKey(key)) return m_annotationsMap[key]; - return new Annotation[0]; + return Array.Empty(); } /// diff --git a/src/Aardvark.Base.IO/FieldCoderExtensions.cs b/src/Aardvark.Base.IO/FieldCoderExtensions.cs index 8ecb4bcfd..1fc60449e 100644 --- a/src/Aardvark.Base.IO/FieldCoderExtensions.cs +++ b/src/Aardvark.Base.IO/FieldCoderExtensions.cs @@ -65,7 +65,7 @@ public static FieldCoder CreateFieldCoder(this Type type, string name, string me if (prop != null) { // template: - // (c, o) => + // (c, o) => // { // if (c.IsWriting) { var v = ((Foo)o).MyProperty; c.Code(ref v); } // else { var v = 0; c.Code(ref v); ((Foo)o).MyProperty = v; } @@ -105,7 +105,7 @@ private static void EmitPropertyCoder(ILGenerator gen, Type type, PropertyInfo p var method_IsWriting = typeof(ICoder).GetMethod( "get_IsWriting", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, - null, new Type[] { }, null + null, Array.Empty(), null ); var method_Code = GetCodeMethodOverloadFor(prop.PropertyType); @@ -141,12 +141,12 @@ private static void EmitPropertyCoder(ILGenerator gen, Type type, PropertyInfo p gen.Emit(OpCodes.Ldloca, 0); // load address of local variable v gen.Emit(OpCodes.Initobj, prop.PropertyType); // initialize v to default value - // c.Code(ref v); + // c.Code(ref v); gen.Emit(OpCodes.Ldarg_0); // c, used as this for following call gen.Emit(OpCodes.Ldloca, 0); // ref v gen.Emit(OpCodes.Callvirt, method_Code); // call ... c.code(ref v) - // ((T)o).MyProperty = v; + // ((T)o).MyProperty = v; gen.Emit(OpCodes.Ldarg_1); // o gen.Emit(OpCodes.Castclass, type); // cast to T gen.Emit(OpCodes.Ldloc_0); // v diff --git a/src/Aardvark.Base.IO/SymMap.cs b/src/Aardvark.Base.IO/SymMap.cs index ffbb4054c..5556532a9 100644 --- a/src/Aardvark.Base.IO/SymMap.cs +++ b/src/Aardvark.Base.IO/SymMap.cs @@ -94,7 +94,7 @@ public IEnumerable GetFieldCoders(int coderVersion) if (s_lastMapCodedVersionMap.TryGetValue(m_typeName, out lastMapCodedVersion) && lastMapCodedVersion >= coderVersion) { - if (m_typeName == this.GetType().GetCanonicalName()) return new FieldCoder[0]; + if (m_typeName == this.GetType().GetCanonicalName()) return Array.Empty(); return new FieldCoder[] { new FieldCoder(0, "TypeName", (c, o) => c.CodePositiveSymbol(ref ((SymMap)o).m_typeName)), @@ -119,7 +119,7 @@ public IEnumerable GetFieldCoders(int coderVersion) } } - if (m_typeName == this.GetType().GetCanonicalName()) return new FieldCoder[0]; + if (m_typeName == this.GetType().GetCanonicalName()) return Array.Empty(); return new FieldCoder[] { diff --git a/src/Aardvark.Base.IO/ZipFileContainer.cs b/src/Aardvark.Base.IO/ZipFileContainer.cs index 960160fcc..d494b25f4 100644 --- a/src/Aardvark.Base.IO/ZipFileContainer.cs +++ b/src/Aardvark.Base.IO/ZipFileContainer.cs @@ -24,8 +24,8 @@ private struct SubFileHeader public long UncompressedSize; } - private string[] m_ZipFileNames = new string[0]; - private WeakReference[] m_ZipFileStreams = new WeakReference[0]; + private string[] m_ZipFileNames = Array.Empty(); + private WeakReference[] m_ZipFileStreams = Array.Empty(); private readonly SymbolDict m_Files = new SymbolDict(); private readonly SymbolSet m_Directories = new SymbolSet(); private readonly bool m_contentCaseSensitive = false; @@ -97,7 +97,7 @@ public bool Init(string containerPath) Report.BeginTimed("Init Zip container '" + containerPath + "'."); FileStream mainFileStream = null; - FileStream[] zipStreams = new FileStream[0]; + FileStream[] zipStreams = Array.Empty(); try { @@ -120,7 +120,7 @@ public bool Init(string containerPath) zipStreams = new FileStream[zipEoCDR.cd_diskId + 1]; zipStreams[zipEoCDR.cd_diskId] = mainFileStream; - + // Load all parts of a multi zip if (zipEoCDR.cd_diskId > 0) { @@ -142,7 +142,7 @@ public bool Init(string containerPath) zipStreams[i] = File.Open(m_ZipFileNames[i], FileMode.Open, FileAccess.Read, FileShare.None); } } - + // Try to load Zip64 End Of Central Directory Locator var zip64Locator = new TZip64EndOfCentralDirectoryLocator(); zip64Locator.Load(mainFileStream, zipEoCDR.Position); @@ -399,6 +399,6 @@ private string SanitizeFilename(string fileName) #endregion - + } } diff --git a/src/Aardvark.Base/AlgoDat/INode.cs b/src/Aardvark.Base/AlgoDat/INode.cs index 866380097..49d05a968 100644 --- a/src/Aardvark.Base/AlgoDat/INode.cs +++ b/src/Aardvark.Base/AlgoDat/INode.cs @@ -1,4 +1,5 @@ using Aardvark.Base; +using System; using System.Collections.Generic; using System.Linq; @@ -53,7 +54,7 @@ from n in sn.NodesAtDepth(depth - 1) /// public static IEnumerable DepthFirst(this INode self) { - if (self == null) return new INode[0]; + if (self == null) return Array.Empty(); return self.DepthFirst(n => n.SubNodes); } diff --git a/src/Aardvark.Base/Extensions/IEnumerableExtensions.cs b/src/Aardvark.Base/Extensions/IEnumerableExtensions.cs index 62997a63f..64c98cdf9 100644 --- a/src/Aardvark.Base/Extensions/IEnumerableExtensions.cs +++ b/src/Aardvark.Base/Extensions/IEnumerableExtensions.cs @@ -19,7 +19,7 @@ public static IEnumerable Guids() while (true) yield return Guid.NewGuid(); } } - + public static partial class EnumerableEx { #region Indexed Values @@ -47,7 +47,7 @@ public static T[] SortedByDenseIndex( } /// - /// Returns elements with index into 'other'. + /// Returns elements with index into 'other'. /// public static IEnumerable> IndexIntoOther( this IEnumerable self, IList other) @@ -58,7 +58,7 @@ public static IEnumerable> IndexIntoOther( } #endregion - + #region Special Selects public static IEnumerable WhereNotNull(this IEnumerable self) @@ -181,7 +181,7 @@ public static R[] SelectToArray(this T[] self, Func selector) } return result; } - + /// /// Maps the elements of an array to a result list. /// @@ -690,7 +690,7 @@ public static int PairsCount(this IEnumerable self, bool excludeIdenticalP } } } - + /// /// [A B].Triples([x y], [X Y]) -> (A, x, X) (A, x, Y) (A, y, X) (A, y, Y) (B, x, X) (B, x, Y) (B, y, X) (B, y, Y) (C, x, X) (C, x, Y) (C, y, X) (C, y, Y) /// @@ -759,7 +759,7 @@ public static IEnumerable Dup(this IEnumerable self) foreach (var x in self) { yield return x; yield return x; } } - + /// /// Duplicates each element of the sequence n times. /// [A B C].DupElements(4) -> [A A A A B B B B C C C C] @@ -891,7 +891,7 @@ public static IEnumerable NonNull(IEnumerable elements) if (elements == null) return Enumerable.Empty(); return elements; } - + /// /// Compares both enumerables using SequenceEqual and additionally checks /// whether both enumerables are null. @@ -964,7 +964,7 @@ public static T Max(this IEnumerable seq, Func greaterThan, T /// /// Aardvark.Runtime.IEnumerableExtensions: - /// Invokes a transform function on each element of a sequence and + /// Invokes a transform function on each element of a sequence and /// returns the element that yielded the maximum value (and the maximum value in rv_maxVal). /// Only elements that yield larger values than minVal are considered. /// If multiple elements yield the maximum value, the first in the sequence is chosen. @@ -1002,7 +1002,7 @@ public static TSrc MaxElement(this IEnumerable source, Func /// Aardvark.Runtime.IEnumerableExtensions: - /// Invokes a transform function on each element of a sequence and + /// Invokes a transform function on each element of a sequence and /// returns the element that yielded the minimum value (and the minimum value in rv_minVal). /// Only elements that yield smaller values than maxVal are considered. /// If multiple elements yield the minimum value, the first in the sequence is chosen. @@ -2012,7 +2012,7 @@ public static bool TrueForAll( } #endregion - + #region Conversions public static T[] ToArrayDebug(this IEnumerable self) @@ -2193,7 +2193,7 @@ public static TElement[] ToArray(this IEnumerable source, in { if (count == 0) { - return new TElement[0]; + return Array.Empty(); } else { @@ -2302,9 +2302,9 @@ public static int IndexOf(this IEnumerable list, T elementToFind) } return -1; } - + /// - /// Concats single item to sequence. + /// Concats single item to sequence. /// public static IEnumerable Concat(this IEnumerable sequence, T item) { @@ -2313,7 +2313,7 @@ public static IEnumerable Concat(this IEnumerable sequence, T item) } /// - /// Concats sequence to single item. + /// Concats sequence to single item. /// public static IEnumerable Concat(this T item, IEnumerable sequence) { @@ -2400,7 +2400,7 @@ public static IEnumerable SelectMany(this IEnumerable self, Func /// Converts a sequence that contains numbers of elements /// into a sequence that represents the indices of the - /// first element if the elements are stored in consecutive + /// first element if the elements are stored in consecutive /// order and is closed by the total count elements. /// The length of the integrated sequence is +1 of the input. /// @@ -2415,7 +2415,7 @@ public static IEnumerable Integrated(this IEnumerable counts, int sum } /// - /// Integrates a sequence of values. + /// Integrates a sequence of values. /// Returns a sequence of N+1 values where the last is the sum off all value. /// public static IEnumerable Integrated(this IEnumerable values, double sum = 0) diff --git a/src/Aardvark.Base/Extensions/StringExtensions.cs b/src/Aardvark.Base/Extensions/StringExtensions.cs index 7daa019cf..d43517b2e 100644 --- a/src/Aardvark.Base/Extensions/StringExtensions.cs +++ b/src/Aardvark.Base/Extensions/StringExtensions.cs @@ -30,7 +30,7 @@ public static bool ToBool(this string self) if (s == "true" || s == "t") return true; if (s == "false" || s == "f") return false; double r; - // Double.TryParse() sets r to 0 if the conversion fails, + // Double.TryParse() sets r to 0 if the conversion fails, // which means we don't really need to check the return value. Double.TryParse(s, out r); return r != 0.0; @@ -97,7 +97,7 @@ public static decimal ToDecimal(this string self, decimal def) if (!decimal.TryParse(self, out result)) { - result = def; + result = def; } return result; @@ -147,7 +147,7 @@ public static IEnumerable ToUpper(this IEnumerable self) /// /// Returns the english plural of the supplied word (i.e. the word /// with "s" appended) if the supplied integer is not equal to one. - /// Otherwise the word is returned unchanged. + /// Otherwise the word is returned unchanged. /// public static string Plural(this string word, int s) { @@ -404,7 +404,7 @@ public static bool IsNullOrEmpty(this string self) #region Formatting /// - /// Same as String.Format, but uses the InvariantCulture formatter + /// Same as String.Format, but uses the InvariantCulture formatter /// (The one we usually want. You know, . as decimal point,...) /// public static string FormatInvariant(this string format, params object[] args) @@ -451,7 +451,7 @@ public static string ToHex(this byte[] bytes) public static byte[] HexToBytes(this string str) { if (str.Length == 0 || str.Length % 2 != 0) - return new byte[0]; + return System.Array.Empty(); byte[] buffer = new byte[str.Length / 2]; char c; diff --git a/src/Aardvark.Base/Geometry/IntersectionTests_auto.cs b/src/Aardvark.Base/Geometry/IntersectionTests_auto.cs index 0c555057d..eb7f85a81 100644 --- a/src/Aardvark.Base/Geometry/IntersectionTests_auto.cs +++ b/src/Aardvark.Base/Geometry/IntersectionTests_auto.cs @@ -3285,7 +3285,7 @@ public static bool Intersects(this Plane3f plane, Cylinder3f cylinder, out Ray3f return true; } } - rays = new Ray3f[0]; + rays = Array.Empty(); return false; } @@ -7461,7 +7461,7 @@ public static bool Intersects(this Plane3d plane, Cylinder3d cylinder, out Ray3d return true; } } - rays = new Ray3d[0]; + rays = Array.Empty(); return false; } diff --git a/src/Aardvark.Base/Geometry/IntersectionTests_template.cs b/src/Aardvark.Base/Geometry/IntersectionTests_template.cs index 00cca0cf9..ef1d17b2b 100644 --- a/src/Aardvark.Base/Geometry/IntersectionTests_template.cs +++ b/src/Aardvark.Base/Geometry/IntersectionTests_template.cs @@ -3318,7 +3318,7 @@ public static bool Intersects(this __plane3t__ plane, __cylinder3t__ cylinder, o return true; } } - rays = new __ray3t__[0]; + rays = Array.Empty<__ray3t__>(); return false; } diff --git a/src/Aardvark.Base/Geometry/Relations/SubPrimitives_auto.cs b/src/Aardvark.Base/Geometry/Relations/SubPrimitives_auto.cs index 405037df0..b2d7f5d06 100644 --- a/src/Aardvark.Base/Geometry/Relations/SubPrimitives_auto.cs +++ b/src/Aardvark.Base/Geometry/Relations/SubPrimitives_auto.cs @@ -50,7 +50,7 @@ private static int[] ComputeNonConcaveSubPolygon( if (count <= 3) { var result = indices; - indices = new int[0]; + indices = Array.Empty(); return result; } @@ -78,7 +78,7 @@ private static int[] ComputeNonConcaveSubPolygon( if (newIndex == lastIndex) { var finalIndices = indices; - indices = new int[0]; + indices = Array.Empty(); return finalIndices; } @@ -502,7 +502,7 @@ private static int[] ComputeNonConcaveSubPolygon( if (count <= 3) { var result = indices; - indices = new int[0]; + indices = Array.Empty(); return result; } @@ -530,7 +530,7 @@ private static int[] ComputeNonConcaveSubPolygon( if (newIndex == lastIndex) { var finalIndices = indices; - indices = new int[0]; + indices = Array.Empty(); return finalIndices; } diff --git a/src/Aardvark.Base/Geometry/Relations/SubPrimitives_template.cs b/src/Aardvark.Base/Geometry/Relations/SubPrimitives_template.cs index ee4e2bc4f..b6a63579c 100644 --- a/src/Aardvark.Base/Geometry/Relations/SubPrimitives_template.cs +++ b/src/Aardvark.Base/Geometry/Relations/SubPrimitives_template.cs @@ -60,7 +60,7 @@ private static int[] ComputeNonConcaveSubPolygon( if (count <= 3) { var result = indices; - indices = new int[0]; + indices = Array.Empty(); return result; } @@ -88,7 +88,7 @@ private static int[] ComputeNonConcaveSubPolygon( if (newIndex == lastIndex) { var finalIndices = indices; - indices = new int[0]; + indices = Array.Empty(); return finalIndices; } diff --git a/src/Aardvark.Base/Geometry/Types/Geometry_auto.cs b/src/Aardvark.Base/Geometry/Types/Geometry_auto.cs index d2335cb30..931cfc3b5 100644 --- a/src/Aardvark.Base/Geometry/Types/Geometry_auto.cs +++ b/src/Aardvark.Base/Geometry/Types/Geometry_auto.cs @@ -274,7 +274,7 @@ public readonly IEnumerable EdgeLines public readonly V2f[] GetEdgeArray() { var pc = m_pointCount; - if (pc < 2) return new V2f[0]; + if (pc < 2) return Array.Empty(); var edgeArray = new V2f[pc]; var p = m_pointArray[0]; var p0 = p; @@ -294,7 +294,7 @@ public readonly V2f[] GetEdgeArray() public readonly Line2f[] GetEdgeLineArray() { var pc = PointCount; - if (pc < 2) return new Line2f[0]; + if (pc < 2) return Array.Empty(); var ela = new Line2f[pc]; var p = m_pointArray[0]; var p0 = p; @@ -3751,7 +3751,7 @@ public readonly IEnumerable EdgeLines public readonly V3f[] GetEdgeArray() { var pc = m_pointCount; - if (pc < 2) return new V3f[0]; + if (pc < 2) return Array.Empty(); var edgeArray = new V3f[pc]; var p = m_pointArray[0]; var p0 = p; @@ -3771,7 +3771,7 @@ public readonly V3f[] GetEdgeArray() public readonly Line3f[] GetEdgeLineArray() { var pc = PointCount; - if (pc < 2) return new Line3f[0]; + if (pc < 2) return Array.Empty(); var ela = new Line3f[pc]; var p = m_pointArray[0]; var p0 = p; @@ -7229,7 +7229,7 @@ public readonly IEnumerable EdgeLines public readonly V2d[] GetEdgeArray() { var pc = m_pointCount; - if (pc < 2) return new V2d[0]; + if (pc < 2) return Array.Empty(); var edgeArray = new V2d[pc]; var p = m_pointArray[0]; var p0 = p; @@ -7249,7 +7249,7 @@ public readonly V2d[] GetEdgeArray() public readonly Line2d[] GetEdgeLineArray() { var pc = PointCount; - if (pc < 2) return new Line2d[0]; + if (pc < 2) return Array.Empty(); var ela = new Line2d[pc]; var p = m_pointArray[0]; var p0 = p; @@ -10706,7 +10706,7 @@ public readonly IEnumerable EdgeLines public readonly V3d[] GetEdgeArray() { var pc = m_pointCount; - if (pc < 2) return new V3d[0]; + if (pc < 2) return Array.Empty(); var edgeArray = new V3d[pc]; var p = m_pointArray[0]; var p0 = p; @@ -10726,7 +10726,7 @@ public readonly V3d[] GetEdgeArray() public readonly Line3d[] GetEdgeLineArray() { var pc = PointCount; - if (pc < 2) return new Line3d[0]; + if (pc < 2) return Array.Empty(); var ela = new Line3d[pc]; var p = m_pointArray[0]; var p0 = p; diff --git a/src/Aardvark.Base/Geometry/Types/Geometry_template.cs b/src/Aardvark.Base/Geometry/Types/Geometry_template.cs index c3d2179da..baf841a4f 100644 --- a/src/Aardvark.Base/Geometry/Types/Geometry_template.cs +++ b/src/Aardvark.Base/Geometry/Types/Geometry_template.cs @@ -323,7 +323,7 @@ public readonly IEnumerable<__tline__> EdgeLines public readonly __tvec__[] GetEdgeArray() { var pc = m_pointCount; - if (pc < 2) return new __tvec__[0]; + if (pc < 2) return Array.Empty<__tvec__>(); var edgeArray = new __tvec__[pc]; var p = m_pointArray[0]; var p0 = p; @@ -343,7 +343,7 @@ public readonly __tvec__[] GetEdgeArray() public readonly __tline__[] GetEdgeLineArray() { var pc = PointCount; - if (pc < 2) return new __tline__[0]; + if (pc < 2) return Array.Empty<__tline__>(); var ela = new __tline__[pc]; var p = m_pointArray[0]; var p0 = p; diff --git a/src/Aardvark.Base/Geometry/Types/Polygon/ImmutablePolygon.cs b/src/Aardvark.Base/Geometry/Types/Polygon/ImmutablePolygon.cs index 23ae57123..179779185 100644 --- a/src/Aardvark.Base/Geometry/Types/Polygon/ImmutablePolygon.cs +++ b/src/Aardvark.Base/Geometry/Types/Polygon/ImmutablePolygon.cs @@ -14,7 +14,7 @@ public class ImmutablePolygon: IImmutablePolygon /// /// The empty polygon (no points). /// - public static readonly IImmutablePolygon Empty = new ImmutablePolygon(new T[0]); + public static readonly IImmutablePolygon Empty = new ImmutablePolygon(Array.Empty()); /// /// Vertices. @@ -63,37 +63,37 @@ public override string ToString() public int Count => m_ps.Count; /// - /// Returns new polygon with point added. + /// Returns new polygon with point added. /// public IImmutablePolygon AddPoint(T p) => new ImmutablePolygon(m_ps.Add(p)); /// - /// Returns new polygon with points added. + /// Returns new polygon with points added. /// public IImmutablePolygon AddPoints(IEnumerable points) => new ImmutablePolygon(m_ps.AddRange(points)); /// - /// Returns new polygon with point replaced. + /// Returns new polygon with point replaced. /// public IImmutablePolygon SetPoint(int index, T p) => new ImmutablePolygon(m_ps.SetItem(index, p)); /// - /// Returns new polygon with point p inserted at given index. + /// Returns new polygon with point p inserted at given index. /// public IImmutablePolygon InsertPoint(int index, T p) => new ImmutablePolygon(m_ps.Insert(index, p)); /// - /// Returns new polygon with point removed. + /// Returns new polygon with point removed. /// public IImmutablePolygon RemovePoint(int index) => new ImmutablePolygon(m_ps.RemoveAt(index)); /// - /// Returns new polygon with points removed. + /// Returns new polygon with points removed. /// public IImmutablePolygon RemovePoints(IEnumerable indexes) { diff --git a/src/Aardvark.Base/Introspection/Introspection.cs b/src/Aardvark.Base/Introspection/Introspection.cs index 89f5a92e0..97ee5abca 100644 --- a/src/Aardvark.Base/Introspection/Introspection.cs +++ b/src/Aardvark.Base/Introspection/Introspection.cs @@ -111,13 +111,13 @@ internal static string GetIdentifier(this Assembly asm, NamingScheme scheme) public static class IntrospectionProperties { /// - /// Introspection is based on Assembly.GetEntryAssembly which represents the managed + /// Introspection is based on Assembly.GetEntryAssembly which represents the managed /// entry point (i.e. the first assembly that was executed by AppDomain.ExecuteAssembly). /// However, started from an unmanaged entry point (like VisualStudio tests) Assembly.GetEntryAssembly /// is null. To allow us to start from unmanaged hosting processes this alternative /// has been implemented. /// A second use case are managed interactive shells like fsi.exi. Here we want to - /// start our dependency walk at a custom assembly instead of the running assembly + /// start our dependency walk at a custom assembly instead of the running assembly /// which is the interactive shell host. /// public static Assembly CustomEntryAssembly { get; set; } @@ -269,7 +269,7 @@ public static bool AssemblyFilter(string name) } else { - // no option left.... + // no option left.... return DateTime.Now; } }; @@ -326,13 +326,13 @@ public static void RegisterAssembly(Assembly a) /// public static IEnumerable GetAllClassesImplementingInterface(Type interfaceType) => AllAssemblies.SelectMany(a => GetAllClassesImplementingInterface(a, interfaceType)); - + /// /// Enumerates all classes inheriting from the specified base class. /// public static IEnumerable GetAllClassesInheritingFrom(Type baseType) => AllAssemblies.SelectMany(a => GetAllClassesInheritingFrom(a, baseType)); - + /// /// Enumerates all types decorated with attribute T as tuples of type /// and its one or more T-attributes. @@ -433,7 +433,7 @@ where attribs.Length > 0 select (m, attribs), result => result.Select(m => m.Item1.DeclaringType.AssemblyQualifiedName) ); - + static Introspection() { // enumerating all assemblies reachable from entry assembly @@ -473,7 +473,7 @@ static Introspection() { RegisterAllAssembliesInCustomEntryPath(); } - + //Report.Line("s_telemetryEnumerateAssembliesCheckTime1: {0}", s_telemetryEnumerateAssembliesCheckTime1.Value); //Report.Line("s_telemetryEnumerateAssembliesCheckTime2: {0}", s_telemetryEnumerateAssembliesCheckTime2.Value); } @@ -518,7 +518,7 @@ public static void RegisterAllAssembliesInPath(string path, bool verbose) /// /// Note by hs: Since this function throws and catches exceptions in non exceptional cases we - /// use [DebuggerNonUserCode] to deactive first chance exceptions here + /// use [DebuggerNonUserCode] to deactive first chance exceptions here /// at least if non user code is deactivated in Options/Debugging. /// /// the name of the entry assembly @@ -617,7 +617,7 @@ Func> encode Report.Line(4, "[cache hit ] {0}", a); return decode(lines.Skip(1)).ToArray(); } - } + } } catch(Exception e) { Report.Warn("Could not get cache for {1}: {0}", e.Message, a.FullName); @@ -649,7 +649,7 @@ Func> encode Report.End(); ts = e.Types.Where(t => t != null).ToArray(); } - + var result = createResult(ts).ToArray(); @@ -728,7 +728,7 @@ internal static class Dl [DllImport("libdl", SetLastError = true, CharSet = CharSet.Ansi)] public static extern IntPtr dlopen(string path, int flag); - + [DllImport("libdl", SetLastError = true, CharSet = CharSet.Ansi)] public static extern IntPtr dlsym(IntPtr handle, string name); @@ -924,7 +924,7 @@ private static unsafe bool IsPlugin(string file) var attType = m.GetTypeReference((System.Reflection.Metadata.TypeReferenceHandle)pp); var nameStr = m.GetString(attType.Name); var nsStr = m.GetString(attType.Namespace); - if (nsStr == "Aardvark.Base" && nameStr == "OnAardvarkInitAttribute") + if (nsStr == "Aardvark.Base" && nameStr == "OnAardvarkInitAttribute") { return true; } @@ -1028,7 +1028,7 @@ public static List LoadPlugins() { //Note: I removed the separate AppDomain for Plugin probing because: //1) it made problems on startup in some setups - //2) the code below seemed to not do anything in the new AppDomain since the call + //2) the code below seemed to not do anything in the new AppDomain since the call // var paths = aardvark.GetPluginAssemblyPaths(); // was actually executed in this AppDomain. //Changes are marked with APPD @@ -1474,12 +1474,12 @@ public static void UnpackNativeDependencies(Assembly a) private static readonly Regex dllRx = new Regex(@"\.(dll|exe)$"); private static readonly Regex dylibRx = new Regex(@"\.dylib$"); - /// The path native dlls will be extracted to, each either each library to a separate folder or directly to the NativeLibraryPath + /// The path native dlls will be extracted to, each either each library to a separate folder or directly to the NativeLibraryPath /// directory (depending on the configuration of SeparateLibraryDirectories). - /// + /// /// The default configuration extract native libraries to shared temp path with each library in its unique versioned directory. - /// - /// Setting NativeLibraryPath to the application path and SeparateLibraryDirectories to false will result in the "old" style of + /// + /// Setting NativeLibraryPath to the application path and SeparateLibraryDirectories to false will result in the "old" style of /// loading native libs, that is not compatible if the application does not have write permission to the directory (e.g. ProgramFiles). [Obsolete("using explicit native library path is no longer possble https://github.com/aardvark-platform/aardvark.base/issues/64")] public static string NativeLibraryPath = Path.Combine(Path.GetTempPath(), "aardvark-native"); @@ -1567,7 +1567,7 @@ public static IntPtr LoadLibrary(Assembly assembly, string nativeName) } IntPtr ptr = IntPtr.Zero; string probe = Environment.CurrentDirectory; - var nextToAssembly = new string[0]; + var nextToAssembly = Array.Empty(); if (assembly != null) { @@ -1587,7 +1587,7 @@ public static IntPtr LoadLibrary(Assembly assembly, string nativeName) try { - string[] formats = new string[0]; + string[] formats = Array.Empty(); if (os == OS.Linux) formats = new[] { "{0}.so", "lib{0}.so", "lib{0}.so.1" }; else if (os == OS.Win32) formats = new[] { "{0}.dll" }; @@ -1640,7 +1640,7 @@ public static IntPtr LoadLibrary(Assembly assembly, string nativeName) var lowerLibName = libName.ToLower(); var libPath = Directory.GetFiles(p).Where(fp => Path.GetFileName(fp).ToLower() == lowerLibName).FirstOrDefault(); if (libPath != null) - { + { if (setDllDir) Kernel32.SetDllDirectory(p); probe = libPath; @@ -1809,7 +1809,7 @@ public static void LoadNativeDependencies(Assembly a) #if NETCOREAPP3_1_OR_GREATER - string[] formats = new string[0]; + string[] formats = Array.Empty(); var os = GetOS(); if (os == OS.Linux) formats = new[] { "{0}.so", "lib{0}.so", "lib{0}.so.1" }; @@ -2001,7 +2001,7 @@ private static void LoadAll(IEnumerable xs) else if (parameters.Length == 1 && parameters[0].ParameterType == typeof(IEnumerable)) mi.Invoke(null, new object[] { Introspection.AllAssemblies }); else Report.Warn("Strange aardvark init method found: {0}, should be Init : IEnumberable -> unit or unit -> unit", mi); } - catch (Exception e) + catch (Exception e) { Report.Warn("failed: {0}", e); } diff --git a/src/Aardvark.Base/Math/Numerics/Polynomial.cs b/src/Aardvark.Base/Math/Numerics/Polynomial.cs index 006ceb5f7..abbbe8d65 100644 --- a/src/Aardvark.Base/Math/Numerics/Polynomial.cs +++ b/src/Aardvark.Base/Math/Numerics/Polynomial.cs @@ -61,7 +61,7 @@ public static double Evaluate(this double[] coeff, double x) public static double EvaluateDerivative(this double[] coeff, double x) { int i = coeff.Length - 1; - if (i < 0) throw new ArgumentException(); + if (i < 0) throw new ArgumentException(); double value = i * coeff[i]; --i; while (i > 0) { value = x * value + i * coeff[i]; --i; } @@ -82,7 +82,7 @@ public static double[] RealRoots(this double[] coeff) { case 0: case 1: - return new double[0]; + return Array.Empty(); case 2: return RealRootOf(coeff[1], coeff[2]).NonNanToArray(); case 3: return RealRootsOf(coeff[2], coeff[1], coeff[0]) .NonNanToArray(); @@ -107,7 +107,7 @@ public static double[] RealRootsNormed(this double[] coeff) { switch (coeff.Length) { - case 0: return new double[0]; + case 0: return Array.Empty(); case 1: return RealRootOfNormed(coeff[0]).IntoArray(); case 2: return RealRootsOfNormed(coeff[1], coeff[0]) .NonNanToArray(); @@ -122,7 +122,7 @@ public static double[] RealRootsNormed(this double[] coeff) private static double[] NonNanToArray(this double root) { - if (double.IsNaN(root)) return new double[0]; + if (double.IsNaN(root)) return Array.Empty(); return new double[] { root }; } @@ -130,7 +130,7 @@ private static double[] NonNanToArray(this (double, double) p) { if (double.IsNaN(p.Item1)) { - if (double.IsNaN(p.Item2)) return new double[0]; + if (double.IsNaN(p.Item2)) return Array.Empty(); return new double[] { p.Item2 }; } if (double.IsNaN(p.Item2)) return new double[] { p.Item1 }; @@ -174,7 +174,7 @@ public static double RealRootOf(double a, double b) if (Fun.IsTiny(a)) return double.NaN; return -b / a; } - + /// /// Return -p as the root of x + p = 0. /// @@ -378,14 +378,14 @@ public static (double, double, double, double) RealRootsOfNormed( u = Fun.Sqrt(u); // factor of 10^5! if (v < Constant.PositiveTinyValue) // values greater than v = 0.0; // +tiny == 4 * eps - else // do not seem to + else // do not seem to v = Fun.Sqrt(v); // improve accuraccy! double q1 = q < 0 ? -v : v; return MergeSortedAndShift(RealRootsOfNormed(q1, z - u), RealRootsOfNormed(-q1, z + u), -1/4.0 * c3); } - + static (double, double, double, double) MergeSortedAndShift( (double, double, double) t, double d, double shift) { @@ -457,10 +457,10 @@ private static double[] WithoutDoubleRoots4(double[] a, double eps) if (len < 2) return a; if ((a[0] - a[1]).Abs() < eps) { - if (len < 3) return new double[0]; + if (len < 3) return Array.Empty(); if (len < 4) return new double[] { a[2] }; if ((a[2] - a[3]).Abs() < eps) - return new double[0]; + return Array.Empty(); else return new double[] { a[2], a[3] }; } diff --git a/src/Tests/Aardvark.Base.Tests/RangesBoxes/BoxTests.cs b/src/Tests/Aardvark.Base.Tests/RangesBoxes/BoxTests.cs index 434f7b2fd..fbfb1b90d 100644 --- a/src/Tests/Aardvark.Base.Tests/RangesBoxes/BoxTests.cs +++ b/src/Tests/Aardvark.Base.Tests/RangesBoxes/BoxTests.cs @@ -26,7 +26,7 @@ public class BoxTests [Test] public void BoxFromEmptyArrayShouldBeInvalid() { - var ps = new V3d[0]; + var ps = Array.Empty(); var bb = new Box3d(ps); Assert.IsTrue(bb.IsInvalid); }