Skip to content

Commit 76423d6

Browse files
committed
use interpolated strings in PresentationCore
1 parent 7992065 commit 76423d6

File tree

64 files changed

+249
-417
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+249
-417
lines changed

src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/AppModel/SiteOfOriginContainer.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,7 @@ internal static Uri SiteOfOrigin
5858
#if DEBUG
5959
if (_traceSwitch.Enabled)
6060
System.Diagnostics.Trace.TraceInformation(
61-
DateTime.Now.ToLongTimeString() + " " + DateTime.Now.Millisecond + " " +
62-
Environment.CurrentManagedThreadId +
63-
": SiteOfOriginContainer: returning site of origin " + siteOfOrigin);
61+
$"{DateTime.Now:T} {DateTime.Now.Millisecond} {Environment.CurrentManagedThreadId}: SiteOfOriginContainer: returning site of origin {siteOfOrigin}");
6462
#endif
6563

6664
return siteOfOrigin;
@@ -229,9 +227,7 @@ protected override PackagePart GetPartCore(Uri uri)
229227
#if DEBUG
230228
if (_traceSwitch.Enabled)
231229
System.Diagnostics.Trace.TraceInformation(
232-
DateTime.Now.ToLongTimeString() + " " + DateTime.Now.Millisecond + " " +
233-
Environment.CurrentManagedThreadId +
234-
": SiteOfOriginContainer: Creating SiteOfOriginPart for Uri " + uri);
230+
$"{DateTime.Now:T} {DateTime.Now.Millisecond} {Environment.CurrentManagedThreadId}: SiteOfOriginContainer: Creating SiteOfOriginPart for Uri {uri}");
235231
#endif
236232
return new SiteOfOriginPart(this, uri);
237233
}

src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/AppModel/SiteOfOriginPart.cs

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,7 @@ protected override Stream GetStreamCore(FileMode mode, FileAccess access)
5555
#if DEBUG
5656
if (SiteOfOriginContainer._traceSwitch.Enabled)
5757
System.Diagnostics.Trace.TraceInformation(
58-
DateTime.Now.ToLongTimeString() + " " + DateTime.Now.Millisecond + " " +
59-
Environment.CurrentManagedThreadId +
60-
": SiteOfOriginPart: Getting stream.");
58+
$"{DateTime.Now:T} {DateTime.Now.Millisecond} {Environment.CurrentManagedThreadId}: SiteOfOriginPart: Getting stream.");
6159
#endif
6260
return GetStreamAndSetContentType(false);
6361
}
@@ -67,9 +65,7 @@ protected override string GetContentTypeCore()
6765
#if DEBUG
6866
if (SiteOfOriginContainer._traceSwitch.Enabled)
6967
System.Diagnostics.Trace.TraceInformation(
70-
DateTime.Now.ToLongTimeString() + " " + DateTime.Now.Millisecond + " " +
71-
Environment.CurrentManagedThreadId +
72-
": SiteOfOriginPart: Getting content type.");
68+
$"{DateTime.Now:T} {DateTime.Now.Millisecond} {Environment.CurrentManagedThreadId}: SiteOfOriginPart: Getting content type.");
7369
#endif
7470

