Enable IDE0170 (Simplify property pattern) and IDE0200 (remove unnecessary lambda...
authorStephen Toub <stoub@microsoft.com>
Tue, 28 Jun 2022 18:46:45 +0000 (14:46 -0400)
committerGitHub <noreply@github.com>
Tue, 28 Jun 2022 18:46:45 +0000 (14:46 -0400)
As part of updating the config file with recently added rules, also turn on a few of them.

58 files changed:
eng/CodeAnalysis.src.globalconfig
eng/CodeAnalysis.test.globalconfig
src/coreclr/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.CoreCLR.cs
src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.ASN1.GetIntegerBytes.cs
src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.ASN1.Nid.cs
src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Crypto.cs
src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.PooledCrypto.cs
src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.X509.cs
src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.X509Name.cs
src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.X509StoreCtx.cs
src/libraries/Common/src/System/Security/Cryptography/ECDiffieHellmanAndroid.Derive.cs
src/libraries/Common/src/System/Security/Cryptography/ECDiffieHellmanOpenSsl.Derive.cs
src/libraries/Common/src/System/Security/Cryptography/ECDiffieHellmanSecurityTransforms.cs
src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationManager.cs
src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationRoot.cs
src/libraries/Microsoft.Extensions.DependencyInjection/src/ServiceLookup/CallSiteFactory.cs
src/libraries/Microsoft.Extensions.DependencyInjection/src/ServiceLookup/CallSiteVisitor.cs
src/libraries/Microsoft.Extensions.FileProviders.Physical/src/PhysicalFileProvider.cs
src/libraries/Microsoft.Extensions.Hosting.WindowsServices/src/WindowsServiceLifetime.cs
src/libraries/Microsoft.Extensions.Options/src/OptionsMonitor.cs
src/libraries/System.ComponentModel.Annotations/src/System/ComponentModel/DataAnnotations/ValidationContext.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/AttributedModelServices.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/Hosting/FilteredCatalog.Traversal.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/ExportfactoryCreator.LifetimeContext.cs
src/libraries/System.ComponentModel.Composition/src/System/ComponentModel/Composition/ReflectionModel/ExportfactoryCreator.cs
src/libraries/System.ComponentModel.EventBasedAsync/src/System/ComponentModel/BackgroundWorker.cs
src/libraries/System.Composition.Hosting/src/System/Composition/Hosting/Core/ExportDescriptorProvider.cs
src/libraries/System.Composition.Hosting/src/System/Composition/Hosting/Util/Formatters.cs
src/libraries/System.Composition.Runtime/src/System/Composition/Runtime/Util/Formatters.cs
src/libraries/System.Data.Common/src/System/Data/Common/SqlUDTStorage.cs
src/libraries/System.Data.Common/src/System/Data/TypeLimiter.cs
src/libraries/System.Diagnostics.DiagnosticSource/src/System/Diagnostics/Metrics/MeterListener.cs
src/libraries/System.Formats.Asn1/src/System/Formats/Asn1/AsnDecoder.BitString.cs
src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpHandler.cs
src/libraries/System.Net.Requests/src/System/Net/WebRequest.cs
src/libraries/System.Private.CoreLib/src/Internal/Runtime/InteropServices/ComponentActivator.cs
src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventProvider.cs
src/libraries/System.Private.CoreLib/src/System/IO/FileSystem.Unix.cs
src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/AccessorBuilder.cs
src/libraries/System.Private.Xml/src/System/Xml/Serialization/ReflectionXmlSerializationReader.cs
src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/TypeLoading/General/Helpers.cs
src/libraries/System.Runtime.Serialization.Formatters/src/System/Runtime/Serialization/SerializationEventsCache.cs
src/libraries/System.Security.Cryptography.Pkcs/src/System/Security/Cryptography/Pkcs/CmsSigner.cs
src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/AsymmetricAlgorithm.cs
src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/ECDsaCertificateExtensions.cs
src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/OpenSslExportProvider.cs
src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/OpenSslX509CertificateReader.cs
src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/OpenSslX509ChainProcessor.cs
src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/X509Certificate2.cs
src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/AtomPub10CategoriesDocumentFormatter.cs
src/libraries/System.Speech/src/Internal/SapiInterop/SapiRecoContext.cs
src/libraries/System.Text.Json/gen/JsonSourceGenerator.Parser.cs
src/libraries/System.Text.RegularExpressions/gen/RegexGenerator.Emitter.cs
src/libraries/System.Text.RegularExpressions/gen/RegexGenerator.Parser.cs
src/libraries/System.Threading.Tasks.Dataflow/src/Blocks/BatchBlock.cs
src/mono/System.Private.CoreLib/src/System/Reflection/Metadata/MetadataUpdater.cs
src/mono/wasm/debugger/BrowserDebugProxy/DebugStore.cs
src/tasks/AotCompilerTask/MonoAOTCompiler.cs

index 95f58b4..a21a9e9 100644 (file)
@@ -1445,9 +1445,6 @@ dotnet_diagnostic.IDE0048.severity = silent
 # IDE0049: Use language keywords instead of framework type names for type references
 dotnet_diagnostic.IDE0049.severity = warning
 
-# IDE0050: Convert anonymous type to tuple
-dotnet_diagnostic.IDE0050.severity = suggestion
-
 # IDE0051: Remove unused private members
 dotnet_diagnostic.IDE0051.severity = suggestion
 
@@ -1569,6 +1566,27 @@ dotnet_diagnostic.IDE0160.severity = silent
 # IDE0161: Convert to file-scoped namespace
 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.
 dotnet_diagnostic.IDE1005.severity = warning
 
index 59fc4e0..d5d00ae 100644 (file)
@@ -1440,9 +1440,6 @@ dotnet_diagnostic.IDE0048.severity = silent
 # IDE0049: Use language keywords instead of framework type names for type references
 dotnet_diagnostic.IDE0049.severity = silent
 
-# IDE0050: Convert anonymous type to tuple
-dotnet_diagnostic.IDE0050.severity = silent
-
 # IDE0051: Remove unused private members
 dotnet_diagnostic.IDE0051.severity = silent
 
@@ -1563,6 +1560,27 @@ dotnet_diagnostic.IDE0160.severity = silent
 # IDE0161: Convert to file-scoped namespace
 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.
 dotnet_diagnostic.IDE1005.severity = silent
 
index 4b65923..4ee3f10 100644 (file)
@@ -57,7 +57,7 @@ namespace System.Runtime.InteropServices
         [RequiresDynamicCode("Marshalling code for the object might not be available")]
         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)]
