diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/Application/AddressUtility.cs b/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/Application/AddressUtility.cs index ced9e9f5cb9..289bb02e877 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/Application/AddressUtility.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/Application/AddressUtility.cs @@ -54,11 +54,7 @@ internal static string GetEmailAddressFromMailtoUri(Uri mailtoUri) if (IsMailtoUri(mailtoUri)) { // Create the address from the URI - address = string.Format( - CultureInfo.CurrentCulture, - _addressTemplate, - mailtoUri.GetComponents(UriComponents.UserInfo, UriFormat.Unescaped), - mailtoUri.GetComponents(UriComponents.Host, UriFormat.Unescaped)); + address = $"{mailtoUri.GetComponents(UriComponents.UserInfo, UriFormat.Unescaped)}@{mailtoUri.GetComponents(UriComponents.Host, UriFormat.Unescaped)}"; } return address; @@ -75,45 +71,17 @@ internal static Uri GenerateMailtoUri(string address) // Add the scheme to the e-mail address to form a URI object if (!string.IsNullOrEmpty(address)) { - return new Uri(string.Format( - CultureInfo.CurrentCulture, - _mailtoUriTemplate, - Uri.UriSchemeMailto, - _mailtoSchemeDelimiter, - address)); + // The delimiter between the scheme and the address in a mailto URI. + // We unfortunately cannot use the Uri class SchemeDelimiter because + // it is by default set to "://", which makes mailto: URIs generated + // look like "mailto://user@host", which in turn cannot be parsed + // properly by this class. + return new Uri($"{Uri.UriSchemeMailto}:{address}"); } return null; } #endregion Internal Methods - - #region Private Fields - //-------------------------------------------------------------------------- - // Private Fields - //-------------------------------------------------------------------------- - - /// - /// The template for an e-mail address with a user name and a host. - /// - private const string _addressTemplate = "{0}@{1}"; - - /// - /// The template for a mailto scheme URI with the mailto scheme and an - /// address. - /// - private const string _mailtoUriTemplate = "{0}{1}{2}"; - - /// - /// The delimiter between the scheme and the address in a mailto URI. - /// We unfortunately cannot use the Uri class SchemeDelimiter because - /// it is by default set to "://", which makes mailto: URIs generated - /// look like "mailto://user@host", whicn in turn cannot be parsed - /// properly by this class. - /// - private const string _mailtoSchemeDelimiter = ":"; - - #endregion Private Fields - } } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/Application/Document.cs b/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/Application/Document.cs index db297ccce95..b3455959344 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/Application/Document.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationUI/MS/Internal/Documents/Application/Document.cs @@ -312,10 +312,7 @@ private void AssertIfNotDisposed() { Invariant.Assert( _isDisposed, - string.Format( - System.Globalization.CultureInfo.CurrentCulture, - "{0} was not disposed.", - this)); + $"{this} was not disposed."); } /// 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 1566a6b39a0..97d9462147b 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 @@ -829,17 +829,10 @@ private Uri MakeTemporaryFileName(bool inSameFolder, int generation) file = this.GetHashCode().ToString(CultureInfo.InvariantCulture); } - string temp = string.Format( - CultureInfo.CurrentCulture, - "{0}{1}~{2}{3}{4}", - Path.GetDirectoryName(path), - Path.DirectorySeparatorChar, - generation == 0 ? - string.Empty : - generation.ToString(CultureInfo.CurrentCulture) - + "~", - file, - XpsFileExtension); + string temp = generation == 0 + ? $"{Path.GetDirectoryName(path)}{Path.DirectorySeparatorChar}~{file}{XpsFileExtension}" + : $"{Path.GetDirectoryName(path)}{Path.DirectorySeparatorChar}~{generation}~{file}{XpsFileExtension}"; + return new Uri(temp); } 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 97fb2d99d93..7be3b565536 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 @@ -89,12 +89,7 @@ internal static Drawing.Image GetImageFromStatus( sigStatus = SignatureStatus.Invalid; } - string resourceName = string.Format( - CultureInfo.InvariantCulture, - @"{0}_{1}x{2}", - sigStatus.ToString(), - height, - width); + string resourceName = $@"{sigStatus}_{height}x{width}"; return (Drawing.Image)Resources.ResourceManager.GetObject(resourceName); } @@ -323,13 +318,7 @@ private static string GetSignatureSummaryMessage(SignatureStatus sigStatus, Cert /// The short date or 'none' if the value was null. private static string GetFormattedDate(Nullable date) { - string none = SR.SignatureResourceHelperNone; - - return date == null ? - none : - String.Format( - CultureInfo.CurrentCulture, - ((DateTime)date).ToShortDateString()); + return date?.ToShortDateString() ?? SR.SignatureResourceHelperNone; } #endregion Private Methods diff --git a/src/Microsoft.DotNet.Wpf/src/ReachFramework/Packaging/XpsFixedDocumentReaderWriter.cs b/src/Microsoft.DotNet.Wpf/src/ReachFramework/Packaging/XpsFixedDocumentReaderWriter.cs index d53efe130ea..e938b5e4ca2 100644 --- a/src/Microsoft.DotNet.Wpf/src/ReachFramework/Packaging/XpsFixedDocumentReaderWriter.cs +++ b/src/Microsoft.DotNet.Wpf/src/ReachFramework/Packaging/XpsFixedDocumentReaderWriter.cs @@ -871,11 +871,7 @@ IList linkTargetStream xmlWriter.WriteRaw (""); foreach (String nameElement in linkTargetStream) { - xmlWriter.WriteRaw (String.Format( - System.Globalization.CultureInfo.InvariantCulture, - "", - nameElement) - ); + xmlWriter.WriteRaw($""); } xmlWriter.WriteRaw (""); } diff --git a/src/Microsoft.DotNet.Wpf/src/ReachFramework/Packaging/XpsManager.cs b/src/Microsoft.DotNet.Wpf/src/ReachFramework/Packaging/XpsManager.cs index 8f46c1a91b6..723a133a1fe 100644 --- a/src/Microsoft.DotNet.Wpf/src/ReachFramework/Packaging/XpsManager.cs +++ b/src/Microsoft.DotNet.Wpf/src/ReachFramework/Packaging/XpsManager.cs @@ -1124,59 +1124,49 @@ ContentType contentType if (contentType.AreTypeAndSubTypeEqual(XpsS0Markup.DocumentSequenceContentType)) { - uniqueUri = String.Format(System.Globalization.CultureInfo.InvariantCulture, - "{0}.fdseq", - new object[] { contentKey }); + uniqueUri = $"{contentKey}.fdseq"; } else if (contentType.AreTypeAndSubTypeEqual(XpsS0Markup.FixedDocumentContentType)) { - uniqueUri = String.Format(System.Globalization.CultureInfo.InvariantCulture, - "/Documents/{0}/FixedDocument.fdoc", - new object[] { counter }); + uniqueUri = string.Create(System.Globalization.CultureInfo.InvariantCulture, + $"/Documents/{counter}/FixedDocument.fdoc"); string pageContentKey = GetContentCounterKey(XpsS0Markup.FixedPageContentType); _contentTypes[pageContentKey] = 1; } else if (contentType.AreTypeAndSubTypeEqual(XpsS0Markup.FixedPageContentType)) { - uniqueUri = String.Format(System.Globalization.CultureInfo.InvariantCulture, - "/Documents/{0}/Pages/{1}.fpage", - new object[] { docCounter, counter }); + uniqueUri = string.Create(System.Globalization.CultureInfo.InvariantCulture, + $"/Documents/{docCounter}/Pages/{counter}.fpage"); } else if (contentKey.Equals("Dictionary", StringComparison.OrdinalIgnoreCase)) { - uniqueUri = String.Format(System.Globalization.CultureInfo.InvariantCulture, - "/Resources/{0}.dict", - new object[] { uniqueName }); + uniqueUri = string.Create(System.Globalization.CultureInfo.InvariantCulture, + $"/Resources/{uniqueName}.dict"); } else if (contentKey.Equals("Font", StringComparison.OrdinalIgnoreCase)) { - uniqueUri = String.Format(System.Globalization.CultureInfo.InvariantCulture, - "/Resources/{0}.ttf", - new object[] { uniqueName }); + uniqueUri = string.Create(System.Globalization.CultureInfo.InvariantCulture, + $"/Resources/{uniqueName}.ttf"); } else if (contentKey.Equals("ColorContext", StringComparison.OrdinalIgnoreCase)) { - uniqueUri = String.Format(System.Globalization.CultureInfo.InvariantCulture, - "/Resources/{0}.icc", - new object[] { uniqueName }); + uniqueUri = string.Create(System.Globalization.CultureInfo.InvariantCulture, + $"/Resources/{uniqueName}.icc"); } else if (contentKey.Equals("ResourceDictionary", StringComparison.OrdinalIgnoreCase)) { - uniqueUri = String.Format(System.Globalization.CultureInfo.InvariantCulture, - "/Resources/{0}.dict", - new object[] { uniqueName }); + uniqueUri = string.Create(System.Globalization.CultureInfo.InvariantCulture, + $"/Resources/{uniqueName}.dict"); } else if (contentKey.Equals("Image", StringComparison.OrdinalIgnoreCase)) { - uniqueUri = String.Format(System.Globalization.CultureInfo.InvariantCulture, - "/Resources/{0}.{1}", - new object[] { uniqueName, LookupImageExtension(contentType) }); + uniqueUri = string.Create(System.Globalization.CultureInfo.InvariantCulture, + $"/Resources/{uniqueName}.{LookupImageExtension(contentType)}"); } else { - uniqueUri = String.Format(System.Globalization.CultureInfo.InvariantCulture, - "/{0}s/{0}_{1}.xaml", - new object[] { contentKey, counter }); + uniqueUri = string.Create(System.Globalization.CultureInfo.InvariantCulture, + $"/{contentKey}s/{contentKey}_{counter}.xaml"); } // diff --git a/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/FallbackPTProvider.cs b/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/FallbackPTProvider.cs index cbad58842a3..16174713909 100644 --- a/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/FallbackPTProvider.cs +++ b/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/FallbackPTProvider.cs @@ -111,13 +111,8 @@ public override MemoryStream GetPrintCapabilities(MemoryStream printTicket) catch (XmlException xmlException) { throw new ArgumentException( - String.Format( - CultureInfo.CurrentCulture, - "{0} {1} {2}", - PrintSchemaTags.Framework.PrintTicketRoot, - PTUtility.GetTextFromResource("FormatException.XMLNotWellFormed"), - xmlException.Message), - "printTicket", + $"{PrintSchemaTags.Framework.PrintTicketRoot} {PTUtility.GetTextFromResource("FormatException.XMLNotWellFormed")} {xmlException.Message}", + nameof(printTicket), xmlException); } @@ -383,21 +378,15 @@ private string OemDriverNamespace { if (this._printTicketNamespace == null) { - string deviceNamepace = string.Format( + string deviceNamepace = string.Create( CultureInfo.InvariantCulture, - DeviceNamespaceFormat, - BuildInfo.WCP_VERSION_SUFFIX, - this._driverName, - this._driverVersion); + $"http://schemas.microsoft.com/windows/printing/oemdriverpt/netfx{BuildInfo.WCP_VERSION_SUFFIX}/{_driverName}/v{_driverVersion}"); if (!Uri.IsWellFormedUriString(deviceNamepace, UriKind.Absolute)) { - deviceNamepace = string.Format( + deviceNamepace = string.Create( CultureInfo.InvariantCulture, - DeviceNamespaceFormat, - BuildInfo.WCP_VERSION_SUFFIX, - Uri.EscapeDataString(this._driverName), - this._driverVersion); + $"http://schemas.microsoft.com/windows/printing/oemdriverpt/netfx{BuildInfo.WCP_VERSION_SUFFIX}/{Uri.EscapeDataString(_driverName)}/v{_driverVersion}"); } this._printTicketNamespace = deviceNamepace; diff --git a/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PTProvider.cs b/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PTProvider.cs index aefa5506b55..cc667dc410b 100644 --- a/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PTProvider.cs +++ b/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PTProvider.cs @@ -238,12 +238,8 @@ public override MemoryStream GetPrintCapabilities(MemoryStream printTicket) if (hResult == (uint)NativeErrorCode.E_PRINTTICKET_FORMAT) { - throw new ArgumentException(String.Format(CultureInfo.CurrentCulture, - "{0} {1} {2}", - PrintSchemaTags.Framework.PrintTicketRoot, - PTUtility.GetTextFromResource("FormatException.XMLNotWellFormed"), - errorMsg), - "printTicket"); + throw new ArgumentException($"{PrintSchemaTags.Framework.PrintTicketRoot} {PTUtility.GetTextFromResource("FormatException.XMLNotWellFormed")} {errorMsg}", + nameof(printTicket)); } else { @@ -343,11 +339,7 @@ public override MemoryStream MergeAndValidatePrintTicket(MemoryStream basePrintT if ((hResult == (uint)NativeErrorCode.E_PRINTTICKET_FORMAT) || (hResult == (uint)NativeErrorCode.E_DELTA_PRINTTICKET_FORMAT)) { - throw new ArgumentException(String.Format(CultureInfo.CurrentCulture, - "{0} {1} {2}", - PrintSchemaTags.Framework.PrintTicketRoot, - PTUtility.GetTextFromResource("FormatException.XMLNotWellFormed"), - errorMsg), + throw new ArgumentException($"{PrintSchemaTags.Framework.PrintTicketRoot} {PTUtility.GetTextFromResource("FormatException.XMLNotWellFormed")} {errorMsg}", (hResult == (uint)NativeErrorCode.E_PRINTTICKET_FORMAT) ? "basePrintTicket" : "deltaPrintTicket"); } else @@ -504,12 +496,8 @@ public override byte[] ConvertPrintTicketToDevMode(MemoryStream printTicket, if ((hResult == (uint)NativeErrorCode.E_XML_INVALID) || (hResult == (uint)NativeErrorCode.E_PRINTTICKET_FORMAT)) { - throw new ArgumentException(String.Format(CultureInfo.CurrentCulture, - "{0} {1} {2}", - PrintSchemaTags.Framework.PrintTicketRoot, - PTUtility.GetTextFromResource("FormatException.XMLNotWellFormed"), - errorMsg), - "printTicket"); + throw new ArgumentException($"{PrintSchemaTags.Framework.PrintTicketRoot} {PTUtility.GetTextFromResource("FormatException.XMLNotWellFormed")} {errorMsg}", + nameof(printTicket)); } throw new PrintQueueException((int)hResult, diff --git a/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PrintCapabilitesWriter.cs b/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PrintCapabilitesWriter.cs index a542ca4f5b7..b753d45e48f 100644 --- a/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PrintCapabilitesWriter.cs +++ b/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PrintCapabilitesWriter.cs @@ -308,7 +308,7 @@ public void WriteJobInputBinFeature(IList bins, IList binDisplayN } else { - optionLocalName = string.Format(CultureInfo.InvariantCulture, "User{0:0000000000}", bins[i]); + optionLocalName = string.Create(CultureInfo.InvariantCulture, $"User{bins[i]:0000000000}"); string optionDisplayName = (i < binDisplayNames.Count) ? binDisplayNames[i] : null; WriteStartOption(this._privateNamespace, optionLocalName, optionDisplayName, "None"); WriteEndOption(); @@ -416,7 +416,7 @@ out pskMaterial } else { - optionLocalName = string.Format(CultureInfo.InvariantCulture, "User{0:0000000000}", mediaTypes[i]); + optionLocalName = string.Create(CultureInfo.InvariantCulture, $"User{mediaTypes[i]:0000000000}"); optionDisplayName = (i < mediaTypeDisplayNames.Count) ? mediaTypeDisplayNames[i] : null; pskFrontCoating = null; pskBackCoating = null; diff --git a/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PrintSchemaShim.cs b/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PrintSchemaShim.cs index 21aaf4172cf..a9a5e10f4e6 100644 --- a/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PrintSchemaShim.cs +++ b/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PrintSchemaShim.cs @@ -162,12 +162,7 @@ public static DevMode TryGetEmbeddedDevMode(InternalPrintTicket ticket, string o XPathNavigator docNavigator = ticket.XmlDoc.DocumentElement.CreateNavigator(); if (docNavigator != null) { - string xPathString = string.Format( - System.Globalization.CultureInfo.InvariantCulture, - @"{0}:PrintTicket/{0}:ParameterInit[@name='{1}:PageDevmodeSnapshot']/{0}:Value", - psfPrefix, - oemDriverPrefix - ); + string xPathString = $@"{psfPrefix}:PrintTicket/{psfPrefix}:ParameterInit[@name='{oemDriverPrefix}:PageDevmodeSnapshot']/{psfPrefix}:Value"; XPathNavigator node = docNavigator.SelectSingleNode(xPathString, ticket.NamespaceManager); if (node != null) diff --git a/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PrtCap_Public.cs b/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PrtCap_Public.cs index 8a7233211c5..ebbc1c0616a 100644 --- a/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PrtCap_Public.cs +++ b/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PrtCap_Public.cs @@ -461,11 +461,7 @@ internal static FormatException NewPrintCapFormatException(string detailMsg) /// the new FormatException instance internal static FormatException NewPrintCapFormatException(string detailMsg, Exception innerException) { - return new FormatException(String.Format(CultureInfo.CurrentCulture, - "{0} {1} {2}", - PrintSchemaTags.Framework.PrintCapRoot, - PTUtility.GetTextFromResource("FormatException.XMLNotWellFormed"), - detailMsg), + return new FormatException($"{PrintSchemaTags.Framework.PrintCapRoot} {PTUtility.GetTextFromResource("FormatException.XMLNotWellFormed")} {detailMsg}", innerException); } @@ -527,4 +523,4 @@ private void PostBuildProcessing() #endregion Private Fields } -} \ No newline at end of file +} diff --git a/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PrtCap_Public_Simple.cs b/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PrtCap_Public_Simple.cs index 6424c0410cf..a6e1a7a137f 100644 --- a/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PrtCap_Public_Simple.cs +++ b/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PrtCap_Public_Simple.cs @@ -101,8 +101,7 @@ public double ExtentHeight /// String that shows the page imageable area capability. public override string ToString() { - return String.Format(CultureInfo.CurrentCulture, "({0}, {1}), ({2}, {3})", - OriginWidth, OriginHeight, ExtentWidth, ExtentHeight); + return $"({OriginWidth}, {OriginHeight}), ({ExtentWidth}, {ExtentHeight})"; } #endregion Public Methods @@ -164,11 +163,7 @@ public int MaximumScale /// Converts the page scaling factor range to human-readable string. /// /// String that shows the page scaling factor range. - public override string ToString() - { - return String.Format(CultureInfo.CurrentCulture, "({0}, {1})", - MinimumScale, MaximumScale); - } + public override string ToString() => $"({MinimumScale}, {MaximumScale})"; #endregion Public Methods @@ -1005,4 +1000,4 @@ public ReadOnlyCollection TrueTypeFontModeCapability #endregion Private Fields } -} \ No newline at end of file +} diff --git a/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PrtTicket_Public.cs b/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PrtTicket_Public.cs index cafca712746..e6ff2540feb 100644 --- a/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PrtTicket_Public.cs +++ b/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PrtTicket_Public.cs @@ -527,11 +527,7 @@ internal static FormatException NewPTFormatException(string detailMsg) /// the new FormatException instance internal static FormatException NewPTFormatException(string detailMsg, Exception innerException) { - return new FormatException(String.Format(CultureInfo.CurrentCulture, - "{0} {1} {2}", - PrintSchemaTags.Framework.PrintTicketRoot, - PTUtility.GetTextFromResource("FormatException.XMLNotWellFormed"), - detailMsg), + return new FormatException($"{PrintSchemaTags.Framework.PrintTicketRoot} {PTUtility.GetTextFromResource("FormatException.XMLNotWellFormed")} {detailMsg}", innerException); } diff --git a/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PrtTicket_Public_Simple.cs b/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PrtTicket_Public_Simple.cs index 77c625f4505..5ec353d1560 100644 --- a/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PrtTicket_Public_Simple.cs +++ b/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PrtTicket_Public_Simple.cs @@ -115,11 +115,8 @@ public Nullable Height /// String that shows the page media size setting. public override string ToString() { - return ((PageMediaSizeName != null) ? String.Format(CultureInfo.CurrentCulture, "{0}", PageMediaSizeName) : "Null") + " (" + - ((Width != null) ? String.Format(CultureInfo.CurrentCulture, "{0}", Width) : "Null") + - " x " + - ((Height != null) ? String.Format(CultureInfo.CurrentCulture, "{0}", Height) : "Null") + - ")"; + const string nullString = "Null"; + return $"{PageMediaSizeName?.ToString() ?? nullString} ({Width?.ToString() ?? nullString} x {Height?.ToString() ?? nullString})"; } #endregion Public Methods @@ -223,12 +220,7 @@ public Nullable QualitativeResolution /// String that shows the page resolution setting. public override string ToString() { - return ((X != null) ? String.Format(CultureInfo.CurrentCulture, "{0}", X) : "Null") + - " x " + - ((Y != null) ? String.Format(CultureInfo.CurrentCulture, "{0}", Y) : "Null") + - " (QualitativeResolution: " + - ((QualitativeResolution != null) ? QualitativeResolution.ToString() : "Null") + - ")"; + return $"{X?.ToString() ?? "Null"} x {Y?.ToString() ?? "Null"} (QualitativeResolution: {QualitativeResolution?.ToString() ?? "Null"})"; } #endregion Public Methods diff --git a/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/ColorTypeConverter.cs b/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/ColorTypeConverter.cs index ee72465cc15..dfb57b16fc5 100644 --- a/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/ColorTypeConverter.cs +++ b/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/ColorTypeConverter.cs @@ -183,18 +183,14 @@ Type destinationType IFormatProvider provider = culture; char separator = MS.Internal.TokenizerHelper.GetNumericListSeparator(provider); - sb.AppendFormat(provider, "ContextColor {0} ", uriString); - sb.AppendFormat(provider, "{1:R}{0}", separator, color.ScA); - for (int i = 0; i < color.GetNativeColorValues().GetLength(0); ++i) + sb.AppendFormat(provider, $"ContextColor {uriString} "); + sb.AppendFormat(provider, $"{color.ScA:R}{separator}"); + for (int i = 0; i < color.GetNativeColorValues().Length; ++i) { - sb.AppendFormat(provider, "{0:R}", color.GetNativeColorValues()[i]); - if (i < color.GetNativeColorValues().GetLength(0) - 1) - { - sb.AppendFormat(provider, "{0}", separator); - } + sb.AppendFormat(provider, $"{color.GetNativeColorValues()[i]:R}{separator}"); } - colorString = sb.ToString(); + colorString = sb.ToString(0, sb.Length - 1); } return colorString;