7571
GetStreamAndSetContentType(true);
@@ -95,9 +91,7 @@ private Stream GetStreamAndSetContentType(bool onlyNeedContentType)
9591
#if DEBUG
9692
if (SiteOfOriginContainer._traceSwitch.Enabled)
9793
System.Diagnostics.Trace.TraceInformation(
98-
DateTime.Now.ToLongTimeString() + " " + DateTime.Now.Millisecond + " " +
99-
Environment.CurrentManagedThreadId +
100-
": SiteOfOriginPart: Getting content type and using previously determined value");
94+
$"{DateTime.Now:T} {DateTime.Now.Millisecond} {Environment.CurrentManagedThreadId}: SiteOfOriginPart: Getting content type and using previously determined value");
10195
#endif
10296
return null;
10397
}
@@ -111,9 +105,7 @@ private Stream GetStreamAndSetContentType(bool onlyNeedContentType)
111105
#if DEBUG
112106
if (SiteOfOriginContainer._traceSwitch.Enabled)
113107
System.Diagnostics.Trace.TraceInformation(
114-
DateTime.Now.ToLongTimeString() + " " + DateTime.Now.Millisecond + " " +
115-
Environment.CurrentManagedThreadId +
116-
"SiteOfOriginPart: Using Cached stream");
108+
$"{DateTime.Now:T} {DateTime.Now.Millisecond} {Environment.CurrentManagedThreadId}SiteOfOriginPart: Using Cached stream");
117109
#endif
118110
Stream temp = _cacheStream;
119111
_cacheStream = null;
@@ -125,9 +117,7 @@ private Stream GetStreamAndSetContentType(bool onlyNeedContentType)
125117
#if DEBUG
126118
if (SiteOfOriginContainer._traceSwitch.Enabled)
127119
System.Diagnostics.Trace.TraceInformation(
128-
DateTime.Now.ToLongTimeString() + " " + DateTime.Now.Millisecond + " " +
129-
Environment.CurrentManagedThreadId +
130-
": SiteOfOriginPart: Determining absolute uri for this resource");
120+
$"{DateTime.Now:T} {DateTime.Now.Millisecond} {Environment.CurrentManagedThreadId}: SiteOfOriginPart: Determining absolute uri for this resource");
131121
#endif
132122
string original = Uri.ToString();
133123
Invariant.Assert(original[0] == '/');
@@ -138,9 +128,7 @@ private Stream GetStreamAndSetContentType(bool onlyNeedContentType)
138128
#if DEBUG
139129
if (SiteOfOriginContainer._traceSwitch.Enabled)
140130
System.Diagnostics.Trace.TraceInformation(
141-
DateTime.Now.ToLongTimeString() + " " + DateTime.Now.Millisecond + " " +
142-
Environment.CurrentManagedThreadId +
143-
": SiteOfOriginPart: Making web request to " + _absoluteLocation);
131+
$"{DateTime.Now:T} {DateTime.Now.Millisecond} {Environment.CurrentManagedThreadId}: SiteOfOriginPart: Making web request to {_absoluteLocation}");
144132
#endif
145133

146134
// For performance reasons it is better to open local files directly
@@ -164,9 +152,7 @@ private Stream HandleFileSource(bool onlyNeedContentType)
164152
#if DEBUG
165153
if (SiteOfOriginContainer._traceSwitch.Enabled)
166154
System.Diagnostics.Trace.TraceInformation(
167-
DateTime.Now.ToLongTimeString() + " " + DateTime.Now.Millisecond + " " +
168-
Environment.CurrentManagedThreadId +
169-
": Opening local file " + _absoluteLocation);
155+
$"{DateTime.Now:T} {DateTime.Now.Millisecond} {Environment.CurrentManagedThreadId}: Opening local file {_absoluteLocation}");
170156
#endif
171157
if (_contentType == MS.Internal.ContentType.Empty)
172158
{
@@ -188,19 +174,15 @@ private Stream HandleWebSource(bool onlyNeedContentType)
188174
#if DEBUG
189175
if (SiteOfOriginContainer._traceSwitch.Enabled)
190176
System.Diagnostics.Trace.TraceInformation(
191-
DateTime.Now.ToLongTimeString() + " " + DateTime.Now.Millisecond + " " +
192-
Environment.CurrentManagedThreadId +
193-
": Successfully retrieved stream from " + _absoluteLocation);
177+
$"{DateTime.Now:T} {DateTime.Now.Millisecond} {Environment.CurrentManagedThreadId}: Successfully retrieved stream from {_absoluteLocation}");
194178
#endif
195179

196180
if (_contentType == MS.Internal.ContentType.Empty)
197181
{
198182
#if DEBUG
199183
if (SiteOfOriginContainer._traceSwitch.Enabled)
200184
System.Diagnostics.Trace.TraceInformation(
201-
DateTime.Now.ToLongTimeString() + " " + DateTime.Now.Millisecond + " " +
202-
Environment.CurrentManagedThreadId +
203-
": SiteOfOriginPart: Setting _contentType");
185+
$"{DateTime.Now:T} {DateTime.Now.Millisecond} {Environment.CurrentManagedThreadId}: SiteOfOriginPart: Setting _contentType");
204186
#endif
205187

206188
_contentType = WpfWebRequestHelper.GetContentType(response);

src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/FontCache/FontCacheUtil.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ internal static string CompositeFontExtension
321321

322322
static Util()
323323
{
324-
string s = Environment.GetEnvironmentVariable(WinDir) + @"\Fonts\";
324+
string s = $@"{Environment.GetEnvironmentVariable(WinDir)}\Fonts\";
325325

326326
_windowsFontsLocalPath = s.ToUpperInvariant();
327327

@@ -537,7 +537,7 @@ internal static Uri CombineUriWithFaceIndex(string fontUri, int faceIndex)
537537
// so that they don't conflict with the fragment part.
538538
string canonicalPathUri = new Uri(fontUri).GetComponents(UriComponents.AbsoluteUri, UriFormat.SafeUnescaped);
539539
string faceIndexString = faceIndex.ToString(CultureInfo.InvariantCulture);
540-
return new Uri(canonicalPathUri + '#' + faceIndexString);
540+
return new Uri($"{canonicalPathUri}#{faceIndexString}");
541541
}
542542