@@ -65,7 +65,7 @@ namespace System.Runtime.InteropServices
         [RequiresDynamicCode("Marshalling code for the object might not be available")]
         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)]
@@ -73,7 +73,7 @@ namespace System.Runtime.InteropServices
         [RequiresDynamicCode("Marshalling code for the object might not be available")]
         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)]
@@ -83,7 +83,7 @@ namespace System.Runtime.InteropServices
         public static long ReadInt64([MarshalAs(UnmanagedType.AsAny), In] object ptr, int ofs)
 #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>
@@ -125,7 +125,7 @@ namespace System.Runtime.InteropServices
         [RequiresDynamicCode("Marshalling code for the object might not be available")]
         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)]
@@ -133,7 +133,7 @@ namespace System.Runtime.InteropServices
         [RequiresDynamicCode("Marshalling code for the object might not be available")]
         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)]
@@ -141,7 +141,7 @@ namespace System.Runtime.InteropServices
         [RequiresDynamicCode("Marshalling code for the object might not be available")]
         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)]
@@ -149,7 +149,7 @@ namespace System.Runtime.InteropServices
         [RequiresDynamicCode("Marshalling code for the object might not be available")]
         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>
index a5af06c..abbd2e4 100644 (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
             // and length.
             byte[] derEncoded = OpenSslEncode(
-                handle => GetAsn1IntegerDerSize(handle),
-                (handle, buf) => EncodeAsn1Integer(handle, buf),
+                GetAsn1IntegerDerSize,
+                EncodeAsn1Integer,
                 asn1Integer);
 
             try
index 3de8f89..cc22af2 100644 (file)
@@ -20,7 +20,7 @@ internal static partial class Interop
 
         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)
index 50dc4c2..a2f209e 100644 (file)
@@ -107,25 +107,25 @@ internal static partial class Interop
 
         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)
         {
-            return GetDynamicBuffer((handle, buf, i) => GetX509Thumbprint(handle, buf, i), x509);
+            return GetDynamicBuffer(GetX509Thumbprint, x509);
         }
 
         internal static X500DistinguishedName LoadX500Name(IntPtr namePtr)
         {
             CheckValidOpenSslHandle(namePtr);
 
-            byte[] buf = GetDynamicBuffer((ptr, buf1, i) => GetX509NameRawBytes(ptr, buf1, i), namePtr);
+            byte[] buf = GetDynamicBuffer(GetX509NameRawBytes, namePtr);
             return new X500DistinguishedName(buf);
         }
 
         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)
index 3d7c192..ae78b51 100644 (file)
@@ -10,7 +10,7 @@ internal static partial class Interop
     {
         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)
index ede2291..1362a2a 100644 (file)
@@ -90,7 +90,7 @@ internal static partial class Interop
             CheckValidOpenSslHandle(x);
 
             return SafeInteriorHandle.OpenInteriorHandle(
-                handle => X509GetSerialNumber_private(handle),
+                X509GetSerialNumber_private,
                 x);
         }
 
@@ -117,7 +117,7 @@ internal static partial class Interop
             CheckValidOpenSslHandle(x);
 
             return SafeInteriorHandle.OpenInteriorHandle(
-                (handle, arg) => CryptoNative_X509FindExtensionData(handle, arg),
+                CryptoNative_X509FindExtensionData,
                 x,
                 extensionNid);
         }
