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 a8de3ef10d1..025776b621f 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 @@ -44,9 +44,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; @@ -179,9 +177,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 ce9d5072428..b62c3beb081 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 @@ -48,9 +48,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); } @@ -60,9 +58,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); @@ -88,9 +84,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; } @@ -104,9 +98,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; @@ -118,9 +110,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] == '/'); @@ -131,9 +121,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 @@ -157,9 +145,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) { @@ -181,9 +167,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) @@ -191,9 +175,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 4561b2ab1cd..410cb1eee9a 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 @@ -300,7 +300,7 @@ internal static string CompositeFontExtension static Util() { - string s = Environment.GetEnvironmentVariable(WinDir) + @"\Fonts\"; + string s = $@"{Environment.GetEnvironmentVariable(WinDir)}\Fonts\"; _windowsFontsLocalPath = s.ToUpperInvariant(); @@ -516,7 +516,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) @@ -640,7 +640,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) { @@ -680,11 +680,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 05449b5fe04..010ebf39098 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 @@ -92,7 +92,7 @@ private void SetFontSources() { if (_tryGetCompositeFontsOnly) { - files = Directory.GetFiles(_uri.LocalPath, "*" + Util.CompositeFontExtension); + files = Directory.GetFiles(_uri.LocalPath, $"*{Util.CompositeFontExtension}"); isOnlyCompositeFontFiles = true; } else 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 44305e9102b..2caaf9ac9ed 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 @@ -342,7 +342,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/ErasingStroke.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/ErasingStroke.cs index 701f29260fc..01a92060cbe 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 @@ -76,7 +76,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/MS/internal/Ink/ExtendedProperty.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/ExtendedProperty.cs index 1fed771f814..af41ccb7912 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 @@ -120,13 +120,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 21f8dad3361..ae33e562c53 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 @@ -768,7 +768,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 02a3d32f626..dceb48e2f2c 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 @@ -344,7 +344,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; @@ -362,7 +362,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: @@ -556,7 +556,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; @@ -731,7 +731,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; @@ -775,7 +775,7 @@ private void DecodeRawISF(Stream inputStream) break; } } - ISFDebugTrace(" Size = " + bytesDecodedInCurrentTag.ToString()); + ISFDebugTrace($" Size = {bytesDecodedInCurrentTag}"); if (bytesDecodedInCurrentTag > remainingBytesInStream) { throw new ArgumentException(ISFDebugMessage("Invalid ISF data")); @@ -1735,7 +1735,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")); @@ -1754,7 +1754,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")); @@ -1767,7 +1767,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")); @@ -1780,7 +1780,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")); @@ -1789,7 +1789,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")); @@ -1798,7 +1798,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")); @@ -1807,7 +1807,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")); @@ -1818,7 +1818,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")); } @@ -1828,13 +1828,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; @@ -1847,7 +1847,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) { @@ -1879,7 +1879,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) @@ -1890,7 +1890,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")); } @@ -1904,7 +1904,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")); } @@ -1918,7 +1918,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")); } @@ -1932,7 +1932,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")); } @@ -1955,7 +1955,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); @@ -1966,7 +1966,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")); } @@ -2025,7 +2025,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 8f404d8ecc9..d72526fd992 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 @@ -74,9 +74,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 c64e1877913..3d13f2b74fa 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 @@ -69,7 +69,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 ec517b2cda8..9eb4de7fbe5 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 @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. @@ -90,10 +90,10 @@ 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 aae40dfad90..e70caca5a5f 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 @@ -18,7 +18,7 @@ internal static class VisualTreeUtils // Constructors // //------------------------------------------------------ - + //------------------------------------------------------ // // Public Methods @@ -30,7 +30,7 @@ internal static class VisualTreeUtils // Public Properties // //------------------------------------------------------ - + //------------------------------------------------------ // // Public Events @@ -41,7 +41,7 @@ internal static class VisualTreeUtils // // Internal Methods // - //------------------------------------------------------ + //------------------------------------------------------ #region Internal Methods @@ -50,13 +50,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) @@ -78,7 +78,7 @@ internal static void SetFlagsToRoot(DependencyObject element, bool value, Visual { Visual visual; Visual3D visual3D; - + AsVisualInternal(element, out visual, out visual3D); if (visual != null) @@ -99,7 +99,7 @@ internal static DependencyObject FindFirstAncestorWithFlagsAnd(DependencyObject { Visual visual; Visual3D visual3D; - + AsVisualInternal(element, out visual, out visual3D); if (visual != null) @@ -128,7 +128,7 @@ internal static PointHitTestResult AsNearestPointHitTestResult(HitTestResult res { return null; } - + PointHitTestResult resultAsPointHitTestResult = result as PointHitTestResult; if (resultAsPointHitTestResult != null) @@ -166,7 +166,7 @@ internal static PointHitTestResult AsNearestPointHitTestResult(HitTestResult res { Point4D worldPoint = ((Point4D)resultAsRayHitTestResult.PointHit) * worldTransform; Point viewportPoint = viewport.WorldToViewport(worldPoint); - + return new PointHitTestResult(viewport, viewportPoint); } @@ -175,7 +175,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; } @@ -220,7 +220,7 @@ private static void EnsureVisual(DependencyObject element, bool allowNull) throw new ArgumentException(SR.Visual_NotAVisual); } - element.VerifyAccess(); + element.VerifyAccess(); } /// @@ -236,7 +236,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. @@ -286,28 +286,28 @@ internal static bool AsVisualInternal(DependencyObject element, out Visual visua 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. @@ -329,14 +329,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 2803af84c3b..39838a2069f 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/MediaTrace.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/MediaTrace.cs @@ -78,7 +78,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}"); } } @@ -95,7 +95,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(); @@ -121,7 +121,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 243ee4cef22..ea0b48a708f 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 @@ -78,7 +78,7 @@ TextFormattingMode textFormattingMode ) { SpanVector cachedScaledTypefaceIndexSpans; - + int ichItem = 0; CharacterBufferRange unicodeString = new CharacterBufferRange( @@ -88,15 +88,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. @@ -106,7 +106,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(), @@ -129,7 +129,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( @@ -415,10 +415,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}" ) ); } @@ -484,7 +483,7 @@ private int MapByFontFamily( IFontFamily fontFamily, CanonicalFontFamilyReference canonicalFamilyReference, FontStyle canonicalStyle, - FontWeight canonicalWeight, + FontWeight canonicalWeight, FontStretch canonicalStretch, ref PhysicalFontFamily firstValidFamily, ref int firstValidLength, @@ -911,7 +910,7 @@ out int nextValid targetFamily, canonicalFamilyReference, canonicalStyle, - canonicalWeight, + canonicalWeight, canonicalStretch, ref firstValidFamily, ref firstValidLength, @@ -1035,7 +1034,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 f111c3844ac..2832c79941d 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 @@ -709,8 +709,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; } @@ -845,9 +844,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) { @@ -890,9 +887,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) { @@ -935,14 +930,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) @@ -1040,9 +1031,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) { @@ -1079,9 +1068,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) || @@ -1112,9 +1099,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) { @@ -1130,9 +1115,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) { @@ -1143,9 +1126,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) { @@ -1157,14 +1138,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; @@ -1173,18 +1150,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) { @@ -1200,25 +1173,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; @@ -1265,9 +1230,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) { @@ -1279,14 +1242,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) @@ -1316,9 +1275,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) { @@ -1343,9 +1300,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) @@ -1388,9 +1343,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) { @@ -1424,9 +1377,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) @@ -1566,9 +1517,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) { @@ -2457,8 +2406,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 248443c3dc4..e00b9e5e167 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 @@ -60,7 +60,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) { @@ -79,12 +79,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 //------------------------------------------------------ // @@ -110,7 +108,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)) { @@ -145,15 +143,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); } @@ -167,9 +163,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); @@ -427,7 +421,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. @@ -478,7 +472,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) { @@ -517,7 +511,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. @@ -573,7 +567,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 0a7f375bf3d..6a6d77daec0 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 @@ -63,9 +63,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 @@ -102,9 +100,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, @@ -115,9 +111,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 0fc219ed398..e1407f50dea 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 @@ -65,9 +65,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 @@ -88,9 +86,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); } @@ -98,9 +94,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 @@ -132,9 +126,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; @@ -171,9 +163,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) @@ -193,9 +183,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 @@ -483,9 +471,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) @@ -504,9 +490,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(); } @@ -517,9 +501,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(); @@ -540,9 +522,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 @@ -599,9 +579,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) @@ -616,18 +594,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); @@ -643,9 +617,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); @@ -656,9 +628,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; } @@ -667,9 +637,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 @@ -767,9 +735,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. @@ -789,9 +755,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; @@ -804,9 +768,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 @@ -833,9 +795,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(); @@ -875,9 +835,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 @@ -890,9 +848,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 50952c9d45c..f5c735f8b32 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 @@ -377,7 +377,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 2a385b305ee..bb1f6faff44 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/FreezableCollection.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/FreezableCollection.cs @@ -1076,7 +1076,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 edd4aabb12e..7d81b34c517 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 @@ -842,7 +842,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 275d3836feb..ddeae0f3dc4 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 @@ -178,7 +178,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; } @@ -186,7 +186,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/InputBinding.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Command/InputBinding.cs index 131c334033f..3fe7c72a97f 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 @@ -60,7 +60,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 62b408cb05f..894f415e868 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 @@ -11,8 +11,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 37de27289ef..f25c853a758 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 @@ -14,7 +14,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/InputScope.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/InputScope.cs index 4efe8dd7e7f..02ca683e4c6 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 @@ -18,7 +18,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 { /// @@ -101,7 +101,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/DynamicRendererThreadManager.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Common/DynamicRendererThreadManager.cs index 02fc79e0f9b..e1b352cefa5 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 @@ -246,11 +246,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 74b40cfcb21..0b1045a0589 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 @@ -99,7 +99,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 d22d73ada58..c72d58f37e2 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 @@ -161,7 +161,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/StylusLogic.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Common/StylusLogic.cs index 1883308f46c..f47064f5125 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 @@ -67,7 +67,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 @@ -77,12 +77,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 @@ -116,7 +116,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 eda2b3ebf0e..8954b6f4685 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 @@ -90,11 +90,8 @@ 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/Input/Stylus/Common/TabletDeviceBase.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Stylus/Common/TabletDeviceBase.cs index b290f8792cf..5107bcfcfe4 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 @@ -178,7 +178,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 f1b6809428c..152310af2db 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 @@ -1151,7 +1151,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. @@ -1186,7 +1186,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; @@ -1220,9 +1220,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. @@ -1239,7 +1239,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 8f55d21bd5c..fa17229ad91 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 @@ -1086,7 +1086,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 625caae6991..b331f794f40 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 @@ -160,7 +160,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/InterOp/HwndMouseInputProvider.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/InterOp/HwndMouseInputProvider.cs index fadcb8b976f..b15f8727206 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 @@ -1470,7 +1470,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 dd5e64b73a5..b2fefa9ed6b 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 @@ -841,7 +841,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/Animation/KeySpline.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/KeySpline.cs index fce1f5690be..15cd6ab39eb 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 @@ -480,12 +480,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 be117f76ec7..fa9c363dd9e 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 @@ -112,14 +112,13 @@ public override object ConvertTo( } else if (destinationType == typeof(string)) { - return String.Format( +#pragma warning disable 56506 // Suppress presharp warning: Parameter 'cultureInfo.TextInfo' to this public method must be validated: A null-dereference can occur here. + string separator = cultureInfo != null ? cultureInfo.TextInfo.ListSeparator : CultureInfo.InvariantCulture.TextInfo.ListSeparator; +#pragma warning restore 56506 + return string.Create( 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); + $"{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/Color.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Color.cs index 041612c399f..8d0026cb6cc 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 @@ -256,8 +256,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. /// @@ -294,14 +294,13 @@ 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.Length; ++i ) + sb.Append(provider, $"{Parsers.s_ContextColor}{uriString} {scRgbColor.a:R}{separator}"); + for (int i= 0; i< nativeColorValue.Length; ++i ) { - sb.AppendFormat(provider,"{0:" + format + "}",nativeColorValue[i]); - if (i < nativeColorValue.Length - 1) + sb.AppendFormat(provider, $"{{0:{format}}}", nativeColorValue[i]); + if (i< nativeColorValue.GetLength(0)-1 ) { - sb.AppendFormat(provider,"{0}",separator); + sb.Append(provider, $"{separator}"); } } return sb.ToString(); 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 ccd2752963a..25ab6edfc2e 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 @@ -133,7 +133,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/Effects/Generated/BitmapEffectCollection.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Effects/Generated/BitmapEffectCollection.cs index 540dd402579..d9994b1d434 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 @@ -844,7 +844,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/FamilyMap.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/FamilyMap.cs index 7d8b136c442..2e1497b9143 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 @@ -89,15 +89,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/Fonts.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Fonts.cs index 420fa96b8c9..754f5bd9946 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 @@ -106,7 +106,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 8fd4cb6a41b..8cd7482be11 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 @@ -869,7 +869,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 a25ee61bc63..6eb4bc0b93a 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 @@ -886,7 +886,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 eb320f3714d..fbecd30d400 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 @@ -851,7 +851,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 de0324b2574..76df67251ba 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 @@ -886,7 +886,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 325d4c78491..ce07ddd6553 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 @@ -954,7 +954,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 188d9ccd47f..7592df009c8 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 @@ -869,7 +869,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 7394e0809fd..945ce9a6c16 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 @@ -941,7 +941,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 5a231e33ea6..d83f945cf6f 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 @@ -851,7 +851,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 39894b76238..94f8da2ac33 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 @@ -871,7 +871,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 1ff30664f0f..30bb309ac80 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 @@ -851,7 +851,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 95bbd3ebc57..b416d972953 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 @@ -886,7 +886,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 17ed80e1896..f3f889c6a1c 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 @@ -871,7 +871,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/GlyphsSerializer.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/GlyphsSerializer.cs index 72b4622cceb..2cc641b0c6e 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 @@ -234,12 +234,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 @@ -296,13 +296,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); 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 1c8ed6b0a6a..1678a04f3f2 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 @@ -174,7 +174,7 @@ static KnownColors() KnownColor[] knownColorValues = Enum.GetValues(); 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 941fbdeb8e0..9c942a2c4dc 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 @@ -84,7 +84,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 92804df102f..b597f443caf 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 @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. @@ -204,10 +204,9 @@ 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 5df8bbf0674..a11aeb472b7 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 @@ -925,7 +925,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 4000415913a..01cc4216528 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 @@ -22,7 +22,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 38113b0c84b..81405a41185 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 @@ -22,7 +22,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 0da40cf4385..97af3c8826d 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 @@ -22,7 +22,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/Media/Visual.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Visual.cs index 041d137c233..dd9bd4a9a09 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 @@ -1983,9 +1983,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/Generated/GeneralTransform3DCollection.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media3D/Generated/GeneralTransform3DCollection.cs index 98e114c231a..c2c073c15ab 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 @@ -849,7 +849,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 c90c480b566..327e8eab95f 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 @@ -884,7 +884,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 aa0ba43dcb2..3afe282be36 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 @@ -884,7 +884,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 ff650f2854c..de535e590bf 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 @@ -870,7 +870,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 0083f05eeb0..da0ae42ed8a 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 @@ -884,7 +884,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 c1e98e567e8..35c1feb9c09 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 @@ -870,7 +870,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 9f10ce3a31f..e7bd6ae1dfe 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 @@ -410,7 +410,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/Media3D/Visual3D.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media3D/Visual3D.cs index fe698077f8e..2099866f857 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 @@ -5,6 +5,7 @@ using MS.Internal; using MS.Internal.Media; using MS.Internal.Media3D; +using System.Globalization; using System.Windows.Diagnostics; using System.Windows.Media.Composition; @@ -653,9 +654,8 @@ 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)); + string.Create(CultureInfo.InvariantCulture, + $"'{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 1e0a5049c32..c0036e6dacd 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 @@ -549,11 +549,8 @@ 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)); + string.Create(CultureInfo.InvariantCulture, + $"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 19d586b70c2..09fc3cb8aef 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/RoutedEvent.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/RoutedEvent.cs @@ -24,8 +24,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 @@ -108,7 +108,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 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 5db8b97629b..0e659414450 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 @@ -210,43 +210,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() diff --git a/src/Microsoft.DotNet.Wpf/src/WpfGfx/codegen/mcg/helpers/CollectionHelper.cs b/src/Microsoft.DotNet.Wpf/src/WpfGfx/codegen/mcg/helpers/CollectionHelper.cs index ee6641eabea..44173c77ad6 100644 --- a/src/Microsoft.DotNet.Wpf/src/WpfGfx/codegen/mcg/helpers/CollectionHelper.cs +++ b/src/Microsoft.DotNet.Wpf/src/WpfGfx/codegen/mcg/helpers/CollectionHelper.cs @@ -770,7 +770,7 @@ public [[type]] 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); } }