diff --git a/src/Microsoft.DotNet.Wpf/src/.editorconfig b/src/Microsoft.DotNet.Wpf/src/.editorconfig index 8c0a38efa4c..1b9eb1cbe3d 100644 --- a/src/Microsoft.DotNet.Wpf/src/.editorconfig +++ b/src/Microsoft.DotNet.Wpf/src/.editorconfig @@ -227,9 +227,6 @@ dotnet_diagnostic.IDE0077.severity = suggestion # IDE0078: Use pattern matching dotnet_diagnostic.IDE0078.severity = suggestion -# IDE0082: 'typeof' can be converted to 'nameof' -dotnet_diagnostic.IDE0082.severity = suggestion - # IDE0100: Remove redundant equality dotnet_diagnostic.IDE0100.severity = suggestion diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media3D/ModelVisual3D.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media3D/ModelVisual3D.cs index 5e9e2814c28..c6fa3af2bd0 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media3D/ModelVisual3D.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media3D/ModelVisual3D.cs @@ -77,7 +77,7 @@ void IAddChild.AddChild(Object value) if (visual3D == null) { - throw new System.ArgumentException(SR.Format(SR.Collection_BadType, this.GetType().Name, value.GetType().Name, typeof(Visual3D).Name)); + throw new System.ArgumentException(SR.Format(SR.Collection_BadType, this.GetType().Name, value.GetType().Name, nameof(Visual3D))); } Children.Add(visual3D); diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media3D/Viewport3DVisual.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media3D/Viewport3DVisual.cs index 0b04ab16344..7f5008627ef 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media3D/Viewport3DVisual.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media3D/Viewport3DVisual.cs @@ -493,7 +493,7 @@ internal override HitTestResultBehavior HitTestPointInternal( /// protected override GeometryHitTestResult HitTestCore(GeometryHitTestParameters hitTestParameters) { - throw new NotSupportedException(SR.Format(SR.HitTest_Invalid, typeof(GeometryHitTestParameters).Name, this.GetType().Name)); + throw new NotSupportedException(SR.Format(SR.HitTest_Invalid, nameof(GeometryHitTestParameters), this.GetType().Name)); } internal Point WorldToViewport(Point4D point) diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/MenuItem.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/MenuItem.cs index 2be4fc0100e..6ee069af262 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/MenuItem.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/MenuItem.cs @@ -2099,7 +2099,7 @@ protected override DependencyObject GetContainerForItemOverride() } else { - throw new InvalidOperationException(SR.Format(SR.InvalidItemContainer, this.GetType().Name, typeof(MenuItem).Name, typeof(Separator).Name, itemContainer)); + throw new InvalidOperationException(SR.Format(SR.InvalidItemContainer, this.GetType().Name, nameof(MenuItem), nameof(Separator), itemContainer)); } } } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/Primitives/MenuBase.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/Primitives/MenuBase.cs index 9f85482c19c..d393645a765 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/Primitives/MenuBase.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/Primitives/MenuBase.cs @@ -502,7 +502,7 @@ protected override DependencyObject GetContainerForItemOverride() } else { - throw new InvalidOperationException(SR.Format(SR.InvalidItemContainer, this.GetType().Name, typeof(MenuItem).Name, typeof(Separator).Name, itemContainer)); + throw new InvalidOperationException(SR.Format(SR.InvalidItemContainer, this.GetType().Name, nameof(MenuItem), nameof(Separator), itemContainer)); } } } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/Primitives/StatusBar.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/Primitives/StatusBar.cs index 52d92abc756..738281e6f73 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/Primitives/StatusBar.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/Primitives/StatusBar.cs @@ -121,7 +121,7 @@ protected override DependencyObject GetContainerForItemOverride() } else { - throw new InvalidOperationException(SR.Format(SR.InvalidItemContainer, this.GetType().Name, typeof(StatusBarItem).Name, typeof(Separator).Name, itemContainer)); + throw new InvalidOperationException(SR.Format(SR.InvalidItemContainer, this.GetType().Name, nameof(StatusBarItem), nameof(Separator), itemContainer)); } } } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/DeferrableContentConverter.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/DeferrableContentConverter.cs index db939b3225a..fc707eb7f4f 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/DeferrableContentConverter.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/DeferrableContentConverter.cs @@ -78,7 +78,7 @@ private static T RequireService(IServiceProvider provider) where T : class T result = provider.GetService(typeof(T)) as T; if (result == null) { - throw new InvalidOperationException(SR.Format(SR.DeferringLoaderNoContext, typeof(DeferrableContentConverter).Name, typeof(T).Name)); + throw new InvalidOperationException(SR.Format(SR.DeferringLoaderNoContext, nameof(DeferrableContentConverter), typeof(T).Name)); } return result; } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/TableColumnCollection.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/TableColumnCollection.cs index 4fbad5e3992..eb768b8499c 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/TableColumnCollection.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/TableColumnCollection.cs @@ -276,7 +276,7 @@ int IList.Add(object value) if (item == null) { - throw new ArgumentException(SR.Format(SR.TableCollectionElementTypeExpected, typeof(TableColumn).Name), nameof(value)); + throw new ArgumentException(SR.Format(SR.TableCollectionElementTypeExpected, nameof(TableColumn)), nameof(value)); } return ((IList)_columnCollection).Add(value); 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 33cec3afdd2..25a346d9338 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 @@ -192,7 +192,7 @@ private static void WriteXamlTextSegment(XmlWriter xmlWriter, ITextPointer range if (elementLevel == EmptyDocumentDepth && typeof(Run).IsAssignableFrom(rangeStart.ParentType)) { elementLevel++; - xmlWriter.WriteStartElement(typeof(Run).Name); + xmlWriter.WriteStartElement(nameof(Run)); } // Create text navigator for reading the range's content @@ -1185,8 +1185,8 @@ private static void WriteEmbeddedObject(object embeddedObject, XmlWriter xmlWrit // Write Source property as the complex property to specify the BitmapImage // cache option as "OnLoad" instead of the default "OnDeman". Otherwise, // we couldn't load the image by disposing WpfPayload package. - xmlWriter.WriteStartElement($"{typeof(Image).Name}.{Image.SourceProperty.Name}"); - xmlWriter.WriteStartElement(typeof(System.Windows.Media.Imaging.BitmapImage).Name); + xmlWriter.WriteStartElement($"{nameof(Image)}.{Image.SourceProperty.Name}"); + xmlWriter.WriteStartElement(nameof(Media.Imaging.BitmapImage)); xmlWriter.WriteAttributeString(System.Windows.Media.Imaging.BitmapImage.UriSourceProperty.Name, imageSource); xmlWriter.WriteAttributeString(System.Windows.Media.Imaging.BitmapImage.CacheOptionProperty.Name, "OnLoad"); xmlWriter.WriteEndElement(); diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/FrameworkTemplate.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/FrameworkTemplate.cs index d7f0ff7c4e4..4c68f566050 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/FrameworkTemplate.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/FrameworkTemplate.cs @@ -375,8 +375,7 @@ private void ValidateVisualTree(FrameworkElementFactory templateRoot) if (templateRoot != null && typeof(FrameworkContentElement).IsAssignableFrom(templateRoot.Type)) { - throw new ArgumentException(SR.Format(SR.VisualTreeRootIsFrameworkElement, - typeof(FrameworkElement).Name, templateRoot.Type.Name)); + throw new ArgumentException(SR.Format(SR.VisualTreeRootIsFrameworkElement, nameof(FrameworkElement), templateRoot.Type.Name)); } } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/TemplateContentLoader.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/TemplateContentLoader.cs index 84ef9362679..c5c239afbc9 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/TemplateContentLoader.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/TemplateContentLoader.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. @@ -22,14 +22,14 @@ private static T RequireService(IServiceProvider provider) where T : class T result = provider.GetService(typeof(T)) as T; if (result == null) { - throw new InvalidOperationException(SR.Format(SR.DeferringLoaderNoContext,typeof(TemplateContentLoader).Name, typeof(T).Name)); + throw new InvalidOperationException(SR.Format(SR.DeferringLoaderNoContext, nameof(TemplateContentLoader), typeof(T).Name)); } return result; } public override XamlReader Save(object value, IServiceProvider serviceProvider) { - throw new NotSupportedException(SR.Format(SR.DeferringLoaderNoSave, typeof(TemplateContentLoader).Name)); + throw new NotSupportedException(SR.Format(SR.DeferringLoaderNoSave, nameof(TemplateContentLoader))); } } }