Enable IDE0170 (Simplify property pattern) and IDE0200 (remove unnecessary lambda expression) (#71011)

As part of updating the config file with recently added rules, also turn on a few of them.
This commit is contained in:
Stephen Toub 2022-06-28 14:46:45 -04:00 committed by GitHub
parent 14f993e9e0
commit 9f7bf79991
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
58 changed files with 138 additions and 139 deletions

View File

@ -1445,9 +1445,6 @@ dotnet_diagnostic.IDE0048.severity = silent
# IDE0049: Use language keywords instead of framework type names for type references # IDE0049: Use language keywords instead of framework type names for type references
dotnet_diagnostic.IDE0049.severity = warning dotnet_diagnostic.IDE0049.severity = warning
# IDE0050: Convert anonymous type to tuple
dotnet_diagnostic.IDE0050.severity = suggestion
# IDE0051: Remove unused private members # IDE0051: Remove unused private members
dotnet_diagnostic.IDE0051.severity = suggestion dotnet_diagnostic.IDE0051.severity = suggestion
@ -1569,6 +1566,27 @@ dotnet_diagnostic.IDE0160.severity = silent
# IDE0161: Convert to file-scoped namespace # IDE0161: Convert to file-scoped namespace
dotnet_diagnostic.IDE0161.severity = silent dotnet_diagnostic.IDE0161.severity = silent
# IDE0170: Simplify property pattern
dotnet_diagnostic.IDE0170.severity = warning
# IDE0180: Use tuple swap
dotnet_diagnostic.IDE0180.severity = suggestion
# IDE0200: Remove unnecessary lambda expression
dotnet_diagnostic.IDE0200.severity = warning
# IDE0210: Use top-level statements
dotnet_diagnostic.IDE0210.severity = silent
# IDE0211: Use program main
dotnet_diagnostic.IDE0211.severity = silent
# IDE0220: foreach cast
dotnet_diagnostic.IDE0220.severity = silent
# IDE0230: Use UTF8 string literal
dotnet_diagnostic.IDE0230.severity = suggestion
# IDE1005: Delegate invocation can be simplified. # IDE1005: Delegate invocation can be simplified.
dotnet_diagnostic.IDE1005.severity = warning dotnet_diagnostic.IDE1005.severity = warning

View File

@ -1440,9 +1440,6 @@ dotnet_diagnostic.IDE0048.severity = silent
# IDE0049: Use language keywords instead of framework type names for type references # IDE0049: Use language keywords instead of framework type names for type references
dotnet_diagnostic.IDE0049.severity = silent dotnet_diagnostic.IDE0049.severity = silent
# IDE0050: Convert anonymous type to tuple
dotnet_diagnostic.IDE0050.severity = silent
# IDE0051: Remove unused private members # IDE0051: Remove unused private members
dotnet_diagnostic.IDE0051.severity = silent dotnet_diagnostic.IDE0051.severity = silent
@ -1563,6 +1560,27 @@ dotnet_diagnostic.IDE0160.severity = silent
# IDE0161: Convert to file-scoped namespace # IDE0161: Convert to file-scoped namespace
dotnet_diagnostic.IDE0161.severity = silent dotnet_diagnostic.IDE0161.severity = silent
# IDE0170: Simplify property pattern
dotnet_diagnostic.IDE0170.severity = silent
# IDE0180: Use tuple swap
dotnet_diagnostic.IDE0180.severity = silent
# IDE0200: Remove unnecessary lambda expression
dotnet_diagnostic.IDE0200.severity = silent
# IDE0210: Use top-level statements
dotnet_diagnostic.IDE0210.severity = silent
# IDE0211: Use program main
dotnet_diagnostic.IDE0211.severity = silent
# IDE0220: foreach cast
dotnet_diagnostic.IDE0220.severity = silent
# IDE0230: Use UTF8 string literal
dotnet_diagnostic.IDE0230.severity = silent
# IDE1005: Delegate invocation can be simplified. # IDE1005: Delegate invocation can be simplified.
dotnet_diagnostic.IDE1005.severity = silent dotnet_diagnostic.IDE1005.severity = silent

View File

@ -57,7 +57,7 @@ namespace System.Runtime.InteropServices
[RequiresDynamicCode("Marshalling code for the object might not be available")] [RequiresDynamicCode("Marshalling code for the object might not be available")]
public static byte ReadByte(object ptr, int ofs) public static byte ReadByte(object ptr, int ofs)
{ {
return ReadValueSlow(ptr, ofs, (IntPtr nativeHome, int offset) => ReadByte(nativeHome, offset)); return ReadValueSlow(ptr, ofs, ReadByte);
} }
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
@ -65,7 +65,7 @@ namespace System.Runtime.InteropServices
[RequiresDynamicCode("Marshalling code for the object might not be available")] [RequiresDynamicCode("Marshalling code for the object might not be available")]
public static short ReadInt16(object ptr, int ofs) public static short ReadInt16(object ptr, int ofs)
{ {
return ReadValueSlow(ptr, ofs, (IntPtr nativeHome, int offset) => ReadInt16(nativeHome, offset)); return ReadValueSlow(ptr, ofs, ReadInt16);
} }
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
@ -73,7 +73,7 @@ namespace System.Runtime.InteropServices
[RequiresDynamicCode("Marshalling code for the object might not be available")] [RequiresDynamicCode("Marshalling code for the object might not be available")]
public static int ReadInt32(object ptr, int ofs) public static int ReadInt32(object ptr, int ofs)
{ {
return ReadValueSlow(ptr, ofs, (IntPtr nativeHome, int offset) => ReadInt32(nativeHome, offset)); return ReadValueSlow(ptr, ofs, ReadInt32);
} }
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
@ -83,7 +83,7 @@ namespace System.Runtime.InteropServices
public static long ReadInt64([MarshalAs(UnmanagedType.AsAny), In] object ptr, int ofs) public static long ReadInt64([MarshalAs(UnmanagedType.AsAny), In] object ptr, int ofs)
#pragma warning restore CS0618 // Type or member is obsolete #pragma warning restore CS0618 // Type or member is obsolete
{ {
return ReadValueSlow(ptr, ofs, (IntPtr nativeHome, int offset) => ReadInt64(nativeHome, offset)); return ReadValueSlow(ptr, ofs, ReadInt64);
} }
/// <summary>Read value from marshaled object (marshaled using AsAny).</summary> /// <summary>Read value from marshaled object (marshaled using AsAny).</summary>
@ -125,7 +125,7 @@ namespace System.Runtime.InteropServices
[RequiresDynamicCode("Marshalling code for the object might not be available")] [RequiresDynamicCode("Marshalling code for the object might not be available")]
public static void WriteByte(object ptr, int ofs, byte val) public static void WriteByte(object ptr, int ofs, byte val)
{ {
WriteValueSlow(ptr, ofs, val, (IntPtr nativeHome, int offset, byte value) => WriteByte(nativeHome, offset, value)); WriteValueSlow(ptr, ofs, val, WriteByte);
} }
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
@ -133,7 +133,7 @@ namespace System.Runtime.InteropServices
[RequiresDynamicCode("Marshalling code for the object might not be available")] [RequiresDynamicCode("Marshalling code for the object might not be available")]
public static void WriteInt16(object ptr, int ofs, short val) public static void WriteInt16(object ptr, int ofs, short val)
{ {
WriteValueSlow(ptr, ofs, val, (IntPtr nativeHome, int offset, short value) => Marshal.WriteInt16(nativeHome, offset, value)); WriteValueSlow(ptr, ofs, val, Marshal.WriteInt16);
} }
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
@ -141,7 +141,7 @@ namespace System.Runtime.InteropServices
[RequiresDynamicCode("Marshalling code for the object might not be available")] [RequiresDynamicCode("Marshalling code for the object might not be available")]
public static void WriteInt32(object ptr, int ofs, int val) public static void WriteInt32(object ptr, int ofs, int val)
{ {
WriteValueSlow(ptr, ofs, val, (IntPtr nativeHome, int offset, int value) => Marshal.WriteInt32(nativeHome, offset, value)); WriteValueSlow(ptr, ofs, val, Marshal.WriteInt32);
} }
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
@ -149,7 +149,7 @@ namespace System.Runtime.InteropServices
[RequiresDynamicCode("Marshalling code for the object might not be available")] [RequiresDynamicCode("Marshalling code for the object might not be available")]
public static void WriteInt64(object ptr, int ofs, long val) public static void WriteInt64(object ptr, int ofs, long val)
{ {
WriteValueSlow(ptr, ofs, val, (IntPtr nativeHome, int offset, long value) => Marshal.WriteInt64(nativeHome, offset, value)); WriteValueSlow(ptr, ofs, val, Marshal.WriteInt64);
} }
/// <summary> /// <summary>

View File

@ -31,8 +31,8 @@ internal static partial class Interop
// wrong endianness here), DER encode it, then use the DER reader to skip past the tag // wrong endianness here), DER encode it, then use the DER reader to skip past the tag
// and length. // and length.
byte[] derEncoded = OpenSslEncode( byte[] derEncoded = OpenSslEncode(
handle => GetAsn1IntegerDerSize(handle), GetAsn1IntegerDerSize,
(handle, buf) => EncodeAsn1Integer(handle, buf), EncodeAsn1Integer,
asn1Integer); asn1Integer);
try try

View File

@ -20,7 +20,7 @@ internal static partial class Interop
internal static int ResolveRequiredNid(string oid) internal static int ResolveRequiredNid(string oid)
{ {
return s_nidLookup.GetOrAdd(oid, s => LookupNid(s)); return s_nidLookup.GetOrAdd(oid, LookupNid);
} }
private static int LookupNid(string oid) private static int LookupNid(string oid)

View File

@ -107,25 +107,25 @@ internal static partial class Interop
internal static byte[] GetAsn1StringBytes(IntPtr asn1) internal static byte[] GetAsn1StringBytes(IntPtr asn1)
{ {
return GetDynamicBuffer((ptr, buf, i) => GetAsn1StringBytes(ptr, buf, i), asn1); return GetDynamicBuffer(GetAsn1StringBytes, asn1);
} }
internal static byte[] GetX509Thumbprint(SafeX509Handle x509) internal static byte[] GetX509Thumbprint(SafeX509Handle x509)
{ {
return GetDynamicBuffer((handle, buf, i) => GetX509Thumbprint(handle, buf, i), x509); return GetDynamicBuffer(GetX509Thumbprint, x509);
} }
internal static X500DistinguishedName LoadX500Name(IntPtr namePtr) internal static X500DistinguishedName LoadX500Name(IntPtr namePtr)
{ {
CheckValidOpenSslHandle(namePtr); CheckValidOpenSslHandle(namePtr);
byte[] buf = GetDynamicBuffer((ptr, buf1, i) => GetX509NameRawBytes(ptr, buf1, i), namePtr); byte[] buf = GetDynamicBuffer(GetX509NameRawBytes, namePtr);
return new X500DistinguishedName(buf); return new X500DistinguishedName(buf);
} }
internal static byte[] GetX509PublicKeyParameterBytes(SafeX509Handle x509) internal static byte[] GetX509PublicKeyParameterBytes(SafeX509Handle x509)
{ {
return GetDynamicBuffer((handle, buf, i) => GetX509PublicKeyParameterBytes(handle, buf, i), x509); return GetDynamicBuffer(GetX509PublicKeyParameterBytes, x509);
} }
internal static void X509StoreSetVerifyTime(SafeX509StoreHandle ctx, DateTime verifyTime) internal static void X509StoreSetVerifyTime(SafeX509StoreHandle ctx, DateTime verifyTime)

View File

@ -10,7 +10,7 @@ internal static partial class Interop
{ {
internal static ArraySegment<byte> RentAsn1StringBytes(IntPtr asn1) internal static ArraySegment<byte> RentAsn1StringBytes(IntPtr asn1)
{ {
return RentDynamicBuffer((ptr, buf, i) => GetAsn1StringBytes(ptr, buf, i), asn1); return RentDynamicBuffer(GetAsn1StringBytes, asn1);
} }
private static ArraySegment<byte> RentDynamicBuffer<THandle>(NegativeSizeReadMethod<THandle> method, THandle handle) private static ArraySegment<byte> RentDynamicBuffer<THandle>(NegativeSizeReadMethod<THandle> method, THandle handle)

View File

@ -90,7 +90,7 @@ internal static partial class Interop
CheckValidOpenSslHandle(x); CheckValidOpenSslHandle(x);
return SafeInteriorHandle.OpenInteriorHandle( return SafeInteriorHandle.OpenInteriorHandle(
handle => X509GetSerialNumber_private(handle), X509GetSerialNumber_private,
x); x);
} }
@ -117,7 +117,7 @@ internal static partial class Interop
CheckValidOpenSslHandle(x); CheckValidOpenSslHandle(x);
return SafeInteriorHandle.OpenInteriorHandle( return SafeInteriorHandle.OpenInteriorHandle(
(handle, arg) => CryptoNative_X509FindExtensionData(handle, arg), CryptoNative_X509FindExtensionData,
x, x,
extensionNid); extensionNid);
} }

