提交 ebc69bcd 编写于 作者: V vladres

Replace invocations of CaseInsensitiveComparison.Compare with...

Replace invocations of CaseInsensitiveComparison.Compare with CaseInsensitiveComparison.Equals, remove some unnecessary code elements (usings, qualifiers, type arguments, casts, empty elements in xml doc comments).
 (changeset 1329726)
上级 01c81256
......@@ -763,7 +763,7 @@ private void CheckNewModifier(Symbol symbol, bool isNew, DiagnosticBag diagnosti
DiagnosticInfo useSiteDiagnostic = overriddenMember.GetUseSiteDiagnostic();
if (useSiteDiagnostic != null)
{
suppressAccessors = Symbol.ReportUseSiteDiagnostic(useSiteDiagnostic, diagnostics, overridingMember.Locations[0]);
suppressAccessors = ReportUseSiteDiagnostic(useSiteDiagnostic, diagnostics, overridingMember.Locations[0]);
}
}
}
......
......@@ -2276,7 +2276,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
DirectCast(right, GenericNameSyntax).Identifier)
If Not identifier.IsBracketed AndAlso
CaseInsensitiveComparison.Compare(identifier.ValueText, SyntaxFacts.GetText(SyntaxKind.NewKeyword)) = 0 Then
CaseInsensitiveComparison.Equals(identifier.ValueText, SyntaxFacts.GetText(SyntaxKind.NewKeyword)) Then
If leftTypeSymbol.IsArrayType() Then
' No instance constructors found. Can't call constructor on an array type.
......@@ -2435,7 +2435,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Dim effectiveOptions = If(left.Kind <> BoundKind.MyBaseReference, options,
options Or LookupOptions.UseBaseReferenceAccessibility)
If eventContext Then
effectiveOptions = CType(effectiveOptions Or LookupOptions.EventsOnly, LookupOptions)
effectiveOptions = effectiveOptions Or LookupOptions.EventsOnly
End If
LookupMember(lookupResult, type, rightName, rightArity, effectiveOptions, useSiteDiagnostics) ' overload resolution filters methods by arity.
......@@ -2524,7 +2524,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
referenceLocation IsNot Nothing AndAlso referenceLocation.IsInSource AndAlso
declarationLocation.SourceTree Is referenceLocation.SourceTree Then
localType = Symbols.LocalSymbol.UseBeforeDeclarationResultType
localType = LocalSymbol.UseBeforeDeclarationResultType
If diagnostics IsNot Nothing Then
ReportDiagnostic(diagnostics, node, ERRID.ERR_UseOfLocalBeforeDeclaration1, localSymbol)
......@@ -3357,7 +3357,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Dim typeCharacterString As String = Nothing
Dim specialType As SpecialType = GetSpecialTypeForTypeCharacter(typeChar, typeCharacterString)
If specialType <> Microsoft.CodeAnalysis.SpecialType.None Then
If specialType <> SpecialType.None Then
If type.IsArrayType() Then
type = DirectCast(type, ArrayTypeSymbol).ElementType
End If
......@@ -4151,10 +4151,10 @@ lElseClause:
Return BadExpression(node, operand, ErrorTypeSymbol.UnknownResultType)
ElseIf operand.Type.IsObjectType() Then
' Late-bound pattern.
If OptionStrict = VisualBasic.OptionStrict.On Then
If OptionStrict = OptionStrict.On Then
ReportDiagnostic(diagnostics, node, ERRID.ERR_StrictDisallowsLateBinding)
Return BadExpression(node, operand, ErrorTypeSymbol.UnknownResultType)
ElseIf OptionStrict = VisualBasic.OptionStrict.Custom Then
ElseIf OptionStrict = OptionStrict.Custom Then
ReportDiagnostic(diagnostics, node, ERRID.WRN_LateBindingResolution)
End If
End If
......
......@@ -3,11 +3,8 @@
Imports System.Collections.Immutable
Imports System.Runtime.InteropServices
Imports System.Threading
Imports Microsoft.CodeAnalysis.Collections
Imports Microsoft.CodeAnalysis.Text
Imports Microsoft.CodeAnalysis.VisualBasic.Symbols
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Imports TypeKind = Microsoft.CodeAnalysis.TypeKind
Namespace Microsoft.CodeAnalysis.VisualBasic
......@@ -500,7 +497,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
End If
block = New BoundBlock(lambdaSyntax, Nothing, ImmutableArray(Of LocalSymbol).Empty,
ImmutableArray.Create(Of BoundStatement)(boundStatement), boundStatement.HasErrors).MakeCompilerGenerated()
ImmutableArray.Create(boundStatement), boundStatement.HasErrors).MakeCompilerGenerated()
Case SyntaxKind.MultiLineFunctionLambdaExpression,
SyntaxKind.MultiLineSubLambdaExpression
......@@ -660,9 +657,9 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Public Sub ReportLambdaParameterInferredToBeObject(unboundParam As UnboundLambdaParameterSymbol, diagnostics As DiagnosticBag)
If OptionStrict = VisualBasic.OptionStrict.On Then
If OptionStrict = OptionStrict.On Then
ReportDiagnostic(diagnostics, unboundParam.IdentifierSyntax, ERRID.ERR_StrictDisallowImplicitObjectLambda)
ElseIf OptionStrict = VisualBasic.OptionStrict.Custom Then
ElseIf OptionStrict = OptionStrict.Custom Then
ReportDiagnostic(diagnostics, unboundParam.IdentifierSyntax, ERRID.WRN_ObjectAssumedVar1, ErrorFactory.ErrorInfo(ERRID.WRN_MissingAsClauseinVarDecl))
End If
End Sub
......@@ -949,7 +946,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
ReportDiagnostic(diagnostics, LambdaHeaderErrorNode(source), ERRID.ERR_RestrictedType1, restrictedType)
ElseIf numCandidates <> 1 Then
If OptionStrict = VisualBasic.OptionStrict.On Then
If OptionStrict = OptionStrict.On Then
If numCandidates = 0 Then
' "Cannot infer a return type, and Option Strict On does not allow 'Object' to be assumed. Specifying the return type might correct this error."
ReportDiagnostic(diagnostics, LambdaHeaderErrorNode(source), ERRID.ERR_LambdaNoTypeObjectDisallowed)
......@@ -959,7 +956,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
ReportDiagnostic(diagnostics, LambdaHeaderErrorNode(source), ERRID.ERR_LambdaTooManyTypesObjectDisallowed)
Debug.Assert(lambdaReturnType.IsObjectType())
End If
ElseIf OptionStrict = VisualBasic.OptionStrict.Custom Then
ElseIf OptionStrict = OptionStrict.Custom Then
If numCandidates = 0 Then
' "Cannot infer a return type; 'Object' assumed."
ReportDiagnostic(diagnostics, LambdaHeaderErrorNode(source), ERRID.WRN_ObjectAssumed1, ErrorFactory.ErrorInfo(ERRID.WRN_LambdaNoTypeObjectAssumed))
......
......@@ -2,13 +2,8 @@
Imports System.Collections.Immutable
Imports System.Runtime.InteropServices
Imports Microsoft.CodeAnalysis.Collections
Imports Microsoft.CodeAnalysis.RuntimeMembers
Imports Microsoft.CodeAnalysis.Text
Imports Microsoft.CodeAnalysis.VisualBasic.Symbols
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Imports TypeKind = Microsoft.CodeAnalysis.TypeKind
Imports Roslyn.Utilities
Namespace Microsoft.CodeAnalysis.VisualBasic
......@@ -1206,8 +1201,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
''' <param name="equalsValueOpt">The optional initializing expression</param>
''' <param name="valueExpression">The bound initializing expression</param>
''' <param name="asClauseType">The bound as clause type</param>
''' <returns></returns>
''' <remarks></remarks>
Friend Function ComputeVariableType(symbol As LocalSymbol,
modifiedIdentifierOpt As ModifiedIdentifierSyntax,
asClauseOpt As AsClauseSyntax,
......@@ -1221,18 +1214,18 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Dim typeDiagnostic As Func(Of DiagnosticInfo) = Nothing
If symbol.IsStatic Then
If OptionStrict = VisualBasic.OptionStrict.On Then
If OptionStrict = OptionStrict.On Then
typeDiagnostic = ErrorFactory.GetErrorInfo_ERR_StrictDisallowImplicitObject
ElseIf OptionStrict = VisualBasic.OptionStrict.Custom Then
ElseIf OptionStrict = OptionStrict.Custom Then
typeDiagnostic = ErrorFactory.GetErrorInfo_WRN_ObjectAssumedVar1_WRN_StaticLocalNoInference
End If
ElseIf Not (OptionInfer AndAlso equalsValueOpt IsNot Nothing) Then
If OptionStrict = VisualBasic.OptionStrict.On Then
If OptionStrict = OptionStrict.On Then
typeDiagnostic = ErrorFactory.GetErrorInfo_ERR_StrictDisallowImplicitObject
ElseIf OptionStrict = VisualBasic.OptionStrict.Custom Then
ElseIf OptionStrict = OptionStrict.Custom Then
typeDiagnostic = ErrorFactory.GetErrorInfo_WRN_ObjectAssumedVar1_WRN_MissingAsClauseinVarDecl
End If
End If
......@@ -1349,7 +1342,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
If valueType IsNot Nothing AndAlso valueType.GetEnumUnderlyingTypeOrSelf.IsIntrinsicType Then
type = valueExpression.Type
End If
ElseIf Not symbol.IsStatic AndAlso OptionStrict <> VisualBasic.OptionStrict.On AndAlso
ElseIf Not symbol.IsStatic AndAlso OptionStrict <> OptionStrict.On AndAlso
Not hasExplicitType AndAlso type.IsObjectType() AndAlso
modifiedIdentifierOpt IsNot Nothing AndAlso
modifiedIdentifierOpt.Nullable.Node IsNot Nothing AndAlso
......@@ -1695,7 +1688,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
' Set the type of the symbol, so we don't have to re-compute it later.
local.SetType(type)
If localForFunctionValue IsNot Nothing AndAlso CaseInsensitiveComparison.Compare(local.Name, localForFunctionValue.Name) = 0 Then
If localForFunctionValue IsNot Nothing AndAlso CaseInsensitiveComparison.Equals(local.Name, localForFunctionValue.Name) Then
' Does name conflict with the function name?
ReportDiagnostic(diagnostics, nameSyntax, ERRID.ERR_LocalSameAsFunc)
......@@ -2744,7 +2737,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Dim condition As BoundExpression = BindBooleanExpression(node.WhileStatement.Condition, diagnostics)
' Get the binder for the body of the loop. This defines the break and continue labels.
Dim loopBodyBinder = GetBinder(DirectCast(node, VisualBasicSyntaxNode))
Dim loopBodyBinder = GetBinder(node)
' Bind the body of the loop.
Dim loopBody As BoundBlock = loopBodyBinder.BindBlock(node, node.Statements, diagnostics)
......@@ -2760,7 +2753,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
' that is visible through the entire For block. It also needs to support Continue/Exit
' Interestingly, control variable is in scope when Limit and Step or the collection are bound,
' but initialized after Limit and Step or collection are evaluated...
Dim loopBinder = Me.GetBinder(DirectCast(node, VisualBasicSyntaxNode))
Dim loopBinder = Me.GetBinder(node)
Debug.Assert(loopBinder IsNot Nothing)
Dim declaredOrInferredLocalOpt As LocalSymbol = Nothing
......@@ -2790,7 +2783,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
' that is visible through the entire For block. It also needs to support Continue/Exit
' Interestingly, control variable is in scope when Limit and Step or the collection are bound,
' but initialized after Limit and Step or collection are evaluated...
Dim loopBinder = Me.GetBinder(DirectCast(node, VisualBasicSyntaxNode))
Dim loopBinder = Me.GetBinder(node)
Debug.Assert(loopBinder IsNot Nothing)
Dim declaredOrInferredLocalOpt As LocalSymbol = Nothing
......@@ -3458,7 +3451,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Private Function VerifyForControlVariableDeclaration(variableDeclarator As VariableDeclaratorSyntax, diagnostics As DiagnosticBag) As Boolean
' Check variable declaration syntax if present
Debug.Assert(variableDeclarator.Names.Count = 1, "should be exactly one control variable")
Dim identifier = DirectCast(variableDeclarator.Names(0), ModifiedIdentifierSyntax)
Dim identifier = variableDeclarator.Names(0)
' nullable type inference is not supported
If variableDeclarator.AsClause Is Nothing AndAlso
......@@ -3714,7 +3707,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
ienumerableUseSiteDiagnostics.Clear()
Dim ienumerable = GetSpecialType(SpecialType.System_Collections_IEnumerable, collectionSyntax, ienumerableUseSiteDiagnostics)
If ((collection.IsNothingLiteral OrElse collectionType.IsObjectType) AndAlso Me.OptionStrict <> VisualBasic.OptionStrict.On) OrElse
If ((collection.IsNothingLiteral OrElse collectionType.IsObjectType) AndAlso Me.OptionStrict <> OptionStrict.On) OrElse
(Not collection.IsNothingLiteral AndAlso Not collectionType.IsArrayType AndAlso IsOrInheritsFromOrImplementsInterface(collectionType, ienumerable, useSiteDiagnostics, matchingInterfaces)) Then
Debug.Assert(collection.IsNothingLiteral OrElse collectionType.IsObjectType OrElse (matchingInterfaces.First = ienumerable AndAlso matchingInterfaces.Count = 1))
......@@ -3730,7 +3723,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
ienumerableUseSiteDiagnostics.Free()
Else
Debug.Assert(collectionType IsNot Nothing OrElse collection.IsNothingLiteral AndAlso Me.OptionStrict = VisualBasic.OptionStrict.On)
Debug.Assert(collectionType IsNot Nothing OrElse collection.IsNothingLiteral AndAlso Me.OptionStrict = OptionStrict.On)
diagnostics.Add(collectionSyntax, useSiteDiagnostics)
......@@ -3802,7 +3795,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Dim methodOrPropertyGroup As BoundMethodOrPropertyGroup
methodOrPropertyGroup = New BoundMethodGroup(collectionSyntax,
Nothing,
ImmutableArray.Create(Of MethodSymbol)(DirectCast(member, MethodSymbol)),
ImmutableArray.Create(DirectCast(member, MethodSymbol)),
LookupResultKind.Good,
collectionPlaceholder,
QualificationKind.QualifiedViaValue)
......@@ -3823,7 +3816,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
If member IsNot Nothing AndAlso member.GetUseSiteErrorInfo Is Nothing Then
methodOrPropertyGroup = New BoundMethodGroup(collectionSyntax,
Nothing,
ImmutableArray.Create(Of MethodSymbol)(DirectCast(member, MethodSymbol)),
ImmutableArray.Create(DirectCast(member, MethodSymbol)),
LookupResultKind.Good,
boundEnumeratorPlaceholder,
QualificationKind.QualifiedViaValue)
......@@ -3854,7 +3847,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
If member IsNot Nothing AndAlso member.GetUseSiteErrorInfo Is Nothing Then
methodOrPropertyGroup = New BoundPropertyGroup(collectionSyntax,
ImmutableArray.Create(Of PropertySymbol)(DirectCast(member, PropertySymbol)),
ImmutableArray.Create(DirectCast(member, PropertySymbol)),
LookupResultKind.Good,
boundEnumeratorPlaceholder,
QualificationKind.QualifiedViaValue)
......@@ -3890,7 +3883,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
' do not actually generate dispose calls in IL
' Dev10 does the same thing (StatementSemantics.cpp, Line 5678++)
' this is true even for multidimensional arrays that are handled through the design pattern.
Debug.Assert(collectionType IsNot Nothing OrElse OptionStrict <> VisualBasic.OptionStrict.On AndAlso collection.Kind = BoundKind.Conversion AndAlso DirectCast(collection, BoundConversion).Operand.IsNothingLiteral)
Debug.Assert(collectionType IsNot Nothing OrElse OptionStrict <> OptionStrict.On AndAlso collection.Kind = BoundKind.Conversion AndAlso DirectCast(collection, BoundConversion).Operand.IsNothingLiteral)
If collectionType Is Nothing OrElse Not collectionType.IsArrayType Then
needToDispose = True
End If
......@@ -4302,7 +4295,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
''' end using
'''</summary>
Public Function BindUsingBlock(node As UsingBlockSyntax, diagnostics As DiagnosticBag) As BoundStatement
Dim usingBinder = Me.GetBinder(DirectCast(node, VisualBasicSyntaxNode))
Dim usingBinder = Me.GetBinder(node)
Debug.Assert(usingBinder IsNot Nothing)
Dim resourceList As ImmutableArray(Of BoundLocalDeclarationBase) = Nothing
......@@ -4459,7 +4452,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Dim isValidDispose = Conversions.IsWideningConversion(conversionKind)
If isValidDispose OrElse
(resourceType.IsObjectType() AndAlso OptionStrict <> VisualBasic.OptionStrict.On) Then
(resourceType.IsObjectType() AndAlso OptionStrict <> OptionStrict.On) Then
Dim resourcePlaceholder = New BoundRValuePlaceholder(syntaxNode, resourceType)
Dim disposeConversion As BoundExpression = Nothing
Dim disposeCondition As BoundExpression = Nothing
......@@ -4606,7 +4599,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
ReportDiagnostic(diagnostics, node.TryPart.Begin, ERRID.ERR_TryWithoutCatchOrFinally)
End If
Dim tryBinder As Binder = GetBinder(DirectCast(node, VisualBasicSyntaxNode))
Dim tryBinder As Binder = GetBinder(node)
Return New BoundTryStatement(node, tryBlock, catchBlocks, finallyBlockOpt, tryBinder.GetExitLabel(SyntaxKind.ExitTryStatement))
End Function
......@@ -4847,7 +4840,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
' If we are not in a lambda binding then we have a real return statement.
Debug.Assert(originalSyntax IsNot Nothing)
Debug.Assert(expressionSyntax Is originalSyntax OrElse DirectCast(originalSyntax, ReturnStatementSyntax).Expression Is expressionSyntax)
Debug.Assert(expressionSyntax Is originalSyntax OrElse originalSyntax.Expression Is expressionSyntax)
Dim isAsync As Boolean
Dim isIterator As Boolean
......
' Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System.Collections.Generic
Imports System.Collections.Immutable
Imports System.Collections.ObjectModel
Imports System.Runtime.CompilerServices
Imports System.Runtime.InteropServices
Imports System.Threading
Imports Microsoft.CodeAnalysis.Text
Imports Microsoft.CodeAnalysis.VisualBasic.Symbols
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Imports TypeKind = Microsoft.CodeAnalysis.TypeKind
Namespace Microsoft.CodeAnalysis.VisualBasic
......@@ -506,7 +502,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
baseType = CreateNullableOf(baseType,
modifiedIdentifier,
If(asClauseSyntaxOpt IsNot Nothing,
DirectCast(asClauseSyntaxOpt.Type, VisualBasicSyntaxNode),
asClauseSyntaxOpt.Type,
DirectCast(modifiedIdentifier, VisualBasicSyntaxNode)),
diagBag)
End If
......@@ -875,7 +871,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Dim name = param.Name
For Each tp In typeParams
If CaseInsensitiveComparison.Compare(tp.Name, name) = 0 Then
If CaseInsensitiveComparison.Equals(tp.Name, name) Then
' "'{0}' is already declared as a type parameter of this method."
ReportDiagnostic(diagBag, paramSyntax.Identifier, ERRID.ERR_NameSameAsMethodTypeParam1, name)
Exit For
......@@ -966,7 +962,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Private Shared Function CheckReservedParameterName(reservedName As String, syntax As ParameterSyntax, errorId As ERRID, diagnostics As DiagnosticBag) As Boolean
Dim identifier = syntax.Identifier
Dim name = identifier.Identifier.ValueText
If IdentifierComparison.Compare(reservedName, name) = 0 Then
If IdentifierComparison.Equals(reservedName, name) Then
Dim location = identifier.GetLocation()
diagnostics.Add(errorId, location)
Return False
......@@ -983,7 +979,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
diagnostics As DiagnosticBag)
Dim name = parameter.Name
For i = 0 To nParams - 1
If IdentifierComparison.Compare(params(i).Name, name) = 0 Then
If IdentifierComparison.Equals(params(i).Name, name) Then
' "Parameter already declared with name '{0}'."
ReportDiagnostic(diagnostics, syntax.Identifier, ERRID.ERR_DuplicateParamName1, name)
Return
......
......@@ -4,7 +4,8 @@ Imports Microsoft.CodeAnalysis.VisualBasic.Symbols
Namespace Microsoft.CodeAnalysis.VisualBasic
''' <summary> This is an implementation of a special symbol comparer, which is supposed to be used for
''' <summary>
''' This is an implementation of a special symbol comparer, which is supposed to be used for
''' sorting original definition symbols (explicitly or explicitly declared in source within the same
''' container) in lexical order of their declarations. It will not work on anything that uses non-source locations.
''' </summary>
......@@ -16,7 +17,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Private Sub New()
End Sub
Public Function Compare(x As Symbol, y As Symbol) As Integer Implements IComparer(Of Microsoft.CodeAnalysis.VisualBasic.Symbol).Compare
Public Function Compare(x As Symbol, y As Symbol) As Integer Implements IComparer(Of Symbol).Compare
Dim comparison As Integer
If x Is y Then
......
......@@ -3,7 +3,6 @@
Imports System.Collections.Immutable
Imports System.Runtime.InteropServices
Imports System.Threading
Imports Microsoft.CodeAnalysis.Diagnostics
Imports Microsoft.CodeAnalysis.Instrumentation
Imports Microsoft.CodeAnalysis.Text
Imports Microsoft.CodeAnalysis.VisualBasic.Symbols
......@@ -569,7 +568,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Return True
End If
If node.IsStructuredTrivia Then
node = DirectCast(DirectCast(node, StructuredTriviaSyntax).ParentTrivia.Token.Parent, VisualBasicSyntaxNode)
node = DirectCast(node, StructuredTriviaSyntax).ParentTrivia.Token.Parent
Else
node = node.Parent
End If
......@@ -687,7 +686,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
SyntaxKind.CrefOperatorReference,
SyntaxKind.CrefReference,
SyntaxKind.XmlString
' fall through
' fall through
Case Else
Return False
......@@ -906,7 +905,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
AddSymbolsFromDiagnosticInfo(symbolsBuilder, DirectCast(s, ErrorTypeSymbol).ErrorInfo)
Return symbolsBuilder.ToImmutable()
Else
Return ImmutableArray.Create(Of Symbol)(s)
Return ImmutableArray.Create(s)
End If
Else
' 2 or more symbols. Use a hash set to remove duplicates.
......@@ -928,7 +927,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
End If
Next
Return ImmutableArray.CreateRange(Of Symbol)(symbolSet)
Return ImmutableArray.CreateRange(symbolSet)
End If
End Function
......@@ -1994,8 +1993,8 @@ _Default:
Dim type As NamedTypeSymbol = TryCast(container, NamedTypeSymbol)
If type IsNot Nothing AndAlso
(options And (Global.Microsoft.CodeAnalysis.VisualBasic.LookupOptions.LabelsOnly Or Global.Microsoft.CodeAnalysis.VisualBasic.LookupOptions.NamespacesOrTypesOnly Or Global.Microsoft.CodeAnalysis.VisualBasic.LookupOptions.MustNotBeInstance)) = 0 Then
If (options And Global.Microsoft.CodeAnalysis.VisualBasic.LookupOptions.IgnoreAccessibility) <> 0 Then
(options And (LookupOptions.LabelsOnly Or LookupOptions.NamespacesOrTypesOnly Or LookupOptions.MustNotBeInstance)) = 0 Then
If (options And LookupOptions.IgnoreAccessibility) <> 0 Then
constructors = type.InstanceConstructors
Else
constructors = binder.GetAccessibleConstructors(type, useSiteDiagnostics:=Nothing)
......@@ -2923,7 +2922,7 @@ _Default:
Dim symbolInfo As VisualBasicPreprocessingSymbolInfo = node.SyntaxTree.GetPreprocessingSymbolInfo(node)
If symbolInfo.Symbol IsNot Nothing Then
Debug.Assert(CaseInsensitiveComparison.Compare(symbolInfo.Symbol.Name, node.Identifier.ValueText) = 0)
Debug.Assert(CaseInsensitiveComparison.Equals(symbolInfo.Symbol.Name, node.Identifier.ValueText))
Return symbolInfo
End If
......
' Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
' Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System.Collections.Concurrent
Imports System.Collections.Immutable
......@@ -6,6 +6,7 @@ Imports System.IO
Imports System.Runtime.InteropServices
Imports System.Threading
Imports System.Threading.Tasks
Imports Microsoft.Cci
Imports Microsoft.CodeAnalysis.CodeGen
Imports Microsoft.CodeAnalysis.Diagnostics
Imports Microsoft.CodeAnalysis.Emit
......@@ -263,6 +264,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
End Property
#Region "Constructors and Factories"
''' <summary>
''' Create a new compilation from scratch.
''' </summary>
......@@ -301,7 +303,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
CheckSubmissionOptions(options)
Dim vbTree = DirectCast(syntaxTree, SyntaxTree)
Dim vbTree = syntaxTree
Dim vbPrevious = DirectCast(previousSubmission, VisualBasicCompilation)
Return Create(
......@@ -660,7 +662,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
''' </param>
''' <returns>
''' Returns a static type of the expression of the last expression or call statement if there is any,
''' a symbol for <see cref="System.Void"/> otherwise.
''' a symbol for <see cref="Void"/> otherwise.
''' </returns>
''' <remarks>
''' Note that the return type is System.Void for both compilations "System.Console.WriteLine()" and "?System.Console.WriteLine()",
......@@ -755,7 +757,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Throw New ArgumentNullException("syntaxTree")
End If
Dim vbtree = TryCast(syntaxTree, SyntaxTree)
Dim vbtree = syntaxTree
Return vbtree IsNot Nothing AndAlso m_rootNamespaces.ContainsKey(vbtree)
End Function
......@@ -937,8 +939,8 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Throw New ArgumentException(VBResources.TreeMustHaveARootNodeWithCompilationUnit, "newTree")
End If
Dim vbOldTree = DirectCast(oldTree, SyntaxTree)
Dim vbNewTree = DirectCast(newTree, SyntaxTree)
Dim vbOldTree = oldTree
Dim vbNewTree = newTree
If vbOldTree.IsEmbeddedOrMyTemplateTree() Then
Throw New ArgumentException(VBResources.CannotRemoveCompilerSpecialTree)
......@@ -976,7 +978,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
End Function
Private Shared Function CreateEmbeddedTrees(compReference As Lazy(Of VisualBasicCompilation)) As ImmutableArray(Of EmbeddedTreeAndDeclaration)
Return ImmutableArray.Create(Of EmbeddedTreeAndDeclaration)(
Return ImmutableArray.Create(
New EmbeddedTreeAndDeclaration(
Function()
Dim compilation = compReference.Value
......@@ -987,7 +989,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Function()
Dim compilation = compReference.Value
Return If(compilation.Options.EmbedVbCoreRuntime Or compilation.IncludeInternalXmlHelper,
ForTree(VisualBasic.Symbols.EmbeddedSymbolManager.EmbeddedSyntax, compilation.Options, compilation.IsSubmission),
ForTree(EmbeddedSymbolManager.EmbeddedSyntax, compilation.Options, compilation.IsSubmission),
Nothing)
End Function),
New EmbeddedTreeAndDeclaration(
......@@ -1000,7 +1002,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Function()
Dim compilation = compReference.Value
Return If(compilation.Options.EmbedVbCoreRuntime,
ForTree(VisualBasic.Symbols.EmbeddedSymbolManager.VbCoreSyntaxTree, compilation.Options, compilation.IsSubmission),
ForTree(EmbeddedSymbolManager.VbCoreSyntaxTree, compilation.Options, compilation.IsSubmission),
Nothing)
End Function),
New EmbeddedTreeAndDeclaration(
......@@ -1013,7 +1015,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Function()
Dim compilation = compReference.Value
Return If(compilation.IncludeInternalXmlHelper(),
ForTree(VisualBasic.Symbols.EmbeddedSymbolManager.InternalXmlHelperSyntax, compilation.Options, compilation.IsSubmission),
ForTree(EmbeddedSymbolManager.InternalXmlHelperSyntax, compilation.Options, compilation.IsSubmission),
Nothing)
End Function),
New EmbeddedTreeAndDeclaration(
......@@ -1690,7 +1692,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
''' <summary>
''' Resolves a symbol that represents script container (Script class).
''' Uses the full name of the container class stored in <see cref="P:CompilationOptions.ScriptClassName"/> to find the symbol.
''' Uses the full name of the container class stored in <see cref="CompilationOptions.ScriptClassName"/> to find the symbol.
''' </summary>
''' <returns>
''' The Script class symbol or null if it is not defined.
......@@ -1707,9 +1709,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
''' <summary>
''' Get symbol for predefined type from Cor Library referenced by this compilation.
''' </summary>
''' <param name="typeId"></param>
''' <returns></returns>
''' <remarks></remarks>
Friend Shadows Function GetSpecialType(typeId As SpecialType) As NamedTypeSymbol
Dim result = Assembly.GetSpecialType(typeId)
Debug.Assert(result.SpecialType = typeId)
......@@ -1760,7 +1759,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
''' SemanticModel.
'''</summary>
Public Shadows Function GetSemanticModel(syntaxTree As SyntaxTree) As SemanticModel
Return New SyntaxTreeSemanticModel(Me, DirectCast(Me.SourceModule, SourceModuleSymbol), DirectCast(syntaxTree, SyntaxTree))
Return New SyntaxTreeSemanticModel(Me, DirectCast(Me.SourceModule, SourceModuleSymbol), syntaxTree)
End Function
#End Region
......@@ -2011,7 +2010,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Friend Overrides Function AnalyzerForLanguage(analyzers As ImmutableArray(Of IDiagnosticAnalyzer), options As AnalyzerOptions, cancellationToken As CancellationToken) As AnalyzerDriver
Dim getKind As Func(Of SyntaxNode, SyntaxKind) = Function(node As SyntaxNode) node.VisualBasicKind
Return New AnalyzerDriver(Of VisualBasic.SyntaxKind)(analyzers, getKind, options, cancellationToken)
Return New AnalyzerDriver(Of SyntaxKind)(analyzers, getKind, options, cancellationToken)
End Function
#End Region
......@@ -2329,9 +2328,9 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
diagnosticBag.Add(ERRID.WRN_MultipleDeclFileExtChecksum, New SourceLocation(checkSumDirective), path)
Else
Dim newDocument = New Cci.DebugSourceDocument(
Dim newDocument = New DebugSourceDocument(
normalizedPath,
Cci.DebugSourceDocument.CorSymLanguageTypeBasic,
DebugSourceDocument.CorSymLanguageTypeBasic,
MakeCheckSumBytes(checkSumDirective.Checksum.ValueText),
Guid.Parse(checkSumDirective.Guid.ValueText))
......@@ -2372,9 +2371,9 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Return builder.ToImmutableAndFree()
End Function
Private Shared Function MakeDebugSourceDocumentForTree(normalizedPath As String, tree As SyntaxTree) As Cci.DebugSourceDocument
Private Shared Function MakeDebugSourceDocumentForTree(normalizedPath As String, tree As SyntaxTree) As DebugSourceDocument
Dim checkSumSha1 As Func(Of ImmutableArray(Of Byte)) = Function() tree.GetSha1Checksum()
Return New Cci.DebugSourceDocument(normalizedPath, Microsoft.Cci.DebugSourceDocument.CorSymLanguageTypeBasic, checkSumSha1)
Return New DebugSourceDocument(normalizedPath, DebugSourceDocument.CorSymLanguageTypeBasic, checkSumSha1)
End Function
Private Sub SetupWin32Resources(moduleBeingBuilt As PEModuleBuilder, win32Resources As Stream, diagnostics As DiagnosticBag)
......@@ -2442,7 +2441,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
End Property
Protected Overrides Function CommonGetSemanticModel(syntaxTree As SyntaxTree) As SemanticModel
Return Me.GetSemanticModel(DirectCast(syntaxTree, SyntaxTree))
Return Me.GetSemanticModel(syntaxTree)
End Function
Protected Overrides ReadOnly Property CommonSyntaxTrees As IEnumerable(Of SyntaxTree)
......@@ -2482,7 +2481,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
End Function
Protected Overrides Function CommonReplaceSyntaxTree(oldTree As SyntaxTree, newTree As SyntaxTree) As Compilation
Return Me.ReplaceSyntaxTree(DirectCast(oldTree, SyntaxTree), DirectCast(newTree, SyntaxTree))
Return Me.ReplaceSyntaxTree(oldTree, newTree)
End Function
Protected Overrides Function CommonWithOptions(options As CompilationOptions) As Compilation
......@@ -2494,7 +2493,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
End Function
Protected Overrides Function CommonContainsSyntaxTree(syntaxTree As SyntaxTree) As Boolean
Return Me.ContainsSyntaxTree(DirectCast(syntaxTree, SyntaxTree))
Return Me.ContainsSyntaxTree(syntaxTree)
End Function
Protected Overrides Function CommonGetAssemblyOrModuleSymbol(reference As MetadataReference) As ISymbol
......
......@@ -117,7 +117,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
Public Overrides Function GetMembers(name As String) As ImmutableArray(Of Symbol)
' TODO - Perf
Return ImmutableArray.CreateRange(Of Symbol)(From member In GetMembers() Where CaseInsensitiveComparison.Compare(member.Name, name) = 0)
Return ImmutableArray.CreateRange(Of Symbol)(From member In GetMembers() Where CaseInsensitiveComparison.Equals(member.Name, name))
End Function
Public Overrides ReadOnly Property MemberNames As IEnumerable(Of String)
......@@ -287,7 +287,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
' WARNING: this functionality assumes that 'type' has the
' same method indexes as the original type
Dim mappedMethod As MethodSymbol = DirectCast(type.GetMembers()(index), MethodSymbol)
Debug.Assert(IdentifierComparison.Compare(method.Name, mappedMethod.Name) = 0)
Debug.Assert(IdentifierComparison.Equals(method.Name, mappedMethod.Name))
Debug.Assert(method.OverriddenMethod Is mappedMethod.OverriddenMethod)
Return mappedMethod
......
......@@ -3,7 +3,9 @@
Imports System.Collections.Immutable
Imports System.Runtime.InteropServices
Imports System.Threading
Imports Microsoft.Cci
Imports Microsoft.CodeAnalysis
Imports Microsoft.CodeAnalysis.Emit
Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
Partial Friend NotInheritable Class AnonymousTypeManager
......@@ -71,7 +73,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
End If
End Sub
Friend MustOverride Function GetAnonymousTypeKey() As Microsoft.CodeAnalysis.Emit.AnonymousTypeKey
Friend MustOverride Function GetAnonymousTypeKey() As AnonymousTypeKey
Public Overrides ReadOnly Property Name As String
Get
......@@ -191,7 +193,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
End Get
End Property
Friend Overrides Function GetSecurityInformation() As IEnumerable(Of Microsoft.Cci.SecurityAttribute)
Friend Overrides Function GetSecurityInformation() As IEnumerable(Of SecurityAttribute)
Throw ExceptionUtilities.Unreachable
End Function
......@@ -211,7 +213,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
Public Overrides Function GetMembers(name As String) As ImmutableArray(Of Symbol)
' TODO - Perf
Return ImmutableArray.CreateRange(Of Symbol)(From member In GetMembers() Where CaseInsensitiveComparison.Compare(member.Name, name) = 0)
Return ImmutableArray.CreateRange(From member In GetMembers() Where CaseInsensitiveComparison.Equals(member.Name, name))
End Function
Public Overrides ReadOnly Property MemberNames As IEnumerable(Of String)
......
' Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System
Imports System.Collections.Generic
Imports System.Collections.Immutable
Imports System.Diagnostics
Imports System.Globalization
Imports System.Threading
Imports System.Reflection
Imports System.Reflection.Metadata
Imports Microsoft.CodeAnalysis.Text
Imports Microsoft.CodeAnalysis.VisualBasic.Symbols
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Imports Roslyn.Utilities
Imports Microsoft.Cci
Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols.Metadata.PE
......@@ -138,7 +132,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols.Metadata.PE
Public Overrides ReadOnly Property DeclaredAccessibility As Accessibility
Get
If Me.m_lazyDeclaredAccessibility = UnsetAccessibility Then
Interlocked.CompareExchange(Me.m_lazyDeclaredAccessibility, DirectCast(GetDeclaredAccessibility(Me), Integer), UnsetAccessibility)
Interlocked.CompareExchange(Me.m_lazyDeclaredAccessibility, GetDeclaredAccessibility(Me), UnsetAccessibility)
End If
Return DirectCast(Me.m_lazyDeclaredAccessibility, Accessibility)
......@@ -191,7 +185,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols.Metadata.PE
Get
Dim defaultPropertyName = m_containingType.DefaultPropertyName
Return (Not String.IsNullOrEmpty(defaultPropertyName)) AndAlso
(IdentifierComparison.Compare(defaultPropertyName, m_name) = 0)
IdentifierComparison.Equals(defaultPropertyName, m_name)
End Get
End Property
......@@ -254,9 +248,9 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols.Metadata.PE
End Get
End Property
Friend Overrides ReadOnly Property CallingConvention As Microsoft.Cci.CallingConvention
Friend Overrides ReadOnly Property CallingConvention As CallingConvention
Get
Return CType(m_callingConvention, Microsoft.Cci.CallingConvention)
Return CType(m_callingConvention, CallingConvention)
End Get
End Property
......@@ -444,7 +438,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols.Metadata.PE
' Do not set a parameter name unless accessors match. This prevents
' binding o.P(x:=1, y:=2) where the arguments x and y have different
' parameter indices in get_P and set_P.
If IdentifierComparison.Compare(name, setParameter.Name) <> 0 Then
If Not IdentifierComparison.Equals(name, setParameter.Name) Then
name = Nothing
End If
......
......@@ -6,7 +6,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
''' <summary>
''' Represents a preprocessing conditional compilation symbol.
''' </summary>
''' <remarks></remarks>
Friend NotInheritable Class PreprocessingSymbol
Inherits Symbol
Implements IPreprocessingSymbol
......@@ -100,7 +99,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
Dim other As PreprocessingSymbol = TryCast(obj, PreprocessingSymbol)
Return other IsNot Nothing AndAlso
IdentifierComparison.Compare(Me.Name, other.Name) = 0
IdentifierComparison.Equals(Me.Name, other.Name)
End Function
Public Overrides Function GetHashCode() As Integer
......
' Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System.Collections.Generic
Imports System.Collections.Immutable
Imports System.Diagnostics
Imports System.Runtime.InteropServices
Imports System.Threading
Imports Microsoft.CodeAnalysis.Text
Imports Microsoft.CodeAnalysis.VisualBasic.Symbols
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Imports Roslyn.Utilities
Imports TypeKind = Microsoft.CodeAnalysis.TypeKind
Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
''' <summary>
''' Represents enum constant field in source.
''' </summary>
......@@ -42,7 +35,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
name:=syntax.Identifier.ValueText,
memberFlags:=SourceMemberFlags.Const Or SourceMemberFlags.Shared Or SourceMemberFlags.AccessibilityPublic)
If IdentifierComparison.Compare(Me.Name, WellKnownMemberNames.EnumBackingFieldName) = 0 Then
If IdentifierComparison.Equals(Me.Name, WellKnownMemberNames.EnumBackingFieldName) Then
diagnostics.Add(ERRID.ERR_ClashWithReservedEnumMember1, syntax.Identifier.GetLocation(), Me.Name)
End If
End Sub
......
' Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System.Collections.Concurrent
Imports System.Collections.Generic
Imports System.Collections.Immutable
Imports System.Globalization
Imports System.Runtime.InteropServices
Imports System.Threading
Imports Microsoft.CodeAnalysis.Text
Imports Microsoft.CodeAnalysis.VisualBasic.Symbols
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Imports TypeKind = Microsoft.CodeAnalysis.TypeKind
Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
......@@ -22,7 +17,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
''' <summary>
''' Holds information about a SourceType in a compact form.
''' </summary>
''' <remarks></remarks>
<Flags>
Friend Enum SourceTypeFlags As UShort
[Private] = CUShort(Accessibility.Private)
......@@ -224,14 +218,14 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
Dim kind = declaration.SyntaxReferences.First.SyntaxTree.GetEmbeddedKind()
If kind <> VisualBasic.Symbols.EmbeddedSymbolKind.None Then
If kind <> EmbeddedSymbolKind.None Then
Return New EmbeddedSymbolManager.EmbeddedNamedTypeSymbol(declaration, containingSymbol, containingModule, kind)
End If
Select Case declaration.Kind
Case VisualBasic.Symbols.DeclarationKind.ImplicitClass,
VisualBasic.Symbols.DeclarationKind.Script,
VisualBasic.Symbols.DeclarationKind.Submission
Case DeclarationKind.ImplicitClass,
DeclarationKind.Script,
DeclarationKind.Submission
Return New ImplicitNamedTypeSymbol(declaration, containingSymbol, containingModule)
Case Else
......@@ -365,7 +359,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
' NOTE: we don't check for use-site errors on the following two types, because
' for EmitMetadataOnly scenario this is not important, and for regular
' emit, those errors will be reported by AsyncRewriter
Dim valueTypeSymbol As NamedTypeSymbol = compilation.GetSpecialType(Microsoft.CodeAnalysis.SpecialType.System_ValueType)
Dim valueTypeSymbol As NamedTypeSymbol = compilation.GetSpecialType(SpecialType.System_ValueType)
Dim iAsyncStateMachine As NamedTypeSymbol = compilation.GetWellKnownType(WellKnownType.System_Runtime_CompilerServices_IAsyncStateMachine)
' NOTE: get the attribute type constructor to ensure use-site errors are reported
......@@ -1332,7 +1326,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
Public Overrides ReadOnly Property TypeKind As TypeKind
Get
Return CType(CUShort(m_flags And SourceTypeFlags.TypeKindMask) >> CUInt(SourceTypeFlags.TypeKindShift), TypeKind)
Return CType((m_flags And SourceTypeFlags.TypeKindMask) >> CUInt(SourceTypeFlags.TypeKindShift), TypeKind)
End Get
End Property
......@@ -1439,7 +1433,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
Dim firstLocation = Me.DeclaringCompilation.FirstSourceLocation(Locations)
Debug.Assert(firstLocation.IsInSource)
Return containingSourceNamespace.GetDeclarationSpelling(DirectCast(firstLocation.SourceTree, VisualBasicSyntaxTree), firstLocation.SourceSpan.Start)
Return containingSourceNamespace.GetDeclarationSpelling(firstLocation.SourceTree, firstLocation.SourceSpan.Start)
End If
Return Nothing
......@@ -1957,7 +1951,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
Dim implParameter As ParameterSymbol = implMethodParams(index)
' Check type parameter name
If CaseInsensitiveComparison.Compare(declParameter.Name, implParameter.Name) <> 0 Then
If Not CaseInsensitiveComparison.Equals(declParameter.Name, implParameter.Name) Then
Debug.Assert(implParameter.Locations.Length = 1)
diagnostics.Add(ERRID.ERR_PartialMethodParamNamesMustMatch3,
......@@ -1978,7 +1972,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
Dim implParameter As TypeParameterSymbol = implTypeParams(index)
' Check parameter name
If CaseInsensitiveComparison.Compare(declParameter.Name, implParameter.Name) <> 0 Then
If Not CaseInsensitiveComparison.Equals(declParameter.Name, implParameter.Name) Then
Debug.Assert(implParameter.Locations.Length = 1)
diagnostics.Add(ERRID.ERR_PartialMethodTypeParamNameMismatch3,
......@@ -2694,7 +2688,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
Dim initializer = New FieldOrPropertyInitializer(propertySymbol, initializerOptRef)
If propertySymbol.IsShared Then
SourceNamedTypeSymbol.AddInitializer(staticInitializers, initializer)
AddInitializer(staticInitializers, initializer)
Else
' auto implemented properties inside of structures can only have an initialization value
' if they are shared.
......@@ -2704,7 +2698,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
Binder.ReportDiagnostic(diagBag, syntax.Identifier, ERRID.ERR_AutoPropertyInitializedInStructure)
End If
SourceNamedTypeSymbol.AddInitializer(instanceInitializers, initializer)
AddInitializer(instanceInitializers, initializer)
End If
End If
End Sub
......
......@@ -4,9 +4,11 @@ Imports System.Collections.Immutable
Imports System.Globalization
Imports System.Runtime.InteropServices
Imports System.Threading
Imports Microsoft.Cci
Imports Microsoft.CodeAnalysis.Text
Imports Microsoft.CodeAnalysis.VisualBasic.Symbols
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Imports CallingConvention = Microsoft.Cci.CallingConvention ' to resolve ambiguity with System.Runtime.InteropServices.CallingConvention
Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
''' <summary>
......@@ -277,20 +279,20 @@ lReportErrorOnTwoTokens:
Return New SourceDeclareMethodSymbol(container, name, flags, binder, syntax, importData)
End Function
Private Shared Function GetPInvokeAttributes(syntax As DeclareStatementSyntax) As Cci.PInvokeAttributes
Dim result As Cci.PInvokeAttributes
Private Shared Function GetPInvokeAttributes(syntax As DeclareStatementSyntax) As PInvokeAttributes
Dim result As PInvokeAttributes
Select Case syntax.CharsetKeyword.VisualBasicKind
Case SyntaxKind.None, SyntaxKind.AnsiKeyword
result = Cci.PInvokeAttributes.CharSetAnsi Or Cci.PInvokeAttributes.NoMangle
result = PInvokeAttributes.CharSetAnsi Or PInvokeAttributes.NoMangle
Case SyntaxKind.UnicodeKeyword
result = Cci.PInvokeAttributes.CharSetUnicode Or Cci.PInvokeAttributes.NoMangle
result = PInvokeAttributes.CharSetUnicode Or PInvokeAttributes.NoMangle
Case SyntaxKind.AutoKeyword
result = Cci.PInvokeAttributes.CharSetAuto
result = PInvokeAttributes.CharSetAuto
End Select
Return result Or Cci.PInvokeAttributes.CallConvWinapi Or Cci.PInvokeAttributes.SupportsLastError
Return result Or PInvokeAttributes.CallConvWinapi Or PInvokeAttributes.SupportsLastError
End Function
Friend Shared Function CreateOperator(
......@@ -729,10 +731,10 @@ lReportErrorOnTwoTokens:
End Property
Friend NotOverridable Overrides ReadOnly Property CallingConvention As Microsoft.Cci.CallingConvention
Friend NotOverridable Overrides ReadOnly Property CallingConvention As CallingConvention
Get
Return If(IsShared, Microsoft.Cci.CallingConvention.Default, Microsoft.Cci.CallingConvention.HasThis) Or
If(IsGenericMethod, Microsoft.Cci.CallingConvention.Generic, Microsoft.Cci.CallingConvention.Default)
Return If(IsShared, CallingConvention.Default, CallingConvention.HasThis) Or
If(IsGenericMethod, CallingConvention.Generic, CallingConvention.Default)
End Get
End Property
......@@ -843,8 +845,8 @@ lReportErrorOnTwoTokens:
Dim location As location = Me.NonMergedLocation
ImmutableInterlocked.InterlockedCompareExchange(Me.m_lazyLocations,
If(location Is Nothing,
ImmutableArray(Of location).Empty,
ImmutableArray.Create(Of location)(location)),
ImmutableArray(Of Location).Empty,
ImmutableArray.Create(location)),
Nothing)
End If
Return m_lazyLocations
......@@ -1167,11 +1169,11 @@ lReportErrorOnTwoTokens:
If methodSyntax IsNot Nothing AndAlso methodSyntax.ImplementsClause IsNot Nothing AndAlso containingSourceType IsNot Nothing Then
Dim binder As binder = BinderBuilder.CreateBinderForType(containingSourceType.ContainingSourceModule, syntaxTree, containingSourceType)
Dim implementingSyntax = FindImplementingSyntax(Of MethodSymbol)(methodSyntax.ImplementsClause,
Me,
implementedMethod,
containingSourceType,
binder)
Dim implementingSyntax = FindImplementingSyntax(methodSyntax.ImplementsClause,
Me,
implementedMethod,
containingSourceType,
binder)
Return implementingSyntax.GetLocation()
End If
......@@ -1201,7 +1203,7 @@ lReportErrorOnTwoTokens:
Return DirectCast(boundStatement, BoundBlock)
End If
Return New BoundBlock(methodBlock, methodBlock.Statements, ImmutableArray(Of LocalSymbol).Empty, ImmutableArray.Create(Of BoundStatement)(boundStatement))
Return New BoundBlock(methodBlock, methodBlock.Statements, ImmutableArray(Of LocalSymbol).Empty, ImmutableArray.Create(boundStatement))
End Function
#End Region
......@@ -1595,11 +1597,11 @@ lReportErrorOnTwoTokens:
' This might be different from ContainingType.DefaultMarshallingCharSet. If the charset is not specified on module
' ContainingType.DefaultMarshallingCharSet would be Ansi (the class is emitted with "Ansi" charset metadata flag)
' while the charset in P/Invoke metadata should be "None".
Dim charSet As CharSet = If(Me.EffectiveDefaultMarshallingCharSet, Cci.Constants.CharSet_None)
Dim charSet As CharSet = If(Me.EffectiveDefaultMarshallingCharSet, Microsoft.Cci.Constants.CharSet_None)
Dim importName As String = Nothing
Dim preserveSig As Boolean = True
Dim callingConvention As CallingConvention = CallingConvention.Winapi
Dim callingConvention As System.Runtime.InteropServices.CallingConvention = System.Runtime.InteropServices.CallingConvention.Winapi
Dim setLastError As Boolean = False
Dim exactSpelling As Boolean = False
Dim bestFitMapping As Boolean? = Nothing
......@@ -1628,7 +1630,7 @@ lReportErrorOnTwoTokens:
preserveSig = namedArg.Value.DecodeValue(Of Boolean)(SpecialType.System_Boolean)
Case "CallingConvention"
callingConvention = namedArg.Value.DecodeValue(Of CallingConvention)(SpecialType.System_Enum)
callingConvention = namedArg.Value.DecodeValue(Of System.Runtime.InteropServices.CallingConvention)(SpecialType.System_Enum)
Case "BestFitMapping"
bestFitMapping = namedArg.Value.DecodeValue(Of Boolean)(SpecialType.System_Boolean)
......@@ -1862,7 +1864,7 @@ lReportErrorOnTwoTokens:
End Get
End Property
Friend NotOverridable Overrides Function GetSecurityInformation() As IEnumerable(Of Cci.SecurityAttribute)
Friend NotOverridable Overrides Function GetSecurityInformation() As IEnumerable(Of SecurityAttribute)
Dim attributesBag As CustomAttributesBag(Of VisualBasicAttributeData) = Me.GetAttributesBag()
Dim wellKnownAttributeData = DirectCast(attributesBag.DecodedWellKnownAttributeData, MethodWellKnownAttributeData)
If wellKnownAttributeData IsNot Nothing Then
......@@ -1872,7 +1874,7 @@ lReportErrorOnTwoTokens:
End If
End If
Return SpecializedCollections.EmptyEnumerable(Of Microsoft.Cci.SecurityAttribute)()
Return SpecializedCollections.EmptyEnumerable(Of SecurityAttribute)()
End Function
Friend Overrides ReadOnly Property HasRuntimeSpecialName As Boolean
......
' Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System.Collections.Concurrent
Imports System.Collections.Generic
Imports System.Collections.Immutable
Imports System.Globalization
Imports System.Runtime.InteropServices
Imports System.Threading
Imports Microsoft.CodeAnalysis.Text
Imports Microsoft.CodeAnalysis.VisualBasic.Symbols
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Imports TypeKind = Microsoft.CodeAnalysis.TypeKind
Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
......@@ -29,9 +23,9 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
' Attribute arguments are comma-separated lists.
Dim separatorComma = {","c}
Dim separatorDot = {"."c}
Dim baseTypeNames() As String = If(attributeData.GetConstructorArgument(Of String)(0, Microsoft.CodeAnalysis.SpecialType.System_String), "").Split(separatorComma, StringSplitOptions.None)
Dim createMethods() As String = If(attributeData.GetConstructorArgument(Of String)(1, Microsoft.CodeAnalysis.SpecialType.System_String), "").Split(separatorComma, StringSplitOptions.None)
Dim disposeMethods() As String = If(attributeData.GetConstructorArgument(Of String)(2, Microsoft.CodeAnalysis.SpecialType.System_String), "").Split(separatorComma, StringSplitOptions.None)
Dim baseTypeNames() As String = If(attributeData.GetConstructorArgument(Of String)(0, SpecialType.System_String), "").Split(separatorComma, StringSplitOptions.None)
Dim createMethods() As String = If(attributeData.GetConstructorArgument(Of String)(1, SpecialType.System_String), "").Split(separatorComma, StringSplitOptions.None)
Dim disposeMethods() As String = If(attributeData.GetConstructorArgument(Of String)(2, SpecialType.System_String), "").Split(separatorComma, StringSplitOptions.None)
' DefaltInstanceAliases are respected only for attrubutes applied in MyTemplate.
Dim defaultInstances() As String
......@@ -143,7 +137,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
If (quickChecker.CheckAttribute(attr) And QuickAttributes.MyGroupCollection) <> 0 Then
' This attribute syntax might be an application of MyGroupCollectionAttribute.
' Let's bind it.
Dim attributeType As NamedTypeSymbol = VisualBasic.Binder.BindAttributeType(binder, attr, Me, throwAwayDiagnostics)
Dim attributeType As NamedTypeSymbol = Binder.BindAttributeType(binder, attr, Me, throwAwayDiagnostics)
If Not attributeType.IsErrorType() Then
If VisualBasicAttributeData.IsTargetEarlyAttribute(attributeType, attr, AttributeDescription.MyGroupCollectionAttribute) Then
' Calling GetAttribute can still get us into cycle if MyGroupCollectionAttribute is applied to itself.
......
......@@ -2,7 +2,6 @@
Imports System.Collections.Immutable
Imports System.Threading
Imports Microsoft.CodeAnalysis.Text
Imports Microsoft.CodeAnalysis.VisualBasic.Symbols
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
......@@ -51,7 +50,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
If(propertySymbol.IsAutoProperty, StringConstants.AutoPropertyValueParameterName, StringConstants.ValueParameterName))
If propertySymbol.ParameterCount = 0 Then
Return ImmutableArray.Create(Of ParameterSymbol)(valueParameter)
Return ImmutableArray.Create(valueParameter)
End If
Dim parameters = ArrayBuilder(Of ParameterSymbol).GetInstance(propertySymbol.ParameterCount + 1)
......@@ -411,7 +410,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
' duplicates if the setter parameter is named 'Value' since we'll report property
' cannot contain parameter named 'Value' if there is a duplicate in that case.
Dim param = parameters(nPropertyParameters)
If IdentifierComparison.Compare(param.Name, StringConstants.ValueParameterName) <> 0 Then
If Not IdentifierComparison.Equals(param.Name, StringConstants.ValueParameterName) Then
Dim paramSyntax = parameterListSyntax(0)
binder.CheckParameterNameNotDuplicate(parameters, nPropertyParameters, paramSyntax, param, diagnostics)
End If
......
......@@ -3,10 +3,8 @@
Imports System.Collections.Immutable
Imports System.Runtime.InteropServices
Imports System.Threading
Imports Microsoft.CodeAnalysis.Text
Imports Microsoft.CodeAnalysis.VisualBasic.Symbols
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Imports TypeKind = Microsoft.CodeAnalysis.TypeKind
Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
''' <summary>
......@@ -80,14 +78,14 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
members = ImmutableArray.Create(Of Symbol)(ctor, beginInvoke, endInvoke, invoke)
End If
sourceModule.AtomicStoreArrayAndDiagnostics(Of Symbol)(m_lazyMembers, members, diagBag, CompilationStage.Declare)
sourceModule.AtomicStoreArrayAndDiagnostics(m_lazyMembers, members, diagBag, CompilationStage.Declare)
diagBag.Free()
Return m_lazyMembers
End Function
Public Overloads Overrides Function GetMembers(name As String) As ImmutableArray(Of Symbol)
Return (From m In GetMembers() Where IdentifierComparison.Compare(m.Name, name) = 0).AsImmutable
Return (From m In GetMembers() Where IdentifierComparison.Equals(m.Name, name)).AsImmutable
End Function
Friend Overrides Function GetFieldsToEmit() As IEnumerable(Of FieldSymbol)
......
......@@ -12,7 +12,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
''' <summary>
''' Map containing information about all conditional symbol definitions in the source file corresponding to a parsed syntax tree.
''' </summary>
''' <remarks></remarks>
Private Class ConditionalSymbolsMap
''' <summary>
......@@ -146,7 +145,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
' Get symbol name at preprocessor definition, i.e. #Const directive.
' NOTE: symbolName and conditionalSymbolName might have different case, we want the definition name.
Dim symbolName = m_conditionalsMap.Keys.First(Function(key) IdentifierComparison.Compare(key, conditionalSymbolName) = 0)
Dim symbolName = m_conditionalsMap.Keys.First(Function(key) IdentifierComparison.Equals(key, conditionalSymbolName))
Return New VisualBasicPreprocessingSymbolInfo(New PreprocessingSymbol(name:=symbolName), constantValueOpt:=constValue.ValueAsObject, isDefined:=True)
End Function
......
' Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports Microsoft.CodeAnalysis
Imports Microsoft.CodeAnalysis.CodeGeneration
Imports Microsoft.CodeAnalysis.Text
Imports Microsoft.CodeAnalysis.VisualBasic
Imports Microsoft.CodeAnalysis.VisualBasic.Extensions
Imports Microsoft.CodeAnalysis.VisualBasic.Symbols
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Namespace Microsoft.CodeAnalysis.VisualBasic.CodeGeneration
......
......@@ -815,7 +815,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Extensions
End If
Dim newModifiedIdentifier = SyntaxFactory.ModifiedIdentifier(modifiedIdentifier.Identifier) ' LeadingTrivia is copied here
replacementNode = SyntaxFactory.VariableDeclarator(SyntaxFactory.SingletonSeparatedList(Of ModifiedIdentifierSyntax)(newModifiedIdentifier.WithTrailingTrivia(variableDeclarator.AsClause.GetTrailingTrivia())),
replacementNode = SyntaxFactory.VariableDeclarator(SyntaxFactory.SingletonSeparatedList(newModifiedIdentifier.WithTrailingTrivia(variableDeclarator.AsClause.GetTrailingTrivia())),
asClause:=Nothing,
initializer:=variableDeclarator.Initializer) 'TrailingTrivia is copied here
issueSpan = variableDeclarator.Span
......@@ -1112,7 +1112,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Extensions
End If
' See if we can simplify a member access expression of the form E.M or E.M() to M or M()
Dim speculationAnalyzer = New SpeculationAnalyzer(memberAccess, reducedNode, DirectCast(semanticModel, SemanticModel), cancellationToken)
Dim speculationAnalyzer = New SpeculationAnalyzer(memberAccess, reducedNode, semanticModel, cancellationToken)
If Not speculationAnalyzer.SymbolsForOriginalAndReplacedNodesAreCompatible() OrElse
speculationAnalyzer.ReplacementChangesSemantics() Then
Return False
......@@ -1151,7 +1151,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Extensions
' nothing we can do here.
Dim symbol = SimplificationHelpers.GetOriginalSymbolInfo(semanticModel, name)
If SimplificationHelpers.IsValidSymbolInfo(symbol) Then
If symbol.Kind = SymbolKind.Method AndAlso DirectCast(symbol, IMethodSymbol).IsConstructor() Then
If symbol.Kind = SymbolKind.Method AndAlso symbol.IsConstructor() Then
symbol = symbol.ContainingType
End If
......@@ -1406,8 +1406,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Extensions
''' must be parented by an namespace declaration and the node itself must be equal to the declaration's Name
''' property.
''' </summary>
''' <param name="node"></param>
''' <returns></returns>
Private Function IsPartOfNamespaceDeclarationName(node As SyntaxNode) As Boolean
Dim nextNode As SyntaxNode = node
......@@ -1711,7 +1709,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Extensions
End Function
''' <summary>
''' Returns the predefined keyword kind for a given specialtype.
''' Returns the predefined keyword kind for a given special type.
''' </summary>
''' <param name="type">The specialtype of this type.</param>
''' <returns>The keyword kind for a given special type, or SyntaxKind.None if the type name is not a predefined type.</returns>
......@@ -1786,8 +1784,8 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Extensions
If attribute.Target Is Nothing Then
Dim identifierValue = SyntaxFacts.MakeHalfWidthIdentifier(identifier.Identifier.ValueText)
If CaseInsensitiveComparison.Compare(identifierValue, "Assembly") = 0 OrElse
CaseInsensitiveComparison.Compare(identifierValue, "Module") = 0 Then
If CaseInsensitiveComparison.Equals(identifierValue, "Assembly") OrElse
CaseInsensitiveComparison.Equals(identifierValue, "Module") Then
Return True
End If
End If
......
......@@ -9,12 +9,10 @@ Imports Microsoft.CodeAnalysis.LanguageServices
Imports Microsoft.CodeAnalysis.Rename
Imports Microsoft.CodeAnalysis.Rename.ConflictEngine
Imports Microsoft.CodeAnalysis.Simplification
Imports Microsoft.CodeAnalysis.Shared.Extensions
Imports Microsoft.CodeAnalysis.Text
Imports Microsoft.CodeAnalysis.VisualBasic.Symbols
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Imports Microsoft.CodeAnalysis.VisualBasic.Utilities
Imports Microsoft.CodeAnalysis.Options
Namespace Microsoft.CodeAnalysis.VisualBasic.Rename
......@@ -225,7 +223,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Rename
Private Function IsPossibleNameConflict(possibleNameConflicts As ICollection(Of String), candidate As String) As Boolean
For Each possibleNameConflict In possibleNameConflicts
If CaseInsensitiveComparison.Compare(possibleNameConflict, candidate) = 0 Then
If CaseInsensitiveComparison.Equals(possibleNameConflict, candidate) Then
Return True
End If
Next
......@@ -235,7 +233,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Rename
Private Function UpdateAliasAnnotation(newToken As SyntaxToken) As SyntaxToken
If Me.aliasSymbol IsNot Nothing AndAlso Not Me.AnnotateForComplexification AndAlso newToken.HasAnnotations(AliasAnnotation.Kind) Then
newToken = CType(RenameUtilities.UpdateAliasAnnotation(newToken, Me.aliasSymbol, Me.replacementText), SyntaxToken)
newToken = RenameUtilities.UpdateAliasAnnotation(newToken, Me.aliasSymbol, Me.replacementText)
End If
Return newToken
......@@ -380,10 +378,10 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Rename
End If
Dim isRenameLocation = IsInRenameLocation(oldToken)
Dim isOldText = CaseInsensitiveComparison.Compare(oldToken.ValueText, originalText) = 0
Dim isOldText = CaseInsensitiveComparison.Equals(oldToken.ValueText, originalText)
Dim tokenNeedsConflictCheck = isRenameLocation OrElse
isOldText OrElse
CaseInsensitiveComparison.Compare(oldToken.ValueText, replacementText) = 0 OrElse
CaseInsensitiveComparison.Equals(oldToken.ValueText, replacementText) OrElse
IsPossibleNameConflict(possibleNameConflicts, oldToken.ValueText)
If tokenNeedsConflictCheck Then
......@@ -582,7 +580,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Rename
If Me.isRenamingInComments Then
If newToken.VisualBasicKind = SyntaxKind.XmlTextLiteralToken Then
newToken = RenameInStringLiteral(oldToken, newToken, AddressOf SyntaxFactory.XmlTextLiteralToken)
ElseIf newToken.VisualBasicKind = SyntaxKind.XmlNameToken AndAlso CaseInsensitiveComparison.Compare(oldToken.ValueText, originalText) = 0 Then
ElseIf newToken.VisualBasicKind = SyntaxKind.XmlNameToken AndAlso CaseInsensitiveComparison.Equals(oldToken.ValueText, originalText) Then
Dim newIdentifierToken = SyntaxFactory.XmlNameToken(newToken.LeadingTrivia, replacementText, SyntaxFacts.GetKeywordKind(replacementText), newToken.TrailingTrivia)
newToken = newToken.CopyAnnotationsTo(Me.renameAnnotations.WithAdditionalAnnotations(newIdentifierToken, New RenameTokenSimplificationAnnotation() With {.OriginalTextSpan = oldToken.Span}))
AddModifiedSpan(oldToken.Span, newToken.Span)
......@@ -652,7 +650,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Rename
' in VB parameters of properties are not allowed to be the same as the containing property
If renamedSymbol.Kind = SymbolKind.Parameter AndAlso
renamedSymbol.ContainingSymbol.Kind = SymbolKind.Property AndAlso
CaseInsensitiveComparison.Compare(renamedSymbol.ContainingSymbol.Name, renamedSymbol.Name) = 0 Then
CaseInsensitiveComparison.Equals(renamedSymbol.ContainingSymbol.Name, renamedSymbol.Name) Then
Dim propertySymbol = renamedSymbol.ContainingSymbol
......@@ -691,7 +689,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Rename
Dim currentTypeParameter = token.Parent
For Each typeParameter In DirectCast(currentTypeParameter.Parent, TypeParameterListSyntax).Parameters
If typeParameter IsNot currentTypeParameter AndAlso CaseInsensitiveComparison.Compare(token.ValueText, typeParameter.Identifier.ValueText) = 0 Then
If typeParameter IsNot currentTypeParameter AndAlso CaseInsensitiveComparison.Equals(token.ValueText, typeParameter.Identifier.ValueText) Then
conflicts.Add(reverseMappedLocations(typeParameter.Identifier.GetLocation()))
End If
Next
......@@ -700,7 +698,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Rename
' if the renamed symbol is a type member, it's name should not coflict with a type parameter
If renamedSymbol.ContainingType IsNot Nothing AndAlso renamedSymbol.ContainingType.GetMembers(renamedSymbol.Name).Contains(renamedSymbol) Then
For Each typeParameter In renamedSymbol.ContainingType.TypeParameters
If CaseInsensitiveComparison.Compare(typeParameter.Name, renamedSymbol.Name) = 0 Then
If CaseInsensitiveComparison.Equals(typeParameter.Name, renamedSymbol.Name) Then
Dim typeParameterToken = typeParameter.Locations.Single().FindToken(cancellationToken)
conflicts.Add(reverseMappedLocations(typeParameterToken.GetLocation()))
End If
......@@ -714,21 +712,21 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Rename
' Handle renaming of symbols used for foreach
Dim implicitReferencesMightConflict = renameSymbol.Kind = SymbolKind.Property AndAlso
CaseInsensitiveComparison.Compare(renameSymbol.Name, "Current") = 0
CaseInsensitiveComparison.Equals(renameSymbol.Name, "Current")
implicitReferencesMightConflict = implicitReferencesMightConflict OrElse
(renameSymbol.Kind = SymbolKind.Method AndAlso
(CaseInsensitiveComparison.Compare(renameSymbol.Name, "MoveNext") = 0 OrElse
CaseInsensitiveComparison.Compare(renameSymbol.Name, "GetEnumerator") = 0))
(CaseInsensitiveComparison.Equals(renameSymbol.Name, "MoveNext") OrElse
CaseInsensitiveComparison.Equals(renameSymbol.Name, "GetEnumerator")))
' TODO: handle Dispose for using statement and Add methods for collection initializers.
If implicitReferencesMightConflict Then
If CaseInsensitiveComparison.Compare(renamedSymbol.Name, renameSymbol.Name) <> 0 Then
If Not CaseInsensitiveComparison.Equals(renamedSymbol.Name, renameSymbol.Name) Then
For Each implicitReferenceLocation In implicitReferenceLocations
Dim token = implicitReferenceLocation.Location.SourceTree.GetTouchingToken(implicitReferenceLocation.Location.SourceSpan.Start, cancellationToken, False)
If token.VisualBasicKind = SyntaxKind.ForKeyword AndAlso token.Parent.IsKind(SyntaxKind.ForEachStatement) Then
Return SpecializedCollections.SingletonEnumerable(Of Location)(DirectCast(token.Parent, ForEachStatementSyntax).Expression.GetLocation())
Return SpecializedCollections.SingletonEnumerable(DirectCast(token.Parent, ForEachStatementSyntax).Expression.GetLocation())
End If
Next
End If
......@@ -745,7 +743,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Rename
''' statement of this lambda.
''' </summary>
''' <param name="token">The token to get the complexification target for.</param>
''' <returns></returns>
Public Function GetExpansionTargetForLocation(token As SyntaxToken) As SyntaxNode Implements IRenameRewriterLanguageService.GetExpansionTargetForLocation
Return GetExpansionTarget(token)
End Function
......@@ -816,9 +813,9 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Rename
cancellationToken As CancellationToken) As IEnumerable(Of Location) Implements IRenameRewriterLanguageService.ComputePossibleImplicitUsageConflicts
' TODO: support other implicitly used methods like dispose
If CaseInsensitiveComparison.Compare(renamedSymbol.Name, "MoveNext") = 0 OrElse
CaseInsensitiveComparison.Compare(renamedSymbol.Name, "GetEnumerator") = 0 OrElse
CaseInsensitiveComparison.Compare(renamedSymbol.Name, "Current") = 0 Then
If CaseInsensitiveComparison.Equals(renamedSymbol.Name, "MoveNext") OrElse
CaseInsensitiveComparison.Equals(renamedSymbol.Name, "GetEnumerator") OrElse
CaseInsensitiveComparison.Equals(renamedSymbol.Name, "Current") Then
If TypeOf renamedSymbol Is IMethodSymbol Then
......@@ -854,11 +851,11 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Rename
If symbol.Kind = SymbolKind.Method Then
Dim method = DirectCast(symbol, IMethodSymbol)
If CaseInsensitiveComparison.Compare(symbol.Name, "MoveNext") = 0 Then
If CaseInsensitiveComparison.Equals(symbol.Name, "MoveNext") Then
If Not method.ReturnsVoid AndAlso Not method.Parameters.Any() AndAlso method.ReturnType.SpecialType = SpecialType.System_Boolean Then
Return SpecializedCollections.SingletonEnumerable(originalDeclarationLocation)
End If
ElseIf CaseInsensitiveComparison.Compare(symbol.Name, "GetEnumerator") = 0 Then
ElseIf CaseInsensitiveComparison.Equals(symbol.Name, "GetEnumerator") Then
' we are a bit pessimistic here.
' To be sure we would need to check if the returned type Is having a MoveNext And Current as required by foreach
If Not method.ReturnsVoid AndAlso
......@@ -867,7 +864,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Rename
End If
End If
ElseIf CaseInsensitiveComparison.Compare(symbol.Name, "Current") = 0 Then
ElseIf CaseInsensitiveComparison.Equals(symbol.Name, "Current") Then
Dim [property] = DirectCast(symbol, IPropertySymbol)
If Not [property].Parameters.Any() AndAlso Not [property].IsWriteOnly Then
......@@ -888,7 +885,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Rename
Const AttributeSuffixLength As Integer = 9
Debug.Assert(AttributeSuffixLength = AttributeSuffix.Length, "Assert (AttributeSuffixLength = AttributeSuffix.Length) failed.")
If replacementText.Length > AttributeSuffixLength AndAlso CaseInsensitiveComparison.Compare(halfWidthReplacementText.Substring(halfWidthReplacementText.Length - AttributeSuffixLength), AttributeSuffix) = 0 Then
If replacementText.Length > AttributeSuffixLength AndAlso CaseInsensitiveComparison.Equals(halfWidthReplacementText.Substring(halfWidthReplacementText.Length - AttributeSuffixLength), AttributeSuffix) Then
Dim conflict = replacementText.Substring(0, replacementText.Length - AttributeSuffixLength)
If Not possibleNameConflicts.Contains(conflict) Then
possibleNameConflicts.Add(conflict)
......@@ -915,7 +912,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Rename
End If
End If
If CaseInsensitiveComparison.Compare(valueText, replacementText) <> 0 Then
If Not CaseInsensitiveComparison.Equals(valueText, replacementText) Then
possibleNameConflicts.Add(valueText)
End If
End Sub
......@@ -929,7 +926,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Rename
''' </summary>
''' <param name="node"></param>
''' <param name="originalSemanticModel"></param>
''' <returns></returns>
Public Shared Function GetSemanticModelForNode(node As SyntaxNode, originalSemanticModel As SemanticModel) As SemanticModel
If node.SyntaxTree Is originalSemanticModel.SyntaxTree Then
' This is possible if the previous rename phase didn't rewrite any nodes in this tree.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册