From bbfc24fd13804a191e20064acd599b0a359092df Mon Sep 17 00:00:00 2001 From: h3xds1nz Date: Wed, 20 Nov 2024 17:40:51 +0100 Subject: [PATCH] Cleanup rest of string.Compare[Ordinal] equality checks and replace it with string.Equals (#9740) * Clean-up most of string.Compare[Ordinal] and replace it with string.Equals instead * Remove null check that's not needed --- .../Internal/MarkupCompiler/MarkupCompiler.cs | 8 ++-- .../MarkupCompiler/ParserExtension.cs | 2 +- .../MS/Internal/Tasks/CompilerWrapper.cs | 2 +- .../Tasks/IncrementalCompileAnalyzer.cs | 4 +- .../Build/Tasks/Windows/FileClassifier.cs | 18 +++----- .../GenerateTemporaryTargetAssembly.cs | 6 +-- .../Build/Tasks/Windows/MarkupCompilePass1.cs | 26 ++++------- .../MS/internal/FontCache/FontCacheUtil.cs | 2 +- .../Internal/AppModel/AppSecurityManager.cs | 2 +- .../MS/Internal/AppModel/ResourcePart.cs | 4 +- .../MS/Internal/AppModel/ReturnEventSaver.cs | 2 +- .../Controls/CustomCategoryAttribute.cs | 6 +-- .../MS/Internal/Controls/WebBrowserEvent.cs | 17 +++---- .../Globalization/LocalizationComments.cs | 2 +- .../MS/Win32/UxThemeWrapper.cs | 2 +- .../System/Windows/Application.cs | 4 +- .../System/Windows/Controls/DataGrid.cs | 2 +- .../Windows/Controls/DataGridBoundColumn.cs | 11 ++--- .../Controls/DataGridCheckBoxColumn.cs | 7 +-- .../Controls/DataGridColumnCollection.cs | 3 +- .../Controls/DataGridComboBoxColumn.cs | 7 ++- .../Controls/DataGridHyperlinkColumn.cs | 7 ++- .../Controls/DataGridTemplateColumn.cs | 11 ++--- .../System/Windows/Controls/DatePicker.cs | 4 +- .../Primitives/DataGridCellsPresenter.cs | 8 ++-- .../DataGridColumnHeadersPresenter.cs | 8 ++-- .../Windows/Controls/Primitives/Popup.cs | 2 +- .../System/Windows/Controls/TextSearch.cs | 3 +- .../Windows/Documents/FixedFindEngine.cs | 10 +--- .../Windows/Documents/RtfToXamlReader.cs | 2 +- .../System/Windows/Documents/Speller.cs | 2 +- .../Documents/TextRangeSerialization.cs | 3 +- .../Windows/Documents/XamlToRtfWriter.cs | 46 +++++++++---------- .../System/Windows/Markup/BamlMapTable.cs | 2 +- .../System/Windows/Markup/XamlReaderHelper.cs | 2 +- .../System/Windows/Markup/XamlTypeMapper.cs | 10 ++-- .../System/Windows/Navigation/JournalEntry.cs | 6 +-- .../Windows/Navigation/NavigationService.cs | 6 +-- .../IO/Packaging/PackagingUtilities.cs | 3 +- .../Shared/MS/Internal/SafeSecurityHelper.cs | 4 +- .../Windows/Controls/TextSearchInternal.cs | 6 +-- .../System/Xaml/XamlObjectReader.cs | 4 +- .../MS/Internal/Automation/ProxyManager.cs | 2 +- .../Automation/WindowShowOrOpenTracker.cs | 2 +- .../AutomationProxies/MSAANativeProvider.cs | 8 ++-- .../AutomationProxies/WindowsComboBox.cs | 2 +- .../AutomationProxies/WindowsListView.cs | 2 +- .../Internal/AutomationProxies/WindowsMenu.cs | 5 +- .../AutomationProxies/WindowsRichEditRange.cs | 2 +- .../AutomationProxies/WindowsScroll.cs | 2 +- .../AutomationProxies/WindowsTooltip.cs | 10 ++-- 51 files changed, 140 insertions(+), 181 deletions(-) diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/MarkupCompiler/MarkupCompiler.cs b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/MarkupCompiler/MarkupCompiler.cs index 00edbad252f..8b24771d9e6 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/MarkupCompiler/MarkupCompiler.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/MarkupCompiler/MarkupCompiler.cs @@ -1364,14 +1364,14 @@ private void InitializeTypeMapper() private bool SwitchStatementSupported() { - return (IsLanguageCSharp || (CompilerInfo != null && (string.Compare(CompilerInfo.GetLanguages()[0], JSCRIPT, StringComparison.OrdinalIgnoreCase) == 0))); + return IsLanguageCSharp || (CompilerInfo != null && string.Equals(CompilerInfo.GetLanguages()[0], JSCRIPT, StringComparison.OrdinalIgnoreCase)); } private bool IsInternalAccessSupported { get { - return (CompilerInfo == null || (string.Compare(CompilerInfo.GetLanguages()[0], JSHARP, StringComparison.OrdinalIgnoreCase) != 0)); + return CompilerInfo == null || !string.Equals(CompilerInfo.GetLanguages()[0], JSHARP, StringComparison.OrdinalIgnoreCase); } } @@ -2112,7 +2112,7 @@ private CodeDomProvider EnsureCodeProvider() private bool IsLanguageSupported(string language) { _language = language; - _isLangCSharp = string.Compare(language, CSHARP, StringComparison.OrdinalIgnoreCase) == 0; + _isLangCSharp = string.Equals(language, CSHARP, StringComparison.OrdinalIgnoreCase); if (IsLanguageCSharp) { @@ -2121,7 +2121,7 @@ private bool IsLanguageSupported(string language) } else { - _isLangVB = string.Compare(language, VB, StringComparison.OrdinalIgnoreCase) == 0; + _isLangVB = string.Equals(language, VB, StringComparison.OrdinalIgnoreCase); if (IsLanguageVB) { _codeProvider = new Microsoft.VisualBasic.VBCodeProvider(); diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/MarkupCompiler/ParserExtension.cs b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/MarkupCompiler/ParserExtension.cs index 366c4766be0..dfed32e89bf 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/MarkupCompiler/ParserExtension.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/MarkupCompiler/ParserExtension.cs @@ -497,7 +497,7 @@ public override bool GetElementType( { // This direct comparison is ok to do in pass2 as it has already been validated in pass1. // This is to avoid a costly instantiation of the CodeDomProvider in pass2. - _isInternalRoot = string.Compare("public", xmlReader.Value.Trim(), StringComparison.OrdinalIgnoreCase) != 0; + _isInternalRoot = !string.Equals("public", xmlReader.Value.Trim(), StringComparison.OrdinalIgnoreCase); } } } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/Tasks/CompilerWrapper.cs b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/Tasks/CompilerWrapper.cs index 4e2a642c3c6..624a8dd29da 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/Tasks/CompilerWrapper.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/Tasks/CompilerWrapper.cs @@ -261,7 +261,7 @@ internal bool DoCompilation(string assemblyName, string language, string rootNam if (asmReference != null) { - if (String.Compare(asmReference.AssemblyName, assemblyName, StringComparison.OrdinalIgnoreCase) == 0) + if (string.Equals(asmReference.AssemblyName, assemblyName, StringComparison.OrdinalIgnoreCase)) { // Set the local assembly file to markupCompiler _mc.LocalAssemblyFile = asmReference; diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/Tasks/IncrementalCompileAnalyzer.cs b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/Tasks/IncrementalCompileAnalyzer.cs index e2bb9b3494d..4a8cd3c5c45 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/Tasks/IncrementalCompileAnalyzer.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/MS/Internal/Tasks/IncrementalCompileAnalyzer.cs @@ -350,7 +350,7 @@ private bool IsSettingModified(string textSource, string textTarget) } else // Both source and target strings are not empty. { - IsSettingModified = String.Compare(textSource, textTarget, StringComparison.OrdinalIgnoreCase) == 0 ? false : true; + IsSettingModified = !string.Equals(textSource, textTarget, StringComparison.OrdinalIgnoreCase); } } @@ -426,7 +426,7 @@ private void UpdateFileListForIncrementalBuild(List modifiedXamlFiles) { for (int j = 0; j < numLocalTypeXamls; j++) { - if (String.Compare(xamlfile.Path, CompilerLocalReference.LocalMarkupPages[j].FilePath, StringComparison.OrdinalIgnoreCase) == 0) + if (string.Equals(xamlfile.Path, CompilerLocalReference.LocalMarkupPages[j].FilePath, StringComparison.OrdinalIgnoreCase)) { addToList = false; break; diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Microsoft/Build/Tasks/Windows/FileClassifier.cs b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Microsoft/Build/Tasks/Windows/FileClassifier.cs index f5cb0257c0d..71f779eca95 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Microsoft/Build/Tasks/Windows/FileClassifier.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Microsoft/Build/Tasks/Windows/FileClassifier.cs @@ -329,25 +329,19 @@ private void Classify(IEnumerable inputItems, List mainLis // private bool IsItemLocalizable(ITaskItem fileItem) { - bool isLocalizable = false; - // if the default culture is not set, by default all // the items are not localizable. + bool isLocalizable = false; - if (Culture != null && Culture.Equals("") == false) + if (!string.IsNullOrEmpty(Culture)) { - string localizableString; + string localizableString = fileItem.GetMetadata(SharedStrings.Localizable); // Default culture is set, by default the item is localizable - // unless it is set as false in the Localizable attribute. - - isLocalizable = true; - - localizableString = fileItem.GetMetadata(SharedStrings.Localizable); - - if (localizableString != null && String.Compare(localizableString, "false", StringComparison.OrdinalIgnoreCase) ==0 ) + // unless it is set as false in the Localizable attribute. + if (!string.Equals(localizableString, "false", StringComparison.OrdinalIgnoreCase)) { - isLocalizable = false; + isLocalizable = true; } } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Microsoft/Build/Tasks/Windows/GenerateTemporaryTargetAssembly.cs b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Microsoft/Build/Tasks/Windows/GenerateTemporaryTargetAssembly.cs index b282d5c4c2a..0fd4fa34342 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Microsoft/Build/Tasks/Windows/GenerateTemporaryTargetAssembly.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Microsoft/Build/Tasks/Windows/GenerateTemporaryTargetAssembly.cs @@ -91,7 +91,7 @@ public GenerateTemporaryTargetAssembly() [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")] public override bool Execute() { - if (string.Compare(IncludePackageReferencesDuringMarkupCompilation, "false", StringComparison.OrdinalIgnoreCase) != 0) + if (!string.Equals(IncludePackageReferencesDuringMarkupCompilation, "false", StringComparison.OrdinalIgnoreCase)) { return ExecuteGenerateTemporaryTargetAssemblyWithPackageReferenceSupport(); } @@ -638,7 +638,7 @@ private void RemoveEntityByName(XmlDocument xmlProjectDoc, string sItemName, str { XmlElement nodeGroup = root.ChildNodes[i] as XmlElement; - if (nodeGroup != null && String.Compare(nodeGroup.Name, groupName, StringComparison.OrdinalIgnoreCase) == 0) + if (nodeGroup != null && string.Equals(nodeGroup.Name, groupName, StringComparison.OrdinalIgnoreCase)) { // // This is ItemGroup element. @@ -651,7 +651,7 @@ private void RemoveEntityByName(XmlDocument xmlProjectDoc, string sItemName, str { XmlElement nodeItem = nodeGroup.ChildNodes[j] as XmlElement; - if (nodeItem != null && String.Compare(nodeItem.Name, sItemName, StringComparison.OrdinalIgnoreCase) == 0) + if (nodeItem != null && string.Equals(nodeItem.Name, sItemName, StringComparison.OrdinalIgnoreCase)) { // This is the item that need to remove. // Add it into the temporary array list. diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Microsoft/Build/Tasks/Windows/MarkupCompilePass1.cs b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Microsoft/Build/Tasks/Windows/MarkupCompilePass1.cs index 57b08bcea40..d3b96aa0482 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Microsoft/Build/Tasks/Windows/MarkupCompilePass1.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Microsoft/Build/Tasks/Windows/MarkupCompilePass1.cs @@ -1545,7 +1545,7 @@ private LocalReferenceFile GenerateLocalTypeItem(string localTypeXamlFile, ITask string xamlInputFullPath = TaskHelper.CreateFullFilePath(inputXamlItem.ItemSpec, SourceDir); - if (String.Compare(localTypeXamlFile, xamlInputFullPath, StringComparison.OrdinalIgnoreCase) == 0) + if (string.Equals(localTypeXamlFile, xamlInputFullPath, StringComparison.OrdinalIgnoreCase)) { // // Got this file from the original XamlFile TaskItem list. @@ -1710,27 +1710,19 @@ private TaskItem ProcessLocFileForXamlItem(ITaskItem xamlItem) // private bool IsItemLocalizable(ITaskItem ti) { - bool bIsLocalizable; + // if UICulture is not set, all baml files are not localizable. + // The Localizable metadata value is ignored for this case. + bool bIsLocalizable = false; - if (String.IsNullOrEmpty(UICulture)) - { - // if UICulture is not set, all baml files are not localizable. - // The Localizable metadate value is ignored for this case. - bIsLocalizable = false; - } - else - { - string strLocalizable; + if (!string.IsNullOrEmpty(UICulture)) + { + string strLocalizable = ti.GetMetadata(SharedStrings.Localizable); // if UICulture is set, by default all the baml files are localizable unless // an explicit value "false" is set to Localizable metadata. - bIsLocalizable = true; - - strLocalizable = ti.GetMetadata(SharedStrings.Localizable); - - if (strLocalizable != null && String.Compare(strLocalizable, "false", StringComparison.OrdinalIgnoreCase) == 0) + if (!string.Equals(strLocalizable, "false", StringComparison.OrdinalIgnoreCase)) { - bIsLocalizable = false; + bIsLocalizable = true; } } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/FontCache/FontCacheUtil.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/FontCache/FontCacheUtil.cs index 7dc1e9e3892..b19d4f88bb2 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/FontCache/FontCacheUtil.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/FontCache/FontCacheUtil.cs @@ -968,7 +968,7 @@ private class LanguageComparerClass : IComparer int IComparer.Compare(LocalizedName x, LocalizedName y) { - return String.Compare(x._language.IetfLanguageTag, y._language.IetfLanguageTag, StringComparison.OrdinalIgnoreCase); + return string.Compare(x._language.IetfLanguageTag, y._language.IetfLanguageTag, StringComparison.OrdinalIgnoreCase); } #endregion diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/AppSecurityManager.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/AppSecurityManager.cs index 7ea040e1db7..f819a711b0a 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/AppSecurityManager.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/AppSecurityManager.cs @@ -88,7 +88,7 @@ internal static LaunchResult SafeLaunchBrowserOnlyIfPossible(Uri originatingUri, (Object.ReferenceEquals(destinationUri.Scheme, Uri.UriSchemeHttps)) || destinationUri.IsFile; - bool fIsMailTo = String.Compare(destinationUri.Scheme, Uri.UriSchemeMailto, StringComparison.OrdinalIgnoreCase) == 0; + bool fIsMailTo = string.Equals(destinationUri.Scheme, Uri.UriSchemeMailto, StringComparison.OrdinalIgnoreCase); // We elevate to navigate the browser iff: // We are user initiated AND diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/ResourcePart.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/ResourcePart.cs index 15643f72106..b4f5115abda 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/ResourcePart.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/ResourcePart.cs @@ -132,12 +132,12 @@ private Stream EnsureResourceLocationSet() { // We do not allow the use of .baml in any Avalon public APIs. This is the code pass needed to go through for loading baml file. // Throw here we will catch all those cases. - if (String.Compare(Path.GetExtension(_name), ResourceContainer.BamlExt, StringComparison.OrdinalIgnoreCase) == 0) + if (string.Equals(Path.GetExtension(_name), ResourceContainer.BamlExt, StringComparison.OrdinalIgnoreCase)) { throw new IOException(SR.Format(SR.UnableToLocateResource, _name)); } - if (String.Compare(Path.GetExtension(_name), ResourceContainer.XamlExt, StringComparison.OrdinalIgnoreCase) == 0) + if (string.Equals(Path.GetExtension(_name), ResourceContainer.XamlExt, StringComparison.OrdinalIgnoreCase)) { // try baml extension first since it's our most common senario. string newName = Path.ChangeExtension(_name, ResourceContainer.BamlExt); diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/ReturnEventSaver.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/ReturnEventSaver.cs index b5aae7a6344..e247ea7f99e 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/ReturnEventSaver.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/AppModel/ReturnEventSaver.cs @@ -119,7 +119,7 @@ internal void _Attach(Object caller, PageFunctionBase child) // E.g. - if we had a listener to OnFinish from a Button on the calling page. // "Return event never fired from PageFunction hosted in its own window" // - if (string.Compare(_returnList[i]._targetTypeName, caller.GetType().AssemblyQualifiedName, StringComparison.Ordinal) != 0) + if (!string.Equals(_returnList[i]._targetTypeName, caller.GetType().AssemblyQualifiedName, StringComparison.Ordinal)) { throw new NotSupportedException(SR.ReturnEventHandlerMustBeOnParentPage); } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Controls/CustomCategoryAttribute.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Controls/CustomCategoryAttribute.cs index 29ea40ae614..e597c6c98c0 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Controls/CustomCategoryAttribute.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Controls/CustomCategoryAttribute.cs @@ -28,11 +28,11 @@ internal CustomCategoryAttribute(string name) : base(name) protected override string GetLocalizedString(string value) { // Return a localized version of the custom category - if (String.Compare(value, "Content", StringComparison.Ordinal) == 0) + if (string.Equals(value, "Content", StringComparison.Ordinal)) return SR.DesignerMetadata_CustomCategory_Content; - else if(String.Compare(value, "Accessibility", StringComparison.Ordinal) == 0) + else if (string.Equals(value, "Accessibility", StringComparison.Ordinal)) return SR.DesignerMetadata_CustomCategory_Accessibility; - else /*if(String.Compare(value, "Navigation", StringComparison.Ordinal) == 0)*/ + else // if (string.Equals(value, "Navigation", StringComparison.Ordinal)) return SR.DesignerMetadata_CustomCategory_Navigation; } } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Controls/WebBrowserEvent.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Controls/WebBrowserEvent.cs index dc7176b3fa8..a2c811a7e6f 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Controls/WebBrowserEvent.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Controls/WebBrowserEvent.cs @@ -85,8 +85,7 @@ public void BeforeNavigate2(object pDisp, ref object url, ref object flags, ref // on a hyperlink, Goback/Forward), or programmatically call GoBack and Forward, // When we get the navigating event, NavigatingToAboutBlank is true, but the source is not "about:blank". // Clear the NavigatingToAboutBlank bit in that case. - if ((_parent.NavigatingToAboutBlank) && - String.Compare(urlString, WebBrowser.AboutBlankUriString, StringComparison.OrdinalIgnoreCase) != 0) + if ((_parent.NavigatingToAboutBlank) && !string.Equals(urlString, WebBrowser.AboutBlankUriString, StringComparison.OrdinalIgnoreCase)) { _parent.NavigatingToAboutBlank = false; } @@ -181,8 +180,7 @@ public void NavigateComplete2(object pDisp, ref object url) // If we are loading from stream. if (_parent.DocumentStream != null) { - Invariant.Assert(_parent.NavigatingToAboutBlank && - (String.Compare((string)url, WebBrowser.AboutBlankUriString, StringComparison.OrdinalIgnoreCase) == 0)); + Invariant.Assert(_parent.NavigatingToAboutBlank && string.Equals((string)url, WebBrowser.AboutBlankUriString, StringComparison.OrdinalIgnoreCase)); try { @@ -210,10 +208,10 @@ public void NavigateComplete2(object pDisp, ref object url) // internally. Make sure we pass null in the event args. if (_parent.NavigatingToAboutBlank) { - Invariant.Assert(String.Compare(urlString, WebBrowser.AboutBlankUriString, StringComparison.OrdinalIgnoreCase) == 0); + Invariant.Assert(string.Equals(urlString, WebBrowser.AboutBlankUriString, StringComparison.OrdinalIgnoreCase)); urlString = null; } - Uri source = (String.IsNullOrEmpty(urlString) ? null : new Uri(urlString)); + Uri source = string.IsNullOrEmpty(urlString) ? null : new Uri(urlString); NavigationEventArgs e = new NavigationEventArgs(source, null, null, null, null, true); _parent.OnNavigated(e); @@ -238,10 +236,10 @@ public void DocumentComplete(object pDisp, ref object url) // internally. Make sure we pass null in the event args. if (_parent.NavigatingToAboutBlank) { - Invariant.Assert(String.Compare(urlString, WebBrowser.AboutBlankUriString, StringComparison.OrdinalIgnoreCase) == 0); + Invariant.Assert(string.Equals(urlString, WebBrowser.AboutBlankUriString, StringComparison.OrdinalIgnoreCase)); urlString = null; } - Uri source = (String.IsNullOrEmpty(urlString) ? null : new Uri(urlString)); + Uri source = string.IsNullOrEmpty(urlString) ? null : new Uri(urlString); NavigationEventArgs e = new NavigationEventArgs(source, null, null, null, null, true); _parent.OnLoadCompleted(e); @@ -255,8 +253,7 @@ public void DocumentComplete(object pDisp, ref object url) private bool ShouldIgnoreCompletionEvent(ref object url) { string urlString = url as string; - return (_parent.NavigatingToAboutBlank && - String.Compare(urlString, WebBrowser.AboutBlankUriString, StringComparison.OrdinalIgnoreCase) != 0); + return _parent.NavigatingToAboutBlank && !string.Equals(urlString, WebBrowser.AboutBlankUriString, StringComparison.OrdinalIgnoreCase); } public void CommandStateChange(long command, bool enable) diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Globalization/LocalizationComments.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Globalization/LocalizationComments.cs index 7ec491b68e2..fcafe2e7db3 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Globalization/LocalizationComments.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Globalization/LocalizationComments.cs @@ -368,7 +368,7 @@ internal bool TryGet(string enumName, out int enumIndex) for (int i = 0; i < _enumNames.Length; i++) { - if (string.Compare(enumName, _enumNames[i], StringComparison.Ordinal) == 0) + if (string.Equals(enumName, _enumNames[i], StringComparison.Ordinal)) { enumIndex = i; return true; diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Win32/UxThemeWrapper.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Win32/UxThemeWrapper.cs index 0bd909cc21c..67a08749841 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Win32/UxThemeWrapper.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Win32/UxThemeWrapper.cs @@ -270,7 +270,7 @@ private static void GetThemeNameAndColor(out string themeName, out string themeC themeName = themeNameSB.ToString(); themeName = Path.GetFileNameWithoutExtension(themeName); - if(String.Compare(themeName, "aero", StringComparison.OrdinalIgnoreCase) == 0 && Utilities.IsOSWindows8OrNewer) + if(string.Equals(themeName, "aero", StringComparison.OrdinalIgnoreCase) && Utilities.IsOSWindows8OrNewer) { themeName = "Aero2"; } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Application.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Application.cs index 5d22a1791ed..929a2b56911 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Application.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Application.cs @@ -2438,7 +2438,7 @@ private static bool IsComponentBeingLoadedFromOuterLoadBaml(Uri curComponentUri) Invariant.Assert(fileInBamlConvert != null, "fileInBamlConvert should not be null"); Invariant.Assert(fileCurrent != null, "fileCurrent should not be null"); - if (String.Compare(fileInBamlConvert, fileCurrent, StringComparison.OrdinalIgnoreCase) == 0) + if (string.Equals(fileInBamlConvert, fileCurrent, StringComparison.OrdinalIgnoreCase)) { // // This is the root element of the xaml page which is being loaded to creat a tree @@ -2465,7 +2465,7 @@ private static bool IsComponentBeingLoadedFromOuterLoadBaml(Uri curComponentUri) if (Math.Abs(diff) == 1) { // Check whether the file name is the same. - if (String.Compare(bamlConvertUriSegments[l - 1], curUriSegments[m - 1], StringComparison.OrdinalIgnoreCase) == 0) + if (string.Equals(bamlConvertUriSegments[l - 1], curUriSegments[m - 1], StringComparison.OrdinalIgnoreCase)) { string component = (diff == 1) ? bamlConvertUriSegments[1] : curUriSegments[1]; diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/DataGrid.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/DataGrid.cs index 0f1754f9109..9eec6828583 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/DataGrid.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/DataGrid.cs @@ -7220,7 +7220,7 @@ private void DefaultSort(DataGridColumn column, bool clearExistingSortDescriptio // get the index of existing descriptor to replace it for (int i = 0; i < Items.SortDescriptions.Count; i++) { - if (string.Compare(Items.SortDescriptions[i].PropertyName, sortPropertyName, StringComparison.Ordinal) == 0 && + if (string.Equals(Items.SortDescriptions[i].PropertyName, sortPropertyName, StringComparison.Ordinal) && (GroupingSortDescriptionIndices == null || !GroupingSortDescriptionIndices.Contains(i))) { diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/DataGridBoundColumn.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/DataGridBoundColumn.cs index a0e7a83a1e6..3e145a59947 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/DataGridBoundColumn.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/DataGridBoundColumn.cs @@ -211,13 +211,12 @@ public override BindingBase ClipboardContentBinding /// protected internal override void RefreshCellContent(FrameworkElement element, string propertyName) { - DataGridCell cell = element as DataGridCell; - if (cell != null) + if (element is DataGridCell cell) { bool isCellEditing = cell.IsEditing; - if ((string.Compare(propertyName, "Binding", StringComparison.Ordinal) == 0) || - (string.Compare(propertyName, "ElementStyle", StringComparison.Ordinal) == 0 && !isCellEditing) || - (string.Compare(propertyName, "EditingElementStyle", StringComparison.Ordinal) == 0 && isCellEditing)) + if ((string.Equals(propertyName, "Binding", StringComparison.Ordinal)) || + (string.Equals(propertyName, "ElementStyle", StringComparison.Ordinal) && !isCellEditing) || + (string.Equals(propertyName, "EditingElementStyle", StringComparison.Ordinal) && isCellEditing)) { cell.BuildVisualTree(); return; @@ -235,4 +234,4 @@ protected internal override void RefreshCellContent(FrameworkElement element, st #endregion } -} \ No newline at end of file +} diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/DataGridCheckBoxColumn.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/DataGridCheckBoxColumn.cs index c868b93c037..6122b5b4660 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/DataGridCheckBoxColumn.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/DataGridCheckBoxColumn.cs @@ -123,12 +123,9 @@ private CheckBox GenerateCheckBox(bool isEditing, DataGridCell cell) protected internal override void RefreshCellContent(FrameworkElement element, string propertyName) { - DataGridCell cell = element as DataGridCell; - if (cell != null && - string.Compare(propertyName, "IsThreeState", StringComparison.Ordinal) == 0) + if (element is DataGridCell cell && string.Equals(propertyName, "IsThreeState", StringComparison.Ordinal)) { - var checkBox = cell.Content as CheckBox; - if (checkBox != null) + if (cell.Content is CheckBox checkBox) { checkBox.IsThreeState = IsThreeState; } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/DataGridColumnCollection.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/DataGridColumnCollection.cs index c80dd4cf6fa..45a121f350a 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/DataGridColumnCollection.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/DataGridColumnCollection.cs @@ -201,8 +201,7 @@ internal void NotifyPropertyChanged(DependencyObject d, string propertyName, Dep { OnCellsPanelHorizontalOffsetChanged(e); } - else if (e.Property == DataGrid.HorizontalScrollOffsetProperty || - string.Compare(propertyName, "ViewportWidth", StringComparison.Ordinal) == 0) + else if (e.Property == DataGrid.HorizontalScrollOffsetProperty || string.Equals(propertyName, "ViewportWidth", StringComparison.Ordinal)) { InvalidateColumnRealization(false); } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/DataGridComboBoxColumn.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/DataGridComboBoxColumn.cs index db498105332..63d16f8cf1e 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/DataGridComboBoxColumn.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/DataGridComboBoxColumn.cs @@ -410,12 +410,11 @@ public string SelectedValuePath protected internal override void RefreshCellContent(FrameworkElement element, string propertyName) { - DataGridCell cell = element as DataGridCell; - if (cell != null) + if (element is DataGridCell cell) { bool isCellEditing = cell.IsEditing; - if ((string.Compare(propertyName, "ElementStyle", StringComparison.Ordinal) == 0 && !isCellEditing) || - (string.Compare(propertyName, "EditingElementStyle", StringComparison.Ordinal) == 0 && isCellEditing)) + if ((string.Equals(propertyName, "ElementStyle", StringComparison.Ordinal) && !isCellEditing) || + (string.Equals(propertyName, "EditingElementStyle", StringComparison.Ordinal) && isCellEditing)) { cell.BuildVisualTree(); } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/DataGridHyperlinkColumn.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/DataGridHyperlinkColumn.cs index f0ef78d92a1..d5dcc44375c 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/DataGridHyperlinkColumn.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/DataGridHyperlinkColumn.cs @@ -112,14 +112,13 @@ private void ApplyContentBinding(DependencyObject target, DependencyProperty pro /// protected internal override void RefreshCellContent(FrameworkElement element, string propertyName) { - DataGridCell cell = element as DataGridCell; - if (cell != null && !cell.IsEditing) + if (element is DataGridCell cell && !cell.IsEditing) { - if (string.Compare(propertyName, "ContentBinding", StringComparison.Ordinal) == 0) + if (string.Equals(propertyName, "ContentBinding", StringComparison.Ordinal)) { cell.BuildVisualTree(); } - else if (string.Compare(propertyName, "TargetName", StringComparison.Ordinal) == 0) + else if (string.Equals(propertyName, "TargetName", StringComparison.Ordinal)) { TextBlock outerBlock = cell.Content as TextBlock; if (outerBlock != null && outerBlock.Inlines.Count > 0) diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/DataGridTemplateColumn.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/DataGridTemplateColumn.cs index ad7479642e4..80c79490700 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/DataGridTemplateColumn.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/DataGridTemplateColumn.cs @@ -206,17 +206,16 @@ protected override FrameworkElement GenerateEditingElement(DataGridCell cell, ob /// protected internal override void RefreshCellContent(FrameworkElement element, string propertyName) { - DataGridCell cell = element as DataGridCell; - if (cell != null) + if (element is DataGridCell cell) { bool isCellEditing = cell.IsEditing; if ((!isCellEditing && - ((string.Compare(propertyName, "CellTemplate", StringComparison.Ordinal) == 0) || - (string.Compare(propertyName, "CellTemplateSelector", StringComparison.Ordinal) == 0))) || + (string.Equals(propertyName, "CellTemplate", StringComparison.Ordinal) || + string.Equals(propertyName, "CellTemplateSelector", StringComparison.Ordinal))) || (isCellEditing && - ((string.Compare(propertyName, "CellEditingTemplate", StringComparison.Ordinal) == 0) || - (string.Compare(propertyName, "CellEditingTemplateSelector", StringComparison.Ordinal) == 0)))) + (string.Equals(propertyName, "CellEditingTemplate", StringComparison.Ordinal) || + string.Equals(propertyName, "CellEditingTemplateSelector", StringComparison.Ordinal)))) { cell.BuildVisualTree(); return; diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/DatePicker.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/DatePicker.cs index ea4eba9c8ee..a4158234784 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/DatePicker.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/DatePicker.cs @@ -1201,7 +1201,7 @@ private void SetSelectedDate() // ex: SelectedDate = DateTime(1008,12,19) but when "12/19/08" is parsed it is interpreted as DateTime(2008,12,19) string selectedDate = DateTimeToString(this.SelectedDate.Value); - if (string.Compare(selectedDate, s, StringComparison.Ordinal) == 0) + if (string.Equals(selectedDate, s, StringComparison.Ordinal)) { return; } @@ -1237,7 +1237,7 @@ private void SetSelectedDate() /// private void SafeSetText(string s) { - if (string.Compare(Text, s, StringComparison.Ordinal) != 0) + if (!string.Equals(Text, s, StringComparison.Ordinal)) { SetCurrentValueInternal(TextProperty, s); } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/Primitives/DataGridCellsPresenter.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/Primitives/DataGridCellsPresenter.cs index 6b9fe3951a6..13d5ffe4f08 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/Primitives/DataGridCellsPresenter.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/Primitives/DataGridCellsPresenter.cs @@ -395,16 +395,16 @@ internal void NotifyPropertyChanged(DependencyObject d, string propertyName, Dep e.Property == DataGridColumn.VisibilityProperty || e.Property == DataGrid.CellsPanelHorizontalOffsetProperty || e.Property == DataGrid.HorizontalScrollOffsetProperty || - string.Compare(propertyName, "ViewportWidth", StringComparison.Ordinal) == 0 || - string.Compare(propertyName, "DelayedColumnWidthComputation", StringComparison.Ordinal) == 0) + string.Equals(propertyName, "ViewportWidth", StringComparison.Ordinal) || + string.Equals(propertyName, "DelayedColumnWidthComputation", StringComparison.Ordinal)) { InvalidateDataGridCellsPanelMeasureAndArrange(); } - else if (string.Compare(propertyName, "RealizedColumnsBlockListForNonVirtualizedRows", StringComparison.Ordinal) == 0) + else if (string.Equals(propertyName, "RealizedColumnsBlockListForNonVirtualizedRows", StringComparison.Ordinal)) { InvalidateDataGridCellsPanelMeasureAndArrange(/* withColumnVirtualization */ false); } - else if (string.Compare(propertyName, "RealizedColumnsBlockListForVirtualizedRows", StringComparison.Ordinal) == 0) + else if (string.Equals(propertyName, "RealizedColumnsBlockListForVirtualizedRows", StringComparison.Ordinal)) { InvalidateDataGridCellsPanelMeasureAndArrange(/* withColumnVirtualization */ true); } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/Primitives/DataGridColumnHeadersPresenter.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/Primitives/DataGridColumnHeadersPresenter.cs index d9366040dd9..71f6970c3c0 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/Primitives/DataGridColumnHeadersPresenter.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/Primitives/DataGridColumnHeadersPresenter.cs @@ -302,8 +302,8 @@ internal void NotifyPropertyChanged(DependencyObject d, string propertyName, Dep else if (e.Property == DataGrid.FrozenColumnCountProperty || e.Property == DataGridColumn.VisibilityProperty || e.Property == DataGrid.CellsPanelHorizontalOffsetProperty || - string.Compare(propertyName, "ViewportWidth", StringComparison.Ordinal) == 0 || - string.Compare(propertyName, "DelayedColumnWidthComputation", StringComparison.Ordinal) == 0) + string.Equals(propertyName, "ViewportWidth", StringComparison.Ordinal) || + string.Equals(propertyName, "DelayedColumnWidthComputation", StringComparison.Ordinal)) { InvalidateDataGridCellsPanelMeasureAndArrange(); } @@ -312,11 +312,11 @@ internal void NotifyPropertyChanged(DependencyObject d, string propertyName, Dep InvalidateArrange(); InvalidateDataGridCellsPanelMeasureAndArrange(); } - else if (string.Compare(propertyName, "RealizedColumnsBlockListForNonVirtualizedRows", StringComparison.Ordinal) == 0) + else if (string.Equals(propertyName, "RealizedColumnsBlockListForNonVirtualizedRows", StringComparison.Ordinal)) { InvalidateDataGridCellsPanelMeasureAndArrange(/* withColumnVirtualization */ false); } - else if (string.Compare(propertyName, "RealizedColumnsBlockListForVirtualizedRows", StringComparison.Ordinal) == 0) + else if (string.Equals(propertyName, "RealizedColumnsBlockListForVirtualizedRows", StringComparison.Ordinal)) { InvalidateDataGridCellsPanelMeasureAndArrange(/* withColumnVirtualization */ true); } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/Primitives/Popup.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/Primitives/Popup.cs index 52a6ec64406..390a6eb4429 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/Primitives/Popup.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/Primitives/Popup.cs @@ -3211,7 +3211,7 @@ private IntPtr GetLastWebOCHwnd() { if (UnsafeNativeMethods.GetClassName(new HandleRef(null, lastHwnd), sb, NativeMethods.MAX_PATH) != 0) { - if (String.Compare(sb.ToString(), WebOCWindowClassName, StringComparison.OrdinalIgnoreCase) == 0) + if (string.Equals(sb.ToString(), WebOCWindowClassName, StringComparison.OrdinalIgnoreCase)) { break; } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/TextSearch.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/TextSearch.cs index 03b64239c76..fe077c3cab9 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/TextSearch.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/TextSearch.cs @@ -211,8 +211,7 @@ internal bool DoSearch(string nextChar) // Fallback search is if they type "bob" and then press "b" // we'll look for "bobb" and when we don't find it we should // find the next item starting with "bob". - if (_charsEntered.Count > 0 - && (String.Compare(_charsEntered[_charsEntered.Count - 1], nextChar, true, GetCulture(_attachedTo))==0)) + if (_charsEntered.Count > 0 && string.Compare(_charsEntered[_charsEntered.Count - 1], nextChar, true, GetCulture(_attachedTo)) == 0) { repeatedChar = true; } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/FixedFindEngine.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/FixedFindEngine.cs index ab418bb992c..99fabb73398 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/FixedFindEngine.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/FixedFindEngine.cs @@ -382,7 +382,6 @@ private static String _ConstructPageString(Stream pageStream, bool reverseRTL) xmlReader.MoveToContent(); StringBuilder pageString = new StringBuilder(); - bool isSideways = false; string unicodeStr = null; while (xmlReader.Read()) @@ -395,15 +394,10 @@ private static String _ConstructPageString(Stream pageStream, bool reverseRTL) { unicodeStr = xmlReader.GetAttribute("UnicodeString"); - if (!String.IsNullOrEmpty(unicodeStr)) + if (!string.IsNullOrEmpty(unicodeStr)) { string sidewaysString = xmlReader.GetAttribute("IsSideways"); - isSideways = false; - if (sidewaysString != null && - String.Compare(sidewaysString, Boolean.TrueString, StringComparison.OrdinalIgnoreCase) == 0) - { - isSideways = true; - } + bool isSideways = string.Equals(sidewaysString, "True", StringComparison.OrdinalIgnoreCase); if (reverseRTL) { diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/RtfToXamlReader.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/RtfToXamlReader.cs index 1f72a18051b..9a347031b5d 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/RtfToXamlReader.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/RtfToXamlReader.cs @@ -3735,7 +3735,7 @@ internal Hashtable FontMappings // If both entries specify charset, they must match. if (lhs_tag.Length > 0 && rhs_tag.Length > 0) { - if (string.Compare(lhs_tag, rhs_tag, StringComparison.OrdinalIgnoreCase) == 0) + if (string.Equals(lhs_tag, rhs_tag, StringComparison.OrdinalIgnoreCase)) { bAdd = true; } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/Speller.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/Speller.cs index 6d2df685dd0..a0f10b22c6d 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/Speller.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/Speller.cs @@ -241,7 +241,7 @@ internal void IgnoreAll(string word) { string error = TextRangeBase.GetTextInternal(errorStart, errorEnd, ref charArray); - if (String.Compare(word, error, true /* ignoreCase */, _defaultCulture) == 0) + if (string.Compare(word, error, ignoreCase: true, _defaultCulture) == 0) { _statusTable.MarkCleanRange(errorStart, errorEnd); } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/TextRangeSerialization.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/TextRangeSerialization.cs index 297749439ec..c5ca982a0db 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/TextRangeSerialization.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/TextRangeSerialization.cs @@ -1940,8 +1940,7 @@ private static ITextPointer GetHyperlinkStart(ITextRange range) private static string FilterNaNStringValueForDoublePropertyType(string stringValue, Type propertyType) { - if (propertyType == typeof(double) && - String.Compare(stringValue, "NaN", StringComparison.OrdinalIgnoreCase) == 0) + if (propertyType == typeof(double) && string.Equals(stringValue, "NaN", StringComparison.OrdinalIgnoreCase)) { return "Auto"; // convert NaN to Auto, to keep parser happy } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/XamlToRtfWriter.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/XamlToRtfWriter.cs index 7d1bbaaa036..a489eb12287 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/XamlToRtfWriter.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/XamlToRtfWriter.cs @@ -2237,29 +2237,29 @@ private RtfImageFormat GetImageFormatFromImageSourceName(string imageName) { string imageFormatName = imageName.Substring(extensionIndex); - if (string.Compare(".png", imageFormatName, StringComparison.OrdinalIgnoreCase) == 0) + if (string.Equals(".png", imageFormatName, StringComparison.OrdinalIgnoreCase)) { imageFormat = RtfImageFormat.Png; } - if (string.Compare(".jpeg", imageFormatName, StringComparison.OrdinalIgnoreCase) == 0 || - string.Compare(".jpg", imageFormatName, StringComparison.OrdinalIgnoreCase) == 0) + if (string.Equals(".jpeg", imageFormatName, StringComparison.OrdinalIgnoreCase) || + string.Equals(".jpg", imageFormatName, StringComparison.OrdinalIgnoreCase)) { imageFormat = RtfImageFormat.Jpeg; } - if (string.Compare(".gif", imageFormatName, StringComparison.OrdinalIgnoreCase) == 0) + if (string.Equals(".gif", imageFormatName, StringComparison.OrdinalIgnoreCase)) { imageFormat = RtfImageFormat.Gif; } - if (string.Compare(".tif", imageFormatName, StringComparison.OrdinalIgnoreCase) == 0 || - string.Compare(".tiff", imageFormatName, StringComparison.OrdinalIgnoreCase) == 0) + if (string.Equals(".tif", imageFormatName, StringComparison.OrdinalIgnoreCase) || + string.Equals(".tiff", imageFormatName, StringComparison.OrdinalIgnoreCase)) { imageFormat = RtfImageFormat.Tif; } - if (string.Compare(".bmp", imageFormatName, StringComparison.OrdinalIgnoreCase) == 0) + if (string.Equals(".bmp", imageFormatName, StringComparison.OrdinalIgnoreCase)) { imageFormat = RtfImageFormat.Bmp; } - if (string.Compare(".dib", imageFormatName, StringComparison.OrdinalIgnoreCase) == 0) + if (string.Equals(".dib", imageFormatName, StringComparison.OrdinalIgnoreCase)) { imageFormat = RtfImageFormat.Dib; } @@ -2271,11 +2271,11 @@ private RtfImageFormat GetImageFormatFromImageSourceName(string imageName) // Get the image stretch type private System.Windows.Media.Stretch GetImageStretch(string imageStretch) { - if (string.Compare("Fill", imageStretch, StringComparison.OrdinalIgnoreCase) == 0) + if (string.Equals("Fill", imageStretch, StringComparison.OrdinalIgnoreCase)) { return System.Windows.Media.Stretch.Fill; } - else if (string.Compare("UniformToFill", imageStretch, StringComparison.OrdinalIgnoreCase) == 0) + else if (string.Equals("UniformToFill", imageStretch, StringComparison.OrdinalIgnoreCase)) { return System.Windows.Media.Stretch.UniformToFill; } @@ -2288,11 +2288,11 @@ private System.Windows.Media.Stretch GetImageStretch(string imageStretch) // Get the image stretch direction type private System.Windows.Controls.StretchDirection GetImageStretchDirection(string imageStretchDirection) { - if (string.Compare("UpOnly", imageStretchDirection, StringComparison.OrdinalIgnoreCase) == 0) + if (string.Equals("UpOnly", imageStretchDirection, StringComparison.OrdinalIgnoreCase)) { return System.Windows.Controls.StretchDirection.UpOnly; } - else if (string.Compare("DownOnly", imageStretchDirection, StringComparison.OrdinalIgnoreCase) == 0) + else if (string.Equals("DownOnly", imageStretchDirection, StringComparison.OrdinalIgnoreCase)) { return System.Windows.Controls.StretchDirection.DownOnly; } @@ -2720,19 +2720,19 @@ XamlToRtfError IXamlContentHandler.SkippedEntity(string name) { XamlToRtfError xamlToRtfError = XamlToRtfError.None; - if (string.Compare(name, ">", StringComparison.OrdinalIgnoreCase) == 0) + if (string.Equals(name, ">", StringComparison.OrdinalIgnoreCase)) { return ((IXamlContentHandler)this).Characters(">"); } - else if (string.Compare(name, "<", StringComparison.OrdinalIgnoreCase) == 0) + else if (string.Equals(name, "<", StringComparison.OrdinalIgnoreCase)) { return ((IXamlContentHandler)this).Characters("<"); } - else if (string.Compare(name, "&", StringComparison.OrdinalIgnoreCase) == 0) + else if (string.Equals(name, "&", StringComparison.OrdinalIgnoreCase)) { return ((IXamlContentHandler)this).Characters("&"); } - else if (name.IndexOf("&#x", StringComparison.OrdinalIgnoreCase) == 0) + else if (name.StartsWith("&#x", StringComparison.OrdinalIgnoreCase)) { xamlToRtfError = XamlToRtfError.InvalidFormat; if (name.Length >= 5) @@ -2746,7 +2746,7 @@ XamlToRtfError IXamlContentHandler.SkippedEntity(string name) } } } - else if (name.IndexOf("&#", StringComparison.OrdinalIgnoreCase) == 0) + else if (name.StartsWith("&#", StringComparison.OrdinalIgnoreCase)) { if (name.Length >= 4) { @@ -2875,11 +2875,11 @@ private XamlToRtfError HandleAttributes(ConverterState converterState, IXamlAttr break; case XamlAttribute.XAFontWeight: - if (string.Compare(valueString, "Normal", StringComparison.OrdinalIgnoreCase) == 0) + if (string.Equals(valueString, "Normal", StringComparison.OrdinalIgnoreCase)) { formatState.Bold = false; } - else if (string.Compare(valueString, "Bold", StringComparison.OrdinalIgnoreCase) == 0) + else if (string.Equals(valueString, "Bold", StringComparison.OrdinalIgnoreCase)) { formatState.Bold = true; } @@ -2895,7 +2895,7 @@ private XamlToRtfError HandleAttributes(ConverterState converterState, IXamlAttr break; case XamlAttribute.XAFontStyle: - if (string.Compare(valueString, "Italic", StringComparison.OrdinalIgnoreCase) == 0) + if (string.Equals(valueString, "Italic", StringComparison.OrdinalIgnoreCase)) { formatState.Italic = true; } @@ -3466,7 +3466,7 @@ internal static int BasicLookup(LookupTableEntry[] entries, string name) { for (int i = 0; i < entries.Length; i++) { - if (string.Compare(entries[i].Name, name, StringComparison.OrdinalIgnoreCase) == 0) + if (string.Equals(entries[i].Name, name, StringComparison.OrdinalIgnoreCase)) { return entries[i].Value; } @@ -3689,12 +3689,12 @@ internal static bool ConvertToDir(ConverterState converterState, string dirName, if (dirName.Length == 0) return false; - if (string.Compare("RightToLeft", dirName, StringComparison.OrdinalIgnoreCase) == 0) + if (string.Equals("RightToLeft", dirName, StringComparison.OrdinalIgnoreCase)) { dirState = DirState.DirRTL; return true; } - else if (string.Compare("LeftToRight", dirName, StringComparison.OrdinalIgnoreCase) == 0) + else if (string.Equals("LeftToRight", dirName, StringComparison.OrdinalIgnoreCase)) { dirState = DirState.DirLTR; return true; diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Markup/BamlMapTable.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Markup/BamlMapTable.cs index 74b2edfd420..f96d6597d40 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Markup/BamlMapTable.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Markup/BamlMapTable.cs @@ -129,7 +129,7 @@ internal static short GetKnownTypeIdFromName( { int probe = (high + low) / 2; Type probeType = KnownTypes.Types[probe]; - int cmp = String.CompareOrdinal(typeShortName, probeType.Name); + int cmp = string.CompareOrdinal(typeShortName, probeType.Name); if (cmp == 0) { // Found a potential match. Now compare the namespaces & assembly to be sure diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Markup/XamlReaderHelper.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Markup/XamlReaderHelper.cs index 4ce11585b23..02290ef67c3 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Markup/XamlReaderHelper.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Markup/XamlReaderHelper.cs @@ -2507,7 +2507,7 @@ public string TokenValue() public bool TokenEquals(string value) { int len = _current - _start; - return len == value.Length && String.CompareOrdinal(value, 0, _text, _start, len) == 0; + return len == value.Length && string.CompareOrdinal(value, 0, _text, _start, len) == 0; } public int Start { get { return _start; } } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Markup/XamlTypeMapper.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Markup/XamlTypeMapper.cs index e78824a8c2e..96179b4b13e 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Markup/XamlTypeMapper.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Markup/XamlTypeMapper.cs @@ -398,24 +398,24 @@ private bool LoadReferenceAssemblies() private void PreLoadDefaultAssemblies(string asmName, string asmPath) { - if (AssemblyWB == null && string.Compare(asmName, _assemblyNames[0], StringComparison.OrdinalIgnoreCase) == 0) + if (AssemblyWB == null && string.Equals(asmName, _assemblyNames[0], StringComparison.OrdinalIgnoreCase)) { AssemblyWB = ReflectionHelper.LoadAssembly(asmName, asmPath); } - else if (AssemblyPC == null && string.Compare(asmName, _assemblyNames[1], StringComparison.OrdinalIgnoreCase) == 0) + else if (AssemblyPC == null && string.Equals(asmName, _assemblyNames[1], StringComparison.OrdinalIgnoreCase)) { AssemblyPC = ReflectionHelper.LoadAssembly(asmName, asmPath); } - else if (AssemblyPF == null && string.Compare(asmName, _assemblyNames[2], StringComparison.OrdinalIgnoreCase) == 0) + else if (AssemblyPF == null && string.Equals(asmName, _assemblyNames[2], StringComparison.OrdinalIgnoreCase)) { AssemblyPF = ReflectionHelper.LoadAssembly(asmName, asmPath); } - else if (string.Compare(asmName, "SYSTEM.XML", StringComparison.OrdinalIgnoreCase) == 0) + else if (string.Equals(asmName, "SYSTEM.XML", StringComparison.OrdinalIgnoreCase)) { // make sure System.Xml is at least loaded as ReflectionOnly ReflectionHelper.LoadAssembly(asmName, asmPath); } - else if (string.Compare(asmName, "SYSTEM", StringComparison.OrdinalIgnoreCase) == 0) + else if (string.Equals(asmName, "SYSTEM", StringComparison.OrdinalIgnoreCase)) { // make sure System is at least loaded as ReflectionOnly ReflectionHelper.LoadAssembly(asmName, asmPath); diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Navigation/JournalEntry.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Navigation/JournalEntry.cs index 6fbae77b3ae..83f1bdd7ee5 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Navigation/JournalEntry.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Navigation/JournalEntry.cs @@ -340,13 +340,11 @@ internal static string GetDisplayName(Uri uri, Uri siteOfOrigin) return uri.ToString(); } - bool isPack = String.Compare(uri.Scheme, PackUriHelper.UriSchemePack, StringComparison.OrdinalIgnoreCase) == 0; string displayName; - - if (isPack) + if (string.Equals(uri.Scheme, PackUriHelper.UriSchemePack, StringComparison.OrdinalIgnoreCase)) { Uri relative = BaseUriHelper.MakeRelativeToSiteOfOriginIfPossible(uri); - if (! relative.IsAbsoluteUri) + if (!relative.IsAbsoluteUri) { displayName = (new Uri(siteOfOrigin, relative)).ToString(); } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Navigation/NavigationService.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Navigation/NavigationService.cs index c9b7c1fc69c..ae5879e15e1 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Navigation/NavigationService.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Navigation/NavigationService.cs @@ -227,9 +227,7 @@ static private bool IsSameUri(Uri baseUri, Uri a, Uri b, bool withFragment) if (isSame && withFragment) { - isSame = isSame && - (string.Compare(aResolved.Fragment, bResolved.Fragment, - StringComparison.OrdinalIgnoreCase) == 0); + isSame = isSame && string.Equals(aResolved.Fragment, bResolved.Fragment, StringComparison.OrdinalIgnoreCase); } return isSame; @@ -701,7 +699,7 @@ internal INavigatorBase FindTarget(string name) FrameworkElement fe = INavigatorHost as FrameworkElement; Debug.Assert(fe != null, "INavigatorHost needs to be FrameworkElement"); - if (String.Compare(name, fe.Name, StringComparison.OrdinalIgnoreCase) == 0) + if (string.Equals(name, fe.Name, StringComparison.OrdinalIgnoreCase)) { return INavigatorHost; } 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 fd0c08bf57e..5a2017e2740 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 @@ -416,8 +416,7 @@ internal static int GetNonXmlnsAttributeCount(XmlReader reader) //MoveToNextAttribute is the same as MoveToFirstAttribute. while (reader.MoveToNextAttribute()) { - if (String.CompareOrdinal(reader.Name, XmlNamespace) != 0 && - String.CompareOrdinal(reader.Prefix, XmlNamespace) != 0) + if (!string.Equals(reader.Name, XmlNamespace, StringComparison.Ordinal) && !string.Equals(reader.Prefix, XmlNamespace, StringComparison.Ordinal)) readerCount++; } diff --git a/src/Microsoft.DotNet.Wpf/src/Shared/MS/Internal/SafeSecurityHelper.cs b/src/Microsoft.DotNet.Wpf/src/Shared/MS/Internal/SafeSecurityHelper.cs index 7aefb101cde..2f05a597dfd 100644 --- a/src/Microsoft.DotNet.Wpf/src/Shared/MS/Internal/SafeSecurityHelper.cs +++ b/src/Microsoft.DotNet.Wpf/src/Shared/MS/Internal/SafeSecurityHelper.cs @@ -147,10 +147,10 @@ internal static Assembly GetLoadedAssembly(AssemblyName assemblyName) CultureInfo curCulture = curAsmName.CultureInfo; byte[] curKeyToken = curAsmName.GetPublicKeyToken(); - if ( (String.Compare(curAsmName.Name, assemblyName.Name, true, TypeConverterHelper.InvariantEnglishUS) == 0) && + if (string.Equals(curAsmName.Name, assemblyName.Name, StringComparison.InvariantCultureIgnoreCase) && (reqVersion == null || reqVersion.Equals(curVersion)) && (reqCulture == null || reqCulture.Equals(curCulture)) && - (reqKeyToken == null || IsSameKeyToken(reqKeyToken, curKeyToken) ) ) + (reqKeyToken == null || IsSameKeyToken(reqKeyToken, curKeyToken))) { return assemblies[i]; } diff --git a/src/Microsoft.DotNet.Wpf/src/System.Windows.Controls.Ribbon/Microsoft/Windows/Controls/TextSearchInternal.cs b/src/Microsoft.DotNet.Wpf/src/System.Windows.Controls.Ribbon/Microsoft/Windows/Controls/TextSearchInternal.cs index 5cc009ff559..f187d3b9f91 100644 --- a/src/Microsoft.DotNet.Wpf/src/System.Windows.Controls.Ribbon/Microsoft/Windows/Controls/TextSearchInternal.cs +++ b/src/Microsoft.DotNet.Wpf/src/System.Windows.Controls.Ribbon/Microsoft/Windows/Controls/TextSearchInternal.cs @@ -119,8 +119,7 @@ internal bool DoHierarchicalSearch(string nextChar) // Fallback search is if they type "bob" and then press "b" // we'll look for "bobb" and when we don't find it we should // find the next item starting with "bob". - if (_charsEntered.Count > 0 - && (String.Compare(_charsEntered[_charsEntered.Count - 1], nextChar, true, GetCulture(_attachedTo)) == 0)) + if (_charsEntered.Count > 0 && string.Compare(_charsEntered[_charsEntered.Count - 1], nextChar, true, GetCulture(_attachedTo)) == 0) { repeatedChar = true; } @@ -261,8 +260,7 @@ internal bool DoSearch(string nextChar) // Fallback search is if they type "bob" and then press "b" // we'll look for "bobb" and when we don't find it we should // find the next item starting with "bob". - if (_charsEntered.Count > 0 - && (String.Compare(_charsEntered[_charsEntered.Count - 1], nextChar, true, GetCulture(_attachedTo))==0)) + if (_charsEntered.Count > 0 && string.Compare(_charsEntered[_charsEntered.Count - 1], nextChar, true, GetCulture(_attachedTo)) == 0) { repeatedChar = true; } diff --git a/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/XamlObjectReader.cs b/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/XamlObjectReader.cs index e0090fd48e7..3e2548d63d9 100644 --- a/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/XamlObjectReader.cs +++ b/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/XamlObjectReader.cs @@ -2246,7 +2246,7 @@ public int Compare(MarkupInfo x, MarkupInfo y) if (xIsDirective && !yIsDirective) { return XFirst; } if (yIsDirective && !xIsDirective) { return YFirst; } - return String.CompareOrdinal(xProperty.Name, yProperty.Name); + return string.CompareOrdinal(xProperty.Name, yProperty.Name); } } @@ -2306,7 +2306,7 @@ public int Compare(MarkupInfo x, MarkupInfo y) if (xIsDirective && !yIsDirective) { return XFirst; } if (yIsDirective && !yIsDirective) { return YFirst; } - return String.CompareOrdinal(xProperty.Name, yProperty.Name); + return string.CompareOrdinal(xProperty.Name, yProperty.Name); } } diff --git a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClient/MS/Internal/Automation/ProxyManager.cs b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClient/MS/Internal/Automation/ProxyManager.cs index 342383fca1b..8ab70515bf2 100644 --- a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClient/MS/Internal/Automation/ProxyManager.cs +++ b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClient/MS/Internal/Automation/ProxyManager.cs @@ -270,7 +270,7 @@ internal static bool IsKnownBadWindow( NativeMethods.HWND hwnd ) foreach (string str in BadImplClassnames) { - if (String.Compare(className, str, StringComparison.OrdinalIgnoreCase) == 0) + if (string.Equals(className, str, StringComparison.OrdinalIgnoreCase)) return true; } diff --git a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClient/MS/Internal/Automation/WindowShowOrOpenTracker.cs b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClient/MS/Internal/Automation/WindowShowOrOpenTracker.cs index f49471d89c1..52de32bf813 100644 --- a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClient/MS/Internal/Automation/WindowShowOrOpenTracker.cs +++ b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClient/MS/Internal/Automation/WindowShowOrOpenTracker.cs @@ -74,7 +74,7 @@ internal override void WinEventProc(int eventId, IntPtr hwnd, int idObject, int // Ignore WCP hwnd creates; we get eventId EventObjectUIFragmentCreate for those // Are these all the WCP classnames? Is there a better way to ignore WCP windows? string str = ProxyManager.GetClassName(nativeHwnd); - if (String.Compare(str, 0, _wcpClassName, 0, _wcpClassName.Length, StringComparison.OrdinalIgnoreCase) == 0) + if (string.Compare(str, 0, _wcpClassName, 0, _wcpClassName.Length, StringComparison.OrdinalIgnoreCase) == 0) return; } diff --git a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/MSAANativeProvider.cs b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/MSAANativeProvider.cs index fc8d5995506..d8be60d0a2c 100644 --- a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/MSAANativeProvider.cs +++ b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/MSAANativeProvider.cs @@ -130,11 +130,11 @@ internal MsaaNativeProvider Wrap(Accessible acc) // needed based on a window handle, object and child ids. // It returns an IRawElementProviderSimple implementation for a native IAccessible object // or null if the hwnd doesn't natively implement IAccessible. - internal static IRawElementProviderSimple Create (IntPtr hwnd, int idChild, int idObject) + internal static IRawElementProviderSimple Create(IntPtr hwnd, int idChild, int idObject) { #if DEBUG // // uncomment this if you want to prevent unwanted interactions with the debugger in Whidbey. -// if (string.Compare(hwnd.ProcessName, "devenv.exe", StringComparison.OrdinalIgnoreCase) == 0) +// if (string.Equals(hwnd.ProcessName, "devenv.exe", StringComparison.OrdinalIgnoreCase)) // { // return null; // } @@ -367,7 +367,7 @@ int [] IRawElementProviderFragment.GetRuntimeId() // two different AutomationElements representing the same underlying // UI in MCE may incorrectly compare as FALSE. string className = Misc.GetClassName(_hwnd); - if(String.Compare(className, "eHome Render Window", StringComparison.OrdinalIgnoreCase) == 0) + if (string.Equals(className, "eHome Render Window", StringComparison.OrdinalIgnoreCase)) _isMCE = TristateBool.TestedTrue; else _isMCE = TristateBool.TestedFalse; @@ -1066,7 +1066,7 @@ private static bool IsKnownBadWindow(IntPtr hwnd) foreach (string str in BadImplClassnames) { - if (String.Compare(className, str, StringComparison.OrdinalIgnoreCase) == 0) + if (string.Equals(className, str, StringComparison.OrdinalIgnoreCase)) return true; } diff --git a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsComboBox.cs b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsComboBox.cs index 38e0e3dd014..66c72b94142 100644 --- a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsComboBox.cs +++ b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsComboBox.cs @@ -678,7 +678,7 @@ static private bool IsComboEx (IntPtr hwndEx) return false; } - return (0 == String.Compare(Misc.GetClassName(hwndEx), ComboboxEx32, StringComparison.OrdinalIgnoreCase)); + return string.Equals(Misc.GetClassName(hwndEx), ComboboxEx32, StringComparison.OrdinalIgnoreCase); } private bool IsEditableCombo() diff --git a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsListView.cs b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsListView.cs index b22f30132a0..78f01328531 100644 --- a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsListView.cs +++ b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsListView.cs @@ -1647,7 +1647,7 @@ private ProxyFragment CreateListViewItemOrStartMenuItem(ProxyFragment parent, in private bool InStartMenu() { string className = Misc.GetClassName(Misc.GetParent(_hwnd)); - return string.Compare(className, "DesktopSFTBarHost", StringComparison.OrdinalIgnoreCase) == 0; + return string.Equals(className, "DesktopSFTBarHost", StringComparison.OrdinalIgnoreCase); } private bool SetScrollPercent(double fScrollPos, int sbFlag, int cPelsAll, out int delta) diff --git a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsMenu.cs b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsMenu.cs index 49f62f6cf30..4f16c7d5a81 100644 --- a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsMenu.cs +++ b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsMenu.cs @@ -912,12 +912,11 @@ private static bool IsSystemPopupMenu (IntPtr hmenu) } // detect if hwnd corresponds to the submenu - private static bool IsWindowSubMenu (IntPtr hwnd) + private static bool IsWindowSubMenu(IntPtr hwnd) { - return (String.Compare(Misc.ProxyGetClassName(hwnd), WindowsMenu.MenuClassName, StringComparison.OrdinalIgnoreCase) == 0); + return string.Equals(Misc.ProxyGetClassName(hwnd), WindowsMenu.MenuClassName, StringComparison.OrdinalIgnoreCase); } - private static int GetHighlightedMenuItem(IntPtr hmenu) { int count = Misc.GetMenuItemCount(hmenu); diff --git a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsRichEditRange.cs b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsRichEditRange.cs index f3129348f89..ee691e4ec54 100644 --- a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsRichEditRange.cs +++ b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsRichEditRange.cs @@ -729,7 +729,7 @@ private static object GetFontName(ITextRange range) else { // on subsequent iterations compare if the font name is the same. - if (string.Compare(name, unitRange.Font.Name, StringComparison.Ordinal) != 0) + if (!string.Equals(name, unitRange.Font.Name, StringComparison.Ordinal)) { return TextPattern.MixedAttributeValue; } diff --git a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsScroll.cs b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsScroll.cs index aa8959bebf8..fa5c3979dda 100644 --- a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsScroll.cs +++ b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsScroll.cs @@ -165,7 +165,7 @@ static internal bool HasScrollableStyle(IntPtr hwnd) string className = Misc.ProxyGetClassName(hwnd); if (className.StartsWith("RichEdit", StringComparison.OrdinalIgnoreCase) || className.StartsWith("WindowForms10.RichEdit", StringComparison.OrdinalIgnoreCase) || - string.Compare(className, "Edit", StringComparison.OrdinalIgnoreCase) == 0) + string.Equals(className, "Edit", StringComparison.OrdinalIgnoreCase)) { hasScrollableStyle = Misc.IsBitSet(style, NativeMethods.ES_MULTILINE); } diff --git a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsTooltip.cs b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsTooltip.cs index c5475b044cd..e3b1742c272 100644 --- a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsTooltip.cs +++ b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/WindowsTooltip.cs @@ -180,20 +180,20 @@ private static bool IsToolTip( IntPtr hwnd ) string className = Misc.ProxyGetClassName(hwnd); - return String.Compare(className, "tooltips_class32", StringComparison.OrdinalIgnoreCase) == 0 || - String.Compare(className, CLASS_TITLEBAR_TOOLTIP, StringComparison.OrdinalIgnoreCase) == 0 || - String.Compare(className, "VBBubble", StringComparison.OrdinalIgnoreCase) == 0; + return string.Equals(className, "tooltips_class32", StringComparison.OrdinalIgnoreCase) || + string.Equals(className, CLASS_TITLEBAR_TOOLTIP, StringComparison.OrdinalIgnoreCase) || + string.Equals(className, "VBBubble", StringComparison.OrdinalIgnoreCase); } private string GetText() { string className = Misc.ProxyGetClassName(_hwnd); - if (String.Compare(className, CLASS_TITLEBAR_TOOLTIP, StringComparison.OrdinalIgnoreCase) == 0) + if (string.Equals(className, CLASS_TITLEBAR_TOOLTIP, StringComparison.OrdinalIgnoreCase)) { return GetTitleBarToolTipText(); } - else if (String.Compare(className, "VBBubble", StringComparison.OrdinalIgnoreCase) == 0) + else if (string.Equals(className, "VBBubble", StringComparison.OrdinalIgnoreCase)) { // The WM_GETTEXT should work for VBBubble. It seems that the string being returned is having // a problem with Unicode covertion and therefore trunk'ing the string after the first character.