From 4f3a68d4bba147dd2847ac739f774f97ef16ab4f Mon Sep 17 00:00:00 2001 From: Stephen Toub Date: Thu, 15 Aug 2019 16:31:52 -0400 Subject: [PATCH] Fix IDE0008 (use explicit type instead of var) Commit migrated from https://github.com/dotnet/coreclr/commit/0a11131ccfeec81ced0124c519b947c30d4ddd75 --- .../Collections/ObjectModel/ReadOnlyDictionary.cs | 6 +- .../Eventing/EventPipeMetadataGenerator.cs | 4 +- .../src/System/MulticastDelegate.cs | 2 +- .../src/System/Reflection/CustomAttribute.cs | 10 +-- .../src/System/AggregateException.cs | 2 +- .../src/System/Buffers/ConfigurableArrayPool.cs | 6 +- .../Text/Utf8Formatter/FormattingHelpers.cs | 2 +- .../Text/Utf8Formatter/Utf8Formatter.TimeSpan.cs | 2 +- .../src/System/CurrentSystemTimeZone.cs | 2 +- .../src/System/Decimal.DecCalc.cs | 4 +- .../src/System/Diagnostics/Contracts/Contracts.cs | 15 ++--- .../System/Diagnostics/Tracing/ActivityTracker.cs | 10 +-- .../src/System/Diagnostics/Tracing/CounterGroup.cs | 4 +- .../Diagnostics/Tracing/DiagnosticCounter.cs | 2 +- .../src/System/Diagnostics/Tracing/EventCounter.cs | 2 +- .../System/Diagnostics/Tracing/EventProvider.cs | 10 +-- .../src/System/Diagnostics/Tracing/EventSource.cs | 34 +++++----- .../Tracing/TraceLogging/ArrayTypeInfo.cs | 4 +- .../Tracing/TraceLogging/ConcurrentSet.cs | 12 ++-- .../Tracing/TraceLogging/DataCollector.cs | 28 ++++---- .../Tracing/TraceLogging/EnumerableTypeInfo.cs | 8 +-- .../Tracing/TraceLogging/EventPayload.cs | 6 +- .../Tracing/TraceLogging/FieldMetadata.cs | 2 +- .../Tracing/TraceLogging/InvokeTypeInfo.cs | 12 ++-- .../Tracing/TraceLogging/PropertyValue.cs | 6 +- .../Tracing/TraceLogging/SimpleTypeInfos.cs | 14 ++-- .../Diagnostics/Tracing/TraceLogging/Statics.cs | 18 +++--- .../TraceLogging/TraceLoggingDataCollector.cs | 2 +- .../TraceLogging/TraceLoggingEventSource.cs | 34 +++++----- .../Tracing/TraceLogging/TraceLoggingEventTypes.cs | 8 +-- .../TraceLogging/TraceLoggingMetadataCollector.cs | 4 +- .../Tracing/TraceLogging/TraceLoggingTypeInfo.cs | 4 +- .../Tracing/TraceLogging/TypeAnalysis.cs | 12 ++-- .../System.Private.CoreLib/src/System/Double.cs | 12 ++-- .../System.Private.CoreLib/src/System/Enum.cs | 2 +- .../src/System/Globalization/CharUnicodeInfo.cs | 2 +- .../src/System/Globalization/DateTimeFormat.cs | 2 +- .../System.Private.CoreLib/src/System/HashCode.cs | 74 +++++++++++----------- .../System/IO/FileStreamCompletionSource.Win32.cs | 2 +- .../src/System/IO/MemoryStream.cs | 2 +- .../System.Private.CoreLib/src/System/IO/Stream.cs | 16 ++--- .../System.Private.CoreLib/src/System/Lazy.cs | 4 +- .../System.Private.CoreLib/src/System/Math.cs | 18 +++--- .../System.Private.CoreLib/src/System/MathF.cs | 18 +++--- .../src/System/MemoryExtensions.cs | 4 +- .../src/System/Number.BigInteger.cs | 12 ++-- .../src/System/Number.Formatting.cs | 2 +- .../Resources/ManifestBasedResourceGroveler.cs | 2 +- .../Runtime/CompilerServices/AsyncMethodBuilder.cs | 2 +- .../System/Runtime/CompilerServices/TaskAwaiter.cs | 14 ++-- .../Runtime/CompilerServices/YieldAwaitable.cs | 4 +- .../src/System/Runtime/Intrinsics/Vector128.cs | 62 +++++++++--------- .../src/System/Runtime/Intrinsics/Vector256.cs | 60 +++++++++--------- .../src/System/Runtime/Intrinsics/Vector64.cs | 44 ++++++------- .../System/Runtime/Loader/AssemblyLoadContext.cs | 2 +- .../src/System/Security/SecureString.Windows.cs | 2 +- .../System.Private.CoreLib/src/System/Single.cs | 12 ++-- .../src/System/SpanHelpers.Byte.cs | 6 +- .../src/System/SpanHelpers.Char.cs | 2 +- .../src/System/SpanHelpers.T.cs | 6 +- .../src/System/String.Comparison.cs | 8 +-- .../src/System/String.Searching.cs | 4 +- .../src/System/StringComparer.cs | 2 +- .../src/System/Text/StringBuilder.cs | 2 +- .../src/System/Text/ValueStringBuilder.cs | 2 +- .../src/System/Threading/SemaphoreSlim.cs | 4 +- .../Tasks/ConcurrentExclusiveSchedulerPair.cs | 8 +-- .../src/System/Threading/Tasks/FutureFactory.cs | 24 +++---- .../Threading/Tasks/ProducerConsumerQueues.cs | 8 +-- .../src/System/Threading/Tasks/Task.cs | 66 +++++++++---------- .../src/System/Threading/Tasks/TaskContinuation.cs | 12 ++-- .../System/Threading/Tasks/TaskExceptionHolder.cs | 10 +-- .../src/System/Threading/Tasks/TaskFactory.cs | 4 +- .../src/System/Threading/Tasks/TaskScheduler.cs | 6 +- .../src/System/Threading/ThreadLocal.cs | 2 +- .../src/System/Threading/WaitHandle.cs | 2 +- 76 files changed, 423 insertions(+), 420 deletions(-) diff --git a/src/coreclr/src/System.Private.CoreLib/src/System/Collections/ObjectModel/ReadOnlyDictionary.cs b/src/coreclr/src/System.Private.CoreLib/src/System/Collections/ObjectModel/ReadOnlyDictionary.cs index 2a8898e..db1bae7 100644 --- a/src/coreclr/src/System.Private.CoreLib/src/System/Collections/ObjectModel/ReadOnlyDictionary.cs +++ b/src/coreclr/src/System.Private.CoreLib/src/System/Collections/ObjectModel/ReadOnlyDictionary.cs @@ -301,7 +301,7 @@ namespace System.Collections.ObjectModel { if (array is DictionaryEntry[] dictEntryArray) { - foreach (var item in m_dictionary) + foreach (KeyValuePair item in m_dictionary) { dictEntryArray[index++] = new DictionaryEntry(item.Key, item.Value); } @@ -316,7 +316,7 @@ namespace System.Collections.ObjectModel try { - foreach (var item in m_dictionary) + foreach (KeyValuePair item in m_dictionary) { objects[index++] = new KeyValuePair(item.Key, item.Value); } @@ -705,7 +705,7 @@ namespace System.Collections.ObjectModel try { - foreach (var item in collection) + foreach (T item in collection) { objects[index++] = item; } diff --git a/src/coreclr/src/System.Private.CoreLib/src/System/Diagnostics/Eventing/EventPipeMetadataGenerator.cs b/src/coreclr/src/System.Private.CoreLib/src/System/Diagnostics/Eventing/EventPipeMetadataGenerator.cs index 827525a..6d51339 100644 --- a/src/coreclr/src/System.Private.CoreLib/src/System/Diagnostics/Eventing/EventPipeMetadataGenerator.cs +++ b/src/coreclr/src/System.Private.CoreLib/src/System/Diagnostics/Eventing/EventPipeMetadataGenerator.cs @@ -84,7 +84,7 @@ namespace System.Diagnostics.Tracing } // Increase the metadataLength for parameters. - foreach (var parameter in parameters) + foreach (EventParameterInfo parameter in parameters) { int pMetadataLength = parameter.GetMetadataLength(); // The call above may return -1 which means we failed to get the metadata length. @@ -113,7 +113,7 @@ namespace System.Diagnostics.Tracing WriteToBuffer(pMetadata, metadataLength, ref offset, version); WriteToBuffer(pMetadata, metadataLength, ref offset, level); WriteToBuffer(pMetadata, metadataLength, ref offset, (uint)parameters.Length); - foreach (var parameter in parameters) + foreach (EventParameterInfo parameter in parameters) { if (!parameter.GenerateMetadata(pMetadata, ref offset, metadataLength)) { diff --git a/src/coreclr/src/System.Private.CoreLib/src/System/MulticastDelegate.cs b/src/coreclr/src/System.Private.CoreLib/src/System/MulticastDelegate.cs index 3abca1a..a169b14 100644 --- a/src/coreclr/src/System.Private.CoreLib/src/System/MulticastDelegate.cs +++ b/src/coreclr/src/System.Private.CoreLib/src/System/MulticastDelegate.cs @@ -68,7 +68,7 @@ namespace System // the types are the same, obj should also be a // MulticastDelegate Debug.Assert(obj is MulticastDelegate, "Shouldn't have failed here since we already checked the types are the same!"); - var d = Unsafe.As(obj); + MulticastDelegate d = Unsafe.As(obj); if (_invocationCount != (IntPtr)0) { diff --git a/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/CustomAttribute.cs b/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/CustomAttribute.cs index 24b11bb..a9f826d 100644 --- a/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/CustomAttribute.cs +++ b/src/coreclr/src/System.Private.CoreLib/src/System/Reflection/CustomAttribute.cs @@ -965,7 +965,7 @@ namespace System.Reflection bool useObjectArray = (caType.IsValueType || caType.ContainsGenericParameters); RuntimeType arrayType = useObjectArray ? (RuntimeType)typeof(object) : caType; - for (var i = 0; i < pcas.Count; i++) + for (int i = 0; i < pcas.Count; i++) result.Add(pcas[i]); while (type != (RuntimeType)typeof(object) && type != null) @@ -976,7 +976,7 @@ namespace System.Reflection } object[] typedResult = CreateAttributeArrayHelper(arrayType, result.Count); - for (var i = 0; i < result.Count; i++) + for (int i = 0; i < result.Count; i++) { typedResult[i] = result[i]; } @@ -1008,7 +1008,7 @@ namespace System.Reflection bool useObjectArray = (caType.IsValueType || caType.ContainsGenericParameters); RuntimeType arrayType = useObjectArray ? (RuntimeType)typeof(object) : caType; - for (var i = 0; i < pcas.Count; i++) + for (int i = 0; i < pcas.Count; i++) result.Add(pcas[i]); while (method != null) @@ -1019,7 +1019,7 @@ namespace System.Reflection } object[] typedResult = CreateAttributeArrayHelper(arrayType, result.Count); - for (var i = 0; i < result.Count; i++) + for (int i = 0; i < result.Count; i++) { typedResult[i] = result[i]; } @@ -1156,7 +1156,7 @@ namespace System.Reflection RuntimeType arrayType = useObjectArray ? (RuntimeType)typeof(object) : attributeFilterType!; object[] result = CreateAttributeArrayHelper(arrayType, attributes.Count + pcaCount); - for (var i = 0; i < attributes.Count; i++) + for (int i = 0; i < attributes.Count; i++) { result[i] = attributes[i]; } diff --git a/src/libraries/System.Private.CoreLib/src/System/AggregateException.cs b/src/libraries/System.Private.CoreLib/src/System/AggregateException.cs index 85277d9..ce750cd 100644 --- a/src/libraries/System.Private.CoreLib/src/System/AggregateException.cs +++ b/src/libraries/System.Private.CoreLib/src/System/AggregateException.cs @@ -228,7 +228,7 @@ namespace System for (int i = 0; i < exceptionsCopy.Length; i++) { - var edi = innerExceptionInfos[i]; + ExceptionDispatchInfo edi = innerExceptionInfos[i]; if (edi != null) exceptionsCopy[i] = edi.SourceException; if (exceptionsCopy[i] == null) diff --git a/src/libraries/System.Private.CoreLib/src/System/Buffers/ConfigurableArrayPool.cs b/src/libraries/System.Private.CoreLib/src/System/Buffers/ConfigurableArrayPool.cs index f70edf1..f7c2829 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Buffers/ConfigurableArrayPool.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Buffers/ConfigurableArrayPool.cs @@ -73,7 +73,7 @@ namespace System.Buffers return Array.Empty(); } - var log = ArrayPoolEventSource.Log; + ArrayPoolEventSource log = ArrayPoolEventSource.Log; T[]? buffer; int index = Utilities.SelectBucketIndex(minimumLength); @@ -152,7 +152,7 @@ namespace System.Buffers } // Log that the buffer was returned - var log = ArrayPoolEventSource.Log; + ArrayPoolEventSource log = ArrayPoolEventSource.Log; if (log.IsEnabled()) { log.BufferReturned(array.GetHashCode(), array.Length, Id); @@ -217,7 +217,7 @@ namespace System.Buffers { buffer = GC.AllocateUninitializedArray(_bufferLength); - var log = ArrayPoolEventSource.Log; + ArrayPoolEventSource log = ArrayPoolEventSource.Log; if (log.IsEnabled()) { log.BufferAllocated(buffer.GetHashCode(), _bufferLength, _poolId, Id, diff --git a/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Utf8Formatter/FormattingHelpers.cs b/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Utf8Formatter/FormattingHelpers.cs index 1b30d5f..693ad7a 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Utf8Formatter/FormattingHelpers.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Utf8Formatter/FormattingHelpers.cs @@ -29,7 +29,7 @@ namespace System.Buffers.Text // // return (format.IsDefault) ? defaultSymbol : format.Symbol; - var symbol = format.Symbol; + char symbol = format.Symbol; if (symbol == default && format.Precision == default) { symbol = defaultSymbol; diff --git a/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Utf8Formatter/Utf8Formatter.TimeSpan.cs b/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Utf8Formatter/Utf8Formatter.TimeSpan.cs index 6ccd329..c21fddc 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Utf8Formatter/Utf8Formatter.TimeSpan.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Utf8Formatter/Utf8Formatter.TimeSpan.cs @@ -56,7 +56,7 @@ namespace System.Buffers.Text ulong totalSecondsRemaining; { // Turn this into a non-negative TimeSpan if possible. - var ticks = value.Ticks; + long ticks = value.Ticks; if (ticks < 0) { ticks = -ticks; diff --git a/src/libraries/System.Private.CoreLib/src/System/CurrentSystemTimeZone.cs b/src/libraries/System.Private.CoreLib/src/System/CurrentSystemTimeZone.cs index 8cf6674..1459f6e 100644 --- a/src/libraries/System.Private.CoreLib/src/System/CurrentSystemTimeZone.cs +++ b/src/libraries/System.Private.CoreLib/src/System/CurrentSystemTimeZone.cs @@ -156,7 +156,7 @@ namespace System DateTime end; TimeSpan delta; - foreach (var rule in TimeZoneInfo.Local.GetAdjustmentRules()) + foreach (TimeZoneInfo.AdjustmentRule rule in TimeZoneInfo.Local.GetAdjustmentRules()) { if (rule.DateStart.Year <= year && rule.DateEnd.Year >= year && rule.DaylightDelta != TimeSpan.Zero) { diff --git a/src/libraries/System.Private.CoreLib/src/System/Decimal.DecCalc.cs b/src/libraries/System.Private.CoreLib/src/System/Decimal.DecCalc.cs index 1910536..af28aa8 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Decimal.DecCalc.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Decimal.DecCalc.cs @@ -790,7 +790,7 @@ ThrowOverflow: goto HaveScale; } - var powerOvfl = PowerOvflValues; + PowerOvfl[] powerOvfl = PowerOvflValues; if (scale > DEC_SCALE_MAX - 9) { // We can't scale by 10^9 without exceeding the max scale factor. @@ -1787,7 +1787,7 @@ ReturnZero: power = -power; if (power < 10) { - var pow10 = s_powers10[power]; + uint pow10 = s_powers10[power]; ulong low64 = UInt32x32To64((uint)mant, pow10); ulong hi64 = UInt32x32To64((uint)(mant >> 32), pow10); result.Low = (uint)low64; diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Contracts/Contracts.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Contracts/Contracts.cs index 72762e8..3d44c51 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Contracts/Contracts.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Contracts/Contracts.cs @@ -20,6 +20,7 @@ using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Reflection; +using System.Runtime.CompilerServices; namespace System.Diagnostics.Contracts { @@ -666,7 +667,7 @@ namespace System.Diagnostics.Contracts if (probablyNotRewritten == null) probablyNotRewritten = thisAssembly; string? simpleName = probablyNotRewritten.GetName().Name; - System.Runtime.CompilerServices.ContractHelper.TriggerFailure(kind, SR.Format(SR.MustUseCCRewrite, contractKind, simpleName), null, null, null); + ContractHelper.TriggerFailure(kind, SR.Format(SR.MustUseCCRewrite, contractKind, simpleName), null, null, null); } #endregion Private Methods @@ -676,8 +677,7 @@ namespace System.Diagnostics.Contracts /// /// Without contract rewriting, failing Assert/Assumes end up calling this method. /// Code going through the contract rewriter never calls this method. Instead, the rewriter produced failures call - /// System.Runtime.CompilerServices.ContractHelper.RaiseContractFailedEvent, followed by - /// System.Runtime.CompilerServices.ContractHelper.TriggerFailure. + /// ContractHelper.RaiseContractFailedEvent, followed by ContractHelper.TriggerFailure. /// [System.Diagnostics.DebuggerNonUserCode] private static void ReportFailure(ContractFailureKind failureKind, string? userMessage, string? conditionText, Exception? innerException) @@ -686,12 +686,11 @@ namespace System.Diagnostics.Contracts throw new ArgumentException(SR.Format(SR.Arg_EnumIllegalVal, failureKind), nameof(failureKind)); // displayMessage == null means: yes we handled it. Otherwise it is the localized failure message - var displayMessage = System.Runtime.CompilerServices.ContractHelper.RaiseContractFailedEvent(failureKind, userMessage, conditionText, innerException); - + string? displayMessage = ContractHelper.RaiseContractFailedEvent(failureKind, userMessage, conditionText, innerException); if (displayMessage == null) return; - System.Runtime.CompilerServices.ContractHelper.TriggerFailure(failureKind, displayMessage, userMessage, conditionText, innerException); + ContractHelper.TriggerFailure(failureKind, displayMessage, userMessage, conditionText, innerException); } /// @@ -707,11 +706,11 @@ namespace System.Diagnostics.Contracts { add { - System.Runtime.CompilerServices.ContractHelper.InternalContractFailed += value; + ContractHelper.InternalContractFailed += value; } remove { - System.Runtime.CompilerServices.ContractHelper.InternalContractFailed -= value; + ContractHelper.InternalContractFailed -= value; } } diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/ActivityTracker.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/ActivityTracker.cs index 3f2a12d..fe44e03 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/ActivityTracker.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/ActivityTracker.cs @@ -75,10 +75,10 @@ namespace System.Diagnostics.Tracing Debug.Assert((options & EventActivityOptions.Disable) == 0); - var currentActivity = m_current.Value; - var fullActivityName = NormalizeActivityName(providerName, activityName, task); + ActivityInfo? currentActivity = m_current.Value; + string fullActivityName = NormalizeActivityName(providerName, activityName, task); - var log = TplEventSource.Log; + TplEventSource log = TplEventSource.Log; if (log.Debug) { log.DebugFacilityMessage("OnStartEnter", fullActivityName); @@ -143,9 +143,9 @@ namespace System.Diagnostics.Tracing if (m_current == null) // We are not enabled return; - var fullActivityName = NormalizeActivityName(providerName, activityName, task); + string fullActivityName = NormalizeActivityName(providerName, activityName, task); - var log = TplEventSource.Log; + TplEventSource log = TplEventSource.Log; if (log.Debug) { log.DebugFacilityMessage("OnStopEnter", fullActivityName); diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/CounterGroup.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/CounterGroup.cs index 3f023cc..cc4a544 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/CounterGroup.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/CounterGroup.cs @@ -184,7 +184,7 @@ namespace System.Diagnostics.Tracing { lock (s_counterGroupLock) // Lock the CounterGroup { - foreach (var counter in _counters) + foreach (DiagnosticCounter counter in _counters) { if (counter is IncrementingEventCounter ieCounter) { @@ -210,7 +210,7 @@ namespace System.Diagnostics.Tracing DateTime now = DateTime.UtcNow; TimeSpan elapsed = now - _timeStampSinceCollectionStarted; - foreach (var counter in _counters) + foreach (DiagnosticCounter counter in _counters) { counter.WritePayload((float)elapsed.TotalSeconds, _pollingIntervalInMilliseconds); } diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/DiagnosticCounter.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/DiagnosticCounter.cs index e986853..87fb34d 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/DiagnosticCounter.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/DiagnosticCounter.cs @@ -141,7 +141,7 @@ namespace System.Diagnostics.Tracing // Otherwise, append it, then append the element we moved to, and then // iterate through the remainder of the elements, appending each. - var sb = new StringBuilder().Append(current.Key).Append(':').Append(current.Value); + StringBuilder sb = new StringBuilder().Append(current.Key).Append(':').Append(current.Value); do { current = enumerator.Current; diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventCounter.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventCounter.cs index 2cc42d7..59847f1 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventCounter.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventCounter.cs @@ -174,7 +174,7 @@ namespace System.Diagnostics.Tracing Debug.Assert(Monitor.IsEntered(this)); for (int i = 0; i < _bufferedValues.Length; i++) { - var value = Interlocked.Exchange(ref _bufferedValues[i], UnusedBufferSlotValue); + double value = Interlocked.Exchange(ref _bufferedValues[i], UnusedBufferSlotValue); if (value != UnusedBufferSlotValue) { OnMetricWritten(value); diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventProvider.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventProvider.cs index 4b22fc0..47b4ad4 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventProvider.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventProvider.cs @@ -289,7 +289,7 @@ namespace System.Diagnostics.Tracing if (sessionsChanged.Count == 0) sessionsChanged.Add(new Tuple(new SessionInfo(0, 0), true)); - foreach (var session in sessionsChanged) + foreach (Tuple session in sessionsChanged) { int sessionChanged = session.Item1.sessionIdBit; int etwSessionId = session.Item1.etwSessionId; @@ -473,9 +473,9 @@ namespace System.Diagnostics.Tracing byte* buffer; for (; ; ) { - var space = stackalloc byte[buffSize]; + byte* space = stackalloc byte[buffSize]; buffer = space; - var hr = 0; + int hr = 0; fixed (Guid* provider = &m_providerId) { @@ -504,7 +504,7 @@ namespace System.Diagnostics.Tracing if (providerInstance->NextOffset == 0) break; Debug.Assert(0 <= providerInstance->NextOffset && providerInstance->NextOffset < buffSize); - var structBase = (byte*)providerInstance; + byte* structBase = (byte*)providerInstance; providerInstance = (Interop.Advapi32.TRACE_PROVIDER_INSTANCE_INFO*)&structBase[providerInstance->NextOffset]; } #else @@ -609,7 +609,7 @@ namespace System.Diagnostics.Tracing #if ES_BUILD_STANDALONE (new RegistryPermission(RegistryPermissionAccess.Read, regKey)).Assert(); #endif - using (var key = Registry.LocalMachine.OpenSubKey(regKey)) + using (RegistryKey? key = Registry.LocalMachine.OpenSubKey(regKey)) { data = key?.GetValue(valueName, null) as byte[]; if (data != null) diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs index b8d3142..7b22d5c 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs @@ -676,7 +676,7 @@ namespace System.Diagnostics.Tracing if (eventSourceGuid.Equals(Guid.Empty) || eventSourceName == null) { - var myType = this.GetType(); + Type myType = this.GetType(); eventSourceGuid = GetGuid(myType); eventSourceName = GetName(myType); } @@ -1614,7 +1614,7 @@ namespace System.Diagnostics.Tracing /// public void Append(byte[] input) { - foreach (var b in input) + foreach (byte b in input) { this.Append(b); } @@ -3066,7 +3066,7 @@ namespace System.Diagnostics.Tracing { // Let the runtime to the work for us, since we can execute code in this context. Attribute? firstAttribute = null; - foreach (var attribute in member.GetCustomAttributes(attributeType, false)) + foreach (object attribute in member.GetCustomAttributes(attributeType, false)) { firstAttribute = (Attribute)attribute; break; @@ -3249,7 +3249,7 @@ namespace System.Diagnostics.Tracing #if FEATURE_MANAGED_ETW_CHANNELS && FEATURE_ADVANCED_MANAGED_ETW_CHANNELS foreach (var providerEnumKind in new string[] { "Keywords", "Tasks", "Opcodes", "Channels" }) #else - foreach (var providerEnumKind in new string[] { "Keywords", "Tasks", "Opcodes" }) + foreach (string providerEnumKind in new string[] { "Keywords", "Tasks", "Opcodes" }) #endif { Type? nestedType = eventSourceType.GetNestedType(providerEnumKind); @@ -3870,7 +3870,7 @@ namespace System.Diagnostics.Tracing private EventSourceSettings ValidateSettings(EventSourceSettings settings) { - var evtFormatMask = EventSourceSettings.EtwManifestEventFormat | + EventSourceSettings evtFormatMask = EventSourceSettings.EtwManifestEventFormat | EventSourceSettings.EtwSelfDescribingEventFormat; if ((settings & evtFormatMask) == evtFormatMask) { @@ -4347,7 +4347,7 @@ namespace System.Diagnostics.Tracing lock (EventListenersLock) { Debug.Assert(s_EventSources != null); - foreach (var esRef in s_EventSources) + foreach (WeakReference esRef in s_EventSources) { if (esRef.Target is EventSource es) es.Dispose(); @@ -4758,7 +4758,7 @@ namespace System.Diagnostics.Tracing var names = new List(); Debug.Assert(m_eventSource.m_eventData != null); - foreach (var parameter in m_eventSource.m_eventData[EventId].Parameters) + foreach (ParameterInfo parameter in m_eventSource.m_eventData[EventId].Parameters) { names.Add(parameter.Name!); } @@ -5407,7 +5407,7 @@ namespace System.Diagnostics.Tracing if (dllName != null) sb.Append("\" resourceFileName=\"").Append(dllName).Append("\" messageFileName=\"").Append(dllName); - var symbolsName = providerName.Replace("-", "").Replace('.', '_'); // Period and - are illegal replace them. + string symbolsName = providerName.Replace("-", "").Replace('.', '_'); // Period and - are illegal replace them. sb.Append("\" symbol=\"").Append(symbolsName); sb.Append("\">").AppendLine(); } @@ -5522,7 +5522,7 @@ namespace System.Diagnostics.Tracing // We create an array indexed by the channel id for fast look up. // E.g. channelMask[Admin] will give you the bit mask for Admin channel. int maxkey = -1; - foreach (var item in this.channelTab.Keys) + foreach (int item in this.channelTab.Keys) { if (item > maxkey) { @@ -5531,7 +5531,7 @@ namespace System.Diagnostics.Tracing } ulong[] channelMask = new ulong[maxkey + 1]; - foreach (var item in this.channelTab) + foreach (KeyValuePair item in this.channelTab) { channelMask[item.Key] = item.Value.Keywords; } @@ -5713,7 +5713,7 @@ namespace System.Diagnostics.Tracing var sortedChannels = new List>(); foreach (KeyValuePair p in channelTab) { sortedChannels.Add(p); } sortedChannels.Sort((p1, p2) => -Comparer.Default.Compare(p1.Value.Keywords, p2.Value.Keywords)); - foreach (var kvpair in sortedChannels) + foreach (KeyValuePair kvpair in sortedChannels) { int channel = kvpair.Key; ChannelInfo channelInfo = kvpair.Value; @@ -5728,7 +5728,7 @@ namespace System.Diagnostics.Tracing #endif if (channelInfo.Attribs != null) { - var attribs = channelInfo.Attribs; + EventChannelAttribute attribs = channelInfo.Attribs; if (Enum.IsDefined(typeof(EventChannelType), attribs.EventChannelType)) channelType = attribs.EventChannelType.ToString(); enabled = attribs.Enabled; @@ -5901,12 +5901,12 @@ namespace System.Diagnostics.Tracing stringTab.Keys.CopyTo(sortedStrings, 0); Array.Sort(sortedStrings, 0, sortedStrings.Length); - foreach (var ci in cultures) + foreach (CultureInfo ci in cultures) { sb.Append(" ").AppendLine(); sb.Append(" ").AppendLine(); - foreach (var stringKey in sortedStrings) + foreach (string stringKey in sortedStrings) { string? val = GetLocalizedMessage(stringKey, ci, etwFormat: true); sb.Append(" ").AppendLine(); @@ -5960,7 +5960,7 @@ namespace System.Diagnostics.Tracing value = localizedString; if (etwFormat && key.StartsWith("event_", StringComparison.Ordinal)) { - var evtName = key.Substring("event_".Length); + string evtName = key.Substring("event_".Length); value = TranslateToManifestConvention(value, evtName); } } @@ -6113,7 +6113,7 @@ namespace System.Diagnostics.Tracing if (type.IsEnum()) { FieldInfo[] fields = type.GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); - var typeName = GetTypeName(fields[0].FieldType); + string typeName = GetTypeName(fields[0].FieldType); return typeName.Replace("win:Int", "win:UInt"); // ETW requires enums to be unsigned. } @@ -6249,7 +6249,7 @@ namespace System.Diagnostics.Tracing List? byteArrArgIndices; if (perEventByteArrayArgIndices.TryGetValue(evtName, out byteArrArgIndices)) { - foreach (var byArrIdx in byteArrArgIndices) + foreach (int byArrIdx in byteArrArgIndices) { if (idx >= byArrIdx) ++idx; diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/ArrayTypeInfo.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/ArrayTypeInfo.cs index 3a607d4..b4aff00 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/ArrayTypeInfo.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/ArrayTypeInfo.cs @@ -34,9 +34,9 @@ namespace System.Diagnostics.Tracing public override void WriteData(TraceLoggingDataCollector collector, PropertyValue value) { - var bookmark = collector.BeginBufferedArray(); + int bookmark = collector.BeginBufferedArray(); - var count = 0; + int count = 0; Array? array = (Array?)value.ReferenceValue; if (array != null) { diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/ConcurrentSet.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/ConcurrentSet.cs index fca673d..1105b5c 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/ConcurrentSet.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/ConcurrentSet.cs @@ -31,12 +31,12 @@ namespace System.Diagnostics.Tracing public ItemType? TryGet(KeyType key) { ItemType? item; - var oldItems = this.items; + ItemType[]? oldItems = this.items; if (oldItems != null) { - var lo = 0; - var hi = oldItems.Length; + int lo = 0; + int hi = oldItems.Length; do { int i = (lo + hi) / 2; @@ -69,7 +69,7 @@ namespace System.Diagnostics.Tracing public ItemType GetOrAdd(ItemType newItem) { ItemType item; - var oldItems = this.items; + ItemType[]? oldItems = this.items; ItemType[] newItems; Retry: @@ -80,8 +80,8 @@ namespace System.Diagnostics.Tracing } else { - var lo = 0; - var hi = oldItems.Length; + int lo = 0; + int hi = oldItems.Length; do { int i = (lo + hi) / 2; diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/DataCollector.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/DataCollector.cs index 72c5c0a..26d05ae 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/DataCollector.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/DataCollector.cs @@ -83,8 +83,8 @@ namespace System.Diagnostics.Tracing var pb = (byte*)value; if (this.bufferNesting == 0) { - var scratchOld = this.scratch; - var scratchNew = scratchOld + size; + byte* scratchOld = this.scratch; + byte* scratchNew = scratchOld + size; if (this.scratchEnd < scratchNew) { throw new IndexOutOfRangeException(SR.EventSource_AddScalarOutOfRange); @@ -100,7 +100,7 @@ namespace System.Diagnostics.Tracing } else { - var oldPos = this.bufferPos; + int oldPos = this.bufferPos; this.bufferPos = checked(this.bufferPos + size); this.EnsureBuffer(); Debug.Assert(buffer != null); @@ -135,7 +135,7 @@ namespace System.Diagnostics.Tracing } else { - var oldPos = this.bufferPos; + int oldPos = this.bufferPos; this.bufferPos = checked(this.bufferPos + size); this.EnsureBuffer(); Debug.Assert(buffer != null); @@ -177,7 +177,7 @@ namespace System.Diagnostics.Tracing } else { - var oldPos = this.bufferPos; + int oldPos = this.bufferPos; this.bufferPos = checked(this.bufferPos + size); this.EnsureBuffer(); Debug.Assert(buffer != null); @@ -201,7 +201,7 @@ namespace System.Diagnostics.Tracing length = ushort.MaxValue; } - var size = length * itemSize; + int size = length * itemSize; if (this.bufferNesting != 0) { this.EnsureBuffer(size + 2); @@ -218,7 +218,7 @@ namespace System.Diagnostics.Tracing } else { - var oldPos = this.bufferPos; + int oldPos = this.bufferPos; this.bufferPos = checked(this.bufferPos + size); this.EnsureBuffer(); Debug.Assert(value != null && buffer != null); @@ -288,7 +288,7 @@ namespace System.Diagnostics.Tracing private void EnsureBuffer() { - var required = this.bufferPos; + int required = this.bufferPos; if (this.buffer == null || this.buffer.Length < required) { this.GrowBuffer(required); @@ -297,7 +297,7 @@ namespace System.Diagnostics.Tracing private void EnsureBuffer(int additionalSize) { - var required = this.bufferPos + additionalSize; + int required = this.bufferPos + additionalSize; if (this.buffer == null || this.buffer.Length < required) { this.GrowBuffer(required); @@ -306,7 +306,7 @@ namespace System.Diagnostics.Tracing private void GrowBuffer(int required) { - var newSize = this.buffer == null ? 64 : this.buffer.Length; + int newSize = this.buffer == null ? 64 : this.buffer.Length; do { @@ -319,13 +319,13 @@ namespace System.Diagnostics.Tracing private void PinArray(object? value, int size) { - var pinsTemp = this.pins; + GCHandle* pinsTemp = this.pins; if (this.pinsEnd <= pinsTemp) { throw new IndexOutOfRangeException(SR.EventSource_PinArrayOutOfRange); } - var datasTemp = this.datas; + EventSource.EventData* datasTemp = this.datas; if (this.datasEnd <= datasTemp) { throw new IndexOutOfRangeException(SR.EventSource_DataDescriptorsOutOfRange); @@ -343,7 +343,7 @@ namespace System.Diagnostics.Tracing { if (!this.writingScalars) { - var datasTemp = this.datas; + EventSource.EventData* datasTemp = this.datas; if (this.datasEnd <= datasTemp) { throw new IndexOutOfRangeException(SR.EventSource_DataDescriptorsOutOfRange); @@ -358,7 +358,7 @@ namespace System.Diagnostics.Tracing { if (this.writingScalars) { - var datasTemp = this.datas; + EventSource.EventData* datasTemp = this.datas; datasTemp->m_Size = checked((int)(this.scratch - (byte*)datasTemp->m_Ptr)); this.datas = datasTemp + 1; this.writingScalars = false; diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/EnumerableTypeInfo.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/EnumerableTypeInfo.cs index c8ebdf8..ce8e4f4 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/EnumerableTypeInfo.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/EnumerableTypeInfo.cs @@ -35,13 +35,13 @@ namespace System.Diagnostics.Tracing public override void WriteData(TraceLoggingDataCollector collector, PropertyValue value) { - var bookmark = collector.BeginBufferedArray(); + int bookmark = collector.BeginBufferedArray(); - var count = 0; + int count = 0; IEnumerable? enumerable = (IEnumerable?)value.ReferenceValue; if (enumerable != null) { - foreach (var element in enumerable) + foreach (object? element in enumerable) { this.elementInfo.WriteData(collector, elementInfo.PropertyValueFactory(element)); count++; @@ -56,7 +56,7 @@ namespace System.Diagnostics.Tracing Debug.Assert(value != null, "null accepted only for some overrides"); var iterType = (IEnumerable)value; List serializedEnumerable = new List(); - foreach (var element in iterType) + foreach (object? element in iterType) { serializedEnumerable.Add(elementInfo.GetData(element)); } diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/EventPayload.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/EventPayload.cs index 9416d50..9985846 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/EventPayload.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/EventPayload.cs @@ -46,7 +46,7 @@ namespace System.Diagnostics.Tracing throw new System.ArgumentNullException(nameof(key)); int position = 0; - foreach (var name in m_names) + foreach (string name in m_names) { if (name == key) { @@ -88,7 +88,7 @@ namespace System.Diagnostics.Tracing if (key == null) throw new System.ArgumentNullException(nameof(key)); - foreach (var item in m_names) + foreach (string item in m_names) { if (item == key) return true; @@ -135,7 +135,7 @@ namespace System.Diagnostics.Tracing throw new System.ArgumentNullException(nameof(key)); int position = 0; - foreach (var name in m_names) + foreach (string name in m_names) { if (name == key) { diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/FieldMetadata.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/FieldMetadata.cs index 843176b..fbe9765 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/FieldMetadata.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/FieldMetadata.cs @@ -114,7 +114,7 @@ namespace System.Diagnostics.Tracing } Statics.CheckName(name); - var coreType = (int)dataType & Statics.InTypeMask; + int coreType = (int)dataType & Statics.InTypeMask; this.name = name; this.nameSize = Encoding.UTF8.GetByteCount(this.name) + 1; this.inType = (byte)(coreType | countFlags); diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/InvokeTypeInfo.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/InvokeTypeInfo.cs index 34ca144..cfdd4db 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/InvokeTypeInfo.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/InvokeTypeInfo.cs @@ -40,13 +40,13 @@ namespace System.Diagnostics.Tracing string? name, EventFieldFormat format) { - var groupCollector = collector.AddGroup(name); + TraceLoggingMetadataCollector groupCollector = collector.AddGroup(name); if (this.properties != null) { - foreach (var property in this.properties) + foreach (PropertyAnalysis property in this.properties) { - var propertyFormat = EventFieldFormat.Default; - var propertyAttribute = property.fieldAttribute; + EventFieldFormat propertyFormat = EventFieldFormat.Default; + EventFieldAttribute? propertyAttribute = property.fieldAttribute; if (propertyAttribute != null) { groupCollector.Tags = propertyAttribute.Tags; @@ -65,7 +65,7 @@ namespace System.Diagnostics.Tracing { if (this.properties != null) { - foreach (var property in this.properties) + foreach (PropertyAnalysis property in this.properties) { property.typeInfo.WriteData(collector, property.getter(value)); } @@ -80,7 +80,7 @@ namespace System.Diagnostics.Tracing var memebersValues = new List(); for (int i = 0; i < this.properties.Length; i++) { - var propertyValue = properties[i].propertyInfo.GetValue(value); + object? propertyValue = properties[i].propertyInfo.GetValue(value); membersNames.Add(properties[i].name); memebersValues.Add(properties[i].typeInfo.GetData(propertyValue)); } diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/PropertyValue.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/PropertyValue.cs index 03e1098..f0354b3 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/PropertyValue.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/PropertyValue.cs @@ -189,12 +189,12 @@ namespace System.Diagnostics.Tracing /// private static Func GetBoxedValueTypePropertyGetter(PropertyInfo property) { - var type = property.PropertyType; + Type type = property.PropertyType; if (type.GetTypeInfo().IsEnum) type = Enum.GetUnderlyingType(type); - var factory = GetFactory(type); + Func factory = GetFactory(type); return container => factory(property.GetValue(container.ReferenceValue)); } @@ -236,7 +236,7 @@ namespace System.Diagnostics.Tracing { public override Func GetPropertyGetter(PropertyInfo property) { - var type = property.PropertyType; + Type type = property.PropertyType; if (!Statics.IsValueType(type)) { diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/SimpleTypeInfos.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/SimpleTypeInfos.cs index 64579d1..a1f31be 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/SimpleTypeInfos.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/SimpleTypeInfos.cs @@ -207,15 +207,15 @@ namespace System.Diagnostics.Tracing public override void WriteMetadata(TraceLoggingMetadataCollector collector, string? name, EventFieldFormat format) { - var group = collector.AddGroup(name); + TraceLoggingMetadataCollector group = collector.AddGroup(name); group.AddScalar("Ticks", Statics.MakeDataType(TraceLoggingDataType.FileTime, format)); group.AddScalar("Offset", TraceLoggingDataType.Int64); } public override void WriteData(TraceLoggingDataCollector collector, PropertyValue value) { - var dateTimeOffset = value.ScalarValue.AsDateTimeOffset; - var ticks = dateTimeOffset.Ticks; + DateTimeOffset dateTimeOffset = value.ScalarValue.AsDateTimeOffset; + long ticks = dateTimeOffset.Ticks; collector.AddScalar(ticks < 504911232000000000 ? 0 : ticks - 504911232000000000); collector.AddScalar(dateTimeOffset.Offset.Ticks); } @@ -274,7 +274,7 @@ namespace System.Diagnostics.Tracing public NullableTypeInfo(Type type, List recursionCheck) : base(type) { - var typeArgs = type.GenericTypeArguments; + Type[] typeArgs = type.GenericTypeArguments; Debug.Assert(typeArgs.Length == 1); this.valueInfo = TraceLoggingTypeInfo.GetInstance(typeArgs[0], recursionCheck); this.valueGetter = PropertyValue.GetPropertyGetter(type.GetTypeInfo().GetDeclaredProperty("Value")!); @@ -285,7 +285,7 @@ namespace System.Diagnostics.Tracing string? name, EventFieldFormat format) { - var group = collector.AddGroup(name); + TraceLoggingMetadataCollector group = collector.AddGroup(name); group.AddScalar("HasValue", TraceLoggingDataType.Boolean8); this.valueInfo.WriteMetadata(group, "Value", format); } @@ -294,9 +294,9 @@ namespace System.Diagnostics.Tracing { // It's not currently possible to get the HasValue property of a nullable type through reflection when the // value is null. Instead, we simply check that the nullable is not null. - var hasValue = value.ReferenceValue != null; + bool hasValue = value.ReferenceValue != null; collector.AddScalar(hasValue); - var val = hasValue ? valueGetter(value) : valueInfo.PropertyValueFactory(Activator.CreateInstance(valueInfo.DataType)); + PropertyValue val = hasValue ? valueGetter(value) : valueInfo.PropertyValueFactory(Activator.CreateInstance(valueInfo.DataType)); this.valueInfo.WriteData(collector, val); } } diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/Statics.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/Statics.cs index e32b3b8..7087995 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/Statics.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/Statics.cs @@ -116,7 +116,7 @@ namespace System.Diagnostics.Tracing public static void EncodeTags(int tags, ref int pos, byte[]? metadata) { // We transmit the low 28 bits of tags, high bits first, 7 bits at a time. - var tagsLeft = tags & 0xfffffff; + int tagsLeft = tags & 0xfffffff; bool more; do { @@ -379,7 +379,7 @@ namespace System.Diagnostics.Tracing #if (ES_BUILD_PCL || ES_BUILD_PN) result = propInfo.IsDefined(attributeType); #else - var attributes = propInfo.GetCustomAttributes( + object[] attributes = propInfo.GetCustomAttributes( attributeType, false); result = attributes.Length != 0; @@ -398,7 +398,7 @@ namespace System.Diagnostics.Tracing break; } #else - var attributes = propInfo.GetCustomAttributes(typeof(AttributeType), false); + object[] attributes = propInfo.GetCustomAttributes(typeof(AttributeType), false); if (attributes.Length != 0) { result = (AttributeType)attributes[0]; @@ -418,7 +418,7 @@ namespace System.Diagnostics.Tracing break; } #else - var attributes = type.GetCustomAttributes(typeof(AttributeType), false); + object[] attributes = type.GetCustomAttributes(typeof(AttributeType), false); if (attributes.Length != 0) { result = (AttributeType)attributes[0]; @@ -443,12 +443,12 @@ namespace System.Diagnostics.Tracing else { #if (ES_BUILD_PCL || ES_BUILD_PN) - var ifaceTypes = type.GetTypeInfo().ImplementedInterfaces; + IEnumerable ifaceTypes = type.GetTypeInfo().ImplementedInterfaces; #else - var ifaceTypes = type.FindInterfaces(IsGenericMatch, typeof(IEnumerable<>)); + Type[] ifaceTypes = type.FindInterfaces(IsGenericMatch, typeof(IEnumerable<>)); #endif - foreach (var ifaceType in ifaceTypes) + foreach (Type ifaceType in ifaceTypes) { #if (ES_BUILD_PCL || ES_BUILD_PN) if (!IsGenericMatch(ifaceType, typeof(IEnumerable<>))) @@ -503,7 +503,7 @@ namespace System.Diagnostics.Tracing recursionCheck.Add(dataType); - var eventAttrib = Statics.GetCustomAttribute(dataType); + EventDataAttribute? eventAttrib = Statics.GetCustomAttribute(dataType); if (eventAttrib != null || Statics.GetCustomAttribute(dataType) != null || IsGenericMatch(dataType, typeof(KeyValuePair<,>))) @@ -674,7 +674,7 @@ namespace System.Diagnostics.Tracing } else { - var elementType = FindEnumerableElementType(dataType); + Type? elementType = FindEnumerableElementType(dataType); if (elementType != null) { result = new EnumerableTypeInfo(dataType, TraceLoggingTypeInfo.GetInstance(elementType, recursionCheck)); diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/TraceLoggingDataCollector.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/TraceLoggingDataCollector.cs index 419f0f2..48ef0b9 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/TraceLoggingDataCollector.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/TraceLoggingDataCollector.cs @@ -62,7 +62,7 @@ namespace System.Diagnostics.Tracing public void AddScalar(PropertyValue value) { - var scalar = value.ScalarValue; + PropertyValue.Scalar scalar = value.ScalarValue; DataCollector.ThreadInstance.AddScalar(&scalar, value.ScalarLength); } diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/TraceLoggingEventSource.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/TraceLoggingEventSource.cs index e6b9265..71c4330 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/TraceLoggingEventSource.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/TraceLoggingEventSource.cs @@ -418,7 +418,7 @@ namespace System.Diagnostics.Tracing ? options.keywords : eventTypes.keywords; - var nameInfo = eventTypes.GetNameInfo(eventName ?? eventTypes.Name, tags); + NameInfo nameInfo = eventTypes.GetNameInfo(eventName ?? eventTypes.Name, tags); if (nameInfo == null) { return; @@ -433,13 +433,13 @@ namespace System.Diagnostics.Tracing IntPtr eventHandle = IntPtr.Zero; #endif - var pinCount = eventTypes.pinCount; - var scratch = stackalloc byte[eventTypes.scratchSize]; - var descriptors = stackalloc EventData[eventTypes.dataCount + 3]; + int pinCount = eventTypes.pinCount; + byte* scratch = stackalloc byte[eventTypes.scratchSize]; + EventData* descriptors = stackalloc EventData[eventTypes.dataCount + 3]; for (int i = 0; i < eventTypes.dataCount + 3; i++) descriptors[i] = default; - var pins = stackalloc GCHandle[pinCount]; + GCHandle* pins = stackalloc GCHandle[pinCount]; for (int i = 0; i < pinCount; i++) pins[i] = default; @@ -467,7 +467,7 @@ namespace System.Diagnostics.Tracing for (int i = 0; i < eventTypes.typeInfos.Length; i++) { - var info = eventTypes.typeInfos[i]; + TraceLoggingTypeInfo info = eventTypes.typeInfos[i]; info.WriteData(TraceLoggingDataCollector.Instance, info.PropertyValueFactory(values[i])); } @@ -535,7 +535,7 @@ namespace System.Diagnostics.Tracing fixed (EventSourceOptions* pOptions = &options) { EventDescriptor descriptor; - var nameInfo = this.UpdateDescriptor(eventName, eventTypes, ref options, out descriptor); + NameInfo? nameInfo = this.UpdateDescriptor(eventName, eventTypes, ref options, out descriptor); if (nameInfo == null) { return; @@ -550,8 +550,8 @@ namespace System.Diagnostics.Tracing // We make a descriptor for each EventData, and because we morph strings to counted strings // we may have 2 for each arg, so we allocate enough for this. - var descriptorsLength = eventTypes.dataCount + eventTypes.typeInfos.Length * 2 + 3; - var descriptors = stackalloc EventData[descriptorsLength]; + int descriptorsLength = eventTypes.dataCount + eventTypes.typeInfos.Length * 2 + 3; + EventData* descriptors = stackalloc EventData[descriptorsLength]; for (int i = 0; i < descriptorsLength; i++) descriptors[i] = default; @@ -604,7 +604,7 @@ namespace System.Diagnostics.Tracing { EventDescriptor descriptor; options.Opcode = options.IsOpcodeSet ? options.Opcode : GetOpcodeWithDefault(options.Opcode, eventName); - var nameInfo = this.UpdateDescriptor(eventName, eventTypes, ref options, out descriptor); + NameInfo? nameInfo = this.UpdateDescriptor(eventName, eventTypes, ref options, out descriptor); if (nameInfo == null) { return; @@ -618,13 +618,13 @@ namespace System.Diagnostics.Tracing #endif #if FEATURE_MANAGED_ETW - var pinCount = eventTypes.pinCount; - var scratch = stackalloc byte[eventTypes.scratchSize]; - var descriptors = stackalloc EventData[eventTypes.dataCount + 3]; + int pinCount = eventTypes.pinCount; + byte* scratch = stackalloc byte[eventTypes.scratchSize]; + EventData* descriptors = stackalloc EventData[eventTypes.dataCount + 3]; for (int i = 0; i < eventTypes.dataCount + 3; i++) descriptors[i] = default; - var pins = stackalloc GCHandle[pinCount]; + GCHandle* pins = stackalloc GCHandle[pinCount]; for (int i = 0; i < pinCount; i++) pins[i] = default; @@ -675,7 +675,7 @@ namespace System.Diagnostics.Tracing pins, pinCount); - var info = eventTypes.typeInfos[0]; + TraceLoggingTypeInfo info = eventTypes.typeInfos[0]; info.WriteData(TraceLoggingDataCollector.Instance, info.PropertyValueFactory(data)); this.WriteEventRaw( @@ -793,14 +793,14 @@ namespace System.Diagnostics.Tracing traitMetaData.Add(0); // Emit size (to be filled in later) traitMetaData.Add(0); traitMetaData.Add(traitNum); // Emit Trait number - var valueLen = AddValueToMetaData(traitMetaData, value) + 3; // Emit the value bytes +3 accounts for 3 bytes we emited above. + int valueLen = AddValueToMetaData(traitMetaData, value) + 3; // Emit the value bytes +3 accounts for 3 bytes we emited above. traitMetaData[lenPos] = unchecked((byte)valueLen); // Fill in size traitMetaData[lenPos + 1] = unchecked((byte)(valueLen >> 8)); } } providerMetadata = Statics.MetadataForString(this.Name, 0, traitMetaData.Count, 0); int startPos = providerMetadata.Length - traitMetaData.Count; - foreach (var b in traitMetaData) + foreach (byte b in traitMetaData) providerMetadata[startPos++] = b; } else diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/TraceLoggingEventTypes.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/TraceLoggingEventTypes.cs index 9ff1cca..004e1e8 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/TraceLoggingEventTypes.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/TraceLoggingEventTypes.cs @@ -109,11 +109,11 @@ namespace System.Diagnostics.Tracing var collector = new TraceLoggingMetadataCollector(); for (int i = 0; i < typeInfos.Length; ++i) { - var typeInfo = typeInfos[i]; + TraceLoggingTypeInfo typeInfo = typeInfos[i]; this.level = Statics.Combine((int)typeInfo.Level, this.level); this.opcode = Statics.Combine((int)typeInfo.Opcode, this.opcode); this.keywords |= typeInfo.Keywords; - var paramName = paramInfos[i].Name; + string? paramName = paramInfos[i].Name; if (Statics.ShouldOverrideFieldName(paramName!)) { paramName = typeInfo.Name; @@ -143,7 +143,7 @@ namespace System.Diagnostics.Tracing this.level = Statics.DefaultLevel; var collector = new TraceLoggingMetadataCollector(); - foreach (var typeInfo in typeInfos) + foreach (TraceLoggingTypeInfo typeInfo in typeInfos) { this.level = Statics.Combine((int)typeInfo.Level, this.level); this.opcode = Statics.Combine((int)typeInfo.Opcode, this.opcode); @@ -199,7 +199,7 @@ namespace System.Diagnostics.Tracing internal NameInfo GetNameInfo(string name, EventTags tags) { - var ret = this.nameInfos.TryGet(new KeyValuePair(name, tags)); + NameInfo? ret = this.nameInfos.TryGet(new KeyValuePair(name, tags)); if (ret == null) { ret = this.nameInfos.GetOrAdd(new NameInfo(name, tags, this.typeMetadata.Length)); diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/TraceLoggingMetadataCollector.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/TraceLoggingMetadataCollector.cs index 8b522e8..56afab6 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/TraceLoggingMetadataCollector.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/TraceLoggingMetadataCollector.cs @@ -309,7 +309,7 @@ namespace System.Diagnostics.Tracing internal byte[] GetMetadata() { - var size = this.impl.Encode(null); + int size = this.impl.Encode(null); var metadata = new byte[size]; this.impl.Encode(metadata); return metadata; @@ -379,7 +379,7 @@ namespace System.Diagnostics.Tracing { int size = 0; - foreach (var field in this.fields) + foreach (FieldMetadata field in this.fields) { field.Encode(ref size, metadata); } diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/TraceLoggingTypeInfo.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/TraceLoggingTypeInfo.cs index d4bd208..cb84442 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/TraceLoggingTypeInfo.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/TraceLoggingTypeInfo.cs @@ -187,14 +187,14 @@ namespace System.Diagnostics.Tracing public static TraceLoggingTypeInfo GetInstance(Type type, List? recursionCheck) { - var cache = threadCache ?? (threadCache = new Dictionary()); + Dictionary cache = threadCache ?? (threadCache = new Dictionary()); TraceLoggingTypeInfo? instance; if (!cache.TryGetValue(type, out instance)) { if (recursionCheck == null) recursionCheck = new List(); - var recursionCheckCount = recursionCheck.Count; + int recursionCheckCount = recursionCheck.Count; instance = Statics.CreateDefaultTypeInfo(type, recursionCheck); cache[type] = instance; recursionCheck.RemoveRange(recursionCheckCount, recursionCheck.Count - recursionCheckCount); diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/TypeAnalysis.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/TypeAnalysis.cs index ff99f5e..f14c691 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/TypeAnalysis.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/TypeAnalysis.cs @@ -30,10 +30,10 @@ namespace System.Diagnostics.Tracing EventDataAttribute? eventAttrib, List recursionCheck) { - var propertyInfos = Statics.GetProperties(dataType); + IEnumerable propertyInfos = Statics.GetProperties(dataType); var propertyList = new List(); - foreach (var propertyInfo in propertyInfos) + foreach (PropertyInfo propertyInfo in propertyInfos) { if (Statics.HasCustomAttribute(propertyInfo, typeof(EventIgnoreAttribute))) { @@ -57,9 +57,9 @@ namespace System.Diagnostics.Tracing continue; } - var propertyType = propertyInfo.PropertyType; + Type propertyType = propertyInfo.PropertyType; var propertyTypeInfo = TraceLoggingTypeInfo.GetInstance(propertyType, recursionCheck); - var fieldAttribute = Statics.GetCustomAttribute(propertyInfo); + EventFieldAttribute? fieldAttribute = Statics.GetCustomAttribute(propertyInfo); string propertyName = fieldAttribute != null && fieldAttribute.Name != null @@ -76,9 +76,9 @@ namespace System.Diagnostics.Tracing this.properties = propertyList.ToArray(); - foreach (var property in this.properties) + foreach (PropertyAnalysis property in this.properties) { - var typeInfo = property.typeInfo; + TraceLoggingTypeInfo typeInfo = property.typeInfo; this.level = (EventLevel)Statics.Combine((int)typeInfo.Level, (int)this.level); this.opcode = (EventOpcode)Statics.Combine((int)typeInfo.Opcode, (int)this.opcode); this.keywords |= typeInfo.Keywords; diff --git a/src/libraries/System.Private.CoreLib/src/System/Double.cs b/src/libraries/System.Private.CoreLib/src/System/Double.cs index a25a29b..21a32e2 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Double.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Double.cs @@ -73,7 +73,7 @@ namespace System [MethodImpl(MethodImplOptions.AggressiveInlining)] public static unsafe bool IsFinite(double d) { - var bits = BitConverter.DoubleToInt64Bits(d); + long bits = BitConverter.DoubleToInt64Bits(d); return (bits & 0x7FFFFFFFFFFFFFFF) < 0x7FF0000000000000; } @@ -82,7 +82,7 @@ namespace System [MethodImpl(MethodImplOptions.AggressiveInlining)] public static unsafe bool IsInfinity(double d) { - var bits = BitConverter.DoubleToInt64Bits(d); + long bits = BitConverter.DoubleToInt64Bits(d); return (bits & 0x7FFFFFFFFFFFFFFF) == 0x7FF0000000000000; } @@ -91,7 +91,7 @@ namespace System [MethodImpl(MethodImplOptions.AggressiveInlining)] public static unsafe bool IsNaN(double d) { - var bits = BitConverter.DoubleToInt64Bits(d); + long bits = BitConverter.DoubleToInt64Bits(d); return (bits & 0x7FFFFFFFFFFFFFFF) > 0x7FF0000000000000; } @@ -116,7 +116,7 @@ namespace System // This is probably not worth inlining, it has branches and should be rarely called public static unsafe bool IsNormal(double d) { - var bits = BitConverter.DoubleToInt64Bits(d); + long bits = BitConverter.DoubleToInt64Bits(d); bits &= 0x7FFFFFFFFFFFFFFF; return (bits < 0x7FF0000000000000) && (bits != 0) && ((bits & 0x7FF0000000000000) != 0); } @@ -134,7 +134,7 @@ namespace System // This is probably not worth inlining, it has branches and should be rarely called public static unsafe bool IsSubnormal(double d) { - var bits = BitConverter.DoubleToInt64Bits(d); + long bits = BitConverter.DoubleToInt64Bits(d); bits &= 0x7FFFFFFFFFFFFFFF; return (bits < 0x7FF0000000000000) && (bits != 0) && ((bits & 0x7FF0000000000000) == 0); } @@ -260,7 +260,7 @@ namespace System [MethodImpl(MethodImplOptions.AggressiveInlining)] // 64-bit constants make the IL unusually large that makes the inliner to reject the method public override int GetHashCode() { - var bits = Unsafe.As(ref Unsafe.AsRef(in m_value)); + long bits = Unsafe.As(ref Unsafe.AsRef(in m_value)); // Optimized check for IsNan() || IsZero() if (((bits - 1) & 0x7FFFFFFFFFFFFFFF) >= 0x7FF0000000000000) diff --git a/src/libraries/System.Private.CoreLib/src/System/Enum.cs b/src/libraries/System.Private.CoreLib/src/System/Enum.cs index 206b1e3..2444e9e 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Enum.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Enum.cs @@ -243,7 +243,7 @@ namespace System // Helper function to silently convert the value to UInt64 from the other base types for enum without throwing an exception. // This is need since the Convert functions do overflow checks. TypeCode typeCode = Convert.GetTypeCode(value); - var result = typeCode switch + ulong result = typeCode switch { TypeCode.SByte => (ulong)(sbyte)value, TypeCode.Byte => (byte)value, diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/CharUnicodeInfo.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/CharUnicodeInfo.cs index e627cc7..da7fc88 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/CharUnicodeInfo.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/CharUnicodeInfo.cs @@ -124,7 +124,7 @@ namespace System.Globalization // Note that & has the lower precedence than addition, so don't forget the parathesis. index = NumericLevel2Index[(index << 4) + ((ch >> 4) & 0x000f)]; index = NumericLevel3Index[(index << 4) + (ch & 0x000f)]; - ref var value = ref Unsafe.AsRef(in NumericValues[index * 8]); + ref byte value = ref Unsafe.AsRef(in NumericValues[index * 8]); if (BitConverter.IsLittleEndian) { diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/DateTimeFormat.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/DateTimeFormat.cs index 55d4039..34ef0aa 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/DateTimeFormat.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/DateTimeFormat.cs @@ -1162,7 +1162,7 @@ namespace System charsWritten = charsRequired; // Hoist most of the bounds checks on destination. - { var unused = destination[MinimumBytesNeeded - 1]; } + { _ = destination[MinimumBytesNeeded - 1]; } WriteFourDecimalDigits((uint)dateTime.Year, destination, 0); destination[4] = '-'; diff --git a/src/libraries/System.Private.CoreLib/src/System/HashCode.cs b/src/libraries/System.Private.CoreLib/src/System/HashCode.cs index b838d6b..0ff94ad 100644 --- a/src/libraries/System.Private.CoreLib/src/System/HashCode.cs +++ b/src/libraries/System.Private.CoreLib/src/System/HashCode.cs @@ -81,7 +81,7 @@ namespace System // over a larger space, so diffusing the bits may help the // collection work more efficiently. - var hc1 = (uint)(value1?.GetHashCode() ?? 0); + uint hc1 = (uint)(value1?.GetHashCode() ?? 0); uint hash = MixEmptyState(); hash += 4; @@ -94,8 +94,8 @@ namespace System public static int Combine(T1 value1, T2 value2) { - var hc1 = (uint)(value1?.GetHashCode() ?? 0); - var hc2 = (uint)(value2?.GetHashCode() ?? 0); + uint hc1 = (uint)(value1?.GetHashCode() ?? 0); + uint hc2 = (uint)(value2?.GetHashCode() ?? 0); uint hash = MixEmptyState(); hash += 8; @@ -109,9 +109,9 @@ namespace System public static int Combine(T1 value1, T2 value2, T3 value3) { - var hc1 = (uint)(value1?.GetHashCode() ?? 0); - var hc2 = (uint)(value2?.GetHashCode() ?? 0); - var hc3 = (uint)(value3?.GetHashCode() ?? 0); + uint hc1 = (uint)(value1?.GetHashCode() ?? 0); + uint hc2 = (uint)(value2?.GetHashCode() ?? 0); + uint hc3 = (uint)(value3?.GetHashCode() ?? 0); uint hash = MixEmptyState(); hash += 12; @@ -126,10 +126,10 @@ namespace System public static int Combine(T1 value1, T2 value2, T3 value3, T4 value4) { - var hc1 = (uint)(value1?.GetHashCode() ?? 0); - var hc2 = (uint)(value2?.GetHashCode() ?? 0); - var hc3 = (uint)(value3?.GetHashCode() ?? 0); - var hc4 = (uint)(value4?.GetHashCode() ?? 0); + uint hc1 = (uint)(value1?.GetHashCode() ?? 0); + uint hc2 = (uint)(value2?.GetHashCode() ?? 0); + uint hc3 = (uint)(value3?.GetHashCode() ?? 0); + uint hc4 = (uint)(value4?.GetHashCode() ?? 0); Initialize(out uint v1, out uint v2, out uint v3, out uint v4); @@ -147,11 +147,11 @@ namespace System public static int Combine(T1 value1, T2 value2, T3 value3, T4 value4, T5 value5) { - var hc1 = (uint)(value1?.GetHashCode() ?? 0); - var hc2 = (uint)(value2?.GetHashCode() ?? 0); - var hc3 = (uint)(value3?.GetHashCode() ?? 0); - var hc4 = (uint)(value4?.GetHashCode() ?? 0); - var hc5 = (uint)(value5?.GetHashCode() ?? 0); + uint hc1 = (uint)(value1?.GetHashCode() ?? 0); + uint hc2 = (uint)(value2?.GetHashCode() ?? 0); + uint hc3 = (uint)(value3?.GetHashCode() ?? 0); + uint hc4 = (uint)(value4?.GetHashCode() ?? 0); + uint hc5 = (uint)(value5?.GetHashCode() ?? 0); Initialize(out uint v1, out uint v2, out uint v3, out uint v4); @@ -171,12 +171,12 @@ namespace System public static int Combine(T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6) { - var hc1 = (uint)(value1?.GetHashCode() ?? 0); - var hc2 = (uint)(value2?.GetHashCode() ?? 0); - var hc3 = (uint)(value3?.GetHashCode() ?? 0); - var hc4 = (uint)(value4?.GetHashCode() ?? 0); - var hc5 = (uint)(value5?.GetHashCode() ?? 0); - var hc6 = (uint)(value6?.GetHashCode() ?? 0); + uint hc1 = (uint)(value1?.GetHashCode() ?? 0); + uint hc2 = (uint)(value2?.GetHashCode() ?? 0); + uint hc3 = (uint)(value3?.GetHashCode() ?? 0); + uint hc4 = (uint)(value4?.GetHashCode() ?? 0); + uint hc5 = (uint)(value5?.GetHashCode() ?? 0); + uint hc6 = (uint)(value6?.GetHashCode() ?? 0); Initialize(out uint v1, out uint v2, out uint v3, out uint v4); @@ -197,13 +197,13 @@ namespace System public static int Combine(T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7) { - var hc1 = (uint)(value1?.GetHashCode() ?? 0); - var hc2 = (uint)(value2?.GetHashCode() ?? 0); - var hc3 = (uint)(value3?.GetHashCode() ?? 0); - var hc4 = (uint)(value4?.GetHashCode() ?? 0); - var hc5 = (uint)(value5?.GetHashCode() ?? 0); - var hc6 = (uint)(value6?.GetHashCode() ?? 0); - var hc7 = (uint)(value7?.GetHashCode() ?? 0); + uint hc1 = (uint)(value1?.GetHashCode() ?? 0); + uint hc2 = (uint)(value2?.GetHashCode() ?? 0); + uint hc3 = (uint)(value3?.GetHashCode() ?? 0); + uint hc4 = (uint)(value4?.GetHashCode() ?? 0); + uint hc5 = (uint)(value5?.GetHashCode() ?? 0); + uint hc6 = (uint)(value6?.GetHashCode() ?? 0); + uint hc7 = (uint)(value7?.GetHashCode() ?? 0); Initialize(out uint v1, out uint v2, out uint v3, out uint v4); @@ -225,14 +225,14 @@ namespace System public static int Combine(T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6, T7 value7, T8 value8) { - var hc1 = (uint)(value1?.GetHashCode() ?? 0); - var hc2 = (uint)(value2?.GetHashCode() ?? 0); - var hc3 = (uint)(value3?.GetHashCode() ?? 0); - var hc4 = (uint)(value4?.GetHashCode() ?? 0); - var hc5 = (uint)(value5?.GetHashCode() ?? 0); - var hc6 = (uint)(value6?.GetHashCode() ?? 0); - var hc7 = (uint)(value7?.GetHashCode() ?? 0); - var hc8 = (uint)(value8?.GetHashCode() ?? 0); + uint hc1 = (uint)(value1?.GetHashCode() ?? 0); + uint hc2 = (uint)(value2?.GetHashCode() ?? 0); + uint hc3 = (uint)(value3?.GetHashCode() ?? 0); + uint hc4 = (uint)(value4?.GetHashCode() ?? 0); + uint hc5 = (uint)(value5?.GetHashCode() ?? 0); + uint hc6 = (uint)(value6?.GetHashCode() ?? 0); + uint hc7 = (uint)(value7?.GetHashCode() ?? 0); + uint hc8 = (uint)(value8?.GetHashCode() ?? 0); Initialize(out uint v1, out uint v2, out uint v3, out uint v4); @@ -329,7 +329,7 @@ namespace System // To see what's really going on here, have a look at the Combine // methods. - var val = (uint)value; + uint val = (uint)value; // Storing the value of _length locally shaves of quite a few bytes // in the resulting machine code. diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/FileStreamCompletionSource.Win32.cs b/src/libraries/System.Private.CoreLib/src/System/IO/FileStreamCompletionSource.Win32.cs index 19cc300..585a2e1 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IO/FileStreamCompletionSource.Win32.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IO/FileStreamCompletionSource.Win32.cs @@ -80,7 +80,7 @@ namespace System.IO // Quick check to make sure the IO hasn't completed if (_overlapped != null) { - var cancelCallback = s_cancelCallback; + Action? cancelCallback = s_cancelCallback; if (cancelCallback == null) s_cancelCallback = cancelCallback = Cancel; // Register the cancellation only if the IO hasn't completed diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/MemoryStream.cs b/src/libraries/System.Private.CoreLib/src/System/IO/MemoryStream.cs index 28ff039..9999bd0 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IO/MemoryStream.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IO/MemoryStream.cs @@ -413,7 +413,7 @@ namespace System.IO try { int n = Read(buffer, offset, count); - var t = _lastReadTask; + Task? t = _lastReadTask; Debug.Assert(t == null || t.Status == TaskStatus.RanToCompletion, "Expected that a stored last task completed successfully"); return (t != null && t.Result == n) ? t : (_lastReadTask = Task.FromResult(n)); diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/Stream.cs b/src/libraries/System.Private.CoreLib/src/System/IO/Stream.cs index d02f250..18bb90d 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IO/Stream.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IO/Stream.cs @@ -281,7 +281,7 @@ namespace System.IO // don't natively support async IO operations when there are multiple // async requests outstanding, we will block the application's main // thread if it does a second IO request until the first one completes. - var semaphore = EnsureAsyncActiveSemaphoreInitialized(); + SemaphoreSlim semaphore = EnsureAsyncActiveSemaphoreInitialized(); Task? semaphoreTask = null; if (serializeAsynchronously) { @@ -337,7 +337,7 @@ namespace System.IO if (asyncResult == null) throw new ArgumentNullException(nameof(asyncResult)); - var readTask = _activeReadWriteTask; + ReadWriteTask? readTask = _activeReadWriteTask; if (readTask == null) { @@ -444,7 +444,7 @@ namespace System.IO // don't natively support async IO operations when there are multiple // async requests outstanding, we will block the application's main // thread if it does a second IO request until the first one completes. - var semaphore = EnsureAsyncActiveSemaphoreInitialized(); + SemaphoreSlim semaphore = EnsureAsyncActiveSemaphoreInitialized(); Task? semaphoreTask = null; if (serializeAsynchronously) { @@ -544,7 +544,7 @@ namespace System.IO if (asyncResult == null) throw new ArgumentNullException(nameof(asyncResult)); - var writeTask = _activeReadWriteTask; + ReadWriteTask? writeTask = _activeReadWriteTask; if (writeTask == null) { throw new ArgumentException(SR.InvalidOperation_WrongAsyncResultOrEndWriteCalledMultiple); @@ -638,7 +638,7 @@ namespace System.IO { Debug.Assert(completedTask is ReadWriteTask); var rwc = (ReadWriteTask)completedTask; - var callback = rwc._callback; + AsyncCallback? callback = rwc._callback; Debug.Assert(callback != null); rwc._callback = null; callback(rwc); @@ -651,10 +651,10 @@ namespace System.IO // Get the ExecutionContext. If there is none, just run the callback // directly, passing in the completed task as the IAsyncResult. // If there is one, process it with ExecutionContext.Run. - var context = _context; + ExecutionContext? context = _context; if (context == null) { - var callback = _callback; + AsyncCallback? callback = _callback; Debug.Assert(callback != null); _callback = null; callback(completingTask); @@ -663,7 +663,7 @@ namespace System.IO { _context = null; - var invokeAsyncCallback = s_invokeAsyncCallback; + ContextCallback? invokeAsyncCallback = s_invokeAsyncCallback; if (invokeAsyncCallback == null) s_invokeAsyncCallback = invokeAsyncCallback = InvokeAsyncCallback; // benign race condition ExecutionContext.RunInternal(context, invokeAsyncCallback, this); diff --git a/src/libraries/System.Private.CoreLib/src/System/Lazy.cs b/src/libraries/System.Private.CoreLib/src/System/Lazy.cs index 77723d0..1ee87e0 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Lazy.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Lazy.cs @@ -143,7 +143,9 @@ namespace System case LazyThreadSafetyMode.ExecutionAndPublication: // we need to create an object for ExecutionAndPublication because we use Monitor-based locking - var state = useDefaultConstructor ? LazyState.ExecutionAndPublicationViaConstructor : LazyState.ExecutionAndPublicationViaFactory; + LazyState state = useDefaultConstructor ? + LazyState.ExecutionAndPublicationViaConstructor : + LazyState.ExecutionAndPublicationViaFactory; return new LazyHelper(state); default: diff --git a/src/libraries/System.Private.CoreLib/src/System/Math.cs b/src/libraries/System.Private.CoreLib/src/System/Math.cs index cdb11e6..0a78f90 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Math.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Math.cs @@ -117,7 +117,7 @@ namespace System public static double BitDecrement(double x) { - var bits = BitConverter.DoubleToInt64Bits(x); + long bits = BitConverter.DoubleToInt64Bits(x); if (((bits >> 32) & 0x7FF00000) >= 0x7FF00000) { @@ -142,7 +142,7 @@ namespace System public static double BitIncrement(double x) { - var bits = BitConverter.DoubleToInt64Bits(x); + long bits = BitConverter.DoubleToInt64Bits(x); if (((bits >> 32) & 0x7FF00000) >= 0x7FF00000) { @@ -170,8 +170,8 @@ namespace System // This method is required to work for all inputs, // including NaN, so we operate on the raw bits. - var xbits = BitConverter.DoubleToInt64Bits(x); - var ybits = BitConverter.DoubleToInt64Bits(y); + long xbits = BitConverter.DoubleToInt64Bits(x); + long ybits = BitConverter.DoubleToInt64Bits(y); // If the sign bits of x and y are not the same, // flip the sign bit of x and return the new value; @@ -465,7 +465,7 @@ namespace System return y; // IEEE 754-2008: NaN payload must be preserved } - var regularMod = x % y; + double regularMod = x % y; if (double.IsNaN(regularMod)) { @@ -477,12 +477,12 @@ namespace System return double.NegativeZero; } - var alternativeResult = (regularMod - (Abs(y) * Sign(x))); + double alternativeResult = (regularMod - (Abs(y) * Sign(x))); if (Abs(alternativeResult) == Abs(regularMod)) { - var divisionResult = x / y; - var roundedResult = Round(divisionResult); + double divisionResult = x / y; + double roundedResult = Round(divisionResult); if (Abs(roundedResult) > Abs(divisionResult)) { @@ -896,7 +896,7 @@ namespace System if (Abs(value) < doubleRoundLimit) { - var power10 = roundPower10Double[digits]; + double power10 = roundPower10Double[digits]; value *= power10; diff --git a/src/libraries/System.Private.CoreLib/src/System/MathF.cs b/src/libraries/System.Private.CoreLib/src/System/MathF.cs index 382af77..eb8e6b9 100644 --- a/src/libraries/System.Private.CoreLib/src/System/MathF.cs +++ b/src/libraries/System.Private.CoreLib/src/System/MathF.cs @@ -42,7 +42,7 @@ namespace System public static float BitDecrement(float x) { - var bits = BitConverter.SingleToInt32Bits(x); + int bits = BitConverter.SingleToInt32Bits(x); if ((bits & 0x7F800000) >= 0x7F800000) { @@ -67,7 +67,7 @@ namespace System public static float BitIncrement(float x) { - var bits = BitConverter.SingleToInt32Bits(x); + int bits = BitConverter.SingleToInt32Bits(x); if ((bits & 0x7F800000) >= 0x7F800000) { @@ -95,8 +95,8 @@ namespace System // This method is required to work for all inputs, // including NaN, so we operate on the raw bits. - var xbits = BitConverter.SingleToInt32Bits(x); - var ybits = BitConverter.SingleToInt32Bits(y); + int xbits = BitConverter.SingleToInt32Bits(x); + int ybits = BitConverter.SingleToInt32Bits(y); // If the sign bits of x and y are not the same, // flip the sign bit of x and return the new value; @@ -122,7 +122,7 @@ namespace System return y; // IEEE 754-2008: NaN payload must be preserved } - var regularMod = x % y; + float regularMod = x % y; if (float.IsNaN(regularMod)) { @@ -134,12 +134,12 @@ namespace System return float.NegativeZero; } - var alternativeResult = (regularMod - (Abs(y) * Sign(x))); + float alternativeResult = (regularMod - (Abs(y) * Sign(x))); if (Abs(alternativeResult) == Abs(regularMod)) { - var divisionResult = x / y; - var roundedResult = Round(divisionResult); + float divisionResult = x / y; + float roundedResult = Round(divisionResult); if (Abs(roundedResult) > Abs(divisionResult)) { @@ -341,7 +341,7 @@ namespace System if (Abs(x) < singleRoundLimit) { - var power10 = roundPower10Single[digits]; + float power10 = roundPower10Single[digits]; x *= power10; diff --git a/src/libraries/System.Private.CoreLib/src/System/MemoryExtensions.cs b/src/libraries/System.Private.CoreLib/src/System/MemoryExtensions.cs index d8c1cc2..81b7bef 100644 --- a/src/libraries/System.Private.CoreLib/src/System/MemoryExtensions.cs +++ b/src/libraries/System.Private.CoreLib/src/System/MemoryExtensions.cs @@ -478,7 +478,7 @@ namespace System if (Unsafe.SizeOf() == sizeof(char)) { - ref var valueRef = ref Unsafe.As(ref MemoryMarshal.GetReference(values)); + ref char valueRef = ref Unsafe.As(ref MemoryMarshal.GetReference(values)); if (values.Length == 5) { // Length 5 is a common length for FileSystemName expression (", <, >, *, ?) and in preference to 2 as it has an explicit overload @@ -647,7 +647,7 @@ namespace System if (Unsafe.SizeOf() == sizeof(char)) { - ref var valueRef = ref Unsafe.As(ref MemoryMarshal.GetReference(values)); + ref char valueRef = ref Unsafe.As(ref MemoryMarshal.GetReference(values)); if (values.Length == 5) { // Length 5 is a common length for FileSystemName expression (", <, >, *, ?) and in preference to 2 as it has an explicit overload diff --git a/src/libraries/System.Private.CoreLib/src/System/Number.BigInteger.cs b/src/libraries/System.Private.CoreLib/src/System/Number.BigInteger.cs index ffe5fb1..babe90d 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Number.BigInteger.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Number.BigInteger.cs @@ -323,8 +323,8 @@ namespace System public BigInteger(ulong value) { - var lower = (uint)(value); - var upper = (uint)(value >> 32); + uint lower = (uint)(value); + uint upper = (uint)(value >> 32); _blocks[0] = lower; _blocks[1] = upper; @@ -1139,7 +1139,7 @@ namespace System while (index < length) { - var block = (ulong)(_blocks[index]); + ulong block = (ulong)(_blocks[index]); ulong product = (block << 3) + (block << 1) + carry; carry = product >> 32; _blocks[index] = (uint)(product); @@ -1177,8 +1177,8 @@ namespace System public void SetUInt64(ulong value) { - var lower = (uint)(value); - var upper = (uint)(value >> 32); + uint lower = (uint)(value); + uint upper = (uint)(value >> 32); _blocks[0] = lower; _blocks[1] = upper; @@ -1201,7 +1201,7 @@ namespace System public void ShiftLeft(uint shift) { // Process blocks high to low so that we can safely process in place - var length = _length; + int length = _length; if ((length == 0) || (shift == 0)) { diff --git a/src/libraries/System.Private.CoreLib/src/System/Number.Formatting.cs b/src/libraries/System.Private.CoreLib/src/System/Number.Formatting.cs index fce06ac..131e3a0 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Number.Formatting.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Number.Formatting.cs @@ -2426,7 +2426,7 @@ namespace System // function to round correctly instead. This can unfortunately lead to double-rounding // bugs but is the best we have right now due to back-compat concerns. - var digit = dig[i]; + byte digit = dig[i]; if ((digit == '\0') || isCorrectlyRounded) { diff --git a/src/libraries/System.Private.CoreLib/src/System/Resources/ManifestBasedResourceGroveler.cs b/src/libraries/System.Private.CoreLib/src/System/Resources/ManifestBasedResourceGroveler.cs index d16546a..e23a034 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Resources/ManifestBasedResourceGroveler.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Resources/ManifestBasedResourceGroveler.cs @@ -146,7 +146,7 @@ namespace System.Resources { Debug.Assert(a != null, "assembly != null"); - var attr = a.GetCustomAttribute(); + NeutralResourcesLanguageAttribute? attr = a.GetCustomAttribute(); if (attr == null) { fallbackLocation = UltimateResourceFallbackLocation.MainAssembly; diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncMethodBuilder.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncMethodBuilder.cs index 474dc74..98a52f5 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncMethodBuilder.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncMethodBuilder.cs @@ -482,7 +482,7 @@ namespace System.Runtime.CompilerServices // generating this extra code until a better solution is implemented. var box = new AsyncStateMachineBox(); #else - var box = AsyncMethodBuilderCore.TrackAsyncMethodCompletion ? + AsyncStateMachineBox box = AsyncMethodBuilderCore.TrackAsyncMethodCompletion ? CreateDebugFinalizableAsyncStateMachineBox() : new AsyncStateMachineBox(); #endif diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/TaskAwaiter.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/TaskAwaiter.cs index daa5913..3402499 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/TaskAwaiter.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/TaskAwaiter.cs @@ -37,8 +37,10 @@ // // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +using System.Collections.ObjectModel; using System.Diagnostics; using System.Diagnostics.Tracing; +using System.Runtime.ExceptionServices; using System.Threading; using System.Threading.Tasks; @@ -166,7 +168,7 @@ namespace System.Runtime.CompilerServices // TaskCanceledException. TCE derives from OCE, and by throwing it we automatically pick up the // completed task's CancellationToken if it has one, including that CT in the OCE. case TaskStatus.Canceled: - var oceEdi = task.GetCancellationExceptionDispatchInfo(); + ExceptionDispatchInfo? oceEdi = task.GetCancellationExceptionDispatchInfo(); if (oceEdi != null) { oceEdi.Throw(); @@ -177,7 +179,7 @@ namespace System.Runtime.CompilerServices // If the task faulted, throw its first exception, // even if it contained more than one. case TaskStatus.Faulted: - var edis = task.GetExceptionDispatchInfos(); + ReadOnlyCollection edis = task.GetExceptionDispatchInfos(); if (edis.Count > 0) { edis[0].Throw(); @@ -251,15 +253,15 @@ namespace System.Runtime.CompilerServices Task.AddToActiveTasks(task); } - var log = TplEventSource.Log; + TplEventSource log = TplEventSource.Log; if (log.IsEnabled()) { // ETW event for Task Wait Begin - var currentTaskAtBegin = Task.InternalCurrent; + Task? currentTaskAtBegin = Task.InternalCurrent; // If this task's continuation is another task, get it. - var continuationTask = AsyncMethodBuilderCore.TryGetContinuationTask(continuation); + Task? continuationTask = AsyncMethodBuilderCore.TryGetContinuationTask(continuation); log.TaskWaitBegin( (currentTaskAtBegin != null ? currentTaskAtBegin.m_taskScheduler!.Id : TaskScheduler.Default.Id), (currentTaskAtBegin != null ? currentTaskAtBegin.Id : 0), @@ -286,7 +288,7 @@ namespace System.Runtime.CompilerServices bool bEtwLogEnabled = innerEtwLog.IsEnabled(); if (bEtwLogEnabled) { - var currentTaskAtEnd = Task.InternalCurrent; + Task? currentTaskAtEnd = Task.InternalCurrent; innerEtwLog.TaskWaitEnd( (currentTaskAtEnd != null ? currentTaskAtEnd.m_taskScheduler!.Id : TaskScheduler.Default.Id), (currentTaskAtEnd != null ? currentTaskAtEnd.Id : 0), diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/YieldAwaitable.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/YieldAwaitable.cs index bdf751c..9cf3ff8 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/YieldAwaitable.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/YieldAwaitable.cs @@ -83,7 +83,7 @@ namespace System.Runtime.CompilerServices // post the continuation to it. However, treat the base type // as if there wasn't a SynchronizationContext, since that's what it // logically represents. - var syncCtx = SynchronizationContext.Current; + SynchronizationContext? syncCtx = SynchronizationContext.Current; if (syncCtx != null && syncCtx.GetType() != typeof(SynchronizationContext)) { syncCtx.Post(s_sendOrPostCallbackRunAction, continuation); @@ -159,7 +159,7 @@ namespace System.Runtime.CompilerServices return AsyncMethodBuilderCore.CreateContinuationWrapper(continuation, (innerContinuation,continuationIdTask) => { - var log = TplEventSource.Log; + TplEventSource log = TplEventSource.Log; log.TaskWaitContinuationStarted(((Task)continuationIdTask).Result); // ETW event for Task Wait End. diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector128.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector128.cs index 4c32326..f0d5aa8 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector128.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector128.cs @@ -204,7 +204,7 @@ namespace System.Runtime.Intrinsics static Vector128 SoftwareFallback(byte value) { - var pResult = stackalloc byte[16] + byte* pResult = stackalloc byte[16] { value, value, @@ -253,7 +253,7 @@ namespace System.Runtime.Intrinsics static Vector128 SoftwareFallback(double value) { - var pResult = stackalloc double[2] + double* pResult = stackalloc double[2] { value, value, @@ -289,7 +289,7 @@ namespace System.Runtime.Intrinsics static Vector128 SoftwareFallback(short value) { - var pResult = stackalloc short[8] + short* pResult = stackalloc short[8] { value, value, @@ -327,7 +327,7 @@ namespace System.Runtime.Intrinsics static Vector128 SoftwareFallback(int value) { - var pResult = stackalloc int[4] + int* pResult = stackalloc int[4] { value, value, @@ -363,7 +363,7 @@ namespace System.Runtime.Intrinsics static Vector128 SoftwareFallback(long value) { - var pResult = stackalloc long[2] + long* pResult = stackalloc long[2] { value, value, @@ -407,7 +407,7 @@ namespace System.Runtime.Intrinsics static Vector128 SoftwareFallback(sbyte value) { - var pResult = stackalloc sbyte[16] + sbyte* pResult = stackalloc sbyte[16] { value, value, @@ -459,7 +459,7 @@ namespace System.Runtime.Intrinsics static Vector128 SoftwareFallback(float value) { - var pResult = stackalloc float[4] + float* pResult = stackalloc float[4] { value, value, @@ -498,7 +498,7 @@ namespace System.Runtime.Intrinsics static Vector128 SoftwareFallback(ushort value) { - var pResult = stackalloc ushort[8] + ushort* pResult = stackalloc ushort[8] { value, value, @@ -537,7 +537,7 @@ namespace System.Runtime.Intrinsics static Vector128 SoftwareFallback(uint value) { - var pResult = stackalloc uint[4] + uint* pResult = stackalloc uint[4] { value, value, @@ -574,7 +574,7 @@ namespace System.Runtime.Intrinsics static Vector128 SoftwareFallback(ulong value) { - var pResult = stackalloc ulong[2] + ulong* pResult = stackalloc ulong[2] { value, value, @@ -662,7 +662,7 @@ namespace System.Runtime.Intrinsics static Vector128 SoftwareFallback(byte e0, byte e1, byte e2, byte e3, byte e4, byte e5, byte e6, byte e7, byte e8, byte e9, byte e10, byte e11, byte e12, byte e13, byte e14, byte e15) { - var pResult = stackalloc byte[16] + byte* pResult = stackalloc byte[16] { e0, e1, @@ -705,7 +705,7 @@ namespace System.Runtime.Intrinsics static Vector128 SoftwareFallback(double e0, double e1) { - var pResult = stackalloc double[2] + double* pResult = stackalloc double[2] { e0, e1, @@ -744,7 +744,7 @@ namespace System.Runtime.Intrinsics static Vector128 SoftwareFallback(short e0, short e1, short e2, short e3, short e4, short e5, short e6, short e7) { - var pResult = stackalloc short[8] + short* pResult = stackalloc short[8] { e0, e1, @@ -792,7 +792,7 @@ namespace System.Runtime.Intrinsics static Vector128 SoftwareFallback(int e0, int e1, int e2, int e3) { - var pResult = stackalloc int[4] + int* pResult = stackalloc int[4] { e0, e1, @@ -826,7 +826,7 @@ namespace System.Runtime.Intrinsics static Vector128 SoftwareFallback(long e0, long e1) { - var pResult = stackalloc long[2] + long* pResult = stackalloc long[2] { e0, e1, @@ -915,7 +915,7 @@ namespace System.Runtime.Intrinsics static Vector128 SoftwareFallback(sbyte e0, sbyte e1, sbyte e2, sbyte e3, sbyte e4, sbyte e5, sbyte e6, sbyte e7, sbyte e8, sbyte e9, sbyte e10, sbyte e11, sbyte e12, sbyte e13, sbyte e14, sbyte e15) { - var pResult = stackalloc sbyte[16] + sbyte* pResult = stackalloc sbyte[16] { e0, e1, @@ -968,7 +968,7 @@ namespace System.Runtime.Intrinsics static Vector128 SoftwareFallback(float e0, float e1, float e2, float e3) { - var pResult = stackalloc float[4] + float* pResult = stackalloc float[4] { e0, e1, @@ -1010,7 +1010,7 @@ namespace System.Runtime.Intrinsics static Vector128 SoftwareFallback(ushort e0, ushort e1, ushort e2, ushort e3, ushort e4, ushort e5, ushort e6, ushort e7) { - var pResult = stackalloc ushort[8] + ushort* pResult = stackalloc ushort[8] { e0, e1, @@ -1059,7 +1059,7 @@ namespace System.Runtime.Intrinsics static Vector128 SoftwareFallback(uint e0, uint e1, uint e2, uint e3) { - var pResult = stackalloc uint[4] + uint* pResult = stackalloc uint[4] { e0, e1, @@ -1094,7 +1094,7 @@ namespace System.Runtime.Intrinsics static Vector128 SoftwareFallback(ulong e0, ulong e1) { - var pResult = stackalloc ulong[2] + ulong* pResult = stackalloc ulong[2] { e0, e1, @@ -1488,7 +1488,7 @@ namespace System.Runtime.Intrinsics // This relies on us stripping the "init" flag from the ".locals" // declaration to let the upper bits be uninitialized. - var pResult = stackalloc byte[16]; + byte* pResult = stackalloc byte[16]; pResult[0] = value; return Unsafe.AsRef>(pResult); } @@ -1502,7 +1502,7 @@ namespace System.Runtime.Intrinsics // This relies on us stripping the "init" flag from the ".locals" // declaration to let the upper bits be uninitialized. - var pResult = stackalloc double[2]; + double* pResult = stackalloc double[2]; pResult[0] = value; return Unsafe.AsRef>(pResult); } @@ -1516,7 +1516,7 @@ namespace System.Runtime.Intrinsics // This relies on us stripping the "init" flag from the ".locals" // declaration to let the upper bits be uninitialized. - var pResult = stackalloc short[8]; + short* pResult = stackalloc short[8]; pResult[0] = value; return Unsafe.AsRef>(pResult); } @@ -1530,7 +1530,7 @@ namespace System.Runtime.Intrinsics // This relies on us stripping the "init" flag from the ".locals" // declaration to let the upper bits be uninitialized. - var pResult = stackalloc int[4]; + int* pResult = stackalloc int[4]; pResult[0] = value; return Unsafe.AsRef>(pResult); } @@ -1544,7 +1544,7 @@ namespace System.Runtime.Intrinsics // This relies on us stripping the "init" flag from the ".locals" // declaration to let the upper bits be uninitialized. - var pResult = stackalloc long[2]; + long* pResult = stackalloc long[2]; pResult[0] = value; return Unsafe.AsRef>(pResult); } @@ -1559,7 +1559,7 @@ namespace System.Runtime.Intrinsics // This relies on us stripping the "init" flag from the ".locals" // declaration to let the upper bits be uninitialized. - var pResult = stackalloc sbyte[16]; + sbyte* pResult = stackalloc sbyte[16]; pResult[0] = value; return Unsafe.AsRef>(pResult); } @@ -1573,7 +1573,7 @@ namespace System.Runtime.Intrinsics // This relies on us stripping the "init" flag from the ".locals" // declaration to let the upper bits be uninitialized. - var pResult = stackalloc float[4]; + float* pResult = stackalloc float[4]; pResult[0] = value; return Unsafe.AsRef>(pResult); } @@ -1588,7 +1588,7 @@ namespace System.Runtime.Intrinsics // This relies on us stripping the "init" flag from the ".locals" // declaration to let the upper bits be uninitialized. - var pResult = stackalloc ushort[8]; + ushort* pResult = stackalloc ushort[8]; pResult[0] = value; return Unsafe.AsRef>(pResult); } @@ -1603,7 +1603,7 @@ namespace System.Runtime.Intrinsics // This relies on us stripping the "init" flag from the ".locals" // declaration to let the upper bits be uninitialized. - var pResult = stackalloc uint[4]; + uint* pResult = stackalloc uint[4]; pResult[0] = value; return Unsafe.AsRef>(pResult); } @@ -1618,7 +1618,7 @@ namespace System.Runtime.Intrinsics // This relies on us stripping the "init" flag from the ".locals" // declaration to let the upper bits be uninitialized. - var pResult = stackalloc ulong[2]; + ulong* pResult = stackalloc ulong[2]; pResult[0] = value; return Unsafe.AsRef>(pResult); } @@ -1772,7 +1772,7 @@ namespace System.Runtime.Intrinsics // This relies on us stripping the "init" flag from the ".locals" // declaration to let the upper bits be uninitialized. - var pResult = stackalloc byte[Vector256.Size]; + byte* pResult = stackalloc byte[Vector256.Size]; Unsafe.AsRef>(pResult) = vector; return Unsafe.AsRef>(pResult); } diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector256.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector256.cs index 6a982de..7443604 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector256.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector256.cs @@ -193,7 +193,7 @@ namespace System.Runtime.Intrinsics static Vector256 SoftwareFallback(byte value) { - var pResult = stackalloc byte[32] + byte* pResult = stackalloc byte[32] { value, value, @@ -255,7 +255,7 @@ namespace System.Runtime.Intrinsics static Vector256 SoftwareFallback(double value) { - var pResult = stackalloc double[4] + double* pResult = stackalloc double[4] { value, value, @@ -289,7 +289,7 @@ namespace System.Runtime.Intrinsics static Vector256 SoftwareFallback(short value) { - var pResult = stackalloc short[16] + short* pResult = stackalloc short[16] { value, value, @@ -335,7 +335,7 @@ namespace System.Runtime.Intrinsics static Vector256 SoftwareFallback(int value) { - var pResult = stackalloc int[8] + int* pResult = stackalloc int[8] { value, value, @@ -375,7 +375,7 @@ namespace System.Runtime.Intrinsics static Vector256 SoftwareFallback(long value) { - var pResult = stackalloc long[4] + long* pResult = stackalloc long[4] { value, value, @@ -410,7 +410,7 @@ namespace System.Runtime.Intrinsics static Vector256 SoftwareFallback(sbyte value) { - var pResult = stackalloc sbyte[32] + sbyte* pResult = stackalloc sbyte[32] { value, value, @@ -472,7 +472,7 @@ namespace System.Runtime.Intrinsics static Vector256 SoftwareFallback(float value) { - var pResult = stackalloc float[8] + float* pResult = stackalloc float[8] { value, value, @@ -511,7 +511,7 @@ namespace System.Runtime.Intrinsics static Vector256 SoftwareFallback(ushort value) { - var pResult = stackalloc ushort[16] + ushort* pResult = stackalloc ushort[16] { value, value, @@ -558,7 +558,7 @@ namespace System.Runtime.Intrinsics static Vector256 SoftwareFallback(uint value) { - var pResult = stackalloc uint[8] + uint* pResult = stackalloc uint[8] { value, value, @@ -599,7 +599,7 @@ namespace System.Runtime.Intrinsics static Vector256 SoftwareFallback(ulong value) { - var pResult = stackalloc ulong[4] + ulong* pResult = stackalloc ulong[4] { value, value, @@ -659,7 +659,7 @@ namespace System.Runtime.Intrinsics static Vector256 SoftwareFallback(byte e0, byte e1, byte e2, byte e3, byte e4, byte e5, byte e6, byte e7, byte e8, byte e9, byte e10, byte e11, byte e12, byte e13, byte e14, byte e15, byte e16, byte e17, byte e18, byte e19, byte e20, byte e21, byte e22, byte e23, byte e24, byte e25, byte e26, byte e27, byte e28, byte e29, byte e30, byte e31) { - var pResult = stackalloc byte[32] + byte* pResult = stackalloc byte[32] { e0, e1, @@ -719,7 +719,7 @@ namespace System.Runtime.Intrinsics static Vector256 SoftwareFallback(double e0, double e1, double e2, double e3) { - var pResult = stackalloc double[4] + double* pResult = stackalloc double[4] { e0, e1, @@ -763,7 +763,7 @@ namespace System.Runtime.Intrinsics static Vector256 SoftwareFallback(short e0, short e1, short e2, short e3, short e4, short e5, short e6, short e7, short e8, short e9, short e10, short e11, short e12, short e13, short e14, short e15) { - var pResult = stackalloc short[16] + short* pResult = stackalloc short[16] { e0, e1, @@ -811,7 +811,7 @@ namespace System.Runtime.Intrinsics static Vector256 SoftwareFallback(int e0, int e1, int e2, int e3, int e4, int e5, int e6, int e7) { - var pResult = stackalloc int[8] + int* pResult = stackalloc int[8] { e0, e1, @@ -847,7 +847,7 @@ namespace System.Runtime.Intrinsics static Vector256 SoftwareFallback(long e0, long e1, long e2, long e3) { - var pResult = stackalloc long[4] + long* pResult = stackalloc long[4] { e0, e1, @@ -908,7 +908,7 @@ namespace System.Runtime.Intrinsics static Vector256 SoftwareFallback(sbyte e0, sbyte e1, sbyte e2, sbyte e3, sbyte e4, sbyte e5, sbyte e6, sbyte e7, sbyte e8, sbyte e9, sbyte e10, sbyte e11, sbyte e12, sbyte e13, sbyte e14, sbyte e15, sbyte e16, sbyte e17, sbyte e18, sbyte e19, sbyte e20, sbyte e21, sbyte e22, sbyte e23, sbyte e24, sbyte e25, sbyte e26, sbyte e27, sbyte e28, sbyte e29, sbyte e30, sbyte e31) { - var pResult = stackalloc sbyte[32] + sbyte* pResult = stackalloc sbyte[32] { e0, e1, @@ -972,7 +972,7 @@ namespace System.Runtime.Intrinsics static Vector256 SoftwareFallback(float e0, float e1, float e2, float e3, float e4, float e5, float e6, float e7) { - var pResult = stackalloc float[8] + float* pResult = stackalloc float[8] { e0, e1, @@ -1021,7 +1021,7 @@ namespace System.Runtime.Intrinsics static Vector256 SoftwareFallback(ushort e0, ushort e1, ushort e2, ushort e3, ushort e4, ushort e5, ushort e6, ushort e7, ushort e8, ushort e9, ushort e10, ushort e11, ushort e12, ushort e13, ushort e14, ushort e15) { - var pResult = stackalloc ushort[16] + ushort* pResult = stackalloc ushort[16] { e0, e1, @@ -1070,7 +1070,7 @@ namespace System.Runtime.Intrinsics static Vector256 SoftwareFallback(uint e0, uint e1, uint e2, uint e3, uint e4, uint e5, uint e6, uint e7) { - var pResult = stackalloc uint[8] + uint* pResult = stackalloc uint[8] { e0, e1, @@ -1107,7 +1107,7 @@ namespace System.Runtime.Intrinsics static Vector256 SoftwareFallback(ulong e0, ulong e1, ulong e2, ulong e3) { - var pResult = stackalloc ulong[4] + ulong* pResult = stackalloc ulong[4] { e0, e1, @@ -1616,7 +1616,7 @@ namespace System.Runtime.Intrinsics // This relies on us stripping the "init" flag from the ".locals" // declaration to let the upper bits be uninitialized. - var pResult = stackalloc byte[32]; + byte* pResult = stackalloc byte[32]; pResult[0] = value; return Unsafe.AsRef>(pResult); } @@ -1630,7 +1630,7 @@ namespace System.Runtime.Intrinsics // This relies on us stripping the "init" flag from the ".locals" // declaration to let the upper bits be uninitialized. - var pResult = stackalloc double[4]; + double* pResult = stackalloc double[4]; pResult[0] = value; return Unsafe.AsRef>(pResult); } @@ -1644,7 +1644,7 @@ namespace System.Runtime.Intrinsics // This relies on us stripping the "init" flag from the ".locals" // declaration to let the upper bits be uninitialized. - var pResult = stackalloc short[16]; + short* pResult = stackalloc short[16]; pResult[0] = value; return Unsafe.AsRef>(pResult); } @@ -1658,7 +1658,7 @@ namespace System.Runtime.Intrinsics // This relies on us stripping the "init" flag from the ".locals" // declaration to let the upper bits be uninitialized. - var pResult = stackalloc int[8]; + int* pResult = stackalloc int[8]; pResult[0] = value; return Unsafe.AsRef>(pResult); } @@ -1672,7 +1672,7 @@ namespace System.Runtime.Intrinsics // This relies on us stripping the "init" flag from the ".locals" // declaration to let the upper bits be uninitialized. - var pResult = stackalloc long[4]; + long* pResult = stackalloc long[4]; pResult[0] = value; return Unsafe.AsRef>(pResult); } @@ -1687,7 +1687,7 @@ namespace System.Runtime.Intrinsics // This relies on us stripping the "init" flag from the ".locals" // declaration to let the upper bits be uninitialized. - var pResult = stackalloc sbyte[32]; + sbyte* pResult = stackalloc sbyte[32]; pResult[0] = value; return Unsafe.AsRef>(pResult); } @@ -1701,7 +1701,7 @@ namespace System.Runtime.Intrinsics // This relies on us stripping the "init" flag from the ".locals" // declaration to let the upper bits be uninitialized. - var pResult = stackalloc float[8]; + float* pResult = stackalloc float[8]; pResult[0] = value; return Unsafe.AsRef>(pResult); } @@ -1716,7 +1716,7 @@ namespace System.Runtime.Intrinsics // This relies on us stripping the "init" flag from the ".locals" // declaration to let the upper bits be uninitialized. - var pResult = stackalloc ushort[16]; + ushort* pResult = stackalloc ushort[16]; pResult[0] = value; return Unsafe.AsRef>(pResult); } @@ -1731,7 +1731,7 @@ namespace System.Runtime.Intrinsics // This relies on us stripping the "init" flag from the ".locals" // declaration to let the upper bits be uninitialized. - var pResult = stackalloc uint[8]; + uint* pResult = stackalloc uint[8]; pResult[0] = value; return Unsafe.AsRef>(pResult); } @@ -1746,7 +1746,7 @@ namespace System.Runtime.Intrinsics // This relies on us stripping the "init" flag from the ".locals" // declaration to let the upper bits be uninitialized. - var pResult = stackalloc ulong[4]; + ulong* pResult = stackalloc ulong[4]; pResult[0] = value; return Unsafe.AsRef>(pResult); } diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector64.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector64.cs index cb6810a..a81ff00 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector64.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector64.cs @@ -157,7 +157,7 @@ namespace System.Runtime.Intrinsics /// A new with all elements initialized to . public static unsafe Vector64 Create(byte value) { - var pResult = stackalloc byte[8] + byte* pResult = stackalloc byte[8] { value, value, @@ -185,7 +185,7 @@ namespace System.Runtime.Intrinsics /// A new with all elements initialized to . public static unsafe Vector64 Create(short value) { - var pResult = stackalloc short[4] + short* pResult = stackalloc short[4] { value, value, @@ -201,7 +201,7 @@ namespace System.Runtime.Intrinsics /// A new with all elements initialized to . public static unsafe Vector64 Create(int value) { - var pResult = stackalloc int[2] + int* pResult = stackalloc int[2] { value, value, @@ -224,7 +224,7 @@ namespace System.Runtime.Intrinsics [CLSCompliant(false)] public static unsafe Vector64 Create(sbyte value) { - var pResult = stackalloc sbyte[8] + sbyte* pResult = stackalloc sbyte[8] { value, value, @@ -244,7 +244,7 @@ namespace System.Runtime.Intrinsics /// A new with all elements initialized to . public static unsafe Vector64 Create(float value) { - var pResult = stackalloc float[2] + float* pResult = stackalloc float[2] { value, value, @@ -259,7 +259,7 @@ namespace System.Runtime.Intrinsics [CLSCompliant(false)] public static unsafe Vector64 Create(ushort value) { - var pResult = stackalloc ushort[4] + ushort* pResult = stackalloc ushort[4] { value, value, @@ -276,7 +276,7 @@ namespace System.Runtime.Intrinsics [CLSCompliant(false)] public static unsafe Vector64 Create(uint value) { - var pResult = stackalloc uint[2] + uint* pResult = stackalloc uint[2] { value, value, @@ -306,7 +306,7 @@ namespace System.Runtime.Intrinsics /// A new with each element initialized to corresponding specified value. public static unsafe Vector64 Create(byte e0, byte e1, byte e2, byte e3, byte e4, byte e5, byte e6, byte e7) { - var pResult = stackalloc byte[8] + byte* pResult = stackalloc byte[8] { e0, e1, @@ -329,7 +329,7 @@ namespace System.Runtime.Intrinsics /// A new with each element initialized to corresponding specified value. public static unsafe Vector64 Create(short e0, short e1, short e2, short e3) { - var pResult = stackalloc short[4] + short* pResult = stackalloc short[4] { e0, e1, @@ -346,7 +346,7 @@ namespace System.Runtime.Intrinsics /// A new with each element initialized to corresponding specified value. public static unsafe Vector64 Create(int e0, int e1) { - var pResult = stackalloc int[2] + int* pResult = stackalloc int[2] { e0, e1, @@ -368,7 +368,7 @@ namespace System.Runtime.Intrinsics [CLSCompliant(false)] public static unsafe Vector64 Create(sbyte e0, sbyte e1, sbyte e2, sbyte e3, sbyte e4, sbyte e5, sbyte e6, sbyte e7) { - var pResult = stackalloc sbyte[8] + sbyte* pResult = stackalloc sbyte[8] { e0, e1, @@ -389,7 +389,7 @@ namespace System.Runtime.Intrinsics /// A new with each element initialized to corresponding specified value. public static unsafe Vector64 Create(float e0, float e1) { - var pResult = stackalloc float[2] + float* pResult = stackalloc float[2] { e0, e1, @@ -407,7 +407,7 @@ namespace System.Runtime.Intrinsics [CLSCompliant(false)] public static unsafe Vector64 Create(ushort e0, ushort e1, ushort e2, ushort e3) { - var pResult = stackalloc ushort[4] + ushort* pResult = stackalloc ushort[4] { e0, e1, @@ -425,7 +425,7 @@ namespace System.Runtime.Intrinsics [CLSCompliant(false)] public static unsafe Vector64 Create(uint e0, uint e1) { - var pResult = stackalloc uint[2] + uint* pResult = stackalloc uint[2] { e0, e1, @@ -515,7 +515,7 @@ namespace System.Runtime.Intrinsics // This relies on us stripping the "init" flag from the ".locals" // declaration to let the upper bits be uninitialized. - var pResult = stackalloc byte[8]; + byte* pResult = stackalloc byte[8]; pResult[0] = value; return Unsafe.AsRef>(pResult); } @@ -528,7 +528,7 @@ namespace System.Runtime.Intrinsics // This relies on us stripping the "init" flag from the ".locals" // declaration to let the upper bits be uninitialized. - var pResult = stackalloc short[4]; + short* pResult = stackalloc short[4]; pResult[0] = value; return Unsafe.AsRef>(pResult); } @@ -541,7 +541,7 @@ namespace System.Runtime.Intrinsics // This relies on us stripping the "init" flag from the ".locals" // declaration to let the upper bits be uninitialized. - var pResult = stackalloc int[2]; + int* pResult = stackalloc int[2]; pResult[0] = value; return Unsafe.AsRef>(pResult); } @@ -555,7 +555,7 @@ namespace System.Runtime.Intrinsics // This relies on us stripping the "init" flag from the ".locals" // declaration to let the upper bits be uninitialized. - var pResult = stackalloc sbyte[8]; + sbyte* pResult = stackalloc sbyte[8]; pResult[0] = value; return Unsafe.AsRef>(pResult); } @@ -568,7 +568,7 @@ namespace System.Runtime.Intrinsics // This relies on us stripping the "init" flag from the ".locals" // declaration to let the upper bits be uninitialized. - var pResult = stackalloc float[2]; + float* pResult = stackalloc float[2]; pResult[0] = value; return Unsafe.AsRef>(pResult); } @@ -582,7 +582,7 @@ namespace System.Runtime.Intrinsics // This relies on us stripping the "init" flag from the ".locals" // declaration to let the upper bits be uninitialized. - var pResult = stackalloc ushort[4]; + ushort* pResult = stackalloc ushort[4]; pResult[0] = value; return Unsafe.AsRef>(pResult); } @@ -596,7 +596,7 @@ namespace System.Runtime.Intrinsics // This relies on us stripping the "init" flag from the ".locals" // declaration to let the upper bits be uninitialized. - var pResult = stackalloc uint[2]; + uint* pResult = stackalloc uint[2]; pResult[0] = value; return Unsafe.AsRef>(pResult); } @@ -686,7 +686,7 @@ namespace System.Runtime.Intrinsics // This relies on us stripping the "init" flag from the ".locals" // declaration to let the upper bits be uninitialized. - var pResult = stackalloc byte[Vector128.Size]; + byte* pResult = stackalloc byte[Vector128.Size]; Unsafe.AsRef>(pResult) = vector; return Unsafe.AsRef>(pResult); } diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.cs index 200fa1c..cf96292 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.cs @@ -424,7 +424,7 @@ namespace System.Runtime.Loader { lock (s_allContexts) { - foreach (var alcAlive in s_allContexts) + foreach (KeyValuePair> alcAlive in s_allContexts) { if (alcAlive.Value.TryGetTarget(out AssemblyLoadContext? alc)) { diff --git a/src/libraries/System.Private.CoreLib/src/System/Security/SecureString.Windows.cs b/src/libraries/System.Private.CoreLib/src/System/Security/SecureString.Windows.cs index a3bc273..abf9f16 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Security/SecureString.Windows.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Security/SecureString.Windows.cs @@ -271,7 +271,7 @@ namespace System.Security return; } - var oldBuffer = _buffer; + SafeBSTRHandle oldBuffer = _buffer; SafeBSTRHandle newBuffer = SafeBSTRHandle.Allocate(GetAlignedSize((uint)capacity)); SafeBSTRHandle.Copy(oldBuffer, newBuffer, (uint)_decryptedLength * sizeof(char)); _buffer = newBuffer; diff --git a/src/libraries/System.Private.CoreLib/src/System/Single.cs b/src/libraries/System.Private.CoreLib/src/System/Single.cs index 7349134..cdb4f1a 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Single.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Single.cs @@ -68,7 +68,7 @@ namespace System [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsFinite(float f) { - var bits = BitConverter.SingleToInt32Bits(f); + int bits = BitConverter.SingleToInt32Bits(f); return (bits & 0x7FFFFFFF) < 0x7F800000; } @@ -77,7 +77,7 @@ namespace System [MethodImpl(MethodImplOptions.AggressiveInlining)] public static unsafe bool IsInfinity(float f) { - var bits = BitConverter.SingleToInt32Bits(f); + int bits = BitConverter.SingleToInt32Bits(f); return (bits & 0x7FFFFFFF) == 0x7F800000; } @@ -86,7 +86,7 @@ namespace System [MethodImpl(MethodImplOptions.AggressiveInlining)] public static unsafe bool IsNaN(float f) { - var bits = BitConverter.SingleToInt32Bits(f); + int bits = BitConverter.SingleToInt32Bits(f); return (bits & 0x7FFFFFFF) > 0x7F800000; } @@ -111,7 +111,7 @@ namespace System // This is probably not worth inlining, it has branches and should be rarely called public static unsafe bool IsNormal(float f) { - var bits = BitConverter.SingleToInt32Bits(f); + int bits = BitConverter.SingleToInt32Bits(f); bits &= 0x7FFFFFFF; return (bits < 0x7F800000) && (bits != 0) && ((bits & 0x7F800000) != 0); } @@ -129,7 +129,7 @@ namespace System // This is probably not worth inlining, it has branches and should be rarely called public static unsafe bool IsSubnormal(float f) { - var bits = BitConverter.SingleToInt32Bits(f); + int bits = BitConverter.SingleToInt32Bits(f); bits &= 0x7FFFFFFF; return (bits < 0x7F800000) && (bits != 0) && ((bits & 0x7F800000) == 0); } @@ -251,7 +251,7 @@ namespace System [MethodImpl(MethodImplOptions.AggressiveInlining)] public override int GetHashCode() { - var bits = Unsafe.As(ref Unsafe.AsRef(in m_value)); + int bits = Unsafe.As(ref Unsafe.AsRef(in m_value)); // Optimized check for IsNan() || IsZero() if (((bits - 1) & 0x7FFFFFFF) >= 0x7F800000) diff --git a/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.Byte.cs b/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.Byte.cs index c1c50a4..d553d97 100644 --- a/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.Byte.cs +++ b/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.Byte.cs @@ -69,7 +69,7 @@ namespace System int offset = -1; for (int i = 0; i < valueLength; i++) { - var tempIndex = IndexOf(ref searchSpace, Unsafe.Add(ref value, i), searchSpaceLength); + int tempIndex = IndexOf(ref searchSpace, Unsafe.Add(ref value, i), searchSpaceLength); if ((uint)tempIndex < (uint)offset) { offset = tempIndex; @@ -94,7 +94,7 @@ namespace System int offset = -1; for (int i = 0; i < valueLength; i++) { - var tempIndex = LastIndexOf(ref searchSpace, Unsafe.Add(ref value, i), searchSpaceLength); + int tempIndex = LastIndexOf(ref searchSpace, Unsafe.Add(ref value, i), searchSpaceLength); if (tempIndex > offset) offset = tempIndex; } @@ -1592,7 +1592,7 @@ namespace System else { // Flag least significant power of two bit - var powerOfTwoFlag = match ^ (match - 1); + ulong powerOfTwoFlag = match ^ (match - 1); // Shift all powers of two into the high byte and extract return (int)((powerOfTwoFlag * XorPowerOfTwoToHighByte) >> 57); } diff --git a/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.Char.cs b/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.Char.cs index a628538..1c73da2 100644 --- a/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.Char.cs +++ b/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.Char.cs @@ -993,7 +993,7 @@ namespace System unchecked { // Flag least significant power of two bit - var powerOfTwoFlag = match ^ (match - 1); + ulong powerOfTwoFlag = match ^ (match - 1); // Shift all powers of two into the high byte and extract return (int)((powerOfTwoFlag * XorPowerOfTwoToHighChar) >> 49); } diff --git a/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.T.cs b/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.T.cs index 7419bb0..faf3733 100644 --- a/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.T.cs +++ b/src/libraries/System.Private.CoreLib/src/System/SpanHelpers.T.cs @@ -442,7 +442,7 @@ namespace System int index = -1; for (int i = 0; i < valueLength; i++) { - var tempIndex = IndexOf(ref searchSpace, Unsafe.Add(ref value, i), searchSpaceLength); + int tempIndex = IndexOf(ref searchSpace, Unsafe.Add(ref value, i), searchSpaceLength); if ((uint)tempIndex < (uint)index) { index = tempIndex; @@ -803,7 +803,7 @@ namespace System int index = -1; for (int i = 0; i < valueLength; i++) { - var tempIndex = LastIndexOf(ref searchSpace, Unsafe.Add(ref value, i), searchSpaceLength); + int tempIndex = LastIndexOf(ref searchSpace, Unsafe.Add(ref value, i), searchSpaceLength); if (tempIndex > index) index = tempIndex; } @@ -910,7 +910,7 @@ namespace System Debug.Assert(firstLength >= 0); Debug.Assert(secondLength >= 0); - var minLength = firstLength; + int minLength = firstLength; if (minLength > secondLength) minLength = secondLength; for (int i = 0; i < minLength; i++) diff --git a/src/libraries/System.Private.CoreLib/src/System/String.Comparison.cs b/src/libraries/System.Private.CoreLib/src/System/String.Comparison.cs index 1b98491..a0e9a9c 100644 --- a/src/libraries/System.Private.CoreLib/src/System/String.Comparison.cs +++ b/src/libraries/System.Private.CoreLib/src/System/String.Comparison.cs @@ -192,7 +192,7 @@ namespace System // public static int Compare(string? strA, string? strB, bool ignoreCase) { - var comparisonType = ignoreCase ? StringComparison.CurrentCultureIgnoreCase : StringComparison.CurrentCulture; + StringComparison comparisonType = ignoreCase ? StringComparison.CurrentCultureIgnoreCase : StringComparison.CurrentCulture; return Compare(strA, strB, comparisonType); } @@ -268,7 +268,7 @@ namespace System // public static int Compare(string? strA, string? strB, bool ignoreCase, CultureInfo? culture) { - var options = ignoreCase ? CompareOptions.IgnoreCase : CompareOptions.None; + CompareOptions options = ignoreCase ? CompareOptions.IgnoreCase : CompareOptions.None; return Compare(strA, strB, culture, options); } @@ -316,7 +316,7 @@ namespace System lengthB = Math.Min(lengthB, strB.Length - indexB); } - var options = ignoreCase ? CompareOptions.IgnoreCase : CompareOptions.None; + CompareOptions options = ignoreCase ? CompareOptions.IgnoreCase : CompareOptions.None; return CultureInfo.CurrentCulture.CompareInfo.Compare(strA, indexA, lengthA, strB, indexB, lengthB, options); } @@ -327,7 +327,7 @@ namespace System // public static int Compare(string? strA, int indexA, string? strB, int indexB, int length, bool ignoreCase, CultureInfo? culture) { - var options = ignoreCase ? CompareOptions.IgnoreCase : CompareOptions.None; + CompareOptions options = ignoreCase ? CompareOptions.IgnoreCase : CompareOptions.None; return Compare(strA, indexA, strB, indexB, length, culture, options); } diff --git a/src/libraries/System.Private.CoreLib/src/System/String.Searching.cs b/src/libraries/System.Private.CoreLib/src/System/String.Searching.cs index 5b4a1fc9..d77b4a2 100644 --- a/src/libraries/System.Private.CoreLib/src/System/String.Searching.cs +++ b/src/libraries/System.Private.CoreLib/src/System/String.Searching.cs @@ -107,7 +107,7 @@ namespace System if (anyOf.Length > 0 && anyOf.Length <= 5) { // The ReadOnlySpan.IndexOfAny extension is vectorized for values of 1 - 5 in length - var result = new ReadOnlySpan(ref Unsafe.Add(ref _firstChar, startIndex), count).IndexOfAny(anyOf); + int result = new ReadOnlySpan(ref Unsafe.Add(ref _firstChar, startIndex), count).IndexOfAny(anyOf); return result == -1 ? result : result + startIndex; } else if (anyOf.Length > 5) @@ -268,7 +268,7 @@ namespace System if (comparisonType == StringComparison.Ordinal) { - var result = SpanHelpers.IndexOf( + int result = SpanHelpers.IndexOf( ref Unsafe.Add(ref this._firstChar, startIndex), count, ref value._firstChar, diff --git a/src/libraries/System.Private.CoreLib/src/System/StringComparer.cs b/src/libraries/System.Private.CoreLib/src/System/StringComparer.cs index f9bd66f..04ce0ed 100644 --- a/src/libraries/System.Private.CoreLib/src/System/StringComparer.cs +++ b/src/libraries/System.Private.CoreLib/src/System/StringComparer.cs @@ -186,7 +186,7 @@ namespace System _compareInfo = (CompareInfo)info.GetValue("_compareInfo", typeof(CompareInfo))!; bool ignoreCase = info.GetBoolean("_ignoreCase"); - var obj = info.GetValueNoThrow("_options", typeof(CompareOptions)); + object? obj = info.GetValueNoThrow("_options", typeof(CompareOptions)); if (obj != null) _options = (CompareOptions)obj; diff --git a/src/libraries/System.Private.CoreLib/src/System/Text/StringBuilder.cs b/src/libraries/System.Private.CoreLib/src/System/Text/StringBuilder.cs index cdaa9bd..8c744ae 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Text/StringBuilder.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Text/StringBuilder.cs @@ -1319,7 +1319,7 @@ namespace System.Text return this; } - var value = en.Current; + T value = en.Current; if (value != null) { Append(value.ToString()); diff --git a/src/libraries/System.Private.CoreLib/src/System/Text/ValueStringBuilder.cs b/src/libraries/System.Private.CoreLib/src/System/Text/ValueStringBuilder.cs index de7fc50..617a90d 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Text/ValueStringBuilder.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Text/ValueStringBuilder.cs @@ -85,7 +85,7 @@ namespace System.Text public override string ToString() { - var s = _chars.Slice(0, _pos).ToString(); + string s = _chars.Slice(0, _pos).ToString(); Dispose(); return s; } diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/SemaphoreSlim.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/SemaphoreSlim.cs index e9ddfbd..68925bb 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/SemaphoreSlim.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/SemaphoreSlim.cs @@ -643,7 +643,7 @@ namespace System.Threading else { Debug.Assert(m_currentCount == 0, "m_currentCount should never be negative"); - var asyncWaiter = CreateAndAddAsyncWaiter(); + TaskNode asyncWaiter = CreateAndAddAsyncWaiter(); return (millisecondsTimeout == Timeout.Infinite && !cancellationToken.CanBeCanceled) ? asyncWaiter : WaitUntilCountOrTimeoutAsync(asyncWaiter, millisecondsTimeout, cancellationToken); @@ -851,7 +851,7 @@ namespace System.Threading --maxAsyncToRelease; // Get the next async waiter to release and queue it to be completed - var waiterTask = m_asyncHead; + TaskNode waiterTask = m_asyncHead; RemoveAsyncWaiter(waiterTask); // ensures waiterTask.Next/Prev are null waiterTask.TrySetResult(result: true); } diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/ConcurrentExclusiveSchedulerPair.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/ConcurrentExclusiveSchedulerPair.cs index a0b3db0..342600e 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/ConcurrentExclusiveSchedulerPair.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/ConcurrentExclusiveSchedulerPair.cs @@ -190,7 +190,7 @@ namespace System.Threading.Tasks if (!CompletionRequested || m_processingCount != 0) return false; // Now, only allow shutdown if an exception occurred or if there are no more tasks to process. - var cs = EnsureCompletionStateInitialized(); + CompletionState cs = EnsureCompletionStateInitialized(); return (cs.m_exceptions != null && cs.m_exceptions.Count > 0) || (m_concurrentTaskScheduler.m_tasks.IsEmpty && m_exclusiveTaskScheduler.m_tasks.IsEmpty); @@ -205,7 +205,7 @@ namespace System.Threading.Tasks // Ensure we only try to complete once, then schedule completion // in order to escape held locks and the caller's context - var cs = EnsureCompletionStateInitialized(); + CompletionState cs = EnsureCompletionStateInitialized(); if (!cs.m_completionQueued) { cs.m_completionQueued = true; @@ -235,7 +235,7 @@ namespace System.Threading.Tasks ContractAssertMonitorStatus(ValueLock, held: true); // Store the faulted task's exceptions - var cs = EnsureCompletionStateInitialized(); + CompletionState cs = EnsureCompletionStateInitialized(); if (cs.m_exceptions == null) cs.m_exceptions = new List(); cs.m_exceptions.AddRange(faultedTask.Exception.InnerExceptions); @@ -744,7 +744,7 @@ namespace System.Threading.Tasks if (m_completionState != null && m_completionState.IsCompleted) return ProcessingMode.Completed; // Otherwise, summarize our current state. - var mode = ProcessingMode.NotCurrentlyProcessing; + ProcessingMode mode = ProcessingMode.NotCurrentlyProcessing; if (m_processingCount == EXCLUSIVE_PROCESSING_SENTINEL) mode |= ProcessingMode.ProcessingExclusiveTask; if (m_processingCount >= 1) mode |= ProcessingMode.ProcessingConcurrentTasks; if (CompletionRequested) mode |= ProcessingMode.Completing; diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/FutureFactory.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/FutureFactory.cs index d0ae442..adaf056 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/FutureFactory.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/FutureFactory.cs @@ -774,7 +774,7 @@ namespace System.Threading.Tasks try { //if we don't require synchronization, a faster set result path is taken - var asyncResult = beginMethod(iar => + IAsyncResult asyncResult = beginMethod(iar => { if (!iar.CompletedSynchronously) FromAsyncCoreLogic(iar, endFunction, endAction, promise, requiresSynchronization: true); @@ -891,7 +891,7 @@ namespace System.Threading.Tasks try { //if we don't require synchronization, a faster set result path is taken - var asyncResult = beginMethod(arg1, iar => + IAsyncResult asyncResult = beginMethod(arg1, iar => { if (!iar.CompletedSynchronously) FromAsyncCoreLogic(iar, endFunction, endAction, promise, requiresSynchronization: true); @@ -1016,7 +1016,7 @@ namespace System.Threading.Tasks try { //if we don't require synchronization, a faster set result path is taken - var asyncResult = beginMethod(arg1, arg2, iar => + IAsyncResult asyncResult = beginMethod(arg1, arg2, iar => { if (!iar.CompletedSynchronously) FromAsyncCoreLogic(iar, endFunction, endAction, promise, requiresSynchronization: true); @@ -1149,7 +1149,7 @@ namespace System.Threading.Tasks try { //if we don't require synchronization, a faster set result path is taken - var asyncResult = beginMethod(arg1, arg2, arg3, iar => + IAsyncResult asyncResult = beginMethod(arg1, arg2, arg3, iar => { if (!iar.CompletedSynchronously) FromAsyncCoreLogic(iar, endFunction, endAction, promise, requiresSynchronization: true); @@ -1204,7 +1204,7 @@ namespace System.Threading.Tasks // the task doesn't have AttachedToParent set on it, there's no need to complete it in // case of an exception occurring... we can just let it go unresolved. var promise = new FromAsyncTrimPromise(thisRef, endMethod); - var asyncResult = beginMethod(thisRef, args, FromAsyncTrimPromise.s_completeFromAsyncResult, promise); + IAsyncResult asyncResult = beginMethod(thisRef, args, FromAsyncTrimPromise.s_completeFromAsyncResult, promise); // If the IAsyncResult completed asynchronously, completing the promise will be handled by the callback. // If it completed synchronously, we'll handle that here. @@ -1229,7 +1229,7 @@ namespace System.Threading.Tasks internal static readonly AsyncCallback s_completeFromAsyncResult = CompleteFromAsyncResult; /// A reference to the object on which the begin/end methods are invoked. - [AllowNull, MaybeNull] private TInstance m_thisRef; + private TInstance? m_thisRef; /// The end method. private Func? m_endMethod; @@ -1258,8 +1258,8 @@ namespace System.Threading.Tasks if (promise == null) ThrowHelper.ThrowArgumentException(ExceptionResource.InvalidOperation_WrongAsyncResultOrEndCalledMultiple, ExceptionArgument.asyncResult); // Grab the relevant state and then null it out so that the task doesn't hold onto the state unnecessarily - var thisRef = promise.m_thisRef; - var endMethod = promise.m_endMethod; + TInstance? thisRef = promise.m_thisRef; + Func? endMethod = promise.m_endMethod; promise.m_thisRef = default; promise.m_endMethod = null; if (endMethod == null) ThrowHelper.ThrowArgumentException(ExceptionResource.InvalidOperation_WrongAsyncResultOrEndCalledMultiple, ExceptionArgument.asyncResult); @@ -1291,7 +1291,7 @@ namespace System.Threading.Tasks bool successfullySet; try { - var result = endMethod(thisRef, asyncResult); + TResult result = endMethod(thisRef, asyncResult); if (requiresSynchronization) { successfullySet = TrySetResult(result); @@ -1623,7 +1623,7 @@ namespace System.Threading.Tasks } // Call common ContinueWhenAll() setup logic, extract starter task. - var starter = TaskFactory.CommonCWAllLogic(tasksCopy); + Task[]> starter = TaskFactory.CommonCWAllLogic(tasksCopy); // returned continuation task, off of starter if (continuationFunction != null) @@ -1669,7 +1669,7 @@ namespace System.Threading.Tasks } // Perform common ContinueWhenAll() setup logic, extract starter task - var starter = TaskFactory.CommonCWAllLogic(tasksCopy); + Task starter = TaskFactory.CommonCWAllLogic(tasksCopy); // returned continuation task, off of starter if (continuationFunction != null) @@ -2044,7 +2044,7 @@ namespace System.Threading.Tasks if (scheduler == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.scheduler); // Call common ContinueWhenAny setup logic, extract starter - var starter = TaskFactory.CommonCWAnyLogic(tasks); + Task starter = TaskFactory.CommonCWAnyLogic(tasks); // Bail early if cancellation has been requested. if (cancellationToken.IsCancellationRequested diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/ProducerConsumerQueues.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/ProducerConsumerQueues.cs index 251ba45..8a45e3e 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/ProducerConsumerQueues.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/ProducerConsumerQueues.cs @@ -145,7 +145,7 @@ namespace System.Threading.Tasks public void Enqueue(T item) { Segment segment = m_tail; - var array = segment.m_array; + T[] array = segment.m_array; int last = segment.m_state.m_last; // local copy to avoid multiple volatile reads // Fast path: there's obviously room in the current segment @@ -198,7 +198,7 @@ namespace System.Threading.Tasks public bool TryDequeue([MaybeNullWhen(false)] out T result) { Segment segment = m_head; - var array = segment.m_array; + T[] array = segment.m_array; int first = segment.m_state.m_first; // local copy to avoid multiple volatile reads // Fast path: there's obviously data available in the current segment @@ -236,7 +236,7 @@ namespace System.Threading.Tasks m_head = segment; } - var first = segment.m_state.m_first; // local copy to avoid extraneous volatile reads + int first = segment.m_state.m_first; // local copy to avoid extraneous volatile reads if (first == segment.m_state.m_last) { @@ -259,7 +259,7 @@ namespace System.Threading.Tasks // This implementation is optimized for calls from the consumer. get { - var head = m_head; + Segment head = m_head; if (head.m_state.m_first != head.m_state.m_lastCopy) return false; // m_first is volatile, so the read of m_lastCopy cannot get reordered if (head.m_state.m_first != head.m_state.m_last) return false; return head.m_next == null; diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs index 11ebc1c..79f2cae 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs @@ -256,7 +256,7 @@ namespace System.Threading.Tasks /// internal void SetCompleted() { - var mres = m_completionEvent; + ManualResetEventSlim? mres = m_completionEvent; if (mres != null) mres.Set(); } @@ -778,7 +778,7 @@ namespace System.Threading.Tasks internal static bool AnyTaskRequiresNotifyDebuggerOfWaitCompletion(Task?[] tasks) { Debug.Assert(tasks != null, "Expected non-null array of tasks"); - foreach (var task in tasks) + foreach (Task? task in tasks) { if (task != null && task.IsWaitNotificationEnabled && @@ -878,7 +878,7 @@ namespace System.Threading.Tasks { Debug.Assert(Task.InternalCurrent == this, "Task.AddNewChild(): Called from an external context"); - var props = EnsureContingentPropertiesInitialized(); + ContingentProperties props = EnsureContingentPropertiesInitialized(); if (props.m_completionCountdown == 1) { @@ -899,7 +899,7 @@ namespace System.Threading.Tasks { Debug.Assert(Task.InternalCurrent == this, "Task.DisregardChild(): Called from an external context"); - var props = EnsureContingentPropertiesInitialized(); + ContingentProperties props = EnsureContingentPropertiesInitialized(); Debug.Assert(props.m_completionCountdown >= 2, "Task.DisregardChild(): Expected parent count to be >= 2"); Interlocked.Decrement(ref props.m_completionCountdown); } @@ -959,7 +959,7 @@ namespace System.Threading.Tasks ThrowHelper.ThrowArgumentNullException(ExceptionArgument.scheduler); } - var options = OptionsMethod(flags); + TaskCreationOptions options = OptionsMethod(flags); if ((options & (TaskCreationOptions)InternalTaskOptions.PromiseTask) != 0) { ThrowHelper.ThrowInvalidOperationException(ExceptionResource.Task_Start_Promise); @@ -1051,7 +1051,7 @@ namespace System.Threading.Tasks int flags = m_stateFlags; // Can't call this method on a continuation task - var options = OptionsMethod(flags); + TaskCreationOptions options = OptionsMethod(flags); if ((options & (TaskCreationOptions)InternalTaskOptions.ContinuationTask) != 0) { ThrowHelper.ThrowInvalidOperationException(ExceptionResource.Task_RunSynchronously_Continuation); @@ -1330,7 +1330,7 @@ namespace System.Threading.Tasks get { // check both the internal cancellation request flag and the CancellationToken attached to this task - var props = Volatile.Read(ref m_contingentProperties); + ContingentProperties? props = Volatile.Read(ref m_contingentProperties); return props != null && (props.m_internalCancellationRequested == CANCELLATION_REQUESTED || props.m_cancellationToken.IsCancellationRequested); @@ -1365,7 +1365,7 @@ namespace System.Threading.Tasks { get { - var props = Volatile.Read(ref m_contingentProperties); + ContingentProperties? props = Volatile.Read(ref m_contingentProperties); return (props == null) ? default : props.m_cancellationToken; } } @@ -1495,7 +1495,7 @@ namespace System.Threading.Tasks { get { - var contingentProps = EnsureContingentPropertiesInitialized(); + ContingentProperties contingentProps = EnsureContingentPropertiesInitialized(); if (contingentProps.m_completionEvent == null) { bool wasCompleted = IsCompleted; @@ -1525,7 +1525,7 @@ namespace System.Threading.Tasks { get { - var props = Volatile.Read(ref m_contingentProperties); + ContingentProperties? props = Volatile.Read(ref m_contingentProperties); return (props != null) && (props.m_exceptionsHolder != null) && (props.m_exceptionsHolder.ContainsFaultList); } } @@ -1635,13 +1635,13 @@ namespace System.Threading.Tasks } // Dispose of the underlying completion event if it exists - var cp = Volatile.Read(ref m_contingentProperties); + ContingentProperties? cp = Volatile.Read(ref m_contingentProperties); if (cp != null) { // Make a copy to protect against racing Disposes. // If we wanted to make this a bit safer, we could use an interlocked here, // but we state that Dispose is not thread safe. - var ev = cp.m_completionEvent; + ManualResetEventSlim? ev = cp.m_completionEvent; if (ev != null) { // Null out the completion event in contingent props; we'll use our copy from here on out @@ -1790,7 +1790,7 @@ namespace System.Threading.Tasks // // Lazily initialize the holder, ensuring only one thread wins. - var props = EnsureContingentPropertiesInitialized(); + ContingentProperties props = EnsureContingentPropertiesInitialized(); if (props.m_exceptionsHolder == null) { TaskExceptionHolder holder = new TaskExceptionHolder(this); @@ -2194,7 +2194,7 @@ namespace System.Threading.Tasks Debug.Assert(childTask.m_contingentProperties?.m_parent == this, "ProcessChildCompletion should only be called for a child of this task"); - var props = Volatile.Read(ref m_contingentProperties); + ContingentProperties? props = Volatile.Read(ref m_contingentProperties); // if the child threw and we haven't observed it we need to save it for future reference if (childTask.IsFaulted && !childTask.IsExceptionObservedByParent) @@ -2343,7 +2343,7 @@ namespace System.Threading.Tasks Task? previousTask = currentTaskSlot; // ETW event for Task Started - var log = TplEventSource.Log; + TplEventSource log = TplEventSource.Log; Guid savedActivityID = new Guid(); bool etwIsEnabled = log.IsEnabled(); if (etwIsEnabled) @@ -2524,7 +2524,7 @@ namespace System.Threading.Tasks // then ignore it. This helps with performance by avoiding unnecessary posts and queueing // of work items, but more so it ensures that if code happens to publish the default context // as current, it won't prevent usage of a current task scheduler if there is one. - var syncCtx = SynchronizationContext.Current; + SynchronizationContext? syncCtx = SynchronizationContext.Current; if (syncCtx != null && syncCtx.GetType() != typeof(SynchronizationContext)) { tc = new SynchronizationContextAwaitTaskContinuation(syncCtx, continuationAction, flowExecutionContext); @@ -2533,7 +2533,7 @@ namespace System.Threading.Tasks { // If there was no SynchronizationContext, then try for the current scheduler. // We only care about it if it's not the default. - var scheduler = TaskScheduler.InternalCurrent; + TaskScheduler? scheduler = TaskScheduler.InternalCurrent; if (scheduler != null && scheduler != TaskScheduler.Default) { tc = new TaskSchedulerAwaitTaskContinuation(scheduler, continuationAction, flowExecutionContext); @@ -2829,7 +2829,7 @@ namespace System.Threading.Tasks } // ETW event for Task Wait Begin - var log = TplEventSource.Log; + TplEventSource log = TplEventSource.Log; bool etwIsEnabled = log.IsEnabled(); if (etwIsEnabled) { @@ -3131,7 +3131,7 @@ namespace System.Threading.Tasks Interlocked.Exchange(ref m_stateFlags, m_stateFlags | TASK_STATE_CANCELED); // Fire completion event if it has been lazily initialized - var cp = Volatile.Read(ref m_contingentProperties); + ContingentProperties? cp = Volatile.Read(ref m_contingentProperties); if (cp != null) { cp.SetCompleted(); @@ -4367,7 +4367,7 @@ namespace System.Threading.Tasks if ((this.Options & (TaskCreationOptions)InternalTaskOptions.PromiseTask) != 0 && !(this is ITaskCompletionAction)) { - var log = TplEventSource.Log; + TplEventSource log = TplEventSource.Log; if (log.IsEnabled()) { log.AwaitTaskContinuationScheduled(TaskScheduler.Current.Id, Task.CurrentId ?? 0, continuationTask.Id); @@ -4785,7 +4785,7 @@ namespace System.Threading.Tasks { // Add any exceptions for this task to the collection, and if it's wait // notification bit is set, store it to operate on at the end. - foreach (var task in waitedOnTaskList) + foreach (Task task in waitedOnTaskList) { if (task.IsFaulted) exceptionSeen = true; else if (task.IsCanceled) cancellationSeen = true; @@ -4807,7 +4807,7 @@ namespace System.Threading.Tasks // about the first one that requires it. The debugger will reset the bit // for any tasks we don't notify of as soon as we break, so we only need to notify // for one. - foreach (var task in notificationTasks) + foreach (Task task in notificationTasks) { if (task.NotifyDebuggerOfWaitCompletionIfNecessary()) break; } @@ -4824,7 +4824,7 @@ namespace System.Threading.Tasks if (!exceptionSeen) cancellationToken.ThrowIfCancellationRequested(); // Now gather up and throw all of the exceptions. - foreach (var task in tasks) AddExceptionsForCompletedTask(ref exceptions, task); + foreach (Task task in tasks) AddExceptionsForCompletedTask(ref exceptions, task); Debug.Assert(exceptions != null, "Should have seen at least one exception"); ThrowHelper.ThrowAggregateException(exceptions); } @@ -4857,7 +4857,7 @@ namespace System.Threading.Tasks var mres = new SetOnCountdownMres(tasks.Count); try { - foreach (var task in tasks) + foreach (Task task in tasks) { task.AddCompletionAction(mres, addBeforeOthers: true); } @@ -4867,7 +4867,7 @@ namespace System.Threading.Tasks { if (!waitCompleted) { - foreach (var task in tasks) + foreach (Task task in tasks) { if (!task.IsCompleted) task.RemoveContinuation(mres); } @@ -5608,7 +5608,7 @@ namespace System.Threading.Tasks { int index = 0; taskArray = new Task[taskCollection.Count]; - foreach (var task in tasks) + foreach (Task task in tasks) { if (task == null) ThrowHelper.ThrowArgumentException(ExceptionResource.Task_MultiTaskContinuation_NullTask, ExceptionArgument.tasks); taskArray[index++] = task; @@ -5722,7 +5722,7 @@ namespace System.Threading.Tasks m_tasks = tasks; m_count = tasks.Length; - foreach (var task in tasks) + foreach (Task task in tasks) { if (task.IsCompleted) this.Invoke(task); // short-circuit the completion action, if possible else task.AddCompletionAction(this); // simple completion action @@ -5747,7 +5747,7 @@ namespace System.Threading.Tasks // If none fault or are canceled, then result will be RanToCompletion for (int i = 0; i < m_tasks.Length; i++) { - var task = m_tasks[i]; + Task? task = m_tasks[i]; Debug.Assert(task != null, "Constituent task in WhenAll should never be null"); if (task.IsFaulted) @@ -5852,7 +5852,7 @@ namespace System.Threading.Tasks { int index = 0; taskArray = new Task[taskCollection.Count]; - foreach (var task in tasks) + foreach (Task task in tasks) { if (task == null) ThrowHelper.ThrowArgumentException(ExceptionResource.Task_MultiTaskContinuation_NullTask, ExceptionArgument.tasks); taskArray[index++] = task; @@ -5962,7 +5962,7 @@ namespace System.Threading.Tasks if (s_asyncDebuggingEnabled) AddToActiveTasks(this); - foreach (var task in tasks) + foreach (Task task in tasks) { if (task.IsCompleted) this.Invoke(task); // short-circuit the completion action, if possible else task.AddCompletionAction(this); // simple completion action @@ -6241,10 +6241,10 @@ namespace System.Threading.Tasks List result = new List(); foreach (object? obj in continuationList) { - var innerDelegates = GetDelegatesFromContinuationObject(obj); + Delegate[]? innerDelegates = GetDelegatesFromContinuationObject(obj); if (innerDelegates != null) { - foreach (var del in innerDelegates) + foreach (Delegate del in innerDelegates) { if (del != null) result.Add(del); @@ -6658,7 +6658,7 @@ namespace System.Threading.Tasks break; case TaskStatus.Faulted: - var edis = task.GetExceptionDispatchInfos(); + ReadOnlyCollection edis = task.GetExceptionDispatchInfos(); ExceptionDispatchInfo oceEdi; if (lookForOce && edis.Count > 0 && (oceEdi = edis[0]) != null && diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskContinuation.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskContinuation.cs index 8461d0e..203ee61 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskContinuation.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskContinuation.cs @@ -486,7 +486,7 @@ namespace System.Threading.Tasks // Create the continuation task task. If we're allowed to inline, try to do so. // The target scheduler may still deny us from executing on this thread, in which case this'll be queued. - var task = CreateTask(state => + Task task = CreateTask(state => { try { @@ -603,19 +603,19 @@ namespace System.Threading.Tasks { // If there's a SynchronizationContext, we'll be conservative and say // this is a bad location to inline. - var ctx = SynchronizationContext.Current; + SynchronizationContext? ctx = SynchronizationContext.Current; if (ctx != null && ctx.GetType() != typeof(SynchronizationContext)) return false; // Similarly, if there's a non-default TaskScheduler, we'll be conservative // and say this is a bad location to inline. - var sched = TaskScheduler.InternalCurrent; + TaskScheduler? sched = TaskScheduler.InternalCurrent; return sched == null || sched == TaskScheduler.Default; } } void IThreadPoolWorkItem.Execute() { - var log = TplEventSource.Log; + TplEventSource log = TplEventSource.Log; ExecutionContext? context = m_capturedContext; if (!log.IsEnabled() && context == null) @@ -681,7 +681,7 @@ namespace System.Threading.Tasks // Pretend there's no current task, so that no task is seen as a parent // and TaskScheduler.Current does not reflect false information - var prevCurrentTask = currentTask; + Task? prevCurrentTask = currentTask; try { if (prevCurrentTask != null) currentTask = null; @@ -807,7 +807,7 @@ namespace System.Threading.Tasks { AwaitTaskContinuation atc = new AwaitTaskContinuation(action, flowExecutionContext: false); - var log = TplEventSource.Log; + TplEventSource log = TplEventSource.Log; if (log.IsEnabled() && task != null) { atc.m_continuationId = Task.NewId(); diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskExceptionHolder.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskExceptionHolder.cs index 9fdc7d1..b2e2c4a 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskExceptionHolder.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskExceptionHolder.cs @@ -146,7 +146,7 @@ namespace System.Threading.Tasks Debug.Assert(exceptionObject != null, "AddFaultException(): Expected a non-null exceptionObject"); // Initialize the exceptions list if necessary. The list should be non-null iff it contains exceptions. - var exceptions = m_faultExceptions; + List? exceptions = m_faultExceptions; if (exceptions == null) m_faultExceptions = exceptions = new List(1); else Debug.Assert(exceptions.Count > 0, "Expected existing exceptions list to have > 0 exceptions."); @@ -170,7 +170,7 @@ namespace System.Threading.Tasks #if DEBUG int numExceptions = 0; #endif - foreach (var exc in exColl) + foreach (Exception exc in exColl) { #if DEBUG Debug.Assert(exc != null, "No exceptions should be null"); @@ -190,7 +190,7 @@ namespace System.Threading.Tasks exceptions.AddRange(ediColl); #if DEBUG Debug.Assert(exceptions.Count > 0, "There should be at least one dispatch info."); - foreach (var tmp in exceptions) + foreach (ExceptionDispatchInfo tmp in exceptions) { Debug.Assert(tmp != null, "No dispatch infos should be null"); } @@ -254,7 +254,7 @@ namespace System.Threading.Tasks /// The aggregate exception to throw. internal AggregateException CreateExceptionObject(bool calledFromFinalizer, Exception? includeThisException) { - var exceptions = m_faultExceptions; + List? exceptions = m_faultExceptions; Debug.Assert(exceptions != null, "Expected an initialized list."); Debug.Assert(exceptions.Count > 0, "Expected at least one exception."); @@ -300,7 +300,7 @@ namespace System.Threading.Tasks /// internal ExceptionDispatchInfo? GetCancellationExceptionDispatchInfo() { - var edi = m_cancellationException; + ExceptionDispatchInfo? edi = m_cancellationException; Debug.Assert(edi == null || edi.SourceException is OperationCanceledException, "Expected the EDI to be for an OperationCanceledException"); return edi; diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskFactory.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskFactory.cs index 300e17e..f027b96 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskFactory.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskFactory.cs @@ -2336,7 +2336,7 @@ namespace System.Threading.Tasks int numTasks = tasks.Count; for (int i = 0; i < numTasks; i++) { - var task = tasks[i]; + Task task = tasks[i]; if (task != null && // if an element was erroneously nulled out concurrently, just skip it; worst case is we don't remove a continuation !task.IsCompleted) task.RemoveContinuation(this); } @@ -2365,7 +2365,7 @@ namespace System.Threading.Tasks int numTasks = tasks.Count; for (int i = 0; i < numTasks; i++) { - var task = tasks[i]; + Task task = tasks[i]; if (task == null) throw new ArgumentException(SR.Task_MultiTaskContinuation_NullTask, nameof(tasks)); if (checkArgsOnly) continue; diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskScheduler.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskScheduler.cs index 0ad671c..27209c4 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskScheduler.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskScheduler.cs @@ -513,7 +513,7 @@ namespace System.Threading.Tasks } List schedulers = new List(); - foreach (var item in s_activeTaskSchedulers) + foreach (KeyValuePair item in s_activeTaskSchedulers) { schedulers.Add(item.Key); } @@ -525,8 +525,8 @@ namespace System.Threading.Tasks schedulers.Add(s_defaultTaskScheduler); } - var arr = schedulers.ToArray(); - foreach (var scheduler in arr) + TaskScheduler[] arr = schedulers.ToArray(); + foreach (TaskScheduler scheduler in arr) { Debug.Assert(scheduler != null, "Table returned an incorrect Count or CopyTo failed"); int tmp = scheduler.Id; // force Ids for debugger diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadLocal.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadLocal.cs index 0056172..4e13489 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadLocal.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadLocal.cs @@ -447,7 +447,7 @@ namespace System.Threading throw new InvalidOperationException(SR.ThreadLocal_ValuesNotAvailable); } - var list = GetValuesAsList(); // returns null if disposed + List? list = GetValuesAsList(); // returns null if disposed if (list == null) throw new ObjectDisposedException(SR.ThreadLocal_Disposed); return list; } diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/WaitHandle.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/WaitHandle.cs index cb7a017..dba05d8 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/WaitHandle.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/WaitHandle.cs @@ -98,7 +98,7 @@ namespace System.Threading internal static int ToTimeoutMilliseconds(TimeSpan timeout) { - var timeoutMilliseconds = (long)timeout.TotalMilliseconds; + long timeoutMilliseconds = (long)timeout.TotalMilliseconds; if (timeoutMilliseconds < -1) { throw new ArgumentOutOfRangeException(nameof(timeout), SR.ArgumentOutOfRange_NeedNonNegOrNegative1); -- 2.7.4