index 0bc5e5a..9cd1e9e 100644 (file)
@@ -24,7 +24,7 @@ internal static partial class Interop
         {
             CheckValidOpenSslHandle(namePtr);
 
-            byte[] buf = GetDynamicBuffer((ptr, buf1, i) => GetX509NameRawBytes(ptr, buf1, i), namePtr);
+            byte[] buf = GetDynamicBuffer(GetX509NameRawBytes, namePtr);
             return new X500DistinguishedName(buf);
         }
 
@@ -33,7 +33,7 @@ internal static partial class Interop
             CheckValidOpenSslHandle(sk);
 
             return SafeInteriorHandle.OpenInteriorHandle(
-                (handle, i) => GetX509NameStackField_private(handle, i),
+                GetX509NameStackField_private,
                 sk,
                 loc);
         }
index 08cf5b4..808dd56 100644 (file)
@@ -61,7 +61,7 @@ internal static partial class Interop
         internal static SafeSharedX509StackHandle X509StoreCtxGetSharedUntrusted(SafeX509StoreCtxHandle ctx)
         {
             return SafeInteriorHandle.OpenInteriorHandle(
-                x => X509StoreCtxGetSharedUntrusted_private(x),
+                X509StoreCtxGetSharedUntrusted_private,
                 ctx);
         }
     }
index 4c26620..94763e9 100644 (file)
@@ -33,7 +33,7 @@ namespace System.Security.Cryptography
                     hashAlgorithm,
                     secretPrepend,
                     secretAppend,
-                    (pubKey, hasher) => DeriveSecretAgreement(pubKey, hasher));
+                    DeriveSecretAgreement);
             }
 
             public override byte[] DeriveKeyFromHmac(
@@ -54,7 +54,7 @@ namespace System.Security.Cryptography
                     hmacKey,
                     secretPrepend,
                     secretAppend,
-                    (pubKey, hasher) => DeriveSecretAgreement(pubKey, hasher));
+                    DeriveSecretAgreement);
             }
 
             public override byte[] DeriveKeyTls(ECDiffieHellmanPublicKey otherPartyPublicKey, byte[] prfLabel, byte[] prfSeed)
@@ -69,7 +69,7 @@ namespace System.Security.Cryptography
                     otherPartyPublicKey,
                     prfLabel,
                     prfSeed,
-                    (pubKey, hasher) => DeriveSecretAgreement(pubKey, hasher));
+                    DeriveSecretAgreement);
             }
 
             /// <summary>
index 734047e..beb222f 100644 (file)
@@ -30,7 +30,7 @@ namespace System.Security.Cryptography
                 hashAlgorithm,
                 secretPrepend,
                 secretAppend,
-                (pubKey, hasher) => DeriveSecretAgreement(pubKey, hasher));
+                DeriveSecretAgreement);
         }
 
         public override byte[] DeriveKeyFromHmac(
@@ -51,7 +51,7 @@ namespace System.Security.Cryptography
                 hmacKey,
                 secretPrepend,
                 secretAppend,
-                (pubKey, hasher) => DeriveSecretAgreement(pubKey, hasher));
+                DeriveSecretAgreement);
         }
 
         public override byte[] DeriveKeyTls(ECDiffieHellmanPublicKey otherPartyPublicKey, byte[] prfLabel, byte[] prfSeed)
@@ -66,7 +66,7 @@ namespace System.Security.Cryptography
                 otherPartyPublicKey,
                 prfLabel,
                 prfSeed,
-                (pubKey, hasher) => DeriveSecretAgreement(pubKey, hasher));
+                DeriveSecretAgreement);
         }
 
         /// <summary>
index 9033c3a..dd5a738 100644 (file)
@@ -136,7 +136,7 @@ namespace System.Security.Cryptography
                     hashAlgorithm,
                     secretPrepend,
                     secretAppend,
-                    (pubKey, hasher) => DeriveSecretAgreement(pubKey, hasher));
+                    DeriveSecretAgreement);
             }
 
             public override byte[] DeriveKeyFromHmac(
@@ -157,7 +157,7 @@ namespace System.Security.Cryptography
                     hmacKey,
                     secretPrepend,
                     secretAppend,
-                    (pubKey, hasher) => DeriveSecretAgreement(pubKey, hasher));
+                    DeriveSecretAgreement);
             }
 
             public override byte[] DeriveKeyTls(ECDiffieHellmanPublicKey otherPartyPublicKey, byte[] prfLabel, byte[] prfSeed)
@@ -172,7 +172,7 @@ namespace System.Security.Cryptography
                     otherPartyPublicKey,
                     prfLabel,
                     prfSeed,
-                    (pubKey, hasher) => DeriveSecretAgreement(pubKey, hasher));
+                    DeriveSecretAgreement);
             }
 
             private byte[]? DeriveSecretAgreement(ECDiffieHellmanPublicKey otherPartyPublicKey, IncrementalHash? hasher)
index 5b27bfb..fda645e 100644 (file)
@@ -120,7 +120,7 @@ namespace Microsoft.Extensions.Configuration
             IConfigurationProvider provider = source.Build(this);
 
             provider.Load();
