Skip to content

Commit

Permalink
Suppress incorrect CA2257 warnings (#1509)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergio0694 authored Feb 21, 2024
1 parent a71ce9a commit 380d66a
Show file tree
Hide file tree
Showing 12 changed files with 69 additions and 23 deletions.
40 changes: 25 additions & 15 deletions src/WinRT.Runtime/Projections/Bindable.net5.cs
Original file line number Diff line number Diff line change
Expand Up @@ -391,9 +391,11 @@ static class IEnumerableMethods
[Guid("036D2C08-DF29-41AF-8AA2-D774BE62BA6F")]
internal unsafe interface IEnumerable : global::System.Collections.IEnumerable, global::Microsoft.UI.Xaml.Interop.IBindableIterable
{
public static string GetGuidSignature() => GuidGenerator.GetSignature(typeof(IEnumerable));

public sealed class AdaptiveFromAbiHelper : FromAbiHelper, global::System.Collections.IEnumerable
public static string GetGuidSignature() => GuidGenerator.GetSignature(typeof(IEnumerable));

#pragma warning disable CA2257 // This member is a type (so it cannot be invoked)
public sealed class AdaptiveFromAbiHelper : FromAbiHelper, global::System.Collections.IEnumerable
#pragma warning restore CA2257
{
private readonly Func<IWinRTObject, global::System.Collections.IEnumerator> _enumerator;

Expand All @@ -410,9 +412,11 @@ public AdaptiveFromAbiHelper(Type runtimeType, IWinRTObject winRTObject)
}

public override global::System.Collections.IEnumerator GetEnumerator() => _enumerator != null ? _enumerator(_winrtObject) : base.GetEnumerator();
}

public class FromAbiHelper : global::System.Collections.IEnumerable
}

#pragma warning disable CA2257 // This member is a type (so it cannot be invoked)
public class FromAbiHelper : global::System.Collections.IEnumerable
#pragma warning restore CA2257
{
private readonly global::System.Collections.IEnumerable _iterable;
protected readonly IWinRTObject _winrtObject;
Expand Down Expand Up @@ -447,9 +451,11 @@ private sealed class NonGenericToGenericIterator : global::Windows.Foundation.Co
public bool _MoveNext() { return iterator.MoveNext(); }
public uint GetMany(ref object[] items) => throw new NotSupportedException();
}
}

public sealed class ToAbiHelper : IBindableIterable
}

