From 5ea6ba40cdbf5ffee11fb241d18ec666924a4a9b Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Tue, 30 Jul 2019 15:15:00 -0700 Subject: [PATCH] Update Roslyn dependencies to align with SDK and VS. - Updated instances of our code to no longer use reference type checks on `ISymbol`s. This was a new restriction added by Roslyn [here](https://github.com/dotnet/roslyn-analyzers/issues/2084). We also have a follow up AspNetCore issue [here](https://github.com/aspnet/AspNetCore/issues/12747) to bring these level of changes to AspNetCore. - Had to pin `Microsoft.CodeAnalysis.Analyzers` in our VSIX projects in order to workaround version conflicts of `Microsoft.CodeAnalysis.Analyzers`. The version conflict is introduced from our dependency on `Microsoft.VisualStudio.ProjectSystem.Managed.VS`. It transitively depends on `Microsoft.CodeAnalysis.Analyzers` `2.6.3` where as our latest Roslyn bits transitively depend on `Microsoft.CodeAnlalysis.Analyzers` `2.9.4`. Tried updating to the latest, private, `Microsoft.VisualStudio.ProjectSystem.Managed.VS` but it also had the version conflict. - Pinned our runtime bits to the latest public Roslyn NuGet package and pinned our tooling bits to the latest private NuGet package (both are compatible flavors of 3.3.0). \n\nCommit migrated from https://github.com/dotnet/aspnetcore-tooling/commit/83d5e2c36f5c0b4d697da238ef4cfd6bdaee6c59 --- ...ViewComponentTagHelperDescriptorFactory.cs | 16 +++++++------- .../src/ViewComponentTypeVisitor.cs | 2 +- ...ViewComponentTagHelperDescriptorFactory.cs | 16 +++++++------- .../src/ViewComponentTypeVisitor.cs | 2 +- ...ViewComponentTagHelperDescriptorFactory.cs | 16 +++++++------- .../src/ViewComponentTypeVisitor.cs | 2 +- .../src/BindTagHelperDescriptorProvider.cs | 6 ++--- .../ComponentTagHelperDescriptorProvider.cs | 12 +++++----- .../src/DefaultTagHelperDescriptorFactory.cs | 22 +++++++++---------- ...EventHandlerTagHelperDescriptorProvider.cs | 2 +- 10 files changed, 48 insertions(+), 48 deletions(-) diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/ViewComponentTagHelperDescriptorFactory.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/ViewComponentTagHelperDescriptorFactory.cs index 68966e734c..06b5bed18f 100644 --- a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/ViewComponentTagHelperDescriptorFactory.cs +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/ViewComponentTagHelperDescriptorFactory.cs @@ -110,11 +110,11 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X if (string.Equals(selectedMethod.Name, ViewComponentTypes.AsyncMethodName, StringComparison.Ordinal)) { // Will invoke asynchronously. Method must not return Task or Task. - if (returnType == _taskSymbol) + if (Equals(returnType, _taskSymbol)) { // This is ok. } - else if (returnType.IsGenericType && returnType.ConstructedFrom == _genericTaskSymbol) + else if (returnType.IsGenericType && Equals(returnType.ConstructedFrom, _genericTaskSymbol)) { // This is ok. } @@ -134,13 +134,13 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X method = null; return false; } - else if (returnType == _taskSymbol) + else if (Equals(returnType, _taskSymbol)) { diagnostic = RazorExtensionsDiagnosticFactory.CreateViewComponent_SyncMethod_CannotReturnTask(type.ToDisplayString(FullNameTypeDisplayFormat)); method = null; return false; } - else if (returnType.IsGenericType && returnType.ConstructedFrom == _genericTaskSymbol) + else if (returnType.IsGenericType && Equals(returnType.ConstructedFrom, _genericTaskSymbol)) { diagnostic = RazorExtensionsDiagnosticFactory.CreateViewComponent_SyncMethod_CannotReturnTask(type.ToDisplayString(FullNameTypeDisplayFormat)); method = null; @@ -208,13 +208,13 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X private string GetIndexerValueTypeName(IParameterSymbol parameter) { INamedTypeSymbol dictionaryType; - if ((parameter.Type as INamedTypeSymbol)?.ConstructedFrom == _iDictionarySymbol) + if (Equals((parameter.Type as INamedTypeSymbol)?.ConstructedFrom, _iDictionarySymbol)) { dictionaryType = (INamedTypeSymbol)parameter.Type; } - else if (parameter.Type.AllInterfaces.Any(s => s.ConstructedFrom == _iDictionarySymbol)) + else if (parameter.Type.AllInterfaces.Any(s => Equals(s.ConstructedFrom, _iDictionarySymbol))) { - dictionaryType = parameter.Type.AllInterfaces.First(s => s.ConstructedFrom == _iDictionarySymbol); + dictionaryType = parameter.Type.AllInterfaces.First(s => Equals(s.ConstructedFrom, _iDictionarySymbol)); } else { @@ -234,7 +234,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X private string GetShortName(INamedTypeSymbol componentType) { - var viewComponentAttribute = componentType.GetAttributes().Where(a => a.AttributeClass == _viewComponentAttributeSymbol).FirstOrDefault(); + var viewComponentAttribute = componentType.GetAttributes().Where(a => Equals(a.AttributeClass, _viewComponentAttributeSymbol)).FirstOrDefault(); var name = viewComponentAttribute ?.NamedArguments .Where(namedArgument => string.Equals(namedArgument.Key, ViewComponentTypes.ViewComponent.Name, StringComparison.Ordinal)) diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/ViewComponentTypeVisitor.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/ViewComponentTypeVisitor.cs index db0912087a..916bc60653 100644 --- a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/ViewComponentTypeVisitor.cs +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X/src/ViewComponentTypeVisitor.cs @@ -73,7 +73,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X return false; } - var attribute = type.GetAttributes().Where(a => a.AttributeClass == queryAttribute).FirstOrDefault(); + var attribute = type.GetAttributes().Where(a => Equals(a.AttributeClass, queryAttribute)).FirstOrDefault(); if (attribute != null) { diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/ViewComponentTagHelperDescriptorFactory.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/ViewComponentTagHelperDescriptorFactory.cs index 0b1221af72..75b4cd62be 100644 --- a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/ViewComponentTagHelperDescriptorFactory.cs +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/ViewComponentTagHelperDescriptorFactory.cs @@ -104,11 +104,11 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X if (string.Equals(selectedMethod.Name, ViewComponentTypes.AsyncMethodName, StringComparison.Ordinal)) { // Will invoke asynchronously. Method must not return Task or Task. - if (returnType == _taskSymbol) + if (Equals(returnType, _taskSymbol)) { // This is ok. } - else if (returnType.IsGenericType && returnType.ConstructedFrom == _genericTaskSymbol) + else if (returnType.IsGenericType && Equals(returnType.ConstructedFrom, _genericTaskSymbol)) { // This is ok. } @@ -128,13 +128,13 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X method = null; return false; } - else if (returnType == _taskSymbol) + else if (Equals(returnType, _taskSymbol)) { diagnostic = RazorExtensionsDiagnosticFactory.CreateViewComponent_SyncMethod_CannotReturnTask(type.ToDisplayString(FullNameTypeDisplayFormat)); method = null; return false; } - else if (returnType.IsGenericType && returnType.ConstructedFrom == _genericTaskSymbol) + else if (returnType.IsGenericType && Equals(returnType.ConstructedFrom, _genericTaskSymbol)) { diagnostic = RazorExtensionsDiagnosticFactory.CreateViewComponent_SyncMethod_CannotReturnTask(type.ToDisplayString(FullNameTypeDisplayFormat)); method = null; @@ -223,13 +223,13 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X private string GetIndexerValueTypeName(IParameterSymbol parameter) { INamedTypeSymbol dictionaryType; - if ((parameter.Type as INamedTypeSymbol)?.ConstructedFrom == _iDictionarySymbol) + if (Equals((parameter.Type as INamedTypeSymbol)?.ConstructedFrom, _iDictionarySymbol)) { dictionaryType = (INamedTypeSymbol)parameter.Type; } - else if (parameter.Type.AllInterfaces.Any(s => s.ConstructedFrom == _iDictionarySymbol)) + else if (parameter.Type.AllInterfaces.Any(s => Equals(s.ConstructedFrom, _iDictionarySymbol))) { - dictionaryType = parameter.Type.AllInterfaces.First(s => s.ConstructedFrom == _iDictionarySymbol); + dictionaryType = parameter.Type.AllInterfaces.First(s => Equals(s.ConstructedFrom, _iDictionarySymbol)); } else { @@ -249,7 +249,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X private string GetShortName(INamedTypeSymbol componentType) { - var viewComponentAttribute = componentType.GetAttributes().Where(a => a.AttributeClass == _viewComponentAttributeSymbol).FirstOrDefault(); + var viewComponentAttribute = componentType.GetAttributes().Where(a => Equals(a.AttributeClass, _viewComponentAttributeSymbol)).FirstOrDefault(); var name = viewComponentAttribute ?.NamedArguments .Where(namedArgument => string.Equals(namedArgument.Key, ViewComponentTypes.ViewComponent.Name, StringComparison.Ordinal)) diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/ViewComponentTypeVisitor.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/ViewComponentTypeVisitor.cs index 01eb3fffaa..0281880866 100644 --- a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/ViewComponentTypeVisitor.cs +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X/src/ViewComponentTypeVisitor.cs @@ -75,7 +75,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X return false; } - var attribute = type.GetAttributes().Where(a => a.AttributeClass == queryAttribute).FirstOrDefault(); + var attribute = type.GetAttributes().Where(a => Equals(a.AttributeClass, queryAttribute)).FirstOrDefault(); if (attribute != null) { diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/ViewComponentTagHelperDescriptorFactory.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/ViewComponentTagHelperDescriptorFactory.cs index a5181fd789..aaa765fb63 100644 --- a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/ViewComponentTagHelperDescriptorFactory.cs +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/ViewComponentTagHelperDescriptorFactory.cs @@ -104,11 +104,11 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions if (string.Equals(selectedMethod.Name, ViewComponentTypes.AsyncMethodName, StringComparison.Ordinal)) { // Will invoke asynchronously. Method must not return Task or Task. - if (returnType == _taskSymbol) + if (Equals(returnType, _taskSymbol)) { // This is ok. } - else if (returnType.IsGenericType && returnType.ConstructedFrom == _genericTaskSymbol) + else if (returnType.IsGenericType && Equals(returnType.ConstructedFrom, _genericTaskSymbol)) { // This is ok. } @@ -128,13 +128,13 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions method = null; return false; } - else if (returnType == _taskSymbol) + else if (Equals(returnType, _taskSymbol)) { diagnostic = RazorExtensionsDiagnosticFactory.CreateViewComponent_SyncMethod_CannotReturnTask(type.ToDisplayString(FullNameTypeDisplayFormat)); method = null; return false; } - else if (returnType.IsGenericType && returnType.ConstructedFrom == _genericTaskSymbol) + else if (returnType.IsGenericType && Equals(returnType.ConstructedFrom, _genericTaskSymbol)) { diagnostic = RazorExtensionsDiagnosticFactory.CreateViewComponent_SyncMethod_CannotReturnTask(type.ToDisplayString(FullNameTypeDisplayFormat)); method = null; @@ -223,13 +223,13 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions private string GetIndexerValueTypeName(IParameterSymbol parameter) { INamedTypeSymbol dictionaryType; - if ((parameter.Type as INamedTypeSymbol)?.ConstructedFrom == _iDictionarySymbol) + if (Equals((parameter.Type as INamedTypeSymbol)?.ConstructedFrom, _iDictionarySymbol)) { dictionaryType = (INamedTypeSymbol)parameter.Type; } - else if (parameter.Type.AllInterfaces.Any(s => s.ConstructedFrom == _iDictionarySymbol)) + else if (parameter.Type.AllInterfaces.Any(s => Equals(s.ConstructedFrom, _iDictionarySymbol))) { - dictionaryType = parameter.Type.AllInterfaces.First(s => s.ConstructedFrom == _iDictionarySymbol); + dictionaryType = parameter.Type.AllInterfaces.First(s => Equals(s.ConstructedFrom, _iDictionarySymbol)); } else { @@ -249,7 +249,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions private string GetShortName(INamedTypeSymbol componentType) { - var viewComponentAttribute = componentType.GetAttributes().Where(a => a.AttributeClass == _viewComponentAttributeSymbol).FirstOrDefault(); + var viewComponentAttribute = componentType.GetAttributes().Where(a => Equals(a.AttributeClass, _viewComponentAttributeSymbol)).FirstOrDefault(); var name = viewComponentAttribute ?.NamedArguments .Where(namedArgument => string.Equals(namedArgument.Key, ViewComponentTypes.ViewComponent.Name, StringComparison.Ordinal)) diff --git a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/ViewComponentTypeVisitor.cs b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/ViewComponentTypeVisitor.cs index 9e1f936060..498b28fdc2 100644 --- a/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/ViewComponentTypeVisitor.cs +++ b/src/Razor/Microsoft.AspNetCore.Mvc.Razor.Extensions/src/ViewComponentTypeVisitor.cs @@ -75,7 +75,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor.Extensions return false; } - var attribute = type.GetAttributes().Where(a => a.AttributeClass == queryAttribute).FirstOrDefault(); + var attribute = type.GetAttributes().Where(a => Equals(a.AttributeClass, queryAttribute)).FirstOrDefault(); if (attribute != null) { diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/src/BindTagHelperDescriptorProvider.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/src/BindTagHelperDescriptorProvider.cs index d8b0ff8086..e21332c150 100644 --- a/src/Razor/Microsoft.CodeAnalysis.Razor/src/BindTagHelperDescriptorProvider.cs +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/src/BindTagHelperDescriptorProvider.cs @@ -235,7 +235,7 @@ namespace Microsoft.CodeAnalysis.Razor // We need to check the constructor argument length here, because this can show up as 0 // if the language service fails to initialize. This is an invalid case, so skip it. - if (attribute.AttributeClass == bindElement && attribute.ConstructorArguments.Length == 4) + if (Equals(attribute.AttributeClass, bindElement) && attribute.ConstructorArguments.Length == 4) { results.Add(new ElementBindData( type.ContainingAssembly.Name, @@ -246,7 +246,7 @@ namespace Microsoft.CodeAnalysis.Razor (string)attribute.ConstructorArguments[2].Value, (string)attribute.ConstructorArguments[3].Value)); } - else if (attribute.AttributeClass == bindInputElement && attribute.ConstructorArguments.Length == 4) + else if (Equals(attribute.AttributeClass, bindInputElement) && attribute.ConstructorArguments.Length == 4) { results.Add(new ElementBindData( type.ContainingAssembly.Name, @@ -257,7 +257,7 @@ namespace Microsoft.CodeAnalysis.Razor (string)attribute.ConstructorArguments[2].Value, (string)attribute.ConstructorArguments[3].Value)); } - else if (attribute.AttributeClass == bindInputElement && attribute.ConstructorArguments.Length == 6) + else if (Equals(attribute.AttributeClass, bindInputElement) && attribute.ConstructorArguments.Length == 6) { results.Add(new ElementBindData( type.ContainingAssembly.Name, diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/src/ComponentTagHelperDescriptorProvider.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/src/ComponentTagHelperDescriptorProvider.cs index 29aa54ced0..f160b53a90 100644 --- a/src/Razor/Microsoft.CodeAnalysis.Razor/src/ComponentTagHelperDescriptorProvider.cs +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/src/ComponentTagHelperDescriptorProvider.cs @@ -327,7 +327,7 @@ namespace Microsoft.CodeAnalysis.Razor var properties = new Dictionary(StringComparer.Ordinal); do { - if (type == symbols.ComponentBase) + if (Equals(type, symbols.ComponentBase)) { // The ComponentBase base class doesn't have any [Parameter]. // Bail out now to avoid walking through its many members, plus the members @@ -380,7 +380,7 @@ namespace Microsoft.CodeAnalysis.Razor kind = PropertyKind.Ignored; } - if (!property.GetAttributes().Any(a => a.AttributeClass == symbols.ParameterAttribute)) + if (!property.GetAttributes().Any(a => Equals(a.AttributeClass, symbols.ParameterAttribute))) { if (property.IsOverride) { @@ -398,7 +398,7 @@ namespace Microsoft.CodeAnalysis.Razor kind = PropertyKind.Enum; } - if (kind == PropertyKind.Default && property.Type == symbols.RenderFragment) + if (kind == PropertyKind.Default && Equals(property.Type, symbols.RenderFragment)) { kind = PropertyKind.ChildContent; } @@ -406,12 +406,12 @@ namespace Microsoft.CodeAnalysis.Razor if (kind == PropertyKind.Default && property.Type is INamedTypeSymbol namedType && namedType.IsGenericType && - namedType.ConstructedFrom == symbols.RenderFragmentOfT) + Equals(namedType.ConstructedFrom, symbols.RenderFragmentOfT)) { kind = PropertyKind.ChildContent; } - if (kind == PropertyKind.Default && property.Type == symbols.EventCallback) + if (kind == PropertyKind.Default && Equals(property.Type, symbols.EventCallback)) { kind = PropertyKind.EventCallback; } @@ -419,7 +419,7 @@ namespace Microsoft.CodeAnalysis.Razor if (kind == PropertyKind.Default && property.Type is INamedTypeSymbol namedType2 && namedType2.IsGenericType && - namedType2.ConstructedFrom == symbols.EventCallbackOfT) + Equals(namedType2.ConstructedFrom, symbols.EventCallbackOfT)) { kind = PropertyKind.EventCallback; } diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/src/DefaultTagHelperDescriptorFactory.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/src/DefaultTagHelperDescriptorFactory.cs index 333003f5b2..17924a0018 100644 --- a/src/Razor/Microsoft.CodeAnalysis.Razor/src/DefaultTagHelperDescriptorFactory.cs +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/src/DefaultTagHelperDescriptorFactory.cs @@ -80,7 +80,7 @@ namespace Microsoft.CodeAnalysis.Razor { var targetElementAttributes = type .GetAttributes() - .Where(attribute => attribute.AttributeClass == _htmlTargetElementAttributeSymbol); + .Where(attribute => Equals(attribute.AttributeClass, _htmlTargetElementAttributeSymbol)); // If there isn't an attribute specifying the tag name derive it from the name if (!targetElementAttributes.Any()) @@ -139,7 +139,7 @@ namespace Microsoft.CodeAnalysis.Razor private void AddAllowedChildren(INamedTypeSymbol type, TagHelperDescriptorBuilder builder) { - var restrictChildrenAttribute = type.GetAttributes().Where(a => a.AttributeClass == _restrictChildrenAttributeSymbol).FirstOrDefault(); + var restrictChildrenAttribute = type.GetAttributes().Where(a => Equals(a.AttributeClass, _restrictChildrenAttributeSymbol)).FirstOrDefault(); if (restrictChildrenAttribute == null) { return; @@ -174,7 +174,7 @@ namespace Microsoft.CodeAnalysis.Razor private void AddTagOutputHint(INamedTypeSymbol type, TagHelperDescriptorBuilder builder) { string outputElementHint = null; - var outputElementHintAttribute = type.GetAttributes().Where(a => a.AttributeClass == _outputElementHintAttributeSymbol).FirstOrDefault(); + var outputElementHintAttribute = type.GetAttributes().Where(a => Equals(a.AttributeClass, _outputElementHintAttributeSymbol)).FirstOrDefault(); if (outputElementHintAttribute != null) { outputElementHint = (string)(outputElementHintAttribute.ConstructorArguments[0]).Value; @@ -189,7 +189,7 @@ namespace Microsoft.CodeAnalysis.Razor { var attributeNameAttribute = property .GetAttributes() - .Where(a => a.AttributeClass == _htmlAttributeNameAttributeSymbol) + .Where(a => Equals(a.AttributeClass, _htmlAttributeNameAttributeSymbol)) .FirstOrDefault(); bool hasExplicitName; @@ -310,13 +310,13 @@ namespace Microsoft.CodeAnalysis.Razor private IReadOnlyList GetDictionaryArgumentTypes(IPropertySymbol property) { INamedTypeSymbol dictionaryType; - if ((property.Type as INamedTypeSymbol)?.ConstructedFrom == _iDictionarySymbol) + if (Equals((property.Type as INamedTypeSymbol)?.ConstructedFrom, _iDictionarySymbol)) { dictionaryType = (INamedTypeSymbol)property.Type; } - else if (property.Type.AllInterfaces.Any(s => s.ConstructedFrom == _iDictionarySymbol)) + else if (property.Type.AllInterfaces.Any(s => Equals(s.ConstructedFrom, _iDictionarySymbol))) { - dictionaryType = property.Type.AllInterfaces.First(s => s.ConstructedFrom == _iDictionarySymbol); + dictionaryType = property.Type.AllInterfaces.First(s => Equals(s.ConstructedFrom, _iDictionarySymbol)); } else { @@ -380,7 +380,7 @@ namespace Microsoft.CodeAnalysis.Razor private bool IsPotentialDictionaryProperty(IPropertySymbol property) { return - ((property.Type as INamedTypeSymbol)?.ConstructedFrom == _iDictionarySymbol || property.Type.AllInterfaces.Any(s => s.ConstructedFrom == _iDictionarySymbol)) && + (Equals((property.Type as INamedTypeSymbol)?.ConstructedFrom, _iDictionarySymbol) || property.Type.AllInterfaces.Any(s => Equals(s.ConstructedFrom, _iDictionarySymbol))) && GetDictionaryArgumentTypes(property)?[0].SpecialType == SpecialType.System_String; } @@ -397,8 +397,8 @@ namespace Microsoft.CodeAnalysis.Razor property.Parameters.Length == 0 && property.GetMethod != null && property.GetMethod.DeclaredAccessibility == Accessibility.Public && - property.GetAttributes().Where(a => a.AttributeClass == _htmlAttributeNotBoundAttributeSymbol).FirstOrDefault() == null && - (property.GetAttributes().Any(a => a.AttributeClass == _htmlAttributeNameAttributeSymbol) || + property.GetAttributes().Where(a => Equals(a.AttributeClass, _htmlAttributeNotBoundAttributeSymbol)).FirstOrDefault() == null && + (property.GetAttributes().Any(a => Equals(a.AttributeClass, _htmlAttributeNameAttributeSymbol)) || property.SetMethod != null && property.SetMethod.DeclaredAccessibility == Accessibility.Public || IsPotentialDictionaryProperty(property)) && !accessibleProperties.ContainsKey(property.Name)) @@ -418,7 +418,7 @@ namespace Microsoft.CodeAnalysis.Razor { if (ExcludeHidden) { - var editorBrowsableAttribute = symbol.GetAttributes().Where(a => a.AttributeClass == _editorBrowsableAttributeSymbol).FirstOrDefault(); + var editorBrowsableAttribute = symbol.GetAttributes().Where(a => Equals(a.AttributeClass, _editorBrowsableAttributeSymbol)).FirstOrDefault(); if (editorBrowsableAttribute == null) { diff --git a/src/Razor/Microsoft.CodeAnalysis.Razor/src/EventHandlerTagHelperDescriptorProvider.cs b/src/Razor/Microsoft.CodeAnalysis.Razor/src/EventHandlerTagHelperDescriptorProvider.cs index e2c5836a53..52710e8fd7 100644 --- a/src/Razor/Microsoft.CodeAnalysis.Razor/src/EventHandlerTagHelperDescriptorProvider.cs +++ b/src/Razor/Microsoft.CodeAnalysis.Razor/src/EventHandlerTagHelperDescriptorProvider.cs @@ -81,7 +81,7 @@ namespace Microsoft.CodeAnalysis.Razor { var attribute = attributes[j]; - if (attribute.AttributeClass == eventHandlerAttribute) + if (Equals(attribute.AttributeClass, eventHandlerAttribute)) { results.Add(new EventHandlerData( type.ContainingAssembly.Name,