-            _changeTokenRegistrations.Add(ChangeToken.OnChange(() => provider.GetReloadToken(), () => RaiseChanged()));
+            _changeTokenRegistrations.Add(ChangeToken.OnChange(provider.GetReloadToken, RaiseChanged));
 
             _providerManager.AddProvider(provider);
             RaiseChanged();
@@ -143,7 +143,7 @@ namespace Microsoft.Extensions.Configuration
             foreach (IConfigurationProvider p in newProvidersList)
             {
                 p.Load();
-                _changeTokenRegistrations.Add(ChangeToken.OnChange(() => p.GetReloadToken(), () => RaiseChanged()));
+                _changeTokenRegistrations.Add(ChangeToken.OnChange(p.GetReloadToken, RaiseChanged));
             }
 
             _providerManager.ReplaceProviders(newProvidersList);
index 74f53a8..2e3455b 100644 (file)
@@ -30,7 +30,7 @@ namespace Microsoft.Extensions.Configuration
             foreach (IConfigurationProvider p in providers)
             {
                 p.Load();
-                _changeTokenRegistrations.Add(ChangeToken.OnChange(() => p.GetReloadToken(), () => RaiseChanged()));
+                _changeTokenRegistrations.Add(ChangeToken.OnChange(p.GetReloadToken, RaiseChanged));
             }
         }
 
index 81add91..07052e9 100644 (file)
@@ -179,7 +179,7 @@ namespace Microsoft.Extensions.DependencyInjection.ServiceLookup
         {
             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:
index b7143a2..3b2dbee 100644 (file)
@@ -18,7 +18,7 @@ namespace Microsoft.Extensions.DependencyInjection.ServiceLookup
         {
             if (!_stackGuard.TryEnterOnCurrentStack())
             {
-                return _stackGuard.RunOnEmptyStack((c, a) => VisitCallSite(c, a), callSite, argument);
+                return _stackGuard.RunOnEmptyStack(VisitCallSite, callSite, argument);
             }
 
             switch (callSite.Cache.Location)
index de633a8..fb2306d 100644 (file)
@@ -67,7 +67,7 @@ namespace Microsoft.Extensions.FileProviders
             }
 
             _filters = filters;
-            _fileWatcherFactory = () => CreateFileWatcher();
+            _fileWatcherFactory = CreateFileWatcher;
         }
 
         /// <summary>
index b535f51..a6101b4 100644 (file)
@@ -54,10 +54,7 @@ namespace Microsoft.Extensions.Hosting.WindowsServices
             {
                 Logger.LogInformation("Application is shutting down...");
             });
-            ApplicationLifetime.ApplicationStopped.Register(() =>
-            {
-                _delayStop.Set();
-            });
+            ApplicationLifetime.ApplicationStopped.Register(_delayStop.Set);
 
             Thread thread = new Thread(Run);
             thread.IsBackground = true;
index 39301d8..a736240 100644 (file)
@@ -36,8 +36,8 @@ namespace Microsoft.Extensions.Options
             void RegisterSource(IOptionsChangeTokenSource<TOptions> source)
             {
                 IDisposable registration = ChangeToken.OnChange(
-                          () => source.GetChangeToken(),
-                          (name) => InvokeChanged(name),
+                          source.GetChangeToken,
+                          InvokeChanged,
                           source.Name);
 
                 _registrations.Add(registration);
index 8708881..a0b8d71 100644 (file)
@@ -91,7 +91,7 @@ namespace System.ComponentModel.DataAnnotations
             if (serviceProvider != null)
             {
                 IServiceProvider localServiceProvider = serviceProvider;
-                InitializeServiceProvider(serviceType => localServiceProvider.GetService(serviceType));
+                InitializeServiceProvider(localServiceProvider.GetService);
             }
 
             _items = items != null ? new Dictionary<object, object?>(items) : new Dictionary<object, object?>();
index 3763bb9..9b5435a 100644 (file)
@@ -151,7 +151,7 @@ namespace System.ComponentModel.Composition
             Requires.NotNullOrNullElements(attributedParts, nameof(attributedParts));
 
             CompositionBatch batch = new CompositionBatch(
-                attributedParts.Select(attributedPart => AttributedModelServices.CreatePart(attributedPart)).ToArray(),
+                attributedParts.Select(AttributedModelServices.CreatePart).ToArray(),
                 Enumerable.Empty<ComposablePart>());
 
             container.Compose(batch);
index 57ad4ed..39b0652 100644 (file)
@@ -69,7 +69,7 @@ namespace System.ComponentModel.Composition.Hosting
             {
                 traversal.Initialize();
                 var traversalClosure = GetTraversalClosure(_innerCatalog.Where(_filter), traversal);
-                return new FilteredCatalog(_innerCatalog, p => traversalClosure.Contains(p));
+                return new FilteredCatalog(_innerCatalog, traversalClosure.Contains);
             }
             finally
             {
index 9321e72..0ebbeae 100644 (file)
@@ -47,7 +47,7 @@ namespace System.ComponentModel.Composition.ReflectionModel
 
                 if (disposable != null)
                 {
-                    disposeAction = () => disposable.Dispose();
+                    disposeAction = disposable.Dispose;
                 }
                 else
                 {
index 7c0b4db..d49741a 100644 (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);
-            return (e) => exportFactoryFactory.Invoke(e);
+            return exportFactoryFactory.Invoke;
         }
 
         private object CreateStronglyTypedExportFactoryOfT<T>(Export export)
index 552ef1d..d0e1e7a 100644 (file)
@@ -126,7 +126,7 @@ namespace System.ComponentModel
 
             _asyncOperation = AsyncOperationManager.CreateOperation(null);
             Task.Factory.StartNew(
-                        arg => WorkerThreadStart(arg),
+                        WorkerThreadStart,
                         argument,
                         CancellationToken.None,
                         TaskCreationOptions.DenyChildAttach,
index 39948b9..da6737f 100644 (file)
@@ -28,7 +28,7 @@ namespace System.Composition.Hosting.Core
         /// <summary>
         /// Constant value provided so that subclasses can avoid creating additional duplicate values.
         /// </summary>
-        protected static readonly Func<IEnumerable<CompositionDependency>> NoDependencies = () => Enumerable.Empty<CompositionDependency>();
+        protected static readonly Func<IEnumerable<CompositionDependency>> NoDependencies = Enumerable.Empty<CompositionDependency>;
 
         /// <summary>
         /// Promise export descriptors for the specified export key.
index 863fccf..c7e0af3 100644 (file)
@@ -46,7 +46,7 @@ namespace System.Composition.Hosting.Util
             }
 
             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)}>";
         }
     }
