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

Mark typed sealed where possible #1050

Merged
merged 2 commits into from
Nov 18, 2021
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.cs
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ private static ComInterfaceEntry ProvideIReferenceArray(Type arrayType)
};
}

internal class InspectableInfo
internal sealed class InspectableInfo
{
private readonly Lazy<string> runtimeClassName;

Expand Down
2 changes: 1 addition & 1 deletion src/WinRT.Runtime/ComWrappersSupport.net5.cs
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ protected override void ReleaseObjects(IEnumerable objects)
}
}

unsafe class VtableEntries
unsafe sealed class VtableEntries
{
public ComInterfaceEntry* Data { get; }
public int Count { get; }
Expand Down
4 changes: 2 additions & 2 deletions src/WinRT.Runtime/ComWrappersSupport.netstandard2.0.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ private static uint Do_Abi_Release(IntPtr pThis)
return UnmanagedObject.FindObject<ComCallableWrapper>(pThis).Release();
}

private class RuntimeWrapperCleanup
private sealed class RuntimeWrapperCleanup
{
public IntPtr _identityComObject;
public System.WeakReference<object> _runtimeWrapper;
Expand Down Expand Up @@ -303,7 +303,7 @@ internal static T FindObject<T>(IntPtr thisPtr)
}
}

internal class ComCallableWrapper
internal sealed class ComCallableWrapper
{
private Dictionary<Guid, IntPtr> _managedQITable;
private GCHandle _qiTableHandle;
Expand Down
4 changes: 2 additions & 2 deletions src/WinRT.Runtime/ExceptionHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ public static int GetHRForException(Exception ex)
// the exception instance in the app to hold the error object alive.
//
[Serializable]
internal class __RestrictedErrorObject
internal sealed class __RestrictedErrorObject
{
// Hold the error object instance but don't serialize/deserialize it
[NonSerialized]
Expand Down Expand Up @@ -404,7 +404,7 @@ internal static Exception GetExceptionForHR(this Exception innerException, int h
}
}

internal class ErrorStrings
internal static class ErrorStrings
{
internal static string Format(string format, params object[] args) => String.Format(format, args);

Expand Down
2 changes: 1 addition & 1 deletion src/WinRT.Runtime/Interop/ExceptionErrorInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void GetErrorDetails(
string GetReference();
}

internal class ManagedExceptionErrorInfo : IErrorInfo, ISupportErrorInfo
internal sealed class ManagedExceptionErrorInfo : IErrorInfo, ISupportErrorInfo
{
private readonly Exception _exception;

Expand Down
2 changes: 1 addition & 1 deletion src/WinRT.Runtime/Interop/IAgileReference.net5.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ static Vftbl()
}

[Guid("00000146-0000-0000-C000-000000000046")]
internal unsafe class IGlobalInterfaceTable : global::WinRT.Interop.IGlobalInterfaceTable
internal sealed unsafe class IGlobalInterfaceTable : global::WinRT.Interop.IGlobalInterfaceTable
{
[Guid("00000146-0000-0000-C000-000000000046")]
[StructLayout(LayoutKind.Sequential)]
Expand Down
4 changes: 2 additions & 2 deletions src/WinRT.Runtime/Interop/IAgileReference.netstandard2.0.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace ABI.WinRT.Interop
using global::WinRT;

[Guid("C03F6A43-65A4-9818-987E-E0B810D2A6F2")]
internal unsafe class IAgileReference : global::WinRT.Interop.IAgileReference
internal sealed unsafe class IAgileReference : global::WinRT.Interop.IAgileReference
{
[Guid("C03F6A43-65A4-9818-987E-E0B810D2A6F2")]
public struct Vftbl
Expand Down Expand Up @@ -162,7 +162,7 @@ public IAgileObject(ObjectReference<Vftbl> obj)
}

[Guid("00000146-0000-0000-C000-000000000046")]
internal unsafe class IGlobalInterfaceTable : global::WinRT.Interop.IGlobalInterfaceTable
internal sealed unsafe class IGlobalInterfaceTable : global::WinRT.Interop.IGlobalInterfaceTable
{
[Guid("00000146-0000-0000-C000-000000000046")]
[StructLayout(LayoutKind.Sequential)]
Expand Down
2 changes: 1 addition & 1 deletion src/WinRT.Runtime/Interop/IContextCallback.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void ContextCallback(
namespace ABI.WinRT.Interop
{
[Guid("000001da-0000-0000-C000-000000000046")]
unsafe class IContextCallback : global::WinRT.Interop.IContextCallback
internal sealed unsafe class IContextCallback : global::WinRT.Interop.IContextCallback
{
[Guid("000001da-0000-0000-C000-000000000046")]
public struct Vftbl
Expand Down
2 changes: 1 addition & 1 deletion src/WinRT.Runtime/Interop/IMarshal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ internal interface IMarshal
namespace ABI.WinRT.Interop
{
[Guid("00000003-0000-0000-c000-000000000046")]
internal class IMarshal
internal sealed class IMarshal
{
internal static readonly Guid IID = new(0x00000003, 0, 0, 0xc0, 0, 0, 0, 0, 0, 0, 0x46);

Expand Down
2 changes: 1 addition & 1 deletion src/WinRT.Runtime/Interop/IWeakReferenceSource.net5.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ interface IWeakReference
IObjectReference Resolve(Guid riid);
}

internal class ManagedWeakReference : IWeakReference
internal sealed class ManagedWeakReference : IWeakReference
{
private readonly WeakReference<object> _ref;
public ManagedWeakReference(object obj)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ interface IWeakReference
IObjectReference Resolve(Guid riid);
}

internal class ManagedWeakReference : IWeakReference
internal sealed class ManagedWeakReference : IWeakReference
{
private WeakReference<object> _ref;
public ManagedWeakReference(object obj)
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 @@ -10,7 +10,7 @@

namespace WinRT
{
internal class Mono
internal static class Mono
{
static Lazy<bool> _usingMono = new Lazy<bool>(() =>
{
Expand Down Expand Up @@ -72,7 +72,7 @@ struct MonoInternalThread_x64
public MonoThreadFlag flags;
}

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

Expand Down
2 changes: 1 addition & 1 deletion src/WinRT.Runtime/ObjectReference.cs
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ private protected virtual T GetVftblForCurrentContext()
}
}

internal class ObjectReferenceWithContext<T> : ObjectReference<T>
internal sealed class ObjectReferenceWithContext<T> : ObjectReference<T>
{
private readonly IntPtr _contextCallbackPtr;
private readonly IntPtr _contextToken;
Expand Down
6 changes: 3 additions & 3 deletions src/WinRT.Runtime/Projections/Bindable.net5.cs
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ internal unsafe interface IEnumerable : global::System.Collections.IEnumerable,
{
public static string GetGuidSignature() => GuidGenerator.GetSignature(typeof(IEnumerable));

public class AdaptiveFromAbiHelper : FromAbiHelper, global::System.Collections.IEnumerable
public sealed class AdaptiveFromAbiHelper : FromAbiHelper, global::System.Collections.IEnumerable
{
private readonly Func<IWinRTObject, global::System.Collections.IEnumerator> _enumerator;

Expand Down Expand Up @@ -480,7 +480,7 @@ private sealed class NonGenericToGenericIterator : global::Windows.Foundation.Co
}
}

public class ToAbiHelper : IBindableIterable
public sealed class ToAbiHelper : IBindableIterable
{
private readonly IEnumerable m_enumerable;

Expand Down Expand Up @@ -596,7 +596,7 @@ unsafe interface IList : global::System.Collections.IList, global::Microsoft.UI.
{
public static string GetGuidSignature() => GuidGenerator.GetSignature(typeof(IList));

public class FromAbiHelper : global::System.Collections.IList
public sealed class FromAbiHelper : global::System.Collections.IList
{
private readonly global::Microsoft.UI.Xaml.Interop.IBindableVector _vector;

Expand Down
8 changes: 4 additions & 4 deletions src/WinRT.Runtime/Projections/EventHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ public static IntPtr GetAbi(IObjectReference value) =>

[global::WinRT.ObjectReferenceWrapper(nameof(_nativeDelegate))]
#if !NET
private class NativeDelegateWrapper
private sealed class NativeDelegateWrapper
#else
private class NativeDelegateWrapper : IWinRTObject
private sealed class NativeDelegateWrapper : IWinRTObject
#endif
{
private readonly ObjectReference<global::WinRT.Interop.IDelegateVftbl> _nativeDelegate;
Expand Down Expand Up @@ -187,9 +187,9 @@ public static IntPtr GetAbi(IObjectReference value) =>

[global::WinRT.ObjectReferenceWrapper(nameof(_nativeDelegate))]
#if !NET
private class NativeDelegateWrapper
private sealed class NativeDelegateWrapper
#else
private class NativeDelegateWrapper : IWinRTObject
private sealed class NativeDelegateWrapper : IWinRTObject
#endif
{
private readonly ObjectReference<global::WinRT.Interop.IDelegateVftbl> _nativeDelegate;
Expand Down
2 changes: 1 addition & 1 deletion src/WinRT.Runtime/Projections/Geometry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace Windows.Foundation
{
internal class GSR
internal static class GSR
{
public static string ArgumentOutOfRange_NeedNonNegNum = "Non-negative number required.";
}
Expand Down
4 changes: 2 additions & 2 deletions src/WinRT.Runtime/Projections/ICustomPropertyProvider.net5.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ interface ICustomProperty
namespace ABI.Microsoft.UI.Xaml.Data
{
[Guid("30DA92C0-23E8-42A0-AE7C-734A0E5D2782")]
internal unsafe class ICustomProperty
internal sealed unsafe class ICustomProperty
{
[Guid("30DA92C0-23E8-42A0-AE7C-734A0E5D2782")]
public struct Vftbl
Expand Down Expand Up @@ -234,7 +234,7 @@ internal static class ICustomProperty_Delegates
public unsafe delegate int get_CanRead_7(IntPtr thisPtr, byte* value);
}

internal class ManagedCustomProperty : global::Microsoft.UI.Xaml.Data.ICustomProperty
internal sealed class ManagedCustomProperty : global::Microsoft.UI.Xaml.Data.ICustomProperty
{
private readonly PropertyInfo _property;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ interface ICustomProperty
namespace ABI.Microsoft.UI.Xaml.Data
{
[Guid("30DA92C0-23E8-42A0-AE7C-734A0E5D2782")]
internal unsafe class ICustomProperty
internal sealed unsafe class ICustomProperty
{
[Guid("30DA92C0-23E8-42A0-AE7C-734A0E5D2782")]
public struct Vftbl
Expand Down Expand Up @@ -220,7 +220,7 @@ internal static class ICustomProperty_Delegates
public unsafe delegate int get_CanRead_7(IntPtr thisPtr, byte* value);
}

internal class ManagedCustomProperty : global::Microsoft.UI.Xaml.Data.ICustomProperty
internal sealed class ManagedCustomProperty : global::Microsoft.UI.Xaml.Data.ICustomProperty
{
private readonly PropertyInfo _property;

Expand Down
4 changes: 2 additions & 2 deletions src/WinRT.Runtime/Projections/IDictionary.net5.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public static void DisposeAbi(IntPtr abi) =>

public static string GetGuidSignature() => GuidGenerator.GetSignature(typeof(IDictionary<K, V>));

public class FromAbiHelper : global::System.Collections.Generic.IDictionary<K, V>
public sealed class FromAbiHelper : global::System.Collections.Generic.IDictionary<K, V>
{
private readonly global::Windows.Foundation.Collections.IMap<K, V> _map;
internal readonly Dictionary<K, (IntPtr, V)> _lookupCache = new();
Expand Down Expand Up @@ -438,7 +438,7 @@ public void Reset()
}
}

public class ToAbiHelper : global::Windows.Foundation.Collections.IMap<K, V>
public sealed class ToAbiHelper : global::Windows.Foundation.Collections.IMap<K, V>
{
private readonly global::System.Collections.Generic.IDictionary<K, V> _dictionary;

Expand Down
2 changes: 1 addition & 1 deletion src/WinRT.Runtime/Projections/IEnumerable.net5.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public static void DisposeAbi(IntPtr abi) =>

public static string GetGuidSignature() => GuidGenerator.GetSignature(typeof(IEnumerable<T>));

public class FromAbiHelper : global::System.Collections.Generic.IEnumerable<T>
public sealed class FromAbiHelper : global::System.Collections.Generic.IEnumerable<T>
{
private readonly global::System.Collections.Generic.IEnumerable<T> _iterable;

Expand Down
2 changes: 1 addition & 1 deletion src/WinRT.Runtime/Projections/IList.net5.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public static void DisposeAbi(IntPtr abi) =>

public static string GetGuidSignature() => GuidGenerator.GetSignature(typeof(IList<T>));

public class FromAbiHelper : global::System.Collections.Generic.IList<T>
public sealed class FromAbiHelper : global::System.Collections.Generic.IList<T>
{
private readonly global::Windows.Foundation.Collections.IVector<T> _vector;

Expand Down
2 changes: 1 addition & 1 deletion src/WinRT.Runtime/Projections/IPropertyValue.net5.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ private static T UnboxValue<T>(object value)
}

#pragma warning disable CS0649
private class Boxed<T>
private sealed class Boxed<T>
where T : struct
{
public T Value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ private static T UnboxValue<T>(object value)
}

#pragma warning disable CS0649
private class Boxed<T>
private sealed class Boxed<T>
where T : struct
{
public T Value;
Expand Down
6 changes: 3 additions & 3 deletions src/WinRT.Runtime/Projections/IReadOnlyDictionary.net5.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public void Reset()
}
}

public class FromAbiHelper : global::System.Collections.Generic.IReadOnlyDictionary<K, V>
public sealed class FromAbiHelper : global::System.Collections.Generic.IReadOnlyDictionary<K, V>
{
private readonly global::Windows.Foundation.Collections.IMapView<K, V> _mapView;
private readonly global::System.Collections.Generic.IEnumerable<global::System.Collections.Generic.KeyValuePair<K, V>> _enumerable;
Expand Down Expand Up @@ -258,7 +258,7 @@ private static V Lookup(global::Windows.Foundation.Collections.IMapView<K, V> _t

}

public class ToAbiHelper : global::Windows.Foundation.Collections.IMapView<K, V>
public sealed class ToAbiHelper : global::Windows.Foundation.Collections.IMapView<K, V>
{
private readonly global::System.Collections.Generic.IReadOnlyDictionary<K, V> _dictionary;

Expand Down Expand Up @@ -305,7 +305,7 @@ public V Lookup(K key)

private sealed class ConstantSplittableMap : global::Windows.Foundation.Collections.IMapView<K, V>, global::System.Collections.Generic.IReadOnlyDictionary<K, V>
{
private class KeyValuePairComparator : IComparer<global::System.Collections.Generic.KeyValuePair<K, V>>
private sealed class KeyValuePairComparator : IComparer<global::System.Collections.Generic.KeyValuePair<K, V>>
{
private static readonly IComparer<K> keyComparator = Comparer<K>.Default;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ public V Lookup(K key)

private sealed class ConstantSplittableMap : global::Windows.Foundation.Collections.IMapView<K, V>, global::System.Collections.Generic.IReadOnlyDictionary<K, V>
{
private class KeyValuePairComparator : IComparer<global::System.Collections.Generic.KeyValuePair<K, V>>
private sealed class KeyValuePairComparator : IComparer<global::System.Collections.Generic.KeyValuePair<K, V>>
{
private static readonly IComparer<K> keyComparator = Comparer<K>.Default;

Expand Down
2 changes: 1 addition & 1 deletion src/WinRT.Runtime/Projections/IReadOnlyList.net5.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static void DisposeAbi(IntPtr abi) =>

public static string GetGuidSignature() => GuidGenerator.GetSignature(typeof(IReadOnlyList<T>));

public class FromAbiHelper : global::System.Collections.Generic.IReadOnlyList<T>
public sealed class FromAbiHelper : global::System.Collections.Generic.IReadOnlyList<T>
{
private readonly global::Windows.Foundation.Collections.IVectorView<T> _vectorView;
private readonly global::System.Collections.Generic.IEnumerable<T> _enumerable;
Expand Down
2 changes: 1 addition & 1 deletion src/WinRT.Runtime/Projections/IReferenceArray.net5.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ private static unsafe int Do_Abi_get_Value_0(IntPtr thisPtr, out int ____return_

[global::WinRT.ObjectReferenceWrapper(nameof(_obj))]
[Guid("61C17707-2D65-11E0-9AE8-D48564015472")]
internal class IReferenceArray<T> : global::Windows.Foundation.IReferenceArray<T>
internal sealed class IReferenceArray<T> : global::Windows.Foundation.IReferenceArray<T>
{
public static IObjectReference CreateMarshaler(object value)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ private static unsafe int Do_Abi_get_Value_0(IntPtr thisPtr, out int ____return_

[global::WinRT.ObjectReferenceWrapper(nameof(_obj))]
[Guid("61C17707-2D65-11E0-9AE8-D48564015472")]
internal class IReferenceArray<T> : global::Windows.Foundation.IReferenceArray<T>
internal sealed class IReferenceArray<T> : global::Windows.Foundation.IReferenceArray<T>
{
public static IObjectReference CreateMarshaler(object value)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public unsafe int OldStartingIndex

[global::WinRT.ObjectReferenceWrapper(nameof(_obj))]
[Guid("5108EBA4-4892-5A20-8374-A96815E0FD27")]
internal unsafe sealed class WinRTNotifyCollectionChangedEventArgsRuntimeClassFactory
internal sealed unsafe class WinRTNotifyCollectionChangedEventArgsRuntimeClassFactory
{
[Guid("5108EBA4-4892-5A20-8374-A96815E0FD27")]
[StructLayout(LayoutKind.Sequential)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ public static unsafe IObjectReference CreateMarshaler(global::System.Collections

[global::WinRT.ObjectReferenceWrapper(nameof(_nativeDelegate))]
#if !NET
private class NativeDelegateWrapper
private sealed class NativeDelegateWrapper
#else
private class NativeDelegateWrapper : IWinRTObject
private sealed class NativeDelegateWrapper : IWinRTObject
#endif
{
private readonly ObjectReference<global::WinRT.Interop.IDelegateVftbl> _nativeDelegate;
Expand Down
4 changes: 2 additions & 2 deletions src/WinRT.Runtime/Projections/PropertyChangedEventHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ public static unsafe IObjectReference CreateMarshaler(global::System.ComponentMo

[global::WinRT.ObjectReferenceWrapper(nameof(_nativeDelegate))]
#if !NET
private class NativeDelegateWrapper
private sealed class NativeDelegateWrapper
#else
private class NativeDelegateWrapper : IWinRTObject
private sealed class NativeDelegateWrapper : IWinRTObject
#endif
{
private readonly ObjectReference<global::WinRT.Interop.IDelegateVftbl> _nativeDelegate;
Expand Down
Loading