View File

@ -24,7 +24,7 @@ internal static partial class Interop
{ {
CheckValidOpenSslHandle(namePtr); CheckValidOpenSslHandle(namePtr);
byte[] buf = GetDynamicBuffer((ptr, buf1, i) => GetX509NameRawBytes(ptr, buf1, i), namePtr); byte[] buf = GetDynamicBuffer(GetX509NameRawBytes, namePtr);
return new X500DistinguishedName(buf); return new X500DistinguishedName(buf);
} }
@ -33,7 +33,7 @@ internal static partial class Interop
CheckValidOpenSslHandle(sk); CheckValidOpenSslHandle(sk);
return SafeInteriorHandle.OpenInteriorHandle( return SafeInteriorHandle.OpenInteriorHandle(
(handle, i) => GetX509NameStackField_private(handle, i), GetX509NameStackField_private,
sk, sk,
loc); loc);
} }

View File

@ -61,7 +61,7 @@ internal static partial class Interop
internal static SafeSharedX509StackHandle X509StoreCtxGetSharedUntrusted(SafeX509StoreCtxHandle ctx) internal static SafeSharedX509StackHandle X509StoreCtxGetSharedUntrusted(SafeX509StoreCtxHandle ctx)
{ {
return SafeInteriorHandle.OpenInteriorHandle( return SafeInteriorHandle.OpenInteriorHandle(
x => X509StoreCtxGetSharedUntrusted_private(x), X509StoreCtxGetSharedUntrusted_private,
ctx); ctx);
} }
} }

