Skip to content

Commit

Permalink
Add missing readonly modifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
hyazinthh committed Jun 5, 2024
1 parent 6e6cc29 commit ffde1fd
Show file tree
Hide file tree
Showing 92 changed files with 437 additions and 437 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Aardvark.Base
public class CameraProjectionOrtho : ICameraProjection
{
private Trafo3d m_trafo;
private EventSource<Trafo3d> m_trafoChanges = new EventSource<Trafo3d>();
private readonly EventSource<Trafo3d> m_trafoChanges = new EventSource<Trafo3d>();
private Box3d m_box;

public CameraProjectionOrtho(double left, double right, double bottom, double top, double near, double far)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Aardvark.Base
public class CameraProjectionPerspective : ICameraProjectionPerspective
{
private Trafo3d m_trafo;
private EventSource<Trafo3d> m_trafoChanges = new EventSource<Trafo3d>();
private readonly EventSource<Trafo3d> m_trafoChanges = new EventSource<Trafo3d>();
private Box3d m_box;

public CameraProjectionPerspective(double horizontalFovInDegrees, double near, double far, double aspectRatio = 1.0)
Expand Down
2 changes: 1 addition & 1 deletion src/Aardvark.Base.Essentials/Camera/CameraViewRaw.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Trafo3d> m_trafoChanges;
private readonly EventSource<Trafo3d> m_trafoChanges;

public CameraViewRaw()
{
Expand Down
2 changes: 1 addition & 1 deletion src/Aardvark.Base.Essentials/Camera/CameraViewWithSky.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Trafo3d> m_trafoChanges = new EventSource<Trafo3d>();
private readonly EventSource<Trafo3d> m_trafoChanges = new EventSource<Trafo3d>();

/// <summary>
/// Sky direction (normalized).
Expand Down
26 changes: 13 additions & 13 deletions src/Aardvark.Base.Essentials/Screenshot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ private enum Mode
Variable,
Mixed,
}
private Http.Verb m_verb;
private string m_route;
private Action<HttpServerRequestInfo> m_handler;
private readonly Http.Verb m_verb;
private readonly string m_route;
private readonly Action<HttpServerRequestInfo> m_handler;

private string[] m_tokens;
private Mode[] m_modes;
private readonly string[] m_tokens;
private readonly Mode[] m_modes;

public Action<HttpServerRequestInfo> Handler { get { return m_handler; } }
public string Route { get { return m_route; } }
Expand Down Expand Up @@ -104,7 +104,7 @@ public HttpServer2Route(string route, Http.Verb verb, Action<HttpServerRequestIn

public class HttpServer2Dispatcher
{
private List<HttpServer2Route> m_routes = new List<HttpServer2Route>();
private readonly List<HttpServer2Route> m_routes = new List<HttpServer2Route>();

public void AddRoutes(params HttpServer2Route[] routes)
{
Expand Down Expand Up @@ -145,7 +145,7 @@ public class HttpServerRequestInfo
private string m_head;
private string m_route;
private Http.Verb m_verb;
private Dictionary<string, string> m_query = new Dictionary<string, string>();
private readonly Dictionary<string, string> m_query = new Dictionary<string, string>();

public string Head
{
Expand Down Expand Up @@ -201,9 +201,9 @@ public double Get(string paramName, double defaultValue)

public class HttpServerDispatcher
{
private Dictionary<string, List<Func<HttpServerRequestInfo, bool>>> m_handlers =
private readonly Dictionary<string, List<Func<HttpServerRequestInfo, bool>>> m_handlers =
new Dictionary<string, List<Func<HttpServerRequestInfo, bool>>>();
private Dictionary<string, List<HttpServerDispatcher>> m_dispatchers =
private readonly Dictionary<string, List<HttpServerDispatcher>> m_dispatchers =
new Dictionary<string, List<HttpServerDispatcher>>();

public void Register(Func<HttpServerRequestInfo, bool> handler)
Expand Down Expand Up @@ -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()
{
Expand Down Expand Up @@ -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!"),
Expand Down
12 changes: 6 additions & 6 deletions src/Aardvark.Base.Essentials/System/Awaitable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -377,9 +377,9 @@ public void Emit()

#endregion

private struct Awaiter : IAwaiter<T>
private readonly struct Awaiter : IAwaiter<T>
{
private Awaitable<T> m_source;
private readonly Awaitable<T> m_source;

#region Constructors

Expand Down Expand Up @@ -804,7 +804,7 @@ void IAwaiter.GetResult()
/// </summary>
public class TaskAwaitable<T> : IAwaitable<T>
{
private Task<T> m_task;
private readonly Task<T> m_task;

/// <summary>
/// </summary>
Expand Down Expand Up @@ -843,7 +843,7 @@ public bool IsCompleted
/// </summary>
public class TaskAwaitable : IAwaitable
{
private Task m_task;
private readonly Task m_task;

/// <summary>
/// </summary>
Expand Down
8 changes: 4 additions & 4 deletions src/Aardvark.Base.Essentials/System/Clock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class Clock : IDisposable
private int m_frequency;
private int m_minimalUpdateTime;
private CancellationTokenSource m_source;
private Dictionary<Action, DateTime> m_lastTime;
private readonly Dictionary<Action, DateTime> m_lastTime;

#region Constructors

Expand Down Expand Up @@ -184,7 +184,7 @@ public static class ClockExtensions

private struct FutureAwaiter : IAwaiter<TimeValue>
{
private FutureAwaitable m_future;
private readonly FutureAwaitable m_future;
private Action m_continuation;

public FutureAwaiter(FutureAwaitable f)
Expand Down Expand Up @@ -253,8 +253,8 @@ void IAwaiter.GetResult()

private class FutureAwaitable : IAwaitable<TimeValue>
{
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)
{
Expand Down
6 changes: 3 additions & 3 deletions src/Aardvark.Base.Essentials/System/EventSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Aardvark.Base
{
public class EventSourceSlim<T> : IEvent<T>
{
private Subject<T> m_subject;
private readonly Subject<T> m_subject;
private T m_latest;
public EventSourceSlim(T defaultValue)
{
Expand Down Expand Up @@ -121,11 +121,11 @@ public static EventSource<Tuple<T0, T1, T2, T3, T4>> Create<T0, T1, T2, T3, T4>(
/// </summary>
public class EventSource<T> : IEvent<T>, IEventEmitter<T>
{
private ThreadLocal<bool> m_currentThreadDoesNotOwnLock = new ThreadLocal<bool>(() => true);
private readonly ThreadLocal<bool> m_currentThreadDoesNotOwnLock = new ThreadLocal<bool>(() => true);
private SpinLock m_lock = new SpinLock(true);
private T m_latest;
private Awaitable<T> m_awaitable = new Awaitable<T>();
private Lazy<Subject<T>> m_eventStream = new Lazy<Subject<T>>();
private readonly Lazy<Subject<T>> m_eventStream = new Lazy<Subject<T>>();

/// <summary>
/// Creates an EventSource with default initial value.
Expand Down
6 changes: 3 additions & 3 deletions src/Aardvark.Base.Essentials/System/EventSourceSpecials.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ public static ConstEventSource<Tuple<T0, T1, T2, T3, T4>> Create<T0, T1, T2, T3,
/// </summary>
public class ConstEventSource<T> : IEvent<T>
{
private static Awaitable s_awaitableNonGeneric = new Awaitable();
private static Awaitable<T> s_awaitable = new Awaitable<T>();
private T m_value;
private static readonly Awaitable s_awaitableNonGeneric = new Awaitable();
private static readonly Awaitable<T> s_awaitable = new Awaitable<T>();
private readonly T m_value;

/// <summary>
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Aardvark.Base.Essentials/System/FilteredEventSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Aardvark.Base
/// </summary>
public class FilteredEventSource<T> : EventSource<T>
{
private Func<T, bool> m_predicate;
private readonly Func<T, bool> m_predicate;

/// <summary>
/// </summary>
Expand Down
12 changes: 6 additions & 6 deletions src/Aardvark.Base.Essentials/System/Reactive.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void Dispose()

internal class Subject<T> : IObservable<T>, IObserver<T>
{
private Dictionary<IObserver<T>, int> m_observers;
private readonly Dictionary<IObserver<T>, int> m_observers;

public Subject()
{
Expand Down Expand Up @@ -111,7 +111,7 @@ public IDisposable Subscribe(IObserver<T> obs)

internal class LambdaObserver<T> : IObserver<T>
{
private Action<T> m_action;
private readonly Action<T> m_action;

public LambdaObserver(Action<T> action)
{
Expand All @@ -132,8 +132,8 @@ public void OnError(Exception e)

internal class MapObserver<T1, T2> : IObserver<T1>
{
private Func<T1, T2> m_mapping;
private IObserver<T2> m_target;
private readonly Func<T1, T2> m_mapping;
private readonly IObserver<T2> m_target;

public MapObserver(IObserver<T2> target, Func<T1, T2> mapping)
{
Expand All @@ -157,8 +157,8 @@ public void OnError(Exception error)

internal class MapObservable<T1, T2> : IObservable<T2>
{
private IObservable<T1> m_input;
private Func<T1, T2> m_mapping;
private readonly IObservable<T1> m_input;
private readonly Func<T1, T2> m_mapping;

public MapObservable(IObservable<T1> input, Func<T1, T2> mapping)
{
Expand Down
8 changes: 4 additions & 4 deletions src/Aardvark.Base.IO/Annotations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ public Annotation(string key, object value)
}
}

internal struct Annotated<T>
internal readonly struct Annotated<T>
{
private T m_value;
private IEnumerable<Annotation> m_tags;
private static IEnumerable<Annotation> s_empty = new Annotation[0];
private readonly T m_value;
private readonly IEnumerable<Annotation> m_tags;
private static readonly IEnumerable<Annotation> s_empty = new Annotation[0];

public Annotated(T value)
{
Expand Down
6 changes: 3 additions & 3 deletions src/Aardvark.Base.IO/BaseCoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down Expand Up @@ -112,7 +112,7 @@ public TypeInfo TypeInfo
public class BaseReadingCoder : BaseCoder
{
protected Dictionary<string, TypeInfo> m_typeInfoOfName;
private Stack<List<TypeInfo>> m_typeInfoArrayStack;
private readonly Stack<List<TypeInfo>> m_typeInfoArrayStack;
protected List<object> m_refs;

#region Constructor
Expand Down Expand Up @@ -178,7 +178,7 @@ public void Del(TypeInfo[] tia)
public class BaseWritingCoder : BaseCoder
{
protected Dictionary<Type, TypeInfo> m_typeInfoOfType;
private Stack<List<TypeInfo>> m_typeInfoArrayStack;
private readonly Stack<List<TypeInfo>> m_typeInfoArrayStack;
protected Dictionary<object, int> m_refs;

#region Constructor
Expand Down
4 changes: 2 additions & 2 deletions src/Aardvark.Base.IO/BinaryReadingCoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions src/Aardvark.Base.IO/BinaryWritingCoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions src/Aardvark.Base.IO/ChunkedMemoryStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ namespace Aardvark.Base.Coder
{
public class ChunkedMemoryStream : Stream
{
private long m_chunkSize;
List<byte[]> m_chunkList;
private readonly long m_chunkSize;
readonly List<byte[]> m_chunkList;

private long m_position;
private int m_posChunk;
Expand Down
18 changes: 9 additions & 9 deletions src/Aardvark.Base.IO/Converter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -277,31 +277,31 @@ private struct RoutingEntry
private bool m_initialized = false;
private SpinLock m_spinLock = new SpinLock();

private Dictionary<(string, string), Action<Convertible, Convertible>>
private readonly Dictionary<(string, string), Action<Convertible, Convertible>>
m_actionMap = new Dictionary<(string, string), Action<Convertible, Convertible>>();

private Dictionary<(string, string), Annotation[]>
private readonly Dictionary<(string, string), Annotation[]>
m_annotationsMap = new Dictionary<(string, string), Annotation[]>();

private Dictionary<string, Dictionary<string, RoutingEntry>>
private readonly Dictionary<string, Dictionary<string, RoutingEntry>>
m_routingMap = new Dictionary<string, Dictionary<string, RoutingEntry>>();

private Dictionary<(string, string), int>
private readonly Dictionary<(string, string), int>
m_weightMap = new Dictionary<(string, string), int>();

private Dictionary<string, List<Func<string, Convertible>>>
private readonly Dictionary<string, List<Func<string, Convertible>>>
m_fileExtensionsMap = new Dictionary<string, List<Func<string, Convertible>>>();

private Dictionary<string, List<Func<Convertible>>>
private readonly Dictionary<string, List<Func<Convertible>>>
m_rawConvertiblesMap = new Dictionary<string, List<Func<Convertible>>>();

private Dictionary<string, List<Func<Convertible>>>
private readonly Dictionary<string, List<Func<Convertible>>>
m_creatorsMap = new Dictionary<string, List<Func<Convertible>>>();

private Dictionary<string, List<string>>
private readonly Dictionary<string, List<string>>
m_resourcesMap = new Dictionary<string, List<string>>();

private List<string> m_availableResources = new List<string>();
private readonly List<string> m_availableResources = new List<string>();

#endregion

Expand Down
Loading

0 comments on commit ffde1fd

Please sign in to comment.