From ffde1fd9096ce88b1f3469b7a6558044f34c3c15 Mon Sep 17 00:00:00 2001 From: Martin Date: Wed, 5 Jun 2024 17:44:22 +0200 Subject: [PATCH] Add missing readonly modifiers --- .../Camera/CameraProjectionOrtho.cs | 2 +- .../Camera/CameraProjectionPerspective.cs | 2 +- .../Camera/CameraViewRaw.cs | 2 +- .../Camera/CameraViewWithSky.cs | 2 +- src/Aardvark.Base.Essentials/Screenshot.cs | 26 ++-- .../System/Awaitable.cs | 12 +- src/Aardvark.Base.Essentials/System/Clock.cs | 8 +- .../System/EventSource.cs | 6 +- .../System/EventSourceSpecials.cs | 6 +- .../System/FilteredEventSource.cs | 2 +- .../System/Reactive.cs | 12 +- src/Aardvark.Base.IO/Annotations.cs | 8 +- src/Aardvark.Base.IO/BaseCoder.cs | 6 +- src/Aardvark.Base.IO/BinaryReadingCoder.cs | 4 +- src/Aardvark.Base.IO/BinaryWritingCoder.cs | 8 +- src/Aardvark.Base.IO/ChunkedMemoryStream.cs | 4 +- src/Aardvark.Base.IO/Converter.cs | 18 +-- src/Aardvark.Base.IO/FieldCoderExtensions.cs | 6 +- src/Aardvark.Base.IO/IFieldCodeable.cs | 14 +- src/Aardvark.Base.IO/ITypedMap.cs | 4 +- src/Aardvark.Base.IO/StreamCodeReader.cs | 2 +- src/Aardvark.Base.IO/SymMap.cs | 2 +- src/Aardvark.Base.IO/TypeCoder.cs | 4 +- src/Aardvark.Base.IO/TypeInfo.cs | 14 +- src/Aardvark.Base.IO/TypeInfoVersion.cs | 6 +- src/Aardvark.Base.IO/UberStream.cs | 4 +- src/Aardvark.Base.IO/WorkDir.cs | 2 +- src/Aardvark.Base.IO/XmlReadingCoder.cs | 16 +-- src/Aardvark.Base.IO/XmlWritingCoder.cs | 16 +-- src/Aardvark.Base.IO/ZipFileContainer.cs | 6 +- src/Aardvark.Base.Telemetry/Debug.cs | 6 +- src/Aardvark.Base.Telemetry/Environment.cs | 2 +- src/Aardvark.Base.Telemetry/HardwareThread.cs | 2 +- src/Aardvark.Base.Telemetry/Probes.cs | 40 +++--- src/Aardvark.Base.Telemetry/Registry.cs | 4 +- src/Aardvark.Base.Telemetry/Views.cs | 22 +-- .../PixImage/PixImageCreators.cs | 4 +- .../AlgoDat/ConcurrentHashSet.cs | 6 +- .../AlgoDat/ExtendedCore/SortedSetExt.cs | 20 +-- src/Aardvark.Base/AlgoDat/LruCache.cs | 12 +- src/Aardvark.Base/AlgoDat/SalesmanOfDeath.cs | 34 ++--- src/Aardvark.Base/AlgoDat/ShortestPath.cs | 8 +- src/Aardvark.Base/Extensions/EnumHelpers.cs | 4 +- .../Extensions/StringExtensions.cs | 2 +- src/Aardvark.Base/Extensions/SubRange.cs | 8 +- src/Aardvark.Base/Extensions/UnsafeCoerce.cs | 2 +- src/Aardvark.Base/Geodesy/GeoConsts.cs | 16 +-- .../Geometry/Types/Geometry_auto.cs | 40 +++--- .../Geometry/Types/Geometry_template.cs | 10 +- .../Types/Polygon/ImmutablePolygon.cs | 2 +- .../Introspection/Introspection.cs | 26 ++-- src/Aardvark.Base/Math/Base/Constant.cs | 2 +- .../Math/Base/DistributionFunction.cs | 4 +- src/Aardvark.Base/Math/Base/MedianWindow.cs | 4 +- src/Aardvark.Base/Math/Base/Statistics.cs | 6 +- src/Aardvark.Base/Math/Colors/Color.cs | 8 +- src/Aardvark.Base/Math/Curves/Curves.cs | 4 +- src/Aardvark.Base/Math/Vectors/V3fCoder.cs | 14 +- .../Math/Vectors/VectorArrayExtensions.cs | 8 +- .../Random/ForcedRandomSeries.cs | 10 +- .../Random/HaltonRandomSeries.cs | 4 +- src/Aardvark.Base/Random/PerlinNoise.cs | 8 +- src/Aardvark.Base/Random/Prime.cs | 4 +- .../Random/PseudoRandomSeries.cs | 2 +- .../Random/RandomDistributions.cs | 2 +- .../Reporting/FilterLogTarget.cs | 4 +- src/Aardvark.Base/Reporting/JobReporter.cs | 6 +- src/Aardvark.Base/Reporting/MultiLogTarget.cs | 2 +- .../Reporting/PerThreadJobReporter.cs | 2 +- .../Reporting/PerThreadLogTarget.cs | 2 +- src/Aardvark.Base/Reporting/Report.cs | 6 +- src/Aardvark.Base/Reporting/Skipper.cs | 2 +- src/Aardvark.Base/Reporting/TextLogTarget.cs | 4 +- src/Aardvark.Base/Sorting/Sorting_auto.cs | 4 +- src/Aardvark.Base/Sorting/Sorting_template.cs | 4 +- src/Aardvark.Base/Symbol/Dict_auto.cs | 136 +++++++++--------- src/Aardvark.Base/Symbol/Dict_template.cs | 14 +- src/Aardvark.Base/Symbol/Dicts.cs | 28 ++-- .../Symbol/SymMapBaseTraversal.cs | 4 +- src/Aardvark.Base/Symbol/Symbol.cs | 8 +- src/Aardvark.Base/Text/TextParser.cs | 8 +- .../Aardvark.Base.Benchmarks/CodeGenTest.cs | 2 +- .../HashCodeCombine.cs | 8 +- src/Tests/Aardvark.Base.Benchmarks/Log2Int.cs | 14 +- .../MatrixMultiply.cs | 4 +- .../Rot3dTransform.cs | 2 +- .../StaticConstants.cs | 2 +- .../TelemetryProbesBenchmark.cs | 12 +- .../Aardvark.Base.Benchmarks/Transform.cs | 2 +- .../Aardvark.Base.Benchmarks/VectorLength.cs | 6 +- .../Extensions/DateTime.cs | 12 +- .../Aardvark.Base.Tests/Extensions/Hashes.cs | 2 +- 92 files changed, 437 insertions(+), 437 deletions(-) diff --git a/src/Aardvark.Base.Essentials/Camera/CameraProjectionOrtho.cs b/src/Aardvark.Base.Essentials/Camera/CameraProjectionOrtho.cs index fab222248..6f27b2b33 100644 --- a/src/Aardvark.Base.Essentials/Camera/CameraProjectionOrtho.cs +++ b/src/Aardvark.Base.Essentials/Camera/CameraProjectionOrtho.cs @@ -6,7 +6,7 @@ namespace Aardvark.Base public class CameraProjectionOrtho : ICameraProjection { private Trafo3d m_trafo; - private EventSource m_trafoChanges = new EventSource(); + private readonly EventSource m_trafoChanges = new EventSource(); private Box3d m_box; public CameraProjectionOrtho(double left, double right, double bottom, double top, double near, double far) diff --git a/src/Aardvark.Base.Essentials/Camera/CameraProjectionPerspective.cs b/src/Aardvark.Base.Essentials/Camera/CameraProjectionPerspective.cs index b46dcb37c..4d826af55 100644 --- a/src/Aardvark.Base.Essentials/Camera/CameraProjectionPerspective.cs +++ b/src/Aardvark.Base.Essentials/Camera/CameraProjectionPerspective.cs @@ -7,7 +7,7 @@ namespace Aardvark.Base public class CameraProjectionPerspective : ICameraProjectionPerspective { private Trafo3d m_trafo; - private EventSource m_trafoChanges = new EventSource(); + private readonly EventSource m_trafoChanges = new EventSource(); private Box3d m_box; public CameraProjectionPerspective(double horizontalFovInDegrees, double near, double far, double aspectRatio = 1.0) diff --git a/src/Aardvark.Base.Essentials/Camera/CameraViewRaw.cs b/src/Aardvark.Base.Essentials/Camera/CameraViewRaw.cs index 8b8c98d40..afce44055 100644 --- a/src/Aardvark.Base.Essentials/Camera/CameraViewRaw.cs +++ b/src/Aardvark.Base.Essentials/Camera/CameraViewRaw.cs @@ -5,7 +5,7 @@ namespace Aardvark.Base public class CameraViewRaw : ICameraView { private Trafo3d m_trafo = Trafo3d.ViewTrafo(V3d.Zero, V3d.XAxis, V3d.ZAxis, -V3d.YAxis); - private EventSource m_trafoChanges; + private readonly EventSource m_trafoChanges; public CameraViewRaw() { diff --git a/src/Aardvark.Base.Essentials/Camera/CameraViewWithSky.cs b/src/Aardvark.Base.Essentials/Camera/CameraViewWithSky.cs index 88ef6f426..734275a5b 100644 --- a/src/Aardvark.Base.Essentials/Camera/CameraViewWithSky.cs +++ b/src/Aardvark.Base.Essentials/Camera/CameraViewWithSky.cs @@ -7,7 +7,7 @@ public class CameraViewWithSky : ICameraView { private V3d m_sky = V3d.OOI; private Trafo3d m_trafo = Trafo3d.ViewTrafo(V3d.Zero, V3d.XAxis, V3d.ZAxis, -V3d.YAxis); - private EventSource m_trafoChanges = new EventSource(); + private readonly EventSource m_trafoChanges = new EventSource(); /// /// Sky direction (normalized). diff --git a/src/Aardvark.Base.Essentials/Screenshot.cs b/src/Aardvark.Base.Essentials/Screenshot.cs index 0c06f6b45..e02809660 100644 --- a/src/Aardvark.Base.Essentials/Screenshot.cs +++ b/src/Aardvark.Base.Essentials/Screenshot.cs @@ -22,12 +22,12 @@ private enum Mode Variable, Mixed, } - private Http.Verb m_verb; - private string m_route; - private Action m_handler; + private readonly Http.Verb m_verb; + private readonly string m_route; + private readonly Action m_handler; - private string[] m_tokens; - private Mode[] m_modes; + private readonly string[] m_tokens; + private readonly Mode[] m_modes; public Action Handler { get { return m_handler; } } public string Route { get { return m_route; } } @@ -104,7 +104,7 @@ public HttpServer2Route(string route, Http.Verb verb, Action m_routes = new List(); + private readonly List m_routes = new List(); public void AddRoutes(params HttpServer2Route[] routes) { @@ -145,7 +145,7 @@ public class HttpServerRequestInfo private string m_head; private string m_route; private Http.Verb m_verb; - private Dictionary m_query = new Dictionary(); + private readonly Dictionary m_query = new Dictionary(); public string Head { @@ -201,9 +201,9 @@ public double Get(string paramName, double defaultValue) public class HttpServerDispatcher { - private Dictionary>> m_handlers = + private readonly Dictionary>> m_handlers = new Dictionary>>(); - private Dictionary> m_dispatchers = + private readonly Dictionary> m_dispatchers = new Dictionary>(); public void Register(Func handler) @@ -450,13 +450,13 @@ public static WebResponse Send( public class HttpServer { private static string s_defaultPrefix = null; - private HttpListener m_listener = new HttpListener(); - private HttpServerDispatcher m_dispatcher = new HttpServerDispatcher(); + private readonly HttpListener m_listener = new HttpListener(); + private readonly HttpServerDispatcher m_dispatcher = new HttpServerDispatcher(); private HttpServer2Dispatcher m_dispatcher2 = null; private volatile bool m_isRunning = false; private volatile bool m_stop = false; - private object m_lock = new object(); + private readonly object m_lock = new object(); public void SwitchToNewStyle() { @@ -656,7 +656,7 @@ public void Start() }); } - private static string s_notFoundReply = + private static readonly string s_notFoundReply = new XElement("html", new XElement("body", new XElement("div", "Not found!"), diff --git a/src/Aardvark.Base.Essentials/System/Awaitable.cs b/src/Aardvark.Base.Essentials/System/Awaitable.cs index a9f7f106b..9e372ff8f 100644 --- a/src/Aardvark.Base.Essentials/System/Awaitable.cs +++ b/src/Aardvark.Base.Essentials/System/Awaitable.cs @@ -139,9 +139,9 @@ public IAwaiter GetAwaiter() #endregion - private struct Awaiter : IAwaiter + private readonly struct Awaiter : IAwaiter { - private Awaitable m_source; + private readonly Awaitable m_source; #region Constructors @@ -377,9 +377,9 @@ public void Emit() #endregion - private struct Awaiter : IAwaiter + private readonly struct Awaiter : IAwaiter { - private Awaitable m_source; + private readonly Awaitable m_source; #region Constructors @@ -804,7 +804,7 @@ void IAwaiter.GetResult() /// public class TaskAwaitable : IAwaitable { - private Task m_task; + private readonly Task m_task; /// /// @@ -843,7 +843,7 @@ public bool IsCompleted /// public class TaskAwaitable : IAwaitable { - private Task m_task; + private readonly Task m_task; /// /// diff --git a/src/Aardvark.Base.Essentials/System/Clock.cs b/src/Aardvark.Base.Essentials/System/Clock.cs index 731f5ee7d..196af298d 100644 --- a/src/Aardvark.Base.Essentials/System/Clock.cs +++ b/src/Aardvark.Base.Essentials/System/Clock.cs @@ -17,7 +17,7 @@ public class Clock : IDisposable private int m_frequency; private int m_minimalUpdateTime; private CancellationTokenSource m_source; - private Dictionary m_lastTime; + private readonly Dictionary m_lastTime; #region Constructors @@ -184,7 +184,7 @@ public static class ClockExtensions private struct FutureAwaiter : IAwaiter { - private FutureAwaitable m_future; + private readonly FutureAwaitable m_future; private Action m_continuation; public FutureAwaiter(FutureAwaitable f) @@ -253,8 +253,8 @@ void IAwaiter.GetResult() private class FutureAwaitable : IAwaitable { - private Clock m_time; - private int m_timeOut; + private readonly Clock m_time; + private readonly int m_timeOut; public FutureAwaitable(Clock time, int timeout = 0) { diff --git a/src/Aardvark.Base.Essentials/System/EventSource.cs b/src/Aardvark.Base.Essentials/System/EventSource.cs index 45874b484..eb4cd7d0a 100644 --- a/src/Aardvark.Base.Essentials/System/EventSource.cs +++ b/src/Aardvark.Base.Essentials/System/EventSource.cs @@ -5,7 +5,7 @@ namespace Aardvark.Base { public class EventSourceSlim : IEvent { - private Subject m_subject; + private readonly Subject m_subject; private T m_latest; public EventSourceSlim(T defaultValue) { @@ -121,11 +121,11 @@ public static EventSource> Create( /// public class EventSource : IEvent, IEventEmitter { - private ThreadLocal m_currentThreadDoesNotOwnLock = new ThreadLocal(() => true); + private readonly ThreadLocal m_currentThreadDoesNotOwnLock = new ThreadLocal(() => true); private SpinLock m_lock = new SpinLock(true); private T m_latest; private Awaitable m_awaitable = new Awaitable(); - private Lazy> m_eventStream = new Lazy>(); + private readonly Lazy> m_eventStream = new Lazy>(); /// /// Creates an EventSource with default initial value. diff --git a/src/Aardvark.Base.Essentials/System/EventSourceSpecials.cs b/src/Aardvark.Base.Essentials/System/EventSourceSpecials.cs index e09a67930..74b91cf66 100644 --- a/src/Aardvark.Base.Essentials/System/EventSourceSpecials.cs +++ b/src/Aardvark.Base.Essentials/System/EventSourceSpecials.cs @@ -52,9 +52,9 @@ public static ConstEventSource> Create public class ConstEventSource : IEvent { - private static Awaitable s_awaitableNonGeneric = new Awaitable(); - private static Awaitable s_awaitable = new Awaitable(); - private T m_value; + private static readonly Awaitable s_awaitableNonGeneric = new Awaitable(); + private static readonly Awaitable s_awaitable = new Awaitable(); + private readonly T m_value; /// /// diff --git a/src/Aardvark.Base.Essentials/System/FilteredEventSource.cs b/src/Aardvark.Base.Essentials/System/FilteredEventSource.cs index 1502f737c..caef833d3 100644 --- a/src/Aardvark.Base.Essentials/System/FilteredEventSource.cs +++ b/src/Aardvark.Base.Essentials/System/FilteredEventSource.cs @@ -6,7 +6,7 @@ namespace Aardvark.Base /// public class FilteredEventSource : EventSource { - private Func m_predicate; + private readonly Func m_predicate; /// /// diff --git a/src/Aardvark.Base.Essentials/System/Reactive.cs b/src/Aardvark.Base.Essentials/System/Reactive.cs index 1fc870ed0..da8acf54d 100644 --- a/src/Aardvark.Base.Essentials/System/Reactive.cs +++ b/src/Aardvark.Base.Essentials/System/Reactive.cs @@ -44,7 +44,7 @@ public void Dispose() internal class Subject : IObservable, IObserver { - private Dictionary, int> m_observers; + private readonly Dictionary, int> m_observers; public Subject() { @@ -111,7 +111,7 @@ public IDisposable Subscribe(IObserver obs) internal class LambdaObserver : IObserver { - private Action m_action; + private readonly Action m_action; public LambdaObserver(Action action) { @@ -132,8 +132,8 @@ public void OnError(Exception e) internal class MapObserver : IObserver { - private Func m_mapping; - private IObserver m_target; + private readonly Func m_mapping; + private readonly IObserver m_target; public MapObserver(IObserver target, Func mapping) { @@ -157,8 +157,8 @@ public void OnError(Exception error) internal class MapObservable : IObservable { - private IObservable m_input; - private Func m_mapping; + private readonly IObservable m_input; + private readonly Func m_mapping; public MapObservable(IObservable input, Func mapping) { diff --git a/src/Aardvark.Base.IO/Annotations.cs b/src/Aardvark.Base.IO/Annotations.cs index d8ac6ce91..219e0cf53 100644 --- a/src/Aardvark.Base.IO/Annotations.cs +++ b/src/Aardvark.Base.IO/Annotations.cs @@ -41,11 +41,11 @@ public Annotation(string key, object value) } } - internal struct Annotated + internal readonly struct Annotated { - private T m_value; - private IEnumerable m_tags; - private static IEnumerable s_empty = new Annotation[0]; + private readonly T m_value; + private readonly IEnumerable m_tags; + private static readonly IEnumerable s_empty = new Annotation[0]; public Annotated(T value) { diff --git a/src/Aardvark.Base.IO/BaseCoder.cs b/src/Aardvark.Base.IO/BaseCoder.cs index c1b557b8c..c4bab37d4 100644 --- a/src/Aardvark.Base.IO/BaseCoder.cs +++ b/src/Aardvark.Base.IO/BaseCoder.cs @@ -46,7 +46,7 @@ public BaseCoder() } private static bool s_initTypeInfosCalled = false; - private static object s_initTypeInfosLock = new Object(); + private static readonly object s_initTypeInfosLock = new Object(); private static void InitTypeInfos() { @@ -112,7 +112,7 @@ public TypeInfo TypeInfo public class BaseReadingCoder : BaseCoder { protected Dictionary m_typeInfoOfName; - private Stack> m_typeInfoArrayStack; + private readonly Stack> m_typeInfoArrayStack; protected List m_refs; #region Constructor @@ -178,7 +178,7 @@ public void Del(TypeInfo[] tia) public class BaseWritingCoder : BaseCoder { protected Dictionary m_typeInfoOfType; - private Stack> m_typeInfoArrayStack; + private readonly Stack> m_typeInfoArrayStack; protected Dictionary m_refs; #region Constructor diff --git a/src/Aardvark.Base.IO/BinaryReadingCoder.cs b/src/Aardvark.Base.IO/BinaryReadingCoder.cs index 8e4d69629..ffccc819a 100644 --- a/src/Aardvark.Base.IO/BinaryReadingCoder.cs +++ b/src/Aardvark.Base.IO/BinaryReadingCoder.cs @@ -13,10 +13,10 @@ namespace Aardvark.Base.Coder public partial class BinaryReadingCoder : BaseReadingCoder, ICoder, IDisposable, IReadingCoder { - private StreamCodeReader m_reader; + private readonly StreamCodeReader m_reader; private string m_fileName; private readonly int m_coderVersion; - private bool m_disposeStream; + private readonly bool m_disposeStream; #region Constructors diff --git a/src/Aardvark.Base.IO/BinaryWritingCoder.cs b/src/Aardvark.Base.IO/BinaryWritingCoder.cs index 00ddf0536..e1dc017bc 100644 --- a/src/Aardvark.Base.IO/BinaryWritingCoder.cs +++ b/src/Aardvark.Base.IO/BinaryWritingCoder.cs @@ -13,12 +13,12 @@ namespace Aardvark.Base.Coder public partial class BinaryWritingCoder : BaseWritingCoder, IWritingCoder, IDisposable { - private StreamCodeWriter m_writer; + private readonly StreamCodeWriter m_writer; private string m_fileName; private long m_size = 0; - private long m_sizePosition = 0; - private long m_startPosition = 0; - private bool m_disposeStream; + private readonly long m_sizePosition = 0; + private readonly long m_startPosition = 0; + private readonly bool m_disposeStream; #region Constructors diff --git a/src/Aardvark.Base.IO/ChunkedMemoryStream.cs b/src/Aardvark.Base.IO/ChunkedMemoryStream.cs index b3bb467fd..0d0045a36 100644 --- a/src/Aardvark.Base.IO/ChunkedMemoryStream.cs +++ b/src/Aardvark.Base.IO/ChunkedMemoryStream.cs @@ -6,8 +6,8 @@ namespace Aardvark.Base.Coder { public class ChunkedMemoryStream : Stream { - private long m_chunkSize; - List m_chunkList; + private readonly long m_chunkSize; + readonly List m_chunkList; private long m_position; private int m_posChunk; diff --git a/src/Aardvark.Base.IO/Converter.cs b/src/Aardvark.Base.IO/Converter.cs index 82e756bb1..add94abad 100644 --- a/src/Aardvark.Base.IO/Converter.cs +++ b/src/Aardvark.Base.IO/Converter.cs @@ -277,31 +277,31 @@ private struct RoutingEntry private bool m_initialized = false; private SpinLock m_spinLock = new SpinLock(); - private Dictionary<(string, string), Action> + private readonly Dictionary<(string, string), Action> m_actionMap = new Dictionary<(string, string), Action>(); - private Dictionary<(string, string), Annotation[]> + private readonly Dictionary<(string, string), Annotation[]> m_annotationsMap = new Dictionary<(string, string), Annotation[]>(); - private Dictionary> + private readonly Dictionary> m_routingMap = new Dictionary>(); - private Dictionary<(string, string), int> + private readonly Dictionary<(string, string), int> m_weightMap = new Dictionary<(string, string), int>(); - private Dictionary>> + private readonly Dictionary>> m_fileExtensionsMap = new Dictionary>>(); - private Dictionary>> + private readonly Dictionary>> m_rawConvertiblesMap = new Dictionary>>(); - private Dictionary>> + private readonly Dictionary>> m_creatorsMap = new Dictionary>>(); - private Dictionary> + private readonly Dictionary> m_resourcesMap = new Dictionary>(); - private List m_availableResources = new List(); + private readonly List m_availableResources = new List(); #endregion diff --git a/src/Aardvark.Base.IO/FieldCoderExtensions.cs b/src/Aardvark.Base.IO/FieldCoderExtensions.cs index 8cae6eb29..8ecb4bcfd 100644 --- a/src/Aardvark.Base.IO/FieldCoderExtensions.cs +++ b/src/Aardvark.Base.IO/FieldCoderExtensions.cs @@ -192,9 +192,9 @@ private static MethodInfo GetCodeMethodOverloadFor(Type t) return s_methodCodeT.MakeGenericMethod(t); } - private static MethodInfo s_methodCodeT; - private static MethodInfo s_methodCodeArrayOfT; - private static MethodInfo s_methodCodeListOfT; + private static readonly MethodInfo s_methodCodeT; + private static readonly MethodInfo s_methodCodeArrayOfT; + private static readonly MethodInfo s_methodCodeListOfT; static FieldCoderExtensions() { diff --git a/src/Aardvark.Base.IO/IFieldCodeable.cs b/src/Aardvark.Base.IO/IFieldCodeable.cs index b17d3608b..1205e6d2a 100644 --- a/src/Aardvark.Base.IO/IFieldCodeable.cs +++ b/src/Aardvark.Base.IO/IFieldCodeable.cs @@ -11,10 +11,10 @@ namespace Aardvark.Base.Coder /// public struct FieldCoder { - int m_order; + readonly int m_order; string m_name; - int m_minVersion; - int m_maxVersion; + readonly int m_minVersion; + readonly int m_maxVersion; Action m_code; #region Constructors @@ -92,8 +92,8 @@ public static IEnumerable Base( internal static class FieldCoderArray { - private static object s_lock = new object(); - private static Dictionary<(int, Type, int), FieldCoder[]> s_fieldCoderArrayMap + private static readonly object s_lock = new object(); + private static readonly Dictionary<(int, Type, int), FieldCoder[]> s_fieldCoderArrayMap = new Dictionary<(int, Type, int), FieldCoder[]>(); public static FieldCoder[] Get(int coderVersion, Type type, int version, IFieldCodeable fieldCodeAble) @@ -122,8 +122,8 @@ public static FieldCoder[] Get(int coderVersion, Type type, int version, IFieldC internal class FieldCoderMap : Dictionary> { - private static object s_lock = new object(); - private static Dictionary<(int, Type, int), FieldCoderMap> s_fieldCoderMapMap + private static readonly object s_lock = new object(); + private static readonly Dictionary<(int, Type, int), FieldCoderMap> s_fieldCoderMapMap = new Dictionary<(int, Type, int), FieldCoderMap>(); public static FieldCoderMap Get(int coderVersion, Type type, int version, IFieldCodeable fieldCodeAble) diff --git a/src/Aardvark.Base.IO/ITypedMap.cs b/src/Aardvark.Base.IO/ITypedMap.cs index 672862ac1..d90154317 100644 --- a/src/Aardvark.Base.IO/ITypedMap.cs +++ b/src/Aardvark.Base.IO/ITypedMap.cs @@ -62,8 +62,8 @@ public interface ITypedMap public class TypeOfString : Dictionary { } public static class FieldTypeMap { - static object s_lock = new object(); - static Dictionary s_fieldTypeTypeMap + static readonly object s_lock = new object(); + static readonly Dictionary s_fieldTypeTypeMap = new Dictionary(); public static TypeOfString Get(Type type, ITypedMap typedMap) diff --git a/src/Aardvark.Base.IO/StreamCodeReader.cs b/src/Aardvark.Base.IO/StreamCodeReader.cs index f65ecf412..7a4f9222b 100644 --- a/src/Aardvark.Base.IO/StreamCodeReader.cs +++ b/src/Aardvark.Base.IO/StreamCodeReader.cs @@ -109,7 +109,7 @@ struct ByteArrayUnion public Array structs; } - private static IntPtr s_byteId = GetTypeIdUncached(); + private static readonly IntPtr s_byteId = GetTypeIdUncached(); private static IntPtr GetTypeIdUncached() where T : struct { var gcHandle = GCHandle.Alloc(new T[1], GCHandleType.Pinned); diff --git a/src/Aardvark.Base.IO/SymMap.cs b/src/Aardvark.Base.IO/SymMap.cs index ca9d8d650..ffbb4054c 100644 --- a/src/Aardvark.Base.IO/SymMap.cs +++ b/src/Aardvark.Base.IO/SymMap.cs @@ -75,7 +75,7 @@ public void CreateNewGuidSymbolIfEmpty() /// Note that all types that are in this set need to implement IAwakeable /// and call CreateNewGuidSymbol in the Awake method. /// - private static SymbolDict s_lastMapCodedVersionMap = new SymbolDict + private static readonly SymbolDict s_lastMapCodedVersionMap = new SymbolDict { { "KdTreeSet", 3 }, { "SphereSet", 3 }, diff --git a/src/Aardvark.Base.IO/TypeCoder.cs b/src/Aardvark.Base.IO/TypeCoder.cs index 03b819cda..dfc7791a6 100644 --- a/src/Aardvark.Base.IO/TypeCoder.cs +++ b/src/Aardvark.Base.IO/TypeCoder.cs @@ -31,7 +31,7 @@ Action writer /// public static partial class TypeCoder { - static Dictionary> s_genericWriterMap = + static readonly Dictionary> s_genericWriterMap = new Dictionary> { { typeof(List<>), (c,t,o) => { var v = (IList)o; c.Code(t, ref v); } }, @@ -47,7 +47,7 @@ public static partial class TypeCoder { typeof(HashSet<>), (c,t,o) => { c.CodeHashSet(t, ref o); } }, }; - static Dictionary> s_genericReaderMap = + static readonly Dictionary> s_genericReaderMap = new Dictionary> { { typeof(List<>), (c,t) => { var v = default(IList); c.Code(t, ref v); return v; } }, diff --git a/src/Aardvark.Base.IO/TypeInfo.cs b/src/Aardvark.Base.IO/TypeInfo.cs index 5c1458371..e60095809 100644 --- a/src/Aardvark.Base.IO/TypeInfo.cs +++ b/src/Aardvark.Base.IO/TypeInfo.cs @@ -13,11 +13,11 @@ public class TypeInfo { private Type m_type; private string m_name; - private string m_xmlName; - private int m_version; + private readonly string m_xmlName; + private readonly int m_version; private Option m_options; private Dictionary m_versionMap; - private Func m_creator; + private readonly Func m_creator; private object m_typeOptions; public Type ProxyType; // if this != null m_creator must create a proxy object @@ -175,16 +175,16 @@ public void AddVersion(TypeInfo oldTypeInfo) #region Private Static Members - private static object s_lock = new object(); + private static readonly object s_lock = new object(); private static readonly Dictionary s_emptyVersionMap = new Dictionary(); - private static Dictionary s_ofType = + private static readonly Dictionary s_ofType = new Dictionary(); - private static Dictionary s_ofName = + private static readonly Dictionary s_ofName = new Dictionary(); - private static Dictionary s_ofXmlName = + private static readonly Dictionary s_ofXmlName = new Dictionary(); #endregion diff --git a/src/Aardvark.Base.IO/TypeInfoVersion.cs b/src/Aardvark.Base.IO/TypeInfoVersion.cs index 8c555e1b4..9cfe2514c 100644 --- a/src/Aardvark.Base.IO/TypeInfoVersion.cs +++ b/src/Aardvark.Base.IO/TypeInfoVersion.cs @@ -62,13 +62,13 @@ public static void Add( } } - private static Dictionary> s_oldTypeListOfType = + private static readonly Dictionary> s_oldTypeListOfType = new Dictionary>(); - private static Dictionary)> + private static readonly Dictionary)> s_conversionOfTargetType = new Dictionary)>(); - private static object s_lock = new object(); + private static readonly object s_lock = new object(); } } diff --git a/src/Aardvark.Base.IO/UberStream.cs b/src/Aardvark.Base.IO/UberStream.cs index cca929bb5..d49ebdd6a 100644 --- a/src/Aardvark.Base.IO/UberStream.cs +++ b/src/Aardvark.Base.IO/UberStream.cs @@ -21,8 +21,8 @@ private struct SubStream #region private fields private long m_position; - private long m_totalLength; - private SubStream[] m_streams; + private readonly long m_totalLength; + private readonly SubStream[] m_streams; #endregion diff --git a/src/Aardvark.Base.IO/WorkDir.cs b/src/Aardvark.Base.IO/WorkDir.cs index 82959e69a..79af93cf1 100644 --- a/src/Aardvark.Base.IO/WorkDir.cs +++ b/src/Aardvark.Base.IO/WorkDir.cs @@ -165,7 +165,7 @@ public static class WorkDir private const string c_workDirNameEnvVariable = "AARDVARK_WORKDIR"; private static string s_workDirName = null; - private static string[] s_fallbackWorkDirNames = + private static readonly string[] s_fallbackWorkDirNames = { @"C:\Aardwork", @"C:\Data\Aardwork", diff --git a/src/Aardvark.Base.IO/XmlReadingCoder.cs b/src/Aardvark.Base.IO/XmlReadingCoder.cs index 367bacac4..366251c95 100644 --- a/src/Aardvark.Base.IO/XmlReadingCoder.cs +++ b/src/Aardvark.Base.IO/XmlReadingCoder.cs @@ -13,11 +13,11 @@ namespace Aardvark.Base.Coder public partial class NewXmlReadingCoder : BaseReadingCoder, IReadingCoder, IDisposable { - private Stack m_stateStack; + private readonly Stack m_stateStack; private State m_state; - private int m_coderVersion; - private Stream m_stream; - private bool m_disposeStream; + private readonly int m_coderVersion; + private readonly Stream m_stream; + private readonly bool m_disposeStream; private string m_fileName; #region Constructors @@ -693,12 +693,12 @@ public void Dispose() public partial class XmlReadingCoder : BaseReadingCoder, IReadingCoder, IDisposable { - private Stack m_stateStack; + private readonly Stack m_stateStack; private State m_state; - private Stream m_stream; + private readonly Stream m_stream; private string m_fileName; private readonly int m_coderVersion; - private bool m_disposeStream = false; + private readonly bool m_disposeStream = false; #region Constructors @@ -1534,7 +1534,7 @@ internal void CodeList(ref List value, items.ForEach(s => { v.Add(creator(s)); }); } - static char[] s_itemSeparator = new[] { ',' }; + static readonly char[] s_itemSeparator = new[] { ',' }; internal void CodeArray(ref T[] v, Func fromString) { diff --git a/src/Aardvark.Base.IO/XmlWritingCoder.cs b/src/Aardvark.Base.IO/XmlWritingCoder.cs index a565db949..803921f9e 100644 --- a/src/Aardvark.Base.IO/XmlWritingCoder.cs +++ b/src/Aardvark.Base.IO/XmlWritingCoder.cs @@ -13,9 +13,9 @@ public partial class NewXmlWritingCoder : BaseWritingCoder, IWritingCoder, IDisposable { public Stack m_itemStack; - private XmlItem m_item; - private Stream m_stream; - bool m_disposeStream; + private readonly XmlItem m_item; + private readonly Stream m_stream; + readonly bool m_disposeStream; private string m_fileName; // bool m_writeRefNumbers; @@ -326,13 +326,13 @@ public void Dispose() public partial class XmlWritingCoder : BaseWritingCoder, IWritingCoder, IDisposable { - private Stack m_elementStack; + private readonly Stack m_elementStack; protected XElement m_element; - private XElement m_container; - private Stream m_stream; + private readonly XElement m_container; + private readonly Stream m_stream; private string m_fileName; bool m_writeRefNumbers; - bool m_disposeStream = false; + readonly bool m_disposeStream = false; #region Constructors @@ -1003,7 +1003,7 @@ public void CodeDouble(ref double value) AddValue(value.ToString(CultureInfo.InvariantCulture)); } - private static char[] s_stringSplitChars = new[] + private static readonly char[] s_stringSplitChars = new[] { '\0', Convert.ToChar(0x19), diff --git a/src/Aardvark.Base.IO/ZipFileContainer.cs b/src/Aardvark.Base.IO/ZipFileContainer.cs index 2437f7c22..960160fcc 100644 --- a/src/Aardvark.Base.IO/ZipFileContainer.cs +++ b/src/Aardvark.Base.IO/ZipFileContainer.cs @@ -26,9 +26,9 @@ private struct SubFileHeader private string[] m_ZipFileNames = new string[0]; private WeakReference[] m_ZipFileStreams = new WeakReference[0]; - private SymbolDict m_Files = new SymbolDict(); - private SymbolSet m_Directories = new SymbolSet(); - private bool m_contentCaseSensitive = false; + private readonly SymbolDict m_Files = new SymbolDict(); + private readonly SymbolSet m_Directories = new SymbolSet(); + private readonly bool m_contentCaseSensitive = false; #endregion diff --git a/src/Aardvark.Base.Telemetry/Debug.cs b/src/Aardvark.Base.Telemetry/Debug.cs index 883e4ba0c..6611d95db 100644 --- a/src/Aardvark.Base.Telemetry/Debug.cs +++ b/src/Aardvark.Base.Telemetry/Debug.cs @@ -8,7 +8,7 @@ public static partial class Telemetry { public static class Debug { - private static List> s_registrationActions = new List>(); + private static readonly List> s_registrationActions = new List>(); /// /// e.g.: using (Telemetry.Debug.CpuTimers.YourTimerNameHere) { /* stuff to time */ } @@ -40,7 +40,7 @@ static Debug() => AddCustomRegistrationAction( private class DynamicCpuTimeProvider : DynamicObject { - private Dictionary m_probes = new Dictionary(); + private readonly Dictionary m_probes = new Dictionary(); public override IEnumerable GetDynamicMemberNames() => m_probes.Keys; @@ -65,7 +65,7 @@ public override bool TryGetMember(GetMemberBinder binder, out object result) private class DynamicCounterProvider : DynamicObject { - private Dictionary m_probes = new Dictionary(); + private readonly Dictionary m_probes = new Dictionary(); public override IEnumerable GetDynamicMemberNames() => m_probes.Keys; diff --git a/src/Aardvark.Base.Telemetry/Environment.cs b/src/Aardvark.Base.Telemetry/Environment.cs index 736398546..1d88110d8 100644 --- a/src/Aardvark.Base.Telemetry/Environment.cs +++ b/src/Aardvark.Base.Telemetry/Environment.cs @@ -9,7 +9,7 @@ public static partial class Telemetry { public class Env : DynamicObject, IEnumerable { - private Dictionary m_probes = + private readonly Dictionary m_probes = new Dictionary(); public void SetMember(string name, IProbe probe) diff --git a/src/Aardvark.Base.Telemetry/HardwareThread.cs b/src/Aardvark.Base.Telemetry/HardwareThread.cs index 7b0876629..7c177d274 100644 --- a/src/Aardvark.Base.Telemetry/HardwareThread.cs +++ b/src/Aardvark.Base.Telemetry/HardwareThread.cs @@ -8,7 +8,7 @@ namespace Aardvark.Base { public static class HardwareThread { - private static Dictionary s_pts = new Dictionary(); + private static readonly Dictionary s_pts = new Dictionary(); private static SpinLock s_ptsLock = new SpinLock(); public static ProcessThread GetProcessThread(int tid) diff --git a/src/Aardvark.Base.Telemetry/Probes.cs b/src/Aardvark.Base.Telemetry/Probes.cs index c8ecab30f..e5fd9d7f9 100644 --- a/src/Aardvark.Base.Telemetry/Probes.cs +++ b/src/Aardvark.Base.Telemetry/Probes.cs @@ -50,7 +50,7 @@ public class StopWatchTime : IProbe public struct StopWatchTimeTimer : IDisposable { StopWatchTime Source; - Stopwatch Watch; + readonly Stopwatch Watch; internal StopWatchTimeTimer(StopWatchTime source, Stopwatch watch) { Source = source; Watch = watch; } public void Dispose() @@ -75,7 +75,7 @@ public void Dispose() public class WallClockTime : IProbe { private int m_actives = 0; - private Stopwatch m_stopwatch = new Stopwatch(); + private readonly Stopwatch m_stopwatch = new Stopwatch(); public WallClockTime() => OnReset += (s, e) => m_stopwatch.Reset(); @@ -129,10 +129,10 @@ private ProcessThread GetCurrentProcessThread() return m_threadLocalProcessThread.Value; } - private ThreadLocal m_threadLocalWin32ThreadId = new ThreadLocal(() => -1); - private ThreadLocal m_threadLocalProcessThread = new ThreadLocal(); + private readonly ThreadLocal m_threadLocalWin32ThreadId = new ThreadLocal(() => -1); + private readonly ThreadLocal m_threadLocalProcessThread = new ThreadLocal(); - private ThreadLocal m_active = new ThreadLocal(() => false); + private readonly ThreadLocal m_active = new ThreadLocal(() => false); private long m_sum = 0; @@ -175,7 +175,7 @@ public CpuTimeTimer Timer public struct CpuTimeTimer : IDisposable { CpuTime Source; - long T0, T0User, T0Privileged; + readonly long T0, T0User, T0Privileged; internal CpuTimeTimer(CpuTime source, long t0, long t0user, long t0priv) { Source = source; T0 = t0; T0User = t0user; T0Privileged = t0priv; } @@ -250,10 +250,10 @@ private ProcessThread GetCurrentProcessThread() return m_threadLocalProcessThread.Value; } - private ThreadLocal m_threadLocalWin32ThreadId = new ThreadLocal(() => -1); - private ThreadLocal m_threadLocalProcessThread = new ThreadLocal(); + private readonly ThreadLocal m_threadLocalWin32ThreadId = new ThreadLocal(() => -1); + private readonly ThreadLocal m_threadLocalProcessThread = new ThreadLocal(); - private HashSet m_threadIds = new HashSet(); + private readonly HashSet m_threadIds = new HashSet(); private TimeSpan m_sum = TimeSpan.Zero; public CpuTimeUser() => OnReset += (s, e) => { lock (m_threadIds) m_sum = TimeSpan.Zero; }; @@ -287,7 +287,7 @@ public struct CpuTimeUserTimer : IDisposable { CpuTimeUser Source; TimeSpan T0; - int ThreadId; + readonly int ThreadId; internal CpuTimeUserTimer(CpuTimeUser source, TimeSpan t0, int threadId) { Source = source; T0 = t0; ThreadId = threadId; } @@ -337,10 +337,10 @@ private ProcessThread GetCurrentProcessThread() Thread.EndThreadAffinity(); return m_threadLocalProcessThread.Value; } - private ThreadLocal m_threadLocalWin32ThreadId = new ThreadLocal(() => -1); - private ThreadLocal m_threadLocalProcessThread = new ThreadLocal(); + private readonly ThreadLocal m_threadLocalWin32ThreadId = new ThreadLocal(() => -1); + private readonly ThreadLocal m_threadLocalProcessThread = new ThreadLocal(); - private HashSet m_threadIds = new HashSet(); + private readonly HashSet m_threadIds = new HashSet(); private TimeSpan m_sum = TimeSpan.Zero; public CpuTimePrivileged() @@ -378,7 +378,7 @@ public struct CpuTimePrivilegedTimer : IDisposable { CpuTimePrivileged Source; TimeSpan T0; - int ThreadId; + readonly int ThreadId; internal CpuTimePrivilegedTimer(CpuTimePrivileged source, TimeSpan t0, int threadId) { Source = source; T0 = t0; ThreadId = threadId; } @@ -416,7 +416,7 @@ public TimeSpan Value public class CustomProbeDouble : IProbe { - private Func m_value; + private readonly Func m_value; public CustomProbeDouble(Func valueFunc) => m_value = valueFunc; @@ -427,7 +427,7 @@ public class CustomProbeDouble : IProbe public class CustomProbeLong : IProbe { - private Func m_value; + private readonly Func m_value; public CustomProbeLong(Func valueFunc) => m_value = valueFunc; @@ -451,7 +451,7 @@ public class CustomProbeTimeSpan : IProbe public class CustomProbeString : IProbe { - private Func m_value; + private readonly Func m_value; public CustomProbeString(Func valueFunc) => m_value = valueFunc; @@ -469,7 +469,7 @@ public class CustomProbeString : IProbe /// public class SnapshotProbeLong : IProbe { - private IProbe m_probe; + private readonly IProbe m_probe; private long m_base; /// @@ -492,7 +492,7 @@ public SnapshotProbeLong(IProbe probe) /// public class SnapshotProbeDouble : IProbe { - private IProbe m_probe; + private readonly IProbe m_probe; private double m_base; /// @@ -515,7 +515,7 @@ public SnapshotProbeDouble(IProbe probe) /// public class SnapshotProbeTimeSpan : IProbe { - private IProbe m_probe; + private readonly IProbe m_probe; private long m_base; /// diff --git a/src/Aardvark.Base.Telemetry/Registry.cs b/src/Aardvark.Base.Telemetry/Registry.cs index e8c936ae0..29b401656 100644 --- a/src/Aardvark.Base.Telemetry/Registry.cs +++ b/src/Aardvark.Base.Telemetry/Registry.cs @@ -6,9 +6,9 @@ namespace Aardvark.Base { public static partial class Telemetry { - private static Dictionary s_namedProbes + private static readonly Dictionary s_namedProbes = new Dictionary(); - private static Dictionary>> s_providersForTimingStats + private static readonly Dictionary>> s_providersForTimingStats = new Dictionary>>(); public static Tuple[] NamedProbes diff --git a/src/Aardvark.Base.Telemetry/Views.cs b/src/Aardvark.Base.Telemetry/Views.cs index 5fd863720..4f2b88452 100644 --- a/src/Aardvark.Base.Telemetry/Views.cs +++ b/src/Aardvark.Base.Telemetry/Views.cs @@ -8,8 +8,8 @@ public static partial class Telemetry { public class UtilizationView : IProbe { - private Stopwatch m_stopwatch = new Stopwatch(); - private Func m_baseValue; + private readonly Stopwatch m_stopwatch = new Stopwatch(); + private readonly Func m_baseValue; private UtilizationView(Func baseValue) { @@ -34,8 +34,8 @@ public UtilizationView(IProbe time) public class RatePerSecondView : IProbe { - private IProbe m_counter; - private Stopwatch m_stopwatch = new Stopwatch(); + private readonly IProbe m_counter; + private readonly Stopwatch m_stopwatch = new Stopwatch(); private double m_lastValue; private long m_lastTicks; private double m_result; @@ -84,7 +84,7 @@ public double Value public class RatioView : IProbe { - private Func m_f; + private readonly Func m_f; public RatioView(IProbe nominator, IProbe denominator) { @@ -110,7 +110,7 @@ public RatioView(IProbe nominator, double denominator) public class SumView : IProbe { - private Func m_f; + private readonly Func m_f; public SumView(IProbe one, params IProbe[] others) { @@ -137,7 +137,7 @@ public SumView(IProbe one, params double[] others) public class SubtractView : IProbe { - private Func m_f; + private readonly Func m_f; public SubtractView(IProbe one, params IProbe[] others) { @@ -164,7 +164,7 @@ public SubtractView(IProbe one, params double[] others) public class MultiplyView : IProbe { - private Func m_f; + private readonly Func m_f; public MultiplyView(IProbe one, IProbe other) { @@ -189,7 +189,7 @@ public MultiplyView(IProbe one, double other) public class MinView : IProbe { - private Func m_f; + private readonly Func m_f; public MinView(IProbe one, params IProbe[] others) { @@ -216,7 +216,7 @@ public MinView(IProbe one, params double[] others) public class MaxView : IProbe { - private Func m_f; + private readonly Func m_f; public MaxView(IProbe one, params IProbe[] others) { @@ -243,7 +243,7 @@ public MaxView(IProbe one, params double[] others) public class AvgView : IProbe { - private Func m_f; + private readonly Func m_f; public AvgView(IProbe one, params IProbe[] others) { diff --git a/src/Aardvark.Base.Tensors.CSharp/PixImage/PixImageCreators.cs b/src/Aardvark.Base.Tensors.CSharp/PixImage/PixImageCreators.cs index 608acd4da..fc9e4bd18 100644 --- a/src/Aardvark.Base.Tensors.CSharp/PixImage/PixImageCreators.cs +++ b/src/Aardvark.Base.Tensors.CSharp/PixImage/PixImageCreators.cs @@ -8,11 +8,11 @@ public partial class PixImage new V3d[] { new V3d(-1, -1, 1), new V3d(-1, 1, 1), new V3d(1, 1, 1), new V3d(1, -1, 1), new V3d(-1, -1, 1), new V3d(-1, 1, -1) }; - private static V3d[] s_dx = + private static readonly V3d[] s_dx = new V3d[] { new V3d(0, 2, 0), new V3d(2, 0, 0), new V3d(0, -2, 0), new V3d(-2, 0, 0), new V3d(2, 0, 0), new V3d(2, 0, 0) }; - private static V3d[] s_dy = + private static readonly V3d[] s_dy = new V3d[] { new V3d(0, 0, -2), new V3d(0, 0, -2), new V3d(0, 0, -2), new V3d(0, 0, -2), new V3d(0, 2, 0), new V3d(0, -2, 0) }; diff --git a/src/Aardvark.Base/AlgoDat/ConcurrentHashSet.cs b/src/Aardvark.Base/AlgoDat/ConcurrentHashSet.cs index a5d87dab8..732274f92 100644 --- a/src/Aardvark.Base/AlgoDat/ConcurrentHashSet.cs +++ b/src/Aardvark.Base/AlgoDat/ConcurrentHashSet.cs @@ -10,7 +10,7 @@ public class ConcurrentHashSet : IEnumerable, ICollection { //int does not waste too much memory and might be used for reference-counting //or similar features. TODO: investigate if this is faster using reference types. - private ConcurrentDictionary m_entries; + private readonly ConcurrentDictionary m_entries; #region Constructors @@ -85,9 +85,9 @@ public void UnionWith(IEnumerable other) #endregion - public struct Enumerator : IEnumerator, System.Collections.IEnumerator + public readonly struct Enumerator : IEnumerator, System.Collections.IEnumerator { - private IEnumerator> m_enumerator; + private readonly IEnumerator> m_enumerator; internal Enumerator(ConcurrentHashSet set) { diff --git a/src/Aardvark.Base/AlgoDat/ExtendedCore/SortedSetExt.cs b/src/Aardvark.Base/AlgoDat/ExtendedCore/SortedSetExt.cs index a12cb911b..2aefbebdb 100644 --- a/src/Aardvark.Base/AlgoDat/ExtendedCore/SortedSetExt.cs +++ b/src/Aardvark.Base/AlgoDat/ExtendedCore/SortedSetExt.cs @@ -72,7 +72,7 @@ public class SortedSetExt : ISet, ICollection, ICollection, IReadOnlyCo { #region local variables/constants private Node _root; - private IComparer _comparer; + private readonly IComparer _comparer; private int _count; private int _version; private Object _syncRoot; @@ -2023,13 +2023,13 @@ internal virtual bool versionUpToDate() /// internal sealed class TreeSubSet : SortedSetExt { - private SortedSetExt _underlying; - private T _min, _max; + private readonly SortedSetExt _underlying; + private readonly T _min, _max; //these exist for unbounded collections //for instance, you could allow this subset to be defined for i>10. The set will throw if //anything <=10 is added, but there is no upperbound. These features Head(), Tail(), were punted //in the spec, and are not available, but the framework is there to make them available at some point. - private bool _lBoundActive, _uBoundActive; + private readonly bool _lBoundActive, _uBoundActive; //used to see if the count is out of date @@ -2342,15 +2342,15 @@ public Node(T item, bool isRed) [SuppressMessage("Microsoft.Performance", "CA1815:OverrideEqualsAndOperatorEqualsOnValueTypes", Justification = "not an expected scenario")] public struct Enumerator : IEnumerator, IEnumerator { - private SortedSetExt _tree; - private int _version; + private readonly SortedSetExt _tree; + private readonly int _version; - private Stack.Node> _stack; + private readonly Stack.Node> _stack; private SortedSetExt.Node _current; //private static SortedSetExt.Node s_dummyNode = new SortedSetExt.Node(default(T)); - private bool _reverse; + private readonly bool _reverse; internal Enumerator(SortedSetExt set) { @@ -2537,8 +2537,8 @@ private static int log2(int value) /// internal sealed class SortedSetEqualityComparer : IEqualityComparer> { - private IComparer _comparer; - private IEqualityComparer _eqComparer; + private readonly IComparer _comparer; + private readonly IEqualityComparer _eqComparer; public SortedSetEqualityComparer() : this(null, null) { } diff --git a/src/Aardvark.Base/AlgoDat/LruCache.cs b/src/Aardvark.Base/AlgoDat/LruCache.cs index ccffc677d..f2c5e99ee 100644 --- a/src/Aardvark.Base/AlgoDat/LruCache.cs +++ b/src/Aardvark.Base/AlgoDat/LruCache.cs @@ -20,12 +20,12 @@ private class Entry public Action DeleteAct; } - private object m_lock; - private Dict m_cache; - private List m_heap; - private Func m_sizeFun; - private Func m_readFun; - private Action m_deleteAct; + private readonly object m_lock; + private readonly Dict m_cache; + private readonly List m_heap; + private readonly Func m_sizeFun; + private readonly Func m_readFun; + private readonly Action m_deleteAct; private long m_capacity; private long m_time; private long m_size; diff --git a/src/Aardvark.Base/AlgoDat/SalesmanOfDeath.cs b/src/Aardvark.Base/AlgoDat/SalesmanOfDeath.cs index 9cf89b736..923454664 100644 --- a/src/Aardvark.Base/AlgoDat/SalesmanOfDeath.cs +++ b/src/Aardvark.Base/AlgoDat/SalesmanOfDeath.cs @@ -4,10 +4,10 @@ namespace Aardvark.Base { - public struct SymmetricMatrix + public readonly struct SymmetricMatrix { - private T[] m_data; - private long m_size; + private readonly T[] m_data; + private readonly long m_size; #region Constructors @@ -179,9 +179,9 @@ public abstract class AbstractGraph where TCost : struct, ICompa #region Reference-Structures/Classes - public struct Edge : IComparable + public readonly struct Edge : IComparable { - private AbstractGraph m_graph; + private readonly AbstractGraph m_graph; public readonly int Index0; public readonly int Index1; @@ -236,8 +236,8 @@ public override bool Equals(object obj) protected class UnionFind { - private List m_nodes; - private int[] m_parent; + private readonly List m_nodes; + private readonly int[] m_parent; #region Constructors @@ -285,12 +285,12 @@ public bool Add(int n0, int n1) public class Tree { - private AbstractGraph m_graph; + private readonly AbstractGraph m_graph; - private List> m_edges; + private readonly List> m_edges; private int m_edgeCount; - private bool[] m_visited; + private readonly bool[] m_visited; #region Constructors @@ -430,10 +430,10 @@ public TAccumulate GetCost(Func ad public class Tour { - private AbstractGraph m_graph; - private int[] m_permutation; + private readonly AbstractGraph m_graph; + private readonly int[] m_permutation; private bool m_2optImproved; - private bool m_circular; + private readonly bool m_circular; #region Constructors @@ -541,10 +541,10 @@ public override string ToString() #endregion } - public struct Vertex + public readonly struct Vertex { - private AbstractGraph m_graph; - private int m_index; + private readonly AbstractGraph m_graph; + private readonly int m_index; #region Constructors @@ -1020,7 +1020,7 @@ public override TCost GetCost(int n0, int n1) internal static class GraphHelpers { - private static Dictionary> m_additions = new Dictionary>() + private static readonly Dictionary> m_additions = new Dictionary>() { {typeof(int), (a,b) => (int)a + (int)b}, {typeof(uint), (a,b) => (uint)a + (uint)b}, diff --git a/src/Aardvark.Base/AlgoDat/ShortestPath.cs b/src/Aardvark.Base/AlgoDat/ShortestPath.cs index f626d6c33..d3539a23e 100644 --- a/src/Aardvark.Base/AlgoDat/ShortestPath.cs +++ b/src/Aardvark.Base/AlgoDat/ShortestPath.cs @@ -17,9 +17,9 @@ public interface IShortestPath public class ShortestPath : IShortestPath { - private List m_nodes; - private List[] m_neighbors; - private Func m_getCostFunc; + private readonly List m_nodes; + private readonly List[] m_neighbors; + private readonly Func m_getCostFunc; private bool[] m_expanded; private int[] m_pointers; private bool m_cancelTask = false; @@ -159,7 +159,7 @@ class FibonacciHeap { public class Node { - private T _item; + private readonly T _item; private Node _parent; private Node _left; private Node _right; diff --git a/src/Aardvark.Base/Extensions/EnumHelpers.cs b/src/Aardvark.Base/Extensions/EnumHelpers.cs index d5eaac137..5a54f7088 100644 --- a/src/Aardvark.Base/Extensions/EnumHelpers.cs +++ b/src/Aardvark.Base/Extensions/EnumHelpers.cs @@ -5,7 +5,7 @@ namespace Aardvark.Base { public static class EnumHelpers { - static Dict> s_neighbourValuesDicts = new Dict>(); + static readonly Dict> s_neighbourValuesDicts = new Dict>(); static Dict GetNeighbourValuesDict(Type enumType) { @@ -57,7 +57,7 @@ public static T GetNextValue(T enumValue) return (T)result.Item2; } - static Dictionary)> s_valueIndexMapping = new Dictionary)>(); // long = worst case enum value + static readonly Dictionary)> s_valueIndexMapping = new Dictionary)>(); // long = worst case enum value static (Array, Dictionary) GetValueIndexMapping(Type enumType) { diff --git a/src/Aardvark.Base/Extensions/StringExtensions.cs b/src/Aardvark.Base/Extensions/StringExtensions.cs index 52d69b74b..7daa019cf 100644 --- a/src/Aardvark.Base/Extensions/StringExtensions.cs +++ b/src/Aardvark.Base/Extensions/StringExtensions.cs @@ -178,7 +178,7 @@ static readonly Dictionary s_irregularPlural { "woman", "women" }, }; - static Dictionary[] s_pluralEndings + static readonly Dictionary[] s_pluralEndings = new Dictionary[] { null, diff --git a/src/Aardvark.Base/Extensions/SubRange.cs b/src/Aardvark.Base/Extensions/SubRange.cs index a157c39fb..06cde185b 100644 --- a/src/Aardvark.Base/Extensions/SubRange.cs +++ b/src/Aardvark.Base/Extensions/SubRange.cs @@ -8,10 +8,10 @@ namespace Aardvark.Base /// public class SubRange : IList { - private IList m_base; - private int m_start; - private int m_count; - private int m_stop; + private readonly IList m_base; + private readonly int m_start; + private readonly int m_count; + private readonly int m_stop; #region Constructor diff --git a/src/Aardvark.Base/Extensions/UnsafeCoerce.cs b/src/Aardvark.Base/Extensions/UnsafeCoerce.cs index e76e365c8..b592a006d 100644 --- a/src/Aardvark.Base/Extensions/UnsafeCoerce.cs +++ b/src/Aardvark.Base/Extensions/UnsafeCoerce.cs @@ -18,7 +18,7 @@ public static IntPtr GetTypeIdUncached() return typeId; } - private static FastConcurrentDict s_typeIds = new FastConcurrentDict(); + private static readonly FastConcurrentDict s_typeIds = new FastConcurrentDict(); [Obsolete("breaks net8.0+")] private static IntPtr GetTypeId() diff --git a/src/Aardvark.Base/Geodesy/GeoConsts.cs b/src/Aardvark.Base/Geodesy/GeoConsts.cs index b4c78ef88..2275489d9 100644 --- a/src/Aardvark.Base/Geodesy/GeoConsts.cs +++ b/src/Aardvark.Base/Geodesy/GeoConsts.cs @@ -5,14 +5,14 @@ /// public class GeoDatum { - private double m_dx; - private double m_dy; - private double m_dz; - - private double m_rx; - private double m_ry; - private double m_rz; - private double m_ds; + private readonly double m_dx; + private readonly double m_dy; + private readonly double m_dz; + + private readonly double m_rx; + private readonly double m_ry; + private readonly double m_rz; + private readonly double m_ds; /// /// Constructs geodetic datum. diff --git a/src/Aardvark.Base/Geometry/Types/Geometry_auto.cs b/src/Aardvark.Base/Geometry/Types/Geometry_auto.cs index 5efc6124f..4998253c1 100644 --- a/src/Aardvark.Base/Geometry/Types/Geometry_auto.cs +++ b/src/Aardvark.Base/Geometry/Types/Geometry_auto.cs @@ -1038,12 +1038,12 @@ public static Polygon2f ConvexClipped( #region IndexPolygon2f [StructLayout(LayoutKind.Sequential)] - public partial struct IndexPolygon2f : IValidity, IPolygon + public readonly partial struct IndexPolygon2f : IValidity, IPolygon { - private int m_pointCount; - private int m_firstIndex; - private int[] m_indexArray; - private V2f[] m_pointArray; + private readonly int m_pointCount; + private readonly int m_firstIndex; + private readonly int[] m_indexArray; + private readonly V2f[] m_pointArray; #region Constructors @@ -4516,12 +4516,12 @@ public static Polygon3f ConvexClipped( #region IndexPolygon3f [StructLayout(LayoutKind.Sequential)] - public partial struct IndexPolygon3f : IValidity, IPolygon + public readonly partial struct IndexPolygon3f : IValidity, IPolygon { - private int m_pointCount; - private int m_firstIndex; - private int[] m_indexArray; - private V3f[] m_pointArray; + private readonly int m_pointCount; + private readonly int m_firstIndex; + private readonly int[] m_indexArray; + private readonly V3f[] m_pointArray; #region Constructors @@ -7993,12 +7993,12 @@ public static Polygon2d ConvexClipped( #region IndexPolygon2d [StructLayout(LayoutKind.Sequential)] - public partial struct IndexPolygon2d : IValidity, IPolygon + public readonly partial struct IndexPolygon2d : IValidity, IPolygon { - private int m_pointCount; - private int m_firstIndex; - private int[] m_indexArray; - private V2d[] m_pointArray; + private readonly int m_pointCount; + private readonly int m_firstIndex; + private readonly int[] m_indexArray; + private readonly V2d[] m_pointArray; #region Constructors @@ -11471,12 +11471,12 @@ public static Polygon3d ConvexClipped( #region IndexPolygon3d [StructLayout(LayoutKind.Sequential)] - public partial struct IndexPolygon3d : IValidity, IPolygon + public readonly partial struct IndexPolygon3d : IValidity, IPolygon { - private int m_pointCount; - private int m_firstIndex; - private int[] m_indexArray; - private V3d[] m_pointArray; + private readonly int m_pointCount; + private readonly int m_firstIndex; + private readonly int[] m_indexArray; + private readonly V3d[] m_pointArray; #region Constructors diff --git a/src/Aardvark.Base/Geometry/Types/Geometry_template.cs b/src/Aardvark.Base/Geometry/Types/Geometry_template.cs index 4da7f655a..a6f519868 100644 --- a/src/Aardvark.Base/Geometry/Types/Geometry_template.cs +++ b/src/Aardvark.Base/Geometry/Types/Geometry_template.cs @@ -500,12 +500,12 @@ public static bool ApproximateEquals(this __type__ a, __type__ b) #region __indextype__ [StructLayout(LayoutKind.Sequential)] - public partial struct __indextype__ : IValidity, IPolygon<__tvec__> + public readonly partial struct __indextype__ : IValidity, IPolygon<__tvec__> { - private int m_pointCount; - private int m_firstIndex; - private int[] m_indexArray; - private __tvec__[] m_pointArray; + private readonly int m_pointCount; + private readonly int m_firstIndex; + private readonly int[] m_indexArray; + private readonly __tvec__[] m_pointArray; #region Constructors diff --git a/src/Aardvark.Base/Geometry/Types/Polygon/ImmutablePolygon.cs b/src/Aardvark.Base/Geometry/Types/Polygon/ImmutablePolygon.cs index ed3858381..23ae57123 100644 --- a/src/Aardvark.Base/Geometry/Types/Polygon/ImmutablePolygon.cs +++ b/src/Aardvark.Base/Geometry/Types/Polygon/ImmutablePolygon.cs @@ -19,7 +19,7 @@ public class ImmutablePolygon: IImmutablePolygon /// /// Vertices. /// - private ImmutableList m_ps = ImmutableList.Empty; + private readonly ImmutableList m_ps = ImmutableList.Empty; /// /// Creates an immutable polygon from given outline. diff --git a/src/Aardvark.Base/Introspection/Introspection.cs b/src/Aardvark.Base/Introspection/Introspection.cs index bb7c40d56..89f5a92e0 100644 --- a/src/Aardvark.Base/Introspection/Introspection.cs +++ b/src/Aardvark.Base/Introspection/Introspection.cs @@ -141,7 +141,7 @@ public static class IntrospectionProperties : null ; - private static HashSet s_defaultAssemblyBlacklist = + private static readonly HashSet s_defaultAssemblyBlacklist = new HashSet( new[] { @@ -277,10 +277,10 @@ public static bool AssemblyFilter(string name) public static class Introspection { - private static CultureInfo s_cultureInfoEnUs = new CultureInfo("en-us"); - private static Dictionary s_assemblies; - private static HashSet s_assembliesThatFailedToLoad = new HashSet(); - private static HashSet s_allAssemblies = new HashSet(); + private static readonly CultureInfo s_cultureInfoEnUs = new CultureInfo("en-us"); + private static readonly Dictionary s_assemblies; + private static readonly HashSet s_assembliesThatFailedToLoad = new HashSet(); + private static readonly HashSet s_allAssemblies = new HashSet(); private static string InitializeCacheDirectory() { @@ -294,7 +294,7 @@ private static string InitializeCacheDirectory() return path; } - private static Lazy s_cacheDirectory = new Lazy(InitializeCacheDirectory); + private static readonly Lazy s_cacheDirectory = new Lazy(InitializeCacheDirectory); /// /// Returns the directory of the introspection cache files. @@ -1084,8 +1084,8 @@ public static List LoadPlugins() private static class LdConfig { - static Regex rx = new Regex(@"[ \t]*(?[^ \t]+)[ \t]+\((?[^,]+)\,(?[^,\)]+)[^\)]*\)[ \t]*\=\>[ \t]*(?.*)"); - static Dictionary result = new Dictionary(); + static readonly Regex rx = new Regex(@"[ \t]*(?[^ \t]+)[ \t]+\((?[^,]+)\,(?[^,\)]+)[^\)]*\)[ \t]*\=\>[ \t]*(?.*)"); + static readonly Dictionary result = new Dictionary(); static bool loaded = false; static void Load() @@ -1470,9 +1470,9 @@ public static void UnpackNativeDependencies(Assembly a) UnpackNativeDependenciesToBaseDir(a,baseDir); } - private static Regex soRx = new Regex(@"\.so(\.[0-9\-]+)?$"); - private static Regex dllRx = new Regex(@"\.(dll|exe)$"); - private static Regex dylibRx = new Regex(@"\.dylib$"); + private static readonly Regex soRx = new Regex(@"\.so(\.[0-9\-]+)?$"); + 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 /// directory (depending on the configuration of SeparateLibraryDirectories). @@ -1488,7 +1488,7 @@ public static void UnpackNativeDependencies(Assembly a) /// NOTE: When using global shared NativeLibraryPath, SeparateLibraryDirectories should not be set to false, as this there might be version conflicts public static bool SeparateLibraryDirectories = true; - private static Dictionary s_nativePaths = new Dictionary(); + private static readonly Dictionary s_nativePaths = new Dictionary(); private static string[] s_allPaths = null; public static string[] GetNativeLibraryPaths() @@ -1547,7 +1547,7 @@ public static bool TryGetNativeLibraryPath(Assembly assembly, out string path) } } - private static Dictionary<(Assembly, string), string> s_cache = new Dictionary<(Assembly, string), string>(); + private static readonly Dictionary<(Assembly, string), string> s_cache = new Dictionary<(Assembly, string), string>(); public static IntPtr LoadLibrary(Assembly assembly, string nativeName) { diff --git a/src/Aardvark.Base/Math/Base/Constant.cs b/src/Aardvark.Base/Math/Base/Constant.cs index 40d99e6a7..e7bcfc929 100644 --- a/src/Aardvark.Base/Math/Base/Constant.cs +++ b/src/Aardvark.Base/Math/Base/Constant.cs @@ -43,7 +43,7 @@ public static class Constant /// public static readonly T NegativeTinyValue; - private static volatile float floatStore; + private static readonly float floatStore; static Constant() { diff --git a/src/Aardvark.Base/Math/Base/DistributionFunction.cs b/src/Aardvark.Base/Math/Base/DistributionFunction.cs index 464a9ca8f..4f0904f22 100644 --- a/src/Aardvark.Base/Math/Base/DistributionFunction.cs +++ b/src/Aardvark.Base/Math/Base/DistributionFunction.cs @@ -9,8 +9,8 @@ namespace Aardvark.Base /// public class DistributionFunction { - double[] m_pdf; - double[] m_cdf; + readonly double[] m_pdf; + readonly double[] m_cdf; /// /// Gets the input probability density function. diff --git a/src/Aardvark.Base/Math/Base/MedianWindow.cs b/src/Aardvark.Base/Math/Base/MedianWindow.cs index 60f5d7d61..e9c51a57d 100644 --- a/src/Aardvark.Base/Math/Base/MedianWindow.cs +++ b/src/Aardvark.Base/Math/Base/MedianWindow.cs @@ -13,8 +13,8 @@ public class MedianWindow double m_median = 0; int m_write = -1; int m_count = 0; // for case when buffer is not fully filled - double[] m_buffer; - int[] m_indices; + readonly double[] m_buffer; + readonly int[] m_indices; public MedianWindow(int count) { diff --git a/src/Aardvark.Base/Math/Base/Statistics.cs b/src/Aardvark.Base/Math/Base/Statistics.cs index 95659a91e..0fd4da241 100644 --- a/src/Aardvark.Base/Math/Base/Statistics.cs +++ b/src/Aardvark.Base/Math/Base/Statistics.cs @@ -110,7 +110,7 @@ public struct Stats : IReportable { long m_count; KahanSum m_sum; - StatsOptions m_options; + readonly StatsOptions m_options; Extremum m_min; Extremum m_max; KahanSum m_sumOfSquares; @@ -262,11 +262,11 @@ public class StatsClass public struct Histogram : IReportable { private Range1d m_slotRange; - private double m_scale; + private readonly double m_scale; private long m_small; private long m_large; private Range1d m_dataRange; - private long[] m_histo; + private readonly long[] m_histo; #region Constructor diff --git a/src/Aardvark.Base/Math/Colors/Color.cs b/src/Aardvark.Base/Math/Colors/Color.cs index e2b404de1..f1d599161 100644 --- a/src/Aardvark.Base/Math/Colors/Color.cs +++ b/src/Aardvark.Base/Math/Colors/Color.cs @@ -243,10 +243,10 @@ static Col() } } - private static Dict s_nameOfFormat = null; - private static SymbolDict s_formatOfName = null; - private static Dict s_intentOfFormat = null; - private static Dict s_channelCountMap = null; + private static readonly Dict s_nameOfFormat = null; + private static readonly SymbolDict s_formatOfName = null; + private static readonly Dict s_intentOfFormat = null; + private static readonly Dict s_channelCountMap = null; public static Symbol GetName(this Format format) { diff --git a/src/Aardvark.Base/Math/Curves/Curves.cs b/src/Aardvark.Base/Math/Curves/Curves.cs index 3bb0911dc..e5d17fd50 100644 --- a/src/Aardvark.Base/Math/Curves/Curves.cs +++ b/src/Aardvark.Base/Math/Curves/Curves.cs @@ -395,8 +395,8 @@ private static (V3d, V3d) Tangents( public class CurvePoints { - private double[] m_params; - private T[] m_items; + private readonly double[] m_params; + private readonly T[] m_items; private Range1i m_indexes; public CurvePoints(double[] parameters, T[] items) diff --git a/src/Aardvark.Base/Math/Vectors/V3fCoder.cs b/src/Aardvark.Base/Math/Vectors/V3fCoder.cs index 05eb4d2af..4addcc54d 100644 --- a/src/Aardvark.Base/Math/Vectors/V3fCoder.cs +++ b/src/Aardvark.Base/Math/Vectors/V3fCoder.cs @@ -17,15 +17,15 @@ namespace Aardvark.Base public class V3fCoder { // private uint m_raster; - private uint m_r2Sub1; - private double m_doubleRaster; - private double m_invDoubleRaster; - private uint m_edgeBasis; - private uint m_cornerBasis; + private readonly uint m_r2Sub1; + private readonly double m_doubleRaster; + private readonly double m_invDoubleRaster; + private readonly uint m_edgeBasis; + private readonly uint m_cornerBasis; #if V3FCODER_DECODE_TABLE private double[] m_unWarpTable; #endif - private double m_dRp05; + private readonly double m_dRp05; #region Constructor @@ -158,7 +158,7 @@ has to be changed to 64-bit ints. const double c_piOver4 = Constant.Pi * 0.25; const double c_4OverPi = 4.0 / Constant.Pi; - private static V3fCoder[] s_coderForBits = + private static readonly V3fCoder[] s_coderForBits = new V3fCoder[33]; static V3fCoder() diff --git a/src/Aardvark.Base/Math/Vectors/VectorArrayExtensions.cs b/src/Aardvark.Base/Math/Vectors/VectorArrayExtensions.cs index 8f60824cb..cbab7654e 100644 --- a/src/Aardvark.Base/Math/Vectors/VectorArrayExtensions.cs +++ b/src/Aardvark.Base/Math/Vectors/VectorArrayExtensions.cs @@ -117,7 +117,7 @@ public static V4d Lerp(this V4d[] array, WeightedIndex[] wia) return result; } - static Dictionary, Array>> + static readonly Dictionary, Array>> s_backwardIndexedLerpMap = new Dictionary, Array>> { @@ -153,7 +153,7 @@ public static Array BackwardIndexedLerpCopy( } - static Dictionary, Array>> + static readonly Dictionary, Array>> s_backwardIndexedNormalMap = new Dictionary, Array>> { @@ -211,7 +211,7 @@ public static void CombineTo( } } - private static Dictionary, Array, int, int>> s_lerpToOffsetMap = new Dictionary, + private static readonly Dictionary, Array, int, int>> s_lerpAndNormalizeToOffsetMap = new Dictionary, Array, int, int>> { diff --git a/src/Aardvark.Base/Random/ForcedRandomSeries.cs b/src/Aardvark.Base/Random/ForcedRandomSeries.cs index 7253c54c4..086c53994 100644 --- a/src/Aardvark.Base/Random/ForcedRandomSeries.cs +++ b/src/Aardvark.Base/Random/ForcedRandomSeries.cs @@ -10,12 +10,12 @@ namespace Aardvark.Base public class ForcedRandomSeries : IRandomSeries { V2i m_index = V2i.OO; - V2i[] m_series; - int m_matrixSize; - double m_norm; - IRandomUniform m_rnd; + readonly V2i[] m_series; + readonly int m_matrixSize; + readonly double m_norm; + readonly IRandomUniform m_rnd; V2i m_seed; - bool m_jitter; + readonly bool m_jitter; /// /// Reads a file that contains a raw V2i binary array as V2i[]. diff --git a/src/Aardvark.Base/Random/HaltonRandomSeries.cs b/src/Aardvark.Base/Random/HaltonRandomSeries.cs index edb111c8f..ab425a9d8 100644 --- a/src/Aardvark.Base/Random/HaltonRandomSeries.cs +++ b/src/Aardvark.Base/Random/HaltonRandomSeries.cs @@ -28,7 +28,7 @@ public double UniformDouble(int seriesIndex) return m_randomUniform.UniformDouble(); } - private double [] m_haltonStateArray; - private IRandomUniform m_randomUniform; + private readonly double [] m_haltonStateArray; + private readonly IRandomUniform m_randomUniform; } } diff --git a/src/Aardvark.Base/Random/PerlinNoise.cs b/src/Aardvark.Base/Random/PerlinNoise.cs index 68d0fea7b..5486b7fce 100644 --- a/src/Aardvark.Base/Random/PerlinNoise.cs +++ b/src/Aardvark.Base/Random/PerlinNoise.cs @@ -8,15 +8,15 @@ namespace Aardvark.Base /// public class PerlinNoise { - private int m_PrimeOne; - private int m_PrimeTwo; - private int m_PrimeThree; + private readonly int m_PrimeOne; + private readonly int m_PrimeTwo; + private readonly int m_PrimeThree; private int m_maxX; private int m_maxY; // private int m_maxZ; float[] m_lookup; - private Func m_interpolate; + private readonly Func m_interpolate; #region Constructors /// diff --git a/src/Aardvark.Base/Random/Prime.cs b/src/Aardvark.Base/Random/Prime.cs index 69992898b..02f6e9084 100644 --- a/src/Aardvark.Base/Random/Prime.cs +++ b/src/Aardvark.Base/Random/Prime.cs @@ -134,7 +134,7 @@ static Prime() private static int primeCapacity; private static int[] primeArray = new int[c_initialPrimeCount]; private static double[] primeInverseArray = new double[c_initialPrimeCount]; - private static bool[] isPrimeArray; - private static int[] primeLogIndexArray = new int[64]; + private static readonly bool[] isPrimeArray; + private static readonly int[] primeLogIndexArray = new int[64]; } } diff --git a/src/Aardvark.Base/Random/PseudoRandomSeries.cs b/src/Aardvark.Base/Random/PseudoRandomSeries.cs index 794e39220..d1db6537d 100644 --- a/src/Aardvark.Base/Random/PseudoRandomSeries.cs +++ b/src/Aardvark.Base/Random/PseudoRandomSeries.cs @@ -10,7 +10,7 @@ namespace Aardvark.Base /// public class PseudoRandomSeries : IRandomSeries { - IRandomUniform m_rnd; + readonly IRandomUniform m_rnd; public PseudoRandomSeries(IRandomUniform rnd) { diff --git a/src/Aardvark.Base/Random/RandomDistributions.cs b/src/Aardvark.Base/Random/RandomDistributions.cs index 1488483bc..172f3b69c 100644 --- a/src/Aardvark.Base/Random/RandomDistributions.cs +++ b/src/Aardvark.Base/Random/RandomDistributions.cs @@ -9,7 +9,7 @@ namespace Aardvark.Base /// public class RandomGaussian : IRandomDistribution { - private IRandomUniform m_rndUniform; + private readonly IRandomUniform m_rndUniform; private double m_cachedValue; public RandomGaussian(IRandomUniform rndUniform) diff --git a/src/Aardvark.Base/Reporting/FilterLogTarget.cs b/src/Aardvark.Base/Reporting/FilterLogTarget.cs index aeabc7825..48a696e16 100644 --- a/src/Aardvark.Base/Reporting/FilterLogTarget.cs +++ b/src/Aardvark.Base/Reporting/FilterLogTarget.cs @@ -8,8 +8,8 @@ namespace Aardvark.Base /// public class FilterLogTarget : ILogTarget { - private ILogTarget m_target; - private Func m_filterFun; + private readonly ILogTarget m_target; + private readonly Func m_filterFun; public FilterLogTarget(ILogTarget target, Func filterFun) { diff --git a/src/Aardvark.Base/Reporting/JobReporter.cs b/src/Aardvark.Base/Reporting/JobReporter.cs index fd989b1db..f070bc19f 100644 --- a/src/Aardvark.Base/Reporting/JobReporter.cs +++ b/src/Aardvark.Base/Reporting/JobReporter.cs @@ -6,12 +6,12 @@ namespace Aardvark.Base { public class JobReporter : IJobReporter { - private int m_ti; + private readonly int m_ti; public int m_indent; private ReportJob m_job; - private Stack m_jobStack; + private readonly Stack m_jobStack; private volatile IReporter[] m_reporterArray; - private object m_reporterArrayLock; + private readonly object m_reporterArrayLock; #region Constructor diff --git a/src/Aardvark.Base/Reporting/MultiLogTarget.cs b/src/Aardvark.Base/Reporting/MultiLogTarget.cs index 7236c1fce..4d2139748 100644 --- a/src/Aardvark.Base/Reporting/MultiLogTarget.cs +++ b/src/Aardvark.Base/Reporting/MultiLogTarget.cs @@ -3,7 +3,7 @@ public class MultiLogTarget : ILogTarget { private volatile ILogTarget[] m_targetArray; - private object m_targetArrayLock; + private readonly object m_targetArrayLock; #region Constructor diff --git a/src/Aardvark.Base/Reporting/PerThreadJobReporter.cs b/src/Aardvark.Base/Reporting/PerThreadJobReporter.cs index fc21fe943..1e078f94d 100644 --- a/src/Aardvark.Base/Reporting/PerThreadJobReporter.cs +++ b/src/Aardvark.Base/Reporting/PerThreadJobReporter.cs @@ -6,7 +6,7 @@ namespace Aardvark.Base public class PerThreadJobReporter : IJobReporter { private SpinLock m_lock; - private volatile Dictionary m_reporterMap; + private readonly Dictionary m_reporterMap; private volatile int m_threadCount; private int m_indent; diff --git a/src/Aardvark.Base/Reporting/PerThreadLogTarget.cs b/src/Aardvark.Base/Reporting/PerThreadLogTarget.cs index 6307e4280..9775877c6 100644 --- a/src/Aardvark.Base/Reporting/PerThreadLogTarget.cs +++ b/src/Aardvark.Base/Reporting/PerThreadLogTarget.cs @@ -5,7 +5,7 @@ namespace Aardvark.Base public class PerThreadLogTarget : ILogTarget { private volatile ILogTarget[] m_targetArray; - Func m_targetCreator; + readonly Func m_targetCreator; #region Constructor diff --git a/src/Aardvark.Base/Reporting/Report.cs b/src/Aardvark.Base/Reporting/Report.cs index b662d63b9..b542ba7f1 100644 --- a/src/Aardvark.Base/Reporting/Report.cs +++ b/src/Aardvark.Base/Reporting/Report.cs @@ -128,9 +128,9 @@ public static void ConsoleWriteAct(int threadIndex, LogType type, int level, str Console.Write(message); Console.Out.Flush(); } - private static bool s_coloredConsole; - private static ConsoleColor s_defaultForeground; - private static ConsoleColor s_defaultBackground; + private static readonly bool s_coloredConsole; + private static readonly ConsoleColor s_defaultForeground; + private static readonly ConsoleColor s_defaultBackground; #if !__ANDROID__ diff --git a/src/Aardvark.Base/Reporting/Skipper.cs b/src/Aardvark.Base/Reporting/Skipper.cs index 698e3f1da..a94263f6f 100644 --- a/src/Aardvark.Base/Reporting/Skipper.cs +++ b/src/Aardvark.Base/Reporting/Skipper.cs @@ -8,7 +8,7 @@ public struct Skipper { int m_count; - int m_limit; + readonly int m_limit; #region Constructor diff --git a/src/Aardvark.Base/Reporting/TextLogTarget.cs b/src/Aardvark.Base/Reporting/TextLogTarget.cs index 4777e346f..503ba1bf6 100644 --- a/src/Aardvark.Base/Reporting/TextLogTarget.cs +++ b/src/Aardvark.Base/Reporting/TextLogTarget.cs @@ -7,9 +7,9 @@ namespace Aardvark.Base { public class TextLogTarget : ILogTarget { - private object m_lock; + private readonly object m_lock; private ReportState m_state; - private Dictionary m_stateTable; + private readonly Dictionary m_stateTable; public Action WriteAct; private int m_width = 80; private int m_maxIndent = 40; diff --git a/src/Aardvark.Base/Sorting/Sorting_auto.cs b/src/Aardvark.Base/Sorting/Sorting_auto.cs index 306a2fa0e..b87950747 100644 --- a/src/Aardvark.Base/Sorting/Sorting_auto.cs +++ b/src/Aardvark.Base/Sorting/Sorting_auto.cs @@ -130251,7 +130251,7 @@ private static int TrailingZeroBitCount(this long x) /// /// Int Leonardo numbers (smooth sort). /// - private static int[] LP = + private static readonly int[] LP = { 1, 1, 3, 5, 9, 15, 25, 41, 67, 109, 177, 287, 465, 753, 1219, 1973, 3193, 5167, 8361, 13529, 21891, 35421, 57313, 92735, @@ -130264,7 +130264,7 @@ private static int TrailingZeroBitCount(this long x) /// /// Long Leonardo numbers (smooth sort). /// - private static long[] LPLong = + private static readonly long[] LPLong = { 1, 1, 3, 5, 9, 15, 25, 41, 67, 109, 177, 287, 465, 753, 1219, 1973, 3193, 5167, 8361, 13529, 21891, 35421, 57313, 92735, diff --git a/src/Aardvark.Base/Sorting/Sorting_template.cs b/src/Aardvark.Base/Sorting/Sorting_template.cs index 382679cda..6b56cdb24 100644 --- a/src/Aardvark.Base/Sorting/Sorting_template.cs +++ b/src/Aardvark.Base/Sorting/Sorting_template.cs @@ -1417,7 +1417,7 @@ private static int TrailingZeroBitCount(this long x) /// /// Int Leonardo numbers (smooth sort). /// - private static int[] LP = + private static readonly int[] LP = { 1, 1, 3, 5, 9, 15, 25, 41, 67, 109, 177, 287, 465, 753, 1219, 1973, 3193, 5167, 8361, 13529, 21891, 35421, 57313, 92735, @@ -1430,7 +1430,7 @@ private static int TrailingZeroBitCount(this long x) /// /// Long Leonardo numbers (smooth sort). /// - private static long[] LPLong = + private static readonly long[] LPLong = { 1, 1, 3, 5, 9, 15, 25, 41, 67, 109, 177, 287, 465, 753, 1219, 1973, 3193, 5167, 8361, 13529, 21891, 35421, 57313, 92735, diff --git a/src/Aardvark.Base/Symbol/Dict_auto.cs b/src/Aardvark.Base/Symbol/Dict_auto.cs index c71ae3563..f5377a048 100644 --- a/src/Aardvark.Base/Symbol/Dict_auto.cs +++ b/src/Aardvark.Base/Symbol/Dict_auto.cs @@ -30,7 +30,7 @@ public class Dict private uint m_count; private uint m_increaseThreshold; private uint m_decreaseThreshold; - private bool m_doNotStackDuplicateKeys; + private readonly bool m_doNotStackDuplicateKeys; private int m_freeIndex; private int m_capacityIndex; private uint m_extraCount; @@ -1150,9 +1150,9 @@ public ValuesWithKeyEnumerator GetValuesWithKeyEnumerator(TKey key) public struct ValuesWithKeyEnumerator : IEnumerator { - Dict m_dict; - TKey m_key; - int m_hash; + readonly Dict m_dict; + readonly TKey m_key; + readonly int m_hash; int m_extraIndex; TValue m_current; @@ -1729,7 +1729,7 @@ IEnumerator IEnumerable.GetEnumerator() public struct Enumerator : IEnumerator> { - Dict m_dict; + readonly Dict m_dict; int m_index; int m_extraIndex; KeyValuePair m_current; @@ -2691,7 +2691,7 @@ IEnumerator IEnumerable.GetEnumerator() public struct Enumerator : IEnumerator { - DictSet m_dict; + readonly DictSet m_dict; int m_index; int m_extraIndex; TKey m_current; @@ -2949,7 +2949,7 @@ public class IntDict private uint m_count; private uint m_increaseThreshold; private uint m_decreaseThreshold; - private bool m_doNotStackDuplicateKeys; + private readonly bool m_doNotStackDuplicateKeys; private int m_freeIndex; private int m_capacityIndex; private uint m_extraCount; @@ -3717,8 +3717,8 @@ public ValuesWithKeyEnumerator GetValuesWithKeyEnumerator(int key) public struct ValuesWithKeyEnumerator : IEnumerator { - IntDict m_dict; - int m_hash; + readonly IntDict m_dict; + readonly int m_hash; int m_extraIndex; TValue m_current; @@ -4128,7 +4128,7 @@ IEnumerator IEnumerable.GetEnumerator() public struct Enumerator : IEnumerator> { - IntDict m_dict; + readonly IntDict m_dict; int m_index; int m_extraIndex; KeyValuePair m_current; @@ -4875,7 +4875,7 @@ IEnumerator IEnumerable.GetEnumerator() public struct Enumerator : IEnumerator { - IntSet m_dict; + readonly IntSet m_dict; int m_index; int m_extraIndex; int m_current; @@ -5133,7 +5133,7 @@ public class SymbolDict private uint m_count; private uint m_increaseThreshold; private uint m_decreaseThreshold; - private bool m_doNotStackDuplicateKeys; + private readonly bool m_doNotStackDuplicateKeys; private int m_freeIndex; private int m_capacityIndex; private uint m_extraCount; @@ -5934,8 +5934,8 @@ public ValuesWithKeyEnumerator GetValuesWithKeyEnumerator(Symbol key) public struct ValuesWithKeyEnumerator : IEnumerator { - SymbolDict m_dict; - int m_hash; + readonly SymbolDict m_dict; + readonly int m_hash; int m_extraIndex; TValue m_current; @@ -6428,7 +6428,7 @@ IEnumerator IEnumerable.GetEnumerator() public struct Enumerator : IEnumerator> { - SymbolDict m_dict; + readonly SymbolDict m_dict; int m_index; int m_extraIndex; KeyValuePair m_current; @@ -7195,7 +7195,7 @@ IEnumerator IEnumerable.GetEnumerator() public struct Enumerator : IEnumerator { - SymbolSet m_dict; + readonly SymbolSet m_dict; int m_index; int m_extraIndex; Symbol m_current; @@ -7446,14 +7446,14 @@ public class BigDict : ICountableDict, IDict, IEnumerable, IEnumerable> { - private Func m_hfun; + private readonly Func m_hfun; private ulong m_capacity; private NextHashKeyValueLong[] m_firstArray; private HashKeyValueNextLong[] m_extraArray; private ulong m_count; private ulong m_increaseThreshold; private ulong m_decreaseThreshold; - private bool m_doNotStackDuplicateKeys; + private readonly bool m_doNotStackDuplicateKeys; private long m_freeIndex; private int m_capacityIndex; private ulong m_extraCount; @@ -8563,9 +8563,9 @@ public ValuesWithKeyEnumerator GetValuesWithKeyEnumerator(TKey key) public struct ValuesWithKeyEnumerator : IEnumerator { - BigDict m_dict; - TKey m_key; - long m_hash; + readonly BigDict m_dict; + readonly TKey m_key; + readonly long m_hash; long m_extraIndex; TValue m_current; @@ -9142,7 +9142,7 @@ IEnumerator IEnumerable.GetEnumerator() public struct Enumerator : IEnumerator> { - BigDict m_dict; + readonly BigDict m_dict; long m_index; long m_extraIndex; KeyValuePair m_current; @@ -9392,7 +9392,7 @@ public class BigDictSet : ICountableDictSet, IDictSet, IEnumerable, IEnumerable { - private Func m_hfun; + private readonly Func m_hfun; private ulong m_capacity; private NextHashKeyLong[] m_firstArray; private HashKeyNextLong[] m_extraArray; @@ -10089,7 +10089,7 @@ IEnumerator IEnumerable.GetEnumerator() public struct Enumerator : IEnumerator { - BigDictSet m_dict; + readonly BigDictSet m_dict; long m_index; long m_extraIndex; TKey m_current; @@ -10346,7 +10346,7 @@ public class LongDict private ulong m_count; private ulong m_increaseThreshold; private ulong m_decreaseThreshold; - private bool m_doNotStackDuplicateKeys; + private readonly bool m_doNotStackDuplicateKeys; private long m_freeIndex; private int m_capacityIndex; private ulong m_extraCount; @@ -11103,8 +11103,8 @@ public ValuesWithKeyEnumerator GetValuesWithKeyEnumerator(long key) public struct ValuesWithKeyEnumerator : IEnumerator { - LongDict m_dict; - long m_hash; + readonly LongDict m_dict; + readonly long m_hash; long m_extraIndex; TValue m_current; @@ -11514,7 +11514,7 @@ IEnumerator IEnumerable.GetEnumerator() public struct Enumerator : IEnumerator> { - LongDict m_dict; + readonly LongDict m_dict; long m_index; long m_extraIndex; KeyValuePair m_current; @@ -12244,7 +12244,7 @@ IEnumerator IEnumerable.GetEnumerator() public struct Enumerator : IEnumerator { - LongSet m_dict; + readonly LongSet m_dict; long m_index; long m_extraIndex; long m_current; @@ -12493,7 +12493,7 @@ private void ReportStats( /// public class ConcurrentDict { - private Dict m_dict; + private readonly Dict m_dict; #region Constructors @@ -13099,7 +13099,7 @@ public void CopyTo(KeyValuePair[] array, int index) /// public class ConcurrentDictSet { - private DictSet m_dict; + private readonly DictSet m_dict; #region Constructors @@ -13358,7 +13358,7 @@ public void CopyTo(TKey[] array, int index) /// public class ConcurrentIntDict { - private IntDict m_dict; + private readonly IntDict m_dict; #region Constructors @@ -13800,7 +13800,7 @@ public void CopyTo(KeyValuePair[] array, int index) /// public class ConcurrentIntSet { - private IntSet m_dict; + private readonly IntSet m_dict; #region Constructors @@ -13997,7 +13997,7 @@ public void CopyTo(int[] array, int index) /// public class ConcurrentSymbolDict { - private SymbolDict m_dict; + private readonly SymbolDict m_dict; #region Constructors @@ -14548,7 +14548,7 @@ public TType GetAsOrDefault(Symbol key) /// public class ConcurrentSymbolSet { - private SymbolSet m_dict; + private readonly SymbolSet m_dict; #region Constructors @@ -14758,7 +14758,7 @@ public void CopyTo(Symbol[] array, int index) /// public class ConcurrentBigDict { - private BigDict m_dict; + private readonly BigDict m_dict; #region Constructors @@ -15353,7 +15353,7 @@ public void CopyTo(KeyValuePair[] array, long index) /// public class ConcurrentBigDictSet { - private BigDictSet m_dict; + private readonly BigDictSet m_dict; #region Constructors @@ -15601,7 +15601,7 @@ public void CopyTo(TKey[] array, long index) /// public class ConcurrentLongDict { - private LongDict m_dict; + private readonly LongDict m_dict; #region Constructors @@ -16032,7 +16032,7 @@ public void CopyTo(KeyValuePair[] array, long index) /// public class ConcurrentLongSet { - private LongSet m_dict; + private readonly LongSet m_dict; #region Constructors @@ -16227,7 +16227,7 @@ public class FastConcurrentDict private uint m_count; private uint m_increaseThreshold; private uint m_decreaseThreshold; - private bool m_doNotStackDuplicateKeys; + private readonly bool m_doNotStackDuplicateKeys; private int m_freeIndex; private int m_capacityIndex; private uint m_extraCount; @@ -19090,7 +19090,7 @@ public class FastConcurrentIntDict private uint m_count; private uint m_increaseThreshold; private uint m_decreaseThreshold; - private bool m_doNotStackDuplicateKeys; + private readonly bool m_doNotStackDuplicateKeys; private int m_freeIndex; private int m_capacityIndex; private uint m_extraCount; @@ -21173,7 +21173,7 @@ public class FastConcurrentSymbolDict private uint m_count; private uint m_increaseThreshold; private uint m_decreaseThreshold; - private bool m_doNotStackDuplicateKeys; + private readonly bool m_doNotStackDuplicateKeys; private int m_freeIndex; private int m_capacityIndex; private uint m_extraCount; @@ -23386,14 +23386,14 @@ public class FastConcurrentBigDict IEnumerable, IEnumerable> { private long m_version; - private Func m_hfun; + private readonly Func m_hfun; private ulong m_capacity; private NextHashKeyValueLong[] m_firstArray; private HashKeyValueNextLong[] m_extraArray; private ulong m_count; private ulong m_increaseThreshold; private ulong m_decreaseThreshold; - private bool m_doNotStackDuplicateKeys; + private readonly bool m_doNotStackDuplicateKeys; private long m_freeIndex; private int m_capacityIndex; private ulong m_extraCount; @@ -25322,7 +25322,7 @@ public class FastConcurrentBigDictSet IEnumerable, IEnumerable { private long m_version; - private Func m_hfun; + private readonly Func m_hfun; private ulong m_capacity; private NextHashKeyLong[] m_firstArray; private HashKeyNextLong[] m_extraArray; @@ -26237,7 +26237,7 @@ public class FastConcurrentLongDict private ulong m_count; private ulong m_increaseThreshold; private ulong m_decreaseThreshold; - private bool m_doNotStackDuplicateKeys; + private readonly bool m_doNotStackDuplicateKeys; private long m_freeIndex; private int m_capacityIndex; private ulong m_extraCount; @@ -28299,7 +28299,7 @@ public class DictIEq private uint m_count; private uint m_increaseThreshold; private uint m_decreaseThreshold; - private bool m_doNotStackDuplicateKeys; + private readonly bool m_doNotStackDuplicateKeys; private int m_freeIndex; private int m_capacityIndex; private uint m_extraCount; @@ -29419,9 +29419,9 @@ public ValuesWithKeyEnumerator GetValuesWithKeyEnumerator(TKey key) public struct ValuesWithKeyEnumerator : IEnumerator { - DictIEq m_dict; - TKey m_key; - int m_hash; + readonly DictIEq m_dict; + readonly TKey m_key; + readonly int m_hash; int m_extraIndex; TValue m_current; @@ -29998,7 +29998,7 @@ IEnumerator IEnumerable.GetEnumerator() public struct Enumerator : IEnumerator> { - DictIEq m_dict; + readonly DictIEq m_dict; int m_index; int m_extraIndex; KeyValuePair m_current; @@ -30961,7 +30961,7 @@ IEnumerator IEnumerable.GetEnumerator() public struct Enumerator : IEnumerator { - DictSetIEq m_dict; + readonly DictSetIEq m_dict; int m_index; int m_extraIndex; TKey m_current; @@ -31213,14 +31213,14 @@ public class BigDictIEq IEnumerable, IEnumerable> where TKey : IEquatable { - private Func m_hfun; + private readonly Func m_hfun; private ulong m_capacity; private NextHashKeyValueLong[] m_firstArray; private HashKeyValueNextLong[] m_extraArray; private ulong m_count; private ulong m_increaseThreshold; private ulong m_decreaseThreshold; - private bool m_doNotStackDuplicateKeys; + private readonly bool m_doNotStackDuplicateKeys; private long m_freeIndex; private int m_capacityIndex; private ulong m_extraCount; @@ -32330,9 +32330,9 @@ public ValuesWithKeyEnumerator GetValuesWithKeyEnumerator(TKey key) public struct ValuesWithKeyEnumerator : IEnumerator { - BigDictIEq m_dict; - TKey m_key; - long m_hash; + readonly BigDictIEq m_dict; + readonly TKey m_key; + readonly long m_hash; long m_extraIndex; TValue m_current; @@ -32909,7 +32909,7 @@ IEnumerator IEnumerable.GetEnumerator() public struct Enumerator : IEnumerator> { - BigDictIEq m_dict; + readonly BigDictIEq m_dict; long m_index; long m_extraIndex; KeyValuePair m_current; @@ -33160,7 +33160,7 @@ public class BigDictSetIEq IEnumerable, IEnumerable where TKey : IEquatable { - private Func m_hfun; + private readonly Func m_hfun; private ulong m_capacity; private NextHashKeyLong[] m_firstArray; private HashKeyNextLong[] m_extraArray; @@ -33857,7 +33857,7 @@ IEnumerator IEnumerable.GetEnumerator() public struct Enumerator : IEnumerator { - BigDictSetIEq m_dict; + readonly BigDictSetIEq m_dict; long m_index; long m_extraIndex; TKey m_current; @@ -34107,7 +34107,7 @@ private void ReportStats( public class ConcurrentDictIEq where TKey : IEquatable { - private DictIEq m_dict; + private readonly DictIEq m_dict; #region Constructors @@ -34714,7 +34714,7 @@ public void CopyTo(KeyValuePair[] array, int index) public class ConcurrentDictSetIEq where TKey : IEquatable { - private DictSetIEq m_dict; + private readonly DictSetIEq m_dict; #region Constructors @@ -34974,7 +34974,7 @@ public void CopyTo(TKey[] array, int index) public class ConcurrentBigDictIEq where TKey : IEquatable { - private BigDictIEq m_dict; + private readonly BigDictIEq m_dict; #region Constructors @@ -35570,7 +35570,7 @@ public void CopyTo(KeyValuePair[] array, long index) public class ConcurrentBigDictSetIEq where TKey : IEquatable { - private BigDictSetIEq m_dict; + private readonly BigDictSetIEq m_dict; #region Constructors @@ -35828,7 +35828,7 @@ public class FastConcurrentDictIEq private uint m_count; private uint m_increaseThreshold; private uint m_decreaseThreshold; - private bool m_doNotStackDuplicateKeys; + private readonly bool m_doNotStackDuplicateKeys; private int m_freeIndex; private int m_capacityIndex; private uint m_extraCount; @@ -38687,14 +38687,14 @@ public class FastConcurrentBigDictIEq where TKey : IEquatable { private long m_version; - private Func m_hfun; + private readonly Func m_hfun; private ulong m_capacity; private NextHashKeyValueLong[] m_firstArray; private HashKeyValueNextLong[] m_extraArray; private ulong m_count; private ulong m_increaseThreshold; private ulong m_decreaseThreshold; - private bool m_doNotStackDuplicateKeys; + private readonly bool m_doNotStackDuplicateKeys; private long m_freeIndex; private int m_capacityIndex; private ulong m_extraCount; @@ -40624,7 +40624,7 @@ public class FastConcurrentBigDictSetIEq where TKey : IEquatable { private long m_version; - private Func m_hfun; + private readonly Func m_hfun; private ulong m_capacity; private NextHashKeyLong[] m_firstArray; private HashKeyNextLong[] m_extraArray; diff --git a/src/Aardvark.Base/Symbol/Dict_template.cs b/src/Aardvark.Base/Symbol/Dict_template.cs index 852c2538e..0def72087 100644 --- a/src/Aardvark.Base/Symbol/Dict_template.cs +++ b/src/Aardvark.Base/Symbol/Dict_template.cs @@ -87,13 +87,13 @@ namespace Aardvark.Base //# } { //# if (wrapped) { - private __nctype____tpar__ m_dict; + private readonly __nctype____tpar__ m_dict; //# } else { // !wrapped //# if (concurrent) { private long m_version; //# } //# if (fun) { - private Func<__tkey__, __itype__> m_hfun; + private readonly Func<__tkey__, __itype__> m_hfun; //# } private __uitype__ m_capacity; private __NextHashItem__[] m_firstArray; @@ -102,7 +102,7 @@ namespace Aardvark.Base private __uitype__ m_increaseThreshold; private __uitype__ m_decreaseThreshold; //# if (hasValue) { - private bool m_doNotStackDuplicateKeys; + private readonly bool m_doNotStackDuplicateKeys; //# } private __itype__ m_freeIndex; private int m_capacityIndex; @@ -1285,9 +1285,9 @@ public ValuesWithKeyEnumerator GetValuesWithKeyEnumerator(__tkey__ key) public struct ValuesWithKeyEnumerator : IEnumerator { - __type__/*# if (isGeneric) { *//*# } */ m_dict;/*# if (hasKey) { */ - TKey m_key;/*# } */ - __itype__ m_hash; + readonly __type__/*# if (isGeneric) { *//*# } */ m_dict;/*# if (hasKey) { */ + readonly TKey m_key;/*# } */ + readonly __itype__ m_hash; __itype__ m_extraIndex; TValue m_current; @@ -1966,7 +1966,7 @@ IEnumerator IEnumerable.GetEnumerator() public struct Enumerator : IEnumerator/*# } */> { - __type__/*# if (isGeneric) { *//*# } */ m_dict; + readonly __type__/*# if (isGeneric) { *//*# } */ m_dict; __itype__ m_index; __itype__ m_extraIndex; /*# if (hasValue) { */KeyValuePair/*# } */ m_current; diff --git a/src/Aardvark.Base/Symbol/Dicts.cs b/src/Aardvark.Base/Symbol/Dicts.cs index 8a0567b2b..74020338a 100644 --- a/src/Aardvark.Base/Symbol/Dicts.cs +++ b/src/Aardvark.Base/Symbol/Dicts.cs @@ -9,7 +9,7 @@ namespace Aardvark.Base public class SingleEntryDict : IDict { - TKey m_key; + readonly TKey m_key; TValue m_value; #region Constructors @@ -81,8 +81,8 @@ public bool TryGetValue(TKey key, out TValue value) /// public class SingleValueDict : IDict, IEnumerable> { - private IDictSet m_keys; - private TValue m_value; + private readonly IDictSet m_keys; + private readonly TValue m_value; #region Constructors @@ -184,7 +184,7 @@ System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() /// public class UniversalDict : IDict { - private TValue m_value; + private readonly TValue m_value; #region Constructor @@ -255,7 +255,7 @@ public bool TryGetValue(TKey key, out TValue value) /// public class UnionDict : IDict, IEnumerable> { - List> m_dictList; + readonly List> m_dictList; #region Constructors @@ -506,9 +506,9 @@ System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() /// public class DeltaDict : IDict, IDictDepth, IEnumerable> { - IDict m_baseDict; - Dict m_deltaDict; - int m_depth; + readonly IDict m_baseDict; + readonly Dict m_deltaDict; + readonly int m_depth; #region Constructors @@ -620,8 +620,8 @@ System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() /// public class SingleValueSymbolDict : IDict, IEnumerable> { - private IDictSet m_keys; - private TValue m_value; + private readonly IDictSet m_keys; + private readonly TValue m_value; #region Constructors @@ -724,7 +724,7 @@ System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() /// public class UniversalSymbolDict : IDict { - private TValue m_value; + private readonly TValue m_value; #region Constructor @@ -795,7 +795,7 @@ public bool TryGetValue(Symbol key, out TValue value) /// public class UnionSymbolDict : IDict, IEnumerable> { - List> m_dictList; + readonly List> m_dictList; #region Constructors @@ -1044,8 +1044,8 @@ System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() /// public class DeltaSymbolDict : IDict, IEnumerable> { - IDict m_baseDict; - IDict m_deltaDict; + readonly IDict m_baseDict; + readonly IDict m_deltaDict; #region Constructors diff --git a/src/Aardvark.Base/Symbol/SymMapBaseTraversal.cs b/src/Aardvark.Base/Symbol/SymMapBaseTraversal.cs index 280556997..0cbe9ead4 100644 --- a/src/Aardvark.Base/Symbol/SymMapBaseTraversal.cs +++ b/src/Aardvark.Base/Symbol/SymMapBaseTraversal.cs @@ -228,7 +228,7 @@ public SymMapBaseCollectionTraversal(SymMapBase root, TextWriter debugOutput) m_out = debugOutput; } - private TextWriter m_out = null; + private readonly TextWriter m_out = null; public List Collect(string typenameToCollect) { @@ -282,7 +282,7 @@ private SymMapBase Visit(SymMapBase m, SymMapBaseTraversal.Visit visit) return m; } - private SymMapBase m_root; + private readonly SymMapBase m_root; private string m_name; private List m_result; private Dictionary m_visited; diff --git a/src/Aardvark.Base/Symbol/Symbol.cs b/src/Aardvark.Base/Symbol/Symbol.cs index 20e07da03..f2b773706 100644 --- a/src/Aardvark.Base/Symbol/Symbol.cs +++ b/src/Aardvark.Base/Symbol/Symbol.cs @@ -161,10 +161,10 @@ public static class SymbolExtensions internal static class SymbolManager { - private static Dict s_stringDict = new Dict(1024); - private static Dict s_guidDict = new Dict(1024); - private static List s_allStrings = new List(1024); - private static List s_allGuids = new List(1024); + private static readonly Dict s_stringDict = new Dict(1024); + private static readonly Dict s_guidDict = new Dict(1024); + private static readonly List s_allStrings = new List(1024); + private static readonly List s_allGuids = new List(1024); private static SpinLock s_lock = new SpinLock(); static SymbolManager() diff --git a/src/Aardvark.Base/Text/TextParser.cs b/src/Aardvark.Base/Text/TextParser.cs index 5afe32129..57b795e60 100644 --- a/src/Aardvark.Base/Text/TextParser.cs +++ b/src/Aardvark.Base/Text/TextParser.cs @@ -180,7 +180,7 @@ public Case(Rx rx, Func> matchedFun, public class Cases : IEnumerable> where TPar : TextParser { - private List> CaseList; + private readonly List> CaseList; public Case[] Array => CaseList.ToArray(); @@ -416,7 +416,7 @@ public ParserCase(Rx rx, Func> matchedFun, /// public class ParserCases : IEnumerable> { - private List> CaseList; + private readonly List> CaseList; public ParserCase[] Array => CaseList.ToArray(); @@ -1379,7 +1379,7 @@ private static char HexOfEscString(string str) => (char)(HexOfOrd((int)str[1]) * 16 + HexOfOrd((int)str[2])); // Decide what to do, based on the first character of the escape sequence. - private static Dictionary s_escMap = new Dictionary { + private static readonly Dictionary s_escMap = new Dictionary { { 'a', "a", str => '\a' }, { 'b', "b", str => '\b' }, { 'f', "f", str => '\f' }, { 'n', "n", str => '\n' }, { 'r', "r", str => '\r' }, { 't', "t", str => '\t' }, { 'v', "v", str => '\v' }, @@ -1388,7 +1388,7 @@ private static char HexOfEscString(string str) { 'x', "x[0-9a-fA-F][0-9a-fA-F]", HexOfEscString }, }; - private static string s_escapes + private static readonly string s_escapes = String.Join("|", s_escMap.Values.Select(e => e.Pattern).Distinct()); private static readonly ParserState s_escState = new ParserCases { diff --git a/src/Tests/Aardvark.Base.Benchmarks/CodeGenTest.cs b/src/Tests/Aardvark.Base.Benchmarks/CodeGenTest.cs index ad8735678..6cc2f92be 100644 --- a/src/Tests/Aardvark.Base.Benchmarks/CodeGenTest.cs +++ b/src/Tests/Aardvark.Base.Benchmarks/CodeGenTest.cs @@ -82,7 +82,7 @@ public float Length_Sse_V3 [DisassemblyDiagnoser(printSource: true)] public class CodeGenTests { - MyVector4[] arr = new MyVector4[1000000]; + readonly MyVector4[] arr = new MyVector4[1000000]; //[GlobalSetup] public CodeGenTests() diff --git a/src/Tests/Aardvark.Base.Benchmarks/HashCodeCombine.cs b/src/Tests/Aardvark.Base.Benchmarks/HashCodeCombine.cs index ff93a70ee..2d0046aa5 100644 --- a/src/Tests/Aardvark.Base.Benchmarks/HashCodeCombine.cs +++ b/src/Tests/Aardvark.Base.Benchmarks/HashCodeCombine.cs @@ -221,11 +221,11 @@ public int V4d_HashCode_SystemCustom() return sum; } - public struct MyM44d + public readonly struct MyM44d { #pragma warning disable CS0649 - double x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15; + readonly double x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15; #pragma warning restore CS0649 public int CustomHashCode() @@ -236,10 +236,10 @@ public int CustomHashCode() } } - public struct MyV4d + public readonly struct MyV4d { #pragma warning disable CS0649 - double x0, x1, x2, x3; + readonly double x0, x1, x2, x3; #pragma warning restore CS0649 public int CustomHashCode() diff --git a/src/Tests/Aardvark.Base.Benchmarks/Log2Int.cs b/src/Tests/Aardvark.Base.Benchmarks/Log2Int.cs index 710993490..2e94448af 100644 --- a/src/Tests/Aardvark.Base.Benchmarks/Log2Int.cs +++ b/src/Tests/Aardvark.Base.Benchmarks/Log2Int.cs @@ -36,10 +36,10 @@ namespace Aardvark.Base.Benchmarks [DisassemblyDiagnoser(printSource: true)] public class Log2Int { - int[] m_numbersInt = new int[1000000]; - uint[] m_numbersUInt = new uint[1000000]; - float[] m_numbersFloat = new float[1000000]; - double[] m_numbersDouble = new double[1000000]; + readonly int[] m_numbersInt = new int[1000000]; + readonly uint[] m_numbersUInt = new uint[1000000]; + readonly float[] m_numbersFloat = new float[1000000]; + readonly double[] m_numbersDouble = new double[1000000]; public Log2Int() { @@ -374,9 +374,9 @@ public void Log2CeilingInt_AardvarkDoubleExp_Ceiling_Frac() [DisassemblyDiagnoser(printSource: true)] public class Log2 { - int[] m_numbersInt = new int[1000000]; - float[] m_numbersFloat = new float[1000000]; - double[] m_numbersDouble = new double[1000000]; + readonly int[] m_numbersInt = new int[1000000]; + readonly float[] m_numbersFloat = new float[1000000]; + readonly double[] m_numbersDouble = new double[1000000]; public Log2() { diff --git a/src/Tests/Aardvark.Base.Benchmarks/MatrixMultiply.cs b/src/Tests/Aardvark.Base.Benchmarks/MatrixMultiply.cs index b23326f7b..2811f8be2 100644 --- a/src/Tests/Aardvark.Base.Benchmarks/MatrixMultiply.cs +++ b/src/Tests/Aardvark.Base.Benchmarks/MatrixMultiply.cs @@ -10,8 +10,8 @@ namespace Aardvark.Base.Benchmarks [DisassemblyDiagnoser(printSource: true)] public class MatrixMultiply { - M44d[] arr44 = new M44d[100000]; - M34d[] arr34 = new M34d[100000]; + readonly M44d[] arr44 = new M44d[100000]; + readonly M34d[] arr34 = new M34d[100000]; //[GlobalSetup] public MatrixMultiply() diff --git a/src/Tests/Aardvark.Base.Benchmarks/Rot3dTransform.cs b/src/Tests/Aardvark.Base.Benchmarks/Rot3dTransform.cs index 145282c36..51b798f12 100644 --- a/src/Tests/Aardvark.Base.Benchmarks/Rot3dTransform.cs +++ b/src/Tests/Aardvark.Base.Benchmarks/Rot3dTransform.cs @@ -12,7 +12,7 @@ namespace Aardvark.Base.Benchmarks [DisassemblyDiagnoser(printSource: true)] public class Rot3dTransform { - V3d[] arr = new V3d[100000]; + readonly V3d[] arr = new V3d[100000]; Rot3d rotG = Rot3d.RotationX(Constant.Pi); M33d matG = M33d.Identity; diff --git a/src/Tests/Aardvark.Base.Benchmarks/StaticConstants.cs b/src/Tests/Aardvark.Base.Benchmarks/StaticConstants.cs index 78c5e4a3c..4acc451bc 100644 --- a/src/Tests/Aardvark.Base.Benchmarks/StaticConstants.cs +++ b/src/Tests/Aardvark.Base.Benchmarks/StaticConstants.cs @@ -40,7 +40,7 @@ public StructThing DoMath(StructThing b) [DisassemblyDiagnoser(printSource: true)] public class StaticConstants { - StructThing[] arr = new StructThing[500000]; + readonly StructThing[] arr = new StructThing[500000]; public StaticConstants() { diff --git a/src/Tests/Aardvark.Base.Benchmarks/TelemetryProbesBenchmark.cs b/src/Tests/Aardvark.Base.Benchmarks/TelemetryProbesBenchmark.cs index 80c3b1392..88656c48b 100644 --- a/src/Tests/Aardvark.Base.Benchmarks/TelemetryProbesBenchmark.cs +++ b/src/Tests/Aardvark.Base.Benchmarks/TelemetryProbesBenchmark.cs @@ -28,13 +28,13 @@ namespace Aardvark.Base.Benchmarks [MemoryDiagnoser, PlainExporter] public class TelemetryProbesBenchmark { - Telemetry.StopWatchTime StopWatchProbe = new Telemetry.StopWatchTime(); - Telemetry.CpuTime CPUProbe = new Telemetry.CpuTime(); - Telemetry.WallClockTime WallProbe = new Telemetry.WallClockTime(); - Telemetry.CpuTimeUser CPUUserProbe = new Telemetry.CpuTimeUser(); - Telemetry.CpuTimePrivileged CPUPrivilegedProbe = new Telemetry.CpuTimePrivileged(); + readonly Telemetry.StopWatchTime StopWatchProbe = new Telemetry.StopWatchTime(); + readonly Telemetry.CpuTime CPUProbe = new Telemetry.CpuTime(); + readonly Telemetry.WallClockTime WallProbe = new Telemetry.WallClockTime(); + readonly Telemetry.CpuTimeUser CPUUserProbe = new Telemetry.CpuTimeUser(); + readonly Telemetry.CpuTimePrivileged CPUPrivilegedProbe = new Telemetry.CpuTimePrivileged(); - double[] m_data = new double[10000].SetByIndex(i => i + 1); + readonly double[] m_data = new double[10000].SetByIndex(i => i + 1); [Benchmark] public int StopWatchTime() diff --git a/src/Tests/Aardvark.Base.Benchmarks/Transform.cs b/src/Tests/Aardvark.Base.Benchmarks/Transform.cs index be9cd888f..3017e1cac 100644 --- a/src/Tests/Aardvark.Base.Benchmarks/Transform.cs +++ b/src/Tests/Aardvark.Base.Benchmarks/Transform.cs @@ -26,7 +26,7 @@ namespace Aardvark.Base.Benchmarks [DisassemblyDiagnoser(printSource: true)] public class TransformV3d { - V3d[] arr = new V3d[100000]; + readonly V3d[] arr = new V3d[100000]; M44d trafo = M44d.RotationX(Constant.Pi); Euclidean3d euclidean = Euclidean3d.RotationX(Constant.Pi); diff --git a/src/Tests/Aardvark.Base.Benchmarks/VectorLength.cs b/src/Tests/Aardvark.Base.Benchmarks/VectorLength.cs index d480ecbeb..ca3131b40 100644 --- a/src/Tests/Aardvark.Base.Benchmarks/VectorLength.cs +++ b/src/Tests/Aardvark.Base.Benchmarks/VectorLength.cs @@ -10,7 +10,7 @@ namespace Aardvark.Base.Benchmarks [DisassemblyDiagnoser(printSource: true)] public class V4fLength { - V4f[] arr = new V4f[1000000]; + readonly V4f[] arr = new V4f[1000000]; //[GlobalSetup] public V4fLength() @@ -49,7 +49,7 @@ public float V4fLengthSse() [DisassemblyDiagnoser(printSource: true)] public class V3fLength { - V3f[] arr = new V3f[1000000]; + readonly V3f[] arr = new V3f[1000000]; //[GlobalSetup] public V3fLength() @@ -88,7 +88,7 @@ public float V3fLengthSse() [DisassemblyDiagnoser(printSource: true)] public class V2fLength { - V2f[] arr = new V2f[1000000]; + readonly V2f[] arr = new V2f[1000000]; //[GlobalSetup] public V2fLength() diff --git a/src/Tests/Aardvark.Base.Tests/Extensions/DateTime.cs b/src/Tests/Aardvark.Base.Tests/Extensions/DateTime.cs index d97eeb843..3e3ee60ea 100644 --- a/src/Tests/Aardvark.Base.Tests/Extensions/DateTime.cs +++ b/src/Tests/Aardvark.Base.Tests/Extensions/DateTime.cs @@ -188,12 +188,12 @@ public static void JulianDay() Report.Line("ComputeJulianDayRaw: {0}ms", sw5.Elapsed.TotalMilliseconds); } - static Stopwatch sw0 = new Stopwatch(); - static Stopwatch sw1 = new Stopwatch(); - static Stopwatch sw2 = new Stopwatch(); - static Stopwatch sw3 = new Stopwatch(); - static Stopwatch sw4 = new Stopwatch(); - static Stopwatch sw5 = new Stopwatch(); + static readonly Stopwatch sw0 = new Stopwatch(); + static readonly Stopwatch sw1 = new Stopwatch(); + static readonly Stopwatch sw2 = new Stopwatch(); + static readonly Stopwatch sw3 = new Stopwatch(); + static readonly Stopwatch sw4 = new Stopwatch(); + static readonly Stopwatch sw5 = new Stopwatch(); static int warpup = 10000; static void TestDate(DateTime date) diff --git a/src/Tests/Aardvark.Base.Tests/Extensions/Hashes.cs b/src/Tests/Aardvark.Base.Tests/Extensions/Hashes.cs index 1976c7380..1b0fb09aa 100644 --- a/src/Tests/Aardvark.Base.Tests/Extensions/Hashes.cs +++ b/src/Tests/Aardvark.Base.Tests/Extensions/Hashes.cs @@ -124,7 +124,7 @@ static SizeOfCache() } } - private static Dictionary _sizeCache = new Dictionary(); + private static readonly Dictionary _sizeCache = new Dictionary(); public static int SizeOf(Type type) { return _sizeCache.GetCreate(type, t =>