Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some more missing 'readonly' modifiers #1707

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/WinRT.Runtime/ComWrappersSupport.net5.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ private static DefaultComWrappers DefaultComWrappersInstance
internal static Type CreateRCWType;

private static ComWrappers _comWrappers;
private static object _comWrappersLock = new object();
private static readonly object _comWrappersLock = new object();
private static ComWrappers ComWrappers
{
get
Expand Down
6 changes: 3 additions & 3 deletions src/WinRT.Runtime/Marshalers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ internal struct HSTRING_HEADER

public ref struct Pinnable
{
private HSTRING_HEADER _header;
private string _value;
private readonly HSTRING_HEADER _header;
private readonly string _value;
#if DEBUG
private bool _pinned;
#endif
Expand Down Expand Up @@ -116,7 +116,7 @@ public unsafe IntPtr GetAbi()
Marshal.ThrowExceptionForHR(Platform.WindowsCreateStringReference(
(ushort*)Unsafe.AsPointer(ref Unsafe.AsRef(in GetPinnableReference())),
_value.Length,
(IntPtr*)Unsafe.AsPointer(ref _header),
(IntPtr*)Unsafe.AsPointer(ref Unsafe.AsRef(in _header)),
&hstring));
return hstring;
}
Expand Down
4 changes: 2 additions & 2 deletions src/WinRT.Runtime/MonoSupport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace WinRT
{
internal static class Mono
{
static unsafe Lazy<bool> _usingMono = new Lazy<bool>(() =>
static readonly unsafe Lazy<bool> _usingMono = new Lazy<bool>(() =>
{
IntPtr modulePtr = Platform.LoadLibraryExW("mono-2.0-bdwgc.dll", IntPtr.Zero, 0);
if (modulePtr == IntPtr.Zero) return false;
Expand Down Expand Up @@ -75,7 +75,7 @@ struct MonoInternalThread_x64

public sealed class ThreadContext : IDisposable
{
static Lazy<HashSet<IntPtr>> _foreignThreads = new Lazy<HashSet<IntPtr>>();
static readonly Lazy<HashSet<IntPtr>> _foreignThreads = new Lazy<HashSet<IntPtr>>();

readonly IntPtr _threadPtr = IntPtr.Zero;

Expand Down
2 changes: 1 addition & 1 deletion src/WinRT.Runtime/Projections/Bindable.net5.cs
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,7 @@ public IEnumerator GetEnumerator()
public sealed class ToAbiHelper : IBindableVector
#pragma warning restore CA2257
{
private global::System.Collections.IList _list;
private readonly global::System.Collections.IList _list;

public ToAbiHelper(global::System.Collections.IList list) => _list = list;

Expand Down