View File

@ -33,7 +33,7 @@ namespace System.Security.Cryptography
hashAlgorithm, hashAlgorithm,
secretPrepend, secretPrepend,
secretAppend, secretAppend,
(pubKey, hasher) => DeriveSecretAgreement(pubKey, hasher)); DeriveSecretAgreement);
} }
public override byte[] DeriveKeyFromHmac( public override byte[] DeriveKeyFromHmac(
@ -54,7 +54,7 @@ namespace System.Security.Cryptography
hmacKey, hmacKey,
secretPrepend, secretPrepend,
secretAppend, secretAppend,
(pubKey, hasher) => DeriveSecretAgreement(pubKey, hasher)); DeriveSecretAgreement);
} }
public override byte[] DeriveKeyTls(ECDiffieHellmanPublicKey otherPartyPublicKey, byte[] prfLabel, byte[] prfSeed) public override byte[] DeriveKeyTls(ECDiffieHellmanPublicKey otherPartyPublicKey, byte[] prfLabel, byte[] prfSeed)
@ -69,7 +69,7 @@ namespace System.Security.Cryptography
otherPartyPublicKey, otherPartyPublicKey,
prfLabel, prfLabel,
prfSeed, prfSeed,
(pubKey, hasher) => DeriveSecretAgreement(pubKey, hasher)); DeriveSecretAgreement);
} }
/// <summary> /// <summary>

View File

@ -30,7 +30,7 @@ namespace System.Security.Cryptography
hashAlgorithm, hashAlgorithm,
secretPrepend, secretPrepend,
secretAppend, secretAppend,
(pubKey, hasher) => DeriveSecretAgreement(pubKey, hasher)); DeriveSecretAgreement);
} }
public override byte[] DeriveKeyFromHmac( public override byte[] DeriveKeyFromHmac(
@ -51,7 +51,7 @@ namespace System.Security.Cryptography
hmacKey, hmacKey,
secretPrepend, secretPrepend,
secretAppend, secretAppend,
(pubKey, hasher) => DeriveSecretAgreement(pubKey, hasher)); DeriveSecretAgreement);
} }
public override byte[] DeriveKeyTls(ECDiffieHellmanPublicKey otherPartyPublicKey, byte[] prfLabel, byte[] prfSeed) public override byte[] DeriveKeyTls(ECDiffieHellmanPublicKey otherPartyPublicKey, byte[] prfLabel, byte[] prfSeed)
@ -66,7 +66,7 @@ namespace System.Security.Cryptography
otherPartyPublicKey, otherPartyPublicKey,
prfLabel, prfLabel,
prfSeed, prfSeed,
(pubKey, hasher) => DeriveSecretAgreement(pubKey, hasher)); DeriveSecretAgreement);
} }
/// <summary> /// <summary>

View File

@ -136,7 +136,7 @@ namespace System.Security.Cryptography
hashAlgorithm, hashAlgorithm,
secretPrepend, secretPrepend,
secretAppend, secretAppend,
(pubKey, hasher) => DeriveSecretAgreement(pubKey, hasher)); DeriveSecretAgreement);
} }
public override byte[] DeriveKeyFromHmac( public override byte[] DeriveKeyFromHmac(
@ -157,7 +157,7 @@ namespace System.Security.Cryptography
hmacKey, hmacKey,
secretPrepend, secretPrepend,
secretAppend, secretAppend,
(pubKey, hasher) => DeriveSecretAgreement(pubKey, hasher)); DeriveSecretAgreement);
} }
public override byte[] DeriveKeyTls(ECDiffieHellmanPublicKey otherPartyPublicKey, byte[] prfLabel, byte[] prfSeed) public override byte[] DeriveKeyTls(ECDiffieHellmanPublicKey otherPartyPublicKey, byte[] prfLabel, byte[] prfSeed)
@ -172,7 +172,7 @@ namespace System.Security.Cryptography
otherPartyPublicKey, otherPartyPublicKey,
prfLabel, prfLabel,
prfSeed, prfSeed,
(pubKey, hasher) => DeriveSecretAgreement(pubKey, hasher)); DeriveSecretAgreement);
} }
private byte[]? DeriveSecretAgreement(ECDiffieHellmanPublicKey otherPartyPublicKey, IncrementalHash? hasher) private byte[]? DeriveSecretAgreement(ECDiffieHellmanPublicKey otherPartyPublicKey, IncrementalHash? hasher)

View File

@ -120,7 +120,7 @@ namespace Microsoft.Extensions.Configuration
IConfigurationProvider provider = source.Build(this); IConfigurationProvider provider = source.Build(this);
provider.Load(); provider.Load();
_changeTokenRegistrations.Add(ChangeToken.OnChange(() => provider.GetReloadToken(), () => RaiseChanged())); _changeTokenRegistrations.Add(ChangeToken.OnChange(provider.GetReloadToken, RaiseChanged));
_providerManager.AddProvider(provider); _providerManager.AddProvider(provider);
RaiseChanged(); RaiseChanged();
@ -143,7 +143,7 @@ namespace Microsoft.Extensions.Configuration
foreach (IConfigurationProvider p in newProvidersList) foreach (IConfigurationProvider p in newProvidersList)
{ {
p.Load(); p.Load();
_changeTokenRegistrations.Add(ChangeToken.OnChange(() => p.GetReloadToken(), () => RaiseChanged())); _changeTokenRegistrations.Add(ChangeToken.OnChange(p.GetReloadToken, RaiseChanged));
} }
_providerManager.ReplaceProviders(newProvidersList); _providerManager.ReplaceProviders(newProvidersList);

View File

@ -30,7 +30,7 @@ namespace Microsoft.Extensions.Configuration
foreach (IConfigurationProvider p in providers) foreach (IConfigurationProvider p in providers)
{ {
p.Load(); p.Load();
_changeTokenRegistrations.Add(ChangeToken.OnChange(() => p.GetReloadToken(), () => RaiseChanged())); _changeTokenRegistrations.Add(ChangeToken.OnChange(p.GetReloadToken, RaiseChanged));
} }
} }

View File