index 2120fb0..104ba2f 100644 (file)
@@ -25,7 +25,7 @@ namespace System.Composition.Runtime.Util
             Debug.Assert(closedGenericType.IsConstructedGenericType);
 
             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)}>";
         }
     }
index 244b109..41b70d7 100644 (file)
@@ -35,7 +35,7 @@ namespace System.Data.Common
         }
 
         // 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",
             Justification = "The only callsite is marked with DynamicallyAccessedMembers. Workaround for https://github.com/mono/linker/issues/1981")]
index 59258ea..4d68583 100644 (file)
@@ -118,7 +118,7 @@ namespace System.Data
         private static IEnumerable<Type> GetPreviouslyDeclaredDataTypes(DataSet dataSet)
         {
             return (dataSet != null)
-                ? dataSet.Tables.Cast<DataTable>().SelectMany(table => GetPreviouslyDeclaredDataTypes(table))
+                ? dataSet.Tables.Cast<DataTable>().SelectMany(GetPreviouslyDeclaredDataTypes)
                 : Enumerable.Empty<Type>();
         }
 
index d11a289..4b3c0f1 100644 (file)
@@ -67,7 +67,7 @@ namespace System.Diagnostics.Metrics
             {
                 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);
                     enabled = true;
                 }
@@ -98,7 +98,7 @@ namespace System.Diagnostics.Metrics
             object? state =  null;
             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;
                 }
index 2af50e7..e36dd61 100644 (file)
@@ -443,7 +443,7 @@ namespace System.Formats.Asn1
                 source,
                 ruleSet,
                 tmpDest,
-                (value, lastByte, dest) => CopyBitStringValue(value, lastByte, dest),
+                CopyBitStringValue,
                 isIndefinite,
                 out unusedBitCount,
                 out bytesRead);
index f854029..4fa86dc 100644 (file)
@@ -44,7 +44,7 @@ namespace System.Net.Http
 
         private static readonly StringWithQualityHeaderValue s_gzipHeaderValue = new StringWithQualityHeaderValue("gzip");
         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]
         private static StringBuilder? t_requestHeadersBuilder;
index 80d1818..8ba5533 100644 (file)
@@ -548,7 +548,7 @@ namespace System.Net
 
         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
             {
                 lock (s_internalSyncObject)
index 118afb9..50f7a5e 100644 (file)
@@ -194,7 +194,7 @@ namespace Internal.Runtime.InteropServices
                                                          IntPtr delegateTypeNative)
         {
             // 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:
             //  * No delegate type was supplied - use the default (i.e. ComponentEntryPoint).
index b294ba0..c552a89 100644 (file)
@@ -381,8 +381,7 @@ namespace System.Diagnostics.Tracing
             List<SessionInfo>? liveSessionList = null;
 
             GetSessionInfo(
-                (int etwSessionId, long matchAllKeywords, ref List<SessionInfo>? sessionList) =>
-                    GetSessionInfoCallback(etwSessionId, matchAllKeywords, ref sessionList),
+                GetSessionInfoCallback,
                 ref liveSessionList);
 
             List<KeyValuePair<SessionInfo, bool>> changedSessionList = new List<KeyValuePair<SessionInfo, bool>>();
index a2aa1b0..24e0076 100644 (file)
@@ -35,7 +35,7 @@ namespace System.IO
             using SafeFileHandle src = SafeFileHandle.OpenReadOnly(sourceFullPath, FileOptions.None, out fileLength, out filePermissions);
             using SafeFileHandle dst = SafeFileHandle.Open(destFullPath, overwrite ? FileMode.Create : FileMode.CreateNew,
                                             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));
 
