From 3e6f1f55f10780bf98cad64ac4205a4378937d46 Mon Sep 17 00:00:00 2001 From: halgab <24685886+halgab@users.noreply.github.com> Date: Fri, 29 Dec 2023 23:35:16 +0100 Subject: [PATCH 1/4] use interpolated strings in PresentationCore --- .../AppModel/SiteOfOriginContainer.cs | 8 +- .../MS/internal/AppModel/SiteOfOriginPart.cs | 36 ++---- .../MS/internal/FontCache/FontCacheUtil.cs | 12 +- .../FontCache/FontSourceCollection.cs | 6 +- .../internal/FontFace/CompositeFontParser.cs | 2 +- .../MS/internal/Ink/ExtendedProperty.cs | 4 +- .../Ink/GestureRecognizer/NativeRecognizer.cs | 2 +- .../Ink/InkSerializedFormat/InkSerializer.cs | 48 ++++---- .../InkSerializedFormat/StrokeSerializer.cs | 5 +- .../MS/internal/Ink/StrokeFIndices.cs | 2 +- .../MS/internal/Ink/StrokeIntersection.cs | 5 +- .../MS/internal/Media/VisualTreeUtils.cs | 49 ++++---- .../MS/internal/MediaTrace.cs | 6 +- .../MS/internal/Shaping/TypefaceMap.cs | 27 +++-- .../MS/internal/TextFormatting/Bidi.cs | 106 +++++------------- .../System/IO/Packaging/PackWebRequest.cs | 28 ++--- .../IO/Packaging/PackWebRequestFactory.cs | 12 +- .../System/IO/Packaging/PackWebResponse.cs | 88 ++++----------- .../Windows/Diagnostics/VisualDiagnostics.cs | 2 +- .../System/Windows/FreezableCollection.cs | 2 +- .../Generated/TextDecorationCollection.cs | 2 +- .../Windows/Input/Command/CommandBinding.cs | 4 +- .../Windows/Input/Command/ISecureCommand.cs | 2 +- .../Windows/Input/Command/InputBinding.cs | 2 +- .../Windows/Input/Command/RoutedCommand.cs | 4 +- .../Windows/Input/Command/RoutedUICommand.cs | 2 +- .../Windows/Input/Command/SecureUICommand.cs | 2 +- .../System/Windows/Input/InputScope.cs | 4 +- .../Input/Stylus/Common/StylusLogic.cs | 8 +- .../Stylus/Common/StylusPointProperty.cs | 6 +- .../Windows/InterOp/HwndMouseInputProvider.cs | 2 +- .../Animation/Generated/TimelineCollection.cs | 2 +- .../Generated/BitmapEffectCollection.cs | 2 +- .../System/Windows/Media/Fonts.cs | 2 +- .../Media/Generated/DoubleCollection.cs | 2 +- .../Media/Generated/DrawingCollection.cs | 2 +- .../Generated/GeneralTransformCollection.cs | 2 +- .../Media/Generated/GeometryCollection.cs | 2 +- .../Media/Generated/GradientStopCollection.cs | 2 +- .../Media/Generated/Int32Collection.cs | 2 +- .../Media/Generated/PathFigureCollection.cs | 2 +- .../Media/Generated/PathSegmentCollection.cs | 2 +- .../Media/Generated/PointCollection.cs | 2 +- .../Media/Generated/TextEffectCollection.cs | 2 +- .../Media/Generated/TransformCollection.cs | 2 +- .../Media/Generated/VectorCollection.cs | 2 +- .../System/Windows/Media/Knowncolors.cs | 2 +- .../System/Windows/Media/LineSegment.cs | 2 +- .../System/Windows/Media/PathFigure.cs | 5 +- .../System/Windows/Media/PathGeometry.cs | 2 +- .../System/Windows/Media/PolyBezierSegment.cs | 2 +- .../System/Windows/Media/PolyLineSegment.cs | 2 +- .../Media/PolyQuadraticBezierSegment.cs | 2 +- .../Generated/GeneralTransform3DCollection.cs | 2 +- .../Media3D/Generated/MaterialCollection.cs | 2 +- .../Media3D/Generated/Model3DCollection.cs | 2 +- .../Media3D/Generated/Point3DCollection.cs | 2 +- .../Generated/Transform3DCollection.cs | 2 +- .../Media3D/Generated/Vector3DCollection.cs | 2 +- .../System/Windows/Media3D/MeshGeometry3D.cs | 2 +- .../System/Windows/RoutedEvent.cs | 4 +- .../System/Windows/Interop/OSVersionHelper.cs | 55 ++++----- 62 files changed, 220 insertions(+), 388 deletions(-) diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/AppModel/SiteOfOriginContainer.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/AppModel/SiteOfOriginContainer.cs index 4a1e2fa9b2a..f4d50ab2b39 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/AppModel/SiteOfOriginContainer.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/AppModel/SiteOfOriginContainer.cs @@ -58,9 +58,7 @@ internal static Uri SiteOfOrigin #if DEBUG if (_traceSwitch.Enabled) System.Diagnostics.Trace.TraceInformation( - DateTime.Now.ToLongTimeString() + " " + DateTime.Now.Millisecond + " " + - Environment.CurrentManagedThreadId + - ": SiteOfOriginContainer: returning site of origin " + siteOfOrigin); + $"{DateTime.Now:T} {DateTime.Now.Millisecond} {Environment.CurrentManagedThreadId}: SiteOfOriginContainer: returning site of origin {siteOfOrigin}"); #endif return siteOfOrigin; @@ -229,9 +227,7 @@ protected override PackagePart GetPartCore(Uri uri) #if DEBUG if (_traceSwitch.Enabled) System.Diagnostics.Trace.TraceInformation( - DateTime.Now.ToLongTimeString() + " " + DateTime.Now.Millisecond + " " + - Environment.CurrentManagedThreadId + - ": SiteOfOriginContainer: Creating SiteOfOriginPart for Uri " + uri); + $"{DateTime.Now:T} {DateTime.Now.Millisecond} {Environment.CurrentManagedThreadId}: SiteOfOriginContainer: Creating SiteOfOriginPart for Uri {uri}"); #endif return new SiteOfOriginPart(this, uri); } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/AppModel/SiteOfOriginPart.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/AppModel/SiteOfOriginPart.cs index 77b011c968f..93c8cf57494 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/AppModel/SiteOfOriginPart.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/AppModel/SiteOfOriginPart.cs @@ -55,9 +55,7 @@ protected override Stream GetStreamCore(FileMode mode, FileAccess access) #if DEBUG if (SiteOfOriginContainer._traceSwitch.Enabled) System.Diagnostics.Trace.TraceInformation( - DateTime.Now.ToLongTimeString() + " " + DateTime.Now.Millisecond + " " + - Environment.CurrentManagedThreadId + - ": SiteOfOriginPart: Getting stream."); + $"{DateTime.Now:T} {DateTime.Now.Millisecond} {Environment.CurrentManagedThreadId}: SiteOfOriginPart: Getting stream."); #endif return GetStreamAndSetContentType(false); } @@ -67,9 +65,7 @@ protected override string GetContentTypeCore() #if DEBUG if (SiteOfOriginContainer._traceSwitch.Enabled) System.Diagnostics.Trace.TraceInformation( - DateTime.Now.ToLongTimeString() + " " + DateTime.Now.Millisecond + " " + - Environment.CurrentManagedThreadId + - ": SiteOfOriginPart: Getting content type."); + $"{DateTime.Now:T} {DateTime.Now.Millisecond} {Environment.CurrentManagedThreadId}: SiteOfOriginPart: Getting content type."); #endif GetStreamAndSetContentType(true); @@ -95,9 +91,7 @@ private Stream GetStreamAndSetContentType(bool onlyNeedContentType) #if DEBUG if (SiteOfOriginContainer._traceSwitch.Enabled) System.Diagnostics.Trace.TraceInformation( - DateTime.Now.ToLongTimeString() + " " + DateTime.Now.Millisecond + " " + - Environment.CurrentManagedThreadId + - ": SiteOfOriginPart: Getting content type and using previously determined value"); + $"{DateTime.Now:T} {DateTime.Now.Millisecond} {Environment.CurrentManagedThreadId}: SiteOfOriginPart: Getting content type and using previously determined value"); #endif return null; } @@ -111,9 +105,7 @@ private Stream GetStreamAndSetContentType(bool onlyNeedContentType) #if DEBUG if (SiteOfOriginContainer._traceSwitch.Enabled) System.Diagnostics.Trace.TraceInformation( - DateTime.Now.ToLongTimeString() + " " + DateTime.Now.Millisecond + " " + - Environment.CurrentManagedThreadId + - "SiteOfOriginPart: Using Cached stream"); + $"{DateTime.Now:T} {DateTime.Now.Millisecond} {Environment.CurrentManagedThreadId}SiteOfOriginPart: Using Cached stream"); #endif Stream temp = _cacheStream; _cacheStream = null; @@ -125,9 +117,7 @@ private Stream GetStreamAndSetContentType(bool onlyNeedContentType) #if DEBUG if (SiteOfOriginContainer._traceSwitch.Enabled) System.Diagnostics.Trace.TraceInformation( - DateTime.Now.ToLongTimeString() + " " + DateTime.Now.Millisecond + " " + - Environment.CurrentManagedThreadId + - ": SiteOfOriginPart: Determining absolute uri for this resource"); + $"{DateTime.Now:T} {DateTime.Now.Millisecond} {Environment.CurrentManagedThreadId}: SiteOfOriginPart: Determining absolute uri for this resource"); #endif string original = Uri.ToString(); Invariant.Assert(original[0] == '/'); @@ -138,9 +128,7 @@ private Stream GetStreamAndSetContentType(bool onlyNeedContentType) #if DEBUG if (SiteOfOriginContainer._traceSwitch.Enabled) System.Diagnostics.Trace.TraceInformation( - DateTime.Now.ToLongTimeString() + " " + DateTime.Now.Millisecond + " " + - Environment.CurrentManagedThreadId + - ": SiteOfOriginPart: Making web request to " + _absoluteLocation); + $"{DateTime.Now:T} {DateTime.Now.Millisecond} {Environment.CurrentManagedThreadId}: SiteOfOriginPart: Making web request to {_absoluteLocation}"); #endif // For performance reasons it is better to open local files directly @@ -164,9 +152,7 @@ private Stream HandleFileSource(bool onlyNeedContentType) #if DEBUG if (SiteOfOriginContainer._traceSwitch.Enabled) System.Diagnostics.Trace.TraceInformation( - DateTime.Now.ToLongTimeString() + " " + DateTime.Now.Millisecond + " " + - Environment.CurrentManagedThreadId + - ": Opening local file " + _absoluteLocation); + $"{DateTime.Now:T} {DateTime.Now.Millisecond} {Environment.CurrentManagedThreadId}: Opening local file {_absoluteLocation}"); #endif if (_contentType == MS.Internal.ContentType.Empty) { @@ -188,9 +174,7 @@ private Stream HandleWebSource(bool onlyNeedContentType) #if DEBUG if (SiteOfOriginContainer._traceSwitch.Enabled) System.Diagnostics.Trace.TraceInformation( - DateTime.Now.ToLongTimeString() + " " + DateTime.Now.Millisecond + " " + - Environment.CurrentManagedThreadId + - ": Successfully retrieved stream from " + _absoluteLocation); + $"{DateTime.Now:T} {DateTime.Now.Millisecond} {Environment.CurrentManagedThreadId}: Successfully retrieved stream from {_absoluteLocation}"); #endif if (_contentType == MS.Internal.ContentType.Empty) @@ -198,9 +182,7 @@ private Stream HandleWebSource(bool onlyNeedContentType) #if DEBUG if (SiteOfOriginContainer._traceSwitch.Enabled) System.Diagnostics.Trace.TraceInformation( - DateTime.Now.ToLongTimeString() + " " + DateTime.Now.Millisecond + " " + - Environment.CurrentManagedThreadId + - ": SiteOfOriginPart: Setting _contentType"); + $"{DateTime.Now:T} {DateTime.Now.Millisecond} {Environment.CurrentManagedThreadId}: SiteOfOriginPart: Setting _contentType"); #endif _contentType = WpfWebRequestHelper.GetContentType(response); diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/FontCache/FontCacheUtil.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/FontCache/FontCacheUtil.cs index fd01c7acab7..14e894efb23 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/FontCache/FontCacheUtil.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/FontCache/FontCacheUtil.cs @@ -322,7 +322,7 @@ internal static string CompositeFontExtension static Util() { - string s = Environment.GetEnvironmentVariable(WinDir) + @"\Fonts\"; + string s = $@"{Environment.GetEnvironmentVariable(WinDir)}\Fonts\"; _windowsFontsLocalPath = s.ToUpperInvariant(); @@ -538,7 +538,7 @@ internal static Uri CombineUriWithFaceIndex(string fontUri, int faceIndex) // so that they don't conflict with the fragment part. string canonicalPathUri = new Uri(fontUri).GetComponents(UriComponents.AbsoluteUri, UriFormat.SafeUnescaped); string faceIndexString = faceIndex.ToString(CultureInfo.InvariantCulture); - return new Uri(canonicalPathUri + '#' + faceIndexString); + return new Uri($"{canonicalPathUri}#{faceIndexString}"); } internal static bool IsSupportedFontExtension(string extension, out bool isComposite) @@ -662,7 +662,7 @@ private static string NormalizeFontFamilyReference(string fontFamilyReference, i { // No fragment separator. The entire string is a family name so convert to uppercase // and add a fragment separator at the beginning. - return string.Concat("#", fontFamilyReference.AsSpan(startIndex, length)).ToUpperInvariant(); + return $"#{fontFamilyReference.AsSpan(startIndex, length)}".ToUpperInvariant(); } else if (fragmentIndex + 1 == startIndex + length) { @@ -702,11 +702,7 @@ internal static string ConvertFamilyNameAndLocationToFontFamilyReference(string if (!string.IsNullOrEmpty(location)) { // We just escaped the family name and the location part should already be a valid URI reference. - fontFamilyReference = string.Concat( - location, - "#", - fontFamilyReference - ); + fontFamilyReference = $"{location}#{fontFamilyReference}"; } return fontFamilyReference; diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/FontCache/FontSourceCollection.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/FontCache/FontSourceCollection.cs index 42778aa0422..4d96e817bfd 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/FontCache/FontSourceCollection.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/FontCache/FontSourceCollection.cs @@ -130,7 +130,7 @@ private void SetFontSources() { if (_tryGetCompositeFontsOnly) { - files = Directory.GetFiles(_uri.LocalPath, "*" + Util.CompositeFontExtension); + files = Directory.GetFiles(_uri.LocalPath, $"*{Util.CompositeFontExtension}"); isOnlyCompositeFontFiles = true; } else @@ -168,7 +168,7 @@ private void SetFontSources() { if (_tryGetCompositeFontsOnly) { - files = Directory.GetFiles(_uri.LocalPath, "*" + Util.CompositeFontExtension); + files = Directory.GetFiles(_uri.LocalPath, $"*{Util.CompositeFontExtension}"); isOnlyCompositeFontFiles = true; } else @@ -269,7 +269,7 @@ System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() private bool _tryGetCompositeFontsOnly; private const string InstalledWindowsFontsRegistryKey = @"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts"; - private const string InstalledWindowsFontsRegistryKeyFullPath = @"HKEY_LOCAL_MACHINE\" + InstalledWindowsFontsRegistryKey; + private const string InstalledWindowsFontsRegistryKeyFullPath = $@"HKEY_LOCAL_MACHINE\{InstalledWindowsFontsRegistryKey}"; } } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/FontFace/CompositeFontParser.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/FontFace/CompositeFontParser.cs index a287ffe9219..8fcc6d1a67f 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/FontFace/CompositeFontParser.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/FontFace/CompositeFontParser.cs @@ -353,7 +353,7 @@ private void ParseFontFamilyCollectionElement() if (!foundOsSection) { - Fail(string.Format("No FontFamily element found in FontFamilyCollection that matches current OS or greater: {0}", OSVersionHelper.GetOsVersion().ToString())); + Fail($"No FontFamily element found in FontFamilyCollection that matches current OS or greater: {OSVersionHelper.GetOsVersion()}"); } } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/ExtendedProperty.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/ExtendedProperty.cs index f7fa3c9c807..5e54b4035f4 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/ExtendedProperty.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/ExtendedProperty.cs @@ -131,13 +131,13 @@ public override string ToString() } else if (Value is string) { - val = "\"" + Value.ToString() + "\""; + val = $"\"{Value}\""; } else { val = Value.ToString(); } - return KnownIds.ConvertToString(Id) + "," + val; + return $"{KnownIds.ConvertToString(Id)},{val}"; } /// diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/GestureRecognizer/NativeRecognizer.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/GestureRecognizer/NativeRecognizer.cs index 68103b147cf..a208b3dd1bd 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/GestureRecognizer/NativeRecognizer.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/GestureRecognizer/NativeRecognizer.cs @@ -788,7 +788,7 @@ enum RECO_TYPE : ushort } private const string GestureRecognizerPath = @"SOFTWARE\MICROSOFT\TPG\SYSTEM RECOGNIZERS\{BED9A940-7D48-48E3-9A68-F4887A5A1B2E}"; - private const string GestureRecognizerFullPath = "HKEY_LOCAL_MACHINE" + @"\" + GestureRecognizerPath; + private const string GestureRecognizerFullPath = $@"HKEY_LOCAL_MACHINE\{GestureRecognizerPath}"; private const string GestureRecognizerValueName = "RECOGNIZER DLL"; private const string GestureRecognizerGuid = "{BED9A940-7D48-48E3-9A68-F4887A5A1B2E}"; diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/InkSerializedFormat/InkSerializer.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/InkSerializedFormat/InkSerializer.cs index 8fec30aa336..bede586b3e8 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/InkSerializedFormat/InkSerializer.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/InkSerializedFormat/InkSerializer.cs @@ -358,7 +358,7 @@ private void DecodeRawISF(Stream inputStream) // Now read the size of the stream localBytesDecoded = SerializationHelper.Decode(inputStream, out remainingBytesInStream); - ISFDebugTrace("Decoded Stream Size in Bytes: " + remainingBytesInStream.ToString()); + ISFDebugTrace($"Decoded Stream Size in Bytes: {remainingBytesInStream}"); if (0 == remainingBytesInStream) return; @@ -376,7 +376,7 @@ private void DecodeRawISF(Stream inputStream) throw new ArgumentException(ISFDebugMessage("Invalid ISF data")); } - ISFDebugTrace("Decoding Tag: " + ((KnownTagCache.KnownTagIndex)isfTag).ToString()); + ISFDebugTrace($"Decoding Tag: {((KnownTagCache.KnownTagIndex)isfTag)}"); switch (isfTag) { case KnownTagCache.KnownTagIndex.GuidTable: @@ -570,7 +570,7 @@ private void DecodeRawISF(Stream inputStream) case KnownTagCache.KnownTagIndex.Stroke: { - ISFDebugTrace(" Decoding Stroke Id#(" + (strokeIndex + 1).ToString() + ")"); + ISFDebugTrace($" Decoding Stroke Id#({(strokeIndex + 1)})"); StrokeDescriptor strokeDescriptor = null; @@ -745,7 +745,7 @@ private void DecodeRawISF(Stream inputStream) { if ((uint)isfTag >= KnownIdCache.CustomGuidBaseIndex || ((uint)isfTag >= KnownTagCache.KnownTagCount && ((uint)isfTag < (KnownTagCache.KnownTagCount + KnownIdCache.OriginalISFIdTable.Length)))) { - ISFDebugTrace(" CUSTOM_GUID=" + guidList.FindGuid(isfTag).ToString()); + ISFDebugTrace($" CUSTOM_GUID={guidList.FindGuid(isfTag)}"); // Loads any custom property data bytesDecodedInCurrentTag = remainingBytesInStream; @@ -789,7 +789,7 @@ private void DecodeRawISF(Stream inputStream) break; } } - ISFDebugTrace(" Size = " + bytesDecodedInCurrentTag.ToString()); + ISFDebugTrace($" Size = {bytesDecodedInCurrentTag}"); if (bytesDecodedInCurrentTag > remainingBytesInStream) { throw new ArgumentException(ISFDebugMessage("Invalid ISF data")); @@ -1751,7 +1751,7 @@ internal void EncodeISF(Stream outputStream) // validate that the expected inkspace rectangle block in ISF was the actual size encoded localEncodedSize = cumulativeEncodedSize - localEncodedSize; if (localEncodedSize != 0) - ISFDebugTrace("Encoded InkSpaceRectangle: size=" + localEncodedSize); + ISFDebugTrace($"Encoded InkSpaceRectangle: size={localEncodedSize}"); if (cumulativeEncodedSize != localStream.Length) throw new InvalidOperationException(ISFDebugMessage("Calculated ISF stream size != actual stream size")); @@ -1770,7 +1770,7 @@ internal void EncodeISF(Stream outputStream) localEncodedSize = cumulativeEncodedSize - localEncodedSize; if (localEncodedSize != 0) - ISFDebugTrace("Encoded PersistenceFormat: size=" + localEncodedSize); + ISFDebugTrace($"Encoded PersistenceFormat: size={localEncodedSize}"); if (cumulativeEncodedSize != localStream.Length) throw new InvalidOperationException(ISFDebugMessage("Calculated ISF stream size != actual stream size")); @@ -1783,7 +1783,7 @@ internal void EncodeISF(Stream outputStream) cumulativeEncodedSize += guidList.Save(localStream); localEncodedSize = cumulativeEncodedSize - localEncodedSize; if (localEncodedSize != 0) - ISFDebugTrace("Encoded Custom Guid Table: size=" + localEncodedSize); + ISFDebugTrace($"Encoded Custom Guid Table: size={localEncodedSize}"); if (cumulativeEncodedSize != localStream.Length) throw new InvalidOperationException(ISFDebugMessage("Calculated ISF stream size != actual stream size")); @@ -1796,7 +1796,7 @@ internal void EncodeISF(Stream outputStream) cumulativeEncodedSize += SerializeDrawingAttrsTable(localStream, guidList); localEncodedSize = cumulativeEncodedSize - localEncodedSize; if (localEncodedSize != 0) - ISFDebugTrace("Encoded DrawingAttributesTable: size=" + localEncodedSize); + ISFDebugTrace($"Encoded DrawingAttributesTable: size={localEncodedSize}"); if (cumulativeEncodedSize != localStream.Length) throw new InvalidOperationException(ISFDebugMessage("Calculated ISF stream size != actual stream size")); @@ -1805,7 +1805,7 @@ internal void EncodeISF(Stream outputStream) cumulativeEncodedSize += SerializePacketDescrTable(localStream); localEncodedSize = cumulativeEncodedSize - localEncodedSize; if (localEncodedSize != 0) - ISFDebugTrace("Encoded Packet Description: size=" + localEncodedSize); + ISFDebugTrace($"Encoded Packet Description: size={localEncodedSize}"); if (cumulativeEncodedSize != localStream.Length) throw new InvalidOperationException(ISFDebugMessage("Calculated ISF stream size != actual stream size")); @@ -1814,7 +1814,7 @@ internal void EncodeISF(Stream outputStream) cumulativeEncodedSize += SerializeMetricTable(localStream); localEncodedSize = cumulativeEncodedSize - localEncodedSize; if (localEncodedSize != 0) - ISFDebugTrace("Encoded Metric Table: size=" + localEncodedSize); + ISFDebugTrace($"Encoded Metric Table: size={localEncodedSize}"); if (cumulativeEncodedSize != localStream.Length) throw new InvalidOperationException(ISFDebugMessage("Calculated ISF stream size != actual stream size")); @@ -1823,7 +1823,7 @@ internal void EncodeISF(Stream outputStream) cumulativeEncodedSize += SerializeTransformTable(localStream); localEncodedSize = cumulativeEncodedSize - localEncodedSize; if (localEncodedSize != 0) - ISFDebugTrace("Encoded Transform Table: size=" + localEncodedSize); + ISFDebugTrace($"Encoded Transform Table: size={localEncodedSize}"); if (cumulativeEncodedSize != localStream.Length) throw new InvalidOperationException(ISFDebugMessage("Calculated ISF stream size != actual stream size")); @@ -1834,7 +1834,7 @@ internal void EncodeISF(Stream outputStream) cumulativeEncodedSize += ExtendedPropertySerializer.EncodeAsISF(_coreStrokes.ExtendedProperties, localStream, guidList, GetCompressionAlgorithm(), true); localEncodedSize = cumulativeEncodedSize - localEncodedSize; if (localEncodedSize != 0) - ISFDebugTrace("Encoded Global Ink Attributes Table: size=" + localEncodedSize); + ISFDebugTrace($"Encoded Global Ink Attributes Table: size={localEncodedSize}"); if (cumulativeEncodedSize != localStream.Length) throw new InvalidOperationException(ISFDebugMessage("Calculated ISF stream size != actual stream size")); } @@ -1844,13 +1844,13 @@ internal void EncodeISF(Stream outputStream) cumulativeEncodedSize += SaveStrokeIds(_coreStrokes, localStream, false); localEncodedSize = cumulativeEncodedSize - localEncodedSize; if (localEncodedSize != 0) - ISFDebugTrace("Encoded Stroke Id List: size=" + localEncodedSize); + ISFDebugTrace($"Encoded Stroke Id List: size={localEncodedSize}"); if (cumulativeEncodedSize != localStream.Length) throw new InvalidOperationException(ISFDebugMessage("Calculated ISF stream size != actual stream size")); StoreStrokeData(localStream, guidList, ref cumulativeEncodedSize, ref localEncodedSize); - ISFDebugTrace("Embedded ISF Stream size=" + cumulativeEncodedSize); + ISFDebugTrace($"Embedded ISF Stream size={cumulativeEncodedSize}"); // Now that all data has been written we need to prepend the stream long preEncodingPosition = outputStream.Position; @@ -1863,7 +1863,7 @@ internal void EncodeISF(Stream outputStream) outputStream.Write(localStream.GetBuffer(), 0, (int)cumulativeEncodedSize); cbFinal += cumulativeEncodedSize; - ISFDebugTrace("Final ISF Stream size=" + cbFinal); + ISFDebugTrace($"Final ISF Stream size={cbFinal}"); if (cbFinal != outputStream.Position - preEncodingPosition) { @@ -1895,7 +1895,7 @@ private void StoreStrokeData(Stream localStream, GuidList guidList, ref uint cum Stroke s = _coreStrokes[i]; uint cbStroke = 0; - ISFDebugTrace("Encoding Stroke Id#" + strokeIds[i]); + ISFDebugTrace($"Encoding Stroke Id#{strokeIds[i]}"); // if the drawing attribute index is different from the current one, write it if (currentDrawingAttributesTableIndex != _strokeLookupTable[s].DrawingAttributesTableIndex) @@ -1906,7 +1906,7 @@ private void StoreStrokeData(Stream localStream, GuidList guidList, ref uint cum currentDrawingAttributesTableIndex = _strokeLookupTable[s].DrawingAttributesTableIndex; localEncodedSize = cumulativeEncodedSize - localEncodedSize; if (localEncodedSize != 0) - ISFDebugTrace(" Encoded DrawingAttribute Table Index: size=" + localEncodedSize); + ISFDebugTrace($" Encoded DrawingAttribute Table Index: size={localEncodedSize}"); if (cumulativeEncodedSize != localStream.Length) throw new InvalidOperationException(ISFDebugMessage("Calculated ISF stream size != actual stream size")); } @@ -1920,7 +1920,7 @@ private void StoreStrokeData(Stream localStream, GuidList guidList, ref uint cum currentStrokeDescriptorTableIndex = _strokeLookupTable[s].StrokeDescriptorTableIndex; localEncodedSize = cumulativeEncodedSize - localEncodedSize; if (localEncodedSize != 0) - ISFDebugTrace(" Encoded Stroke Descriptor Index: size=" + localEncodedSize); + ISFDebugTrace($" Encoded Stroke Descriptor Index: size={localEncodedSize}"); if (cumulativeEncodedSize != localStream.Length) throw new InvalidOperationException(ISFDebugMessage("Calculated ISF stream size != actual stream size")); } @@ -1934,7 +1934,7 @@ private void StoreStrokeData(Stream localStream, GuidList guidList, ref uint cum uCurrMetricDescriptorTableIndex = _strokeLookupTable[s].MetricDescriptorTableIndex; localEncodedSize = cumulativeEncodedSize - localEncodedSize; if (localEncodedSize != 0) - ISFDebugTrace(" Encoded Metric Index: size=" + localEncodedSize); + ISFDebugTrace($" Encoded Metric Index: size={localEncodedSize}"); if (cumulativeEncodedSize != localStream.Length) throw new InvalidOperationException(ISFDebugMessage("Calculated ISF stream size != actual stream size")); } @@ -1948,7 +1948,7 @@ private void StoreStrokeData(Stream localStream, GuidList guidList, ref uint cum currentTransformTableIndex = _strokeLookupTable[s].TransformTableIndex; localEncodedSize = cumulativeEncodedSize - localEncodedSize; if (localEncodedSize != 0) - ISFDebugTrace(" Encoded Transform Index: size=" + localEncodedSize); + ISFDebugTrace($" Encoded Transform Index: size={localEncodedSize}"); if (cumulativeEncodedSize != localStream.Length) throw new InvalidOperationException(ISFDebugMessage("Calculated ISF stream size != actual stream size")); } @@ -1971,7 +1971,7 @@ private void StoreStrokeData(Stream localStream, GuidList guidList, ref uint cum // Now write the tag KnownTagCache.KnownTagIndex.Stroke cumulativeEncodedSize += SerializationHelper.Encode(localStream, (uint)KnownTagCache.KnownTagIndex.Stroke); - ISFDebugTrace("Stroke size=" + tempstrm.Length); + ISFDebugTrace($"Stroke size={tempstrm.Length}"); // Now write the size of the stroke cumulativeEncodedSize += SerializationHelper.Encode(localStream, cbStroke); @@ -1982,7 +1982,7 @@ private void StoreStrokeData(Stream localStream, GuidList guidList, ref uint cum localEncodedSize = cumulativeEncodedSize - localEncodedSize; if (localEncodedSize != 0) - ISFDebugTrace("Encoding Stroke Id#" + strokeIds[i] + " size=" + localEncodedSize); + ISFDebugTrace($"Encoding Stroke Id#{strokeIds[i]} size={localEncodedSize}"); if (cumulativeEncodedSize != localStream.Length) throw new InvalidOperationException(ISFDebugMessage("Calculated ISF stream size != actual stream size")); } @@ -2041,7 +2041,7 @@ internal static uint SaveStrokeIds(StrokeCollection strokes, Stream strm, bool f // First write the KnownTagCache.KnownTagIndex.StrokeIds uint cbWrote = SerializationHelper.Encode(strm, (uint)KnownTagCache.KnownTagIndex.StrokeIds); - ISFDebugTrace("Saved KnownTagCache.KnownTagIndex.StrokeIds size=" + cbWrote.ToString()); + ISFDebugTrace($"Saved KnownTagCache.KnownTagIndex.StrokeIds size={cbWrote}"); // First findout the no of bytes required to huffman compress these ids byte algorithm = AlgoModule.DefaultCompression; diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/InkSerializedFormat/StrokeSerializer.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/InkSerializedFormat/StrokeSerializer.cs index a90461bf85d..2a92c6b810a 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/InkSerializedFormat/StrokeSerializer.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/InkSerializedFormat/StrokeSerializer.cs @@ -81,9 +81,8 @@ internal static uint DecodeStroke(Stream stream, if (cb != size) { - throw new ArgumentException(StrokeCollectionSerializer.ISFDebugMessage("Stroke size (" + - cb.ToString(System.Globalization.CultureInfo.InvariantCulture) + ") != expected (" + - size.ToString(System.Globalization.CultureInfo.InvariantCulture) + ")")); + throw new ArgumentException(StrokeCollectionSerializer.ISFDebugMessage( + string.Create(System.Globalization.CultureInfo.InvariantCulture, $"Stroke size ({cb}) != expected ({size})"))); } stroke = new Stroke(stylusPoints, drawingAttributes, extendedProperties); diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/StrokeFIndices.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/StrokeFIndices.cs index ce284adff90..390944f80a7 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/StrokeFIndices.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/StrokeFIndices.cs @@ -76,7 +76,7 @@ internal double EndFIndex /// public override string ToString() { - return "{" + GetStringRepresentation(_beginFIndex) + "," + GetStringRepresentation(_endFIndex) + "}"; + return $"{{{GetStringRepresentation(_beginFIndex)},{GetStringRepresentation(_endFIndex)}}}"; } /// diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/StrokeIntersection.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/StrokeIntersection.cs index fb1efcb2e83..7c58c18d149 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/StrokeIntersection.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/StrokeIntersection.cs @@ -96,10 +96,7 @@ internal double InEnd /// public override string ToString() { - return "{" + StrokeFIndices.GetStringRepresentation(_hitSegment.BeginFIndex) + "," - + StrokeFIndices.GetStringRepresentation(_inSegment.BeginFIndex) + "," - + StrokeFIndices.GetStringRepresentation(_inSegment.EndFIndex) + "," - + StrokeFIndices.GetStringRepresentation(_hitSegment.EndFIndex) + "}"; + return $"{{{StrokeFIndices.GetStringRepresentation(_hitSegment.BeginFIndex)},{StrokeFIndices.GetStringRepresentation(_inSegment.BeginFIndex)},{StrokeFIndices.GetStringRepresentation(_inSegment.EndFIndex)},{StrokeFIndices.GetStringRepresentation(_hitSegment.EndFIndex)}}}"; } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Media/VisualTreeUtils.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Media/VisualTreeUtils.cs index c4b807fd42b..153bc143361 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Media/VisualTreeUtils.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Media/VisualTreeUtils.cs @@ -24,7 +24,7 @@ internal static class VisualTreeUtils // Constructors // //------------------------------------------------------ - + //------------------------------------------------------ // // Public Methods @@ -36,7 +36,7 @@ internal static class VisualTreeUtils // Public Properties // //------------------------------------------------------ - + //------------------------------------------------------ // // Public Events @@ -47,7 +47,7 @@ internal static class VisualTreeUtils // // Internal Methods // - //------------------------------------------------------ + //------------------------------------------------------ #region Internal Methods @@ -56,13 +56,13 @@ internal static class VisualTreeUtils /// given element. /// internal static void PropagateFlags( - DependencyObject element, + DependencyObject element, VisualFlags flags, VisualProxyFlags proxyFlags) { Visual visual; Visual3D visual3D; - + AsVisualInternal(element, out visual, out visual3D); if (visual != null) @@ -84,7 +84,7 @@ internal static void SetFlagsToRoot(DependencyObject element, bool value, Visual { Visual visual; Visual3D visual3D; - + AsVisualInternal(element, out visual, out visual3D); if (visual != null) @@ -105,7 +105,7 @@ internal static DependencyObject FindFirstAncestorWithFlagsAnd(DependencyObject { Visual visual; Visual3D visual3D; - + AsVisualInternal(element, out visual, out visual3D); if (visual != null) @@ -134,7 +134,7 @@ internal static PointHitTestResult AsNearestPointHitTestResult(HitTestResult res { return null; } - + PointHitTestResult resultAsPointHitTestResult = result as PointHitTestResult; if (resultAsPointHitTestResult != null) @@ -172,7 +172,7 @@ internal static PointHitTestResult AsNearestPointHitTestResult(HitTestResult res { Point4D worldPoint = ((Point4D)resultAsRayHitTestResult.PointHit) * worldTransform; Point viewportPoint = viewport.WorldToViewport(worldPoint); - + return new PointHitTestResult(viewport, viewportPoint); } @@ -181,7 +181,7 @@ internal static PointHitTestResult AsNearestPointHitTestResult(HitTestResult res return null; } - Debug.Fail(String.Format("Unhandled HitTestResult type '{0}'", result.GetType().Name)); + Debug.Fail($"Unhandled HitTestResult type '{result.GetType().Name}'"); return null; } @@ -226,7 +226,7 @@ private static void EnsureVisual(DependencyObject element, bool allowNull) throw new ArgumentException(SR.Visual_NotAVisual); } - element.VerifyAccess(); + element.VerifyAccess(); } /// @@ -242,7 +242,7 @@ internal static void AsNonNullVisual(DependencyObject element, out Visual visual Debug.Assert((visual == null) != (visual3D == null), "Either visual or visual3D exclusively should be non-null."); } - + /// /// Returns null if the given element is null, otherwise visual or visual3D /// will be the strong visual type on exit. @@ -283,37 +283,32 @@ internal static bool AsVisualInternal(DependencyObject element, out Visual visua { bool castSucceeded = AsVisualHelper(element, out visual, out visual3D); - if (!(castSucceeded || element == null)) - { - Debug.Fail(String.Format( - "'{0}' is not a Visual or Visual3D. Caller is responsible for guaranteeing that element is a Visual type.", - element != null ? element.GetType() : null)); - } + Debug.Assert(castSucceeded || element == null, $"'{element?.GetType()}' is not a Visual or Visual3D. Caller is responsible for guaranteeing that element is a Visual type."); return castSucceeded; } - - #endregion Internal Methods + + #endregion Internal Methods //------------------------------------------------------ // // Internal Fields // //------------------------------------------------------ - + #region Internal Fields - public const string BitmapEffectObsoleteMessage = + public const string BitmapEffectObsoleteMessage = "BitmapEffects are deprecated and no longer function. Consider using Effects where appropriate instead."; #endregion - + //------------------------------------------------------ // // Private Methods // //------------------------------------------------------ - + #region Private Methods // Common code for AsVisual and AsVisualInternal -- Don't call this. @@ -335,14 +330,14 @@ private static bool AsVisualHelper(DependencyObject element, out Visual visual, visual = null; visual3D = elementAsVisual3D; return true; - } - + } + visual = null; visual3D = null; return false; } - #endregion Private Methods + #endregion Private Methods } } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/MediaTrace.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/MediaTrace.cs index 44325b9a8b3..101ff0bec48 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/MediaTrace.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/MediaTrace.cs @@ -85,7 +85,7 @@ public void Trace(string message) { if (_switch.Enabled) { - System.Diagnostics.Trace.WriteLine(_switch.Description + " " + _switch.DisplayName + " : " + message); + System.Diagnostics.Trace.WriteLine($"{_switch.Description} {_switch.DisplayName} : {message}"); } } @@ -102,7 +102,7 @@ public void TraceCallers(int Depth) for (int i=0; i < st.FrameCount && i < Depth; i++) { System.Diagnostics.StackFrame sf = st.GetFrame(i); - Trace(sf.GetMethod()+"+"+sf.GetILOffset().ToString(System.Globalization.CultureInfo.InvariantCulture)); + Trace($"{sf.GetMethod()}+{sf.GetILOffset().ToString(System.Globalization.CultureInfo.InvariantCulture)}"); } Unindent(); @@ -128,7 +128,7 @@ public IDisposable Indented() public IDisposable Indented(string message) { - System.Diagnostics.Trace.WriteLine(_switch.Description + " " + _switch.DisplayName + " : " + message); + System.Diagnostics.Trace.WriteLine($"{_switch.Description} {_switch.DisplayName} : {message}"); System.Diagnostics.Trace.Indent(); return (this); } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Shaping/TypefaceMap.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Shaping/TypefaceMap.cs index 358b84d3f0f..a748521ccdb 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Shaping/TypefaceMap.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Shaping/TypefaceMap.cs @@ -86,7 +86,7 @@ TextFormattingMode textFormattingMode ) { SpanVector cachedScaledTypefaceIndexSpans; - + int ichItem = 0; CharacterBufferRange unicodeString = new CharacterBufferRange( @@ -96,15 +96,15 @@ TextFormattingMode textFormattingMode CultureInfo culture = textRunProperties.CultureInfo; IList spans; - + GCHandle gcHandle; IntPtr ptext = characterBufferReference.CharacterBuffer.PinAndGetCharacterPointer(characterBufferReference.OffsetToFirstChar, out gcHandle); - // Contextual number substitution cannot be performed on the run level, since it depends - // on context - nearest preceding strong character. For this reason, contextual number - // substitutions has been already done (TextStore.CreateLSRunsUniformBidiLevel) and + // Contextual number substitution cannot be performed on the run level, since it depends + // on context - nearest preceding strong character. For this reason, contextual number + // substitutions has been already done (TextStore.CreateLSRunsUniformBidiLevel) and // digitCulture has been updated to reflect culture which is dependent on the context. - // NumberSubstitutionMethod.AsCulture method can be resolved to Context, hence it also needs to be resolved to appropriate + // NumberSubstitutionMethod.AsCulture method can be resolved to Context, hence it also needs to be resolved to appropriate // not ambiguous method. // Both of those values (Context and AsCulture) are resolved to one of following: European, Traditional or NativeNational, // which can be safely handled by DWrite without getting context information. @@ -114,7 +114,7 @@ TextFormattingMode textFormattingMode // Itemize the text based on DWrite's text analysis for scripts and number substitution. unsafe { - checked + checked { spans = MS.Internal.Text.TextInterface.TextAnalyzer.Itemize( (char*)ptext.ToPointer(), @@ -137,7 +137,7 @@ TextFormattingMode textFormattingMode SpanVector itemSpans = new SpanVector(null, new FrugalStructList((ICollection)spans)); - cachedScaledTypefaceIndexSpans = new SpanVector(-1); + cachedScaledTypefaceIndexSpans = new SpanVector(-1); foreach(Span itemSpan in itemSpans) { MapItem( @@ -423,10 +423,9 @@ out sizeofChar { Invariant.Assert( false, - string.Format( + string.Create( CultureInfo.InvariantCulture, - "shapeable cache stores conflicting info, ch = {0}, map[ch] = {1}, index = {2}", - ch, map[ch], index + $"shapeable cache stores conflicting info, ch = {ch}, map[ch] = {map[ch]}, index = {index}" ) ); } @@ -492,7 +491,7 @@ private int MapByFontFamily( IFontFamily fontFamily, CanonicalFontFamilyReference canonicalFamilyReference, FontStyle canonicalStyle, - FontWeight canonicalWeight, + FontWeight canonicalWeight, FontStretch canonicalStretch, ref PhysicalFontFamily firstValidFamily, ref int firstValidLength, @@ -919,7 +918,7 @@ out int nextValid targetFamily, canonicalFamilyReference, canonicalStyle, - canonicalWeight, + canonicalWeight, canonicalStretch, ref firstValidFamily, ref firstValidLength, @@ -1043,7 +1042,7 @@ ref nextValid if (firstValidLength <= 0) { // Either firstValidFamily hasn't been set, or has "expired" (see below). The first valid - // family is the first existing physical font in the font linking chain. We want to remember + // family is the first existing physical font in the font linking chain. We want to remember // it so we can use it to map any unresolved characters. firstValidFamily = fontFaceFamily; diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/TextFormatting/Bidi.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/TextFormatting/Bidi.cs index c1db01cc37f..da0eeeeeb70 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/TextFormatting/Bidi.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/TextFormatting/Bidi.cs @@ -717,8 +717,7 @@ byte runLevel // [IN] // We should never be changing a fixed type here Debug.Assert(CharProperty[2, (int) characterClass[counter + classIndex]]==0, - "Resolving fixed class as being neutral: " + - characterClass[counter + classIndex].ToString()); + $"Resolving fixed class as being neutral: {characterClass[counter + classIndex]}"); characterClass[counter + classIndex] = resolutionType; } @@ -853,9 +852,7 @@ Flags flags // [IN] { case StateMachineAction.ST_ST: Debug.Assert(startOfNeutrals == PositionInvalid, - "Cannot have unresolved neutrals. State: " + - state.ToString() + - ", Class: " + currentClass.ToString()); + $"Cannot have unresolved neutrals. State: {state}, Class: {currentClass}"); if (currentClass == DirectionClass.ArabicLetter) { @@ -898,9 +895,7 @@ Flags flags // [IN] case StateMachineAction.ST_ET: Debug.Assert(startOfDelayed != PositionInvalid, - "Must have delayed weak classes. State: " + - state.ToString() + - ", Class: "+ currentClass.ToString()); + $"Must have delayed weak classes. State: {state}, Class: {currentClass}"); if (startOfNeutrals == PositionInvalid) { @@ -943,14 +938,10 @@ Flags flags // [IN] case StateMachineAction.ST_NUMSEP: { Debug.Assert(startOfNeutrals == PositionInvalid, - "Cannot have unresolved neutrals. State: " + - state.ToString() + - ", Class: "+ currentClass.ToString()); + $"Cannot have unresolved neutrals. State: {state}, Class: {currentClass}"); Debug.Assert(startOfDelayed != PositionInvalid, - "Must have delayed weak classes. State: " + - state.ToString() + - " Class: "+ currentClass.ToString()); + $"Must have delayed weak classes. State: {state} Class: {currentClass}"); bool processed = false; if (currentClass == DirectionClass.ArabicLetter) @@ -1048,9 +1039,7 @@ Flags flags // [IN] case StateMachineAction.ST_N: Debug.Assert(startOfNeutrals != PositionInvalid, - "Must have unresolved neutrals. State: " + - state.ToString() +", Class: "+ - currentClass.ToString()); + $"Must have unresolved neutrals. State: {state}, Class: {currentClass}"); if (currentClass == DirectionClass.ArabicLetter) { @@ -1087,9 +1076,7 @@ Flags flags // [IN] case StateMachineAction.EN_N: Debug.Assert(startOfNeutrals != PositionInvalid, - "Must have unresolved neutrals. State: " + - state.ToString() + ", Class: "+ - currentClass.ToString()); + $"Must have unresolved neutrals. State: {state}, Class: {currentClass}"); if ((flags & Flags.OverrideEuropeanNumberResolution) == 0 && ((lastStrongClass == DirectionClass.ArabicLetter) || @@ -1120,9 +1107,7 @@ Flags flags // [IN] case StateMachineAction.SEP_ST: Debug.Assert(startOfNeutrals == PositionInvalid, - "Cannot have unresolved neutrals. State: " + - state.ToString() + ", Class: " + - currentClass.ToString()); + $"Cannot have unresolved neutrals. State: {state}, Class: {currentClass}"); if (startOfDelayed != PositionInvalid) { @@ -1138,9 +1123,7 @@ Flags flags // [IN] case StateMachineAction.CS_NUM: Debug.Assert(startOfNeutrals == PositionInvalid, - "Cannot have unresolved neutrals. State: " + - state.ToString() + ", Class: " + - currentClass.ToString()); + $"Cannot have unresolved neutrals. State: {state}, Class: {currentClass}"); if (startOfDelayed == PositionInvalid) { @@ -1151,9 +1134,7 @@ Flags flags // [IN] case StateMachineAction.SEP_ET: Debug.Assert(startOfDelayed != PositionInvalid, - "Must have delayed weak classes. State: " + - state.ToString() + ", Class: " + - currentClass.ToString()); + $"Must have delayed weak classes. State: {state}, Class: {currentClass}"); if (startOfNeutrals == PositionInvalid) { @@ -1165,14 +1146,10 @@ Flags flags // [IN] case StateMachineAction.SEP_NUMSEP: Debug.Assert(startOfNeutrals == PositionInvalid, - "Cannot have unresolved neutrals. State: " + - state.ToString() + ", Class: " + - currentClass.ToString()); + $"Cannot have unresolved neutrals. State: {state}, Class: {currentClass}"); Debug.Assert(startOfDelayed != PositionInvalid, - "Must have delayed weak classes. State: " + - state.ToString() + ", Class: " + - currentClass.ToString()); + $"Must have delayed weak classes. State: {state}, Class: {currentClass}"); startOfNeutrals = startOfDelayed; startOfDelayed = PositionInvalid; @@ -1181,18 +1158,14 @@ Flags flags // [IN] case StateMachineAction.SEP_N: Debug.Assert(startOfNeutrals != PositionInvalid, - "Must have unresolved neutrals. State: " + - state.ToString() + ", Class: " + - currentClass.ToString()); + $"Must have unresolved neutrals. State: {state}, Class: {currentClass}"); startOfDelayed = PositionInvalid; break; case StateMachineAction.ES_AN: Debug.Assert(startOfNeutrals == PositionInvalid, - "Cannot have unresolved neutrals. State: " + - state.ToString() + ", Class: " + - currentClass.ToString()); + $"Cannot have unresolved neutrals. State: {state}, Class: {currentClass}"); if (startOfDelayed != PositionInvalid) { @@ -1208,25 +1181,17 @@ Flags flags // [IN] case StateMachineAction.ET_ET: Debug.Assert(startOfDelayed != PositionInvalid, - "Must have delayed weak classes. State: " + - state.ToString() + ", Class: " + - currentClass.ToString()); + $"Must have delayed weak classes. State: {state}, Class: {currentClass}"); Debug.Assert(lastClass == DirectionClass.EuropeanTerminator, - "Last class must be ET. State: " + - state.ToString() + ", Class: " + - currentClass.ToString()); + $"Last class must be ET. State: {state}, Class: {currentClass}"); break; case StateMachineAction.ET_NUMSEP: Debug.Assert(startOfNeutrals == PositionInvalid, - "Cannot have unresolved neutrals. State: " + - state.ToString() + ", Class: " + - currentClass.ToString()); + $"Cannot have unresolved neutrals. State: {state}, Class: {currentClass}"); Debug.Assert(startOfDelayed != PositionInvalid, - "Must have delayed weak classes. State: " + - state.ToString() + ", Class: " + - currentClass.ToString()); + $"Must have delayed weak classes. State: {state}, Class: {currentClass}"); startOfNeutrals = startOfDelayed; startOfDelayed = counter; @@ -1273,9 +1238,7 @@ Flags flags // [IN] case StateMachineAction.ET_N: Debug.Assert(startOfNeutrals != PositionInvalid, - "Must have unresolved neutrals. State: " + - state.ToString() + ", Class: " + - currentClass.ToString()); + $"Must have unresolved neutrals. State: {state}, Class: {currentClass}"); if (startOfDelayed == PositionInvalid) { @@ -1287,14 +1250,10 @@ Flags flags // [IN] case StateMachineAction.NUM_NUMSEP: Debug.Assert(startOfNeutrals == PositionInvalid, - "Cannot have unresolved neutrals. State: " + - state.ToString() + ", Class: " + - currentClass.ToString()); + $"Cannot have unresolved neutrals. State: {state}, Class: {currentClass}"); Debug.Assert(startOfDelayed != PositionInvalid, - "Must have delayed weak classes. State: " + - state.ToString() + ", Class: " + - currentClass.ToString()); + $"Must have delayed weak classes. State: {state}, Class: {currentClass}"); if ((lastStrongClass == DirectionClass.ArabicLetter) || previousClassIsArabic || ArabicNumberAfterLeft) @@ -1324,9 +1283,7 @@ Flags flags // [IN] case StateMachineAction.EN_L: Debug.Assert(startOfNeutrals == PositionInvalid, - "Cannot have unresolved neutrals. State: " + - state.ToString() + ", Class: " + - currentClass.ToString()); + $"Cannot have unresolved neutrals. State: {state}, Class: {currentClass}"); if (lastStrongClass == DirectionClass.Left) { @@ -1351,9 +1308,7 @@ Flags flags // [IN] case StateMachineAction.NUM_NUM: Debug.Assert(startOfNeutrals == PositionInvalid, - "Cannot have unresolved neutrals. State: " + - state.ToString() + ", Class: " + - currentClass.ToString()); + $"Cannot have unresolved neutrals. State: {state}, Class: {currentClass}"); if ((flags & Flags.OverrideEuropeanNumberResolution) == 0 && (lastStrongClass == DirectionClass.ArabicLetter || previousClassIsArabic) @@ -1396,9 +1351,7 @@ Flags flags // [IN] case StateMachineAction.EN_AL: Debug.Assert(startOfNeutrals == PositionInvalid, - "Cannot have unresolved neutrals. State: " + - state.ToString() + ", Class: " + - currentClass.ToString()); + $"Cannot have unresolved neutrals. State: {state}, Class: {currentClass}"); if ((flags & Flags.OverrideEuropeanNumberResolution) == 0) { @@ -1432,9 +1385,7 @@ Flags flags // [IN] case StateMachineAction.EN_ET: Debug.Assert(startOfDelayed != PositionInvalid, - "Must have delayed weak classes. State: " + - state.ToString() + ", Class: " + - currentClass.ToString()); + $"Must have delayed weak classes. State: {state}, Class: {currentClass}"); if ((lastStrongClass == DirectionClass.ArabicLetter) || previousClassIsArabic) @@ -1574,9 +1525,7 @@ Flags flags // [IN] case StateMachineAction.N_ST: Debug.Assert(startOfNeutrals == PositionInvalid, - "Cannot have unresolved neutrals. State: " + - state.ToString() + ", Class: " + - currentClass.ToString()); + $"Cannot have unresolved neutrals. State: {state}, Class: {currentClass}"); if (startOfDelayed != PositionInvalid) { @@ -2465,8 +2414,7 @@ out int cchResolved // number of char resolved // unless we passed a corrupted data Debug.Assert(runLengthResolved == runLength, - "Failed to resolve neutrals and weaks. Run#:" + - counter.ToString(CultureInfo.InvariantCulture)); + $"Failed to resolve neutrals and weaks. Run#:{counter.ToString(CultureInfo.InvariantCulture)}"); } else { diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/IO/Packaging/PackWebRequest.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/IO/Packaging/PackWebRequest.cs index 2624fb9c4a3..d2dad768c1b 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/IO/Packaging/PackWebRequest.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/IO/Packaging/PackWebRequest.cs @@ -66,7 +66,7 @@ internal PackWebRequest(Uri uri, Uri packageUri, Uri partUri) /// is the cacheEntry thread-safe? /// This should only be called by PackWebRequestFactory /// Will throw an ArgumentException if the given URI is not of the correct scheme - #pragma warning disable SYSLIB0014 + #pragma warning disable SYSLIB0014 internal PackWebRequest(Uri uri, Uri packageUri, Uri partUri, Package cacheEntry, bool respectCachePolicy, bool cachedPackageIsThreadSafe) { @@ -85,12 +85,10 @@ internal PackWebRequest(Uri uri, Uri packageUri, Uri partUri, Package cacheEntry #if DEBUG if (PackWebRequestFactory._traceSwitch.Enabled && (cacheEntry != null)) System.Diagnostics.Trace.TraceInformation( - DateTime.Now.ToLongTimeString() + " " + DateTime.Now.Millisecond + " " + - Environment.CurrentManagedThreadId + ": " + - "PackWebRequest - working from Package Cache"); + $"{DateTime.Now:T} {DateTime.Now.Millisecond} {Environment.CurrentManagedThreadId}: PackWebRequest - working from Package Cache"); #endif } - #pragma warning restore SYSLIB0014 + #pragma warning restore SYSLIB0014 //------------------------------------------------------ // @@ -116,7 +114,7 @@ public override Stream GetRequestStream() public override WebResponse GetResponse() { bool cachedPackageAvailable = IsCachedPackage; - + // if there is no cached package or it is from the public PackageStore, we must respect CachePolicy if (!cachedPackageAvailable || (cachedPackageAvailable && _respectCachePolicy)) { @@ -151,15 +149,13 @@ public override WebResponse GetResponse() } } } - + if (cachedPackageAvailable) { #if DEBUG if (PackWebRequestFactory._traceSwitch.Enabled) System.Diagnostics.Trace.TraceInformation( - DateTime.Now.ToLongTimeString() + " " + DateTime.Now.Millisecond + " " + - Environment.CurrentManagedThreadId + ": " + - "PackWebRequest - Getting response from Package Cache"); + $"{DateTime.Now:T} {DateTime.Now.Millisecond} {Environment.CurrentManagedThreadId}: PackWebRequest - Getting response from Package Cache"); #endif return new PackWebResponse(_uri, _innerUri, _partName, _cacheEntry, _cachedPackageIsThreadSafe); } @@ -173,9 +169,7 @@ public override WebResponse GetResponse() #if DEBUG if (PackWebRequestFactory._traceSwitch.Enabled) System.Diagnostics.Trace.TraceInformation( - DateTime.Now.ToLongTimeString() + " " + DateTime.Now.Millisecond + " " + - Environment.CurrentManagedThreadId + ": " + - "PackWebRequest - Getting new response"); + $"{DateTime.Now:T} {DateTime.Now.Millisecond} {Environment.CurrentManagedThreadId}: PackWebRequest - Getting new response"); #endif // Create a new response for every call return new PackWebResponse(_uri, _innerUri, _partName, request); @@ -433,7 +427,7 @@ public override bool UseDefaultCredentials /// Inner WebRequest object. /// Inner uri is not resolvable to a valid transport protocol (such as /// ftp or http) and the request cannot be satisfied from the PackageStore. - /// The inner WebRequest is provided for advanced scenarios only and + /// The inner WebRequest is provided for advanced scenarios only and /// need not be accessed in most cases. /// A WebRequest created using the inner-uri or null if the inner uri is not resolvable and we /// have a valid PackageStore entry that can be used to provide data. @@ -484,7 +478,7 @@ private WebRequest GetRequest(bool allowPseudoRequest) { // Don't even attempt to create if we know it will fail. This does not eliminate all failure cases // but most and is very common so let's save an expensive exception. - // We still create a webRequest if possible even if we have a potential cacheEntry + // We still create a webRequest if possible even if we have a potential cacheEntry // because the caller may still specify BypassCache policy before calling GetResponse() that will force us to hit the server. if (!IsPreloadedPackage) { @@ -523,7 +517,7 @@ private WebRequest GetRequest(bool allowPseudoRequest) // In either case, we create a pseudo request to house property values. // In case 1, we know there will never be a cache bypass (we ignore cache policy for PreloadedPackages) // In case 2, the caller is using a schema that we cannot use for transport (not on of ftp, http, file, etc) - // and we will silently accept and ignore their property modifications/queries. + // and we will silently accept and ignore their property modifications/queries. // Note that if they change the cache policy to BypassCache they will get an exception when they call // GetResponse(). If they leave cache policy intact, and call GetResponse() // they will get data from the cached package. @@ -579,7 +573,7 @@ private bool IsPreloadedPackage // statics static private RequestCachePolicy _defaultCachePolicy = new RequestCachePolicy(RequestCacheLevel.CacheIfAvailable); - // These are "cached" inner Uri's taken from the available application: and SiteOfOrigin: Uri's. + // These are "cached" inner Uri's taken from the available application: and SiteOfOrigin: Uri's. // They are kept in statics to eliminate overhead of reparsing them on every request. // We are essentially extracting the "application://" out of "pack://application:,," static private Uri _siteOfOriginUri = PackUriHelper.GetPackageUri(System.Windows.Navigation.BaseUriHelper.SiteOfOriginBaseUri); diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/IO/Packaging/PackWebRequestFactory.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/IO/Packaging/PackWebRequestFactory.cs index 77ef570ea09..94106c00a65 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/IO/Packaging/PackWebRequestFactory.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/IO/Packaging/PackWebRequestFactory.cs @@ -66,9 +66,7 @@ WebRequest IWebRequestCreate.Create(Uri uri) #if DEBUG if (_traceSwitch.Enabled) System.Diagnostics.Trace.TraceInformation( - DateTime.Now.ToLongTimeString() + " " + DateTime.Now.Millisecond + " " + - Environment.CurrentManagedThreadId + ": " + - "PackWebRequestFactory - responding to uri: " + uri); + $"{DateTime.Now:T} {DateTime.Now.Millisecond} {Environment.CurrentManagedThreadId}: PackWebRequestFactory - responding to uri: {uri}"); #endif // only inspect cache if part name is present because cache only contains an object, not // the stream it was derived from @@ -105,9 +103,7 @@ WebRequest IWebRequestCreate.Create(Uri uri) #if DEBUG if (_traceSwitch.Enabled) System.Diagnostics.Trace.TraceInformation( - DateTime.Now.ToLongTimeString() + " " + DateTime.Now.Millisecond + " " + - Environment.CurrentManagedThreadId + ": " + - "PackWebRequestFactory - cache hit - returning CachedPackWebRequest"); + $"{DateTime.Now:T} {DateTime.Now.Millisecond} {Environment.CurrentManagedThreadId}: PackWebRequestFactory - cache hit - returning CachedPackWebRequest"); #endif // use the cached object return new PackWebRequest(uri, packageUri, partUri, c, @@ -118,9 +114,7 @@ WebRequest IWebRequestCreate.Create(Uri uri) #if DEBUG if (_traceSwitch.Enabled) System.Diagnostics.Trace.TraceInformation( - DateTime.Now.ToLongTimeString() + " " + DateTime.Now.Millisecond + " " + - Environment.CurrentManagedThreadId + ": " + - "PackWebRequestFactory - spawning regular PackWebRequest"); + $"{DateTime.Now:T} {DateTime.Now.Millisecond} {Environment.CurrentManagedThreadId}: PackWebRequestFactory - spawning regular PackWebRequest"); #endif return new PackWebRequest(uri, packageUri, partUri); } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/IO/Packaging/PackWebResponse.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/IO/Packaging/PackWebResponse.cs index c811dbe5292..d6f1819d082 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/IO/Packaging/PackWebResponse.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/IO/Packaging/PackWebResponse.cs @@ -74,9 +74,7 @@ internal PackWebResponse(Uri uri, Uri innerUri, Uri partName, WebRequest innerRe #if DEBUG if (PackWebRequestFactory._traceSwitch.Enabled) System.Diagnostics.Trace.TraceInformation( - DateTime.Now.ToLongTimeString() + " " + DateTime.Now.Millisecond + " " + - Environment.CurrentManagedThreadId + ": " + - "PackWebResponse - Creating response "); + $"{DateTime.Now:T} {DateTime.Now.Millisecond} {Environment.CurrentManagedThreadId}: PackWebResponse - Creating response "); #endif _innerUri = innerUri; _partName = partName; // may be null @@ -97,9 +95,7 @@ internal PackWebResponse(Uri uri, Uri innerUri, Uri partName, WebRequest innerRe #if DEBUG if (PackWebRequestFactory._traceSwitch.Enabled) System.Diagnostics.Trace.TraceInformation( - DateTime.Now.ToLongTimeString() + " " + DateTime.Now.Millisecond + " " + - Environment.CurrentManagedThreadId + ": " + - "PackWebResponse() starting timeout timer " + innerRequest.Timeout + " ms"); + $"{DateTime.Now:T} {DateTime.Now.Millisecond} {Environment.CurrentManagedThreadId}: PackWebResponse() starting timeout timer {innerRequest.Timeout} ms"); #endif _timeoutTimer = new Timer(new TimerCallback(TimeoutCallback), null, innerRequest.Timeout, Timeout.Infinite); } @@ -107,9 +103,7 @@ internal PackWebResponse(Uri uri, Uri innerUri, Uri partName, WebRequest innerRe #if DEBUG if (PackWebRequestFactory._traceSwitch.Enabled) System.Diagnostics.Trace.TraceInformation( - DateTime.Now.ToLongTimeString() + " " + DateTime.Now.Millisecond + " " + - Environment.CurrentManagedThreadId + ": " + - "PackWebResponse() BeginGetResponse()"); + $"{DateTime.Now:T} {DateTime.Now.Millisecond} {Environment.CurrentManagedThreadId}: PackWebResponse() BeginGetResponse()"); #endif // Issue the async request to get our "real" WebResponse @@ -141,9 +135,7 @@ internal PackWebResponse(Uri uri, Uri innerUri, Uri partName, Package cacheEntry #if DEBUG if (PackWebRequestFactory._traceSwitch.Enabled) System.Diagnostics.Trace.TraceInformation( - DateTime.Now.ToLongTimeString() + " " + DateTime.Now.Millisecond + " " + - Environment.CurrentManagedThreadId + ": " + - "PackWebResponse - Creating response from Package Cache"); + $"{DateTime.Now:T} {DateTime.Now.Millisecond} {Environment.CurrentManagedThreadId}: PackWebResponse - Creating response from Package Cache"); #endif _uri = uri; _innerUri = innerUri; @@ -180,9 +172,7 @@ public override Stream GetResponseStream() #if DEBUG if (PackWebRequestFactory._traceSwitch.Enabled) System.Diagnostics.Trace.TraceInformation( - DateTime.Now.ToLongTimeString() + " " + DateTime.Now.Millisecond + " " + - Environment.CurrentManagedThreadId + ": " + - "PackWebResponse - GetResponseStream()"); + $"{DateTime.Now:T} {DateTime.Now.Millisecond} {Environment.CurrentManagedThreadId}: PackWebResponse - GetResponseStream()"); #endif // create and return only a single stream for multiple calls if (_responseStream == null) @@ -202,9 +192,7 @@ public override Stream GetResponseStream() { if (PackWebRequestFactory._traceSwitch.Enabled) System.Diagnostics.Trace.TraceInformation( - DateTime.Now.ToLongTimeString() + " " + DateTime.Now.Millisecond + " " + - Environment.CurrentManagedThreadId + ": " + - "PackWebResponse - GetResponseStream() - stream length not available - disabling progressive download"); + $"{DateTime.Now:T} {DateTime.Now.Millisecond} {Environment.CurrentManagedThreadId}: PackWebResponse - GetResponseStream() - stream length not available - disabling progressive download"); } #endif @@ -494,9 +482,7 @@ protected override void Dispose(bool disposing) #if DEBUG if (PackWebRequestFactory._traceSwitch.Enabled) System.Diagnostics.Trace.TraceInformation( - DateTime.Now.ToLongTimeString() + " " + DateTime.Now.Millisecond + " " + - Environment.CurrentManagedThreadId + ": " + - "PackWebResponse.Close()"); + $"{DateTime.Now:T} {DateTime.Now.Millisecond} {Environment.CurrentManagedThreadId}: PackWebResponse.Close()"); #endif // prevent async callback from accessing these resources while we are disposing them lock (_lockObject) @@ -514,9 +500,7 @@ protected override void Dispose(bool disposing) #if DEBUG if (PackWebRequestFactory._traceSwitch.Enabled) System.Diagnostics.Trace.TraceInformation( - DateTime.Now.ToLongTimeString() + " " + DateTime.Now.Millisecond + " " + - Environment.CurrentManagedThreadId + ": " + - "PackWebResponse.Close() - close stream"); + $"{DateTime.Now:T} {DateTime.Now.Millisecond} {Environment.CurrentManagedThreadId}: PackWebResponse.Close() - close stream"); #endif _responseStream.Close(); } @@ -527,9 +511,7 @@ protected override void Dispose(bool disposing) #if DEBUG if (PackWebRequestFactory._traceSwitch.Enabled) System.Diagnostics.Trace.TraceInformation( - DateTime.Now.ToLongTimeString() + " " + DateTime.Now.Millisecond + " " + - Environment.CurrentManagedThreadId + ": " + - "PackWebResponse.Close() - close response"); + $"{DateTime.Now:T} {DateTime.Now.Millisecond} {Environment.CurrentManagedThreadId}: PackWebResponse.Close() - close response"); #endif // always call Dispose to satisfy FxCop ((IDisposable)_fullResponse).Dispose(); @@ -553,9 +535,7 @@ protected override void Dispose(bool disposing) #if DEBUG if (PackWebRequestFactory._traceSwitch.Enabled) System.Diagnostics.Trace.TraceInformation( - DateTime.Now.ToLongTimeString() + " " + DateTime.Now.Millisecond + " " + - Environment.CurrentManagedThreadId + ": " + - "PackWebResponse.Close() - exiting"); + $"{DateTime.Now:T} {DateTime.Now.Millisecond} {Environment.CurrentManagedThreadId}: PackWebResponse.Close() - exiting"); #endif } } // lock @@ -612,9 +592,7 @@ internal Stream GetResponseStream() #if DEBUG if (PackWebRequestFactory._traceSwitch.Enabled) System.Diagnostics.Trace.TraceInformation( - DateTime.Now.ToLongTimeString() + " " + DateTime.Now.Millisecond + " " + - Environment.CurrentManagedThreadId + ": " + - "CachedResponse - Getting response stream"); + $"{DateTime.Now:T} {DateTime.Now.Millisecond} {Environment.CurrentManagedThreadId}: CachedResponse - Getting response stream"); #endif // only one copy if (_parent._responseStream == null) @@ -629,18 +607,14 @@ internal Stream GetResponseStream() #if DEBUG if (PackWebRequestFactory._traceSwitch.Enabled) System.Diagnostics.Trace.TraceInformation( - DateTime.Now.ToLongTimeString() + " " + DateTime.Now.Millisecond + " " + - Environment.CurrentManagedThreadId + ": " + - "CachedResponse - Getting part " + _parent._partName); + $"{DateTime.Now:T} {DateTime.Now.Millisecond} {Environment.CurrentManagedThreadId}: CachedResponse - Getting part {_parent._partName}"); #endif // open the requested stream PackagePart p = _cacheEntry.GetPart(_parent._partName); #if DEBUG if (PackWebRequestFactory._traceSwitch.Enabled) System.Diagnostics.Trace.TraceInformation( - DateTime.Now.ToLongTimeString() + " " + DateTime.Now.Millisecond + " " + - Environment.CurrentManagedThreadId + ": " + - "CachedResponse - Getting part stream "); + $"{DateTime.Now:T} {DateTime.Now.Millisecond} {Environment.CurrentManagedThreadId}: CachedResponse - Getting part stream "); #endif Stream s = p.GetSeekableStream(FileMode.Open, FileAccess.Read); @@ -656,9 +630,7 @@ internal Stream GetResponseStream() #if DEBUG if (PackWebRequestFactory._traceSwitch.Enabled) System.Diagnostics.Trace.TraceInformation( - DateTime.Now.ToLongTimeString() + " " + DateTime.Now.Millisecond + " " + - Environment.CurrentManagedThreadId + ": " + - "CachedResponse - Getting part contenttype"); + $"{DateTime.Now:T} {DateTime.Now.Millisecond} {Environment.CurrentManagedThreadId}: CachedResponse - Getting part contenttype"); #endif _parent._mimeType = new MS.Internal.ContentType(p.ContentType); @@ -669,9 +641,7 @@ internal Stream GetResponseStream() #if DEBUG if (PackWebRequestFactory._traceSwitch.Enabled) System.Diagnostics.Trace.TraceInformation( - DateTime.Now.ToLongTimeString() + " " + DateTime.Now.Millisecond + " " + - Environment.CurrentManagedThreadId + ": " + - "CachedResponse - Length is available from stream"); + $"{DateTime.Now:T} {DateTime.Now.Millisecond} {Environment.CurrentManagedThreadId}: CachedResponse - Length is available from stream"); #endif _parent._fullStreamLength = s.Length; } @@ -680,9 +650,7 @@ internal Stream GetResponseStream() { if (PackWebRequestFactory._traceSwitch.Enabled) System.Diagnostics.Trace.TraceInformation( - DateTime.Now.ToLongTimeString() + " " + DateTime.Now.Millisecond + " " + - Environment.CurrentManagedThreadId + ": " + - "CachedResponse - Length is not available from stream" + _parent._partName); + $"{DateTime.Now:T} {DateTime.Now.Millisecond} {Environment.CurrentManagedThreadId}: CachedResponse - Length is not available from stream{_parent._partName}"); } #endif // re-use existing member variable @@ -782,9 +750,7 @@ private void ResponseCallback(IAsyncResult ar) #if DEBUG if (PackWebRequestFactory._traceSwitch.Enabled) System.Diagnostics.Trace.TraceInformation( - DateTime.Now.ToLongTimeString() + " " + DateTime.Now.Millisecond + " " + - Environment.CurrentManagedThreadId + ": " + - "PackWebResponse.ResponseCallBack()"); + $"{DateTime.Now:T} {DateTime.Now.Millisecond} {Environment.CurrentManagedThreadId}: PackWebResponse.ResponseCallBack()"); #endif // Dispose/Close waits on _responseAvailable so we know that these are available // No need to lock. @@ -804,9 +770,7 @@ private void ResponseCallback(IAsyncResult ar) #if DEBUG if (PackWebRequestFactory._traceSwitch.Enabled) System.Diagnostics.Trace.TraceError( - DateTime.Now.ToLongTimeString() + " " + DateTime.Now.Millisecond + " " + - Environment.CurrentManagedThreadId + ": " + - "PackWebResponse.ResponseCallBack() exception"); + $"{DateTime.Now:T} {DateTime.Now.Millisecond} {Environment.CurrentManagedThreadId}: PackWebResponse.ResponseCallBack() exception"); #endif // inform other thread of error condition _responseError = true; @@ -819,9 +783,7 @@ private void ResponseCallback(IAsyncResult ar) #if DEBUG if (PackWebRequestFactory._traceSwitch.Enabled) System.Diagnostics.Trace.TraceInformation( - DateTime.Now.ToLongTimeString() + " " + DateTime.Now.Millisecond + " " + - Environment.CurrentManagedThreadId + ": " + - "PackWebResponse.ResponseCallBack() - signal response available"); + $"{DateTime.Now:T} {DateTime.Now.Millisecond} {Environment.CurrentManagedThreadId}: PackWebResponse.ResponseCallBack() - signal response available"); #endif // We need the original webRequest to get HttpStack information so that they can be used to make @@ -848,9 +810,7 @@ private void WaitForResponse() #if DEBUG if (PackWebRequestFactory._traceSwitch.Enabled) System.Diagnostics.Trace.TraceInformation( - DateTime.Now.ToLongTimeString() + " " + DateTime.Now.Millisecond + " " + - Environment.CurrentManagedThreadId + ": " + - "PackWebResponse.WaitForResponse()"); + $"{DateTime.Now:T} {DateTime.Now.Millisecond} {Environment.CurrentManagedThreadId}: PackWebResponse.WaitForResponse()"); #endif // wait for the response callback _responseAvailable.WaitOne(); @@ -890,9 +850,7 @@ private void TimeoutCallback(Object stateInfo) #if DEBUG if (PackWebRequestFactory._traceSwitch.Enabled) System.Diagnostics.Trace.TraceError( - DateTime.Now.ToLongTimeString() + " " + DateTime.Now.Millisecond + " " + - Environment.CurrentManagedThreadId + ": " + - "PackWebResponse.TimerCallback() timeout - throwing exception"); + $"{DateTime.Now:T} {DateTime.Now.Millisecond} {Environment.CurrentManagedThreadId}: PackWebResponse.TimerCallback() timeout - throwing exception"); #endif // caller is still blocked so need to throw to indicate timeout // create exception to be thrown on client thread, then unblock the caller @@ -905,9 +863,7 @@ private void TimeoutCallback(Object stateInfo) { if (PackWebRequestFactory._traceSwitch.Enabled) System.Diagnostics.Trace.TraceInformation( - DateTime.Now.ToLongTimeString() + " " + DateTime.Now.Millisecond + " " + - Environment.CurrentManagedThreadId + ": " + - "PackWebResponse.TimerCallback() no timeout - ignoring callback"); + $"{DateTime.Now:T} {DateTime.Now.Millisecond} {Environment.CurrentManagedThreadId}: PackWebResponse.TimerCallback() no timeout - ignoring callback"); } #endif // clean up diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Diagnostics/VisualDiagnostics.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Diagnostics/VisualDiagnostics.cs index ba00a439c7c..5c85b06776b 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Diagnostics/VisualDiagnostics.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Diagnostics/VisualDiagnostics.cs @@ -382,7 +382,7 @@ private static bool IsEnableVisualTreeChangedAllowed const string c_enableVisualTreeNotificationsEnvironmentVariable = "ENABLE_XAML_DIAGNOSTICS_VISUAL_TREE_NOTIFICATIONS"; const string c_devmodeRegKey = @"SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock"; - const string c_devmodeRegKeyFullPath = @"HKEY_LOCAL_MACHINE\" + c_devmodeRegKey; + const string c_devmodeRegKeyFullPath = $@"HKEY_LOCAL_MACHINE\{c_devmodeRegKey}"; const string c_devmodeValueName = "AllowDevelopmentWithoutDevLicense"; } } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/FreezableCollection.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/FreezableCollection.cs index 3d8a38a601d..11911b8c3dc 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/FreezableCollection.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/FreezableCollection.cs @@ -1103,7 +1103,7 @@ public T Current } else { - Debug.Assert(_index == -2, "expected -2, got " + _index + "\n"); + Debug.Assert(_index == -2, $"expected -2, got {_index}\n"); throw new InvalidOperationException(SR.Enumerator_ReachedEnd); } } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Generated/TextDecorationCollection.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Generated/TextDecorationCollection.cs index 3918d06a4b4..e784983e732 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Generated/TextDecorationCollection.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Generated/TextDecorationCollection.cs @@ -849,7 +849,7 @@ public TextDecoration Current } else { - Debug.Assert(_index == -2, "expected -2, got " + _index + "\n"); + Debug.Assert(_index == -2, $"expected -2, got {_index}\n"); throw new InvalidOperationException(SR.Enumerator_ReachedEnd); } } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Command/CommandBinding.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Command/CommandBinding.cs index d6cb56063ea..7b52b878391 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Command/CommandBinding.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Command/CommandBinding.cs @@ -186,7 +186,7 @@ internal void OnExecuted(object sender, ExecutedRoutedEventArgs e) { if (Executed is null) return; if (!CheckCanExecute(sender, e)) return; - Debug.Assert(Executed != null, nameof(Executed) + " != null"); + Debug.Assert(Executed != null, $"{nameof(Executed)} != null"); Executed(sender, e); e.Handled = true; } @@ -194,7 +194,7 @@ internal void OnExecuted(object sender, ExecutedRoutedEventArgs e) { if (PreviewExecuted is null) return; if (!CheckCanExecute(sender, e)) return; - Debug.Assert(PreviewExecuted != null, nameof(PreviewExecuted) + " != null"); + Debug.Assert(PreviewExecuted != null, $"{nameof(PreviewExecuted)} != null"); PreviewExecuted(sender, e); e.Handled = true; } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Command/ISecureCommand.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Command/ISecureCommand.cs index 39862ddfa64..a39334f862d 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Command/ISecureCommand.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Command/ISecureCommand.cs @@ -27,7 +27,7 @@ namespace System.Windows.Input /// interactive (trusted) way. /// [FriendAccessAllowed] - [TypeConverter("System.Windows.Input.CommandConverter, PresentationFramework, Version=" + BuildInfo.WCP_VERSION + ", Culture=neutral, PublicKeyToken=" + BuildInfo.WCP_PUBLIC_KEY_TOKEN + ", Custom=null")] + [TypeConverter($"System.Windows.Input.CommandConverter, PresentationFramework, Version={BuildInfo.WCP_VERSION}, Culture=neutral, PublicKeyToken={BuildInfo.WCP_PUBLIC_KEY_TOKEN}, Custom=null")] internal interface ISecureCommand : ICommand { } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Command/InputBinding.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Command/InputBinding.cs index e96c4984692..69a1bf40d4c 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Command/InputBinding.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Command/InputBinding.cs @@ -64,7 +64,7 @@ public InputBinding(ICommand command, InputGesture gesture) /// /// Command Object associated /// - [TypeConverter("System.Windows.Input.CommandConverter, PresentationFramework, Version=" + BuildInfo.WCP_VERSION + ", Culture=neutral, PublicKeyToken=" + BuildInfo.WCP_PUBLIC_KEY_TOKEN + ", Custom=null")] + [TypeConverter($"System.Windows.Input.CommandConverter, PresentationFramework, Version={BuildInfo.WCP_VERSION}, Culture=neutral, PublicKeyToken={BuildInfo.WCP_PUBLIC_KEY_TOKEN}, Custom=null")] [Localizability(LocalizationCategory.NeverLocalize)] // cannot be localized public ICommand Command { diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Command/RoutedCommand.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Command/RoutedCommand.cs index aa33ac0f254..2d715ceb485 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Command/RoutedCommand.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Command/RoutedCommand.cs @@ -22,8 +22,8 @@ namespace System.Windows.Input /// /// A command that causes handlers associated with it to be called. /// - [TypeConverter("System.Windows.Input.CommandConverter, PresentationFramework, Version=" + BuildInfo.WCP_VERSION + ", Culture=neutral, PublicKeyToken=" + BuildInfo.WCP_PUBLIC_KEY_TOKEN + ", Custom=null")] - [ValueSerializer("System.Windows.Input.CommandValueSerializer, PresentationFramework, Version=" + BuildInfo.WCP_VERSION + ", Culture=neutral, PublicKeyToken=" + BuildInfo.WCP_PUBLIC_KEY_TOKEN + ", Custom=null")] + [TypeConverter($"System.Windows.Input.CommandConverter, PresentationFramework, Version={BuildInfo.WCP_VERSION}, Culture=neutral, PublicKeyToken={BuildInfo.WCP_PUBLIC_KEY_TOKEN}, Custom=null")] + [ValueSerializer($"System.Windows.Input.CommandValueSerializer, PresentationFramework, Version={BuildInfo.WCP_VERSION}, Culture=neutral, PublicKeyToken={BuildInfo.WCP_PUBLIC_KEY_TOKEN}, Custom=null")] public class RoutedCommand : ICommand { #region Constructors diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Command/RoutedUICommand.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Command/RoutedUICommand.cs index 47330bb51d5..1ac349ba7c2 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Command/RoutedUICommand.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Command/RoutedUICommand.cs @@ -18,7 +18,7 @@ namespace System.Windows.Input /// /// RoutedCommand with added UI Information. /// - [TypeConverter("System.Windows.Input.CommandConverter, PresentationFramework, Version=" + BuildInfo.WCP_VERSION + ", Culture=neutral, PublicKeyToken=" + BuildInfo.WCP_PUBLIC_KEY_TOKEN + ", Custom=null")] + [TypeConverter($"System.Windows.Input.CommandConverter, PresentationFramework, Version={BuildInfo.WCP_VERSION}, Culture=neutral, PublicKeyToken={BuildInfo.WCP_PUBLIC_KEY_TOKEN}, Custom=null")] public class RoutedUICommand : RoutedCommand { /// diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Command/SecureUICommand.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Command/SecureUICommand.cs index 153bc7dbe8d..1535d1e0ff9 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Command/SecureUICommand.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Command/SecureUICommand.cs @@ -23,7 +23,7 @@ namespace System.Windows.Input /// /// Command /// - [TypeConverter("System.Windows.Input.CommandConverter, PresentationFramework, Version=" + BuildInfo.WCP_VERSION + ", Culture=neutral, PublicKeyToken=" + BuildInfo.WCP_PUBLIC_KEY_TOKEN + ", Custom=null")] + [TypeConverter($"System.Windows.Input.CommandConverter, PresentationFramework, Version={BuildInfo.WCP_VERSION}, Culture=neutral, PublicKeyToken={BuildInfo.WCP_PUBLIC_KEY_TOKEN}, Custom=null")] internal class SecureUICommand : RoutedUICommand, ISecureCommand { /// diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/InputScope.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/InputScope.cs index 40b337bc16b..e51210bc39c 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/InputScope.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/InputScope.cs @@ -28,7 +28,7 @@ namespace System.Windows.Input /// /// http://avalon/Cicero/Specifications/Stylable%20InputScope.mht - [TypeConverter("System.Windows.Input.InputScopeConverter, PresentationCore, Version=" + BuildInfo.WCP_VERSION + ", Culture=neutral, PublicKeyToken=" + BuildInfo.WCP_PUBLIC_KEY_TOKEN + ", Custom=null")] + [TypeConverter($"System.Windows.Input.InputScopeConverter, PresentationCore, Version={BuildInfo.WCP_VERSION}, Culture=neutral, PublicKeyToken={BuildInfo.WCP_PUBLIC_KEY_TOKEN}, Custom=null")] public class InputScope { /// @@ -111,7 +111,7 @@ public System.Collections.IList PhraseList /// form a list /// [ContentProperty("NameValue")] - [TypeConverter("System.Windows.Input.InputScopeNameConverter, PresentationCore, Version=" + BuildInfo.WCP_VERSION + ", Culture=neutral, PublicKeyToken=" + BuildInfo.WCP_PUBLIC_KEY_TOKEN + ", Custom=null")] + [TypeConverter($"System.Windows.Input.InputScopeNameConverter, PresentationCore, Version={BuildInfo.WCP_VERSION}, Culture=neutral, PublicKeyToken={BuildInfo.WCP_PUBLIC_KEY_TOKEN}, Custom=null")] public class InputScopeName : IAddChild { // NOTE: this is a class rather than a simple string so that we can add more hint information diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Common/StylusLogic.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Common/StylusLogic.cs index b0f201c0026..816eaef420a 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Common/StylusLogic.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Common/StylusLogic.cs @@ -77,7 +77,7 @@ internal enum FlickScrollDirection /// /// The key to assert access to for WISP data /// - private const string WispKeyAssert = @"HKEY_CURRENT_USER\" + WispRootKey; + private const string WispKeyAssert = $@"HKEY_CURRENT_USER\{WispRootKey}"; /// /// The root of all WISP registry entries @@ -87,12 +87,12 @@ internal enum FlickScrollDirection /// /// The event parameters for WISP pen input /// - private const string WispPenSystemEventParametersKey = WispRootKey + @"Software\Microsoft\Wisp\Pen\SysEventParameters"; + private const string WispPenSystemEventParametersKey = $@"{WispRootKey}Software\Microsoft\Wisp\Pen\SysEventParameters"; /// /// The WISP touch paramaters /// - private const string WispTouchConfigKey = WispRootKey + @"Software\Microsoft\Wisp\Touch"; + private const string WispTouchConfigKey = $@"{WispRootKey}Software\Microsoft\Wisp\Touch"; /// /// The max distance a double tap can vary @@ -126,7 +126,7 @@ internal enum FlickScrollDirection /// /// String to use for assert of registry permissions /// - private const string WpfPointerKeyAssert = @"HKEY_CURRENT_USER\" + WpfPointerKey; + private const string WpfPointerKeyAssert = $@"HKEY_CURRENT_USER\{WpfPointerKey}"; /// /// The key location for the registry switch to configure the touch stack system wide diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Common/StylusPointProperty.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Common/StylusPointProperty.cs index 36c9be83ade..78e5d737f55 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Common/StylusPointProperty.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Common/StylusPointProperty.cs @@ -97,11 +97,7 @@ public bool IsButton /// public override string ToString() { - return "{Id=" + - StylusPointPropertyIds.GetStringRepresentation(_id) + - ", IsButton=" + - _isButton.ToString(CultureInfo.InvariantCulture) + - "}"; + return $"{{Id={StylusPointPropertyIds.GetStringRepresentation(_id)}, IsButton={_isButton.ToString(CultureInfo.InvariantCulture)}}}"; } } } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/InterOp/HwndMouseInputProvider.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/InterOp/HwndMouseInputProvider.cs index dd703c1c333..285c98fd1e0 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/InterOp/HwndMouseInputProvider.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/InterOp/HwndMouseInputProvider.cs @@ -1482,7 +1482,7 @@ private void RecordMouseMove(int x, int y, int timestamp) private NativeMethods.TRACKMOUSEEVENT _tme = new NativeMethods.TRACKMOUSEEVENT(); // accessors into PresentationFramework classes - const string PresentationFrameworkAssemblyFullName = "PresentationFramework, Version=" + BuildInfo.WCP_VERSION + ", Culture=neutral, PublicKeyToken=" + BuildInfo.WCP_PUBLIC_KEY_TOKEN; + const string PresentationFrameworkAssemblyFullName = $"PresentationFramework, Version={BuildInfo.WCP_VERSION}, Culture=neutral, PublicKeyToken={BuildInfo.WCP_PUBLIC_KEY_TOKEN}"; private static DependencyProperty WindowChromeWorkerProperty; private static MethodInfo GetEffectiveClientAreaMI; diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/Generated/TimelineCollection.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/Generated/TimelineCollection.cs index 7883663be4e..6a09af975a8 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/Generated/TimelineCollection.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/Generated/TimelineCollection.cs @@ -868,7 +868,7 @@ public Timeline Current } else { - Debug.Assert(_index == -2, "expected -2, got " + _index + "\n"); + Debug.Assert(_index == -2, $"expected -2, got {_index}\n"); throw new InvalidOperationException(SR.Enumerator_ReachedEnd); } } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Effects/Generated/BitmapEffectCollection.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Effects/Generated/BitmapEffectCollection.cs index 9d122483dfb..5d8104eba49 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Effects/Generated/BitmapEffectCollection.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Effects/Generated/BitmapEffectCollection.cs @@ -855,7 +855,7 @@ public BitmapEffect Current } else { - Debug.Assert(_index == -2, "expected -2, got " + _index + "\n"); + Debug.Assert(_index == -2, $"expected -2, got {_index}\n"); throw new InvalidOperationException(SR.Enumerator_ReachedEnd); } } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Fonts.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Fonts.cs index fd96c1b4477..3c78e018bea 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Fonts.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Fonts.cs @@ -119,7 +119,7 @@ public static ICollection GetFontFamilies(Uri baseUri, string locati if (string.IsNullOrEmpty(location)) location = "./"; else if (Util.IsReferenceToWindowsFonts(location)) - location = "./" + location; + location = $"./{location}"; fontLocation = new Uri(baseUri, location); } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Generated/DoubleCollection.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Generated/DoubleCollection.cs index eb789bb0e41..150e107f443 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Generated/DoubleCollection.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Generated/DoubleCollection.cs @@ -878,7 +878,7 @@ public double Current } else { - Debug.Assert(_index == -2, "expected -2, got " + _index + "\n"); + Debug.Assert(_index == -2, $"expected -2, got {_index}\n"); throw new InvalidOperationException(SR.Enumerator_ReachedEnd); } } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Generated/DrawingCollection.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Generated/DrawingCollection.cs index 32096ea4bb8..f9ef5069d4a 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Generated/DrawingCollection.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Generated/DrawingCollection.cs @@ -898,7 +898,7 @@ public Drawing Current } else { - Debug.Assert(_index == -2, "expected -2, got " + _index + "\n"); + Debug.Assert(_index == -2, $"expected -2, got {_index}\n"); throw new InvalidOperationException(SR.Enumerator_ReachedEnd); } } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Generated/GeneralTransformCollection.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Generated/GeneralTransformCollection.cs index 89e1716ea2d..66ea041934b 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Generated/GeneralTransformCollection.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Generated/GeneralTransformCollection.cs @@ -857,7 +857,7 @@ public GeneralTransform Current } else { - Debug.Assert(_index == -2, "expected -2, got " + _index + "\n"); + Debug.Assert(_index == -2, $"expected -2, got {_index}\n"); throw new InvalidOperationException(SR.Enumerator_ReachedEnd); } } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Generated/GeometryCollection.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Generated/GeometryCollection.cs index 64708d0427c..25dc42c8c9c 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Generated/GeometryCollection.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Generated/GeometryCollection.cs @@ -898,7 +898,7 @@ public Geometry Current } else { - Debug.Assert(_index == -2, "expected -2, got " + _index + "\n"); + Debug.Assert(_index == -2, $"expected -2, got {_index}\n"); throw new InvalidOperationException(SR.Enumerator_ReachedEnd); } } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Generated/GradientStopCollection.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Generated/GradientStopCollection.cs index d8f512eb3dc..8192422475f 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Generated/GradientStopCollection.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Generated/GradientStopCollection.cs @@ -960,7 +960,7 @@ public GradientStop Current } else { - Debug.Assert(_index == -2, "expected -2, got " + _index + "\n"); + Debug.Assert(_index == -2, $"expected -2, got {_index}\n"); throw new InvalidOperationException(SR.Enumerator_ReachedEnd); } } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Generated/Int32Collection.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Generated/Int32Collection.cs index 1e15aaab176..1e103e724c4 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Generated/Int32Collection.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Generated/Int32Collection.cs @@ -878,7 +878,7 @@ public int Current } else { - Debug.Assert(_index == -2, "expected -2, got " + _index + "\n"); + Debug.Assert(_index == -2, $"expected -2, got {_index}\n"); throw new InvalidOperationException(SR.Enumerator_ReachedEnd); } } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Generated/PathFigureCollection.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Generated/PathFigureCollection.cs index 0ef8e4e1ad4..10b99167073 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Generated/PathFigureCollection.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Generated/PathFigureCollection.cs @@ -947,7 +947,7 @@ public PathFigure Current } else { - Debug.Assert(_index == -2, "expected -2, got " + _index + "\n"); + Debug.Assert(_index == -2, $"expected -2, got {_index}\n"); throw new InvalidOperationException(SR.Enumerator_ReachedEnd); } } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Generated/PathSegmentCollection.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Generated/PathSegmentCollection.cs index 138f07ab41e..c5952e44bb1 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Generated/PathSegmentCollection.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Generated/PathSegmentCollection.cs @@ -857,7 +857,7 @@ public PathSegment Current } else { - Debug.Assert(_index == -2, "expected -2, got " + _index + "\n"); + Debug.Assert(_index == -2, $"expected -2, got {_index}\n"); throw new InvalidOperationException(SR.Enumerator_ReachedEnd); } } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Generated/PointCollection.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Generated/PointCollection.cs index 15e59695543..499549fe54d 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Generated/PointCollection.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Generated/PointCollection.cs @@ -880,7 +880,7 @@ public Point Current } else { - Debug.Assert(_index == -2, "expected -2, got " + _index + "\n"); + Debug.Assert(_index == -2, $"expected -2, got {_index}\n"); throw new InvalidOperationException(SR.Enumerator_ReachedEnd); } } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Generated/TextEffectCollection.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Generated/TextEffectCollection.cs index 9c3252de274..0ce0c473ad0 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Generated/TextEffectCollection.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Generated/TextEffectCollection.cs @@ -857,7 +857,7 @@ public TextEffect Current } else { - Debug.Assert(_index == -2, "expected -2, got " + _index + "\n"); + Debug.Assert(_index == -2, $"expected -2, got {_index}\n"); throw new InvalidOperationException(SR.Enumerator_ReachedEnd); } } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Generated/TransformCollection.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Generated/TransformCollection.cs index 83072f655d4..0c1df6231c0 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Generated/TransformCollection.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Generated/TransformCollection.cs @@ -898,7 +898,7 @@ public Transform Current } else { - Debug.Assert(_index == -2, "expected -2, got " + _index + "\n"); + Debug.Assert(_index == -2, $"expected -2, got {_index}\n"); throw new InvalidOperationException(SR.Enumerator_ReachedEnd); } } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Generated/VectorCollection.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Generated/VectorCollection.cs index 95fc56bfcba..29619cdb608 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Generated/VectorCollection.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Generated/VectorCollection.cs @@ -880,7 +880,7 @@ public Vector Current } else { - Debug.Assert(_index == -2, "expected -2, got " + _index + "\n"); + Debug.Assert(_index == -2, $"expected -2, got {_index}\n"); throw new InvalidOperationException(SR.Enumerator_ReachedEnd); } } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Knowncolors.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Knowncolors.cs index 92bd8c51da6..4027e9227ef 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Knowncolors.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Knowncolors.cs @@ -175,7 +175,7 @@ static KnownColors() Array knownColorValues = Enum.GetValues(typeof(KnownColor)); foreach (KnownColor colorValue in knownColorValues) { - string aRGBString = String.Format("#{0,8:X8}", (uint)colorValue); + string aRGBString = $"#{(uint)colorValue,8:X8}"; s_knownArgbColors[aRGBString] = colorValue; } } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/LineSegment.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/LineSegment.cs index f2e0c427f91..a86dfa1b77a 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/LineSegment.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/LineSegment.cs @@ -103,7 +103,7 @@ internal override bool IsCurved() /// internal override string ConvertToString(string format, IFormatProvider provider) { - return "L" + ((IFormattable)Point).ToString(format, provider); + return $"L{((IFormattable)Point).ToString(format, provider)}"; } } } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/PathFigure.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/PathFigure.cs index 06b2596be8a..65eddfe94d4 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/PathFigure.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/PathFigure.cs @@ -223,10 +223,7 @@ internal bool CanSerializeToString() internal string ConvertToString(string format, IFormatProvider provider) { PathSegmentCollection segments = Segments; - return "M" + - ((IFormattable)StartPoint).ToString(format, provider) + - (segments != null ? segments.ConvertToString(format, provider) : "") + - (IsClosed ? "z" : ""); + return $"M{((IFormattable)StartPoint).ToString(format, provider)}{(segments != null ? segments.ConvertToString(format, provider) : "")}{(IsClosed ? "z" : "")}"; } /// diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/PathGeometry.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/PathGeometry.cs index 12a800b80bf..c0267f56327 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/PathGeometry.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/PathGeometry.cs @@ -954,7 +954,7 @@ internal override string ConvertToString(string format, IFormatProvider provider if (fillRule != FillRule.EvenOdd) { - return "F1" + figuresString; + return $"F1{figuresString}"; } else { diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/PolyBezierSegment.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/PolyBezierSegment.cs index 8a4513c2b07..47612775d37 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/PolyBezierSegment.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/PolyBezierSegment.cs @@ -41,7 +41,7 @@ public sealed partial class PolyBezierSegment : PathSegment /// internal override string ConvertToString(string format, IFormatProvider provider) { - return (Points != null) ? "C" + Points.ConvertToString(format, provider) : ""; + return (Points != null) ? $"C{Points.ConvertToString(format, provider)}" : ""; } } } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/PolyLineSegment.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/PolyLineSegment.cs index 4c4452d32b1..265351559be 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/PolyLineSegment.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/PolyLineSegment.cs @@ -41,7 +41,7 @@ public sealed partial class PolyLineSegment : PathSegment /// internal override string ConvertToString(string format, IFormatProvider provider) { - return (!IsEmpty()) ? "L" + Points.ConvertToString(format, provider) : ""; + return (!IsEmpty()) ? $"L{Points.ConvertToString(format, provider)}" : ""; } } } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/PolyQuadraticBezierSegment.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/PolyQuadraticBezierSegment.cs index 2d85067649c..a92eb79ac86 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/PolyQuadraticBezierSegment.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/PolyQuadraticBezierSegment.cs @@ -41,7 +41,7 @@ public sealed partial class PolyQuadraticBezierSegment : PathSegment /// internal override string ConvertToString(string format, IFormatProvider provider) { - return (Points != null) ? "Q" + Points.ConvertToString(format, provider) : ""; + return (Points != null) ? $"Q{Points.ConvertToString(format, provider)}" : ""; } } } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media3D/Generated/GeneralTransform3DCollection.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media3D/Generated/GeneralTransform3DCollection.cs index d24bd87e1c9..da9a7015d91 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media3D/Generated/GeneralTransform3DCollection.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media3D/Generated/GeneralTransform3DCollection.cs @@ -853,7 +853,7 @@ public GeneralTransform3D Current } else { - Debug.Assert(_index == -2, "expected -2, got " + _index + "\n"); + Debug.Assert(_index == -2, $"expected -2, got {_index}\n"); throw new InvalidOperationException(SR.Enumerator_ReachedEnd); } } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media3D/Generated/MaterialCollection.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media3D/Generated/MaterialCollection.cs index fb21b82122d..dc4899e1556 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media3D/Generated/MaterialCollection.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media3D/Generated/MaterialCollection.cs @@ -894,7 +894,7 @@ public Material Current } else { - Debug.Assert(_index == -2, "expected -2, got " + _index + "\n"); + Debug.Assert(_index == -2, $"expected -2, got {_index}\n"); throw new InvalidOperationException(SR.Enumerator_ReachedEnd); } } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media3D/Generated/Model3DCollection.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media3D/Generated/Model3DCollection.cs index 2a677e2f608..98258b514f1 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media3D/Generated/Model3DCollection.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media3D/Generated/Model3DCollection.cs @@ -894,7 +894,7 @@ public Model3D Current } else { - Debug.Assert(_index == -2, "expected -2, got " + _index + "\n"); + Debug.Assert(_index == -2, $"expected -2, got {_index}\n"); throw new InvalidOperationException(SR.Enumerator_ReachedEnd); } } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media3D/Generated/Point3DCollection.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media3D/Generated/Point3DCollection.cs index 9a7c56e29b9..77b1bea283b 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media3D/Generated/Point3DCollection.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media3D/Generated/Point3DCollection.cs @@ -877,7 +877,7 @@ public Point3D Current } else { - Debug.Assert(_index == -2, "expected -2, got " + _index + "\n"); + Debug.Assert(_index == -2, $"expected -2, got {_index}\n"); throw new InvalidOperationException(SR.Enumerator_ReachedEnd); } } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media3D/Generated/Transform3DCollection.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media3D/Generated/Transform3DCollection.cs index 8949caa93c2..479b8395b7f 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media3D/Generated/Transform3DCollection.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media3D/Generated/Transform3DCollection.cs @@ -894,7 +894,7 @@ public Transform3D Current } else { - Debug.Assert(_index == -2, "expected -2, got " + _index + "\n"); + Debug.Assert(_index == -2, $"expected -2, got {_index}\n"); throw new InvalidOperationException(SR.Enumerator_ReachedEnd); } } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media3D/Generated/Vector3DCollection.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media3D/Generated/Vector3DCollection.cs index d1dffa178db..ca0e089407d 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media3D/Generated/Vector3DCollection.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media3D/Generated/Vector3DCollection.cs @@ -877,7 +877,7 @@ public Vector3D Current } else { - Debug.Assert(_index == -2, "expected -2, got " + _index + "\n"); + Debug.Assert(_index == -2, $"expected -2, got {_index}\n"); throw new InvalidOperationException(SR.Enumerator_ReachedEnd); } } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media3D/MeshGeometry3D.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media3D/MeshGeometry3D.cs index 1df0cac6b54..8eb448939fe 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media3D/MeshGeometry3D.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media3D/MeshGeometry3D.cs @@ -416,7 +416,7 @@ ref Point barycentric } double dist = (worldPointHit - rayParams.Origin).Length; - Debug.Assert(dist > 0, "Distance is negative: " + dist); + Debug.Assert(dist > 0, $"Distance is negative: {dist}"); if (rayParams.HasModelTransformMatrix) { diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/RoutedEvent.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/RoutedEvent.cs index 85123b2219d..400618f7632 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/RoutedEvent.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/RoutedEvent.cs @@ -25,8 +25,8 @@ namespace System.Windows /// NOTE: None of the members can be null /// /// - [TypeConverter("System.Windows.Markup.RoutedEventConverter, PresentationFramework, Version=" + BuildInfo.WCP_VERSION + ", Culture=neutral, PublicKeyToken=" + BuildInfo.WCP_PUBLIC_KEY_TOKEN + ", Custom=null")] - [ValueSerializer("System.Windows.Markup.RoutedEventValueSerializer, PresentationFramework, Version=" + BuildInfo.WCP_VERSION + ", Culture=neutral, PublicKeyToken=" + BuildInfo.WCP_PUBLIC_KEY_TOKEN + ", Custom=null")] + [TypeConverter($"System.Windows.Markup.RoutedEventConverter, PresentationFramework, Version={BuildInfo.WCP_VERSION}, Culture=neutral, PublicKeyToken={BuildInfo.WCP_PUBLIC_KEY_TOKEN}, Custom=null")] + [ValueSerializer($"System.Windows.Markup.RoutedEventValueSerializer, PresentationFramework, Version={BuildInfo.WCP_VERSION}, Culture=neutral, PublicKeyToken={BuildInfo.WCP_PUBLIC_KEY_TOKEN}, Custom=null")] public sealed class RoutedEvent { #region External API diff --git a/src/Microsoft.DotNet.Wpf/src/Shared/System/Windows/Interop/OSVersionHelper.cs b/src/Microsoft.DotNet.Wpf/src/Shared/System/Windows/Interop/OSVersionHelper.cs index 58d54558dcf..e205a16cb60 100644 --- a/src/Microsoft.DotNet.Wpf/src/Shared/System/Windows/Interop/OSVersionHelper.cs +++ b/src/Microsoft.DotNet.Wpf/src/Shared/System/Windows/Interop/OSVersionHelper.cs @@ -225,43 +225,26 @@ static OSVersionHelper() internal static bool IsOsVersionOrGreater(OperatingSystemVersion osVer) { - switch (osVer) + return osVer switch { - case OperatingSystemVersion.Windows10RS5: - return IsOsWindows10RS5OrGreater; - case OperatingSystemVersion.Windows10RS4: - return IsOsWindows10RS4OrGreater; - case OperatingSystemVersion.Windows10RS3: - return IsOsWindows10RS3OrGreater; - case OperatingSystemVersion.Windows10RS2: - return IsOsWindows10RS2OrGreater; - case OperatingSystemVersion.Windows10RS1: - return IsOsWindows10RS1OrGreater; - case OperatingSystemVersion.Windows10TH2: - return IsOsWindows10TH2OrGreater; - case OperatingSystemVersion.Windows10: - return IsOsWindows10OrGreater; - case OperatingSystemVersion.Windows8Point1: - return IsOsWindows8Point1OrGreater; - case OperatingSystemVersion.Windows8: - return IsOsWindows8OrGreater; - case OperatingSystemVersion.Windows7SP1: - return IsOsWindows7SP1OrGreater; - case OperatingSystemVersion.Windows7: - return IsOsWindows7OrGreater; - case OperatingSystemVersion.WindowsVistaSP2: - return IsOsWindowsVistaSP2OrGreater; - case OperatingSystemVersion.WindowsVistaSP1: - return IsOsWindowsVistaSP1OrGreater; - case OperatingSystemVersion.WindowsVista: - return IsOsWindowsVistaOrGreater; - case OperatingSystemVersion.WindowsXPSP3: - return IsOsWindowsXPSP3OrGreater; - case OperatingSystemVersion.WindowsXPSP2: - return IsOsWindowsXPSP2OrGreater; - } - - throw new ArgumentException($"{osVer} is not a valid OS!", nameof(osVer)); + OperatingSystemVersion.Windows10RS5 => IsOsWindows10RS5OrGreater, + OperatingSystemVersion.Windows10RS4 => IsOsWindows10RS4OrGreater, + OperatingSystemVersion.Windows10RS3 => IsOsWindows10RS3OrGreater, + OperatingSystemVersion.Windows10RS2 => IsOsWindows10RS2OrGreater, + OperatingSystemVersion.Windows10RS1 => IsOsWindows10RS1OrGreater, + OperatingSystemVersion.Windows10TH2 => IsOsWindows10TH2OrGreater, + OperatingSystemVersion.Windows10 => IsOsWindows10OrGreater, + OperatingSystemVersion.Windows8Point1 => IsOsWindows8Point1OrGreater, + OperatingSystemVersion.Windows8 => IsOsWindows8OrGreater, + OperatingSystemVersion.Windows7SP1 => IsOsWindows7SP1OrGreater, + OperatingSystemVersion.Windows7 => IsOsWindows7OrGreater, + OperatingSystemVersion.WindowsVistaSP2 => IsOsWindowsVistaSP2OrGreater, + OperatingSystemVersion.WindowsVistaSP1 => IsOsWindowsVistaSP1OrGreater, + OperatingSystemVersion.WindowsVista => IsOsWindowsVistaOrGreater, + OperatingSystemVersion.WindowsXPSP3 => IsOsWindowsXPSP3OrGreater, + OperatingSystemVersion.WindowsXPSP2 => IsOsWindowsXPSP2OrGreater, + _ => throw new ArgumentException($"{osVer} is not a valid OS!", nameof(osVer)), + }; } internal static OperatingSystemVersion GetOsVersion() From 193511f7276178df0754731f68be3b834154e9f4 Mon Sep 17 00:00:00 2001 From: halgab <24685886+halgab@users.noreply.github.com> Date: Sat, 30 Dec 2023 13:53:15 +0100 Subject: [PATCH 2/4] manual followups --- .../MS/internal/Ink/ErasingStroke.cs | 2 +- .../Stylus/Common/DynamicRendererThreadManager.cs | 6 ++---- .../Windows/Input/Stylus/Common/StylusButton.cs | 2 +- .../Windows/Input/Stylus/Common/StylusDevice.cs | 2 +- .../Windows/Input/Stylus/Common/TabletDeviceBase.cs | 2 +- .../Windows/Input/Stylus/Wisp/PenThreadWorker.cs | 10 +++++----- .../Windows/Input/Stylus/Wisp/WispStylusDevice.cs | 2 +- .../Windows/Input/Stylus/Wisp/WispTabletDevice.cs | 2 +- .../System/Windows/Media/Animation/KeySpline.cs | 7 +------ .../Windows/Media/Animation/KeySplineConverter.cs | 12 ++++-------- .../System/Windows/Media/ColorContext.cs | 2 +- .../PresentationCore/System/Windows/Media/Visual.cs | 4 +--- .../System/Windows/Media3D/Visual3D.cs | 4 +--- .../System/Windows/Media3D/Visual3DCollection.cs | 6 +----- .../PresentationCore/System/Windows/RoutedEvent.cs | 2 +- 15 files changed, 23 insertions(+), 42 deletions(-) diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/ErasingStroke.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/ErasingStroke.cs index a1b7e99f11b..544f43a73ea 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/ErasingStroke.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/ErasingStroke.cs @@ -79,7 +79,7 @@ internal void MoveTo(IEnumerable path) } #if POINTS_FILTER_TRACE _totalPointsAdded += path.Length; - System.Diagnostics.Debug.WriteLine(String.Format("Total Points added: {0} screened: {1} collinear screened: {2}", _totalPointsAdded, _totalPointsScreened, _collinearPointsScreened)); + System.Diagnostics.Debug.WriteLine($"Total Points added: {_totalPointsAdded} screened: {_totalPointsScreened} collinear screened: {_collinearPointsScreened}"); #endif } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Common/DynamicRendererThreadManager.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Common/DynamicRendererThreadManager.cs index 888e588e0ca..3813ee04ecf 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Common/DynamicRendererThreadManager.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Common/DynamicRendererThreadManager.cs @@ -256,11 +256,9 @@ void Dispose(bool disposing) } catch(System.ComponentModel.Win32Exception e) { - if (e.NativeErrorCode != 1400) // ERROR_INVALID_WINDOW_HANDLE - { + Debug.WriteLineIf(e.NativeErrorCode != 1400, // ERROR_INVALID_WINDOW_HANDLE // This is an unlocalized string but it only prints on the Debug Console - Debug.WriteLine(String.Format("Dispatcher.CriticalInvokeShutdown() Failed. Error={0}", e.NativeErrorCode)); - } + $"Dispatcher.CriticalInvokeShutdown() Failed. Error={e.NativeErrorCode}"); } finally { diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Common/StylusButton.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Common/StylusButton.cs index 61a408e535f..221dcc36cd3 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Common/StylusButton.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Common/StylusButton.cs @@ -100,7 +100,7 @@ internal void SetOwner(StylusDeviceBase stylusDevice) /// name of the tablet public override string ToString() { - return String.Format(CultureInfo.CurrentCulture, "{0}({1})", base.ToString(), this.Name); + return $"{base.ToString()}({this.Name})"; } ///////////////////////////////////////////////////////////////////// diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Common/StylusDevice.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Common/StylusDevice.cs index f2acbc8e905..c7d23839118 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Common/StylusDevice.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Common/StylusDevice.cs @@ -175,7 +175,7 @@ public string Name /// public override string ToString() { - return String.Format(CultureInfo.CurrentCulture, "{0}({1})", base.ToString(), this.Name); + return $"{base.ToString()}({this.Name})"; } /// diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Common/TabletDeviceBase.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Common/TabletDeviceBase.cs index 4e110653464..fb4d436e1ef 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Common/TabletDeviceBase.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Common/TabletDeviceBase.cs @@ -185,7 +185,7 @@ internal TabletDeviceType Type /// public override string ToString() { - return String.Format(CultureInfo.CurrentCulture, "{0}({1})", base.ToString(), Name); + return $"{base.ToString()}({this.Name})"; } /// diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Wisp/PenThreadWorker.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Wisp/PenThreadWorker.cs index fb1bcb3d2e8..5b010cdd92f 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Wisp/PenThreadWorker.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Wisp/PenThreadWorker.cs @@ -1160,7 +1160,7 @@ internal void ThreadProc() while (!__disposed) { #if TRACEPTW - Debug.WriteLine(String.Format("PenThreadWorker::ThreadProc(): Update __penContextWeakRefList loop")); + Debug.WriteLine("PenThreadWorker::ThreadProc(): Update __penContextWeakRefList loop"); #endif // We need to ensure that the PenIMC COM objects can be used from this thread. @@ -1195,7 +1195,7 @@ internal void ThreadProc() while (true) { #if TRACEPTW - Debug.WriteLine (String.Format("PenThreadWorker::ThreadProc - handle event loop")); + Debug.WriteLine("PenThreadWorker::ThreadProc - handle event loop"); #endif // get next event int evt; @@ -1229,9 +1229,9 @@ internal void ThreadProc() { // dispatch the event #if TRACEPTW - Debug.WriteLine (String.Format("PenThreadWorker::ThreadProc - FireEvent [evt={0}, stylusId={1}]", evt, stylusPointerId)); + Debug.WriteLine($"PenThreadWorker::ThreadProc - FireEvent [evt={evt}, stylusId={stylusPointerId}]"); #endif - + // This comment addresses and IndexOutOfRangeException in PenThreadWorker which is related and likely caused by the above. // This index is safe as long as there are no corruption issues within PenIMC. There have been // instances of IndexOutOfRangeExceptions from this code but this should not occur in practice. @@ -1248,7 +1248,7 @@ internal void ThreadProc() else { #if TRACEPTW - Debug.WriteLine (String.Format("PenThreadWorker::ThreadProc - FlushInput")); + Debug.WriteLine("PenThreadWorker::ThreadProc - FlushInput"); #endif FlushCache(true); diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Wisp/WispStylusDevice.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Wisp/WispStylusDevice.cs index d42a7aab25c..e8b8df9bd0b 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Wisp/WispStylusDevice.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Wisp/WispStylusDevice.cs @@ -1117,7 +1117,7 @@ internal override string Name /// public override string ToString() { - return String.Format(CultureInfo.CurrentCulture, "{0}({1})", base.ToString(), this.Name); + return $"{base.ToString()}({this.Name})"; } ///////////////////////////////////////////////////////////////////// diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Wisp/WispTabletDevice.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Wisp/WispTabletDevice.cs index 749549c5687..57e38b185f8 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Wisp/WispTabletDevice.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Wisp/WispTabletDevice.cs @@ -169,7 +169,7 @@ internal override PresentationSource ActiveSource /// public override string ToString() { - return String.Format(CultureInfo.CurrentCulture, "{0}({1})", base.ToString(), Name); + return $"{base.ToString()}({this.Name})"; } ///////////////////////////////////////////////////////////////////////// diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/KeySpline.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/KeySpline.cs index e3e0fa64294..2c412ef736a 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/KeySpline.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/KeySpline.cs @@ -491,12 +491,7 @@ internal string InternalConvertToString(string format, IFormatProvider formatPro // Helper to get the numeric list separator for a given culture. char separator = MS.Internal.TokenizerHelper.GetNumericListSeparator(formatProvider); - return String.Format( - formatProvider, - "{1}{0}{2}", - separator, - _controlPoint1, - _controlPoint2); + return string.Create(formatProvider, $"{_controlPoint1}{separator}{_controlPoint2}"); } #endregion diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/KeySplineConverter.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/KeySplineConverter.cs index 4f48bdcc0cd..92959c99b98 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/KeySplineConverter.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/KeySplineConverter.cs @@ -122,15 +122,11 @@ public override object ConvertTo( else if (destinationType == typeof(string)) { #pragma warning disable 56506 // Suppress presharp warning: Parameter 'cultureInfo.TextInfo' to this public method must be validated: A null-dereference can occur here. - return String.Format( - cultureInfo, - "{0}{4}{1}{4}{2}{4}{3}", - keySpline.ControlPoint1.X, - keySpline.ControlPoint1.Y, - keySpline.ControlPoint2.X, - keySpline.ControlPoint2.Y, - cultureInfo != null ? cultureInfo.TextInfo.ListSeparator : CultureInfo.InvariantCulture.TextInfo.ListSeparator); + string separator = cultureInfo != null ? cultureInfo.TextInfo.ListSeparator : CultureInfo.InvariantCulture.TextInfo.ListSeparator; #pragma warning restore 56506 + return string.Create( + cultureInfo, + $"{keySpline.ControlPoint1.X}{separator}{keySpline.ControlPoint1.Y}{separator}{keySpline.ControlPoint2.X}{separator}{keySpline.ControlPoint2.Y}"); } } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/ColorContext.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/ColorContext.cs index baa632cba8c..0e52a7ecce6 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/ColorContext.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/ColorContext.cs @@ -149,7 +149,7 @@ private ColorContext(SafeMILHandle colorContextHandle) } else if (Invariant.Strict) { - Invariant.Assert(false, String.Format(CultureInfo.InvariantCulture, "IWICColorContext::GetExifColorSpace returned {0}.", colorSpace)); + Invariant.Assert(false, string.Create(CultureInfo.InvariantCulture, $"IWICColorContext::GetExifColorSpace returned {colorSpace}.")); } break; diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Visual.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Visual.cs index ca326b86ce6..7072467e6b8 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Visual.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Visual.cs @@ -2002,9 +2002,7 @@ internal void HitTest( { // This should never happen, users can not extend the abstract HitTestParameters class. Invariant.Assert(false, - String.Format(System.Globalization.CultureInfo.InvariantCulture, - "'{0}' HitTestParameters are not supported on {1}.", - hitTestParameters.GetType().Name, this.GetType().Name)); + $"'{hitTestParameters.GetType().Name}' HitTestParameters are not supported on {this.GetType().Name}."); } } } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media3D/Visual3D.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media3D/Visual3D.cs index 0e64db85e0a..2bec6f036e8 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media3D/Visual3D.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media3D/Visual3D.cs @@ -662,9 +662,7 @@ internal void HitTest( { // This should never happen, users can not extend the abstract HitTestParameters3D class. Invariant.Assert(false, - String.Format(System.Globalization.CultureInfo.InvariantCulture, - "'{0}' HitTestParameters3D are not supported on {1}.", - hitTestParameters.GetType().Name, this.GetType().Name)); + $"'{hitTestParameters.GetType().Name}' HitTestParameters3D are not supported on {this.GetType().Name}."); } } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media3D/Visual3DCollection.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media3D/Visual3DCollection.cs index 4ea1abdd52a..0224bcb2be9 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media3D/Visual3DCollection.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media3D/Visual3DCollection.cs @@ -564,11 +564,7 @@ private void Debug_ICC() Debug.Assert(visual.InternalVisualParent == _owner, "Why isn't our child's parent pointer the same as the collection owner?"); Debug.Assert(visual.ParentIndex == i, - String.Format( - CultureInfo.InvariantCulture, - "Child's ParentIndex does not match the child's actual position in the collection. Expected='{0}' Actual='{1}'", - i, - visual.ParentIndex)); + $"Child's ParentIndex does not match the child's actual position in the collection. Expected='{i}' Actual='{visual.ParentIndex}'"); // If the Visual3D is being added to the collection via a resource reference // its inheritance context will be the owner of the ResourceDictionary in which diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/RoutedEvent.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/RoutedEvent.cs index 400618f7632..ec5bc73fffe 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/RoutedEvent.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/RoutedEvent.cs @@ -109,7 +109,7 @@ public Type OwnerType /// public override string ToString() { - return string.Format(CultureInfo.InvariantCulture, "{0}.{1}", _ownerType.Name, _name ); + return string.Create(CultureInfo.InvariantCulture, $"{_ownerType.Name}.{_name}"); } #endregion External API From 4ea763103e02b739c4990762a927be7052f4e2f0 Mon Sep 17 00:00:00 2001 From: halgab <24685886+halgab@users.noreply.github.com> Date: Sat, 30 Dec 2023 14:16:08 +0100 Subject: [PATCH 3/4] StringBuilder.AppendFormat refactos --- .../PresentationCore/System/Windows/Media/Color.cs | 11 +++-------- .../System/Windows/Media/FamilyMap.cs | 10 +++++++--- .../System/Windows/Media/GlyphsSerializer.cs | 8 ++++---- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Color.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Color.cs index 96967556977..3e3e33a152f 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Color.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Color.cs @@ -303,15 +303,10 @@ internal string ConvertToString(string format, IFormatProvider provider) String uriString = safeUnescapedUri.GetComponents(UriComponents.SerializationInfoString, UriFormat.UriEscaped); var sb = new StringBuilder(); - sb.AppendFormat(provider, "{0}{1} ", Parsers.s_ContextColor, uriString); - sb.AppendFormat(provider,"{1:" + format + "}{0}",separator,scRgbColor.a); - for (int i= 0; i< nativeColorValue.GetLength(0); ++i ) + sb.Append(provider, $"{Parsers.s_ContextColor}{uriString}{scRgbColor.a:R}"); + for (int i= 0; i< nativeColorValue.Length; ++i ) { - sb.AppendFormat(provider,"{0:" + format + "}",nativeColorValue[i]); - if (i< nativeColorValue.GetLength(0)-1 ) - { - sb.AppendFormat(provider,"{0}",separator); - } + sb.Append(provider, $"{separator}{nativeColorValue[i]:R}"); } return sb.ToString(); } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/FamilyMap.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/FamilyMap.cs index 0111f3f1250..70261e03729 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/FamilyMap.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/FamilyMap.cs @@ -107,15 +107,19 @@ public string Unicode get { + if (_ranges.Length == 0) + { + return string.Empty; + } + System.Text.StringBuilder sb = new System.Text.StringBuilder(); for (int i = 0; i < _ranges.Length; ++i) { - if (i != 0) sb.Append(','); - sb.AppendFormat(NumberFormatInfo.InvariantInfo, "{0:x4}-{1:x4}", _ranges[i].First, _ranges[i].Last); + sb.Append(NumberFormatInfo.InvariantInfo, $"{_ranges[i].First:x4}-{_ranges[i].Last:x4},"); } - return sb.ToString(); + return sb.ToString(0, sb.Length - 1); } } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/GlyphsSerializer.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/GlyphsSerializer.cs index 9575b42daa3..a059c07a4ad 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/GlyphsSerializer.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/GlyphsSerializer.cs @@ -253,12 +253,12 @@ private void AddCluster(int glyphClusterStart, int glyphClusterEnd, int charClus // the format is ... [(CharacterClusterSize[:GlyphClusterSize])] GlyphIndex ... if (glyphsInCluster != 1) { - _indicesStringBuider.AppendFormat(CultureInfo.InvariantCulture, "({0}:{1})", charactersInCluster, glyphsInCluster); + _indicesStringBuider.Append(CultureInfo.InvariantCulture, $"({charactersInCluster}:{glyphsInCluster})"); } else { if (charactersInCluster != 1) - _indicesStringBuider.AppendFormat(CultureInfo.InvariantCulture, "({0})", charactersInCluster); + _indicesStringBuider.Append(CultureInfo.InvariantCulture, $"({charactersInCluster})"); else { // 1:1 cluster, we can omit (n:m) specification and possibly deduce some @@ -315,13 +315,13 @@ private string CreateCaretStopsString() mask >>= 1; else { - sb.AppendFormat("{0:x1}", accumulatedValue); + sb.Append($"{accumulatedValue:x1}"); accumulatedValue = 0; mask = 0x8; } } if (mask != 0x8) - sb.AppendFormat("{0:x1}", accumulatedValue); + sb.Append($"{accumulatedValue:x1}"); Debug.Assert(caretStopStringLength == sb.ToString().Length); From e7de550cdabcb7720155ed2006a9ec161af9194c Mon Sep 17 00:00:00 2001 From: halgab <24685886+halgab@users.noreply.github.com> Date: Wed, 31 Jan 2024 22:19:19 +0100 Subject: [PATCH 4/4] fix Media.Color --- .../PresentationCore/System/Windows/Media/Color.cs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Color.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Color.cs index 3e3e33a152f..775e49fac14 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Color.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Color.cs @@ -265,8 +265,8 @@ string IFormattable.ToString(string format, IFormatProvider provider) } /// - /// Creates a string representation of this object based on the format string - /// and IFormatProvider passed in. + /// Creates a string representation of this object based on the format string + /// and IFormatProvider passed in. /// If the provider is null, the CurrentCulture is used. /// See the documentation for IFormattable for more information. /// @@ -303,10 +303,14 @@ internal string ConvertToString(string format, IFormatProvider provider) String uriString = safeUnescapedUri.GetComponents(UriComponents.SerializationInfoString, UriFormat.UriEscaped); var sb = new StringBuilder(); - sb.Append(provider, $"{Parsers.s_ContextColor}{uriString}{scRgbColor.a:R}"); + sb.Append(provider, $"{Parsers.s_ContextColor}{uriString} {scRgbColor.a:R}{separator}"); for (int i= 0; i< nativeColorValue.Length; ++i ) { - sb.Append(provider, $"{separator}{nativeColorValue[i]:R}"); + sb.Append(provider, $"{nativeColorValue[i]:R}"); + if (i< nativeColorValue.GetLength(0)-1 ) + { + sb.Append(provider, $"{separator}"); + } } return sb.ToString(); } @@ -413,7 +417,7 @@ public float[] GetNativeColorValues() { Color c1 = new Color(); c1.context = color1.context; - + #pragma warning suppress 6506 // c1.context is obviously not null - both color1.context AND color2.context are not null c1.nativeColorValue = new float[c1.context.NumChannels]; for (int i = 0; i < c1.nativeColorValue.GetLength(0); i++)