@ -179,7 +179,7 @@ namespace Microsoft.Extensions.DependencyInjection.ServiceLookup
{ {
if (!_stackGuard.TryEnterOnCurrentStack()) if (!_stackGuard.TryEnterOnCurrentStack())
{ {
return _stackGuard.RunOnEmptyStack((type, chain) => CreateCallSite(type, chain), serviceType, callSiteChain); return _stackGuard.RunOnEmptyStack(CreateCallSite, serviceType, callSiteChain);
} }
// We need to lock the resolution process for a single service type at a time: // We need to lock the resolution process for a single service type at a time:

View File

@ -18,7 +18,7 @@ namespace Microsoft.Extensions.DependencyInjection.ServiceLookup
{ {
if (!_stackGuard.TryEnterOnCurrentStack()) if (!_stackGuard.TryEnterOnCurrentStack())
{ {
return _stackGuard.RunOnEmptyStack((c, a) => VisitCallSite(c, a), callSite, argument); return _stackGuard.RunOnEmptyStack(VisitCallSite, callSite, argument);
} }
switch (callSite.Cache.Location) switch (callSite.Cache.Location)

View File

@ -67,7 +67,7 @@ namespace Microsoft.Extensions.FileProviders
} }
_filters = filters; _filters = filters;
_fileWatcherFactory = () => CreateFileWatcher(); _fileWatcherFactory = CreateFileWatcher;
} }
/// <summary> /// <summary>

View File

@ -54,10 +54,7 @@ namespace Microsoft.Extensions.Hosting.WindowsServices
{ {
Logger.LogInformation("Application is shutting down..."); Logger.LogInformation("Application is shutting down...");
}); });
ApplicationLifetime.ApplicationStopped.Register(() => ApplicationLifetime.ApplicationStopped.Register(_delayStop.Set);
{
_delayStop.Set();
});
Thread thread = new Thread(Run); Thread thread = new Thread(Run);
thread.IsBackground = true; thread.IsBackground = true;

View File

@ -36,8 +36,8 @@ namespace Microsoft.Extensions.Options
void RegisterSource(IOptionsChangeTokenSource<TOptions> source) void RegisterSource(IOptionsChangeTokenSource<TOptions> source)
{ {
IDisposable registration = ChangeToken.OnChange( IDisposable registration = ChangeToken.OnChange(
() => source.GetChangeToken(), source.GetChangeToken,
(name) => InvokeChanged(name), InvokeChanged,
source.Name); source.Name);
_registrations.Add(registration); _registrations.Add(registration);

View File

@ -91,7 +91,7 @@ namespace System.ComponentModel.DataAnnotations
if (serviceProvider != null) if (serviceProvider != null)
{ {
IServiceProvider localServiceProvider = serviceProvider; IServiceProvider localServiceProvider = serviceProvider;
InitializeServiceProvider(serviceType => localServiceProvider.GetService(serviceType)); InitializeServiceProvider(localServiceProvider.GetService);
} }
_items = items != null ? new Dictionary<object, object?>(items) : new Dictionary<object, object?>(); _items = items != null ? new Dictionary<object, object?>(items) : new Dictionary<object, object?>();

View File

@ -151,7 +151,7 @@ namespace System.ComponentModel.Composition
Requires.NotNullOrNullElements(attributedParts, nameof(attributedParts)); Requires.NotNullOrNullElements(attributedParts, nameof(attributedParts));
CompositionBatch batch = new CompositionBatch( CompositionBatch batch = new CompositionBatch(
attributedParts.Select(attributedPart => AttributedModelServices.CreatePart(attributedPart)).ToArray(), attributedParts.Select(AttributedModelServices.CreatePart).ToArray(),
Enumerable.Empty<ComposablePart>()); Enumerable.Empty<ComposablePart>());
container.Compose(batch); container.Compose(batch);

View File

@ -69,7 +69,7 @@ namespace System.ComponentModel.Composition.Hosting
{ {
traversal.Initialize(); traversal.Initialize();
var traversalClosure = GetTraversalClosure(_innerCatalog.Where(_filter), traversal); var traversalClosure = GetTraversalClosure(_innerCatalog.Where(_filter), traversal);
return new FilteredCatalog(_innerCatalog, p => traversalClosure.Contains(p)); return new FilteredCatalog(_innerCatalog, traversalClosure.Contains);
} }
finally finally
{ {

View File

@ -47,7 +47,7 @@ namespace System.ComponentModel.Composition.ReflectionModel
if (disposable != null) if (disposable != null)
{ {
disposeAction = () => disposable.Dispose(); disposeAction = disposable.Dispose;
} }
else else
{ {

View File

@ -38,7 +38,7 @@ namespace System.ComponentModel.Composition.ReflectionModel
} }
Func<Export, object> exportFactoryFactory = (Func<Export, object>)Delegate.CreateDelegate(typeof(Func<Export, object>), this, genericMethod); Func<Export, object> exportFactoryFactory = (Func<Export, object>)Delegate.CreateDelegate(typeof(Func<Export, object>), this, genericMethod);
return (e) => exportFactoryFactory.Invoke(e); return exportFactoryFactory.Invoke;
} }
private object CreateStronglyTypedExportFactoryOfT<T>(Export export) private object CreateStronglyTypedExportFactoryOfT<T>(Export export)

View File

@ -126,7 +126,7 @@ namespace System.ComponentModel
_asyncOperation = AsyncOperationManager.CreateOperation(null); _asyncOperation = AsyncOperationManager.CreateOperation(null);
Task.Factory.StartNew( Task.Factory.StartNew(
arg => WorkerThreadStart(arg), WorkerThreadStart,
argument, argument,
CancellationToken.None, CancellationToken.None,
TaskCreationOptions.DenyChildAttach, TaskCreationOptions.DenyChildAttach,

View File

@ -28,7 +28,7 @@ namespace System.Composition.Hosting.Core
/// <summary> /// <summary>
/// Constant value provided so that subclasses can avoid creating additional duplicate values. /// Constant value provided so that subclasses can avoid creating additional duplicate values.
/// </summary> /// </summary>
protected static readonly Func<IEnumerable<CompositionDependency>> NoDependencies = () => Enumerable.Empty<CompositionDependency>(); protected static readonly Func<IEnumerable<CompositionDependency>> NoDependencies = Enumerable.Empty<CompositionDependency>;
/// <summary> /// <summary>
/// Promise export descriptors for the specified export key. /// Promise export descriptors for the specified export key.

View File

@ -46,7 +46,7 @@ namespace System.Composition.Hosting.Util
} }
var name = closedGenericType.Name.Substring(0, closedGenericType.Name.IndexOf('`')); var name = closedGenericType.Name.Substring(0, closedGenericType.Name.IndexOf('`'));
var args = closedGenericType.GenericTypeArguments.Select(t => Format(t)); var args = closedGenericType.GenericTypeArguments.Select(Format);
return $"{name}<{string.Join(", ", args)}>"; return $"{name}<{string.Join(", ", args)}>";
} }
} }

View File