index 47b6f31..e6af588 100644 (file)
@@ -71,10 +71,7 @@ namespace System.Runtime.Serialization
                 }
                 else
                 {
-                    return (obj) =>
-                    {
-                        return propInfo.GetValue(obj);
-                    };
+                    return propInfo.GetValue;
                 }
             }
             else if (memberInfo is FieldInfo fieldInfo)
index 25a89eb..08e4c7d 100644 (file)
@@ -169,7 +169,7 @@ namespace System.Xml.Serialization
                 {
                     var xmlns = new XmlSerializerNamespaces();
                     p[index] = xmlns;
-                    member.XmlnsSource = (ns, name) => xmlns.Add(ns, name);
+                    member.XmlnsSource = xmlns.Add;
                 }
 
                 member.Source = source;
@@ -198,10 +198,7 @@ namespace System.Xml.Serialization
                 {
                     anyMember.Collection = new CollectionMember();
                     anyMember.ArraySource = anyMember.Source;
-                    anyMember.Source = (item) =>
-                    {
-                        anyMember.Collection.Add(item);
-                    };
+                    anyMember.Source = anyMember.Collection.Add;
 
                     anyAttribute = anyMember;
                 }
@@ -225,10 +222,7 @@ namespace System.Xml.Serialization
                             if (mapping.Attribute == null && mapping.Text == null)
                             {
                                 anyMember.Collection = new CollectionMember();
-                                anyMember.ArraySource = (item) =>
-                                {
-                                    anyMember.Collection.Add(item);
-                                };
+                                anyMember.ArraySource = anyMember.Collection.Add;
 
                                 textOrArrayMembersList.Add(anyMember);
                             }
