Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[StyleCleanUp] Convert typeof(Foo).Name to nameof(Foo) (IDE0082) #10266

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/Microsoft.DotNet.Wpf/src/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ internal override HitTestResultBehavior HitTestPointInternal(
/// </summary>
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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2106,7 +2106,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));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private static T RequireService<T>(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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ int IList.Add(object value)

if (item == null)
{
throw new ArgumentException(SR.Format(SR.TableCollectionElementTypeExpected, typeof(TableColumn).Name), "value");
throw new ArgumentException(SR.Format(SR.TableCollectionElementTypeExpected, nameof(TableColumn)), "value");
}

return ((IList)_columnCollection).Add(value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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.

Expand All @@ -22,14 +22,14 @@ private static T RequireService<T>(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)));
}
}
}