@ -25,7 +25,7 @@ namespace System.Composition.Runtime.Util
Debug.Assert(closedGenericType.IsConstructedGenericType); Debug.Assert(closedGenericType.IsConstructedGenericType);
var name = closedGenericType.Name.Substring(0, closedGenericType.Name.IndexOf('`')); var name = closedGenericType.Name.Substring(0, closedGenericType.Name.IndexOf('`'));
IEnumerable<string> args = closedGenericType.GenericTypeArguments.Select(t => Format(t)); IEnumerable<string> args = closedGenericType.GenericTypeArguments.Select(Format);
return $"{name}<{string.Join(SR.Formatter_ListSeparatorWithSpace, args)}>"; return $"{name}<{string.Join(SR.Formatter_ListSeparatorWithSpace, args)}>";
} }
} }

View File

@ -35,7 +35,7 @@ namespace System.Data.Common
} }
// to support oracle types and other INUllable types that have static Null as field // to support oracle types and other INUllable types that have static Null as field
internal static object GetStaticNullForUdtType([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties | DynamicallyAccessedMemberTypes.PublicFields)] Type type) => s_typeToNull.GetOrAdd(type, t => GetStaticNullForUdtTypeCore(t)); internal static object GetStaticNullForUdtType([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties | DynamicallyAccessedMemberTypes.PublicFields)] Type type) => s_typeToNull.GetOrAdd(type, GetStaticNullForUdtTypeCore);
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2070:UnrecognizedReflectionPattern", [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2070:UnrecognizedReflectionPattern",
Justification = "The only callsite is marked with DynamicallyAccessedMembers. Workaround for https://github.com/mono/linker/issues/1981")] Justification = "The only callsite is marked with DynamicallyAccessedMembers. Workaround for https://github.com/mono/linker/issues/1981")]

View File

@ -118,7 +118,7 @@ namespace System.Data
private static IEnumerable<Type> GetPreviouslyDeclaredDataTypes(DataSet dataSet) private static IEnumerable<Type> GetPreviouslyDeclaredDataTypes(DataSet dataSet)
{ {
return (dataSet != null) return (dataSet != null)
? dataSet.Tables.Cast<DataTable>().SelectMany(table => GetPreviouslyDeclaredDataTypes(table)) ? dataSet.Tables.Cast<DataTable>().SelectMany(GetPreviouslyDeclaredDataTypes)
: Enumerable.Empty<Type>(); : Enumerable.Empty<Type>();
} }

View File

