diff --git a/src/Microsoft.DotNet.Wpf/src/Common/src/System/IO/Compression/DeflateZLib/ZLibNative.cs b/src/Microsoft.DotNet.Wpf/src/Common/src/System/IO/Compression/DeflateZLib/ZLibNative.cs index 5c73688e384..571f5aa28ac 100644 --- a/src/Microsoft.DotNet.Wpf/src/Common/src/System/IO/Compression/DeflateZLib/ZLibNative.cs +++ b/src/Microsoft.DotNet.Wpf/src/Common/src/System/IO/Compression/DeflateZLib/ZLibNative.cs @@ -243,7 +243,7 @@ private void EnsureNotDisposed() private void EnsureState(State requiredState) { if (InitializationState != requiredState) - throw new InvalidOperationException("InitializationState != " + requiredState.ToString()); + throw new InvalidOperationException($"InitializationState != {requiredState}"); } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/Application/DocumentStream.cs b/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/Application/DocumentStream.cs index 97d9462147b..7c5575f11af 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/Application/DocumentStream.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/Application/DocumentStream.cs @@ -28,13 +28,13 @@ namespace MS.Internal.Documents.Application /// Responsibility: /// The class must hide the location and implemenation complexity of /// performing simple logical operations needed by the system. -/// +/// /// Design Comments: /// The need for this is primarly driven from two factors: -/// +/// /// - Package which does not allow use to discard changes -/// -/// - RightsManagement where key changes make it impossible to edit a +/// +/// - RightsManagement where key changes make it impossible to edit a /// document in place /// internal sealed class DocumentStream : StreamProxy, IDisposable @@ -155,7 +155,7 @@ internal DocumentStream Copy(CriticalFileToken copiesToken) } } // Since we have already closed the original file, we need to reopen it if we - // fail to copy the file or open the new file. After doing so, we rethrow the + // fail to copy the file or open the new file. After doing so, we rethrow the // original exception so it can be handled at a higher level. #pragma warning suppress 56500 // suppress PreSharp Warning 56500: Avoid `swallowing errors by catching non-specific exceptions.. catch @@ -220,7 +220,7 @@ internal DocumentStream Copy(CriticalFileToken copiesToken) /// /// We prefer to create the temporary file in the same location as the /// source to inherit the folders attributes and security. - /// + /// /// If we can not we will use a system generated file. /// /// When true we will copy the source file if @@ -262,7 +262,7 @@ internal DocumentStream CreateTemporary(bool copyOriginal) // Copy Data if (copyOriginal) { - // We use a native File.Copy if possible because this is + // We use a native File.Copy if possible because this is // most performant. This is only possible if the source is file // based. if (isFileSource) @@ -499,9 +499,9 @@ internal bool ReOpenWriteable() /// False if the operation failed. /// /// This method is inplace to work around issues with re-publishing - /// XpsDocuments into the same file. The intended use for the method is + /// XpsDocuments into the same file. The intended use for the method is /// to logically allow in place editing for the user. - /// + /// /// After use this object is unusable and should be disposed as the /// temporary file is gone; it has become the original. In the event of an /// error while swapping the file, the file no longer becomes the original, @@ -588,7 +588,7 @@ internal bool SwapWithOriginal() #pragma warning suppress 56500 // suppress PreSharp Warning 56500: Avoid `swallowing errors by catching non-specific exceptions.. catch { - // TODO: 1603621 back out changes in case of failure + // TODO: 1603621 back out changes in case of failure Trace.SafeWrite( Trace.File, "File attributes or permissions could not be set."); @@ -666,7 +666,7 @@ internal bool DeleteOnClose void IDisposable.Dispose() { Dispose(true); - GC.SuppressFinalize(this); + GC.SuppressFinalize(this); } @@ -735,7 +735,7 @@ protected override void Dispose(bool disposing) /// The stream for the temporary file. /// The file token for the temporary file. private void MakeTempFile( - bool inSameFolder, + bool inSameFolder, out FileStream temporary, out CriticalFileToken tempToken) { @@ -803,8 +803,10 @@ private void MakeTempFile( #if DEBUG Invariant.Assert( ((i != 3) || (temporary != null) || (inSameFolder)), - "Unable to create a temp file.\n" - + "Unless IE Cache is read-only we have a defect."); + """ + Unable to create a temp file. + Unless IE Cache is read-only we have a defect. + """); #endif } } @@ -842,19 +844,19 @@ private Uri MakeTemporaryFileName(bool inSameFolder, int generation) /// /// Design is simple Source needs to be moved to Target ensuring /// no data loss on errror. - /// + /// /// If Source exists rename it (creating Backup) /// Move Source to Target /// If error occurs Move Backup to Source (resore from Backup) /// If all was good (delete Backup) - /// + /// /// This design incures trival I/O costs by using moves. /// private void RobustFileMove() { string sourceFile = _xpsFileToken.Location.LocalPath; string targetFile = _original._xpsFileToken.Location.LocalPath; - string backupFile = targetFile + ".bak"; + string backupFile = $"{targetFile}.bak"; bool backupExists = false; FileAttributes targetAttributes = FileAttributes.Normal; @@ -881,7 +883,7 @@ private void RobustFileMove() // Save the original file attributes so we can restore them if // the temp file copy fails. targetAttributes = File.GetAttributes(targetFile); - File.Move(targetFile, backupFile); + File.Move(targetFile, backupFile); Trace.SafeWrite( Trace.File, @@ -903,7 +905,7 @@ private void RobustFileMove() Trace.File, "Moved(Saved) {0} as {1}.", sourceFile, - targetFile); + targetFile); } catch { @@ -913,7 +915,7 @@ private void RobustFileMove() if (backupExists) { // restore original on failure - File.Move(backupFile, targetFile); + File.Move(backupFile, targetFile); Trace.SafeWrite( Trace.File, "Restored {0} from {1}, due to exception.", @@ -930,8 +932,8 @@ private void RobustFileMove() { // Try to delete the backup file if (backupExists) - { - File.Delete(backupFile); + { + File.Delete(backupFile); backupExists = false; Trace.SafeWrite( Trace.File, @@ -948,7 +950,7 @@ private void RobustFileMove() "Unable to remove backup {0}.\n{1}", backupFile, e); - } + } } /// diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/Application/FilePresentation.cs b/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/Application/FilePresentation.cs index 26411c56128..56155c86728 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/Application/FilePresentation.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/Application/FilePresentation.cs @@ -38,7 +38,7 @@ internal static bool ShowSaveFileDialog(ref CriticalFileToken fileToken) string extension = SR.FileManagementSaveExt; Trace.SafeWrite(Trace.File, "Showing SafeFileDialog."); - + bool result = false; SaveFileDialog save = new SaveFileDialog(); @@ -85,10 +85,10 @@ internal static bool ShowSaveFileDialog(ref CriticalFileToken fileToken) // gets up to homework.386, then the dialog would just pass it through as // is, requiring us to append the extension here. if (!extension.Equals( - Path.GetExtension(filePath), + Path.GetExtension(filePath), StringComparison.OrdinalIgnoreCase)) { - filePath = filePath + extension; + filePath += extension; } Uri file = new Uri(filePath); diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/RightsManagementResourceHelper.cs b/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/RightsManagementResourceHelper.cs index cd230e316dd..52de97e2a2f 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/RightsManagementResourceHelper.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/RightsManagementResourceHelper.cs @@ -45,7 +45,7 @@ private RightsManagementResourceHelper() internal static DocumentStatusResources GetDocumentLevelResources(RightsManagementStatus status) { DocumentStatusResources docStatusResources = new DocumentStatusResources(); - + // Set appropriate Text and ToolTip values. switch (status) { @@ -79,7 +79,7 @@ internal static string GetCredentialManagementResources(RightsManagementUser use case (AuthenticationType.Windows): accountName = String.Format( CultureInfo.CurrentCulture, - SR.RMCredManagementWindowsAccount, + SR.RMCredManagementWindowsAccount, user.Name); break; case (AuthenticationType.Passport): @@ -137,9 +137,7 @@ private static DrawingBrush GetDrawingBrushFromStatus(RightsManagementStatus sta if (_brushResources[index] == null) { // Determine resource name. - string resourceName = "PUIRMStatus" - + Enum.GetName(typeof(RightsManagementStatus), status) - + "BrushKey"; + string resourceName = $"PUIRMStatus{Enum.GetName(status)}BrushKey"; // Acquire reference to the brush. object resource = _frameworkElement.FindResource( diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/SignatureResourceHelper.cs b/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/SignatureResourceHelper.cs index 7be3b565536..18053631ffc 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/SignatureResourceHelper.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/SignatureResourceHelper.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -// Description: +// Description: // SignatureResourceHelper is a helper class used to get resources. using System; using System.Collections; @@ -53,7 +53,7 @@ internal static DocumentStatusResources GetDocumentLevelResources( case SignatureStatus.NotSigned: docSigStatusResources.Text = String.Empty; docSigStatusResources.ToolTip = SR.DocumentSignatureManagerDefaultToolTip; - break; + break; default: // SignatureStatus.Unknown or SignatureStatus.Undetermined // In this case signatures have been applied to the document, but // the validity of the signatures is not yet known. @@ -72,7 +72,7 @@ internal static DocumentStatusResources GetDocumentLevelResources( /// /// Requested signature status /// Requested certificate status - /// A Image on success (valid status, DrawingBrush found), null + /// A Image on success (valid status, DrawingBrush found), null /// otherwise. internal static Drawing.Image GetImageFromStatus( int height, @@ -108,9 +108,9 @@ internal static SignatureResources GetResources(DigitalSignature signature, Cert resources._displayImage = GetImageFromStatus( defaultHeight, defaultWidth, signature.SignatureState, certStatus); - resources._location = + resources._location = string.IsNullOrEmpty(signature.Location) ? none : signature.Location; - resources._reason = + resources._reason = string.IsNullOrEmpty(signature.Reason) ? none : signature.Reason; resources._signBy = GetFormattedDate(signature.SignedOn); resources._subjectName = signature.SubjectName; @@ -131,7 +131,7 @@ internal static SignatureResources GetResources(DigitalSignature signature, Cert /// Get the DrawingBrush icon for the status. /// /// Requested status - /// A DrawingBrush on success (valid status, DrawingBrush found), null + /// A DrawingBrush on success (valid status, DrawingBrush found), null /// otherwise. private static DrawingBrush GetDrawingBrushFromStatus(SignatureStatus sigStatus) { @@ -159,9 +159,7 @@ private static DrawingBrush GetDrawingBrushFromStatus(SignatureStatus sigStatus) if (_brushResources[index] == null) { // Determine resource name. - string resourceName = "PUISignatureStatus" - + Enum.GetName(typeof(SignatureStatus), sigStatus) - + "BrushKey"; + string resourceName = $"PUISignatureStatus{Enum.GetName(sigStatus)}BrushKey"; // Acquire reference to the brush. object resource = _frameworkElement.FindResource( @@ -238,7 +236,7 @@ private static string GetSummaryMessage(DigitalSignature signature, CertificateP signature.SubjectName, GetFormattedDate(signature.SignedOn), location); - break; + break; } return result; @@ -302,7 +300,7 @@ private static string GetSignatureSummaryMessage(SignatureStatus sigStatus, Cert else if (sigStatus == SignatureStatus.Unverifiable) { message = SR.SignatureResourceHelperSignatureStatusUnverifiable; - } + } else { message = SR.SignatureResourceHelperSignatureStatusInvalid; @@ -356,11 +354,11 @@ public override string ToString() { return String.Format( CultureInfo.CurrentCulture, - SR.SignatureResourcesFormatForAccessibility, - _summaryMessage, - _subjectName, - _reason, - _location, + SR.SignatureResourcesFormatForAccessibility, + _summaryMessage, + _subjectName, + _reason, + _location, _signBy); } } diff --git a/src/Microsoft.DotNet.Wpf/src/ReachFramework/AlphaFlattener/BrushProxy.cs b/src/Microsoft.DotNet.Wpf/src/ReachFramework/AlphaFlattener/BrushProxy.cs index e35325a3760..88cfb1aa787 100644 --- a/src/Microsoft.DotNet.Wpf/src/ReachFramework/AlphaFlattener/BrushProxy.cs +++ b/src/Microsoft.DotNet.Wpf/src/ReachFramework/AlphaFlattener/BrushProxy.cs @@ -390,12 +390,12 @@ public override string ToString() } else if (_brushList != null) { - str = str + "BrushList[" + _brushList.Count + "]"; + str = $"{str}BrushList[{_brushList.Count}]"; } if (_opacityMask != null) { - str = str + "^" + _opacityMask.ToString(); + str = $"{str}^{_opacityMask}"; } return str; @@ -674,10 +674,7 @@ public bool IsOpaque() return IsDrawingOpaque(GetDrawingPrimitive(), new RectangleGeometry(vb), Matrix.Identity); } - if (_brush != null) - { - Debug.Assert(false, "IsOpaque(" + _brush.GetType() + ") not handled"); - } + Debug.Assert(_brush == null, $"IsOpaque({_brush.GetType()}) not handled"); if ((_brushList != null) && (_brushList.Count != 0)) { @@ -770,10 +767,7 @@ public bool IsTransparent() return _image.IsTransparent(); } - if (_brush != null) - { - Debug.Assert(false, "IsTransparent not handled " + _brush.GetType()); - } + Debug.Assert(_brush == null, $"IsTransparent not handled {_brush.GetType()}"); return false; } @@ -2992,13 +2986,13 @@ public static Brush ReduceBrush(Brush brush, Rect bounds, Matrix brushToWorldTra { return null; } - + if(treeWalkProgress.IsTreeWalkInProgress(bcb)) { // A visual tree cycle has been detected while reducing vb, calling flattener.VisualWalk on bcb.Target will cause infinite recursion return null; } - + // // Convert from BitmapCacheBrush to DrawingBrush to reduce the number of brush types // we need to handle. This will render the BitmapCacheBrush like a VisualBrush (i.e. as vector content) @@ -3016,15 +3010,15 @@ public static Brush ReduceBrush(Brush brush, Rect bounds, Matrix brushToWorldTra // Mark the brush to avoid cycles in the visual tree treeWalkProgress.EnterTreeWalk(bcb); Visual visual = bcb.Target; - try + try { VisualTreeFlattener flattener = new VisualTreeFlattener(metroContext, pageSize, treeWalkProgress); flattener.VisualWalk(visual); } - finally + finally { treeWalkProgress.ExitTreeWalk(bcb); - } + } // Get Visual descendant bounds with clipping taken into consideration. Rect visualBounds = VisualTreeHelper.GetDescendantBounds(visual); @@ -3047,7 +3041,7 @@ public static Brush ReduceBrush(Brush brush, Rect bounds, Matrix brushToWorldTra new RectangleGeometry(visualBounds) ); - context.Pop(); + context.Pop(); } DrawingBrush drawingBrush = Utility.CreateNonInheritingDrawingBrush(drawing); @@ -3059,7 +3053,7 @@ public static Brush ReduceBrush(Brush brush, Rect bounds, Matrix brushToWorldTra return drawingBrush; } - + VisualBrush vb = brush as VisualBrush; if (vb != null) @@ -3070,13 +3064,13 @@ public static Brush ReduceBrush(Brush brush, Rect bounds, Matrix brushToWorldTra { return null; } - + if(treeWalkProgress.IsTreeWalkInProgress(vb)) { // A visual tree cycle has been detected while reducing vb, calling flattener.VisualWalk on its vb,Visual will cause infinite recursion return null; } - + // // Convert from VisualBrush to DrawingBrush to reduce the number of brush types // we need to handle. @@ -3110,16 +3104,16 @@ public static Brush ReduceBrush(Brush brush, Rect bounds, Matrix brushToWorldTra // Mark the visual brush to avoid cycles in the visual tree treeWalkProgress.EnterTreeWalk(vb); - try + try { VisualTreeFlattener flattener = new VisualTreeFlattener(metroContext, pageSize, treeWalkProgress); flattener.InheritedTransformHint = visualToWorldTransformHint; flattener.VisualWalk(vb.Visual); } - finally + finally { treeWalkProgress.ExitTreeWalk(vb); - } + } // Get Visual descendant bounds with clipping taken into consideration. Rect visualBounds = VisualTreeHelper.GetDescendantBounds(vb.Visual); @@ -3142,7 +3136,7 @@ public static Brush ReduceBrush(Brush brush, Rect bounds, Matrix brushToWorldTra new RectangleGeometry(visualBounds) ); - context.Pop(); + context.Pop(); } DrawingBrush drawingBrush = Utility.CreateNonInheritingDrawingBrush(drawing); diff --git a/src/Microsoft.DotNet.Wpf/src/ReachFramework/AlphaFlattener/DrawingContext.cs b/src/Microsoft.DotNet.Wpf/src/ReachFramework/AlphaFlattener/DrawingContext.cs index c5d6d6a883e..efe19640086 100644 --- a/src/Microsoft.DotNet.Wpf/src/ReachFramework/AlphaFlattener/DrawingContext.cs +++ b/src/Microsoft.DotNet.Wpf/src/ReachFramework/AlphaFlattener/DrawingContext.cs @@ -37,10 +37,10 @@ internal class DisplayListDrawingContext : IProxyDrawingContext #region Constructors public DisplayListDrawingContext( - Flattener flattener, - double opacity, - BrushProxy opacityMask, - Matrix trans, + Flattener flattener, + double opacity, + BrushProxy opacityMask, + Matrix trans, Geometry clip) { _flattener = flattener; @@ -162,7 +162,7 @@ void IProxyDrawingContext.DrawImage(ImageProxy image, Rect dest, Geometry clip, ip.DstRect = dest; ip.Clip = clip; ip.Transform = trans * _transform; - + ip.PushOpacity(_opacity, _opacityMask); _flattener.AddPrimitive(ip); } @@ -184,7 +184,7 @@ bool IProxyDrawingContext.DrawGlyphs(GlyphRun glyphrun, Geometry clip, Matrix tr gp.Clip = clip; gp.Transform = trans * _transform; gp.Brush = foreground; - + gp.PushOpacity(_opacity, _opacityMask); _flattener.AddPrimitive(gp); @@ -195,7 +195,7 @@ bool IProxyDrawingContext.DrawGlyphs(GlyphRun glyphrun, Geometry clip, Matrix tr } /// - /// Implement of IProxyDrawingContext on white background. + /// Implement of IProxyDrawingContext on white background. /// 1) BrushProxy/PenProxy is broken down to Avalon Brush/Pen. /// 2) All transparency as blended with white. /// 3) Output is sent to ILegacyDevice interfiace. @@ -455,7 +455,7 @@ private bool RadialFillGeometry(BrushProxy radial, BrushProxy other, bool pre, A break; } } - + radial.OpacityMask = saveMask; radial.Opacity = saveOpacity; @@ -548,10 +548,10 @@ private bool FillGeometry(BrushProxy one, ArrayList brushes, int from, Geometry #if DEBUG if (Configuration.Verbose >= 2) { - Debug.WriteLine("FillGeometry not implemented " + one + " " + two); + Debug.WriteLine($"FillGeometry not implemented {one} {two}"); } #endif - + return false; } @@ -616,13 +616,13 @@ private void RasterizeGeometry(BrushProxy brush, Geometry shape) #if DEBUG _seq++; - _dc.Comment("-> DrawImage(raster) " + _seq); + _dc.Comment($"-> DrawImage(raster) {_seq}"); #endif _dc.DrawImage(id, null, bounds); #if DEBUG - _dc.Comment("<- DrawImage(raster) " + _seq); + _dc.Comment($"<- DrawImage(raster) {_seq}"); #endif _dc.PopClip(); @@ -776,7 +776,7 @@ void IProxyDrawingContext.DrawGeometry(BrushProxy brush, PenProxy pen, Geometry { if (brush != null) { - // DrawingBrush is always rasterized onward from this stage. + // DrawingBrush is always rasterized onward from this stage. // Avoid the cost of creating new DrawingBrush in GetRealBrush during costing if ((brush.Brush != null) && (brush.Brush is DrawingBrush)) { @@ -796,11 +796,11 @@ void IProxyDrawingContext.DrawGeometry(BrushProxy brush, PenProxy pen, Geometry { b = brush.GetRealBrush(); } - + #if DEBUG _seq++; - _dc.Comment("-> DrawGeometry " + _seq + ' ' + _comment); + _dc.Comment($"-> DrawGeometry {_seq} {_comment}"); #endif if (p == null) { @@ -812,11 +812,11 @@ void IProxyDrawingContext.DrawGeometry(BrushProxy brush, PenProxy pen, Geometry } #if DEBUG - _dc.Comment("<- DrawGeometry" + _seq + ' ' + _comment); + _dc.Comment($"<- DrawGeometry{_seq} {_comment}"); if (Configuration.Verbose >= 2) { - Console.WriteLine(" DrawGeometry(" + _comment + ")"); + Console.WriteLine($" DrawGeometry({_comment})"); } #endif } @@ -887,14 +887,14 @@ void IProxyDrawingContext.DrawImage(ImageProxy image, Rect dest, Geometry clip, } image.BlendOverColor(Colors.White, 1.0, false); - + // BitmapSource img = image.GetImage(); - + if (clip != null) { _dc.PushClip(clip); } - + if (! trans.IsIdentity) { _dc.PushTransform(trans); @@ -902,17 +902,17 @@ void IProxyDrawingContext.DrawImage(ImageProxy image, Rect dest, Geometry clip, #if DEBUG _seq ++; - _dc.Comment("-> DrawImage " + _seq); + _dc.Comment($"-> DrawImage {_seq}"); #endif - + _dc.DrawImage(image.Image, image.Buffer, dest); #if DEBUG - _dc.Comment("<- DrawImage " + _seq); + _dc.Comment($"<- DrawImage {_seq}"); if (Configuration.Verbose >= 2) { - Console.WriteLine(" DrawImage(" + _comment + ")"); + Console.WriteLine($" DrawImage({_comment})"); } #endif @@ -939,12 +939,12 @@ bool IProxyDrawingContext.DrawGlyphs(GlyphRun glyphrun, Geometry clip, Matrix tr { return false; } - + if (clip != null) { _dc.PushClip(clip); } - + if (!trans.IsIdentity) { _dc.PushTransform(trans); @@ -952,17 +952,17 @@ bool IProxyDrawingContext.DrawGlyphs(GlyphRun glyphrun, Geometry clip, Matrix tr #if DEBUG _seq ++; - _dc.Comment("-> DrawGlyphRun " + _seq); + _dc.Comment($"-> DrawGlyphRun {_seq}"); #endif _dc.DrawGlyphRun(b, glyphrun); #if DEBUG - _dc.Comment("<- DrawGlyphRun " + _seq); + _dc.Comment($"<- DrawGlyphRun {_seq}"); if (Configuration.Verbose >= 2) { - Console.WriteLine(" DrawGlyphRun(" + _comment + ")"); + Console.WriteLine($" DrawGlyphRun({_comment})"); } #endif diff --git a/src/Microsoft.DotNet.Wpf/src/ReachFramework/AlphaFlattener/Flattener.cs b/src/Microsoft.DotNet.Wpf/src/ReachFramework/AlphaFlattener/Flattener.cs index ffe259d19a2..83506bf2d5f 100644 --- a/src/Microsoft.DotNet.Wpf/src/ReachFramework/AlphaFlattener/Flattener.cs +++ b/src/Microsoft.DotNet.Wpf/src/ReachFramework/AlphaFlattener/Flattener.cs @@ -352,7 +352,7 @@ public void AlphaFlatten(IProxyDrawingContext dc, bool disjoint) Console.WriteLine(); - Console.WriteLine("Primitives in display list: {0}", count); + Console.WriteLine($"Primitives in display list: {count}"); Console.WriteLine(); } @@ -428,7 +428,7 @@ public void AlphaFlatten(IProxyDrawingContext dc, bool disjoint) private void DeleteCommand(int i) { #if DEBUG - Console.WriteLine("Delete command {0}", i); + Console.WriteLine($"Delete command {i}"); #endif PrimitiveInfo pi = _dl.Commands[i]; @@ -734,7 +734,7 @@ private static bool ConvertTransparentOnOpaque(List commands, int if (proceedBlending && pi.primitive.IsOpaque) { #if DEBUG - Console.WriteLine("Make {0} opaque", i); + Console.WriteLine($"Make {i} opaque"); #endif @@ -995,18 +995,13 @@ internal void LogInterestingPrimitives(List commands, int count, } Console.WriteLine(); - Console.WriteLine("Interesting primitives: {0}", vip); - Console.WriteLine("Area with transparency: {0}", DisplayList.LeftPad(target, 0)); + Console.WriteLine($"Interesting primitives: {vip}"); + Console.WriteLine($"Area with transparency: {DisplayList.LeftPad(target, 0)}"); Console.WriteLine(); for (int i = 0; i < transparentCluster.Count; i++) { - Console.WriteLine( - "Cluster {0}: {1} {2} {3}", - i + 1, - DisplayList.LeftPad(transparentCluster[i].DebugBounds, 0), - DisplayList.LeftPad(transparentCluster[i].DebugPrimitives, 0), - transparentCluster[i].DebugRasterize); + Console.WriteLine($"Cluster {i + 1}: {DisplayList.LeftPad(transparentCluster[i].DebugBounds, 0)} {DisplayList.LeftPad(transparentCluster[i].DebugPrimitives, 0)} {transparentCluster[i].DebugRasterize}"); } Console.WriteLine(); @@ -1064,12 +1059,12 @@ internal void SaveInterestingPrimitives(List commands, int count, { if (vipID != 0) { - name = "vip" + vipID + ".xaml"; + name = $"vip{vipID}.xaml"; } SerializeVisual(dv, _dl.m_width, _dl.m_height, name); - Console.WriteLine("Serialized primitives to " + name); + Console.WriteLine($"Serialized primitives to {name}"); name = null; } @@ -1077,7 +1072,7 @@ internal void SaveInterestingPrimitives(List commands, int count, { Console.WriteLine(e.ToString()); - name = "vip" + vipID + ".xaml"; + name = $"vip{vipID}.xaml"; } vipID++; diff --git a/src/Microsoft.DotNet.Wpf/src/ReachFramework/AlphaFlattener/Primitive.cs b/src/Microsoft.DotNet.Wpf/src/ReachFramework/AlphaFlattener/Primitive.cs index 4eaff72b863..823feb1262d 100644 --- a/src/Microsoft.DotNet.Wpf/src/ReachFramework/AlphaFlattener/Primitive.cs +++ b/src/Microsoft.DotNet.Wpf/src/ReachFramework/AlphaFlattener/Primitive.cs @@ -535,7 +535,7 @@ out bitmapToDrawingTransform } #if DEBUG - Console.WriteLine("Drawing of type '" + d.GetType() + "' not handled."); + Console.WriteLine($"Drawing of type '{d.GetType()}' not handled."); #endif return null; diff --git a/src/Microsoft.DotNet.Wpf/src/ReachFramework/AlphaFlattener/PrimitiveList.cs b/src/Microsoft.DotNet.Wpf/src/ReachFramework/AlphaFlattener/PrimitiveList.cs index 1181ca8bd4b..42d512ae5ce 100644 --- a/src/Microsoft.DotNet.Wpf/src/ReachFramework/AlphaFlattener/PrimitiveList.cs +++ b/src/Microsoft.DotNet.Wpf/src/ReachFramework/AlphaFlattener/PrimitiveList.cs @@ -15,7 +15,7 @@ namespace Microsoft.Internal.AlphaFlattener { - internal class DisplayList + internal class DisplayList { public bool m_DisJoint; public double m_width; @@ -36,7 +36,7 @@ public DisplayList(bool disJoint, double width, double height) internal static string LeftPad(object obj, int len) { string s; - + List l = obj as List; if (l != null) @@ -47,13 +47,13 @@ internal static string LeftPad(object obj, int len) { if (s.Length > 1) { - s = s + ' '; + s = $"{s} "; } - + s = s + i; } - return s + ">"; + return $"{s}>"; } else if (obj is Double) { @@ -63,10 +63,7 @@ internal static string LeftPad(object obj, int len) { Rect r = (Rect) obj; - return " [" + LeftPad(r.Left, 6) + ' ' - + LeftPad(r.Top, 6) + ' ' - + LeftPad(r.Width, 6) + ' ' - + LeftPad(r.Height, 6) + "]"; + return $" [{LeftPad(r.Left, 6)} {LeftPad(r.Top, 6)} {LeftPad(r.Width, 6)} {LeftPad(r.Height, 6)}]"; } else { @@ -83,7 +80,7 @@ static internal void PrintPrimitive(PrimitiveInfo info, int index, bool verbose) Console.WriteLine(); Console.WriteLine(" No Type Und Ovr TrO Bounding Box Clipping"); - + if (verbose) { Console.Write(" Transform"); @@ -92,15 +89,15 @@ static internal void PrintPrimitive(PrimitiveInfo info, int index, bool verbose) Console.WriteLine(); return; } - + Primitive p = info.primitive; string typ = p.GetType().ToString(); typ = typ.Substring(typ.LastIndexOf('.') + 1); - Console.Write(LeftPad(index, 4) + LeftPad(typ, 18) + ":"); - + Console.Write($"{LeftPad(index, 4)}{LeftPad(typ, 18)}:"); + List extra = null; if (p.IsOpaque) @@ -125,7 +122,7 @@ static internal void PrintPrimitive(PrimitiveInfo info, int index, bool verbose) if (info.overlap != null) { - Console.Write(' ' + LeftPad(info.overlap.Count, 3)); + Console.Write($" {LeftPad(info.overlap.Count, 3)}"); if (info.overlapHasTransparency != 0) { @@ -143,30 +140,30 @@ static internal void PrintPrimitive(PrimitiveInfo info, int index, bool verbose) { Console.Write(" "); } - + Console.Write(LeftPad(info.bounds, 0)); - + Geometry clip = p.Clip; if (clip != null) { Console.Write(LeftPad(clip.Bounds, 0)); } - + if (verbose) { Matrix m = p.Transform; Console.Write(" {"); - Console.Write(LeftPad(m.M11, 3) + ' '); - Console.Write(LeftPad(m.M12, 3) + ' '); - Console.Write(LeftPad(m.M21, 3) + ' '); - Console.Write(LeftPad(m.M22, 3) + ' '); - Console.Write(LeftPad(m.OffsetX, 6) + ' '); + Console.Write($"{LeftPad(m.M11, 3)} "); + Console.Write($"{LeftPad(m.M12, 3)} "); + Console.Write($"{LeftPad(m.M21, 3)} "); + Console.Write($"{LeftPad(m.M22, 3)} "); + Console.Write($"{LeftPad(m.OffsetX, 6)} "); Console.Write(LeftPad(m.OffsetY, 6)); Console.Write("} "); } - + if (verbose) { GlyphPrimitive gp = p as GlyphPrimitive; @@ -174,14 +171,14 @@ static internal void PrintPrimitive(PrimitiveInfo info, int index, bool verbose) if (gp != null) { IList chars = gp.GlyphRun.Characters; - + Console.Write(" \""); for (int i = 0; i < chars.Count; i ++) { Console.Write(chars[i]); } - + Console.Write('"'); } } @@ -200,7 +197,7 @@ static internal void PrintPrimitive(PrimitiveInfo info, int index, bool verbose) if (sb != null) { - Console.Write(" SolidColorBrush({0})", sb.Color); + Console.Write($" SolidColorBrush({sb.Color})"); } } } @@ -210,7 +207,7 @@ static internal void PrintPrimitive(PrimitiveInfo info, int index, bool verbose) { Console.Write(' '); Console.Write(LeftPad(extra, 0)); - } + } Console.WriteLine(); } @@ -371,7 +368,7 @@ public void ReportOverlapping(int one, int two) #if DEBUG if (Configuration.Verbose >= 2) { - Console.Write(" <{0} {1}>", one, two); + Console.Write($" <{one} {two}>"); overlapcount ++; diff --git a/src/Microsoft.DotNet.Wpf/src/ReachFramework/AlphaFlattener/PrimitiveRenderer.cs b/src/Microsoft.DotNet.Wpf/src/ReachFramework/AlphaFlattener/PrimitiveRenderer.cs index dbe2dae0d0d..60bc0d209f9 100644 --- a/src/Microsoft.DotNet.Wpf/src/ReachFramework/AlphaFlattener/PrimitiveRenderer.cs +++ b/src/Microsoft.DotNet.Wpf/src/ReachFramework/AlphaFlattener/PrimitiveRenderer.cs @@ -73,7 +73,7 @@ public void DrawGeometry(Geometry cur, string desp, GeometryPrimitive gp) // Draw the stroking as filling widened path #if DEBUG - FillGeometry(topPI, cur, desp + "_widen", null, null, start, inter, topBounds); + FillGeometry(topPI, cur, $"{desp}_widen", null, null, start, inter, topBounds); #else FillGeometry(topPI, cur, null, null, null, start, inter, topBounds); #endif @@ -139,7 +139,7 @@ public bool DrawGlyphs(GlyphRun glyphrun, Rect bounds, Matrix trans, string desp } _dc.Comment(desp); - + return _dc.DrawGlyphs(glyphrun, _clip, trans, _brush); } @@ -175,7 +175,7 @@ public PenProxy Pen _pen = value; } } - + public List Overlapping { set { _overlapping = value; } @@ -228,15 +228,15 @@ private static string Oper(string t1, char op, string t2) if ((op != '-') && t1.IndexOfAny(opers) >= 0) { - t1 = "(" + t1 + ")"; + t1 = $"({t1})"; } if (t2.IndexOfAny(opers) >= 0) { - t2 = "(" + t2 + ")"; + t2 = $"({t2})"; } - return t1 + op + t2; + return $"{t1}{op}{t2}"; } #endif @@ -245,11 +245,11 @@ private static string Oper(string t1, char op, string t2) #region Private Methods private void RenderImage( - ImageProxy image, - Rect dest, - Geometry bounds, - bool clipToBounds, - int start, + ImageProxy image, + Rect dest, + Geometry bounds, + bool clipToBounds, + int start, Matrix trans, string desp ) @@ -407,13 +407,13 @@ private void FillGeometry(Geometry cur, string desp, Geometry curAlt, string des // Recursive // _brush must be in world space private void FillGeometry( - PrimitiveInfo topPI, - Geometry cur, - string desp, - Geometry curAlt, - string despAlt, - int start, - Geometry inter, + PrimitiveInfo topPI, + Geometry cur, + string desp, + Geometry curAlt, + string despAlt, + int start, + Geometry inter, Geometry topBounds ) { diff --git a/src/Microsoft.DotNet.Wpf/src/ReachFramework/AlphaFlattener/Utility.cs b/src/Microsoft.DotNet.Wpf/src/ReachFramework/AlphaFlattener/Utility.cs index da9d1de11e9..8acb4e3a002 100644 --- a/src/Microsoft.DotNet.Wpf/src/ReachFramework/AlphaFlattener/Utility.cs +++ b/src/Microsoft.DotNet.Wpf/src/ReachFramework/AlphaFlattener/Utility.cs @@ -23,7 +23,7 @@ using BuildInfo = MS.Internal.ReachFramework.BuildInfo; -[assembly: InternalsVisibleTo( "System.Printing, PublicKey=" + BuildInfo.WCP_PUBLIC_KEY_STRING)] +[assembly: InternalsVisibleTo($"System.Printing, PublicKey={BuildInfo.WCP_PUBLIC_KEY_STRING}")] // This code is debug only until we decide to go all the way with enforcements. #if ENFORCEMENT @@ -52,7 +52,7 @@ internal static void Stop() if (Configuration.Verbose >= 2) { - Console.WriteLine("{0} {1} {2}", s_count, elapsed.TotalSeconds, s_total); + Console.WriteLine($"{s_count} {elapsed.TotalSeconds} {s_total}"); } } } @@ -1000,7 +1000,7 @@ static private Geometry Combine(Geometry one, Geometry two, GeometryCombineMode { if (IsRectangle(GetAsPathGeometry(one)) && IsRectangle(GetAsPathGeometry(two))) { - Console.WriteLine("Combine({0})", mode); + Console.WriteLine($"Combine({mode})"); } } @@ -1597,7 +1597,7 @@ public static Rect GetTileContentBounds(TileBrush brush) uiElement.Arrange(new Rect(uiElement.DesiredSize)); } } - + bounds = VisualTreeHelper.GetDescendantBounds(visualBrush.Visual); Geometry clip = VisualTreeHelper.GetClip(visualBrush.Visual); diff --git a/src/Microsoft.DotNet.Wpf/src/ReachFramework/Packaging/XPSSignatureDefinition.cs b/src/Microsoft.DotNet.Wpf/src/ReachFramework/Packaging/XPSSignatureDefinition.cs index ee4fc5b879d..f440d900970 100644 --- a/src/Microsoft.DotNet.Wpf/src/ReachFramework/Packaging/XPSSignatureDefinition.cs +++ b/src/Microsoft.DotNet.Wpf/src/ReachFramework/Packaging/XPSSignatureDefinition.cs @@ -383,7 +383,7 @@ public class XpsSignatureDefinition if (SignBy != null) { writer.WriteStartElement(XpsS0Markup.SignBy); - writer.WriteString(((DateTime)SignBy).ToUniversalTime().ToString("s", DateTimeFormatInfo.InvariantInfo) + "Z"); + writer.WriteString(string.Create(CultureInfo.InvariantCulture, $"{((DateTime)SignBy).ToUniversalTime():s}Z")); writer.WriteEndElement(); } diff --git a/src/Microsoft.DotNet.Wpf/src/ReachFramework/Packaging/XpsDocument.cs b/src/Microsoft.DotNet.Wpf/src/ReachFramework/Packaging/XpsDocument.cs index 51a3befe5d7..40e8c18ba20 100644 --- a/src/Microsoft.DotNet.Wpf/src/ReachFramework/Packaging/XpsDocument.cs +++ b/src/Microsoft.DotNet.Wpf/src/ReachFramework/Packaging/XpsDocument.cs @@ -174,7 +174,7 @@ CompressionOption compressionOption // if( !Uri.IsAbsoluteUri) { - Uri = new Uri( new Uri(Directory.GetCurrentDirectory()+"/"), this.Uri ); + Uri = new Uri( new Uri($"{Directory.GetCurrentDirectory()}/"), this.Uri ); } CurrentXpsManager.XpsDocument = this; diff --git a/src/Microsoft.DotNet.Wpf/src/ReachFramework/Packaging/XpsManager.cs b/src/Microsoft.DotNet.Wpf/src/ReachFramework/Packaging/XpsManager.cs index 723a133a1fe..5714acb4f9c 100644 --- a/src/Microsoft.DotNet.Wpf/src/ReachFramework/Packaging/XpsManager.cs +++ b/src/Microsoft.DotNet.Wpf/src/ReachFramework/Packaging/XpsManager.cs @@ -120,7 +120,7 @@ CompressionOption compressionOption ) { _ownsPackage = true; - + _uri = new Uri(path, UriKind.RelativeOrAbsolute); // //The URI has to be absolute @@ -129,7 +129,7 @@ CompressionOption compressionOption // if( !_uri.IsAbsoluteUri) { - _uri = new Uri( new Uri(Directory.GetCurrentDirectory()+"/"), path ); + _uri = new Uri( new Uri($"{Directory.GetCurrentDirectory()}/"), path ); } Package package = PackageStore.GetPackage( _uri ); @@ -157,8 +157,8 @@ CompressionOption compressionOption (packageAccess== FileAccess.Read) ? FileShare.Read: FileShare.None ); } - - AddPackageToCache( _uri, package ); + + AddPackageToCache( _uri, package ); } else { @@ -319,7 +319,7 @@ Uri partUri { throw new ArgumentException(SR.Format(SR.ReachPackaging_InvalidContentType, contentType), "contentType"); } - + //Do not compress image Content Types CompressionOption compressionOption = _compressionOption; @@ -420,7 +420,7 @@ Uri partUri // // Generate a unique part Uri // - String uniqueUri = "/Resources/" + Guid.NewGuid().ToString() + XpsS0Markup.ObfuscatedFontExt; + String uniqueUri = $"/Resources/{Guid.NewGuid()}{XpsS0Markup.ObfuscatedFontExt}"; System.Uri partUri = PackUriHelper.CreatePartUri(new Uri(uniqueUri, UriKind.Relative)); PackagePart metroPart = _metroPackage.CreatePart(partUri, @@ -495,7 +495,7 @@ PrintTicket printTicket } /// - /// This method writes an empty print ticket part and adds a relationship + /// This method writes an empty print ticket part and adds a relationship /// associate the print ticket part with the specified Metro part. It only /// does so when the document is streaming. /// @@ -642,8 +642,8 @@ Uri uri if (propertiesPartRelationship != null) { - Uri propertiesPartUri = - PackUriHelper.ResolvePartUri(propertiesPartRelationship.SourceUri, + Uri propertiesPartUri = + PackUriHelper.ResolvePartUri(propertiesPartRelationship.SourceUri, propertiesPartRelationship.TargetUri); if (package.PartExists(propertiesPartUri)) @@ -747,12 +747,12 @@ Uri uri if( oldThumbnail != null ) { throw new XpsPackagingException(SR.ReachPackaging_AlreadyHasThumbnail); - } + } if( !( imageType == XpsImageType.JpegImageType || imageType == XpsImageType.PngImageType ) ) { throw new XpsPackagingException(SR.ReachPackaging_UnsupportedThumbnailImageType); - } + } newThumbnail = new XpsThumbnail(this, parent, GenerateUniquePart(ImageTypeToString(imageType)) @@ -949,14 +949,13 @@ string id { string docContentKey = GetContentCounterKey(XpsS0Markup.FixedDocumentContentType); int docCounter = 0; - + if (_contentTypes.ContainsKey(docContentKey)) { docCounter = _contentTypes[docContentKey]-1; } - return new Uri("/Documents/" + docCounter + "/Structure/DocStructure.struct", - UriKind.Relative); + return new Uri($"/Documents/{docCounter}/Structure/DocStructure.struct", UriKind.Relative); } /// @@ -972,14 +971,13 @@ int pageNumber { string docContentKey = GetContentCounterKey(XpsS0Markup.FixedDocumentContentType); int docCounter = 0; - + if (_contentTypes.ContainsKey(docContentKey)) { docCounter = _contentTypes[docContentKey]-1; } - return new Uri("/Documents/" + docCounter + "/Structure/Fragments/"+pageNumber+".frag", - UriKind.Relative); + return new Uri($"/Documents/{docCounter}/Structure/Fragments/{pageNumber}.frag", UriKind.Relative); } #region Private methods @@ -1010,7 +1008,7 @@ bool streaming _metroPackage = metroPackage; _compressionOption = compressionOption; _streaming = streaming; - + _contentTypes = new Dictionary(11); _cachedParts = new Dictionary(11); @@ -1036,23 +1034,23 @@ object relatedPart { ArgumentNullException.ThrowIfNull(relatedPart); string uniqueUri = ""; - + if( relatedPart is XpsFixedDocumentSequenceReaderWriter ) { - uniqueUri = "/MetaData/Job_PT.xml"; + uniqueUri = "/MetaData/Job_PT.xml"; } else if( relatedPart is XpsFixedDocumentReaderWriter ) { XpsFixedDocumentReaderWriter doc = relatedPart as XpsFixedDocumentReaderWriter; - uniqueUri = "/Documents/" + doc.DocumentNumber + "/Document_PT.xml"; + uniqueUri = $"/Documents/{doc.DocumentNumber}/Document_PT.xml"; } else if( relatedPart is XpsFixedPageReaderWriter ) { XpsFixedPageReaderWriter page = relatedPart as XpsFixedPageReaderWriter; XpsFixedDocumentReaderWriter doc = (relatedPart as XpsFixedPageReaderWriter).Parent as XpsFixedDocumentReaderWriter; - uniqueUri = "/Documents/" + doc.DocumentNumber + "/Page" + page.PageNumber+ "_PT.xml"; + uniqueUri = $"/Documents/{doc.DocumentNumber}/Page{page.PageNumber}_PT.xml"; } - + return PackUriHelper.CreatePartUri(new Uri(uniqueUri, UriKind.Relative)); } @@ -1079,7 +1077,7 @@ ContentType contentType { string contentKey = GetContentCounterKey(XpsS0Markup.FixedDocumentContentType); int docNumber = _contentTypes[contentKey] - 1; - uniqueUri = "/Documents/" + docNumber + "/Document_PT.xml"; + uniqueUri = $"/Documents/{docNumber}/Document_PT.xml"; } else if (contentType.AreTypeAndSubTypeEqual(XpsS0Markup.FixedPageContentType)) { @@ -1087,12 +1085,12 @@ ContentType contentType string pageContentKey = GetContentCounterKey(XpsS0Markup.FixedPageContentType); int docNumber = _contentTypes[documentContentKey] - 1; int pageNumber = _contentTypes[pageContentKey] - 1; - uniqueUri = "/Documents/" + docNumber + "/Page" + pageNumber + "_PT.xml"; + uniqueUri = $"/Documents/{docNumber}/Page{pageNumber}_PT.xml"; } return PackUriHelper.CreatePartUri(new Uri(uniqueUri, UriKind.Relative)); } - + /// /// Generates a unique Uri based on the content-type @@ -1245,7 +1243,7 @@ ContentType contentType else { key = contentType.SubTypeComponent; - } + } } // @@ -1308,7 +1306,7 @@ ContentType contentType reference = _packageCache[uri]; reference -= 1; - + if(reference > 0 ) { _packageCache[uri] = reference; @@ -1346,7 +1344,7 @@ ContentType contentType internal static Dictionary _packageCache; internal static Object _globalLock; - + #endregion Private data #region IDisposable implementation @@ -1399,9 +1397,9 @@ ContentType contentType { extention = XpsS0Markup.WdpExtension; } - return extention; + return extention; } - + #endregion Private static methods #region Internal static data @@ -1442,7 +1440,7 @@ Package package if (startingPartRelationship != null) { - Uri startPartUri = PackUriHelper.ResolvePartUri(startingPartRelationship.SourceUri, + Uri startPartUri = PackUriHelper.ResolvePartUri(startingPartRelationship.SourceUri, startingPartRelationship.TargetUri); if (package.PartExists(startPartUri)) @@ -1541,7 +1539,7 @@ Uri fileUri Uri relativeUri = baseUri.MakeRelativeUri(fileUri); Uri unescapedUri = new Uri(relativeUri.GetComponents(UriComponents.SerializationInfoString, UriFormat.SafeUnescaped), UriKind.RelativeOrAbsolute); - + return unescapedUri.GetComponents(UriComponents.SerializationInfoString, UriFormat.UriEscaped); } public @@ -1572,11 +1570,11 @@ Uri fileUri case XpsImageType.JpegImageType: imageContentType = XpsS0Markup.JpgContentType; break; - + case XpsImageType.PngImageType: imageContentType = XpsS0Markup.PngContentType; break; - + case XpsImageType.TiffImageType: imageContentType = XpsS0Markup.TifContentType; break; diff --git a/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/DocumentNUp.cs b/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/DocumentNUp.cs index 6a07c3a9478..565bfc7404e 100644 --- a/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/DocumentNUp.cs +++ b/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/DocumentNUp.cs @@ -558,8 +558,7 @@ public NUpPresentationDirectionSetting PresentationDirection /// A string that represents this document NUp setting. public override string ToString() { - return PagesPerSheet.ToString(CultureInfo.CurrentCulture) + ", " + - PresentationDirection.ToString(); + return $"{PagesPerSheet}, {PresentationDirection}"; } #endregion Public Methods diff --git a/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PageCanvasSize.cs b/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PageCanvasSize.cs index 5809c4ca6a2..a0a02c745bf 100644 --- a/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PageCanvasSize.cs +++ b/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PageCanvasSize.cs @@ -99,7 +99,7 @@ public double ExtentHeight /// A string that represents this imageable area. public override string ToString() { - return "[ImageableArea: Origin (" + OriginWidth + "," + OriginHeight + "), Extent (" + ExtentWidth + "x" + ExtentHeight + ")]"; + return $"[ImageableArea: Origin ({OriginWidth},{OriginHeight}), Extent ({ExtentWidth}x{ExtentHeight})]"; } #endregion Public Methods @@ -176,8 +176,7 @@ public CanvasImageableArea ImageableArea /// A string that represents this imageable size capability object. public override string ToString() { - return "ImageableSizeWidth=" + ImageableSizeWidth + ", ImageableSizeHeight=" + ImageableSizeHeight + " " + - ((ImageableArea != null) ? ImageableArea.ToString() : "[ImageableArea: null]"); + return $"ImageableSizeWidth={ImageableSizeWidth}, ImageableSizeHeight={ImageableSizeHeight} {((ImageableArea != null) ? ImageableArea.ToString() : "[ImageableArea: null]")}"; } #endregion Public Methods @@ -387,4 +386,4 @@ internal override sealed bool BuildProperty(XmlPrintCapReader reader) #endregion Internal Fields } -} \ No newline at end of file +} diff --git a/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PageMediaSize.cs b/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PageMediaSize.cs index 132c4923e0a..735dc269765 100644 --- a/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PageMediaSize.cs +++ b/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PageMediaSize.cs @@ -90,8 +90,7 @@ public double MediaSizeHeight /// A string that represents this non-custom page media size. public override string ToString() { - return Value.ToString() + ": " + MediaSizeWidth.ToString(CultureInfo.CurrentCulture) + - " x " + MediaSizeHeight.ToString(CultureInfo.CurrentCulture); + return $"{Value}: {MediaSizeWidth} x {MediaSizeHeight}"; } #endregion Public Methods @@ -533,9 +532,7 @@ public void SetFixedMediaSize(PageMediaSizeName value, /// A string that represents this page media size setting. public override string ToString() { - return Value.ToString() + - ": MediaSizeWidth=" + MediaSizeWidth.ToString(CultureInfo.CurrentCulture) + - ", MediaSizeHeight=" + MediaSizeHeight.ToString(CultureInfo.CurrentCulture); + return $"{Value}: MediaSizeWidth={MediaSizeWidth}, MediaSizeHeight={MediaSizeHeight}"; } #endregion Public Methods @@ -591,4 +588,4 @@ private void InternalSetFixedMediaSize(PageMediaSizeName value, #endregion Private Methods } -} \ No newline at end of file +} diff --git a/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PageResolution.cs b/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PageResolution.cs index 6e9dd096c29..2a28689c0ed 100644 --- a/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PageResolution.cs +++ b/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PageResolution.cs @@ -91,9 +91,7 @@ public int ResolutionY /// A string that represents this page resolution. public override string ToString() { - return ResolutionX.ToString(CultureInfo.CurrentCulture) + " x " + - ResolutionY.ToString(CultureInfo.CurrentCulture) + " (Qualitative: " + - QualitativeResolution.ToString() + ")"; + return $"{ResolutionX} x {ResolutionY} (Qualitative: {QualitativeResolution})"; } #endregion Public Methods @@ -426,9 +424,7 @@ public PageQualitativeResolution QualitativeResolution /// A string that represents this page resolution setting. public override string ToString() { - return ResolutionX.ToString(CultureInfo.CurrentCulture) + "x" + - ResolutionY.ToString(CultureInfo.CurrentCulture) + - "(qualitative: " + QualitativeResolution.ToString() + ")"; + return $"{ResolutionX}x{ResolutionY}(qualitative: {QualitativeResolution})"; } #endregion Public Methods diff --git a/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PageScaling.cs b/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PageScaling.cs index 949ae9e08f7..9d780fe0273 100644 --- a/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PageScaling.cs +++ b/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PageScaling.cs @@ -125,10 +125,7 @@ public ScalingSquareScaleCapability CustomSquareScale /// A string that represents this scaling option. public override string ToString() { - return Value.ToString() + ": " + - ((CustomScaleWidth != null) ? CustomScaleWidth.ToString() : "null") + " x " + - ((CustomScaleHeight != null) ? CustomScaleHeight.ToString() : "null") + " x " + - ((CustomSquareScale != null) ? CustomSquareScale.ToString() : "null"); + return $"{Value}: {((CustomScaleWidth != null) ? CustomScaleWidth.ToString() : "null")} x {((CustomScaleHeight != null) ? CustomScaleHeight.ToString() : "null")} x {((CustomSquareScale != null) ? CustomSquareScale.ToString() : "null")}"; } #endregion Public Methods @@ -554,13 +551,10 @@ public override string ToString() } else { - return Value.ToString() + - ", ScaleWidth=" + CustomScaleWidth.ToString(CultureInfo.CurrentCulture) + - ", ScaleHeight=" + CustomScaleHeight.ToString(CultureInfo.CurrentCulture) + - ", SquareScale=" + CustomSquareScale.ToString(CultureInfo.CurrentCulture); + return $"{Value}, ScaleWidth={CustomScaleWidth}, ScaleHeight={CustomScaleHeight}, SquareScale={CustomSquareScale}"; } } #endregion Public Methods } -} \ No newline at end of file +} diff --git a/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PrintCapabilitesWriter.cs b/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PrintCapabilitesWriter.cs index b753d45e48f..26556c5bf55 100644 --- a/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PrintCapabilitesWriter.cs +++ b/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PrintCapabilitesWriter.cs @@ -519,7 +519,7 @@ out optionDisplayNameId { string x = XmlConvert.ToString(resolutions[i].x); string y = XmlConvert.ToString(resolutions[i].y); - WriteStartOption(this._privateNamespace, null, x + " x " + y, "None"); + WriteStartOption(this._privateNamespace, null, $"{x} x {y}", "None"); { WriteStartScoredProperty(PrintSchemaNamespaces.StandardKeywordSet, "ResolutionX"); { diff --git a/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PrintSchema.cs b/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PrintSchema.cs index 64dab4aaa72..1c7eef3d77d 100644 --- a/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PrintSchema.cs +++ b/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PrintSchema.cs @@ -1964,15 +1964,7 @@ private Framework() {} internal const string Unspecified = "Unspecified"; internal const string Unknown = "Unknown"; - internal const string EmptyPrintTicket = - "" + - "<" + PrintSchemaPrefixes.Framework + ":" + PrintSchemaTags.Framework.PrintTicketRoot + - " xmlns:" + PrintSchemaPrefixes.Framework + "=\"" + PrintSchemaNamespaces.Framework + "\"" + - " xmlns:" + PrintSchemaPrefixes.StandardKeywordSet + "=\"" + PrintSchemaNamespaces.StandardKeywordSet + "\"" + - " xmlns:" + PrintSchemaPrefixes.xsi + "=\"" + PrintSchemaNamespaces.xsi + "\"" + - " xmlns:" + PrintSchemaPrefixes.xsd + "=\"" + PrintSchemaNamespaces.xsd + "\"" + - " version=\"1\">" + - ""; + internal const string EmptyPrintTicket = $"<{PrintSchemaPrefixes.Framework}:{PrintSchemaTags.Framework.PrintTicketRoot} xmlns:{PrintSchemaPrefixes.Framework}=\"{PrintSchemaNamespaces.Framework}\" xmlns:{PrintSchemaPrefixes.StandardKeywordSet}=\"{PrintSchemaNamespaces.StandardKeywordSet}\" xmlns:{PrintSchemaPrefixes.xsi}=\"{PrintSchemaNamespaces.xsi}\" xmlns:{PrintSchemaPrefixes.xsd}=\"{PrintSchemaNamespaces.xsd}\" version=\"1\">"; } internal class Keywords diff --git a/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PrintSchemaShim.cs b/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PrintSchemaShim.cs index a9a5e10f4e6..c210537ba18 100644 --- a/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PrintSchemaShim.cs +++ b/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PrintSchemaShim.cs @@ -133,7 +133,7 @@ public static bool TryEmbedDevMode(InternalPrintTicket ticket, string oemDriverN { XmlAttribute nameAttr = ticket.XmlDoc.CreateAttribute("name"); { - nameAttr.Value = oemDriverPrefix + ":PageDevmodeSnapshot"; + nameAttr.Value = $"{oemDriverPrefix}:PageDevmodeSnapshot"; } parameterInitElem.Attributes.Append(nameAttr); diff --git a/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PrtCap_Base.cs b/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PrtCap_Base.cs index f95372e6e13..981f42c8c54 100644 --- a/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PrtCap_Base.cs +++ b/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PrtCap_Base.cs @@ -288,8 +288,7 @@ public int DefaultValue /// A string that represents this object. public override string ToString() { - return ParameterName + ": min=" + MinValue + ", max=" + MaxValue + - ", default=" + DefaultValue; + return $"{ParameterName}: min={MinValue}, max={MaxValue}, default={DefaultValue}"; } #endregion Public Methods @@ -479,8 +478,7 @@ internal LengthParameterDefinition() : base() /// A string that represents this object. public override string ToString() { - return ParameterName + ": min=" + MinValue + ", max=" + MaxValue + - ", default=" + DefaultValue; + return $"{ParameterName}: min={MinValue}, max={MaxValue}, default={DefaultValue}"; } #endregion Public Methods diff --git a/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PrtTicket_Editor.cs b/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PrtTicket_Editor.cs index 2bd36dca593..e2eeefe975e 100644 --- a/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PrtTicket_Editor.cs +++ b/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PrtTicket_Editor.cs @@ -215,11 +215,11 @@ public static string AddStdNamespaceDeclaration(XmlElement root, string prefix_h for (index = 0; index < limit; index++) { // the new prefix is in the format like: "psk0000" "xsi0001" "xsd0100" - prefix = prefix_header + index.ToString(CultureInfo.InvariantCulture).PadLeft(4, '0'); + prefix = string.Create(CultureInfo.InvariantCulture, $"{prefix_header}{index:0000}"); - if (root.Attributes["xmlns:" + prefix] == null) + if (root.Attributes[$"xmlns:{prefix}"] == null) { - root.SetAttribute("xmlns:" + prefix, nsURI); + root.SetAttribute($"xmlns:{prefix}", nsURI); break; } } @@ -456,7 +456,7 @@ public static string GetQName(XmlDocument xmlDoc, string URI, string localName) } else { - QName = prefix + ":" + localName; + QName = $"{prefix}:{localName}"; } // Console.WriteLine("URI:{0}, localName:{1} ===> QName:{2}", URI, localName, QName); diff --git a/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/VisualSerializer.cs b/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/VisualSerializer.cs index 6541ca105ca..166f5338900 100644 --- a/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/VisualSerializer.cs +++ b/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/VisualSerializer.cs @@ -288,7 +288,7 @@ protected string FindBrush(Brush brush, Rect bounds) } _objects.Add(sBrush); - _objnams.Add("b" + _brushId); + _objnams.Add($"b{_brushId}"); // Replace brush ID place holder with the real ID: // Can't put ID in for brush reuse. @@ -296,7 +296,7 @@ protected string FindBrush(Brush brush, Rect bounds) // // - sbBrush = sbBrush.Replace("bxx", "b" + _brushId, 0, 40); + sbBrush = sbBrush.Replace("bxx", $"b{_brushId}", 0, 40); _brushId++; @@ -357,7 +357,7 @@ protected string SimpleBrushToString(Brush brush) // Write GradientStopCollection protected void WriteGradientStops(string prefix, GradientStopCollection gsc) { - _writer.WriteStartElement(prefix + ".GradientStops"); + _writer.WriteStartElement($"{prefix}.GradientStops"); int count = gsc.Count; @@ -661,15 +661,15 @@ protected void WriteBitmap(string attribute, ImageSource imageSource) { string sourceProfile = ColorTypeConverter.SerializeColorContext(_context,colorConvertedBitmap.SourceColorContext); - bitmapUri = "{ColorConvertedBitmap " + bitmapUri + " " + sourceProfile; + bitmapUri = $"{{ColorConvertedBitmap {bitmapUri} {sourceProfile}"; if (new ColorContext(PixelFormats.Default) != colorConvertedBitmap.DestinationColorContext) { string destinationProfile = ColorTypeConverter.SerializeColorContext(_context, colorConvertedBitmap.DestinationColorContext); - bitmapUri = bitmapUri + " " + destinationProfile; + bitmapUri = $"{bitmapUri} {destinationProfile}"; } - bitmapUri = bitmapUri + "}"; + bitmapUri = $"{bitmapUri}}}"; } } @@ -904,11 +904,11 @@ protected void WriteBrush(string attribute, Brush brush, Rect bounds) if ((_manager != null) || (_forceGeneral >= 1) ) // to container | within resource dictionary { - _writer.WriteAttributeString(attribute, "{StaticResource " + ob + "}"); + _writer.WriteAttributeString(attribute, $"{{StaticResource {ob}}}"); } // to loose files else { - _writer.WriteAttributeString(attribute, "{DynamicResource " + ob + "}"); + _writer.WriteAttributeString(attribute, $"{{DynamicResource {ob}}}"); } } } @@ -961,7 +961,7 @@ protected void WritePen(Pen pen, Rect bounds, bool isLineGeometry) } else { - string doubleString = GetString(dashes)+" "+GetString(dashes); + string doubleString = $"{GetString(dashes)} {GetString(dashes)}"; _writer.WriteAttributeString("StrokeDashArray",doubleString ); } } @@ -1129,7 +1129,7 @@ private void WritePathFigureCollection(PathFigureCollection figures, bool forFil } else { - _writer.WriteStartElement(ps.ToString() + "PathSegment not handled"); + _writer.WriteStartElement($"{ps}PathSegment not handled"); } if (!ps.IsStroked) @@ -1467,7 +1467,7 @@ internal bool WriteGeometry(string element, string attribute, Geometry geo, Matr } // Output as element - _writer.WriteStartElement(element + "." + attribute); + _writer.WriteStartElement($"{element}.{attribute}"); } _writer.WriteStartElement("PathGeometry"); @@ -2137,7 +2137,7 @@ void IMetroDrawingContext.DrawGlyphRun(Brush foreground, GlyphRun glyphRun) // Prefix it with '{}' to avoid being confused with markup extension if (characters[0] == '{') { - characters = "{}" + characters; + characters = $"{{}}{characters}"; } if (serializeGlyphRun.Characters.Count > MaxGlyphCount) diff --git a/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/VisualTreeFlattener.cs b/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/VisualTreeFlattener.cs index 1e1c630227d..beb6ee38265 100644 --- a/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/VisualTreeFlattener.cs +++ b/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/VisualTreeFlattener.cs @@ -82,7 +82,7 @@ Type destinationType ) { - string bitmapName = "bitmap" + m_bitmapId; + string bitmapName = $"bitmap{m_bitmapId}"; BitmapEncoder encoder = null; @@ -127,7 +127,7 @@ Type destinationType if (encoder != null) { - bitmapName = bitmapName + '.' + extension; + bitmapName = $"{bitmapName}.{extension}"; } } } @@ -138,13 +138,13 @@ Type destinationType { encoder = new WmpBitmapEncoder(); - bitmapName = bitmapName + ".wmp"; + bitmapName = $"{bitmapName}.wmp"; } else { encoder = new PngBitmapEncoder(); - bitmapName = bitmapName + ".png"; + bitmapName = $"{bitmapName}.png"; } } @@ -164,12 +164,12 @@ Type destinationType index = m_mainFile.Length; } - string uri = m_mainFile.Substring(0, index) + "_" + bitmapName; + string uri = $"{m_mainFile.AsSpan(0, index)}_{bitmapName}"; Stream bitmapStreamDest = new System.IO.FileStream(uri, FileMode.Create, FileAccess.ReadWrite, FileShare.None); #if DEBUG - Console.WriteLine("Saving " + uri); + Console.WriteLine($"Saving {uri}"); #endif encoder.Save(bitmapStreamDest); @@ -270,13 +270,13 @@ internal override TypeConverter GetTypeConverter(Type objType) { m_imageConverter = new LooseImageSourceTypeConverter(m_mainFile); } - + return m_imageConverter; } return null; } - } + } } namespace System.Windows.Xps.Serialization @@ -368,7 +368,7 @@ public Matrix InheritedTransformHint internal VisualTreeFlattener(IMetroDrawingContext dc, Size pageSize, TreeWalkProgress treeWalkProgress) { Debug.Assert(treeWalkProgress != null); - + // DrawingContextFlattener flattens calls to DrawingContext _dcf = new DrawingContextFlattener(dc, pageSize, treeWalkProgress); } @@ -383,7 +383,7 @@ internal VisualTreeFlattener(IMetroDrawingContext dc, Size pageSize, TreeWalkPro internal VisualTreeFlattener(System.Xml.XmlWriter resWriter, System.Xml.XmlWriter bodyWriter, PackageSerializationManager manager, Size pageSize, TreeWalkProgress treeWalkProgress) { Debug.Assert(treeWalkProgress != null); - + VisualSerializer dc = new VisualSerializer(resWriter, bodyWriter, manager); _dcf = new DrawingContextFlattener(dc, pageSize, treeWalkProgress); @@ -407,7 +407,7 @@ static int Complexity(System.Windows.Media.Drawing drawing) } DrawingGroup dg = drawing as DrawingGroup; - + if (dg != null) { if (Utility.IsTransparent(dg.Opacity)) @@ -511,7 +511,7 @@ internal bool StartVisual(Visual visual) FrameworkElement fe = visual as FrameworkElement; String nameAttr = null; - // we will presever the name for this element if + // we will presever the name for this element if // 1. It is FrameworkElement and Name is non empty. // 2. It is not FixedPage(because NameProperty of FixedPage is already reserved) // 3. It is not from template. TemplatedParent is null. @@ -525,7 +525,7 @@ internal bool StartVisual(Visual visual) } int dummy; // Some classes like DocumentViewer, in its visual tree, will implicitly generate - // some named elements. We will avoid create the duplicate names. + // some named elements. We will avoid create the duplicate names. if (_nameList.TryGetValue(fe.Name, out dummy) == false) { nameAttr = fe.Name; @@ -690,7 +690,7 @@ internal void DrawingWalk(System.Windows.Media.Drawing d, Matrix drawingToWorldT { return; } - + { GeometryDrawing gd = d as GeometryDrawing; @@ -701,7 +701,7 @@ internal void DrawingWalk(System.Windows.Media.Drawing d, Matrix drawingToWorldT return; } } - + { GlyphRunDrawing gd = d as GlyphRunDrawing; @@ -712,7 +712,7 @@ internal void DrawingWalk(System.Windows.Media.Drawing d, Matrix drawingToWorldT return; } } - + { ImageDrawing id = d as ImageDrawing; @@ -723,7 +723,7 @@ internal void DrawingWalk(System.Windows.Media.Drawing d, Matrix drawingToWorldT return; } } - + DrawingGroup dg = d as DrawingGroup; if (dg != null) @@ -769,7 +769,7 @@ internal void DrawingWalk(System.Windows.Media.Drawing d, Matrix drawingToWorldT } #if DEBUG - Console.WriteLine("Drawing of type '" + d.GetType() + "' not handled."); + Console.WriteLine($"Drawing of type '{d.GetType()}' not handled."); #endif } @@ -830,7 +830,7 @@ static internal void SaveAsXml(Visual visual, System.Xml.XmlWriter resWriter, Sy resWriter.WriteStartElement("Canvas.Resources"); resWriter.WriteStartElement("ResourceDictionary"); resWriter.WriteWhitespace("\r\n"); - + VisualTreeFlattener flattener = new VisualTreeFlattener(resWriter, bodyWriter, manager, new Size(8.5 * 96, 11 * 96), new TreeWalkProgress()); flattener.VisualWalk(visual); diff --git a/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/MetroSerializationManager.cs b/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/MetroSerializationManager.cs index 016a0b15033..5fc4605f372 100644 --- a/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/MetroSerializationManager.cs +++ b/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/MetroSerializationManager.cs @@ -820,7 +820,7 @@ Object serializableObject // MemberInfo memberInfo = dependencyProperty. OwnerType. - GetMethod("Get" + dependencyProperty.Name, + GetMethod($"Get{dependencyProperty.Name}", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.FlattenHierarchy); diff --git a/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/NGCSerializationManager.cs b/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/NGCSerializationManager.cs index 3fcd9622395..952d8f8d23b 100644 --- a/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/NGCSerializationManager.cs +++ b/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/NGCSerializationManager.cs @@ -822,9 +822,7 @@ XpsSerializationPrintTicketRequiredEventArgs args _fpPrintTicket = args.PrintTicket; // The NULL check might not be needed but just in case... - String printTicketPairXMLStr = - (_rootPrintTicket == null ? "" : _rootPrintTicket.ToXmlString()) + - (_fpPrintTicket == null ? "" : _fpPrintTicket.ToXmlString()); + string printTicketPairXMLStr = $"{_rootPrintTicket?.ToXmlString()}{_fpPrintTicket?.ToXmlString()}"; PrintTicket newActivePrintTicket; diff --git a/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/ReachDocumentSequenceSerializer.cs b/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/ReachDocumentSequenceSerializer.cs index 26aea135014..12c582d0a00 100644 --- a/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/ReachDocumentSequenceSerializer.cs +++ b/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/ReachDocumentSequenceSerializer.cs @@ -21,13 +21,13 @@ namespace System.Windows.Xps.Serialization { /// - /// + /// /// internal class DocumentSequenceSerializer : ReachSerializer { /// - /// + /// /// public DocumentSequenceSerializer( @@ -35,7 +35,7 @@ PackageSerializationManager manager ): base(manager) { - + } /// @@ -71,7 +71,7 @@ SerializableObjectContext serializableObjectContext // // Pick the data for the PrintTicket if it existed // - XpsSerializationPrintTicketRequiredEventArgs e = + XpsSerializationPrintTicketRequiredEventArgs e = new XpsSerializationPrintTicketRequiredEventArgs(PrintTicketLevel.FixedDocumentSequencePrintTicket, 0); @@ -103,7 +103,7 @@ SerializableObjectContext serializableObjectContext // // Signal to any registered callers that the Sequence has been serialized // - XpsSerializationProgressChangedEventArgs progressEvent = + XpsSerializationProgressChangedEventArgs progressEvent = new XpsSerializationProgressChangedEventArgs(XpsWritingProgressChangeLevel.FixedDocumentSequenceWritingProgress, 0, 0, @@ -115,9 +115,9 @@ SerializableObjectContext serializableObjectContext } ((IXpsSerializationManager)SerializationManager).OnXPSSerializationProgressChanged(progressEvent); } - + /// - /// + /// /// public override @@ -157,7 +157,7 @@ SerializablePropertyContext serializablePropertyContext attributeValue = GetValueOfAttributeAsString(serializablePropertyContext); - if ( (attributeValue != null) && + if ( (attributeValue != null) && (attributeValue.Length > 0) ) { // @@ -191,10 +191,7 @@ SerializablePropertyContext serializablePropertyContext if (propertyValue is Type) { int index = valueAsString.LastIndexOf('.'); - valueAsString = string.Concat( - XpsSerializationManager.TypeOfString, - index > 0 ? valueAsString.AsSpan(index + 1) : valueAsString, - "}"); + valueAsString = $"{XpsSerializationManager.TypeOfString}{(index > 0 ? valueAsString.AsSpan(index + 1) : valueAsString)}}}"; } } else @@ -206,5 +203,5 @@ SerializablePropertyContext serializablePropertyContext } }; } - + diff --git a/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/ReachDocumentSequenceSerializerAsync.cs b/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/ReachDocumentSequenceSerializerAsync.cs index 38ca303dda7..20d1de31db3 100644 --- a/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/ReachDocumentSequenceSerializerAsync.cs +++ b/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/ReachDocumentSequenceSerializerAsync.cs @@ -21,13 +21,13 @@ namespace System.Windows.Xps.Serialization { /// - /// + /// /// internal class DocumentSequenceSerializerAsync : ReachSerializerAsync { /// - /// + /// /// public DocumentSequenceSerializerAsync( @@ -35,7 +35,7 @@ PackageSerializationManager manager ): base(manager) { - + } public @@ -49,15 +49,15 @@ ReachSerializerContext context { } - - switch (context.Action) + + switch (context.Action) { case SerializerAction.endPersistObjectData: { EndPersistObjectData(); break; } - + default: { base.AsyncOperation(context); @@ -101,7 +101,7 @@ SerializableObjectContext serializableObjectContext if(serializableObjectContext.IsComplexValue) { - XpsSerializationPrintTicketRequiredEventArgs e = + XpsSerializationPrintTicketRequiredEventArgs e = new XpsSerializationPrintTicketRequiredEventArgs(PrintTicketLevel.FixedDocumentSequencePrintTicket, 0); @@ -140,7 +140,7 @@ SerializableObjectContext serializableObjectContext // // Signal to any registered callers that the Sequence has been serialized // - XpsSerializationProgressChangedEventArgs progressEvent = + XpsSerializationProgressChangedEventArgs progressEvent = new XpsSerializationProgressChangedEventArgs(XpsWritingProgressChangeLevel.FixedDocumentSequenceWritingProgress, 0, 0, @@ -153,9 +153,9 @@ SerializableObjectContext serializableObjectContext ((IXpsSerializationManager)SerializationManager).OnXPSSerializationProgressChanged(progressEvent); } - + /// - /// + /// /// public override @@ -195,7 +195,7 @@ SerializablePropertyContext serializablePropertyContext attributeValue = GetValueOfAttributeAsString(serializablePropertyContext); - if ( (attributeValue != null) && + if ( (attributeValue != null) && (attributeValue.Length > 0) ) { // @@ -229,10 +229,7 @@ SerializablePropertyContext serializablePropertyContext if (propertyValue is Type) { int index = valueAsString.LastIndexOf('.'); - valueAsString = string.Concat( - XpsSerializationManager.TypeOfString, - index > 0 ? valueAsString.AsSpan(index + 1) : valueAsString, - "}"); + valueAsString = $"{XpsSerializationManager.TypeOfString}{(index > 0 ? valueAsString.AsSpan(index + 1) : valueAsString)}}}"; } } else @@ -244,5 +241,5 @@ SerializablePropertyContext serializablePropertyContext } }; } - + diff --git a/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/ReachFixedDocumentSerializer.cs b/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/ReachFixedDocumentSerializer.cs index afa5e93deb7..c6c55b630e3 100644 --- a/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/ReachFixedDocumentSerializer.cs +++ b/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/ReachFixedDocumentSerializer.cs @@ -2,10 +2,10 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -/*++ +/*++ Abstract: This file contains the definition of a class that defines - the common functionality required to serialize a FixedDocument + the common functionality required to serialize a FixedDocument --*/ using System; using System.Collections; @@ -47,13 +47,13 @@ PackageSerializationManager manager ): base(manager) { - + } #endregion Constructor #region Public Methods - + /// /// The main method that is called to serialize a FixedDocument. /// @@ -86,11 +86,11 @@ Object serializedObject #endregion Public Methods #region Internal Methods - + /// /// The main method that is called to serialize the FixedDocument - /// and that is usually called from within the serialization manager - /// when a node in the graph of objects is at a turn where it should + /// and that is usually called from within the serialization manager + /// when a node in the graph of objects is at a turn where it should /// be serialized. /// /// @@ -121,7 +121,7 @@ SerializablePropertyContext serializedProperty } /// - /// The method is called once the object data is discovered at that + /// The method is called once the object data is discovered at that /// point of the serizlization process. /// /// @@ -142,7 +142,7 @@ SerializableObjectContext serializableObjectContext { (SerializationManager as XpsSerializationManager).RegisterDocumentStart(); } - + if(xmlnsForType == null) { XmlWriter.WriteStartElement(serializableObjectContext.Name); @@ -156,7 +156,7 @@ SerializableObjectContext serializableObjectContext { if(serializableObjectContext.IsComplexValue) { - XpsSerializationPrintTicketRequiredEventArgs e = + XpsSerializationPrintTicketRequiredEventArgs e = new XpsSerializationPrintTicketRequiredEventArgs(PrintTicketLevel.FixedDocumentPrintTicket, 0); @@ -195,7 +195,7 @@ SerializableObjectContext serializableObjectContext // // Signal to any registered callers that the Document has been serialized // - XpsSerializationProgressChangedEventArgs progressEvent = + XpsSerializationProgressChangedEventArgs progressEvent = new XpsSerializationProgressChangedEventArgs(XpsWritingProgressChangeLevel.FixedDocumentWritingProgress, 0, 0, @@ -208,7 +208,7 @@ SerializableObjectContext serializableObjectContext (SerializationManager as XpsSerializationManager).RegisterDocumentEnd(); } } - + /// /// This method is the one that writed out the attribute within /// the xml stream when serializing simple properties. @@ -229,7 +229,7 @@ SerializablePropertyContext serializablePropertyContext attributeValue = GetValueOfAttributeAsString(serializablePropertyContext); - if ( (attributeValue != null) && + if ( (attributeValue != null) && (attributeValue.Length > 0) ) { // @@ -241,7 +241,7 @@ SerializablePropertyContext serializablePropertyContext /// - /// Converts the Value of the Attribute to a String by calling into + /// Converts the Value of the Attribute to a String by calling into /// the appropriate type converters. /// /// @@ -271,10 +271,7 @@ SerializablePropertyContext serializablePropertyContext if (propertyValue is Type) { int index = valueAsString.LastIndexOf('.'); - valueAsString = string.Concat( - XpsSerializationManager.TypeOfString, - index > 0 ? valueAsString.AsSpan(index + 1) : valueAsString, - "}"); + valueAsString = $"{XpsSerializationManager.TypeOfString}{(index > 0 ? valueAsString.AsSpan(index + 1) : valueAsString)}}}"; } } else @@ -288,7 +285,7 @@ SerializablePropertyContext serializablePropertyContext #endregion Internal Methods #region Public Properties - + /// /// Queries / Set the XmlWriter for a FixedDocument /// @@ -318,5 +315,5 @@ SerializablePropertyContext serializablePropertyContext }; } - + diff --git a/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/ReachFixedDocumentSerializerAsync.cs b/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/ReachFixedDocumentSerializerAsync.cs index 16768d1df56..e54080a5bd6 100644 --- a/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/ReachFixedDocumentSerializerAsync.cs +++ b/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/ReachFixedDocumentSerializerAsync.cs @@ -2,11 +2,11 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -/*++ +/*++ Abstract: This file contains the definition of a class that defines the common functionality required to serialize a FixedDocument - + --*/ using System; using System.Collections; @@ -48,13 +48,13 @@ PackageSerializationManager manager ): base(manager) { - + } #endregion Constructor #region Public Methods - + public override void @@ -66,15 +66,15 @@ ReachSerializerContext context { } - - switch (context.Action) + + switch (context.Action) { case SerializerAction.endPersistObjectData: { EndPersistObjectData(); break; } - + default: { base.AsyncOperation(context); @@ -115,11 +115,11 @@ Object serializedObject #endregion Public Methods #region Internal Methods - + /// /// The main method that is called to serialize the FixedDocument - /// and that is usually called from within the serialization manager - /// when a node in the graph of objects is at a turn where it should + /// and that is usually called from within the serialization manager + /// when a node in the graph of objects is at a turn where it should /// be serialized. /// /// @@ -150,7 +150,7 @@ SerializablePropertyContext serializedProperty } /// - /// The method is called once the object data is discovered at that + /// The method is called once the object data is discovered at that /// point of the serizlization process. /// /// @@ -190,7 +190,7 @@ SerializableObjectContext serializableObjectContext ((IXpsSerializationManagerAsync)SerializationManager).OperationStack.Push(context); - XpsSerializationPrintTicketRequiredEventArgs e = + XpsSerializationPrintTicketRequiredEventArgs e = new XpsSerializationPrintTicketRequiredEventArgs(PrintTicketLevel.FixedDocumentPrintTicket, 0); @@ -227,7 +227,7 @@ SerializableObjectContext serializableObjectContext // Clear off the table from the packaging policy // ((XpsSerializationManager)SerializationManager).ResourcePolicy.ImageCrcTable = null; - + ((XpsSerializationManager)SerializationManager).ResourcePolicy.ImageUriHashTable = null; @@ -236,7 +236,7 @@ SerializableObjectContext serializableObjectContext // // Signal to any registered callers that the Document has been serialized // - XpsSerializationProgressChangedEventArgs progressEvent = + XpsSerializationProgressChangedEventArgs progressEvent = new XpsSerializationProgressChangedEventArgs(XpsWritingProgressChangeLevel.FixedDocumentWritingProgress, 0, 0, @@ -248,7 +248,7 @@ SerializableObjectContext serializableObjectContext (SerializationManager as XpsSerializationManager).RegisterDocumentEnd(); } } - + /// /// This method is the one that writed out the attribute within /// the xml stream when serializing simple properties. @@ -269,7 +269,7 @@ SerializablePropertyContext serializablePropertyContext attributeValue = GetValueOfAttributeAsString(serializablePropertyContext); - if ( (attributeValue != null) && + if ( (attributeValue != null) && (attributeValue.Length > 0) ) { // @@ -281,7 +281,7 @@ SerializablePropertyContext serializablePropertyContext /// - /// Converts the Value of the Attribute to a String by calling into + /// Converts the Value of the Attribute to a String by calling into /// the appropriate type converters. /// /// @@ -311,10 +311,7 @@ SerializablePropertyContext serializablePropertyContext if (propertyValue is Type) { int index = valueAsString.LastIndexOf('.'); - valueAsString = string.Concat( - XpsSerializationManager.TypeOfString, - index > 0 ? valueAsString.AsSpan(index + 1) : valueAsString, - "}"); + valueAsString = $"{XpsSerializationManager.TypeOfString}{(index > 0 ? valueAsString.AsSpan(index + 1) : valueAsString)}}}"; } } else @@ -328,7 +325,7 @@ SerializablePropertyContext serializablePropertyContext #endregion Internal Methods #region Public Properties - + /// /// Queries / Set the XmlWriter for a FixedDocument /// @@ -358,5 +355,5 @@ SerializablePropertyContext serializablePropertyContext }; } - + diff --git a/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/ReachFixedPageSerializer.cs b/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/ReachFixedPageSerializer.cs index 35b5488c919..352e3b571ab 100644 --- a/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/ReachFixedPageSerializer.cs +++ b/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/ReachFixedPageSerializer.cs @@ -344,10 +344,7 @@ SerializablePropertyContext serializablePropertyContext if (propertyValue is Type) { int index = valueAsString.LastIndexOf('.'); - valueAsString = string.Concat( - XpsSerializationManager.TypeOfString, - index > 0 ? valueAsString.AsSpan(index + 1) : valueAsString, - "}"); + valueAsString = $"{XpsSerializationManager.TypeOfString}{(index > 0 ? valueAsString.AsSpan(index + 1) : valueAsString)}}}"; } } else diff --git a/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/ReachFixedPageSerializerAsync.cs b/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/ReachFixedPageSerializerAsync.cs index ab53940fd7c..3c86b50fda1 100644 --- a/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/ReachFixedPageSerializerAsync.cs +++ b/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/ReachFixedPageSerializerAsync.cs @@ -3,13 +3,13 @@ // See the LICENSE file in the project root for more information. /*++ - - + + Abstract: This file contains the definition of a class that - defines the common functionality required to serialize + defines the common functionality required to serialize a FixedPage - + --*/ using System; using System.Collections; @@ -52,13 +52,13 @@ PackageSerializationManager manager ): base(manager) { - + } #endregion Constructor - + #region Public Methods - + public override void @@ -68,7 +68,7 @@ ReachSerializerContext context { if(context != null) { - switch (context.Action) + switch (context.Action) { case SerializerAction.endPersistObjectData: { @@ -126,11 +126,11 @@ Object serializedObject #endregion Public Methods #region Internal Methods - + /// /// The main method that is called to serialize the FixedPage - /// and that is usually called from within the serialization manager - /// when a node in the graph of objects is at a turn where it should + /// and that is usually called from within the serialization manager + /// when a node in the graph of objects is at a turn where it should /// be serialized. /// /// @@ -159,7 +159,7 @@ SerializablePropertyContext serializedProperty } /// - /// The method is called once the object data is discovered at that + /// The method is called once the object data is discovered at that /// point of the serialization process. /// /// @@ -193,7 +193,7 @@ SerializableObjectContext serializableObjectContext else { XmlWriter.WriteStartElement(serializableObjectContext.Name); - + XmlWriter.WriteAttributeString(XpsS0Markup.Xmlns, xmlnsForType); XmlWriter.WriteAttributeString(XpsS0Markup.XmlnsX, XpsS0Markup.XmlnsXSchema); @@ -211,9 +211,9 @@ SerializableObjectContext serializableObjectContext { Size fixedPageSize = new Size(fixedPage.Width, fixedPage.Height); ((IXpsSerializationManager)SerializationManager).FixedPageSize = fixedPageSize; - + // - // Before we serialize any properties on the FixedPage, we need to + // Before we serialize any properties on the FixedPage, we need to // serialize the FixedPage as a Visual // Visual fixedPageAsVisual = serializableObjectContext.TargetObject as Visual; @@ -236,7 +236,7 @@ SerializableObjectContext serializableObjectContext ((IXpsSerializationManagerAsync)SerializationManager).OperationStack.Push(context); PrintTicket printTicket = ((IXpsSerializationManager)SerializationManager).FixedPagePrintTicket; - + if(printTicket != null) { PrintTicketSerializer serializer = new PrintTicketSerializer(SerializationManager); @@ -275,7 +275,7 @@ SerializablePropertyContext serializablePropertyContext attributeValue = GetValueOfAttributeAsString(serializablePropertyContext); - if ( (attributeValue != null) && + if ( (attributeValue != null) && (attributeValue.Length > 0) ) { // @@ -286,7 +286,7 @@ SerializablePropertyContext serializablePropertyContext } /// - /// Converts the Value of the Attribute to a String by calling into + /// Converts the Value of the Attribute to a String by calling into /// the appropriate type converters. /// /// @@ -316,10 +316,7 @@ SerializablePropertyContext serializablePropertyContext if (propertyValue is Type) { int index = valueAsString.LastIndexOf('.'); - valueAsString = string.Concat( - XpsSerializationManager.TypeOfString, - index > 0 ? valueAsString.AsSpan(index + 1) : valueAsString, - "}"); + valueAsString = $"{XpsSerializationManager.TypeOfString}{(index > 0 ? valueAsString.AsSpan(index + 1) : valueAsString)}}}"; } } else @@ -331,9 +328,9 @@ SerializablePropertyContext serializablePropertyContext } #endregion Internal Methods - + #region Public Properties - + /// /// Queries / Set the XmlWriter for a FixedPage. /// @@ -360,7 +357,7 @@ SerializablePropertyContext serializablePropertyContext } #endregion Public Properties - + #region Private Methods private @@ -423,7 +420,7 @@ ReachFixedPageSerializerContext context XmlWriter.WriteEndElement(); // - //Release used resources + //Release used resources // XmlWriter = null; // @@ -438,7 +435,7 @@ ReachFixedPageSerializerContext context // // Signal to any registered callers that the Page has been serialized // - XpsSerializationProgressChangedEventArgs progressEvent = + XpsSerializationProgressChangedEventArgs progressEvent = new XpsSerializationProgressChangedEventArgs(XpsWritingProgressChangeLevel.FixedPageWritingProgress, 0, 0, diff --git a/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/XpsOMFixedPageSerializer.cs b/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/XpsOMFixedPageSerializer.cs index 92cb093a8ea..5bf90bcb37d 100644 --- a/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/XpsOMFixedPageSerializer.cs +++ b/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/XpsOMFixedPageSerializer.cs @@ -39,7 +39,7 @@ PackageSerializationManager manager { /// /// Fail if manager is not XpsOMSerializationManager - /// + /// _xpsOMSerializationManager = (XpsOMSerializationManager)manager; } @@ -148,7 +148,7 @@ SerializableObjectContext serializableObjectContext treeWalker = new ReachTreeWalker(this); treeWalker.SerializeLinksInFixedPage((FixedPage)serializableObjectContext.TargetObject); - + String xmlnsForType = SerializationManager.GetXmlNSForType(serializableObjectContext.TargetObject.GetType()); if (xmlnsForType == null) @@ -302,10 +302,7 @@ SerializablePropertyContext serializablePropertyContext if (propertyValue is Type) { int index = valueAsString.LastIndexOf('.'); - valueAsString = string.Concat( - XpsSerializationManager.TypeOfString, - index > 0 ? valueAsString.AsSpan(index + 1) : valueAsString, - "}"); + valueAsString = $"{XpsSerializationManager.TypeOfString}{(index > 0 ? valueAsString.AsSpan(index + 1) : valueAsString)}}}"; } } else diff --git a/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/XpsOMPackagingPolicy.cs b/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/XpsOMPackagingPolicy.cs index 0c237ebf775..539766fa7b2 100644 --- a/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/XpsOMPackagingPolicy.cs +++ b/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/manager/XpsOMPackagingPolicy.cs @@ -776,7 +776,7 @@ Uri uri Uri GenerateUriForObfuscatedFont() { - String uniqueUri = "/Resources/" + Guid.NewGuid().ToString() + XpsS0Markup.ObfuscatedFontExt; + String uniqueUri = $"/Resources/{Guid.NewGuid()}{XpsS0Markup.ObfuscatedFontExt}"; Uri uri = PackUriHelper.CreatePartUri(new Uri(uniqueUri, UriKind.Relative)); return uri; } diff --git a/src/Microsoft.DotNet.Wpf/src/Shared/MS/Internal/IO/Packaging/PackagingUtilities.cs b/src/Microsoft.DotNet.Wpf/src/Shared/MS/Internal/IO/Packaging/PackagingUtilities.cs index 19789212122..68b95b12bb6 100644 --- a/src/Microsoft.DotNet.Wpf/src/Shared/MS/Internal/IO/Packaging/PackagingUtilities.cs +++ b/src/Microsoft.DotNet.Wpf/src/Shared/MS/Internal/IO/Packaging/PackagingUtilities.cs @@ -539,7 +539,7 @@ private static bool UserHasProfile() { // inspect registry and look for user profile via SID string userSid = System.Security.Principal.WindowsIdentity.GetCurrent().User.Value; - userProfileKey = Registry.LocalMachine.OpenSubKey(_profileListKeyName + @"\" + userSid); + userProfileKey = Registry.LocalMachine.OpenSubKey($@"{_profileListKeyName}\{userSid}"); userHasProfile = userProfileKey != null; } finally @@ -839,6 +839,6 @@ void CheckDisposed() /// ProfileListKeyName /// private const string _profileListKeyName = @"SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList"; - private const string _fullProfileListKeyName = @"HKEY_LOCAL_MACHINE\" + _profileListKeyName; + private const string _fullProfileListKeyName = $@"HKEY_LOCAL_MACHINE\{_profileListKeyName}"; } } diff --git a/src/Microsoft.DotNet.Wpf/src/Shared/MS/Internal/Invariant.cs b/src/Microsoft.DotNet.Wpf/src/Shared/MS/Internal/Invariant.cs index d4b4a5a84ce..d9d73f81363 100644 --- a/src/Microsoft.DotNet.Wpf/src/Shared/MS/Internal/Invariant.cs +++ b/src/Microsoft.DotNet.Wpf/src/Shared/MS/Internal/Invariant.cs @@ -18,13 +18,13 @@ namespace MS.Internal { using System; - using System.Security; + using System.Security; using Microsoft.Win32; using System.Diagnostics; using System.Windows; - + /// - /// Provides methods that assert an application is in a valid state. + /// Provides methods that assert an application is in a valid state. /// [FriendAccessAllowed] // Built into Base, used by Framework. internal // DO NOT MAKE PUBLIC - See security notes on Assert @@ -187,7 +187,7 @@ internal static bool Strict /// /// Shuts down the process immediately, with no chance for additional /// code to run. - /// + /// /// In debug we raise a Debug.Assert dialog before shutting down. /// /// @@ -207,7 +207,7 @@ static void FailFast(string message, string detailMessage) Debugger.Break(); } - Debug.Assert(false, "Invariant failure: " + message, detailMessage); + Debug.Fail($"Invariant failure: {message}", detailMessage); Environment.FailFast(SR.InvariantFailure); } diff --git a/src/Microsoft.DotNet.Wpf/src/Shared/MS/Internal/MatrixUtil.cs b/src/Microsoft.DotNet.Wpf/src/Shared/MS/Internal/MatrixUtil.cs index 14757411837..1442a54ec49 100644 --- a/src/Microsoft.DotNet.Wpf/src/Shared/MS/Internal/MatrixUtil.cs +++ b/src/Microsoft.DotNet.Wpf/src/Shared/MS/Internal/MatrixUtil.cs @@ -240,7 +240,7 @@ internal static void MultiplyMatrix(ref Matrix matrix1, ref Matrix matrix2) return; #if DEBUG default: - Debug.Fail("Matrix multiply hit an invalid case: " + combinedType); + Debug.Fail($"Matrix multiply hit an invalid case: {combinedType}"); break; #endif } diff --git a/src/Microsoft.DotNet.Wpf/src/Shared/MS/Internal/Registry.cs b/src/Microsoft.DotNet.Wpf/src/Shared/MS/Internal/Registry.cs index a4d1d855005..ad0560259c7 100644 --- a/src/Microsoft.DotNet.Wpf/src/Shared/MS/Internal/Registry.cs +++ b/src/Microsoft.DotNet.Wpf/src/Shared/MS/Internal/Registry.cs @@ -19,7 +19,7 @@ internal static class RegistryKeys internal const string WPF = @"Software\Microsoft\.NETFramework\Windows Presentation Foundation", - WPF_Features = WPF+"\\Features", + WPF_Features = $"{WPF}\\Features", value_MediaImageDisallow = "MediaImageDisallow", value_MediaVideoDisallow = "MediaVideoDisallow", value_MediaAudioDisallow = "MediaAudioDisallow", @@ -27,7 +27,7 @@ internal const string value_ScriptInteropDisallow = "ScriptInteropDisallow", value_AutomationWeakReferenceDisallow = "AutomationWeakReferenceDisallow", - WPF_Hosting = WPF+"\\Hosting", + WPF_Hosting = $"{WPF}\\Hosting", value_DisableXbapErrorPage = "DisableXbapErrorPage", value_UnblockWebBrowserControl = "UnblockWebBrowserControl", @@ -40,12 +40,12 @@ internal const string // wpf\src\Shared\Cpp\Utils.cxx // Should these reg keys change the above file should be also modified to reflect that. FRAMEWORK_RegKey = @"Software\Microsoft\Net Framework Setup\NDP\v4\Client\", - FRAMEWORK_RegKey_FullPath = @"HKEY_LOCAL_MACHINE\" + FRAMEWORK_RegKey, + FRAMEWORK_RegKey_FullPath = $@"HKEY_LOCAL_MACHINE\{FRAMEWORK_RegKey}", FRAMEWORK_InstallPath_RegValue = "InstallPath"; internal static bool ReadLocalMachineBool(string key, string valueName) { - string keyPath = "HKEY_LOCAL_MACHINE\\" + key; + string keyPath = $"HKEY_LOCAL_MACHINE\\{key}"; object value = Registry.GetValue(keyPath, valueName, null); return value is int && (int)value != 0; } diff --git a/src/Microsoft.DotNet.Wpf/src/Shared/MS/Internal/TextServicesLoader.cs b/src/Microsoft.DotNet.Wpf/src/Shared/MS/Internal/TextServicesLoader.cs index 355c3a67d2c..2c7dc60a792 100644 --- a/src/Microsoft.DotNet.Wpf/src/Shared/MS/Internal/TextServicesLoader.cs +++ b/src/Microsoft.DotNet.Wpf/src/Shared/MS/Internal/TextServicesLoader.cs @@ -3,12 +3,12 @@ // See the LICENSE file in the project root for more information. // -// +// // // Description: Creates ITfThreadMgr instances, the root object of the Text // Services Framework. // -// +// // // @@ -53,7 +53,7 @@ internal class TextServicesLoader private TextServicesLoader() {} #endregion Constructors - + //------------------------------------------------------ // // Public Methods @@ -77,7 +77,7 @@ private TextServicesLoader() {} // Protected Methods // //------------------------------------------------------ - + //------------------------------------------------------ // // Internal Methods @@ -91,7 +91,7 @@ private TextServicesLoader() {} //------------------------------------------------------ #region Internal Properties - + /// /// Loads an instance of the Text Services Framework. /// @@ -101,7 +101,7 @@ private TextServicesLoader() {} internal static UnsafeNativeMethods.ITfThreadMgr Load() { UnsafeNativeMethods.ITfThreadMgr threadManager; - + Invariant.Assert(Thread.CurrentThread.GetApartmentState() == ApartmentState.STA, "Load called on MTA thread!"); if (ServicesInstalled) @@ -228,13 +228,13 @@ private static EnableState SingleTIPWantsToRun(RegistryKey keyLocalMachine, stri // Loop through all the langid entries for TIP. // First, check current user. - result = IterateSubKeys(Registry.CurrentUser, "SOFTWARE\\Microsoft\\CTF\\TIP\\" + subKeyName + "\\LanguageProfile", new IterateHandler(IsLangidEnabled), false); + result = IterateSubKeys(Registry.CurrentUser, $"SOFTWARE\\Microsoft\\CTF\\TIP\\{subKeyName}\\LanguageProfile", new IterateHandler(IsLangidEnabled), false); // Any explicit value short circuits the process. // Otherwise check local machine. if (result == EnableState.None || result == EnableState.Error) { - result = IterateSubKeys(keyLocalMachine, subKeyName + "\\LanguageProfile", new IterateHandler(IsLangidEnabled), true); + result = IterateSubKeys(keyLocalMachine, $"{subKeyName}\\LanguageProfile", new IterateHandler(IsLangidEnabled), true); if (result == EnableState.None) { @@ -346,7 +346,7 @@ private static EnableState IterateSubKeys(RegistryKey keyBase, string subKey, It // Status of a TIP assembly. private enum EnableState - { + { Error, // Invalid entry. None, // No explicit Enable entry on the assembly. Enabled, // Assembly is enabled. @@ -358,7 +358,7 @@ private enum EnableState // Install state. private enum InstallState - { + { Unknown, // Haven't checked to see if any TIPs are installed yet. Installed, // Checked and installed. NotInstalled // Checked and not installed. diff --git a/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/HwndWrapper.cs b/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/HwndWrapper.cs index c6672b0fede..621d1a8474f 100644 --- a/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/HwndWrapper.cs +++ b/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/HwndWrapper.cs @@ -337,7 +337,7 @@ private void CheckForCreateWindowFailure( IntPtr result, bool handled ) if( IntPtr.Zero != result ) { - System.Diagnostics.Debug.WriteLine("Non-zero WndProc result=" + result); + System.Diagnostics.Debug.WriteLine($"Non-zero WndProc result={result}"); if( handled ) { if( System.Diagnostics.Debugger.IsAttached ) diff --git a/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/NativeMethodsCLR.cs b/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/NativeMethodsCLR.cs index f71435eafa1..4be52e01b2c 100644 --- a/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/NativeMethodsCLR.cs +++ b/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/NativeMethodsCLR.cs @@ -3006,7 +3006,7 @@ public POINT(int x, int y) { } #if DEBUG public override string ToString() { - return "{x=" + x + ", y=" + y + "}"; + return $"{{x={x}, y={y}}}"; } #endif } @@ -4041,7 +4041,7 @@ public void CopyTo(COMRECT destRect) { // } public override string ToString() { - return "Left = " + left + " Top " + top + " Right = " + right + " Bottom = " + bottom; + return $"Left = {left} Top {top} Right = {right} Bottom = {bottom}"; } } diff --git a/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/UnsafeNativeMethodsCLR.cs b/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/UnsafeNativeMethodsCLR.cs index 3f7a7a66582..4fa70b349a5 100644 --- a/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/UnsafeNativeMethodsCLR.cs +++ b/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/UnsafeNativeMethodsCLR.cs @@ -131,10 +131,7 @@ public static bool DeleteObjectNoThrow(HandleRef hObject) bool result = IntDeleteObject(hObject); int error = Marshal.GetLastWin32Error(); - if(!result) - { - Debug.WriteLine("DeleteObject failed. Error = " + error); - } + Debug.WriteLineIf(!result, $"DeleteObject failed. Error = {error}"); return result; } @@ -340,10 +337,7 @@ public static bool CloseHandleNoThrow(HandleRef handle) bool result = IntCloseHandle(handle); int error = Marshal.GetLastWin32Error(); - if(!result) - { - Debug.WriteLine("CloseHandle failed. Error = " + error); - } + Debug.WriteLineIf(!result, $"CloseHandle failed. Error = {error}"); return result; } @@ -390,10 +384,7 @@ public static bool UnmapViewOfFileNoThrow(HandleRef pvBaseAddress) bool result = IntUnmapViewOfFile(pvBaseAddress); int error = Marshal.GetLastWin32Error(); - if(!result) - { - Debug.WriteLine("UnmapViewOfFile failed. Error = " + error); - } + Debug.WriteLineIf(!result, $"UnmapViewOfFile failed. Error = {error}"); return result; } @@ -711,68 +702,68 @@ internal enum LoadLibraryFlags : uint { None = 0x00000000, /// - /// If this value is used, and the executable module is a DLL, the system does - /// not call DllMain for process and thread initialization and termination. - /// Also, the system does not load additional executable modules that are + /// If this value is used, and the executable module is a DLL, the system does + /// not call DllMain for process and thread initialization and termination. + /// Also, the system does not load additional executable modules that are /// referenced by the specified module. /// /// - /// Do not use this value; it is provided only for backward compatibility. - /// If you are planning to access only data or resources in the DLL, use - /// or + /// Do not use this value; it is provided only for backward compatibility. + /// If you are planning to access only data or resources in the DLL, use + /// or /// or - /// or both. Otherwise, load the library as a DLL or executable module + /// or both. Otherwise, load the library as a DLL or executable module /// using the function. /// DONT_RESOLVE_DLL_REFERENCES = 0x00000001, /// - /// If this value is used, the system does not check AppLocker rules or apply - /// Software Restriction Policies for the DLL. This action applies only to the - /// DLL being loaded and not to its dependencies. This value is recommended + /// If this value is used, the system does not check AppLocker rules or apply + /// Software Restriction Policies for the DLL. This action applies only to the + /// DLL being loaded and not to its dependencies. This value is recommended /// for use in setup programs that must run extracted DLLs during installation. /// /// - /// Windows Server 2008 R2 and Windows 7: - /// On systems with KB2532445 installed, the - /// caller must be running as "LocalSystem" or "TrustedInstaller"; otherwise the - /// system ignores this flag. For more information, see "You can circumvent AppLocker - /// rules by using an Office macro on a computer that is running Windows 7 or - /// Windows Server 2008 R2" in the Help and Support Knowledge Base + /// Windows Server 2008 R2 and Windows 7: + /// On systems with KB2532445 installed, the + /// caller must be running as "LocalSystem" or "TrustedInstaller"; otherwise the + /// system ignores this flag. For more information, see "You can circumvent AppLocker + /// rules by using an Office macro on a computer that is running Windows 7 or + /// Windows Server 2008 R2" in the Help and Support Knowledge Base /// at - /// - /// Windows Server 2008, Windows Vista, Windows Server 2003 and Windows XP: + /// + /// Windows Server 2008, Windows Vista, Windows Server 2003 and Windows XP: /// AppLocker was introduced in Windows 7 and Windows Server 2008 R2. /// LOAD_IGNORE_CODE_AUTHZ_LEVEL = 0x00000010, /// - /// If this value is used, the system maps the file into the calling process's - /// virtual address space as if it were a data file. Nothing is done to execute - /// or prepare to execute the mapped file. Therefore, you cannot call functions - /// like GetModuleFileName, GetModuleHandle or GetProcAddress with this DLL. - /// Using this value causes writes to read-only memory to raise an access violation. - /// Use this flag when you want to load a DLL only to extract messages or resources + /// If this value is used, the system maps the file into the calling process's + /// virtual address space as if it were a data file. Nothing is done to execute + /// or prepare to execute the mapped file. Therefore, you cannot call functions + /// like GetModuleFileName, GetModuleHandle or GetProcAddress with this DLL. + /// Using this value causes writes to read-only memory to raise an access violation. + /// Use this flag when you want to load a DLL only to extract messages or resources /// from it.This value can be used with . /// LOAD_LIBRARY_AS_DATAFILE = 0x00000002, /// - /// Similar to LOAD_LIBRARY_AS_DATAFILE, except that the DLL file is opened with - /// exclusive write access for the calling process. Other processes cannot open - /// the DLL file for write access while it is in use. However, the DLL can - /// still be opened by other processes. This value can be used with - /// . + /// Similar to LOAD_LIBRARY_AS_DATAFILE, except that the DLL file is opened with + /// exclusive write access for the calling process. Other processes cannot open + /// the DLL file for write access while it is in use. However, the DLL can + /// still be opened by other processes. This value can be used with + /// . /// /// - /// Windows Server 2003 and Windows XP: This value is not supported until + /// Windows Server 2003 and Windows XP: This value is not supported until /// Windows Vista. /// LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE = 0x00000040, /// - /// If this value is used, the system maps the file into the process's virtual - /// address space as an image file. However, the loader does not load the static - /// imports or perform the other usual initialization steps. Use this flag when - /// you want to load a DLL only to extract messages or resources from it. Unless - /// the application depends on the file having the in-memory layout of an image, - /// this value should be used with either or + /// If this value is used, the system maps the file into the process's virtual + /// address space as an image file. However, the loader does not load the static + /// imports or perform the other usual initialization steps. Use this flag when + /// you want to load a DLL only to extract messages or resources from it. Unless + /// the application depends on the file having the in-memory layout of an image, + /// this value should be used with either or /// . /// /// @@ -780,86 +771,86 @@ internal enum LoadLibraryFlags : uint /// LOAD_LIBRARY_AS_IMAGE_RESOURCE = 0x00000020, /// - /// If this value is used, the application's installation directory is searched for the - /// DLL and its dependencies. Directories in the standard search path are not searched. + /// If this value is used, the application's installation directory is searched for the + /// DLL and its dependencies. Directories in the standard search path are not searched. /// This value cannot be combined with . /// /// - /// Windows 7, Windows Server 2008 R2, Windows Vista and Windows Server 2008: + /// Windows 7, Windows Server 2008 R2, Windows Vista and Windows Server 2008: /// This value requires KB2533623 to be installed. - /// Windows Server 2003 and Windows XP: + /// Windows Server 2003 and Windows XP: /// This value is not supported. /// LOAD_LIBRARY_SEARCH_APPLICATION_DIR = 0x00000200, /// - /// This value is a combination of , - /// , and . - /// Directories in the standard search path are not searched. This value cannot be combined with - /// . This value represents the recommended maximum number + /// This value is a combination of , + /// , and . + /// Directories in the standard search path are not searched. This value cannot be combined with + /// . This value represents the recommended maximum number /// of directories an application should include in its DLL search path. /// /// - /// Windows 7, Windows Server 2008 R2, Windows Vista and Windows Server 2008: - /// This value requires KB2533623 to be installed. - /// - /// Windows Server 2003 and Windows XP: + /// Windows 7, Windows Server 2008 R2, Windows Vista and Windows Server 2008: + /// This value requires KB2533623 to be installed. + /// + /// Windows Server 2003 and Windows XP: /// This value is not supported. /// LOAD_LIBRARY_SEARCH_DEFAULT_DIRS = 0x00001000, /// - /// If this value is used, the directory that contains the DLL is temporarily added to - /// the beginning of the list of directories that are searched for the DLL's dependencies. + /// If this value is used, the directory that contains the DLL is temporarily added to + /// the beginning of the list of directories that are searched for the DLL's dependencies. /// Directories in the standard search path are not searched. - /// - /// The lpFileName parameter must specify a fully qualified path. This value cannot be - /// combined with . - /// - /// For example, if Lib2.dll is a dependency of C:\Dir1\Lib1.dll, loading Lib1.dll with - /// this value causes the system to search for Lib2.dll only in C:\Dir1. To search for - /// Lib2.dll in C:\Dir1 and all of the directories in the DLL search path, combine this + /// + /// The lpFileName parameter must specify a fully qualified path. This value cannot be + /// combined with . + /// + /// For example, if Lib2.dll is a dependency of C:\Dir1\Lib1.dll, loading Lib1.dll with + /// this value causes the system to search for Lib2.dll only in C:\Dir1. To search for + /// Lib2.dll in C:\Dir1 and all of the directories in the DLL search path, combine this /// value with . /// /// - /// Windows 7, Windows Server 2008 R2, Windows Vista and Windows Server 2008: + /// Windows 7, Windows Server 2008 R2, Windows Vista and Windows Server 2008: /// This value requires KB2533623 to be installed. - /// - /// Windows Server 2003 and Windows XP: + /// + /// Windows Server 2003 and Windows XP: /// This value is not supported. /// LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR = 0x00000100, /// - /// If this value is used, %windows%\system32 is searched for the DLL and its dependencies. - /// Directories in the standard search path are not searched. This value cannot be + /// If this value is used, %windows%\system32 is searched for the DLL and its dependencies. + /// Directories in the standard search path are not searched. This value cannot be /// combined with /// /// - /// Windows 7, Windows Server 2008 R2, Windows Vista and Windows Server 2008: + /// Windows 7, Windows Server 2008 R2, Windows Vista and Windows Server 2008: /// This value requires KB2533623 to be installed. - /// Windows Server 2003 and Windows XP: + /// Windows Server 2003 and Windows XP: /// This value is not supported. /// LOAD_LIBRARY_SEARCH_SYSTEM32 = 0x00000800, /// - /// If this value is used, directories added using the AddDllDirectory or the SetDllDirectory - /// function are searched for the DLL and its dependencies. If more than one directory has been added, - /// the order in which the directories are searched is unspecified. Directories in the - /// standard search path are not searched. This value cannot be combined with + /// If this value is used, directories added using the AddDllDirectory or the SetDllDirectory + /// function are searched for the DLL and its dependencies. If more than one directory has been added, + /// the order in which the directories are searched is unspecified. Directories in the + /// standard search path are not searched. This value cannot be combined with /// /// /// - /// Windows 7, Windows Server 2008 R2, Windows Vista and Windows Server 2008: + /// Windows 7, Windows Server 2008 R2, Windows Vista and Windows Server 2008: /// This value requires KB2533623 to be installed. - /// Windows Server 2003 and Windows XP: + /// Windows Server 2003 and Windows XP: /// This value is not supported. /// LOAD_LIBRARY_SEARCH_USER_DIRS = 0x00000400, /// - /// If this value is used and lpFileName specifies an absolute path, the system uses the alternate - /// file search strategy discussed in the Remarks section to find associated executable modules that - /// the specified module causes to be loaded. If this value is used and lpFileName specifies a - /// relative path, the behavior is undefined. If this value is not used, or if lpFileName does not specify a path, - /// the system uses the standard search strategy discussed in the Remarks section to find associated - /// executable modules that the specified module causes to be loaded.This value cannot be combined with + /// If this value is used and lpFileName specifies an absolute path, the system uses the alternate + /// file search strategy discussed in the Remarks section to find associated executable modules that + /// the specified module causes to be loaded. If this value is used and lpFileName specifies a + /// relative path, the behavior is undefined. If this value is not used, or if lpFileName does not specify a path, + /// the system uses the standard search strategy discussed in the Remarks section to find associated + /// executable modules that the specified module causes to be loaded.This value cannot be combined with /// any LOAD_LIBRARY_SEARCH flag. /// LOAD_WITH_ALTERED_SEARCH_PATH = 0x00000008 @@ -877,19 +868,19 @@ internal enum GetModuleHandleFlags : uint { None = 0x00000000, /// - /// The lpModuleName parameter in is an address + /// The lpModuleName parameter in is an address /// in the module. /// GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS = 0x00000004, /// - /// The module stays loaded until the process is terminated, no matter how many times + /// The module stays loaded until the process is terminated, no matter how many times /// FreeLibrary is called. /// This option cannot be used with . /// GET_MODULE_HANDLE_EX_FLAG_PIN = 0x00000001, /// - /// The reference count for the module is not incremented. This option is equivalent to the - /// behavior of GetModuleHandle. Do not pass the retrieved module handle to the FreeLibrary + /// The reference count for the module is not incremented. This option is equivalent to the + /// behavior of GetModuleHandle. Do not pass the retrieved module handle to the FreeLibrary /// function; doing so can cause the DLL to be unmapped prematurely. /// This option cannot be used with . /// @@ -1048,7 +1039,7 @@ public static int ReleaseDC(HandleRef hWnd, HandleRef hDC) { public static extern IntPtr SetActiveWindow(HandleRef hWnd); //Refactor shared native methods so that parser dependency - // is in separate file. + // is in separate file. #if PBTCOMPILER [DllImport(ExternDll.User32, ExactSpelling=true, CharSet=CharSet.Auto)] public static extern IntPtr SetCursor(HandleRef hcursor); @@ -1070,15 +1061,15 @@ public static bool DestroyIcon(IntPtr hIcon) bool result = IntDestroyIcon(hIcon); int error = Marshal.GetLastWin32Error(); - if(!result) - { - // To be consistent with out other PInvoke wrappers - // we should "throw" here. But we don't want to - // introduce new "throws" w/o time to follow up on any - // new problems that causes. - Debug.WriteLine("DestroyIcon failed. Error = " + error); + // To be consistent with out other PInvoke wrappers + // we should "throw" here. But we don't want to + // introduce new "throws" w/o time to follow up on any + // new problems that causes. + Debug.WriteLineIf(!result, $"DestroyIcon failed. Error = {error}"); + // if(!result) + // { //throw new Win32Exception(); - } + // } return result; } @@ -1091,15 +1082,15 @@ public static bool DeleteObject(IntPtr hObject) bool result = IntDeleteObject(hObject); int error = Marshal.GetLastWin32Error(); - if(!result) - { - // To be consistent with out other PInvoke wrappers - // we should "throw" here. But we don't want to - // introduce new "throws" w/o time to follow up on any - // new problems that causes. - Debug.WriteLine("DeleteObject failed. Error = " + error); + // To be consistent with out other PInvoke wrappers + // we should "throw" here. But we don't want to + // introduce new "throws" w/o time to follow up on any + // new problems that causes. + Debug.WriteLineIf(!result, $"DeleteObject failed. Error = {error}"); + // if(!result) + // { //throw new Win32Exception(); - } + // } return result; } @@ -1118,10 +1109,7 @@ internal static NativeMethods.BitmapHandle CreateDIBSection(HandleRef hdc, ref N NativeMethods.BitmapHandle hBitmap = PrivateCreateDIBSection(hdc, ref bitmapInfo, iUsage, ref ppvBits, hSection, dwOffset); int error = Marshal.GetLastWin32Error(); - if ( hBitmap.IsInvalid ) - { - Debug.WriteLine("CreateDIBSection failed. Error = " + error); - } + Debug.WriteLineIf(hBitmap.IsInvalid, $"CreateDIBSection failed. Error = {error}"); return hBitmap; } @@ -1134,10 +1122,7 @@ internal static NativeMethods.BitmapHandle CreateBitmap(int width, int height, i NativeMethods.BitmapHandle hBitmap = PrivateCreateBitmap(width, height, planes, bitsPerPixel, lpvBits); int error = Marshal.GetLastWin32Error(); - if ( hBitmap.IsInvalid ) - { - Debug.WriteLine("CreateBitmap failed. Error = " + error); - } + Debug.WriteLineIf(hBitmap.IsInvalid, $"CreateBitmap failed. Error = {error}"); return hBitmap; } @@ -1151,10 +1136,7 @@ internal static bool DestroyIcon(HandleRef handle) bool result = PrivateDestroyIcon(handle); int error = Marshal.GetLastWin32Error(); - if ( !result ) - { - Debug.WriteLine("DestroyIcon failed. Error = " + error); - } + Debug.WriteLineIf(!result, $"DestroyIcon failed. Error = {error}"); return result; } @@ -1166,10 +1148,7 @@ internal static NativeMethods.IconHandle CreateIconIndirect([In, MarshalAs(Unman NativeMethods.IconHandle hIcon = PrivateCreateIconIndirect(iconInfo); int error = Marshal.GetLastWin32Error(); - if ( hIcon.IsInvalid ) - { - Debug.WriteLine("CreateIconIndirect failed. Error = " + error); - } + Debug.WriteLineIf(hIcon.IsInvalid, $"CreateIconIndirect failed. Error = {error}"); return hIcon; } @@ -3067,7 +3046,7 @@ public static extern uint GetRawInputDeviceInfo( /// /// /// Use this API to change the DPI_AWARENESS_CONTEXT for the thread from the default value for the app. - /// + /// /// Minimum supported client: Windows 10, version 1607 (RS1) /// [DllImport(ExternDll.User32, CallingConvention = CallingConvention.Winapi)] @@ -3081,7 +3060,7 @@ public static extern uint GetRawInputDeviceInfo( /// This method will return the latest DPI_AWARENESS_CONTEXT sent to SetThreadDpiAwarenessContext. /// If SetThreadDpiAwarenessContext was never called for this thread, then the return value will equal /// the default DPI_AWARENESS_CONTEXT for the process. - /// + /// /// Minimum supported client: Windows 10, version 1607 (RS1) /// [DllImport(ExternDll.User32, CallingConvention = CallingConvention.Winapi)] @@ -3098,7 +3077,7 @@ public static extern uint GetRawInputDeviceInfo( /// /// /// A handle to a display device context that defines the visible region of interest. - /// + /// /// If this parameter is NULL, the hdcMonitor parameter passed to the callback function /// will be NULL, and the visible region of interest is the virtual screen that encompasses all /// the displays on the desktop. @@ -3106,10 +3085,10 @@ public static extern uint GetRawInputDeviceInfo( /// /// A pointer to a RECT structure that specifies a clipping rectangle. The region of interest /// is the intersection of the clipping rectangle with the visible region specified by hdc. - /// + /// /// If hdc is non-NULL, the coordinates of the clipping rectangle are relative to the origin /// of the hdc.If hdc is NULL, the coordinates are virtual-screen coordinates. - /// + /// /// This parameter can be NULL if you don't want to clip the region specified by hdc. /// /// A pointer to a MonitorEnumProc application-defined callback function. @@ -3121,20 +3100,20 @@ public static extern uint GetRawInputDeviceInfo( /// /// /// There are two reasons to call the EnumDisplayMonitors function: - /// + /// /// You want to draw optimally into a device context that spans several display monitors, and the monitors have different color formats. /// You want to obtain a handle and position rectangle for one or more display monitors. - /// + /// /// To determine whether all the display monitors in a system share the same color format, call GetSystemMetrics (SM_SAMEDISPLAYFORMAT). - /// + /// /// You do not need to use the EnumDisplayMonitors function when a window spans display monitors that have different color formats. /// You can continue to paint under the assumption that the entire screen has the color properties of the primary monitor.Your windows will /// look fine.EnumDisplayMonitors just lets you make them look better. - /// + /// /// Setting the hdc parameter to NULL lets you use the EnumDisplayMonitors function to obtain a handle and position rectangle for /// one or more display monitors.The following table shows how the four combinations of NULL and non-NULLhdc and lprcClip values affect /// the behavior of the EnumDisplayMonitors function. - /// + /// /// +-----------------------------------------------------------------------------------+----------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ /// | hdc | lprcRect | EnumDisplayMonitors behavior | /// +-----------------------------------------------------------------------------------+----------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ @@ -3151,9 +3130,9 @@ public static extern uint GetRawInputDeviceInfo( [DllImport(ExternDll.User32, CallingConvention = CallingConvention.Winapi)] [return: MarshalAs(UnmanagedType.Bool)] internal static extern bool EnumDisplayMonitors( - IntPtr hdc, - IntPtr lprcClip, - NativeMethods.MonitorEnumProc lpfnEnum, + IntPtr hdc, + IntPtr lprcClip, + NativeMethods.MonitorEnumProc lpfnEnum, IntPtr lParam); /// diff --git a/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/UnsafeNativeMethodsOther.cs b/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/UnsafeNativeMethodsOther.cs index 358e053fdf0..e531ddf3ac8 100644 --- a/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/UnsafeNativeMethodsOther.cs +++ b/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/UnsafeNativeMethodsOther.cs @@ -510,7 +510,7 @@ internal static IntPtr GetWindowLongPtr(HandleRef hWnd, int nIndex ) // we should "throw" here. But we don't want to // introduce new "throws" w/o time to follow up on any // new problems that causes. - Debug.WriteLine("GetWindowLongPtr failed. Error = " + error); + Debug.WriteLine($"GetWindowLongPtr failed. Error = {error}"); // throw new System.ComponentModel.Win32Exception(error); } @@ -544,7 +544,7 @@ internal static Int32 GetWindowLong(HandleRef hWnd, int nIndex ) // we should "throw" here. But we don't want to // introduce new "throws" w/o time to follow up on any // new problems that causes. - Debug.WriteLine("GetWindowLong failed. Error = " + error); + Debug.WriteLine($"GetWindowLong failed. Error = {error}"); // throw new System.ComponentModel.Win32Exception(error); } @@ -684,7 +684,7 @@ internal static void GetIconInfo(HandleRef hIcon, out NativeMethods.ICONINFO pic if(!success) { - Debug.WriteLine("GetIconInfo failed. Error = " + error); + Debug.WriteLine($"GetIconInfo failed. Error = {error}"); throw new Win32Exception(); } diff --git a/src/Microsoft.DotNet.Wpf/src/Shared/RefAssemblyAttrs.cs b/src/Microsoft.DotNet.Wpf/src/Shared/RefAssemblyAttrs.cs index 39b1fce8eb1..f363fa18427 100644 --- a/src/Microsoft.DotNet.Wpf/src/Shared/RefAssemblyAttrs.cs +++ b/src/Microsoft.DotNet.Wpf/src/Shared/RefAssemblyAttrs.cs @@ -40,38 +40,38 @@ internal static class BuildInfo internal const string DEVDIV_PUBLIC_KEY_TOKEN = "b77a5c561934e089"; // Constants to prevent hardcoding in InternalsVisibleTo attribute - internal const string DirectWriteForwarder = "DirectWriteForwarder, PublicKey=" + WCP_PUBLIC_KEY_STRING; - internal const string PresentationCore = "PresentationCore, PublicKey=" + WCP_PUBLIC_KEY_STRING; - internal const string PresentationCFFRasterizer = "PresentationCFFRasterizer, PublicKey=" + WCP_PUBLIC_KEY_STRING; - internal const string PresentationFramework = "PresentationFramework, PublicKey=" + WCP_PUBLIC_KEY_STRING; - internal const string PresentationUI = "PresentationUI, PublicKey=" + WCP_PUBLIC_KEY_STRING; - internal const string PresentationFrameworkLuna = "PresentationFramework.Luna, PublicKey=" + WCP_PUBLIC_KEY_STRING; - internal const string PresentationFrameworkRoyale = "PresentationFramework.Royale, PublicKey=" + WCP_PUBLIC_KEY_STRING; - internal const string PresentationFrameworkAero = "PresentationFramework.Aero, PublicKey=" + WCP_PUBLIC_KEY_STRING; - internal const string PresentationFrameworkAero2 = "PresentationFramework.Aero2, PublicKey=" + WCP_PUBLIC_KEY_STRING; - internal const string PresentationFrameworkAeroLite = "PresentationFramework.AeroLite, PublicKey=" + WCP_PUBLIC_KEY_STRING; - internal const string PresentationFrameworkClassic = "PresentationFramework.Classic, PublicKey=" + WCP_PUBLIC_KEY_STRING; - internal const string PresentationFrameworkSystemCore = "PresentationFramework-SystemCore, PublicKey=" + DEVDIV_PUBLIC_KEY_STRING; - internal const string PresentationFrameworkSystemData = "PresentationFramework-SystemData, PublicKey=" + DEVDIV_PUBLIC_KEY_STRING; - internal const string PresentationFrameworkSystemDrawing = "PresentationFramework-SystemDrawing, PublicKey=" + DEVDIV_PUBLIC_KEY_STRING; - internal const string PresentationFrameworkSystemXml = "PresentationFramework-SystemXml, PublicKey=" + DEVDIV_PUBLIC_KEY_STRING; - internal const string PresentationFrameworkSystemXmlLinq = "PresentationFramework-SystemXmlLinq, PublicKey=" + DEVDIV_PUBLIC_KEY_STRING; - internal const string ReachFramework = "ReachFramework, PublicKey=" + WCP_PUBLIC_KEY_STRING; - internal const string SystemPrinting = "System.Printing, PublicKey=" + WCP_PUBLIC_KEY_STRING; - internal const string SystemXaml = "System.Xaml, PublicKey=" + DEVDIV_PUBLIC_KEY_STRING; - internal const string WindowsFormsIntegration = "WindowsFormsIntegration, PublicKey=" + WCP_PUBLIC_KEY_STRING; + internal const string DirectWriteForwarder = $"DirectWriteForwarder, PublicKey={WCP_PUBLIC_KEY_STRING}"; + internal const string PresentationCore = $"PresentationCore, PublicKey={WCP_PUBLIC_KEY_STRING}"; + internal const string PresentationCFFRasterizer = $"PresentationCFFRasterizer, PublicKey={WCP_PUBLIC_KEY_STRING}"; + internal const string PresentationFramework = $"PresentationFramework, PublicKey={WCP_PUBLIC_KEY_STRING}"; + internal const string PresentationUI = $"PresentationUI, PublicKey={WCP_PUBLIC_KEY_STRING}"; + internal const string PresentationFrameworkLuna = $"PresentationFramework.Luna, PublicKey={WCP_PUBLIC_KEY_STRING}"; + internal const string PresentationFrameworkRoyale = $"PresentationFramework.Royale, PublicKey={WCP_PUBLIC_KEY_STRING}"; + internal const string PresentationFrameworkAero = $"PresentationFramework.Aero, PublicKey={WCP_PUBLIC_KEY_STRING}"; + internal const string PresentationFrameworkAero2 = $"PresentationFramework.Aero2, PublicKey={WCP_PUBLIC_KEY_STRING}"; + internal const string PresentationFrameworkAeroLite = $"PresentationFramework.AeroLite, PublicKey={WCP_PUBLIC_KEY_STRING}"; + internal const string PresentationFrameworkClassic = $"PresentationFramework.Classic, PublicKey={WCP_PUBLIC_KEY_STRING}"; + internal const string PresentationFrameworkSystemCore = $"PresentationFramework-SystemCore, PublicKey={DEVDIV_PUBLIC_KEY_STRING}"; + internal const string PresentationFrameworkSystemData = $"PresentationFramework-SystemData, PublicKey={DEVDIV_PUBLIC_KEY_STRING}"; + internal const string PresentationFrameworkSystemDrawing = $"PresentationFramework-SystemDrawing, PublicKey={DEVDIV_PUBLIC_KEY_STRING}"; + internal const string PresentationFrameworkSystemXml = $"PresentationFramework-SystemXml, PublicKey={DEVDIV_PUBLIC_KEY_STRING}"; + internal const string PresentationFrameworkSystemXmlLinq = $"PresentationFramework-SystemXmlLinq, PublicKey={DEVDIV_PUBLIC_KEY_STRING}"; + internal const string ReachFramework = $"ReachFramework, PublicKey={WCP_PUBLIC_KEY_STRING}"; + internal const string SystemPrinting = $"System.Printing, PublicKey={WCP_PUBLIC_KEY_STRING}"; + internal const string SystemXaml = $"System.Xaml, PublicKey={DEVDIV_PUBLIC_KEY_STRING}"; + internal const string WindowsFormsIntegration = $"WindowsFormsIntegration, PublicKey={WCP_PUBLIC_KEY_STRING}"; // Make internal visible to the 3.5 dll, System.Windows.Presentation.dll. // we hard code the key here because the 3.5 dll is built in the devdiv depot using the CLR key. - internal const string SystemWindowsPresentation = "System.Windows.Presentation, PublicKey=" + DEVDIV_PUBLIC_KEY_STRING; - internal const string SystemWindowsControlsRibbon = "System.Windows.Controls.Ribbon, PublicKey=" + DEVDIV_PUBLIC_KEY_STRING; + internal const string SystemWindowsPresentation = $"System.Windows.Presentation, PublicKey={DEVDIV_PUBLIC_KEY_STRING}"; + internal const string SystemWindowsControlsRibbon = $"System.Windows.Controls.Ribbon, PublicKey={DEVDIV_PUBLIC_KEY_STRING}"; } internal static class DllImport { - internal const string PresentationNative = "PresentationNative" + BuildInfo.WCP_VERSION_SUFFIX + ".dll"; - internal const string PresentationCFFRasterizerNative = "PresentationCFFRasterizerNative" + BuildInfo.WCP_VERSION_SUFFIX + ".dll"; - internal const string MilCore = "wpfgfx" + BuildInfo.WCP_VERSION_SUFFIX + ".dll"; + internal const string PresentationNative = $"PresentationNative{BuildInfo.WCP_VERSION_SUFFIX}.dll"; + internal const string PresentationCFFRasterizerNative = $"PresentationCFFRasterizerNative{BuildInfo.WCP_VERSION_SUFFIX}.dll"; + internal const string MilCore = $"wpfgfx{BuildInfo.WCP_VERSION_SUFFIX}.dll"; // DLL's w/o version suffix internal const string UIAutomationCore = "UIAutomationCore.dll"; diff --git a/src/Microsoft.DotNet.Wpf/src/Shared/System/Windows/Markup/TypeConverterHelper.cs b/src/Microsoft.DotNet.Wpf/src/Shared/System/Windows/Markup/TypeConverterHelper.cs index 92d39b6797e..4758e5c0c38 100644 --- a/src/Microsoft.DotNet.Wpf/src/Shared/System/Windows/Markup/TypeConverterHelper.cs +++ b/src/Microsoft.DotNet.Wpf/src/Shared/System/Windows/Markup/TypeConverterHelper.cs @@ -65,7 +65,7 @@ internal static MemberInfo GetMemberInfoForPropertyConverter(object dpOrPiOrMi) { // Get the method member that defines the DependencyProperty memberInfo = dp.OwnerType.GetMethod( - "Get" + dp.Name, + $"Get{dp.Name}", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.FlattenHierarchy); } @@ -85,7 +85,7 @@ internal static MemberInfo GetMemberInfoForPropertyConverter(object dpOrPiOrMi) { // Use the Setter of the attached property (if any) memberInfo = methodInfo.DeclaringType.GetMethod( - "Get" + methodInfo.Name.Substring("Set".Length), + $"Get{methodInfo.Name.Substring("Set".Length)}", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.FlattenHierarchy); } diff --git a/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/AssemblyHelper.cs b/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/AssemblyHelper.cs index 50068d36cca..8a783780415 100644 --- a/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/AssemblyHelper.cs +++ b/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/AssemblyHelper.cs @@ -208,9 +208,9 @@ private static object LoadExtensionFor(string name) { // build the full display name of the extension assembly string assemblyName = Assembly.GetExecutingAssembly().FullName; - string extensionAssemblyName = assemblyName.Replace("WindowsBase", "PresentationFramework-" + name) + string extensionAssemblyName = assemblyName.Replace("WindowsBase", $"PresentationFramework-{name}") .Replace(BuildInfo.WCP_PUBLIC_KEY_TOKEN, BuildInfo.DEVDIV_PUBLIC_KEY_TOKEN); - string extensionTypeName = "MS.Internal." + name + "Extension"; + string extensionTypeName = $"MS.Internal.{name}Extension"; object result = null; // create the instance of the extension class diff --git a/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/AvTrace.cs b/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/AvTrace.cs index c8a800ad922..5c4ad877867 100644 --- a/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/AvTrace.cs +++ b/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/AvTrace.cs @@ -284,7 +284,7 @@ public string Trace( TraceEventType type, int eventId, string message, string[] // Append to the format string a "; {0} = '{1}'", where the index increments (e.g. the second iteration will // produce {2} & {3}). - traceBuilder.Append("; {" + (formatIndex++).ToString() + "}='{" + (formatIndex++).ToString() + "}'" ); + traceBuilder.Append($"; {{{(formatIndex++)}}}='{{{(formatIndex++)}}}'"); // If this parameter is null, convert to ""; otherwise, when a string.format is ultimately called // it produces bad results. @@ -303,11 +303,9 @@ public string Trace( TraceEventType type, int eventId, string message, string[] && !(parameters[j] is Type) && !(parameters[j] is DependencyProperty) ) { - traceBuilder.Append("; " + labels[i].ToString() + ".HashCode='" - + GetHashCodeHelper(parameters[j]).ToString() + "'" ); + traceBuilder.Append($"; {labels[i]}.HashCode='{GetHashCodeHelper(parameters[j])}'"); - traceBuilder.Append("; " + labels[i].ToString() + ".Type='" - + GetTypeHelper(parameters[j]).ToString() + "'" ); + traceBuilder.Append($"; {labels[i]}.Type='{GetTypeHelper(parameters[j])}'"); } diff --git a/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/ComponentModel/DependencyObjectPropertyDescriptor.cs b/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/ComponentModel/DependencyObjectPropertyDescriptor.cs index 6c428e3bda2..38373fda3c3 100644 --- a/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/ComponentModel/DependencyObjectPropertyDescriptor.cs +++ b/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/ComponentModel/DependencyObjectPropertyDescriptor.cs @@ -58,7 +58,7 @@ internal DependencyObjectPropertyDescriptor(PropertyDescriptor property, Depende /// Attributes property and demand create the attributes at that time. /// internal DependencyObjectPropertyDescriptor(DependencyProperty dp, Type ownerType) - : base(string.Concat(dp.OwnerType.Name, ".", dp.Name), null) + : base($"{dp.OwnerType.Name}.{dp.Name}", null) { _dp = dp; _componentType = ownerType; @@ -404,7 +404,7 @@ internal static MethodInfo GetAttachedPropertyMethod(DependencyProperty dp) if (methodObj == null || (method != null && !object.ReferenceEquals(method.DeclaringType, reflectionType))) { BindingFlags f = BindingFlags.Static | BindingFlags.Public | BindingFlags.DeclaredOnly; - string methodName = string.Concat("Get", dp.Name); + string methodName = $"Get{dp.Name}"; method = reflectionType.GetMethod(methodName, f, _dpBinder, DpType, null); lock(_getMethodCache) { @@ -570,7 +570,7 @@ private static MethodInfo GetAttachedPropertySetMethod(DependencyProperty dp) if (methodObj == null || (method != null && !object.ReferenceEquals(method.DeclaringType, reflectionType))) { BindingFlags f = BindingFlags.Static | BindingFlags.Public | BindingFlags.DeclaredOnly; - string methodName = string.Concat("Set", dp.Name); + string methodName = $"Set{dp.Name}"; Type[] paramTypes = new Type[] { DpType[0], diff --git a/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/IO/Packaging/CustomSignedXml.cs b/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/IO/Packaging/CustomSignedXml.cs index 76b91d9fedd..e23086efb38 100644 --- a/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/IO/Packaging/CustomSignedXml.cs +++ b/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/IO/Packaging/CustomSignedXml.cs @@ -162,7 +162,7 @@ private static XmlElement SelectSubObjectNodeForXAdESInDataObjects(Signature sig // NOTE: this is executing an XPath query // idValue has already been tested as an NCName (unless overridden for compatibility), so there's no // escaping that needs to be done here. - XmlNodeList nodeList = element.SelectNodes(".//*[@Id='" + idValue + "']"); + XmlNodeList nodeList = element.SelectNodes($".//*[@Id='{idValue}']"); if (nodeList.Count > 0) { @@ -271,7 +271,7 @@ private static bool AllowAmbiguousReferenceTargets() #endregion Registry access private const string _XAdESNameSpace = @"http://uri.etsi.org/01903/v1.2.2#"; - private const string _XAdESTargetType = _XAdESNameSpace + @"SignedProperties"; + private const string _XAdESTargetType = $@"{_XAdESNameSpace}SignedProperties"; } } diff --git a/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/IO/Packaging/XmlDigitalSignatureProcessor.cs b/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/IO/Packaging/XmlDigitalSignatureProcessor.cs index 01b8d38ed82..47dec0d2206 100644 --- a/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/IO/Packaging/XmlDigitalSignatureProcessor.cs +++ b/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/IO/Packaging/XmlDigitalSignatureProcessor.cs @@ -787,7 +787,7 @@ private PackageDigitalSignature Sign( // add reference from SignedInfo to Package object tag Reference objectReference = new Reference(XTable.Get(XTable.ID.OpcLinkAttrValue)); - objectReference.Type = XTable.Get(XTable.ID.W3CSignatureNamespaceRoot) + "Object"; + objectReference.Type = $"{XTable.Get(XTable.ID.W3CSignatureNamespaceRoot)}Object"; objectReference.DigestMethod = _hashAlgorithmName; _signedXml.AddReference(objectReference); diff --git a/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/IO/Packaging/XmlSignatureProperties.cs b/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/IO/Packaging/XmlSignatureProperties.cs index f78584c42e8..8767b915fee 100644 --- a/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/IO/Packaging/XmlSignatureProperties.cs +++ b/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/IO/Packaging/XmlSignatureProperties.cs @@ -120,7 +120,7 @@ internal static XmlElement AssembleSignatureProperties( idAttr.Value = XTable.Get(XTable.ID.SignaturePropertyIdAttrValue); signatureProperty.Attributes.Append(idAttr); XmlAttribute targetAttr = xDoc.CreateAttribute(XTable.Get(XTable.ID.TargetAttrName)); - targetAttr.Value = "#" + signatureId; + targetAttr.Value = $"#{signatureId}"; signatureProperty.Attributes.Append(targetAttr); // @@ -439,7 +439,7 @@ private static bool VerifyTargetAttribute(XmlReader reader, string signatureId) { //If the Target attribute has a non-empty string then //it must match the tag Id attribute value - if (signatureId != null && string.Equals(idTargetValue, "#" + signatureId, StringComparison.Ordinal)) + if (signatureId != null && string.Equals(idTargetValue, $"#{signatureId}", StringComparison.Ordinal)) return true; else return false; diff --git a/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/Interop/ErrorCodes.cs b/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/Interop/ErrorCodes.cs index eb4543c71c6..32e5c5a91b7 100644 --- a/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/Interop/ErrorCodes.cs +++ b/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/Interop/ErrorCodes.cs @@ -322,7 +322,7 @@ public override string ToString() var error = (Win32Error)publicStaticField.GetValue(null); if ((HRESULT)error == this) { - return "HRESULT_FROM_WIN32(" + publicStaticField.Name + ")"; + return $"HRESULT_FROM_WIN32({publicStaticField.Name})"; } } } diff --git a/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/ComponentModel/DependencyPropertyDescriptor.cs b/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/ComponentModel/DependencyPropertyDescriptor.cs index d80919749b0..fbc183d618c 100644 --- a/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/ComponentModel/DependencyPropertyDescriptor.cs +++ b/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/ComponentModel/DependencyPropertyDescriptor.cs @@ -169,8 +169,8 @@ internal static DependencyPropertyDescriptor FromProperty(DependencyProperty dep } else { - if (ownerType.GetMethod("Get" + dependencyProperty.Name) == null && - ownerType.GetMethod("Set" + dependencyProperty.Name) == null) + if (ownerType.GetMethod($"Get{dependencyProperty.Name}") == null && + ownerType.GetMethod($"Set{dependencyProperty.Name}") == null) { return null; } diff --git a/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/BaseCompatibilityPreferences.cs b/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/BaseCompatibilityPreferences.cs index ac00df5b7f7..c7c1aec7b77 100644 --- a/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/BaseCompatibilityPreferences.cs +++ b/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/BaseCompatibilityPreferences.cs @@ -288,7 +288,7 @@ private static void SetMatchPackageSignatureMethodToPackagePartDigestMethodFromR /// /// String to use for assert of registry permissions /// - private const string WpfPackagingKey = @"HKEY_CURRENT_USER\" + WpfPackagingSubKeyPath; + private const string WpfPackagingKey = $@"HKEY_CURRENT_USER\{WpfPackagingSubKeyPath}"; /// /// The key location for the registry switch to configure the Packaging API diff --git a/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/DependencyProperty.cs b/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/DependencyProperty.cs index 7139ea33411..21608519c99 100644 --- a/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/DependencyProperty.cs +++ b/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/DependencyProperty.cs @@ -23,7 +23,7 @@ namespace System.Windows /// /// An attached dependency-based property /// - [TypeConverter("System.Windows.Markup.DependencyPropertyConverter, PresentationFramework, Version=" + BuildInfo.WCP_VERSION + ", Culture=neutral, PublicKeyToken=" + BuildInfo.WCP_PUBLIC_KEY_TOKEN + ", Custom=null")] + [TypeConverter($"System.Windows.Markup.DependencyPropertyConverter, PresentationFramework, Version={BuildInfo.WCP_VERSION}, Culture=neutral, PublicKeyToken={BuildInfo.WCP_PUBLIC_KEY_TOKEN}, Custom=null")] [ValueSerializer(typeof(DependencyPropertyValueSerializer))] public sealed class DependencyProperty { @@ -1129,7 +1129,7 @@ internal static int GetUniqueGlobalIndex(Type ownerType, string name) { if (ownerType != null) { - throw new InvalidOperationException(SR.Format(SR.TooManyDependencyProperties, ownerType.Name + "." + name)); + throw new InvalidOperationException(SR.Format(SR.TooManyDependencyProperties, $"{ownerType.Name}.{name}")); } else { diff --git a/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/DependencyPropertyValueSerializer.cs b/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/DependencyPropertyValueSerializer.cs index 0279ec06c2d..6c19f1edfdb 100644 --- a/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/DependencyPropertyValueSerializer.cs +++ b/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/DependencyPropertyValueSerializer.cs @@ -36,7 +36,7 @@ public override string ConvertToString(object value, IValueSerializerContext con ValueSerializer typeSerializer = ValueSerializer.GetSerializerFor(typeof(Type), context); if (typeSerializer != null) { - return typeSerializer.ConvertToString(property.OwnerType, context) + "." + property.Name; + return $"{typeSerializer.ConvertToString(property.OwnerType, context)}.{property.Name}"; } } diff --git a/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/SplashScreen.cs b/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/SplashScreen.cs index 318e9bb3969..10677905a20 100644 --- a/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/SplashScreen.cs +++ b/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/SplashScreen.cs @@ -51,7 +51,7 @@ public SplashScreen(Assembly resourceAssembly, string resourceName) _resourceName = resourceName.ToLowerInvariant(); _hInstance = Marshal.GetHINSTANCE(resourceAssembly.ManifestModule); AssemblyName name = new AssemblyName(resourceAssembly.FullName); - _resourceManager = new ResourceManager(name.Name + ".g", resourceAssembly); + _resourceManager = new ResourceManager($"{name.Name}.g", resourceAssembly); } public void Show(bool autoClose) diff --git a/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/Threading/DispatcherOperation.cs b/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/Threading/DispatcherOperation.cs index 48a752e33e9..4398fd65ec9 100644 --- a/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/Threading/DispatcherOperation.cs +++ b/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/Threading/DispatcherOperation.cs @@ -284,7 +284,7 @@ internal String Name { get { - return _method.Method.DeclaringType + "." + _method.Method.Name; + return $"{_method.Method.DeclaringType}.{_method.Method.Name}"; } }