543543
internal static bool IsSupportedFontExtension(string extension, out bool isComposite)
@@ -661,7 +661,7 @@ private static string NormalizeFontFamilyReference(string fontFamilyReference, i
661661
{
662662
// No fragment separator. The entire string is a family name so convert to uppercase
663663
// and add a fragment separator at the beginning.
664-
return string.Concat("#", fontFamilyReference.AsSpan(startIndex, length)).ToUpperInvariant();
664+
return $"#{fontFamilyReference.AsSpan(startIndex, length)}".ToUpperInvariant();
665665
}
666666
else if (fragmentIndex + 1 == startIndex + length)
667667
{
@@ -701,11 +701,7 @@ internal static string ConvertFamilyNameAndLocationToFontFamilyReference(string
701701
if (!string.IsNullOrEmpty(location))
702702
{
703703
// We just escaped the family name and the location part should already be a valid URI reference.
704-
fontFamilyReference = string.Concat(
705-
location,
706-
"#",
707-
fontFamilyReference
708-
);
704+
fontFamilyReference = $"{location}#{fontFamilyReference}";
709705
}
710706

711707
return fontFamilyReference;

src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/FontCache/FontSourceCollection.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ private void SetFontSources()
130130
{
131131
if (_tryGetCompositeFontsOnly)
132132
{
133-
files = Directory.GetFiles(_uri.LocalPath, "*" + Util.CompositeFontExtension);
133+
files = Directory.GetFiles(_uri.LocalPath, $"*{Util.CompositeFontExtension}");
134134
isOnlyCompositeFontFiles = true;
135135
}
136136
else
@@ -168,7 +168,7 @@ private void SetFontSources()
168168
{
169169
if (_tryGetCompositeFontsOnly)
170170
{
171-
files = Directory.GetFiles(_uri.LocalPath, "*" + Util.CompositeFontExtension);
171+
files = Directory.GetFiles(_uri.LocalPath, $"*{Util.CompositeFontExtension}");
172172
isOnlyCompositeFontFiles = true;
173173
}
174174
else
@@ -269,7 +269,7 @@ System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
269269
private bool _tryGetCompositeFontsOnly;
270270

271271
private const string InstalledWindowsFontsRegistryKey = @"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts";
272-
private const string InstalledWindowsFontsRegistryKeyFullPath = @"HKEY_LOCAL_MACHINE\" + InstalledWindowsFontsRegistryKey;
272+
private const string InstalledWindowsFontsRegistryKeyFullPath = $@"HKEY_LOCAL_MACHINE\{InstalledWindowsFontsRegistryKey}";
273273
}
274274
}
275275

src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/FontFace/CompositeFontParser.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ private void ParseFontFamilyCollectionElement()
353353

354354
if (!foundOsSection)
355355
{
356-
Fail(string.Format("No FontFamily element found in FontFamilyCollection that matches current OS or greater: {0}", OSVersionHelper.GetOsVersion().ToString()));
356+
Fail($"No FontFamily element found in FontFamilyCollection that matches current OS or greater: {OSVersionHelper.GetOsVersion()}");
357357
}
358358
}
359359

src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/ExtendedProperty.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,13 @@ public override string ToString()
131131
}
132132
else if (Value is string)
133133
{
134-
val = "\"" + Value.ToString() + "\"";
134+
val = $"\"{Value}\"";
135135
}
136136
else
137137
{
138138
val = Value.ToString();
139139
}
140-
return KnownIds.ConvertToString(Id) + "," + val;
140+
return $"{KnownIds.ConvertToString(Id)},{val}";
141141
}
142142

143143
/// <summary>

src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/GestureRecognizer/NativeRecognizer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,7 @@ enum RECO_TYPE : ushort
794794
}
795795

796796
private const string GestureRecognizerPath = @"SOFTWARE\MICROSOFT\TPG\SYSTEM RECOGNIZERS\{BED9A940-7D48-48E3-9A68-F4887A5A1B2E}";
797-
private const string GestureRecognizerFullPath = "HKEY_LOCAL_MACHINE" + @"\" + GestureRecognizerPath;
797+
private const string GestureRecognizerFullPath = $@"HKEY_LOCAL_MACHINE\{GestureRecognizerPath}";
798798
private const string GestureRecognizerValueName = "RECOGNIZER DLL";
799799
private const string GestureRecognizerGuid = "{BED9A940-7D48-48E3-9A68-F4887A5A1B2E}";
800800

0 commit comments

Comments
 (0)