@@ -247,10 +241,7 @@ namespace System.Xml.Serialization
                     && !(mapping.Elements!.Length == 1 && mapping.Elements[0].Mapping is ArrayMapping))
                 {
                     anyMember.Collection = new CollectionMember();
-                    anyMember.ArraySource = (item) =>
-                    {
-                        anyMember.Collection.Add(item);
-                    };
+                    anyMember.ArraySource = anyMember.Collection.Add;
 
                     membersList.Add(anyMember);
                     textOrArrayMembersList.Add(anyMember);
@@ -1163,10 +1154,7 @@ namespace System.Xml.Serialization
 
                     var arrayMember = new Member(memberMapping);
                     arrayMember.Collection = new CollectionMember();
-                    arrayMember.ArraySource = (item) =>
-                    {
-                        arrayMember.Collection.Add(item);
-                    };
+                    arrayMember.ArraySource = arrayMember.Collection.Add;
 
                     if ((readOnly && o == null) || Reader.IsEmptyElement)
                     {
@@ -1720,10 +1708,7 @@ namespace System.Xml.Serialization
                                 var xmlSerializerNamespaces = new XmlSerializerNamespaces();
                                 var setMemberValue = GetSetMemberValueDelegate(o!, member.Mapping.Name);
                                 setMemberValue(o, xmlSerializerNamespaces);
-                                member.XmlnsSource = (ns, name) =>
-                                {
-                                    xmlSerializerNamespaces.Add(ns, name);
-                                };
+                                member.XmlnsSource = xmlSerializerNamespaces.Add;
                             }
                             else
                             {
@@ -2126,17 +2111,11 @@ namespace System.Xml.Serialization
             {
                 if (memberInfo is PropertyInfo propInfo)
                 {
-                    return delegate (object? o, object? p)
-                    {
-                        propInfo.SetValue(o, p);
-                    };
+                    return propInfo.SetValue;
                 }
                 else if (memberInfo is FieldInfo fieldInfo)
                 {
-                    return delegate (object? o, object? p)
-                    {
-                        fieldInfo.SetValue(o, p);
-                    };
+                    return fieldInfo.SetValue;
                 }
 
                 throw new InvalidOperationException(SR.XmlInternalError);
@@ -2149,11 +2128,7 @@ namespace System.Xml.Serialization
                     var setMethod = propInfo.GetSetMethod(true);
                     if (setMethod == null)
                     {
-                        return delegate (object? o, object? p)
-                        {
-                            // Maintain the same failure behavior as non-cached delegate
-                            propInfo.SetValue(o, p);
-                        };
+                        return propInfo.SetValue;
                     }
 
                     setTypedDelegate = (Action<TObj, TParam>)setMethod.CreateDelegate(typeof(Action<TObj, TParam>));
index d10edff..7817703 100644 (file)
@@ -273,10 +273,7 @@ namespace System.Reflection.TypeLoading
             MetadataLoadContext loader = defaultAssembly.Loader;
 
             Func<AssemblyName, Assembly> assemblyResolver =
-                delegate (AssemblyName assemblyName)
-                {
-                    return loader.LoadFromAssemblyName(assemblyName);
-                };
+                loader.LoadFromAssemblyName;
 
             Func<Assembly?, string, bool, Type?> typeResolver =
                 delegate (Assembly? assembly, string fullName, bool ignoreCase2)
index 9e8d8d3..a11b6f6 100644 (file)
@@ -99,7 +99,7 @@ namespace System.Runtime.Serialization
 
         internal static SerializationEvents GetSerializationEventsForType(
             [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type t) =>
-            s_cache.GetOrAdd(t, type => CreateSerializationEvents(type));
+            s_cache.GetOrAdd(t, CreateSerializationEvents);
 
         [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2067:UnrecognizedReflectionPattern",
             Justification = "The Type is annotated correctly, it just can't pass through the lambda method.")]
index f636bcd..416dadb 100644 (file)
@@ -223,7 +223,7 @@ namespace System.Security.Cryptography.Pkcs
                 SignedAttributesSet signedAttrsSet = default;
                 signedAttrsSet.SignedAttributes = PkcsHelpers.NormalizeAttributeSet(
                     signedAttrs.ToArray(),
-                    normalized => hasher.AppendData(normalized));
+                    hasher.AppendData);
 
                 // 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,
index 117480a..7c1fb49 100644 (file)
@@ -117,8 +117,7 @@ namespace System.Security.Cryptography
             return ExportArray(
                 passwordBytes,
                 pbeParameters,
-                (ReadOnlySpan<byte> span, PbeParameters parameters, Span<byte> destination, out int i) =>
-                    TryExportEncryptedPkcs8PrivateKey(span, parameters, destination, out i));
+                TryExportEncryptedPkcs8PrivateKey);
         }
 
         public virtual byte[] ExportEncryptedPkcs8PrivateKey(
@@ -128,17 +127,16 @@ namespace System.Security.Cryptography
             return ExportArray(
                 password,
                 pbeParameters,
-                (ReadOnlySpan<char> span, PbeParameters parameters, Span<byte> destination, out int i) =>
-                    TryExportEncryptedPkcs8PrivateKey(span, parameters, destination, out i));
+                TryExportEncryptedPkcs8PrivateKey);
         }
 
         public virtual byte[] ExportPkcs8PrivateKey() =>
             ExportArray(
-                (Span<byte> destination, out int i) => TryExportPkcs8PrivateKey(destination, out i));
+                TryExportPkcs8PrivateKey);
 
         public virtual byte[] ExportSubjectPublicKeyInfo() =>
             ExportArray(
-                (Span<byte> destination, out int i) => TryExportSubjectPublicKeyInfo(destination, out i));
+                TryExportSubjectPublicKeyInfo);
 
         public virtual bool TryExportEncryptedPkcs8PrivateKey(
             ReadOnlySpan<byte> passwordBytes,
index de72605..63c60b4 100644 (file)
@@ -16,7 +16,7 @@ namespace System.Security.Cryptography.X509Certificates
         /// </summary>
         public static ECDsa? GetECDsaPublicKey(this X509Certificate2 certificate)
         {
-            return certificate.GetPublicKey<ECDsa>(cert => HasECDsaKeyUsage(cert));
+            return certificate.GetPublicKey<ECDsa>(HasECDsaKeyUsage);
         }
 
         /// <summary>
@@ -24,7 +24,7 @@ namespace System.Security.Cryptography.X509Certificates
         /// </summary>
         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)
index e8dcae1..355dbc3 100644 (file)
@@ -89,8 +89,8 @@ namespace System.Security.Cryptography.X509Certificates
                 {
                     Interop.Crypto.CheckValidOpenSslHandle(pkcs7);
                     return Interop.Crypto.OpenSslEncode(
-                        handle => Interop.Crypto.GetPkcs7DerSize(handle),
-                        (handle, buf) => Interop.Crypto.EncodePkcs7(handle, buf),
+                        Interop.Crypto.GetPkcs7DerSize,
+                        Interop.Crypto.EncodePkcs7,
                         pkcs7);
                 }
             }
index 5ab9285..fe1fa8f 100644 (file)
@@ -376,8 +376,8 @@ namespace System.Security.Cryptography.X509Certificates
             get
             {
                 return Interop.Crypto.OpenSslEncode(
-                    x => Interop.Crypto.GetX509DerSize(x),
-                    (x, buf) => Interop.Crypto.EncodeX509(x, buf),
+                    Interop.Crypto.GetX509DerSize,
+                    Interop.Crypto.EncodeX509,
                     _cert);
             }
         }