#pragma warning disable CA2257 // This member is a type (so it cannot be invoked)
public sealed class ToAbiHelper : IBindableIterable
#pragma warning restore CA2257
{
private readonly IEnumerable m_enumerable;

Expand Down Expand Up @@ -563,9 +569,11 @@ static class IListMethods
[Guid("393DE7DE-6FD0-4C0D-BB71-47244A113E93")]
internal unsafe interface IList : global::System.Collections.IList, global::Microsoft.UI.Xaml.Interop.IBindableVector
{
public static string GetGuidSignature() => GuidGenerator.GetSignature(typeof(IList));

public sealed class FromAbiHelper : global::System.Collections.IList
public static string GetGuidSignature() => GuidGenerator.GetSignature(typeof(IList));

#pragma warning disable CA2257 // This member is a type (so it cannot be invoked)
public sealed class FromAbiHelper : global::System.Collections.IList
#pragma warning restore CA2257
{
private readonly global::Microsoft.UI.Xaml.Interop.IBindableVector _vector;

Expand Down Expand Up @@ -799,9 +807,11 @@ public IEnumerator GetEnumerator()
{
return ((IEnumerable)(IWinRTObject)_vector).GetEnumerator();
}
}

public sealed class ToAbiHelper : IBindableVector
}

#pragma warning disable CA2257 // This member is a type (so it cannot be invoked)
public sealed class ToAbiHelper : IBindableVector
#pragma warning restore CA2257
{
private global::System.Collections.IList _list;

Expand Down
6 changes: 4 additions & 2 deletions src/WinRT.Runtime/Projections/ICommand.net5.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ static class ICommandMethods
[DynamicInterfaceCastableImplementation]
internal unsafe interface ICommand : global::System.Windows.Input.ICommand
{
[Guid("E5AF3542-CA67-4081-995B-709DD13792DF")]
public struct Vftbl
[Guid("E5AF3542-CA67-4081-995B-709DD13792DF")]
#pragma warning disable CA2257 // This member is a type (so it cannot be invoked)
public struct Vftbl
#pragma warning restore CA2257
{
internal IInspectable.Vftbl IInspectableVftbl;
private void* _add_CanExecuteChanged_0;
Expand Down
4 changes: 4 additions & 0 deletions src/WinRT.Runtime/Projections/IDictionary.net5.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1094,7 +1094,9 @@ public static void DisposeAbi(IntPtr abi) =>

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

#pragma warning disable CA2257 // This member is a type (so it cannot be invoked)
public sealed class ToAbiHelper : global::Windows.Foundation.Collections.IMap<K, V>
#pragma warning restore CA2257
{
private readonly global::System.Collections.Generic.IDictionary<K, V> _dictionary;

Expand Down Expand Up @@ -1184,7 +1186,9 @@ static void InitFallbackCCWVTableIfNeeded()
// This is left here for backwards compat purposes where older generated
// projections can be using FindVftblType and using this to cast.
[Guid("3C2925FE-8519-45C1-AA79-197B6718C1C1")]
#pragma warning disable CA2257 // This member is a type (so it cannot be invoked)
public unsafe struct Vftbl
#pragma warning restore CA2257
{
internal IInspectable.Vftbl IInspectableVftbl;

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

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

#pragma warning disable CA2257 // This member is a type (so it cannot be invoked)
internal sealed class ToAbiHelper : global::Windows.Foundation.Collections.IIterable<T>
#pragma warning restore CA2257
{
private readonly IEnumerable<T> m_enumerable;

Expand Down Expand Up @@ -389,7 +391,9 @@ static void InitFallbackCCWVTableIfNeeded()
// This is left here for backwards compat purposes where older generated
// projections can be using FindVftblType and using this to cast.
[Guid("FAA585EA-6214-4217-AFDA-7F46DE5869B3")]
#pragma warning disable CA2257 // This member is a type (so it cannot be invoked)
public unsafe struct Vftbl
#pragma warning restore CA2257
{
internal IInspectable.Vftbl IInspectableVftbl;

Expand Down Expand Up @@ -938,7 +942,9 @@ public static void DisposeAbi(IntPtr abi) =>
// In IEnumerator<> scenarios, we use this as a helper for the implementation and don't actually use it to
// create a CCW.
[global::WinRT.WinRTExposedType(typeof(IBindableIteratorTypeDetails))]
#pragma warning disable CA2257 // This member is a type (so it cannot be invoked)
public sealed class ToAbiHelper : global::Windows.Foundation.Collections.IIterator<T>, global::Microsoft.UI.Xaml.Interop.IBindableIterator
#pragma warning restore CA2257
{
private readonly global::System.Collections.Generic.IEnumerator<T> m_enumerator;
private bool m_firstItem = true;
Expand Down Expand Up @@ -1064,7 +1070,9 @@ static void InitFallbackCCWVTableIfNeeded()
// This is left here for backwards compat purposes where older generated
// projections can be using FindVftblType and using this to cast.
[Guid("6A79E863-4300-459A-9966-CBB660963EE1")]
#pragma warning disable CA2257 // This member is a type (so it cannot be invoked)
public unsafe struct Vftbl
#pragma warning restore CA2257
{
internal IInspectable.Vftbl IInspectableVftbl;

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

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

#pragma warning disable CA2257 // This member is a type (so it cannot be invoked)
public sealed class ToAbiHelper : global::Windows.Foundation.Collections.IVector<T>
#pragma warning restore CA2257
{
private readonly global::System.Collections.Generic.IList<T> _list;

Expand Down Expand Up @@ -1308,7 +1310,9 @@ static void InitFallbackCCWVTableIfNeeded()
// This is left here for backwards compat purposes where older generated
// projections can be using FindVftblType and using this to cast.
[Guid("913337E9-11A1-4345-A3A2-4E7F956E222D")]
#pragma warning disable CA2257 // This member is a type (so it cannot be invoked)
public unsafe struct Vftbl
#pragma warning restore CA2257
{
internal IInspectable.Vftbl IInspectableVftbl;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@ public static unsafe (Action<global::System.Collections.Specialized.NotifyCollec
[Guid("530155E1-28A5-5693-87CE-30724D95A06D")]
internal unsafe interface INotifyCollectionChanged : global::System.Collections.Specialized.INotifyCollectionChanged
{
[Guid("530155E1-28A5-5693-87CE-30724D95A06D")]
public struct Vftbl
[Guid("530155E1-28A5-5693-87CE-30724D95A06D")]
#pragma warning disable CA2257 // This member is a type (so it cannot be invoked)
public struct Vftbl
#pragma warning restore CA2257
{
internal IInspectable.Vftbl IInspectableVftbl;

Expand Down
6 changes: 4 additions & 2 deletions src/WinRT.Runtime/Projections/INotifyDataErrorInfo.net5.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ static class INotifyDataErrorInfoMethods
[Guid("0EE6C2CC-273E-567D-BC0A-1DD87EE51EBA")]
internal unsafe interface INotifyDataErrorInfo : global::System.ComponentModel.INotifyDataErrorInfo
{
[Guid("0EE6C2CC-273E-567D-BC0A-1DD87EE51EBA")]
public struct Vftbl
[Guid("0EE6C2CC-273E-567D-BC0A-1DD87EE51EBA")]
#pragma warning disable CA2257 // This member is a type (so it cannot be invoked)
public struct Vftbl
#pragma warning restore CA2247
{
internal IInspectable.Vftbl IInspectableVftbl;
public delegate* unmanaged<IntPtr, byte*, int> get_HasErrors_0;
Expand Down
6 changes: 4 additions & 2 deletions src/WinRT.Runtime/Projections/INotifyPropertyChanged.net5.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ static class INotifyPropertyChangedMethods
internal unsafe interface INotifyPropertyChanged : global::System.ComponentModel.INotifyPropertyChanged
{
[Guid("90B17601-B065-586E-83D9-9ADC3A695284")]
[StructLayout(LayoutKind.Sequential)]
public struct Vftbl
[StructLayout(LayoutKind.Sequential)]
#pragma warning disable CA2257 // This member is a type (so it cannot be invoked)
public struct Vftbl
#pragma warning restore CA2257
{
internal IInspectable.Vftbl IInspectableVftbl;

Expand Down
2 changes: 2 additions & 0 deletions src/WinRT.Runtime/Projections/IPropertyValue.net5.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1292,7 +1292,9 @@ private static unsafe int Do_Abi_get_Type_0(IntPtr thisPtr, global::Windows.Foun
internal unsafe interface IPropertyValue : global::Windows.Foundation.IPropertyValue
{
[Guid("4BD682DD-7554-40E9-9A9B-82654EDE7E62")]
#pragma warning disable CA2257 // This member is a type (so it cannot be invoked)
public struct Vftbl
#pragma warning restore CA2257
{
internal IInspectable.Vftbl IInspectableVftbl;
internal void* _get_Type_0;
Expand Down
4 changes: 4 additions & 0 deletions src/WinRT.Runtime/Projections/IReadOnlyDictionary.net5.cs
Original file line number Diff line number Diff line change
Expand Up @@ -978,7 +978,9 @@ public static void DisposeAbi(IntPtr abi) =>

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

#pragma warning disable CA2257 // This member is a type (so it cannot be invoked)
public sealed class ToAbiHelper : global::Windows.Foundation.Collections.IMapView<K, V>
#pragma warning restore CA2257
{
private readonly global::System.Collections.Generic.IReadOnlyDictionary<K, V> _dictionary;

Expand Down Expand Up @@ -1053,7 +1055,9 @@ static void InitFallbackCCWVTableIfNeeded()
// This is left here for backwards compat purposes where older generated
// projections can be using FindVftblType and using this to cast.
[Guid("E480CE40-A338-4ADA-ADCF-272272E48CB9")]
#pragma warning disable CA2257 // This member is a type (so it cannot be invoked)
public unsafe struct Vftbl
#pragma warning restore CA2257
{
internal IInspectable.Vftbl IInspectableVftbl;

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

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

#pragma warning disable CA2257 // This member is a type (so it cannot be invoked)
public sealed class ToAbiHelper : global::Windows.Foundation.Collections.IVectorView<T>
#pragma warning restore CA2257
{
private readonly global::System.Collections.Generic.IReadOnlyList<T> _list;

Expand Down Expand Up @@ -630,7 +632,9 @@ static void InitFallbackCCWVTableIfNeeded()
// This is left here for backwards compat purposes where older generated
// projections can be using FindVftblType and using this to cast.
[Guid("BBE1FA4C-B0E3-4583-BAEF-1F1B2E483E56")]
#pragma warning disable CA2257 // This member is a type (so it cannot be invoked)
public unsafe struct Vftbl
#pragma warning restore CA2257
{
internal IInspectable.Vftbl IInspectableVftbl;

Expand Down
2 changes: 2 additions & 0 deletions src/WinRT.Runtime/Projections/IServiceProvider.net5.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ namespace ABI.System
internal unsafe interface IServiceProvider : global::System.IServiceProvider
{
[Guid("68B3A2DF-8173-539F-B524-C8A2348F5AFB")]
#pragma warning disable CA2257 // This member is a type (so it cannot be invoked)
public struct Vftbl
#pragma warning restore CA2257
{
internal IInspectable.Vftbl IInspectableVftbl;

Expand Down

0 comments on commit 380d66a

Please sign in to comment.