@ -67,7 +67,7 @@ namespace System.Diagnostics.Metrics
{ {
if (instrument is not null && !_disposed && !instrument.Meter.Disposed) if (instrument is not null && !_disposed && !instrument.Meter.Disposed)
{ {
_enabledMeasurementInstruments.AddIfNotExist(instrument, (instrument1, instrument2) => object.ReferenceEquals(instrument1, instrument2)); _enabledMeasurementInstruments.AddIfNotExist(instrument, object.ReferenceEquals);
oldState = instrument.EnableMeasurement(new ListenerSubscription(this, state), out oldStateStored); oldState = instrument.EnableMeasurement(new ListenerSubscription(this, state), out oldStateStored);
enabled = true; enabled = true;
} }
@ -98,7 +98,7 @@ namespace System.Diagnostics.Metrics
object? state = null; object? state = null;
lock (Instrument.SyncObject) lock (Instrument.SyncObject)
{ {
if (instrument is null || _enabledMeasurementInstruments.Remove(instrument, (instrument1, instrument2) => object.ReferenceEquals(instrument1, instrument2)) == default) if (instrument is null || _enabledMeasurementInstruments.Remove(instrument, object.ReferenceEquals) == default)
{ {
return default; return default;
} }

View File

@ -443,7 +443,7 @@ namespace System.Formats.Asn1
source, source,
ruleSet, ruleSet,
tmpDest, tmpDest,
(value, lastByte, dest) => CopyBitStringValue(value, lastByte, dest), CopyBitStringValue,
isIndefinite, isIndefinite,
out unusedBitCount, out unusedBitCount,
out bytesRead); out bytesRead);

View File

@ -44,7 +44,7 @@ namespace System.Net.Http
private static readonly StringWithQualityHeaderValue s_gzipHeaderValue = new StringWithQualityHeaderValue("gzip"); private static readonly StringWithQualityHeaderValue s_gzipHeaderValue = new StringWithQualityHeaderValue("gzip");
private static readonly StringWithQualityHeaderValue s_deflateHeaderValue = new StringWithQualityHeaderValue("deflate"); private static readonly StringWithQualityHeaderValue s_deflateHeaderValue = new StringWithQualityHeaderValue("deflate");
private static readonly Lazy<bool> s_supportsTls13 = new Lazy<bool>(() => CheckTls13Support()); private static readonly Lazy<bool> s_supportsTls13 = new Lazy<bool>(CheckTls13Support);
[ThreadStatic] [ThreadStatic]
private static StringBuilder? t_requestHeadersBuilder; private static StringBuilder? t_requestHeadersBuilder;

View File

@ -548,7 +548,7 @@ namespace System.Net
public static IWebProxy? DefaultWebProxy public static IWebProxy? DefaultWebProxy
{ {
get => LazyInitializer.EnsureInitialized<IWebProxy>(ref s_DefaultWebProxy, ref s_DefaultWebProxyInitialized, ref s_internalSyncObject, () => GetSystemWebProxy()); get => LazyInitializer.EnsureInitialized<IWebProxy>(ref s_DefaultWebProxy, ref s_DefaultWebProxyInitialized, ref s_internalSyncObject, GetSystemWebProxy);
set set
{ {
lock (s_internalSyncObject) lock (s_internalSyncObject)

View File

@ -194,7 +194,7 @@ namespace Internal.Runtime.InteropServices
IntPtr delegateTypeNative) IntPtr delegateTypeNative)
{ {
// Create a resolver callback for types. // Create a resolver callback for types.
Func<AssemblyName, Assembly> resolver = name => alc.LoadFromAssemblyName(name); Func<AssemblyName, Assembly> resolver = alc.LoadFromAssemblyName;
// Determine the signature of the type. There are 3 possibilities: // Determine the signature of the type. There are 3 possibilities:
// * No delegate type was supplied - use the default (i.e. ComponentEntryPoint). // * No delegate type was supplied - use the default (i.e. ComponentEntryPoint).

View File

@ -381,8 +381,7 @@ namespace System.Diagnostics.Tracing
List<SessionInfo>? liveSessionList = null; List<SessionInfo>? liveSessionList = null;
GetSessionInfo( GetSessionInfo(
(int etwSessionId, long matchAllKeywords, ref List<SessionInfo>? sessionList) => GetSessionInfoCallback,
GetSessionInfoCallback(etwSessionId, matchAllKeywords, ref sessionList),
ref liveSessionList); ref liveSessionList);
List<KeyValuePair<SessionInfo, bool>> changedSessionList = new List<KeyValuePair<SessionInfo, bool>>(); List<KeyValuePair<SessionInfo, bool>> changedSessionList = new List<KeyValuePair<SessionInfo, bool>>();

View File

@ -35,7 +35,7 @@ namespace System.IO
using SafeFileHandle src = SafeFileHandle.OpenReadOnly(sourceFullPath, FileOptions.None, out fileLength, out filePermissions); using SafeFileHandle src = SafeFileHandle.OpenReadOnly(sourceFullPath, FileOptions.None, out fileLength, out filePermissions);
using SafeFileHandle dst = SafeFileHandle.Open(destFullPath, overwrite ? FileMode.Create : FileMode.CreateNew, using SafeFileHandle dst = SafeFileHandle.Open(destFullPath, overwrite ? FileMode.Create : FileMode.CreateNew,
FileAccess.ReadWrite, FileShare.None, FileOptions.None, preallocationSize: 0, filePermissions, FileAccess.ReadWrite, FileShare.None, FileOptions.None, preallocationSize: 0, filePermissions,
(Interop.ErrorInfo error, Interop.Sys.OpenFlags flags, string path) => CreateOpenException(error, flags, path)); CreateOpenException);
Interop.CheckIo(Interop.Sys.CopyFile(src, dst, fileLength)); Interop.CheckIo(Interop.Sys.CopyFile(src, dst, fileLength));

View File

@ -71,10 +71,7 @@ namespace System.Runtime.Serialization
} }
else else
{ {
return (obj) => return propInfo.GetValue;
{
return propInfo.GetValue(obj);
};
} }
} }
else if (memberInfo is FieldInfo fieldInfo) else if (memberInfo is FieldInfo fieldInfo)

View File

@ -169,7 +169,7 @@ namespace System.Xml.Serialization
{ {
var xmlns = new XmlSerializerNamespaces(); var xmlns = new XmlSerializerNamespaces();
p[index] = xmlns; p[index] = xmlns;
member.XmlnsSource = (ns, name) => xmlns.Add(ns, name); member.XmlnsSource = xmlns.Add;
} }
member.Source = source; member.Source = source;
@ -198,10 +198,7 @@ namespace System.Xml.Serialization
{ {
anyMember.Collection = new CollectionMember(); anyMember.Collection = new CollectionMember();
anyMember.ArraySource = anyMember.Source; anyMember.ArraySource = anyMember.Source;
anyMember.Source = (item) => anyMember.Source = anyMember.Collection.Add;
{
anyMember.Collection.Add(item);
};
anyAttribute = anyMember; anyAttribute = anyMember;
} }
@ -225,10 +222,7 @@ namespace System.Xml.Serialization
if (mapping.Attribute == null && mapping.Text == null) if (mapping.Attribute == null && mapping.Text == null)
{ {
anyMember.Collection = new CollectionMember(); anyMember.Collection = new CollectionMember();
anyMember.ArraySource = (item) => anyMember.ArraySource = anyMember.Collection.Add;
{
anyMember.Collection.Add(item);
};
textOrArrayMembersList.Add(anyMember); textOrArrayMembersList.Add(anyMember);
} }
@ -247,10 +241,7 @@ namespace System.Xml.Serialization
&& !(mapping.Elements!.Length == 1 && mapping.Elements[0].Mapping is ArrayMapping)) && !(mapping.Elements!.Length == 1 && mapping.Elements[0].Mapping is ArrayMapping))
{ {
anyMember.Collection = new CollectionMember(); anyMember.Collection = new CollectionMember();
anyMember.ArraySource = (item) => anyMember.ArraySource = anyMember.Collection.Add;
{
anyMember.Collection.Add(item);
};
membersList.Add(anyMember); membersList.Add(anyMember);
textOrArrayMembersList.Add(anyMember); textOrArrayMembersList.Add(anyMember);
@ -1163,10 +1154,7 @@ namespace System.Xml.Serialization
var arrayMember = new Member(memberMapping); var arrayMember = new Member(memberMapping);
arrayMember.Collection = new CollectionMember(); arrayMember.Collection = new CollectionMember();
arrayMember.ArraySource = (item) => arrayMember.ArraySource = arrayMember.Collection.Add;
{
arrayMember.Collection.Add(item);
};
if ((readOnly && o == null) || Reader.IsEmptyElement) if ((readOnly && o == null) || Reader.IsEmptyElement)
{ {
@ -1720,10 +1708,7 @@ namespace System.Xml.Serialization
var xmlSerializerNamespaces = new XmlSerializerNamespaces(); var xmlSerializerNamespaces = new XmlSerializerNamespaces();
var setMemberValue = GetSetMemberValueDelegate(o!, member.Mapping.Name); var setMemberValue = GetSetMemberValueDelegate(o!, member.Mapping.Name);
setMemberValue(o, xmlSerializerNamespaces); setMemberValue(o, xmlSerializerNamespaces);
member.XmlnsSource = (ns, name) => member.XmlnsSource = xmlSerializerNamespaces.Add;
{
xmlSerializerNamespaces.Add(ns, name);
};
} }
else else
{ {
@ -2126,17 +2111,11 @@ namespace System.Xml.Serialization
{ {
if (memberInfo is PropertyInfo propInfo) if (memberInfo is PropertyInfo propInfo)
{ {
return delegate (object? o, object? p) return propInfo.SetValue;
{
propInfo.SetValue(o, p);
};
} }
else if (memberInfo is FieldInfo fieldInfo) else if (memberInfo is FieldInfo fieldInfo)
{ {
return delegate (object? o, object? p) return fieldInfo.SetValue;
{
fieldInfo.SetValue(o, p);
};
} }
throw new InvalidOperationException(SR.XmlInternalError); throw new InvalidOperationException(SR.XmlInternalError);
@ -2149,11 +2128,7 @@ namespace System.Xml.Serialization
var setMethod = propInfo.GetSetMethod(true); var setMethod = propInfo.GetSetMethod(true);
if (setMethod == null) if (setMethod == null)
{ {
return delegate (object? o, object? p) return propInfo.SetValue;
{
// Maintain the same failure behavior as non-cached delegate
propInfo.SetValue(o, p);
};
} }
setTypedDelegate = (Action<TObj, TParam>)setMethod.CreateDelegate(typeof(Action<TObj, TParam>)); setTypedDelegate = (Action<TObj, TParam>)setMethod.CreateDelegate(typeof(Action<TObj, TParam>));

View File

@ -273,10 +273,7 @@ namespace System.Reflection.TypeLoading
MetadataLoadContext loader = defaultAssembly.Loader; MetadataLoadContext loader = defaultAssembly.Loader;
Func<AssemblyName, Assembly> assemblyResolver = Func<AssemblyName, Assembly> assemblyResolver =
delegate (AssemblyName assemblyName) loader.LoadFromAssemblyName;
{
return loader.LoadFromAssemblyName(assemblyName);
};
Func<Assembly?, string, bool, Type?> typeResolver = Func<Assembly?, string, bool, Type?> typeResolver =
delegate (Assembly? assembly, string fullName, bool ignoreCase2) delegate (Assembly? assembly, string fullName, bool ignoreCase2)

View File

@ -99,7 +99,7 @@ namespace System.Runtime.Serialization
internal static SerializationEvents GetSerializationEventsForType( internal static SerializationEvents GetSerializationEventsForType(
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type t) => [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type t) =>
s_cache.GetOrAdd(t, type => CreateSerializationEvents(type)); s_cache.GetOrAdd(t, CreateSerializationEvents);
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2067:UnrecognizedReflectionPattern", [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2067:UnrecognizedReflectionPattern",
Justification = "The Type is annotated correctly, it just can't pass through the lambda method.")] Justification = "The Type is annotated correctly, it just can't pass through the lambda method.")]

View File

@ -223,7 +223,7 @@ namespace System.Security.Cryptography.Pkcs
SignedAttributesSet signedAttrsSet = default; SignedAttributesSet signedAttrsSet = default;
signedAttrsSet.SignedAttributes = PkcsHelpers.NormalizeAttributeSet( signedAttrsSet.SignedAttributes = PkcsHelpers.NormalizeAttributeSet(
signedAttrs.ToArray(), signedAttrs.ToArray(),
normalized => hasher.AppendData(normalized)); hasher.AppendData);
// Since this contains user data in a context where BER is permitted, use BER. // Since this contains user data in a context where BER is permitted, use BER.
// There shouldn't be any observable difference here between BER and DER, though, // There shouldn't be any observable difference here between BER and DER, though,

View File

@ -117,8 +117,7 @@ namespace System.Security.Cryptography
return ExportArray( return ExportArray(
passwordBytes, passwordBytes,
pbeParameters, pbeParameters,
(ReadOnlySpan<byte> span, PbeParameters parameters, Span<byte> destination, out int i) => TryExportEncryptedPkcs8PrivateKey);
TryExportEncryptedPkcs8PrivateKey(span, parameters, destination, out i));
} }
public virtual byte[] ExportEncryptedPkcs8PrivateKey( public virtual byte[] ExportEncryptedPkcs8PrivateKey(
@ -128,17 +127,16 @@ namespace System.Security.Cryptography
return ExportArray( return ExportArray(
password, password,
pbeParameters, pbeParameters,
(ReadOnlySpan<char> span, PbeParameters parameters, Span<byte> destination, out int i) => TryExportEncryptedPkcs8PrivateKey);
TryExportEncryptedPkcs8PrivateKey(span, parameters, destination, out i));
} }
public virtual byte[] ExportPkcs8PrivateKey() => public virtual byte[] ExportPkcs8PrivateKey() =>
ExportArray( ExportArray(
(Span<byte> destination, out int i) => TryExportPkcs8PrivateKey(destination, out i)); TryExportPkcs8PrivateKey);
public virtual byte[] ExportSubjectPublicKeyInfo() => public virtual byte[] ExportSubjectPublicKeyInfo() =>
ExportArray( ExportArray(
(Span<byte> destination, out int i) => TryExportSubjectPublicKeyInfo(destination, out i)); TryExportSubjectPublicKeyInfo);
public virtual bool TryExportEncryptedPkcs8PrivateKey( public virtual bool TryExportEncryptedPkcs8PrivateKey(
ReadOnlySpan<byte> passwordBytes, ReadOnlySpan<byte> passwordBytes,

View File

@ -16,7 +16,7 @@ namespace System.Security.Cryptography.X509Certificates
/// </summary> /// </summary>
public static ECDsa? GetECDsaPublicKey(this X509Certificate2 certificate) public static ECDsa? GetECDsaPublicKey(this X509Certificate2 certificate)
{ {
return certificate.GetPublicKey<ECDsa>(cert => HasECDsaKeyUsage(cert)); return certificate.GetPublicKey<ECDsa>(HasECDsaKeyUsage);
} }
/// <summary> /// <summary>
@ -24,7 +24,7 @@ namespace System.Security.Cryptography.X509Certificates
/// </summary> /// </summary>
public static ECDsa? GetECDsaPrivateKey(this X509Certificate2 certificate) public static ECDsa? GetECDsaPrivateKey(this X509Certificate2 certificate)
{ {
return certificate.GetPrivateKey<ECDsa>(cert => HasECDsaKeyUsage(cert)); return certificate.GetPrivateKey<ECDsa>(HasECDsaKeyUsage);
} }
public static X509Certificate2 CopyWithPrivateKey(this X509Certificate2 certificate, ECDsa privateKey) public static X509Certificate2 CopyWithPrivateKey(this X509Certificate2 certificate, ECDsa privateKey)

View File

@ -89,8 +89,8 @@ namespace System.Security.Cryptography.X509Certificates
{ {
Interop.Crypto.CheckValidOpenSslHandle(pkcs7); Interop.Crypto.CheckValidOpenSslHandle(pkcs7);
return Interop.Crypto.OpenSslEncode( return Interop.Crypto.OpenSslEncode(
handle => Interop.Crypto.GetPkcs7DerSize(handle), Interop.Crypto.GetPkcs7DerSize,
(handle, buf) => Interop.Crypto.EncodePkcs7(handle, buf), Interop.Crypto.EncodePkcs7,
pkcs7); pkcs7);
} }
} }

View File

@ -376,8 +376,8 @@ namespace System.Security.Cryptography.X509Certificates
get get
{ {
return Interop.Crypto.OpenSslEncode( return Interop.Crypto.OpenSslEncode(
x => Interop.Crypto.GetX509DerSize(x), Interop.Crypto.GetX509DerSize,
(x, buf) => Interop.Crypto.EncodeX509(x, buf), Interop.Crypto.EncodeX509,
_cert); _cert);
} }
} }