index ae0e372..0b1d6dd 100644 (file)
@@ -760,8 +760,8 @@ namespace System.Security.Cryptography.X509Certificates
             using (SafeOcspRequestHandle req = Interop.Crypto.X509ChainBuildOcspRequest(_storeCtx, chainDepth))
             {
                 ArraySegment<byte> encoded = Interop.Crypto.OpenSslRentEncode(
-                    handle => Interop.Crypto.GetOcspRequestDerSize(handle),
-                    (handle, buf) => Interop.Crypto.EncodeOcspRequest(handle, buf),
+                    Interop.Crypto.GetOcspRequestDerSize,
+                    Interop.Crypto.EncodeOcspRequest,
                     req);
 
                 ArraySegment<char> urlEncoded = UrlBase64Encoding.RentEncode(encoded);
@@ -1303,7 +1303,7 @@ namespace System.Security.Cryptography.X509Certificates
         {
             return s_errorStrings.GetOrAdd(
                 code.Code,
-                c => Interop.Crypto.GetX509VerifyCertErrorString(c));
+                Interop.Crypto.GetX509VerifyCertErrorString);
         }
 
         private sealed class WorkingChain : IDisposable
index 9546c53..4cfddb4 100644 (file)
@@ -701,7 +701,7 @@ namespace System.Security.Cryptography.X509Certificates
         /// </exception>
         public ECDiffieHellman? GetECDiffieHellmanPublicKey()
         {
-            return this.GetPublicKey<ECDiffieHellman>(cert => HasECDiffieHellmanKeyUsage(cert));
+            return this.GetPublicKey<ECDiffieHellman>(HasECDiffieHellmanKeyUsage);
         }
 
         /// <summary>
@@ -716,7 +716,7 @@ namespace System.Security.Cryptography.X509Certificates
         /// </exception>
         public ECDiffieHellman? GetECDiffieHellmanPrivateKey()
         {
-            return this.GetPrivateKey<ECDiffieHellman>(cert => HasECDiffieHellmanKeyUsage(cert));
+            return this.GetPrivateKey<ECDiffieHellman>(HasECDiffieHellmanKeyUsage);
         }
 
         /// <summary>
index 908ff31..2a03f55 100644 (file)
@@ -159,8 +159,8 @@ namespace System.ServiceModel.Syndication
             {
                 SyndicationFeedFormatter.MoveToStartElement(reader);
                 SetDocument(AtomPub10ServiceDocumentFormatter.ReadCategories(reader, null,
-                    () => CreateInlineCategoriesDocument(),
-                    () => CreateReferencedCategoriesDocument(),
+                    CreateInlineCategoriesDocument,
+                    CreateReferencedCategoriesDocument,
                     Version,
                     _maxExtensionSize));
             }
index 19c895c..c28b308 100644 (file)
@@ -74,7 +74,7 @@ namespace System.Speech.Internal.SapiInterop
 
         internal void DisposeEventNotify(EventNotify eventNotify)
         {
-            _proxy.Invoke2(delegate { eventNotify.Dispose(); });
+            _proxy.Invoke2(eventNotify.Dispose);
         }
 
         internal void SetGrammarOptions(SPGRAMMAROPTIONS options)
index 86c38c3..ce9ed21 100644 (file)
@@ -552,7 +552,7 @@ namespace System.Text.Json.SourceGeneration
                 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)
             {
index 8104729..d1d5ecb 100644 (file)
@@ -1365,7 +1365,7 @@ namespace System.Text.RegularExpressions.Generator
                             {
                                 int numChars = RegexCharClass.GetSetChars(childStart.Str!, setChars);
                                 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
                             {
index 0829ccf..9fa9110 100644 (file)
@@ -23,7 +23,7 @@ namespace System.Text.RegularExpressions.Generator
 
         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.
-            node is MethodDeclarationSyntax { AttributeLists: { Count: > 0 } };
+            node is MethodDeclarationSyntax { AttributeLists.Count: > 0 };
 
         private static bool IsSemanticTargetForGeneration(SemanticModel semanticModel, MethodDeclarationSyntax methodDeclarationSyntax, CancellationToken cancellationToken)
         {
index 3cb92a3..56ee24c 100644 (file)
@@ -68,7 +68,7 @@ namespace System.Threading.Tasks.Dataflow
                 onItemsRemoved, itemCountingFunc);
 
             // 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
             _target.Completion.ContinueWith(delegate { _source.Complete(); },
index ba51ce0..df36076 100644 (file)
@@ -51,7 +51,7 @@ namespace System.Reflection.Metadata
 
         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()
         {
index 2baa2f2..c480fd7 100644 (file)
@@ -128,7 +128,7 @@ namespace Microsoft.WebAssembly.Diagnostics
             if (request == null || store == null)
                 return false;
 
-            return store.AllSources().FirstOrDefault(source => TryResolve(source)) != null;
+            return store.AllSources().FirstOrDefault(TryResolve) != null;
         }
 
         public bool CompareRequest(JObject req)
index 6d63979..12b4daf 100644 (file)
@@ -522,7 +522,7 @@ public class MonoAOTCompiler : Microsoft.Build.Utilities.Task
             ParallelLoopResult result = Parallel.ForEach(
                                             Partitioner.Create(argsList, EnumerablePartitionerOptions.NoBuffering),
                                             new ParallelOptions { MaxDegreeOfParallelism = allowedParallelism },
-                                            (args, state) => PrecompileLibraryParallel(args, state));
+                                            PrecompileLibraryParallel);
 
             if (result.IsCompleted)
             {