View File

@ -760,8 +760,8 @@ namespace System.Security.Cryptography.X509Certificates
using (SafeOcspRequestHandle req = Interop.Crypto.X509ChainBuildOcspRequest(_storeCtx, chainDepth)) using (SafeOcspRequestHandle req = Interop.Crypto.X509ChainBuildOcspRequest(_storeCtx, chainDepth))
{ {
ArraySegment<byte> encoded = Interop.Crypto.OpenSslRentEncode( ArraySegment<byte> encoded = Interop.Crypto.OpenSslRentEncode(
handle => Interop.Crypto.GetOcspRequestDerSize(handle), Interop.Crypto.GetOcspRequestDerSize,
(handle, buf) => Interop.Crypto.EncodeOcspRequest(handle, buf), Interop.Crypto.EncodeOcspRequest,
req); req);
ArraySegment<char> urlEncoded = UrlBase64Encoding.RentEncode(encoded); ArraySegment<char> urlEncoded = UrlBase64Encoding.RentEncode(encoded);
@ -1303,7 +1303,7 @@ namespace System.Security.Cryptography.X509Certificates
{ {
return s_errorStrings.GetOrAdd( return s_errorStrings.GetOrAdd(
code.Code, code.Code,
c => Interop.Crypto.GetX509VerifyCertErrorString(c)); Interop.Crypto.GetX509VerifyCertErrorString);
} }
private sealed class WorkingChain : IDisposable private sealed class WorkingChain : IDisposable

View File

@ -701,7 +701,7 @@ namespace System.Security.Cryptography.X509Certificates
/// </exception> /// </exception>
public ECDiffieHellman? GetECDiffieHellmanPublicKey() public ECDiffieHellman? GetECDiffieHellmanPublicKey()
{ {
return this.GetPublicKey<ECDiffieHellman>(cert => HasECDiffieHellmanKeyUsage(cert)); return this.GetPublicKey<ECDiffieHellman>(HasECDiffieHellmanKeyUsage);
} }
/// <summary> /// <summary>
@ -716,7 +716,7 @@ namespace System.Security.Cryptography.X509Certificates
/// </exception> /// </exception>
public ECDiffieHellman? GetECDiffieHellmanPrivateKey() public ECDiffieHellman? GetECDiffieHellmanPrivateKey()
{ {
return this.GetPrivateKey<ECDiffieHellman>(cert => HasECDiffieHellmanKeyUsage(cert)); return this.GetPrivateKey<ECDiffieHellman>(HasECDiffieHellmanKeyUsage);
} }
/// <summary> /// <summary>

View File

@ -159,8 +159,8 @@ namespace System.ServiceModel.Syndication
{ {
SyndicationFeedFormatter.MoveToStartElement(reader); SyndicationFeedFormatter.MoveToStartElement(reader);
SetDocument(AtomPub10ServiceDocumentFormatter.ReadCategories(reader, null, SetDocument(AtomPub10ServiceDocumentFormatter.ReadCategories(reader, null,
() => CreateInlineCategoriesDocument(), CreateInlineCategoriesDocument,
() => CreateReferencedCategoriesDocument(), CreateReferencedCategoriesDocument,
Version, Version,
_maxExtensionSize)); _maxExtensionSize));
} }

View File

@ -74,7 +74,7 @@ namespace System.Speech.Internal.SapiInterop
internal void DisposeEventNotify(EventNotify eventNotify) internal void DisposeEventNotify(EventNotify eventNotify)
{ {
_proxy.Invoke2(delegate { eventNotify.Dispose(); }); _proxy.Invoke2(eventNotify.Dispose);
} }
internal void SetGrammarOptions(SPGRAMMAROPTIONS options) internal void SetGrammarOptions(SPGRAMMAROPTIONS options)

View File

@ -552,7 +552,7 @@ namespace System.Text.Json.SourceGeneration
return typeGenerationSpec; return typeGenerationSpec;
} }
internal static bool IsSyntaxTargetForGeneration(SyntaxNode node) => node is ClassDeclarationSyntax { AttributeLists: { Count: > 0 }, BaseList: { Types : {Count : > 0 } } }; internal static bool IsSyntaxTargetForGeneration(SyntaxNode node) => node is ClassDeclarationSyntax { AttributeLists.Count: > 0, BaseList.Types.Count: > 0 };
internal static ClassDeclarationSyntax? GetSemanticTargetForGeneration(GeneratorSyntaxContext context, CancellationToken cancellationToken) internal static ClassDeclarationSyntax? GetSemanticTargetForGeneration(GeneratorSyntaxContext context, CancellationToken cancellationToken)
{ {

View File

@ -1365,7 +1365,7 @@ namespace System.Text.RegularExpressions.Generator
{ {
int numChars = RegexCharClass.GetSetChars(childStart.Str!, setChars); int numChars = RegexCharClass.GetSetChars(childStart.Str!, setChars);
Debug.Assert(numChars != 0); Debug.Assert(numChars != 0);
writer.WriteLine($"case {string.Join(" or ", setChars.Slice(0, numChars).ToArray().Select(c => Literal(c)))}:"); writer.WriteLine($"case {string.Join(" or ", setChars.Slice(0, numChars).ToArray().Select(Literal))}:");
} }
else else
{ {

View File

@ -23,7 +23,7 @@ namespace System.Text.RegularExpressions.Generator
private static bool IsSyntaxTargetForGeneration(SyntaxNode node, CancellationToken cancellationToken) => private static bool IsSyntaxTargetForGeneration(SyntaxNode node, CancellationToken cancellationToken) =>
// We don't have a semantic model here, so the best we can do is say whether there are any attributes. // We don't have a semantic model here, so the best we can do is say whether there are any attributes.
node is MethodDeclarationSyntax { AttributeLists: { Count: > 0 } }; node is MethodDeclarationSyntax { AttributeLists.Count: > 0 };
private static bool IsSemanticTargetForGeneration(SemanticModel semanticModel, MethodDeclarationSyntax methodDeclarationSyntax, CancellationToken cancellationToken) private static bool IsSemanticTargetForGeneration(SemanticModel semanticModel, MethodDeclarationSyntax methodDeclarationSyntax, CancellationToken cancellationToken)
{ {

View File

@ -68,7 +68,7 @@ namespace System.Threading.Tasks.Dataflow
onItemsRemoved, itemCountingFunc); onItemsRemoved, itemCountingFunc);
// Initialize target // Initialize target
_target = new BatchBlockTargetCore(this, batchSize, batch => _source.AddMessage(batch), dataflowBlockOptions); _target = new BatchBlockTargetCore(this, batchSize, _source.AddMessage, dataflowBlockOptions);
// When the target is done, let the source know it won't be getting any more data // When the target is done, let the source know it won't be getting any more data
_target.Completion.ContinueWith(delegate { _source.Complete(); }, _target.Completion.ContinueWith(delegate { _source.Complete(); },

View File

@ -51,7 +51,7 @@ namespace System.Reflection.Metadata
public static bool IsSupported { get; } = ApplyUpdateEnabled(justComponentCheck: 0) != 0; public static bool IsSupported { get; } = ApplyUpdateEnabled(justComponentCheck: 0) != 0;
private static Lazy<string> s_ApplyUpdateCapabilities = new Lazy<string>(() => InitializeApplyUpdateCapabilities()); private static readonly Lazy<string> s_ApplyUpdateCapabilities = new Lazy<string>(InitializeApplyUpdateCapabilities);
private static string InitializeApplyUpdateCapabilities() private static string InitializeApplyUpdateCapabilities()
{ {

View File

@ -128,7 +128,7 @@ namespace Microsoft.WebAssembly.Diagnostics
if (request == null || store == null) if (request == null || store == null)
return false; return false;
return store.AllSources().FirstOrDefault(source => TryResolve(source)) != null; return store.AllSources().FirstOrDefault(TryResolve) != null;
} }
public bool CompareRequest(JObject req) public bool CompareRequest(JObject req)

View File

@ -522,7 +522,7 @@ public class MonoAOTCompiler : Microsoft.Build.Utilities.Task
ParallelLoopResult result = Parallel.ForEach( ParallelLoopResult result = Parallel.ForEach(
Partitioner.Create(argsList, EnumerablePartitionerOptions.NoBuffering), Partitioner.Create(argsList, EnumerablePartitionerOptions.NoBuffering),
new ParallelOptions { MaxDegreeOfParallelism = allowedParallelism }, new ParallelOptions { MaxDegreeOfParallelism = allowedParallelism },
(args, state) => PrecompileLibraryParallel(args, state)); PrecompileLibraryParallel);
if (result.IsCompleted) if (result.IsCompleted)
{ {