code
stringlengths 2
1.05M
| repo_name
stringlengths 5
101
| path
stringlengths 4
991
| language
stringclasses 3
values | license
stringclasses 5
values | size
int64 2
1.05M
|
|---|---|---|---|---|---|
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System.Collections.Immutable
Imports System.Diagnostics
Imports System.Runtime.InteropServices
Imports Microsoft.CodeAnalysis.Text
Imports Microsoft.CodeAnalysis.VisualBasic.Symbols
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Imports TypeKind = Microsoft.CodeAnalysis.TypeKind
Namespace Microsoft.CodeAnalysis.VisualBasic
Partial Friend NotInheritable Class LocalRewriter
''' <summary>
''' Rewrites a for each statement.
''' </summary>
''' <param name="node">The node.</param><returns></returns>
Public Overrides Function VisitForEachStatement(node As BoundForEachStatement) As BoundNode
Dim locals = ArrayBuilder(Of LocalSymbol).GetInstance()
Dim statements = ArrayBuilder(Of BoundStatement).GetInstance()
' there can be a conversion on top of an one dimensional array to cause the ConvertedType of the semantic model
' to show the IEnumerable type.
' we need to ignore this conversion for the rewriting.
' Strings and multidimensional arrays match the pattern and will not have this artificial conversion.
Dim collectionType As TypeSymbol
Dim originalCollection As BoundExpression
If node.Collection.Kind = BoundKind.Conversion Then
Dim conversion = DirectCast(node.Collection, BoundConversion)
Dim operand = conversion.Operand
If Not conversion.ExplicitCastInCode AndAlso Not operand.IsNothingLiteral AndAlso
(operand.Type.IsArrayType OrElse operand.Type.IsStringType) Then
originalCollection = operand
Else
originalCollection = node.Collection
End If
Else
originalCollection = node.Collection
End If
collectionType = originalCollection.Type
Dim replacedCollection As BoundExpression = originalCollection
' LIFTING OF FOR-EACH CONTROL VARIABLES
'
' For Each <ControlVariable> In <CollectionExpression>
' <Body>
' Next
'
' VB has two forms of "For Each". The first is where the <ControlVariable>
' binds to an already-existing variable. The second is where it introduces a new
' control variable.
'
' Execution of For Each (the form that introduces a new control variable) is as follows:
' [1] Allocate a new temporary local symbol for the control variable
' [2] Evaluate <CollectionExpression>, where any reference to "<ControlVariable>" binds to the location in [1]
' [3] Allocate a new temporary and initialize it to the result of calling GetEnumerator() on [2]
' [4] We will call MoveNext/Current to execute the <Body> a number of times...
' For each iteration of the body,
' [5] Allocate a new storage location for the control variable
' [6] Initialize it to [3].Current
' [7] Execute <Body>, where any reference to "<ControlVariable>" binds to the location in [5] for this iteration
'
' Of course, none of this allocation is observable unless there are lambdas.
' If there are no lambdas then we can make do with only a single allocation for the whole thing.
' But there may be lambdas in either <EnumeratorExpression> or <Body>...
'
'
' IMPLEMENTATION:
'
' The LambdaRewriter code will, if there were a lambda inside <Body> that captures "<ControlVariable>",
' lift "<ControlVariable>" into a closure which is allocated once for each iteration of the body and initialized with the
' (This allocation is initialized by copying the previously allocated closure if there was one).
'
' However, if <EnumeratorExpression> referred to "<ControlVariable>", then we'll need to allocate another one for it.
' This rewrite is how we do it:
' Dim tmp ' implicitly initialized with default(CollectionVariableType)
' For Each <ControlVariable> In <CollectionExpression> {tmp/<ControlVariable>}
' <Body>
' Next
'
' if the for each loop declares a variable we need to check if the collection expression references
' it. If it does, we allocate a new temporary variable of the control variable's type. All references to
' the control variable in the collection expression will be replaced with a reference to the temporary local.
' This way capturing this local will be correct.
' The variable will not be initialized, because a declared control variable is also not initialized when
' executing the collection expression.
If node.DeclaredOrInferredLocalOpt IsNot Nothing Then
Dim tempLocal = New SynthesizedLocal(Me._currentMethodOrLambda, node.ControlVariable.Type, SynthesizedLocalKind.LoweringTemp)
Dim tempForControlVariable = New BoundLocal(node.Syntax, tempLocal, node.ControlVariable.Type)
Dim replacedControlVariable As Boolean = False
replacedCollection = DirectCast(LocalVariableSubstitutor.Replace(originalCollection,
node.DeclaredOrInferredLocalOpt,
tempLocal,
replacedControlVariable), BoundExpression)
' if a reference to the control variable was found we add the temporary local and we need to make sure
' that this variable does not get captured by using a copy constructor.
' Example:
' for i = 0 to 3 do
' for each x in (function() {x+1})()
' next x
' next i
'
' Should always capture x in the collection expression uninitialized.
If replacedControlVariable Then
locals.Add(tempLocal)
If Me._symbolsCapturedWithoutCopyCtor Is Nothing Then
Me._symbolsCapturedWithoutCopyCtor = New HashSet(Of Symbol)()
End If
Me._symbolsCapturedWithoutCopyCtor.Add(tempLocal)
End If
End If
' Either replace the placeholder with the original collection or the one that the referenced replaced.
If node.EnumeratorInfo.CollectionPlaceholder IsNot Nothing Then
AddPlaceholderReplacement(node.EnumeratorInfo.CollectionPlaceholder,
VisitExpressionNode(replacedCollection).MakeRValue)
End If
If collectionType.IsArrayType AndAlso DirectCast(collectionType, ArrayTypeSymbol).Rank = 1 Then
' Optimized rewrite for one dimensional arrays (iterate over index is faster than IEnumerable)
RewriteForEachArrayOrString(node, statements, locals, isArray:=True, collectionExpression:=replacedCollection)
ElseIf collectionType.IsStringType Then
' Optimized rewrite for strings (iterate over index is faster than IEnumerable)
RewriteForEachArrayOrString(node, statements, locals, isArray:=False, collectionExpression:=replacedCollection)
ElseIf Not node.Collection.HasErrors Then
RewriteForEachIEnumerable(node, statements, locals)
End If
If node.EnumeratorInfo.CollectionPlaceholder IsNot Nothing Then
RemovePlaceholderReplacement(node.EnumeratorInfo.CollectionPlaceholder)
End If
Return New BoundBlock(node.Syntax,
Nothing,
locals.ToImmutableAndFree(),
statements.ToImmutableAndFree)
End Function
''' <summary>
''' Rewrites a for each over an one dimensional array or a string.
'''
''' As an optimization, if c is an array type of rank 1, the form becomes:
'''
''' Dim collectionCopy As C = c
''' Dim collectionIndex As Integer = 0
''' Do While collectionIndex < len(collectionCopy) ' len(a) represents the LDLEN opcode
''' dim controlVariable = DirectCast(collectionCopy(collectionIndex), typeOfControlVariable)
''' <loop body>
''' continue:
''' collectionIndex += 1
''' postIncrement:
''' Loop
'''
''' An iteration over a string becomes
''' Dim collectionCopy As String = c
''' Dim collectionIndex As Integer = 0
''' Dim limit as Integer = s.Length
''' Do While collectionIndex < limit
''' dim controlVariable = DirectCast(collectionCopy.Chars(collectionIndex), typeOfControlVariable)
''' <loop body>
''' continue:
''' collectionIndex += 1
''' postIncrement:
''' Loop
''' </summary>
''' <param name="node">The node.</param>
''' <param name="statements">The statements.</param>
''' <param name="locals">The locals.</param>
''' <param name="isArray">if set to <c>true</c> [is array].</param>
Private Sub RewriteForEachArrayOrString(
node As BoundForEachStatement,
statements As ArrayBuilder(Of BoundStatement),
locals As ArrayBuilder(Of LocalSymbol),
isArray As Boolean,
collectionExpression As BoundExpression
)
Dim syntaxNode = DirectCast(node.Syntax, ForOrForEachBlockSyntax)
Dim generateUnstructuredExceptionHandlingResumeCode As Boolean = ShouldGenerateUnstructuredExceptionHandlingResumeCode(node)
Dim loopResumeTarget As ImmutableArray(Of BoundStatement) = Nothing
If generateUnstructuredExceptionHandlingResumeCode Then
loopResumeTarget = RegisterUnstructuredExceptionHandlingResumeTarget(syntaxNode, canThrow:=True)
End If
Dim controlVariableType = node.ControlVariable.Type
Dim enumeratorInfo = node.EnumeratorInfo
If collectionExpression.Kind = BoundKind.Conversion Then
Dim conversion = DirectCast(collectionExpression, BoundConversion)
If Not conversion.ExplicitCastInCode AndAlso conversion.Operand.Type.IsArrayType Then
collectionExpression = conversion.Operand
End If
End If
Dim collectionType = collectionExpression.Type
Debug.Assert(collectionExpression.Type.SpecialType = SpecialType.System_String OrElse
(collectionType.IsArrayType AndAlso DirectCast(collectionType, ArrayTypeSymbol).Rank = 1))
' Where do the bound expressions of the bound for each node get rewritten?
' The collection will be assigned to a local copy. This assignment is rewritten by using "CreateLocalAndAssignment"
' The current value will be assigned to the control variable once per iteration. This is done in this method
' The casts and conversions get rewritten in "RewriteWhileStatement"
'
' Loop initialization: collection copy + index & limit
'
' Dim collectionCopy As C = c
Dim boundCollectionLocal As BoundLocal = Nothing
Dim boundCollectionAssignment = CreateLocalAndAssignment(syntaxNode.ForOrForEachStatement,
collectionExpression.MakeRValue(),
boundCollectionLocal,
locals,
SynthesizedLocalKind.ForEachArray)
If Not loopResumeTarget.IsDefaultOrEmpty Then
boundCollectionAssignment = New BoundStatementList(boundCollectionAssignment.Syntax, loopResumeTarget.Add(boundCollectionAssignment))
End If
If GenerateDebugInfo Then
' first sequence point to highlight the for each statement
boundCollectionAssignment = New BoundSequencePoint(DirectCast(node.Syntax, ForOrForEachBlockSyntax).ForOrForEachStatement, boundCollectionAssignment)
End If
statements.Add(boundCollectionAssignment)
' Dim collectionIndex As Integer = 0
Dim boundIndex As BoundLocal = Nothing
Dim integerType = GetSpecialTypeWithUseSiteDiagnostics(SpecialType.System_Int32, syntaxNode)
Dim boundIndexInitialization = CreateLocalAndAssignment(syntaxNode.ForOrForEachStatement,
New BoundLiteral(syntaxNode,
ConstantValue.Default(SpecialType.System_Int32),
integerType),
boundIndex,
locals,
SynthesizedLocalKind.ForEachArrayIndex)
statements.Add(boundIndexInitialization)
' build either
' Array.Length(collectionCopy)
' or
' collectionCopy.Length
Dim boundLimit As BoundExpression = Nothing
If isArray Then
' in case of an array, the upper limit is Array.Length. This will be the ldlen opcode later on
boundLimit = New BoundArrayLength(syntaxNode, boundCollectionLocal, integerType)
Else
' for strings we use String.Length
Dim lengthPropertyGet = GetSpecialTypeMember(SpecialMember.System_String__Length)
boundLimit = New BoundCall(syntaxNode,
DirectCast(lengthPropertyGet, MethodSymbol),
Nothing,
boundCollectionLocal,
ImmutableArray(Of BoundExpression).Empty,
Nothing,
integerType)
End If
'
' new statements for the loop body (getting current value + index increment)
'
Dim boundCurrent As BoundExpression
Dim elementType As TypeSymbol
If isArray Then
elementType = DirectCast(collectionType, ArrayTypeSymbol).ElementType
boundCurrent = New BoundArrayAccess(syntaxNode,
boundCollectionLocal.MakeRValue(),
ImmutableArray.Create(Of BoundExpression)(boundIndex.MakeRValue()),
isLValue:=False,
type:=elementType)
Else
elementType = GetSpecialType(SpecialType.System_Char)
' controlVariable = StringCopy.Chars(arrayIndex)
' because the controlVariable can be any LValue, this might have side effects (e.g. ObjArray(SomeFunc()).field)
' we will evaluate the expression once per iteration, the side effects are intended.
Dim charsPropertyGet As MethodSymbol = Nothing
If TryGetSpecialMember(charsPropertyGet, SpecialMember.System_String__Chars, syntaxNode) Then
boundCurrent = New BoundCall(syntaxNode,
DirectCast(charsPropertyGet, MethodSymbol),
Nothing,
boundCollectionLocal,
ImmutableArray.Create(Of BoundExpression)(boundIndex.MakeRValue()),
constantValueOpt:=Nothing,
type:=elementType)
Else
boundCurrent = New BoundBadExpression(syntaxNode, LookupResultKind.NotReferencable, ImmutableArray(Of Symbol).Empty,
ImmutableArray.Create(Of BoundNode)(boundIndex.MakeRValue()), elementType, hasErrors:=True)
End If
End If
' now we know the bound node for the current value; add it to the replacement map to get inserted into the
' conversion from current to the type of the control variable
If enumeratorInfo.CurrentPlaceholder IsNot Nothing Then
AddPlaceholderReplacement(enumeratorInfo.CurrentPlaceholder, boundCurrent)
End If
' controlVariable = arrayCopy(arrayIndex)
' because the controlVariable can be any LValue, this might have side effects (e.g. ObjArray(SomeFunc()).field)
' we will evaluate the expression once per iteration, the side effects are intended.
Dim boundCurrentAssignment As BoundStatement = New BoundAssignmentOperator(syntaxNode,
node.ControlVariable,
enumeratorInfo.CurrentConversion,
suppressObjectClone:=False,
type:=node.ControlVariable.Type).ToStatement
boundCurrentAssignment.SetWasCompilerGenerated() ' used to not create sequence points
boundCurrentAssignment = DirectCast(Visit(boundCurrentAssignment), BoundStatement)
Dim boundIncrementAssignment = CreateIndexIncrement(syntaxNode, boundIndex)
'
' build loop statement
'
' now build while loop
Dim boundWhileStatement = CreateLoweredWhileStatements(syntaxNode,
node,
boundLimit,
boundIndex,
boundCurrentAssignment,
boundIncrementAssignment,
generateUnstructuredExceptionHandlingResumeCode)
statements.AddRange(DirectCast(boundWhileStatement, BoundStatementList).Statements)
If enumeratorInfo.CurrentPlaceholder IsNot Nothing Then
RemovePlaceholderReplacement(enumeratorInfo.CurrentPlaceholder)
End If
End Sub
''' <summary>
''' Creates a local and assigns it the given bound expression.
''' </summary>
''' <param name="syntaxNode">The syntax node.</param>
''' <param name="initExpression">The initialization expression.</param>
''' <param name="boundLocal">The bound local.</param>
''' <param name="locals">The locals.</param>
Private Function CreateLocalAndAssignment(
syntaxNode As StatementSyntax,
initExpression As BoundExpression,
<Out()> ByRef boundLocal As BoundLocal,
locals As ArrayBuilder(Of LocalSymbol),
kind As SynthesizedLocalKind
) As BoundStatement
' Dim collectionCopy As C = c
Dim expressionType = initExpression.Type
Debug.Assert(kind.IsLongLived())
Dim collectionCopy = New SynthesizedLocal(Me._currentMethodOrLambda, expressionType, kind, syntaxNode)
locals.Add(collectionCopy)
boundLocal = New BoundLocal(syntaxNode, collectionCopy, expressionType)
' if this ever fails, you found a test case to see how the suppressObjectClone flag should be set to match
' Dev10 behavior.
Debug.Assert(expressionType.SpecialType <> SpecialType.System_Object)
Dim boundCollectionAssignment = New BoundAssignmentOperator(syntaxNode,
boundLocal,
VisitAndGenerateObjectCloneIfNeeded(initExpression),
suppressObjectClone:=True,
type:=expressionType).ToStatement
boundCollectionAssignment.SetWasCompilerGenerated() ' used to not create sequence points
Return boundCollectionAssignment
End Function
''' <summary>
''' Creates the index increment statement.
''' </summary>
''' <param name="syntaxNode">The syntax node.</param>
''' <param name="boundIndex">The bound index expression (bound local).</param>
Private Function CreateIndexIncrement(
syntaxNode As VisualBasicSyntaxNode,
boundIndex As BoundLocal
) As BoundStatement
' collectionIndex += 1
Dim expressionType = boundIndex.Type
Dim boundAddition = New BoundBinaryOperator(syntaxNode,
BinaryOperatorKind.Add,
boundIndex.MakeRValue(),
New BoundLiteral(syntaxNode, ConstantValue.Create(1), expressionType),
checked:=True,
type:=expressionType)
' if this ever fails, you found a test case to see how the suppressObjectClone flag should be set to match
' Dev10 behavior.
Debug.Assert(expressionType.SpecialType <> SpecialType.System_Object)
Dim boundIncrementAssignment As BoundStatement = New BoundAssignmentOperator(syntaxNode,
boundIndex,
boundAddition,
suppressObjectClone:=False,
type:=expressionType).ToStatement.MakeCompilerGenerated
boundIncrementAssignment = DirectCast(Visit(boundIncrementAssignment), BoundStatement)
If GenerateDebugInfo Then
' create a hidden sequence point for the index increment to not stop on it while debugging
boundIncrementAssignment = New BoundSequencePoint(Nothing, boundIncrementAssignment)
End If
Return boundIncrementAssignment
End Function
''' <summary>
''' Creates the while statement for the for each rewrite
''' </summary>
''' <param name="syntaxNode">The syntax node.</param>
''' <param name="limit">The limit to check the index against.</param>
''' <param name="index">The index.</param>
''' <param name="currentAssignment">The assignment statement of the current value.</param>
''' <param name="incrementAssignment">The increment statement.</param>
''' <param name="node">The bound for each node.</param>
''' <returns>The lowered statement list for the while statement.</returns>
Private Function CreateLoweredWhileStatements(
syntaxNode As VisualBasicSyntaxNode,
node As BoundForEachStatement,
limit As BoundExpression,
index As BoundLocal,
currentAssignment As BoundStatement,
incrementAssignment As BoundStatement,
generateUnstructuredExceptionHandlingResumeCode As Boolean
) As BoundStatementList
Dim body = DirectCast(Visit(node.Body), BoundStatement)
Dim endSyntax = DirectCast(syntaxNode, ForEachBlockSyntax).NextStatement
If generateUnstructuredExceptionHandlingResumeCode Then
If GenerateDebugInfo AndAlso endSyntax IsNot Nothing Then
incrementAssignment = Concat(New BoundSequencePoint(endSyntax,
New BoundStatementList(syntaxNode, RegisterUnstructuredExceptionHandlingResumeTarget(syntaxNode, canThrow:=True))),
incrementAssignment)
Else
incrementAssignment = New BoundStatementList(syntaxNode,
RegisterUnstructuredExceptionHandlingResumeTarget(syntaxNode, canThrow:=True).Add(incrementAssignment))
End If
ElseIf GenerateDebugInfo AndAlso endSyntax IsNot Nothing Then
incrementAssignment = Concat(New BoundSequencePoint(endSyntax, Nothing),
incrementAssignment)
End If
' Note: we're moving the continue label before the increment of the array index to not create an infinite loop
' if somebody uses "Continue For". This will then increase the index and start a new iteration.
' Also: see while node creation below
Dim rewrittenBodyStatements = ImmutableArray.Create(Of BoundStatement)(currentAssignment,
body,
New BoundLabelStatement(syntaxNode, node.ContinueLabel),
incrementAssignment)
' declare the control variable inside of the while loop to capture it for each
' iteration of this loop with a copy constructor
Dim rewrittenBodyBlock As BoundBlock = New BoundBlock(syntaxNode,
Nothing,
If(node.DeclaredOrInferredLocalOpt IsNot Nothing,
ImmutableArray.Create(Of LocalSymbol)(node.DeclaredOrInferredLocalOpt),
ImmutableArray(Of LocalSymbol).Empty),
rewrittenBodyStatements)
Dim booleanType = GetSpecialTypeWithUseSiteDiagnostics(SpecialType.System_Boolean, syntaxNode)
Dim boundCondition = TransformRewrittenBinaryOperator(
New BoundBinaryOperator(syntaxNode,
BinaryOperatorKind.LessThan,
index.MakeRValue(),
limit,
checked:=False,
type:=booleanType))
' now build while loop
' Note: we're creating a new label for the while loop that get's used for the initial jump from the
' beginning of the loop to the condition to check it for the first time.
' Also: see while body creation above
Dim boundWhileStatement = RewriteWhileStatement(syntaxNode,
Nothing,
Nothing,
VisitExpressionNode(boundCondition),
rewrittenBodyBlock,
New GeneratedLabelSymbol("postIncrement"),
node.ExitLabel)
Return DirectCast(boundWhileStatement, BoundStatementList)
End Function
''' <summary>
''' Rewrite a for each that uses IEnumerable. It's basic form is:
'''
''' Dim e As E = c.GetEnumerator()
''' Do While e.MoveNext()
''' controlVariable = e.Current
''' <loop body>
''' Loop
'''
''' To support disposable enumerators, the compiler will generate code to dispose the
''' enumerator after loop termination. Only when E implements IDisposable can this be done.
''' The one exception to this rule is when E is specifically IEnumerator, in which case
''' the compiler will generate code to dynamically query the enumerator to determine
''' if it implements IDisposable.
'''
''' If E is IEnumerator the loop becomes:
'''
''' Dim e As IEnumerator = c.GetEnumerator()
''' Try
''' Do While e.MoveNext()
''' dim controlVariable = e.Current
''' <loop body>
''' Loop
''' Finally
''' If TryCast(e, IDisposable) IsNot Nothing then
''' CType(e, IDisposable).Dispose()
''' End If
''' End Try
'''
''' If E is known at compile time to implement IDisposable the loop becomes:
'''
''' Dim e As E = c.GetEnumerator()
''' Try
''' Do While e.MoveNext()
''' dim controlVariable = e.Current
''' <loop body>
''' Loop
''' Finally
''' If Not e Is Nothing Then
''' CType(e, IDisposable).Dispose()
''' End If
''' End Try
'''
''' The exception to these forms is the existence of On Error in which case the Try/Finally
''' block will be eliminated (instead the body of the Finally will immediately follow
''' the end of the loop).
''' </summary>
''' <param name="node"></param>
''' <param name="statements"></param>
''' <param name="locals"></param>
Private Sub RewriteForEachIEnumerable(
node As BoundForEachStatement,
statements As ArrayBuilder(Of BoundStatement),
locals As ArrayBuilder(Of LocalSymbol)
)
Dim syntaxNode = DirectCast(node.Syntax, ForOrForEachBlockSyntax)
Dim enumeratorInfo = node.EnumeratorInfo
' We don't wrap the loop with a Try block if On Error is present.
Dim needTryFinally As Boolean = enumeratorInfo.NeedToDispose AndAlso Not InsideValidUnstructuredExceptionHandlingOnErrorContext()
Dim saveState As UnstructuredExceptionHandlingContext = Nothing
If needTryFinally Then
' Unstructured Exception Handling should be disabled inside compiler generated Try/Catch/Finally.
saveState = LeaveUnstructuredExceptionHandlingContext(node)
End If
Dim generateUnstructuredExceptionHandlingResumeCode As Boolean = ShouldGenerateUnstructuredExceptionHandlingResumeCode(node)
Dim loopResumeTarget As ImmutableArray(Of BoundStatement) = Nothing
If generateUnstructuredExceptionHandlingResumeCode Then
loopResumeTarget = RegisterUnstructuredExceptionHandlingResumeTarget(syntaxNode, canThrow:=True)
End If
' Where do the bound expressions of the bound for each node get rewritten?
' The collection will be used in a call to GetEnumerator() and assigned to a local. This assignment is rewritten
' by using "CreateLocalAndAssignment"
' The current value will be assigned to the control variable once per iteration. This is done in this method
' The casts and conversions get rewritten in "RewriteWhileStatement".
' Get Enumerator and store it in a temporary
' FYI: The GetEnumerator call accesses the collection and does not contain a placeholder.
Dim boundEnumeratorLocal As BoundLocal = Nothing
Dim boundEnumeratorAssignment = CreateLocalAndAssignment(syntaxNode.ForOrForEachStatement,
enumeratorInfo.GetEnumerator,
boundEnumeratorLocal,
locals,
SynthesizedLocalKind.ForEachEnumerator)
If Not loopResumeTarget.IsDefaultOrEmpty Then
boundEnumeratorAssignment = New BoundStatementList(boundEnumeratorAssignment.Syntax, loopResumeTarget.Add(boundEnumeratorAssignment))
End If
If GenerateDebugInfo Then
' first sequence point; highlight for each statement
boundEnumeratorAssignment = New BoundSequencePoint(DirectCast(node.Syntax, ForOrForEachBlockSyntax).ForOrForEachStatement, boundEnumeratorAssignment)
End If
Debug.Assert(enumeratorInfo.EnumeratorPlaceholder IsNot Nothing)
AddPlaceholderReplacement(enumeratorInfo.EnumeratorPlaceholder, boundEnumeratorLocal)
' Dev10 adds a conversion here from the result of MoveNext to Boolean. However we know for sure that the return
' type must be boolean because we check specifically for the return type in case of the design pattern, or we look
' up the method by using GetSpecialTypeMember which has the return type encoded.
Debug.Assert(enumeratorInfo.MoveNext.Type.SpecialType = SpecialType.System_Boolean)
If enumeratorInfo.CurrentPlaceholder IsNot Nothing Then
AddPlaceholderReplacement(enumeratorInfo.CurrentPlaceholder, VisitExpressionNode(enumeratorInfo.Current))
End If
' assign the returned value from current to the control variable
Dim boundCurrentAssignment = New BoundAssignmentOperator(syntaxNode,
node.ControlVariable,
enumeratorInfo.CurrentConversion,
suppressObjectClone:=False,
type:=node.ControlVariable.Type).ToStatement
boundCurrentAssignment.SetWasCompilerGenerated() ' used to not create sequence points
Dim rewrittenBodyStatements = ImmutableArray.Create(Of BoundStatement)(DirectCast(Visit(boundCurrentAssignment), BoundStatement),
DirectCast(Visit(node.Body), BoundStatement))
' declare the control variable inside of the while loop to capture it for each
' iteration of this loop with a copy constructor
Dim rewrittenBodyBlock As BoundBlock = New BoundBlock(syntaxNode, Nothing, If(node.DeclaredOrInferredLocalOpt IsNot Nothing, ImmutableArray.Create(Of LocalSymbol)(node.DeclaredOrInferredLocalOpt), ImmutableArray(Of LocalSymbol).Empty), rewrittenBodyStatements)
Dim bodyEpilogue As BoundStatement = New BoundLabelStatement(syntaxNode, node.ContinueLabel)
If generateUnstructuredExceptionHandlingResumeCode Then
bodyEpilogue = Concat(bodyEpilogue, New BoundStatementList(syntaxNode, RegisterUnstructuredExceptionHandlingResumeTarget(syntaxNode, canThrow:=True)))
End If
If GenerateDebugInfo Then
Dim statementEndSyntax = DirectCast(syntaxNode, ForEachBlockSyntax).NextStatement
If statementEndSyntax IsNot Nothing Then
bodyEpilogue = New BoundSequencePoint(statementEndSyntax, bodyEpilogue)
End If
End If
rewrittenBodyBlock = AppendToBlock(rewrittenBodyBlock, bodyEpilogue)
' now build while loop
Dim boundWhileStatement = RewriteWhileStatement(syntaxNode,
Nothing,
Nothing,
VisitExpressionNode(enumeratorInfo.MoveNext),
rewrittenBodyBlock,
New GeneratedLabelSymbol("MoveNextLabel"),
node.ExitLabel)
Dim visitedWhile = DirectCast(boundWhileStatement, BoundStatementList)
If enumeratorInfo.CurrentPlaceholder IsNot Nothing Then
RemovePlaceholderReplacement(enumeratorInfo.CurrentPlaceholder)
End If
If enumeratorInfo.NeedToDispose Then
Dim disposalStatement = GenerateDisposeCallForForeachAndUsing(node.Syntax,
boundEnumeratorLocal,
VisitExpressionNode(enumeratorInfo.DisposeCondition),
enumeratorInfo.IsOrInheritsFromOrImplementsIDisposable,
VisitExpressionNode(enumeratorInfo.DisposeCast))
If Not needTryFinally Then
statements.Add(boundEnumeratorAssignment)
statements.Add(visitedWhile)
If generateUnstructuredExceptionHandlingResumeCode Then
' Do not reenter the loop if Dispose throws.
RegisterUnstructuredExceptionHandlingResumeTarget(syntaxNode, canThrow:=True, statements:=statements)
End If
statements.Add(disposalStatement)
Else
Dim boundTryFinally = New BoundTryStatement(syntaxNode,
New BoundBlock(syntaxNode,
Nothing, ImmutableArray(Of LocalSymbol).Empty,
ImmutableArray.Create(Of BoundStatement)(boundEnumeratorAssignment,
visitedWhile)),
ImmutableArray(Of BoundCatchBlock).Empty,
New BoundBlock(syntaxNode,
Nothing, ImmutableArray(Of LocalSymbol).Empty,
ImmutableArray.Create(Of BoundStatement)(disposalStatement)),
exitLabelOpt:=Nothing)
boundTryFinally.SetWasCompilerGenerated() ' used to not create sequence points
statements.Add(boundTryFinally)
End If
Else
Debug.Assert(Not needTryFinally)
statements.Add(boundEnumeratorAssignment)
statements.AddRange(visitedWhile)
End If
If needTryFinally Then
RestoreUnstructuredExceptionHandlingContext(node, saveState)
End If
RemovePlaceholderReplacement(enumeratorInfo.EnumeratorPlaceholder)
End Sub
''' <summary>
''' Depending on whether the bound local's type is, implements or inherits IDisposable for sure, or might implement it,
''' this function returns the statements to call Dispose on the bound local.
'''
''' If it's known to implement IDisposable, the generated code looks like this for reference types:
''' If e IsNot Nothing Then
''' CType(e, IDisposable).Dispose()
''' End If
''' or
''' e.Dispose()
''' for value types (including type parameters with a value constraint).
''' Otherwise it looks like the following
''' If TryCast(e, IDisposable) IsNot Nothing then
''' CType(e, IDisposable).Dispose()
''' End If
''' </summary>
''' <remarks>This method is used by the for each rewriter and the using rewriter. The latter should only call
''' this method with both IsOrInheritsFromOrImplementsIDisposable and needToDispose set to true, as using is not
''' pattern based and must implement IDisposable.
''' </remarks>
''' <param name="syntaxNode">The syntax node.</param>
''' <param name="rewrittenBoundLocal">The bound local.</param>
''' <param name="rewrittenCondition">The condition used in the if statement around the dispose call</param>
''' <param name="IsOrInheritsFromOrImplementsIDisposable">A flag indicating whether the bound local's type is,
''' inherits or implements IDisposable or not.</param>
''' <param name="rewrittenDisposeConversion">Conversion from the local type to IDisposable</param>
Public Function GenerateDisposeCallForForeachAndUsing(
syntaxNode As VisualBasicSyntaxNode,
rewrittenBoundLocal As BoundLocal,
rewrittenCondition As BoundExpression,
IsOrInheritsFromOrImplementsIDisposable As Boolean,
rewrittenDisposeConversion As BoundExpression
) As BoundStatement
Dim disposeMethod As MethodSymbol = Nothing
If Not TryGetSpecialMember(disposeMethod, SpecialMember.System_IDisposable__Dispose, syntaxNode) Then
Return New BoundBadExpression(syntaxNode, LookupResultKind.NotReferencable, ImmutableArray(Of Symbol).Empty,
If(rewrittenCondition IsNot Nothing,
ImmutableArray.Create(Of BoundNode)(rewrittenBoundLocal, rewrittenCondition),
ImmutableArray.Create(Of BoundNode)(rewrittenBoundLocal)),
ErrorTypeSymbol.UnknownResultType, hasErrors:=True).ToStatement()
End If
Dim voidType = GetSpecialTypeWithUseSiteDiagnostics(SpecialType.System_Void, syntaxNode)
Dim localType = rewrittenBoundLocal.Type
' the bound nodes for the condition and the cast both come from the initial binding and are contained in
' the bound for each node.
' This way the construction of the "reference type implements IDisposable" case and the case of
' "may implement IDisposable" can be handled by the same code fragment. Only the value types know to implement
' IDisposable need to be handled differently
Dim boundCall As BoundStatement
If IsOrInheritsFromOrImplementsIDisposable AndAlso
(localType.IsValueType OrElse localType.IsTypeParameter) Then
' there's no need to cast the enumerator if it's known to be a value type, because they are implicitly
' sealed the methods cannot ever be overridden.
' this will be an constrained call, because the receiver is a value type and the method is an
' interface method:
' e.Dispose() ' constrained call
boundCall = New BoundCall(syntaxNode,
disposeMethod,
Nothing,
rewrittenBoundLocal,
ImmutableArray(Of BoundExpression).Empty,
constantValueOpt:=Nothing,
type:=voidType).ToStatement
boundCall.SetWasCompilerGenerated() ' used to not create sequence points
If localType.IsValueType Then
Return boundCall
End If
Else
Debug.Assert(rewrittenDisposeConversion IsNot Nothing)
' call to Dispose
boundCall = New BoundCall(syntaxNode,
disposeMethod,
Nothing,
rewrittenDisposeConversion,
ImmutableArray(Of BoundExpression).Empty, Nothing, voidType).ToStatement
boundCall.SetWasCompilerGenerated() ' used to not create sequence points
End If
' if statement (either the condition is "e IsNot nothing" or "TryCast(e, IDisposable) IsNot Nothing", see comment above)
Return RewriteIfStatement(syntaxNode, rewrittenCondition.Syntax, rewrittenCondition, boundCall, Nothing, generateDebugInfo:=False)
End Function
''' <summary>
''' Internal helper class to replace local symbols in bound locals of a given bound tree.
''' </summary>
Private Class LocalVariableSubstitutor
Inherits BoundTreeRewriter
Private _original As LocalSymbol
Private _replacement As LocalSymbol
Private _replacedNode As Boolean = False
Public Shared Function Replace(
node As BoundNode,
original As LocalSymbol,
replacement As LocalSymbol,
ByRef replacedNode As Boolean
) As BoundNode
Dim rewriter As New LocalVariableSubstitutor(original, replacement)
Dim result = rewriter.Visit(node)
replacedNode = rewriter.ReplacedNode
Return result
End Function
Private ReadOnly Property ReplacedNode As Boolean
Get
Return _replacedNode
End Get
End Property
Private Sub New(original As LocalSymbol, replacement As LocalSymbol)
_original = original
_replacement = replacement
End Sub
Public Overrides Function VisitLocal(node As BoundLocal) As BoundNode
If node.LocalSymbol Is _original Then
_replacedNode = True
Return node.Update(_replacement, node.IsLValue, node.Type)
End If
Return node
End Function
End Class
End Class
End Namespace
|
dsplaisted/roslyn
|
src/Compilers/VisualBasic/Portable/Lowering/LocalRewriter/LocalRewriter_ForEach.vb
|
Visual Basic
|
apache-2.0
| 48,160
|
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.Recommendations.Expressions
Public Class GlobalKeywordRecommenderTests
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function NoneInClassDeclarationTest() As Task
Await VerifyRecommendationsMissingAsync(<ClassDeclaration>|</ClassDeclaration>, "Global")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function GlobalInStatementTest() As Task
Await VerifyRecommendationsContainAsync(<MethodBody>|</MethodBody>, "Global")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function GlobalAfterReturnTest() As Task
Await VerifyRecommendationsContainAsync(<MethodBody>Return |</MethodBody>, "Global")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function GlobalAfterArgument1Test() As Task
Await VerifyRecommendationsContainAsync(<MethodBody>Goo(|</MethodBody>, "Global")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function GlobalAfterArgument2Test() As Task
Await VerifyRecommendationsContainAsync(<MethodBody>Goo(bar, |</MethodBody>, "Global")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function GlobalAfterBinaryExpressionTest() As Task
Await VerifyRecommendationsContainAsync(<MethodBody>Goo(bar + |</MethodBody>, "Global")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function GlobalAfterNotTest() As Task
Await VerifyRecommendationsContainAsync(<MethodBody>Goo(Not |</MethodBody>, "Global")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function GlobalAfterTypeOfTest() As Task
Await VerifyRecommendationsContainAsync(<MethodBody>If TypeOf |</MethodBody>, "Global")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function GlobalAfterDoWhileTest() As Task
Await VerifyRecommendationsContainAsync(<MethodBody>Do While |</MethodBody>, "Global")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function GlobalAfterDoUntilTest() As Task
Await VerifyRecommendationsContainAsync(<MethodBody>Do Until |</MethodBody>, "Global")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function GlobalAfterLoopWhileTest() As Task
Await VerifyRecommendationsContainAsync(<MethodBody>
Do
Loop While |</MethodBody>, "Global")
End Function
<Fact>
<Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function GlobalAfterLoopUntilTest() As Task
Await VerifyRecommendationsContainAsync(<MethodBody>
Do
Loop Until |</MethodBody>, "Global")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function GlobalAfterIfTest() As Task
Await VerifyRecommendationsContainAsync(<MethodBody>If |</MethodBody>, "Global")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function GlobalAfterElseIfTest() As Task
Await VerifyRecommendationsContainAsync(<MethodBody>ElseIf |</MethodBody>, "Global")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function GlobalAfterElseSpaceIfTest() As Task
Await VerifyRecommendationsContainAsync(<MethodBody>Else If |</MethodBody>, "Global")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function GlobalAfterErrorTest() As Task
Await VerifyRecommendationsContainAsync(<MethodBody>Error |</MethodBody>, "Global")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function GlobalAfterThrowTest() As Task
Await VerifyRecommendationsContainAsync(<MethodBody>Throw |</MethodBody>, "Global")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function GlobalAfterInitializerTest() As Task
Await VerifyRecommendationsContainAsync(<MethodBody>Dim x = |</MethodBody>, "Global")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function GlobalAfterArrayInitializerSquiggleTest() As Task
Await VerifyRecommendationsContainAsync(<MethodBody>Dim x = {|</MethodBody>, "Global")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function GlobalAfterArrayInitializerCommaTest() As Task
Await VerifyRecommendationsContainAsync(<MethodBody>Dim x = {0, |</MethodBody>, "Global")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function GlobalNotAfterItselfTest() As Task
Await VerifyRecommendationsMissingAsync(<MethodBody>Global.|</MethodBody>, "Global")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function GlobalNotAfterImportsTest() As Task
Await VerifyRecommendationsMissingAsync(<File>Imports |</File>, "Global")
End Function
<WorkItem(543270, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543270")>
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function NotInDelegateCreationTest() As Task
Dim code =
<File>
Module Program
Sub Main(args As String())
Dim f1 As New Goo2( |
End Sub
Delegate Sub Goo2()
Function Bar2() As Object
Return Nothing
End Function
End Module
</File>
Await VerifyRecommendationsMissingAsync(code, "Global")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function GlobalAfterInheritsTest() As Task
Dim code =
<File>
Class C
Inherits |
End Class
</File>
Await VerifyRecommendationsContainAsync(code, "Global")
End Function
<Fact, Trait(Traits.Feature, Traits.Features.KeywordRecommending)>
Public Async Function GlobalAfterImplementsTest() As Task
Dim code =
<File>
Class C
Implements |
End Class
</File>
Await VerifyRecommendationsContainAsync(code, "Global")
End Function
End Class
End Namespace
|
mmitche/roslyn
|
src/EditorFeatures/VisualBasicTest/Recommendations/Expressions/GlobalKeywordRecommenderTests.vb
|
Visual Basic
|
apache-2.0
| 7,219
|
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System.Collections.ObjectModel
Imports System.ComponentModel.Composition
Imports Microsoft.CodeAnalysis.Editor.Host
Imports Microsoft.VisualStudio.Text
Imports Microsoft.VisualStudio.Text.Editor
Imports Microsoft.VisualStudio.Text.Operations
Imports Microsoft.VisualStudio.Utilities
Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.LineCommit
<Export(GetType(IWpfTextViewConnectionListener))>
<ContentType(ContentTypeNames.VisualBasicContentType)>
<TextViewRole(PredefinedTextViewRoles.Editable)>
Friend Class CommitConnectionListener
Implements IWpfTextViewConnectionListener
Private ReadOnly _commitBufferManagerFactory As CommitBufferManagerFactory
Private ReadOnly _textBufferAssociatedViewService As ITextBufferAssociatedViewService
Private ReadOnly _textUndoHistoryRegistry As ITextUndoHistoryRegistry
Private ReadOnly _waitIndicator As IWaitIndicator
<ImportingConstructor()>
Public Sub New(commitBufferManagerFactory As CommitBufferManagerFactory,
textBufferAssociatedViewService As ITextBufferAssociatedViewService,
textUndoHistoryRegistry As ITextUndoHistoryRegistry,
waitIndicator As IWaitIndicator)
_commitBufferManagerFactory = commitBufferManagerFactory
_textBufferAssociatedViewService = textBufferAssociatedViewService
_textUndoHistoryRegistry = textUndoHistoryRegistry
_waitIndicator = waitIndicator
End Sub
Public Sub SubjectBuffersConnected(view As IWpfTextView, reason As ConnectionReason, subjectBuffers As Collection(Of ITextBuffer)) Implements IWpfTextViewConnectionListener.SubjectBuffersConnected
' Make sure we have a view manager
view.Properties.GetOrCreateSingletonProperty(
Function() New CommitViewManager(view, _commitBufferManagerFactory, _textBufferAssociatedViewService, _textUndoHistoryRegistry, _waitIndicator))
' Connect to each of these buffers, and increment their ref count
For Each buffer In subjectBuffers
_commitBufferManagerFactory.CreateForBuffer(buffer).AddReferencingView()
Next
End Sub
Public Sub SubjectBuffersDisconnected(view As IWpfTextView, reason As ConnectionReason, subjectBuffers As Collection(Of ITextBuffer)) Implements IWpfTextViewConnectionListener.SubjectBuffersDisconnected
For Each buffer In subjectBuffers
_commitBufferManagerFactory.CreateForBuffer(buffer).RemoveReferencingView()
Next
' If we have no subject buffers left, we can remove our view manager
If Not view.BufferGraph.GetTextBuffers(Function(b) b.ContentType.IsOfType(ContentTypeNames.VisualBasicContentType)).Any() Then
view.Properties.GetProperty(Of CommitViewManager)(GetType(CommitViewManager)).Disconnect()
view.Properties.RemoveProperty(GetType(CommitViewManager))
End If
End Sub
End Class
End Namespace
|
v-codeel/roslyn
|
src/EditorFeatures/VisualBasic/LineCommit/CommitConnectionListener.vb
|
Visual Basic
|
apache-2.0
| 3,249
|
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class frmMain
Inherits ComponentFactory.Krypton.Toolkit.KryptonForm
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(frmMain))
Me.MenuStrip1 = New System.Windows.Forms.MenuStrip
Me.SystemToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.LogInToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.LogOutToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.ToolStripMenuItem1 = New System.Windows.Forms.ToolStripSeparator
Me.ExitToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.FileToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.ToolStripMenuItem6 = New System.Windows.Forms.ToolStripMenuItem
Me.CoursesToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.SubjectsToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.EmployeesToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.StudentsToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.ToolStripMenuItem2 = New System.Windows.Forms.ToolStripSeparator
Me.FeesToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.FeesAmountsToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.ToolStripMenuItem13 = New System.Windows.Forms.ToolStripMenuItem
Me.FeeToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.SemestralFeesToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.ToolStripMenuItem16 = New System.Windows.Forms.ToolStripSeparator
Me.StudentLedgersToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.ToolStripMenuItem17 = New System.Windows.Forms.ToolStripSeparator
Me.DiscountsToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.ChargesToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.ToolStripMenuItem11 = New System.Windows.Forms.ToolStripMenuItem
Me.StudentAdmissionToolStripMenuItem1 = New System.Windows.Forms.ToolStripMenuItem
Me.ListForExportToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.OpenImportedToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.ToolStripMenuItem8 = New System.Windows.Forms.ToolStripMenuItem
Me.EvaluationToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.StudentAdmissionToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.EnrollmentToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.ToolStripMenuItem7 = New System.Windows.Forms.ToolStripMenuItem
Me.ToolStripSeparator1 = New System.Windows.Forms.ToolStripSeparator
Me.SubjectsOfferedToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.EnrollStudentToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.ToolStripMenuItem4 = New System.Windows.Forms.ToolStripSeparator
Me.GradesToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.ReportsToolStripMenuItem1 = New System.Windows.Forms.ToolStripMenuItem
Me.CourseOfferingsToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.ToolStripMenuItem14 = New System.Windows.Forms.ToolStripMenuItem
Me.CashieringToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.ReportToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.PaymentsReceivedToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.ToolStripMenuItem9 = New System.Windows.Forms.ToolStripMenuItem
Me.AcceptGradToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.ViewsToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.ToolStripMenuItem12 = New System.Windows.Forms.ToolStripMenuItem
Me.BlockSectionsToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.AllToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.EnrolledStudentsToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.StudentGradesToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.StudentScheduleToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.TeachersLoadToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.ToolStripMenuItem15 = New System.Windows.Forms.ToolStripSeparator
Me.SummaryOfEnrollmentToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.ToolStripMenuItem18 = New System.Windows.Forms.ToolStripSeparator
Me.StudentLedgersToolStripMenuItem1 = New System.Windows.Forms.ToolStripMenuItem
Me.ToolStripMenuItem3 = New System.Windows.Forms.ToolStripMenuItem
Me.DatabaseSettingsToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.OtherSettingsToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.ReportsToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.EnrollmentListToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.PromotionalReportToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.CourseLoadsbyProgramYearLevelSexToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.EnrolmentSummarybyProgramYearLevelSexToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.EnrolmentHeadcountByProgramYearLevelSexToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.CourseProfileToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.StudentsProfileBySexAgeHomeAddressToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.EnrolmentReportbyProgramYearLevelSexToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.EnrolmentReportByProgramMajorWLabOrNoneToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.TotalEnrolledUnitsToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.GradingSheetsToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.ReportOfRatingsToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.PromotionalReportToolStripMenuItem1 = New System.Windows.Forms.ToolStripMenuItem
Me.GenWtdAveToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.ConsilidatedStudentsIndividualPermanentRecordToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.StudentsApplicationForGraduationFormIXToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.ConsolidatedIndividualGeWtdAveForAcadAwardsToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.OfficialTranscriptOfRecordsToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.ToolStripMenuItem10 = New System.Windows.Forms.ToolStripMenuItem
Me.SystemLoginsToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.SetCurrentTermYearToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.HelpToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.ContentsToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.ToolStripMenuItem5 = New System.Windows.Forms.ToolStripSeparator
Me.AboutToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.StatusStrip1 = New System.Windows.Forms.StatusStrip
Me.ToolStripStatusLabel1 = New System.Windows.Forms.ToolStripStatusLabel
Me.ToolStrip1 = New System.Windows.Forms.ToolStrip
Me.SplitContainer1 = New System.Windows.Forms.SplitContainer
Me.KryptonHeaderGroup1 = New ComponentFactory.Krypton.Toolkit.KryptonHeaderGroup
Me.cmdCourseOfferings = New ComponentFactory.Krypton.Toolkit.KryptonButton
Me.KryptonButton2 = New ComponentFactory.Krypton.Toolkit.KryptonButton
Me.KryptonHeaderGroup2 = New ComponentFactory.Krypton.Toolkit.KryptonHeaderGroup
Me.PictureBox1 = New System.Windows.Forms.PictureBox
Me.lblHeader = New ComponentFactory.Krypton.Toolkit.KryptonHeader
Me.WebMain = New System.Windows.Forms.WebBrowser
Me.ToolStripMenuItem19 = New System.Windows.Forms.ToolStripSeparator
Me.OpenImportedDataToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.BackupDatabaseToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
Me.MenuStrip1.SuspendLayout()
Me.StatusStrip1.SuspendLayout()
Me.SplitContainer1.Panel1.SuspendLayout()
Me.SplitContainer1.Panel2.SuspendLayout()
Me.SplitContainer1.SuspendLayout()
CType(Me.KryptonHeaderGroup1, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.KryptonHeaderGroup1.Panel, System.ComponentModel.ISupportInitialize).BeginInit()
Me.KryptonHeaderGroup1.Panel.SuspendLayout()
Me.KryptonHeaderGroup1.SuspendLayout()
CType(Me.KryptonHeaderGroup2, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.KryptonHeaderGroup2.Panel, System.ComponentModel.ISupportInitialize).BeginInit()
Me.KryptonHeaderGroup2.Panel.SuspendLayout()
Me.KryptonHeaderGroup2.SuspendLayout()
CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'MenuStrip1
'
Me.MenuStrip1.Font = New System.Drawing.Font("Segoe UI", 8.25!)
Me.MenuStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.SystemToolStripMenuItem, Me.FileToolStripMenuItem, Me.ToolStripMenuItem13, Me.ToolStripMenuItem11, Me.ToolStripMenuItem8, Me.EnrollmentToolStripMenuItem, Me.ToolStripMenuItem14, Me.ToolStripMenuItem9, Me.ViewsToolStripMenuItem, Me.ToolStripMenuItem3, Me.ReportsToolStripMenuItem, Me.ToolStripMenuItem10, Me.HelpToolStripMenuItem})
Me.MenuStrip1.Location = New System.Drawing.Point(0, 0)
Me.MenuStrip1.Name = "MenuStrip1"
Me.MenuStrip1.Size = New System.Drawing.Size(1065, 24)
Me.MenuStrip1.TabIndex = 1
Me.MenuStrip1.Text = "MenuStrip1"
'
'SystemToolStripMenuItem
'
Me.SystemToolStripMenuItem.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.LogInToolStripMenuItem, Me.LogOutToolStripMenuItem, Me.ToolStripMenuItem1, Me.ExitToolStripMenuItem})
Me.SystemToolStripMenuItem.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.SystemToolStripMenuItem.Name = "SystemToolStripMenuItem"
Me.SystemToolStripMenuItem.Size = New System.Drawing.Size(65, 20)
Me.SystemToolStripMenuItem.Text = "&System"
'
'LogInToolStripMenuItem
'
Me.LogInToolStripMenuItem.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.LogInToolStripMenuItem.Name = "LogInToolStripMenuItem"
Me.LogInToolStripMenuItem.Size = New System.Drawing.Size(127, 22)
Me.LogInToolStripMenuItem.Text = "Log-&In"
'
'LogOutToolStripMenuItem
'
Me.LogOutToolStripMenuItem.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.LogOutToolStripMenuItem.Name = "LogOutToolStripMenuItem"
Me.LogOutToolStripMenuItem.Size = New System.Drawing.Size(127, 22)
Me.LogOutToolStripMenuItem.Text = "Log-&Out"
'
'ToolStripMenuItem1
'
Me.ToolStripMenuItem1.Name = "ToolStripMenuItem1"
Me.ToolStripMenuItem1.Size = New System.Drawing.Size(124, 6)
'
'ExitToolStripMenuItem
'
Me.ExitToolStripMenuItem.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.ExitToolStripMenuItem.Image = CType(resources.GetObject("ExitToolStripMenuItem.Image"), System.Drawing.Image)
Me.ExitToolStripMenuItem.Name = "ExitToolStripMenuItem"
Me.ExitToolStripMenuItem.Size = New System.Drawing.Size(127, 22)
Me.ExitToolStripMenuItem.Text = "E&xit"
'
'FileToolStripMenuItem
'
Me.FileToolStripMenuItem.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.ToolStripMenuItem6, Me.CoursesToolStripMenuItem, Me.SubjectsToolStripMenuItem, Me.EmployeesToolStripMenuItem, Me.StudentsToolStripMenuItem, Me.ToolStripMenuItem2, Me.FeesToolStripMenuItem, Me.FeesAmountsToolStripMenuItem, Me.ToolStripMenuItem19, Me.OpenImportedDataToolStripMenuItem})
Me.FileToolStripMenuItem.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.FileToolStripMenuItem.Name = "FileToolStripMenuItem"
Me.FileToolStripMenuItem.Size = New System.Drawing.Size(42, 20)
Me.FileToolStripMenuItem.Text = "&File"
'
'ToolStripMenuItem6
'
Me.ToolStripMenuItem6.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.ToolStripMenuItem6.Name = "ToolStripMenuItem6"
Me.ToolStripMenuItem6.Size = New System.Drawing.Size(175, 22)
Me.ToolStripMenuItem6.Text = "Departments"
'
'CoursesToolStripMenuItem
'
Me.CoursesToolStripMenuItem.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.CoursesToolStripMenuItem.Name = "CoursesToolStripMenuItem"
Me.CoursesToolStripMenuItem.Size = New System.Drawing.Size(175, 22)
Me.CoursesToolStripMenuItem.Text = "Programs"
'
'SubjectsToolStripMenuItem
'
Me.SubjectsToolStripMenuItem.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.SubjectsToolStripMenuItem.Name = "SubjectsToolStripMenuItem"
Me.SubjectsToolStripMenuItem.Size = New System.Drawing.Size(175, 22)
Me.SubjectsToolStripMenuItem.Text = "Subjects"
'
'EmployeesToolStripMenuItem
'
Me.EmployeesToolStripMenuItem.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.EmployeesToolStripMenuItem.Name = "EmployeesToolStripMenuItem"
Me.EmployeesToolStripMenuItem.Size = New System.Drawing.Size(175, 22)
Me.EmployeesToolStripMenuItem.Text = "Employees"
'
'StudentsToolStripMenuItem
'
Me.StudentsToolStripMenuItem.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.StudentsToolStripMenuItem.Name = "StudentsToolStripMenuItem"
Me.StudentsToolStripMenuItem.Size = New System.Drawing.Size(175, 22)
Me.StudentsToolStripMenuItem.Text = "Students"
'
'ToolStripMenuItem2
'
Me.ToolStripMenuItem2.Name = "ToolStripMenuItem2"
Me.ToolStripMenuItem2.Size = New System.Drawing.Size(172, 6)
'
'FeesToolStripMenuItem
'
Me.FeesToolStripMenuItem.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.FeesToolStripMenuItem.Name = "FeesToolStripMenuItem"
Me.FeesToolStripMenuItem.Size = New System.Drawing.Size(175, 22)
Me.FeesToolStripMenuItem.Text = "Fees Names"
Me.FeesToolStripMenuItem.Visible = False
'
'FeesAmountsToolStripMenuItem
'
Me.FeesAmountsToolStripMenuItem.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.FeesAmountsToolStripMenuItem.Name = "FeesAmountsToolStripMenuItem"
Me.FeesAmountsToolStripMenuItem.Size = New System.Drawing.Size(175, 22)
Me.FeesAmountsToolStripMenuItem.Text = "Semestral Fees"
Me.FeesAmountsToolStripMenuItem.Visible = False
'
'ToolStripMenuItem13
'
Me.ToolStripMenuItem13.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.FeeToolStripMenuItem, Me.SemestralFeesToolStripMenuItem, Me.ToolStripMenuItem16, Me.StudentLedgersToolStripMenuItem, Me.ToolStripMenuItem17, Me.DiscountsToolStripMenuItem, Me.ChargesToolStripMenuItem})
Me.ToolStripMenuItem13.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.ToolStripMenuItem13.Name = "ToolStripMenuItem13"
Me.ToolStripMenuItem13.Size = New System.Drawing.Size(86, 20)
Me.ToolStripMenuItem13.Text = "Accounting"
'
'FeeToolStripMenuItem
'
Me.FeeToolStripMenuItem.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.FeeToolStripMenuItem.Name = "FeeToolStripMenuItem"
Me.FeeToolStripMenuItem.Size = New System.Drawing.Size(178, 22)
Me.FeeToolStripMenuItem.Text = "Fees Titles"
'
'SemestralFeesToolStripMenuItem
'
Me.SemestralFeesToolStripMenuItem.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.SemestralFeesToolStripMenuItem.Name = "SemestralFeesToolStripMenuItem"
Me.SemestralFeesToolStripMenuItem.Size = New System.Drawing.Size(178, 22)
Me.SemestralFeesToolStripMenuItem.Text = "Semestral Fees"
'
'ToolStripMenuItem16
'
Me.ToolStripMenuItem16.Name = "ToolStripMenuItem16"
Me.ToolStripMenuItem16.Size = New System.Drawing.Size(175, 6)
'
'StudentLedgersToolStripMenuItem
'
Me.StudentLedgersToolStripMenuItem.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.StudentLedgersToolStripMenuItem.Name = "StudentLedgersToolStripMenuItem"
Me.StudentLedgersToolStripMenuItem.Size = New System.Drawing.Size(178, 22)
Me.StudentLedgersToolStripMenuItem.Text = "Student Ledgers"
'
'ToolStripMenuItem17
'
Me.ToolStripMenuItem17.Name = "ToolStripMenuItem17"
Me.ToolStripMenuItem17.Size = New System.Drawing.Size(175, 6)
'
'DiscountsToolStripMenuItem
'
Me.DiscountsToolStripMenuItem.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.DiscountsToolStripMenuItem.Name = "DiscountsToolStripMenuItem"
Me.DiscountsToolStripMenuItem.Size = New System.Drawing.Size(178, 22)
Me.DiscountsToolStripMenuItem.Text = "Discounts"
Me.DiscountsToolStripMenuItem.ToolTipText = "Click to add discounts"
'
'ChargesToolStripMenuItem
'
Me.ChargesToolStripMenuItem.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.ChargesToolStripMenuItem.Name = "ChargesToolStripMenuItem"
Me.ChargesToolStripMenuItem.Size = New System.Drawing.Size(178, 22)
Me.ChargesToolStripMenuItem.Text = "Charges"
Me.ChargesToolStripMenuItem.ToolTipText = "Click to add charges"
'
'ToolStripMenuItem11
'
Me.ToolStripMenuItem11.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.StudentAdmissionToolStripMenuItem1, Me.ListForExportToolStripMenuItem, Me.OpenImportedToolStripMenuItem})
Me.ToolStripMenuItem11.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.ToolStripMenuItem11.Name = "ToolStripMenuItem11"
Me.ToolStripMenuItem11.Size = New System.Drawing.Size(83, 20)
Me.ToolStripMenuItem11.Text = "Admission"
'
'StudentAdmissionToolStripMenuItem1
'
Me.StudentAdmissionToolStripMenuItem1.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.StudentAdmissionToolStripMenuItem1.Name = "StudentAdmissionToolStripMenuItem1"
Me.StudentAdmissionToolStripMenuItem1.Size = New System.Drawing.Size(191, 22)
Me.StudentAdmissionToolStripMenuItem1.Text = "Student Admission"
'
'ListForExportToolStripMenuItem
'
Me.ListForExportToolStripMenuItem.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.ListForExportToolStripMenuItem.Name = "ListForExportToolStripMenuItem"
Me.ListForExportToolStripMenuItem.Size = New System.Drawing.Size(191, 22)
Me.ListForExportToolStripMenuItem.Text = "List For Export"
'
'OpenImportedToolStripMenuItem
'
Me.OpenImportedToolStripMenuItem.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.OpenImportedToolStripMenuItem.Name = "OpenImportedToolStripMenuItem"
Me.OpenImportedToolStripMenuItem.Size = New System.Drawing.Size(191, 22)
Me.OpenImportedToolStripMenuItem.Text = "Open Imported"
'
'ToolStripMenuItem8
'
Me.ToolStripMenuItem8.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.EvaluationToolStripMenuItem, Me.StudentAdmissionToolStripMenuItem})
Me.ToolStripMenuItem8.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.ToolStripMenuItem8.Name = "ToolStripMenuItem8"
Me.ToolStripMenuItem8.Size = New System.Drawing.Size(72, 20)
Me.ToolStripMenuItem8.Text = "Advising"
'
'EvaluationToolStripMenuItem
'
Me.EvaluationToolStripMenuItem.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.EvaluationToolStripMenuItem.Name = "EvaluationToolStripMenuItem"
Me.EvaluationToolStripMenuItem.Size = New System.Drawing.Size(273, 22)
Me.EvaluationToolStripMenuItem.Text = "Evaluation/Encoding of Subjects"
'
'StudentAdmissionToolStripMenuItem
'
Me.StudentAdmissionToolStripMenuItem.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.StudentAdmissionToolStripMenuItem.Name = "StudentAdmissionToolStripMenuItem"
Me.StudentAdmissionToolStripMenuItem.Size = New System.Drawing.Size(273, 22)
Me.StudentAdmissionToolStripMenuItem.Text = "Student Admission"
Me.StudentAdmissionToolStripMenuItem.Visible = False
'
'EnrollmentToolStripMenuItem
'
Me.EnrollmentToolStripMenuItem.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.ToolStripMenuItem7, Me.ToolStripSeparator1, Me.SubjectsOfferedToolStripMenuItem, Me.EnrollStudentToolStripMenuItem, Me.ToolStripMenuItem4, Me.GradesToolStripMenuItem, Me.ReportsToolStripMenuItem1})
Me.EnrollmentToolStripMenuItem.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.EnrollmentToolStripMenuItem.Name = "EnrollmentToolStripMenuItem"
Me.EnrollmentToolStripMenuItem.Size = New System.Drawing.Size(83, 20)
Me.EnrollmentToolStripMenuItem.Text = "&Enrollment"
'
'ToolStripMenuItem7
'
Me.ToolStripMenuItem7.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.ToolStripMenuItem7.Name = "ToolStripMenuItem7"
Me.ToolStripMenuItem7.Size = New System.Drawing.Size(191, 22)
Me.ToolStripMenuItem7.Text = "Student Admission"
Me.ToolStripMenuItem7.Visible = False
'
'ToolStripSeparator1
'
Me.ToolStripSeparator1.Name = "ToolStripSeparator1"
Me.ToolStripSeparator1.Size = New System.Drawing.Size(188, 6)
'
'SubjectsOfferedToolStripMenuItem
'
Me.SubjectsOfferedToolStripMenuItem.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.SubjectsOfferedToolStripMenuItem.Name = "SubjectsOfferedToolStripMenuItem"
Me.SubjectsOfferedToolStripMenuItem.Size = New System.Drawing.Size(191, 22)
Me.SubjectsOfferedToolStripMenuItem.Text = "Course Offerings"
'
'EnrollStudentToolStripMenuItem
'
Me.EnrollStudentToolStripMenuItem.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.EnrollStudentToolStripMenuItem.Name = "EnrollStudentToolStripMenuItem"
Me.EnrollStudentToolStripMenuItem.Size = New System.Drawing.Size(191, 22)
Me.EnrollStudentToolStripMenuItem.Text = "Enroll Student"
'
'ToolStripMenuItem4
'
Me.ToolStripMenuItem4.Name = "ToolStripMenuItem4"
Me.ToolStripMenuItem4.Size = New System.Drawing.Size(188, 6)
'
'GradesToolStripMenuItem
'
Me.GradesToolStripMenuItem.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.GradesToolStripMenuItem.Name = "GradesToolStripMenuItem"
Me.GradesToolStripMenuItem.Size = New System.Drawing.Size(191, 22)
Me.GradesToolStripMenuItem.Text = "Grades"
'
'ReportsToolStripMenuItem1
'
Me.ReportsToolStripMenuItem1.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.CourseOfferingsToolStripMenuItem})
Me.ReportsToolStripMenuItem1.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.ReportsToolStripMenuItem1.Name = "ReportsToolStripMenuItem1"
Me.ReportsToolStripMenuItem1.Size = New System.Drawing.Size(191, 22)
Me.ReportsToolStripMenuItem1.Text = "Reports"
'
'CourseOfferingsToolStripMenuItem
'
Me.CourseOfferingsToolStripMenuItem.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.CourseOfferingsToolStripMenuItem.Name = "CourseOfferingsToolStripMenuItem"
Me.CourseOfferingsToolStripMenuItem.Size = New System.Drawing.Size(179, 22)
Me.CourseOfferingsToolStripMenuItem.Text = "Course Offerings"
'
'ToolStripMenuItem14
'
Me.ToolStripMenuItem14.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.CashieringToolStripMenuItem, Me.ReportToolStripMenuItem})
Me.ToolStripMenuItem14.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.ToolStripMenuItem14.Name = "ToolStripMenuItem14"
Me.ToolStripMenuItem14.Size = New System.Drawing.Size(84, 20)
Me.ToolStripMenuItem14.Text = "Cashiering"
'
'CashieringToolStripMenuItem
'
Me.CashieringToolStripMenuItem.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.CashieringToolStripMenuItem.Name = "CashieringToolStripMenuItem"
Me.CashieringToolStripMenuItem.Size = New System.Drawing.Size(144, 22)
Me.CashieringToolStripMenuItem.Text = "Cashiering"
'
'ReportToolStripMenuItem
'
Me.ReportToolStripMenuItem.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.PaymentsReceivedToolStripMenuItem})
Me.ReportToolStripMenuItem.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.ReportToolStripMenuItem.Name = "ReportToolStripMenuItem"
Me.ReportToolStripMenuItem.Size = New System.Drawing.Size(144, 22)
Me.ReportToolStripMenuItem.Text = "Report"
'
'PaymentsReceivedToolStripMenuItem
'
Me.PaymentsReceivedToolStripMenuItem.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.PaymentsReceivedToolStripMenuItem.Name = "PaymentsReceivedToolStripMenuItem"
Me.PaymentsReceivedToolStripMenuItem.Size = New System.Drawing.Size(202, 22)
Me.PaymentsReceivedToolStripMenuItem.Text = "Payments Received"
'
'ToolStripMenuItem9
'
Me.ToolStripMenuItem9.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.AcceptGradToolStripMenuItem})
Me.ToolStripMenuItem9.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.ToolStripMenuItem9.Name = "ToolStripMenuItem9"
Me.ToolStripMenuItem9.Size = New System.Drawing.Size(68, 20)
Me.ToolStripMenuItem9.Text = "Grading"
'
'AcceptGradToolStripMenuItem
'
Me.AcceptGradToolStripMenuItem.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.AcceptGradToolStripMenuItem.Name = "AcceptGradToolStripMenuItem"
Me.AcceptGradToolStripMenuItem.Size = New System.Drawing.Size(170, 22)
Me.AcceptGradToolStripMenuItem.Text = "Accept Grades"
'
'ViewsToolStripMenuItem
'
Me.ViewsToolStripMenuItem.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.ToolStripMenuItem12, Me.EnrolledStudentsToolStripMenuItem, Me.StudentGradesToolStripMenuItem, Me.StudentScheduleToolStripMenuItem, Me.TeachersLoadToolStripMenuItem, Me.ToolStripMenuItem15, Me.SummaryOfEnrollmentToolStripMenuItem, Me.ToolStripMenuItem18, Me.StudentLedgersToolStripMenuItem1})
Me.ViewsToolStripMenuItem.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.ViewsToolStripMenuItem.Name = "ViewsToolStripMenuItem"
Me.ViewsToolStripMenuItem.Size = New System.Drawing.Size(56, 20)
Me.ViewsToolStripMenuItem.Text = "Views"
'
'ToolStripMenuItem12
'
Me.ToolStripMenuItem12.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.BlockSectionsToolStripMenuItem, Me.AllToolStripMenuItem})
Me.ToolStripMenuItem12.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.ToolStripMenuItem12.Name = "ToolStripMenuItem12"
Me.ToolStripMenuItem12.Size = New System.Drawing.Size(217, 22)
Me.ToolStripMenuItem12.Text = "Course Offerings"
'
'BlockSectionsToolStripMenuItem
'
Me.BlockSectionsToolStripMenuItem.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.BlockSectionsToolStripMenuItem.Name = "BlockSectionsToolStripMenuItem"
Me.BlockSectionsToolStripMenuItem.Size = New System.Drawing.Size(169, 22)
Me.BlockSectionsToolStripMenuItem.Text = "Block Sections"
'
'AllToolStripMenuItem
'
Me.AllToolStripMenuItem.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.AllToolStripMenuItem.Name = "AllToolStripMenuItem"
Me.AllToolStripMenuItem.Size = New System.Drawing.Size(169, 22)
Me.AllToolStripMenuItem.Text = "Listing"
'
'EnrolledStudentsToolStripMenuItem
'
Me.EnrolledStudentsToolStripMenuItem.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.EnrolledStudentsToolStripMenuItem.Name = "EnrolledStudentsToolStripMenuItem"
Me.EnrolledStudentsToolStripMenuItem.Size = New System.Drawing.Size(217, 22)
Me.EnrolledStudentsToolStripMenuItem.Text = "Enrolled Students"
'
'StudentGradesToolStripMenuItem
'
Me.StudentGradesToolStripMenuItem.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.StudentGradesToolStripMenuItem.Name = "StudentGradesToolStripMenuItem"
Me.StudentGradesToolStripMenuItem.Size = New System.Drawing.Size(217, 22)
Me.StudentGradesToolStripMenuItem.Text = "Student Grades"
'
'StudentScheduleToolStripMenuItem
'
Me.StudentScheduleToolStripMenuItem.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.StudentScheduleToolStripMenuItem.Name = "StudentScheduleToolStripMenuItem"
Me.StudentScheduleToolStripMenuItem.Size = New System.Drawing.Size(217, 22)
Me.StudentScheduleToolStripMenuItem.Text = "Student Schedule"
'
'TeachersLoadToolStripMenuItem
'
Me.TeachersLoadToolStripMenuItem.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.TeachersLoadToolStripMenuItem.Name = "TeachersLoadToolStripMenuItem"
Me.TeachersLoadToolStripMenuItem.Size = New System.Drawing.Size(217, 22)
Me.TeachersLoadToolStripMenuItem.Text = "Faculty Load"
'
'ToolStripMenuItem15
'
Me.ToolStripMenuItem15.Name = "ToolStripMenuItem15"
Me.ToolStripMenuItem15.Size = New System.Drawing.Size(214, 6)
'
'SummaryOfEnrollmentToolStripMenuItem
'
Me.SummaryOfEnrollmentToolStripMenuItem.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.SummaryOfEnrollmentToolStripMenuItem.Name = "SummaryOfEnrollmentToolStripMenuItem"
Me.SummaryOfEnrollmentToolStripMenuItem.Size = New System.Drawing.Size(217, 22)
Me.SummaryOfEnrollmentToolStripMenuItem.Text = "Summary of Enrollment"
'
'ToolStripMenuItem18
'
Me.ToolStripMenuItem18.Name = "ToolStripMenuItem18"
Me.ToolStripMenuItem18.Size = New System.Drawing.Size(214, 6)
'
'StudentLedgersToolStripMenuItem1
'
Me.StudentLedgersToolStripMenuItem1.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.StudentLedgersToolStripMenuItem1.Name = "StudentLedgersToolStripMenuItem1"
Me.StudentLedgersToolStripMenuItem1.Size = New System.Drawing.Size(217, 22)
Me.StudentLedgersToolStripMenuItem1.Text = "Student Ledgers"
Me.StudentLedgersToolStripMenuItem1.Visible = False
'
'ToolStripMenuItem3
'
Me.ToolStripMenuItem3.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.DatabaseSettingsToolStripMenuItem, Me.OtherSettingsToolStripMenuItem})
Me.ToolStripMenuItem3.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.ToolStripMenuItem3.Name = "ToolStripMenuItem3"
Me.ToolStripMenuItem3.Size = New System.Drawing.Size(68, 20)
Me.ToolStripMenuItem3.Text = "Settings"
'
'DatabaseSettingsToolStripMenuItem
'
Me.DatabaseSettingsToolStripMenuItem.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.DatabaseSettingsToolStripMenuItem.Name = "DatabaseSettingsToolStripMenuItem"
Me.DatabaseSettingsToolStripMenuItem.Size = New System.Drawing.Size(191, 22)
Me.DatabaseSettingsToolStripMenuItem.Text = "Database Settings"
'
'OtherSettingsToolStripMenuItem
'
Me.OtherSettingsToolStripMenuItem.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.OtherSettingsToolStripMenuItem.Name = "OtherSettingsToolStripMenuItem"
Me.OtherSettingsToolStripMenuItem.Size = New System.Drawing.Size(191, 22)
Me.OtherSettingsToolStripMenuItem.Text = "Other Settings"
'
'ReportsToolStripMenuItem
'
Me.ReportsToolStripMenuItem.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.EnrollmentListToolStripMenuItem, Me.PromotionalReportToolStripMenuItem, Me.CourseLoadsbyProgramYearLevelSexToolStripMenuItem, Me.EnrolmentSummarybyProgramYearLevelSexToolStripMenuItem, Me.EnrolmentHeadcountByProgramYearLevelSexToolStripMenuItem, Me.CourseProfileToolStripMenuItem, Me.StudentsProfileBySexAgeHomeAddressToolStripMenuItem, Me.EnrolmentReportbyProgramYearLevelSexToolStripMenuItem, Me.EnrolmentReportByProgramMajorWLabOrNoneToolStripMenuItem, Me.TotalEnrolledUnitsToolStripMenuItem, Me.GradingSheetsToolStripMenuItem, Me.ReportOfRatingsToolStripMenuItem, Me.PromotionalReportToolStripMenuItem1, Me.GenWtdAveToolStripMenuItem, Me.ConsilidatedStudentsIndividualPermanentRecordToolStripMenuItem, Me.StudentsApplicationForGraduationFormIXToolStripMenuItem, Me.ConsolidatedIndividualGeWtdAveForAcadAwardsToolStripMenuItem, Me.OfficialTranscriptOfRecordsToolStripMenuItem})
Me.ReportsToolStripMenuItem.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.ReportsToolStripMenuItem.Name = "ReportsToolStripMenuItem"
Me.ReportsToolStripMenuItem.Size = New System.Drawing.Size(68, 20)
Me.ReportsToolStripMenuItem.Text = "Reports"
'
'EnrollmentListToolStripMenuItem
'
Me.EnrollmentListToolStripMenuItem.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.EnrollmentListToolStripMenuItem.Name = "EnrollmentListToolStripMenuItem"
Me.EnrollmentListToolStripMenuItem.Size = New System.Drawing.Size(408, 22)
Me.EnrollmentListToolStripMenuItem.Text = "Student's Individual Load"
'
'PromotionalReportToolStripMenuItem
'
Me.PromotionalReportToolStripMenuItem.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.PromotionalReportToolStripMenuItem.Name = "PromotionalReportToolStripMenuItem"
Me.PromotionalReportToolStripMenuItem.Size = New System.Drawing.Size(408, 22)
Me.PromotionalReportToolStripMenuItem.Text = "Instructor's Individual Load (Class List)"
'
'CourseLoadsbyProgramYearLevelSexToolStripMenuItem
'
Me.CourseLoadsbyProgramYearLevelSexToolStripMenuItem.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.CourseLoadsbyProgramYearLevelSexToolStripMenuItem.Name = "CourseLoadsbyProgramYearLevelSexToolStripMenuItem"
Me.CourseLoadsbyProgramYearLevelSexToolStripMenuItem.Size = New System.Drawing.Size(408, 22)
Me.CourseLoadsbyProgramYearLevelSexToolStripMenuItem.Text = "Course Loads (by Program, Year Level & Sex)"
'
'EnrolmentSummarybyProgramYearLevelSexToolStripMenuItem
'
Me.EnrolmentSummarybyProgramYearLevelSexToolStripMenuItem.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.EnrolmentSummarybyProgramYearLevelSexToolStripMenuItem.Name = "EnrolmentSummarybyProgramYearLevelSexToolStripMenuItem"
Me.EnrolmentSummarybyProgramYearLevelSexToolStripMenuItem.Size = New System.Drawing.Size(408, 22)
Me.EnrolmentSummarybyProgramYearLevelSexToolStripMenuItem.Text = "Enrolment Summary (by Program, Year Level & Sex)"
'
'EnrolmentHeadcountByProgramYearLevelSexToolStripMenuItem
'
Me.EnrolmentHeadcountByProgramYearLevelSexToolStripMenuItem.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.EnrolmentHeadcountByProgramYearLevelSexToolStripMenuItem.Name = "EnrolmentHeadcountByProgramYearLevelSexToolStripMenuItem"
Me.EnrolmentHeadcountByProgramYearLevelSexToolStripMenuItem.Size = New System.Drawing.Size(408, 22)
Me.EnrolmentHeadcountByProgramYearLevelSexToolStripMenuItem.Text = "Enrolment Headcount (By Program, Year Level & Sex)"
'
'CourseProfileToolStripMenuItem
'
Me.CourseProfileToolStripMenuItem.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.CourseProfileToolStripMenuItem.Name = "CourseProfileToolStripMenuItem"
Me.CourseProfileToolStripMenuItem.Size = New System.Drawing.Size(408, 22)
Me.CourseProfileToolStripMenuItem.Text = "Course Profile"
'
'StudentsProfileBySexAgeHomeAddressToolStripMenuItem
'
Me.StudentsProfileBySexAgeHomeAddressToolStripMenuItem.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.StudentsProfileBySexAgeHomeAddressToolStripMenuItem.Name = "StudentsProfileBySexAgeHomeAddressToolStripMenuItem"
Me.StudentsProfileBySexAgeHomeAddressToolStripMenuItem.Size = New System.Drawing.Size(408, 22)
Me.StudentsProfileBySexAgeHomeAddressToolStripMenuItem.Text = "Student's Profile (By Sex, Age, & Home Address"
'
'EnrolmentReportbyProgramYearLevelSexToolStripMenuItem
'
Me.EnrolmentReportbyProgramYearLevelSexToolStripMenuItem.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.EnrolmentReportbyProgramYearLevelSexToolStripMenuItem.Name = "EnrolmentReportbyProgramYearLevelSexToolStripMenuItem"
Me.EnrolmentReportbyProgramYearLevelSexToolStripMenuItem.Size = New System.Drawing.Size(408, 22)
Me.EnrolmentReportbyProgramYearLevelSexToolStripMenuItem.Text = "Enrolment Report (by Program, Year Level & Sex)"
'
'EnrolmentReportByProgramMajorWLabOrNoneToolStripMenuItem
'
Me.EnrolmentReportByProgramMajorWLabOrNoneToolStripMenuItem.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.EnrolmentReportByProgramMajorWLabOrNoneToolStripMenuItem.Name = "EnrolmentReportByProgramMajorWLabOrNoneToolStripMenuItem"
Me.EnrolmentReportByProgramMajorWLabOrNoneToolStripMenuItem.Size = New System.Drawing.Size(408, 22)
Me.EnrolmentReportByProgramMajorWLabOrNoneToolStripMenuItem.Text = "Enrolment Report (By Program, Major & W/ Lab or None)"
'
'TotalEnrolledUnitsToolStripMenuItem
'
Me.TotalEnrolledUnitsToolStripMenuItem.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.TotalEnrolledUnitsToolStripMenuItem.Name = "TotalEnrolledUnitsToolStripMenuItem"
Me.TotalEnrolledUnitsToolStripMenuItem.Size = New System.Drawing.Size(408, 22)
Me.TotalEnrolledUnitsToolStripMenuItem.Text = "Total Enrolled Units (By Program, Year Level, Sex)"
'
'GradingSheetsToolStripMenuItem
'
Me.GradingSheetsToolStripMenuItem.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.GradingSheetsToolStripMenuItem.Name = "GradingSheetsToolStripMenuItem"
Me.GradingSheetsToolStripMenuItem.Size = New System.Drawing.Size(408, 22)
Me.GradingSheetsToolStripMenuItem.Text = "Grading Sheets"
'
'ReportOfRatingsToolStripMenuItem
'
Me.ReportOfRatingsToolStripMenuItem.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.ReportOfRatingsToolStripMenuItem.Name = "ReportOfRatingsToolStripMenuItem"
Me.ReportOfRatingsToolStripMenuItem.Size = New System.Drawing.Size(408, 22)
Me.ReportOfRatingsToolStripMenuItem.Text = "Report of Ratings"
'
'PromotionalReportToolStripMenuItem1
'
Me.PromotionalReportToolStripMenuItem1.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.PromotionalReportToolStripMenuItem1.Name = "PromotionalReportToolStripMenuItem1"
Me.PromotionalReportToolStripMenuItem1.Size = New System.Drawing.Size(408, 22)
Me.PromotionalReportToolStripMenuItem1.Text = "Promotional Report"
'
'GenWtdAveToolStripMenuItem
'
Me.GenWtdAveToolStripMenuItem.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.GenWtdAveToolStripMenuItem.Name = "GenWtdAveToolStripMenuItem"
Me.GenWtdAveToolStripMenuItem.Size = New System.Drawing.Size(408, 22)
Me.GenWtdAveToolStripMenuItem.Text = "Gen. Wtd. Ave."
'
'ConsilidatedStudentsIndividualPermanentRecordToolStripMenuItem
'
Me.ConsilidatedStudentsIndividualPermanentRecordToolStripMenuItem.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.ConsilidatedStudentsIndividualPermanentRecordToolStripMenuItem.Name = "ConsilidatedStudentsIndividualPermanentRecordToolStripMenuItem"
Me.ConsilidatedStudentsIndividualPermanentRecordToolStripMenuItem.Size = New System.Drawing.Size(408, 22)
Me.ConsilidatedStudentsIndividualPermanentRecordToolStripMenuItem.Text = "Consilidated Student's Individual Permanent Record"
'
'StudentsApplicationForGraduationFormIXToolStripMenuItem
'
Me.StudentsApplicationForGraduationFormIXToolStripMenuItem.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.StudentsApplicationForGraduationFormIXToolStripMenuItem.Name = "StudentsApplicationForGraduationFormIXToolStripMenuItem"
Me.StudentsApplicationForGraduationFormIXToolStripMenuItem.Size = New System.Drawing.Size(408, 22)
Me.StudentsApplicationForGraduationFormIXToolStripMenuItem.Text = "Student's Application for Graduation (Form IX)"
'
'ConsolidatedIndividualGeWtdAveForAcadAwardsToolStripMenuItem
'
Me.ConsolidatedIndividualGeWtdAveForAcadAwardsToolStripMenuItem.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.ConsolidatedIndividualGeWtdAveForAcadAwardsToolStripMenuItem.Name = "ConsolidatedIndividualGeWtdAveForAcadAwardsToolStripMenuItem"
Me.ConsolidatedIndividualGeWtdAveForAcadAwardsToolStripMenuItem.Size = New System.Drawing.Size(408, 22)
Me.ConsolidatedIndividualGeWtdAveForAcadAwardsToolStripMenuItem.Text = "Consolidated Individual Ge. Wtd. Ave. for Acad. Awards"
'
'OfficialTranscriptOfRecordsToolStripMenuItem
'
Me.OfficialTranscriptOfRecordsToolStripMenuItem.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.OfficialTranscriptOfRecordsToolStripMenuItem.Name = "OfficialTranscriptOfRecordsToolStripMenuItem"
Me.OfficialTranscriptOfRecordsToolStripMenuItem.Size = New System.Drawing.Size(408, 22)
Me.OfficialTranscriptOfRecordsToolStripMenuItem.Text = "Official Transcript Of Records"
'
'ToolStripMenuItem10
'
Me.ToolStripMenuItem10.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.SystemLoginsToolStripMenuItem, Me.SetCurrentTermYearToolStripMenuItem, Me.BackupDatabaseToolStripMenuItem})
Me.ToolStripMenuItem10.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.ToolStripMenuItem10.Name = "ToolStripMenuItem10"
Me.ToolStripMenuItem10.Size = New System.Drawing.Size(145, 20)
Me.ToolStripMenuItem10.Text = "Administrative Tasks"
'
'SystemLoginsToolStripMenuItem
'
Me.SystemLoginsToolStripMenuItem.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.SystemLoginsToolStripMenuItem.Name = "SystemLoginsToolStripMenuItem"
Me.SystemLoginsToolStripMenuItem.Size = New System.Drawing.Size(213, 22)
Me.SystemLoginsToolStripMenuItem.Text = "System Logins"
'
'SetCurrentTermYearToolStripMenuItem
'
Me.SetCurrentTermYearToolStripMenuItem.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.SetCurrentTermYearToolStripMenuItem.Name = "SetCurrentTermYearToolStripMenuItem"
Me.SetCurrentTermYearToolStripMenuItem.Size = New System.Drawing.Size(213, 22)
Me.SetCurrentTermYearToolStripMenuItem.Text = "Set Current Term/Year"
'
'HelpToolStripMenuItem
'
Me.HelpToolStripMenuItem.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.ContentsToolStripMenuItem, Me.ToolStripMenuItem5, Me.AboutToolStripMenuItem})
Me.HelpToolStripMenuItem.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.HelpToolStripMenuItem.Name = "HelpToolStripMenuItem"
Me.HelpToolStripMenuItem.Size = New System.Drawing.Size(49, 20)
Me.HelpToolStripMenuItem.Text = "&Help"
'
'ContentsToolStripMenuItem
'
Me.ContentsToolStripMenuItem.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.ContentsToolStripMenuItem.Name = "ContentsToolStripMenuItem"
Me.ContentsToolStripMenuItem.Size = New System.Drawing.Size(132, 22)
Me.ContentsToolStripMenuItem.Text = "&Contents"
'
'ToolStripMenuItem5
'
Me.ToolStripMenuItem5.Name = "ToolStripMenuItem5"
Me.ToolStripMenuItem5.Size = New System.Drawing.Size(129, 6)
'
'AboutToolStripMenuItem
'
Me.AboutToolStripMenuItem.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.AboutToolStripMenuItem.Name = "AboutToolStripMenuItem"
Me.AboutToolStripMenuItem.Size = New System.Drawing.Size(132, 22)
Me.AboutToolStripMenuItem.Text = "&About"
'
'StatusStrip1
'
Me.StatusStrip1.Font = New System.Drawing.Font("Segoe UI", 8.25!)
Me.StatusStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.ToolStripStatusLabel1})
Me.StatusStrip1.Location = New System.Drawing.Point(0, 474)
Me.StatusStrip1.Name = "StatusStrip1"
Me.StatusStrip1.RenderMode = System.Windows.Forms.ToolStripRenderMode.ManagerRenderMode
Me.StatusStrip1.Size = New System.Drawing.Size(1065, 22)
Me.StatusStrip1.TabIndex = 2
Me.StatusStrip1.Text = "StatusStrip1"
'
'ToolStripStatusLabel1
'
Me.ToolStripStatusLabel1.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.ToolStripStatusLabel1.Name = "ToolStripStatusLabel1"
Me.ToolStripStatusLabel1.Size = New System.Drawing.Size(144, 17)
Me.ToolStripStatusLabel1.Text = " ToolStripStatusLabel1"
'
'ToolStrip1
'
Me.ToolStrip1.Font = New System.Drawing.Font("Segoe UI", 8.25!)
Me.ToolStrip1.Location = New System.Drawing.Point(0, 24)
Me.ToolStrip1.Name = "ToolStrip1"
Me.ToolStrip1.Size = New System.Drawing.Size(1065, 25)
Me.ToolStrip1.TabIndex = 4
Me.ToolStrip1.Text = "ToolStrip1"
'
'SplitContainer1
'
Me.SplitContainer1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.SplitContainer1.Dock = System.Windows.Forms.DockStyle.Fill
Me.SplitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel1
Me.SplitContainer1.Location = New System.Drawing.Point(0, 49)
Me.SplitContainer1.Name = "SplitContainer1"
'
'SplitContainer1.Panel1
'
Me.SplitContainer1.Panel1.Controls.Add(Me.KryptonHeaderGroup1)
'
'SplitContainer1.Panel2
'
Me.SplitContainer1.Panel2.Controls.Add(Me.KryptonHeaderGroup2)
Me.SplitContainer1.Size = New System.Drawing.Size(1065, 425)
Me.SplitContainer1.SplitterDistance = 235
Me.SplitContainer1.TabIndex = 5
'
'KryptonHeaderGroup1
'
Me.KryptonHeaderGroup1.Dock = System.Windows.Forms.DockStyle.Fill
Me.KryptonHeaderGroup1.GroupBackStyle = ComponentFactory.Krypton.Toolkit.PaletteBackStyle.FormMain
Me.KryptonHeaderGroup1.Location = New System.Drawing.Point(0, 0)
Me.KryptonHeaderGroup1.Name = "KryptonHeaderGroup1"
'
'KryptonHeaderGroup1.Panel
'
Me.KryptonHeaderGroup1.Panel.Controls.Add(Me.cmdCourseOfferings)
Me.KryptonHeaderGroup1.Panel.Controls.Add(Me.KryptonButton2)
Me.KryptonHeaderGroup1.Size = New System.Drawing.Size(233, 423)
Me.KryptonHeaderGroup1.StateNormal.HeaderPrimary.Content.ShortText.Font = New System.Drawing.Font("Microsoft Sans Serif", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.KryptonHeaderGroup1.TabIndex = 1
Me.KryptonHeaderGroup1.Text = "Heading"
Me.KryptonHeaderGroup1.ValuesPrimary.Description = ""
Me.KryptonHeaderGroup1.ValuesPrimary.Heading = "Heading"
Me.KryptonHeaderGroup1.ValuesPrimary.Image = CType(resources.GetObject("KryptonHeaderGroup1.ValuesPrimary.Image"), System.Drawing.Image)
Me.KryptonHeaderGroup1.ValuesSecondary.Description = ""
Me.KryptonHeaderGroup1.ValuesSecondary.Heading = ""
Me.KryptonHeaderGroup1.ValuesSecondary.Image = Nothing
'
'cmdCourseOfferings
'
Me.cmdCourseOfferings.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.cmdCourseOfferings.Location = New System.Drawing.Point(46, 14)
Me.cmdCourseOfferings.Name = "cmdCourseOfferings"
Me.cmdCourseOfferings.Size = New System.Drawing.Size(140, 39)
Me.cmdCourseOfferings.StateNormal.Content.ShortText.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.cmdCourseOfferings.TabIndex = 12
Me.cmdCourseOfferings.Text = "Course Offerings"
Me.cmdCourseOfferings.Values.ExtraText = ""
Me.cmdCourseOfferings.Values.Image = CType(resources.GetObject("cmdCourseOfferings.Values.Image"), System.Drawing.Image)
Me.cmdCourseOfferings.Values.ImageStates.ImageCheckedNormal = Nothing
Me.cmdCourseOfferings.Values.ImageStates.ImageCheckedPressed = Nothing
Me.cmdCourseOfferings.Values.ImageStates.ImageCheckedTracking = Nothing
Me.cmdCourseOfferings.Values.Text = "Course Offerings"
Me.cmdCourseOfferings.Visible = False
'
'KryptonButton2
'
Me.KryptonButton2.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.KryptonButton2.Location = New System.Drawing.Point(46, 341)
Me.KryptonButton2.Name = "KryptonButton2"
Me.KryptonButton2.Size = New System.Drawing.Size(140, 39)
Me.KryptonButton2.StateNormal.Content.ShortText.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.KryptonButton2.TabIndex = 11
Me.KryptonButton2.Text = "E&xit [Esc]"
Me.KryptonButton2.Values.ExtraText = ""
Me.KryptonButton2.Values.Image = CType(resources.GetObject("KryptonButton2.Values.Image"), System.Drawing.Image)
Me.KryptonButton2.Values.ImageStates.ImageCheckedNormal = Nothing
Me.KryptonButton2.Values.ImageStates.ImageCheckedPressed = Nothing
Me.KryptonButton2.Values.ImageStates.ImageCheckedTracking = Nothing
Me.KryptonButton2.Values.Text = "E&xit [Esc]"
'
'KryptonHeaderGroup2
'
Me.KryptonHeaderGroup2.Dock = System.Windows.Forms.DockStyle.Fill
Me.KryptonHeaderGroup2.Location = New System.Drawing.Point(0, 0)
Me.KryptonHeaderGroup2.Name = "KryptonHeaderGroup2"
'
'KryptonHeaderGroup2.Panel
'
Me.KryptonHeaderGroup2.Panel.Controls.Add(Me.PictureBox1)
Me.KryptonHeaderGroup2.Panel.Controls.Add(Me.lblHeader)
Me.KryptonHeaderGroup2.Panel.Controls.Add(Me.WebMain)
Me.KryptonHeaderGroup2.Size = New System.Drawing.Size(824, 423)
Me.KryptonHeaderGroup2.StateNormal.HeaderPrimary.Content.ShortText.Font = New System.Drawing.Font("Microsoft Sans Serif", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.KryptonHeaderGroup2.TabIndex = 2
Me.KryptonHeaderGroup2.Text = "Welcome"
Me.KryptonHeaderGroup2.ValuesPrimary.Description = ""
Me.KryptonHeaderGroup2.ValuesPrimary.Heading = "Welcome"
Me.KryptonHeaderGroup2.ValuesPrimary.Image = CType(resources.GetObject("KryptonHeaderGroup2.ValuesPrimary.Image"), System.Drawing.Image)
Me.KryptonHeaderGroup2.ValuesSecondary.Description = ""
Me.KryptonHeaderGroup2.ValuesSecondary.Heading = ""
Me.KryptonHeaderGroup2.ValuesSecondary.Image = Nothing
'
'PictureBox1
'
Me.PictureBox1.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.PictureBox1.Image = CType(resources.GetObject("PictureBox1.Image"), System.Drawing.Image)
Me.PictureBox1.Location = New System.Drawing.Point(3, 34)
Me.PictureBox1.Name = "PictureBox1"
Me.PictureBox1.Size = New System.Drawing.Size(816, 359)
Me.PictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage
Me.PictureBox1.TabIndex = 4
Me.PictureBox1.TabStop = False
'
'lblHeader
'
Me.lblHeader.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.lblHeader.AutoSize = False
Me.lblHeader.HeaderStyle = ComponentFactory.Krypton.Toolkit.HeaderStyle.Secondary
Me.lblHeader.Location = New System.Drawing.Point(3, 3)
Me.lblHeader.Name = "lblHeader"
Me.lblHeader.Size = New System.Drawing.Size(816, 25)
Me.lblHeader.StateCommon.Border.DrawBorders = CType((((ComponentFactory.Krypton.Toolkit.PaletteDrawBorders.Top Or ComponentFactory.Krypton.Toolkit.PaletteDrawBorders.Bottom) _
Or ComponentFactory.Krypton.Toolkit.PaletteDrawBorders.Left) _
Or ComponentFactory.Krypton.Toolkit.PaletteDrawBorders.Right), ComponentFactory.Krypton.Toolkit.PaletteDrawBorders)
Me.lblHeader.StateCommon.Content.ShortText.Font = New System.Drawing.Font("Tahoma", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.lblHeader.TabIndex = 3
Me.lblHeader.Values.Description = ""
Me.lblHeader.Values.Heading = ""
Me.lblHeader.Values.Image = Nothing
'
'WebMain
'
Me.WebMain.Dock = System.Windows.Forms.DockStyle.Fill
Me.WebMain.IsWebBrowserContextMenuEnabled = False
Me.WebMain.Location = New System.Drawing.Point(0, 0)
Me.WebMain.MinimumSize = New System.Drawing.Size(20, 20)
Me.WebMain.Name = "WebMain"
Me.WebMain.ScriptErrorsSuppressed = True
Me.WebMain.Size = New System.Drawing.Size(822, 396)
Me.WebMain.TabIndex = 0
'
'ToolStripMenuItem19
'
Me.ToolStripMenuItem19.Name = "ToolStripMenuItem19"
Me.ToolStripMenuItem19.Size = New System.Drawing.Size(174, 6)
'
'OpenImportedDataToolStripMenuItem
'
Me.OpenImportedDataToolStripMenuItem.Font = New System.Drawing.Font("Segoe UI", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.OpenImportedDataToolStripMenuItem.Name = "OpenImportedDataToolStripMenuItem"
Me.OpenImportedDataToolStripMenuItem.Size = New System.Drawing.Size(203, 22)
Me.OpenImportedDataToolStripMenuItem.Text = "Open Imported Data"
'
'BackupDatabaseToolStripMenuItem
'
Me.BackupDatabaseToolStripMenuItem.Font = New System.Drawing.Font("Segoe UI", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.BackupDatabaseToolStripMenuItem.Name = "BackupDatabaseToolStripMenuItem"
Me.BackupDatabaseToolStripMenuItem.Size = New System.Drawing.Size(215, 22)
Me.BackupDatabaseToolStripMenuItem.Text = "Backup Database"
'
'frmMain
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(7.0!, 16.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.BackColor = System.Drawing.SystemColors.GradientInactiveCaption
Me.ClientSize = New System.Drawing.Size(1065, 496)
Me.Controls.Add(Me.SplitContainer1)
Me.Controls.Add(Me.ToolStrip1)
Me.Controls.Add(Me.StatusStrip1)
Me.Controls.Add(Me.MenuStrip1)
Me.Font = New System.Drawing.Font("Tahoma", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.IsMdiContainer = True
Me.KeyPreview = True
Me.MainMenuStrip = Me.MenuStrip1
Me.Margin = New System.Windows.Forms.Padding(3, 4, 3, 4)
Me.Name = "frmMain"
Me.Text = "electonic School Management System"
Me.WindowState = System.Windows.Forms.FormWindowState.Maximized
Me.MenuStrip1.ResumeLayout(False)
Me.MenuStrip1.PerformLayout()
Me.StatusStrip1.ResumeLayout(False)
Me.StatusStrip1.PerformLayout()
Me.SplitContainer1.Panel1.ResumeLayout(False)
Me.SplitContainer1.Panel2.ResumeLayout(False)
Me.SplitContainer1.ResumeLayout(False)
CType(Me.KryptonHeaderGroup1.Panel, System.ComponentModel.ISupportInitialize).EndInit()
Me.KryptonHeaderGroup1.Panel.ResumeLayout(False)
CType(Me.KryptonHeaderGroup1, System.ComponentModel.ISupportInitialize).EndInit()
Me.KryptonHeaderGroup1.ResumeLayout(False)
CType(Me.KryptonHeaderGroup2.Panel, System.ComponentModel.ISupportInitialize).EndInit()
Me.KryptonHeaderGroup2.Panel.ResumeLayout(False)
CType(Me.KryptonHeaderGroup2, System.ComponentModel.ISupportInitialize).EndInit()
Me.KryptonHeaderGroup2.ResumeLayout(False)
CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents MenuStrip1 As System.Windows.Forms.MenuStrip
Friend WithEvents StatusStrip1 As System.Windows.Forms.StatusStrip
Friend WithEvents ToolStripStatusLabel1 As System.Windows.Forms.ToolStripStatusLabel
Friend WithEvents ToolStrip1 As System.Windows.Forms.ToolStrip
Friend WithEvents SplitContainer1 As System.Windows.Forms.SplitContainer
Friend WithEvents SystemToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents LogInToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents LogOutToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents ToolStripMenuItem1 As System.Windows.Forms.ToolStripSeparator
Friend WithEvents ExitToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents FileToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents SubjectsToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents CoursesToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents EmployeesToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents StudentsToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents EnrollmentToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents SubjectsOfferedToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents EnrollStudentToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents ViewsToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents EnrolledStudentsToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents KryptonHeaderGroup2 As ComponentFactory.Krypton.Toolkit.KryptonHeaderGroup
Friend WithEvents WebMain As System.Windows.Forms.WebBrowser
Friend WithEvents KryptonHeaderGroup1 As ComponentFactory.Krypton.Toolkit.KryptonHeaderGroup
Friend WithEvents KryptonButton2 As ComponentFactory.Krypton.Toolkit.KryptonButton
Friend WithEvents ReportsToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents ToolStripMenuItem2 As System.Windows.Forms.ToolStripSeparator
Friend WithEvents ToolStripMenuItem3 As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents FeesToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents ToolStripMenuItem4 As System.Windows.Forms.ToolStripSeparator
Friend WithEvents GradesToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents StudentGradesToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents EnrollmentListToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents PromotionalReportToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents StudentScheduleToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents TeachersLoadToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents DatabaseSettingsToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents HelpToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents ContentsToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents ToolStripMenuItem5 As System.Windows.Forms.ToolStripSeparator
Friend WithEvents AboutToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents OtherSettingsToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents ToolStripMenuItem6 As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents lblHeader As ComponentFactory.Krypton.Toolkit.KryptonHeader
Friend WithEvents ToolStripMenuItem7 As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents ToolStripSeparator1 As System.Windows.Forms.ToolStripSeparator
Friend WithEvents CourseLoadsbyProgramYearLevelSexToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents EnrolmentSummarybyProgramYearLevelSexToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents EnrolmentHeadcountByProgramYearLevelSexToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents CourseProfileToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents StudentsProfileBySexAgeHomeAddressToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents EnrolmentReportbyProgramYearLevelSexToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents EnrolmentReportByProgramMajorWLabOrNoneToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents TotalEnrolledUnitsToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents GradingSheetsToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents ReportOfRatingsToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents PromotionalReportToolStripMenuItem1 As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents GenWtdAveToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents ConsilidatedStudentsIndividualPermanentRecordToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents StudentsApplicationForGraduationFormIXToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents ConsolidatedIndividualGeWtdAveForAcadAwardsToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents OfficialTranscriptOfRecordsToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox
Friend WithEvents FeesAmountsToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents ToolStripMenuItem8 As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents EvaluationToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents ToolStripMenuItem9 As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents ToolStripMenuItem10 As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents SystemLoginsToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents SetCurrentTermYearToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents StudentAdmissionToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents ToolStripMenuItem11 As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents StudentAdmissionToolStripMenuItem1 As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents cmdCourseOfferings As ComponentFactory.Krypton.Toolkit.KryptonButton
Friend WithEvents ToolStripMenuItem12 As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents ToolStripMenuItem13 As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents FeeToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents SemestralFeesToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents ReportsToolStripMenuItem1 As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents CourseOfferingsToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents ToolStripMenuItem14 As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents CashieringToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents ReportToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents PaymentsReceivedToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents BlockSectionsToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents AllToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents ToolStripMenuItem15 As System.Windows.Forms.ToolStripSeparator
Friend WithEvents SummaryOfEnrollmentToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents ToolStripMenuItem16 As System.Windows.Forms.ToolStripSeparator
Friend WithEvents StudentLedgersToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents ToolStripMenuItem17 As System.Windows.Forms.ToolStripSeparator
Friend WithEvents DiscountsToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents ChargesToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents ToolStripMenuItem18 As System.Windows.Forms.ToolStripSeparator
Friend WithEvents StudentLedgersToolStripMenuItem1 As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents AcceptGradToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents ListForExportToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents OpenImportedToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents ToolStripMenuItem19 As System.Windows.Forms.ToolStripSeparator
Friend WithEvents OpenImportedDataToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents BackupDatabaseToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
End Class
|
JeffreyAReyes/eSMS
|
Forms/FormsMains/frmMain.Designer.vb
|
Visual Basic
|
mit
| 76,510
|
Imports System.IO
Imports System.Runtime.InteropServices
Module Example
<STAThread()> _
Sub Main()
Dim objApplication As SolidEdgeFramework.Application = Nothing
Dim objAssemblyDocument As SolidEdgeAssembly.AssemblyDocument = Nothing
Dim objStudyOwner As SolidEdgePart.StudyOwner = Nothing
Try
OleMessageFilter.Register()
' Connect to Solid Edge
objApplication = Marshal.GetActiveObject("SolidEdge.Application")
objAssemblyDocument = objApplication.ActiveDocument
objStudyOwner = objAssemblyDocument.StudyOwner
objStudyOwner.SetAsmDefaultMaterial(objAssemblyDocument)
Catch ex As Exception
Console.WriteLine(ex.Message)
Finally
OleMessageFilter.Revoke()
End Try
End Sub
End Module
|
SolidEdgeCommunity/docs
|
docfx_project/snippets/SolidEdgePart.StudyOwner.SetAsmDefaultMaterial.vb
|
Visual Basic
|
mit
| 852
|
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class InsertSnippetForm
Inherits System.Windows.Forms.Form
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(InsertSnippetForm))
Me.CopyToClipboardBt = New System.Windows.Forms.Button()
Me.InsertAtCursorBt = New System.Windows.Forms.Button()
Me.ContentsTxt = New System.Windows.Forms.TextBox()
Me.GroupBox1 = New System.Windows.Forms.GroupBox()
Me.CancelBt = New System.Windows.Forms.Button()
Me.GroupBox1.SuspendLayout()
Me.SuspendLayout()
'
'CopyToClipboardBt
'
Me.CopyToClipboardBt.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.CopyToClipboardBt.Location = New System.Drawing.Point(261, 239)
Me.CopyToClipboardBt.Name = "CopyToClipboardBt"
Me.CopyToClipboardBt.Size = New System.Drawing.Size(107, 23)
Me.CopyToClipboardBt.TabIndex = 4
Me.CopyToClipboardBt.Text = "Copy to Clipboard"
Me.CopyToClipboardBt.UseVisualStyleBackColor = True
'
'InsertAtCursorBt
'
Me.InsertAtCursorBt.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.InsertAtCursorBt.Location = New System.Drawing.Point(148, 239)
Me.InsertAtCursorBt.Name = "InsertAtCursorBt"
Me.InsertAtCursorBt.Size = New System.Drawing.Size(107, 23)
Me.InsertAtCursorBt.TabIndex = 3
Me.InsertAtCursorBt.Text = "Insert at Cursor"
Me.InsertAtCursorBt.UseVisualStyleBackColor = True
'
'ContentsTxt
'
Me.ContentsTxt.AcceptsReturn = True
Me.ContentsTxt.AcceptsTab = True
Me.ContentsTxt.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.ContentsTxt.Location = New System.Drawing.Point(6, 19)
Me.ContentsTxt.Multiline = True
Me.ContentsTxt.Name = "ContentsTxt"
Me.ContentsTxt.ScrollBars = System.Windows.Forms.ScrollBars.Both
Me.ContentsTxt.Size = New System.Drawing.Size(457, 187)
Me.ContentsTxt.TabIndex = 6
'
'GroupBox1
'
Me.GroupBox1.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.GroupBox1.Controls.Add(Me.ContentsTxt)
Me.GroupBox1.Location = New System.Drawing.Point(12, 12)
Me.GroupBox1.Name = "GroupBox1"
Me.GroupBox1.Size = New System.Drawing.Size(469, 221)
Me.GroupBox1.TabIndex = 7
Me.GroupBox1.TabStop = False
Me.GroupBox1.Text = "Enter Text"
'
'CancelBt
'
Me.CancelBt.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.CancelBt.DialogResult = System.Windows.Forms.DialogResult.Cancel
Me.CancelBt.Location = New System.Drawing.Point(374, 239)
Me.CancelBt.Name = "CancelBt"
Me.CancelBt.Size = New System.Drawing.Size(107, 23)
Me.CancelBt.TabIndex = 8
Me.CancelBt.Text = "Cancel"
Me.CancelBt.UseVisualStyleBackColor = True
'
'InsertSnippetForm
'
Me.AcceptButton = Me.InsertAtCursorBt
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.CancelButton = Me.CancelBt
Me.ClientSize = New System.Drawing.Size(493, 272)
Me.Controls.Add(Me.CancelBt)
Me.Controls.Add(Me.GroupBox1)
Me.Controls.Add(Me.CopyToClipboardBt)
Me.Controls.Add(Me.InsertAtCursorBt)
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.Name = "InsertSnippetForm"
Me.Text = "InsertSnippetForm"
Me.GroupBox1.ResumeLayout(False)
Me.GroupBox1.PerformLayout()
Me.ResumeLayout(False)
End Sub
Friend WithEvents CopyToClipboardBt As Windows.Forms.Button
Friend WithEvents InsertAtCursorBt As Windows.Forms.Button
Friend WithEvents ContentsTxt As Windows.Forms.TextBox
Friend WithEvents GroupBox1 As Windows.Forms.GroupBox
Friend WithEvents CancelBt As Windows.Forms.Button
End Class
|
CodeExplained/WindowsLiveWriterExtentions
|
WPCodeSnippets/InsertSnippetForm.Designer.vb
|
Visual Basic
|
mit
| 5,556
|
Imports System
Imports System.Collections.Generic
Imports System.Collections.Specialized
Imports System.ComponentModel
Imports System.Data
Imports System.Data.SqlClient
Imports System.Linq
Imports Csla
Imports Csla.Data
Namespace Invoices.Business
''' <summary>
''' ProductTypeCachedList (read only list).<br/>
''' This is a generated base class of <see cref="ProductTypeCachedList"/> business object.
''' This class is a root collection.
''' </summary>
''' <remarks>
''' The items of the collection are <see cref="ProductTypeCachedInfo"/> objects.
''' Cached. Updated by ProductTypeItem
''' </remarks>
<Serializable>
Public Partial Class ProductTypeCachedList
#If WINFORMS Then
Inherits ReadOnlyBindingListBase(Of ProductTypeCachedList, ProductTypeCachedInfo)
#Else
Inherits ReadOnlyListBase(Of ProductTypeCachedList, ProductTypeCachedInfo)
#End If
#Region " Event handler properties "
<NotUndoable>
Private Shared _singleInstanceSavedHandler As Boolean = True
''' <summary>
''' Gets or sets a value indicating whether only a single instance should handle the Saved event.
''' </summary>
''' <value>
''' <c>true</c> if only a single instance should handle the Saved event; otherwise, <c>false</c>.
''' </value>
Public Shared Property SingleInstanceSavedHandler() As Boolean
Get
Return _singleInstanceSavedHandler
End Get
Set(ByVal value As Boolean)
_singleInstanceSavedHandler = value
End Set
End Property
#End Region
#Region " Collection Business Methods "
''' <summary>
''' Determines whether a <see cref="ProductTypeCachedInfo"/> item is in the collection.
''' </summary>
''' <param name="productTypeId">The ProductTypeId of the item to search for.</param>
''' <returns><c>True</c> if the ProductTypeCachedInfo is a collection item; otherwise, <c>false</c>.</returns>
Public Overloads Function Contains(productTypeId As Integer) As Boolean
For Each item As ProductTypeCachedInfo In Me
If item.ProductTypeId = productTypeId Then
Return True
End If
Next
Return False
End Function
#End Region
#Region " Private Fields "
Private Shared _list As ProductTypeCachedList
#End Region
#Region " Cache Management Methods "
''' <summary>
''' Clears the in-memory ProductTypeCachedList cache so it is reloaded on the next request.
''' </summary>
Public Shared Sub InvalidateCache()
_list = Nothing
End Sub
''' <summary>
''' Used by async loaders to load the cache.
''' </summary>
''' <param name="lst">The list to cache.</param>
Friend Shared Sub SetCache(lst As ProductTypeCachedList)
_list = lst
End Sub
Friend Shared ReadOnly Property IsCached As Boolean
Get
Return _list IsNot Nothing
End Get
End Property
#End Region
#Region " Factory Methods "
''' <summary>
''' Factory method. Loads a <see cref="ProductTypeCachedList"/> collection.
''' </summary>
''' <returns>A reference to the fetched <see cref="ProductTypeCachedList"/> collection.</returns>
Public Shared Function GetProductTypeCachedList() As ProductTypeCachedList
If _list Is Nothing Then
_list = DataPortal.Fetch(Of ProductTypeCachedList)()
End If
Return _list
End Function
''' <summary>
''' Factory method. Asynchronously loads a <see cref="ProductTypeCachedList"/> collection.
''' </summary>
''' <param name="callback">The completion callback method.</param>
Public Shared Sub GetProductTypeCachedList(ByVal callback As EventHandler(Of DataPortalResult(Of ProductTypeCachedList)))
If _list Is Nothing Then
DataPortal.BeginFetch(Of ProductTypeCachedList)(Sub(o, e)
_list = e.Object
callback(o, e)
End Sub)
Else
callback(Nothing, New DataPortalResult(Of ProductTypeCachedList)(_list, Nothing, Nothing))
End If
End Sub
#End Region
#Region " Constructor "
''' <summary>
''' Initializes a new instance of the <see cref="ProductTypeCachedList"/> class.
''' </summary>
''' <remarks> Do not use to create a Csla object. Use factory methods instead.</remarks>
<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)>
Public Sub New()
' Use factory methods and do not use direct creation.
ProductTypeItemSaved.Register(Me)
Dim rlce = RaiseListChangedEvents
RaiseListChangedEvents = False
AllowNew = False
AllowEdit = False
AllowRemove = False
RaiseListChangedEvents = rlce
End Sub
#End Region
#Region " Saved Event Handler "
''' <summary>
''' Handle Saved events of <see cref="ProductTypeItem"/> to update the list of <see cref="ProductTypeCachedInfo"/> objects.
''' </summary>
''' <param name="sender">The sender of the event.</param>
''' <param name="e">The <see cref="Csla.Core.SavedEventArgs"/> instance containing the event data.</param>
Private Sub ProductTypeItemSavedHandler(sender As Object, e As Csla.Core.SavedEventArgs)
Dim obj As ProductTypeItem = CType(e.NewObject, ProductTypeItem)
If CType(sender, ProductTypeItem).IsNew Then
IsReadOnly = False
Dim rlce As Boolean = RaiseListChangedEvents
RaiseListChangedEvents = True
Add(ProductTypeCachedInfo.LoadInfo(obj))
RaiseListChangedEvents = rlce
IsReadOnly = True
ElseIf CType(sender, ProductTypeItem).IsDeleted Then
For index = 0 To Count - 1
Dim child As ProductTypeCachedInfo = Me(index)
If child.ProductTypeId = obj.ProductTypeId Then
IsReadOnly = False
Dim rlce As Boolean = RaiseListChangedEvents
RaiseListChangedEvents = True
RemoveItem(index)
RaiseListChangedEvents = rlce
IsReadOnly = True
Exit For
End If
Next
Else
For index = 0 To Count - 1
Dim child As ProductTypeCachedInfo = Me(index)
If child.ProductTypeId = obj.ProductTypeId Then
child.UpdatePropertiesOnSaved(obj)
#If Not WINFORMS Then
Dim notifyCollectionChangedEventArgs As New NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Replace, child, child, index)
OnCollectionChanged(notifyCollectionChangedEventArgs)
#Else
Dim listChangedEventArgs As New ListChangedEventArgs(ListChangedType.ItemChanged, index)
OnListChanged(listChangedEventArgs)
#End If
Exit For
End If
Next
End If
End Sub
#End Region
#Region " Data Access "
''' <summary>
''' Loads a <see cref="ProductTypeCachedList"/> collection from the database.
''' </summary>
Protected Overloads Sub DataPortal_Fetch()
Using ctx = ConnectionManager(Of SqlConnection).GetManager("Invoices")
Using cmd = New SqlCommand("dbo.GetProductTypeCachedList", ctx.Connection)
cmd.CommandType = CommandType.StoredProcedure
Dim args As New DataPortalHookArgs(cmd)
OnFetchPre(args)
LoadCollection(cmd)
OnFetchPost(args)
End Using
End Using
End Sub
Private Sub LoadCollection(cmd As SqlCommand)
Using dr As New SafeDataReader(cmd.ExecuteReader())
Fetch(dr)
End Using
End Sub
''' <summary>
''' Loads all <see cref="ProductTypeCachedList"/> collection items from the given SafeDataReader.
''' </summary>
''' <param name="dr">The SafeDataReader to use.</param>
Private Sub Fetch(dr As SafeDataReader)
IsReadOnly = False
Dim rlce = RaiseListChangedEvents
RaiseListChangedEvents = False
While dr.Read()
Add(DataPortal.FetchChild(Of ProductTypeCachedInfo)(dr))
End While
RaiseListChangedEvents = rlce
IsReadOnly = True
End Sub
#End Region
#Region " DataPortal Hooks "
''' <summary>
''' Occurs after setting query parameters and before the fetch operation.
''' </summary>
Partial Private Sub OnFetchPre(args As DataPortalHookArgs)
End Sub
''' <summary>
''' Occurs after the fetch operation (object or collection is fully loaded and set up).
''' </summary>
Partial Private Sub OnFetchPost(args As DataPortalHookArgs)
End Sub
#End Region
#Region " ProductTypeItemSaved nested class "
'TODO: edit "ProductTypeCachedList.vb", uncomment the "OnDeserialized" method and add the following line:
'TODO: ProductTypeItemSaved.Register(Me)
''' <summary>
''' Nested class to manage the Saved events of <see cref="ProductTypeItem"/>
''' to update the list of <see cref="ProductTypeCachedInfo"/> objects.
''' </summary>
Private NotInheritable Class ProductTypeItemSaved
Private Shared _references As List(Of WeakReference)
Private Sub New()
End Sub
Private Shared Function Found(ByVal obj As Object) As Boolean
Return _references.Any(Function(reference) Equals(reference.Target, obj))
End Function
''' <summary>
''' Registers a ProductTypeCachedList instance to handle Saved events.
''' to update the list of <see cref="ProductTypeCachedInfo"/> objects.
''' </summary>
''' <param name="obj">The ProductTypeCachedList instance.</param>
Public Shared Sub Register(ByVal obj As ProductTypeCachedList)
Dim mustRegister As Boolean = _references Is Nothing
If mustRegister Then
_references = New List(Of WeakReference)()
End If
If ProductTypeCachedList.SingleInstanceSavedHandler Then
_references.Clear()
End If
If Not Found(obj) Then
_references.Add(New WeakReference(obj))
End If
If mustRegister Then
AddHandler ProductTypeItem.ProductTypeItemSaved, AddressOf ProductTypeItemSavedHandler
End If
End Sub
''' <summary>
''' Handles Saved events of <see cref="ProductTypeItem"/>.
''' </summary>
''' <param name="sender">The sender of the event.</param>
''' <param name="e">The <see cref="Csla.Core.SavedEventArgs"/> instance containing the event data.</param>
Public Shared Sub ProductTypeItemSavedHandler(ByVal sender As Object, ByVal e As Csla.Core.SavedEventArgs)
For Each reference As WeakReference In _references
If reference.IsAlive Then
CType(reference.Target, ProductTypeCachedList).ProductTypeItemSavedHandler(sender, e)
End If
Next reference
End Sub
''' <summary>
''' Removes event handling and clears all registered ProductTypeCachedList instances.
''' </summary>
Public Shared Sub Unregister()
RemoveHandler ProductTypeItem.ProductTypeItemSaved, AddressOf ProductTypeItemSavedHandler
_references = Nothing
End Sub
End Class
#End Region
End Class
End Namespace
|
CslaGenFork/CslaGenFork
|
trunk/CoverageTest/Invoices/Invoices-VB/Invoices.Business/ProductTypeCachedList.Designer.vb
|
Visual Basic
|
mit
| 12,938
|
Imports QM.PDA.BO.Context
''' <summary>
''' Login screen
''' </summary>
Public Class ViCoLogin
#Region "Properties"
Private _msbBlankNextMsg As String
Private _msbValidNextMsg As String
Private _exit As String
Private _user As BO.User
#End Region
#Region " Event Handlers "
Private Sub ViCoLogin_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
If CurrentStudy IsNot Nothing Then
lblStudyName.Text = CurrentStudy.Name
lblStudyName.Text &= String.Format("{0}({1})", vbCrLf, CurrentStudy.ShortName)
End If
cmbCode.DataSource = BO.User.GetAll
cmbCode.DisplayMember = "PDAUserName"
cmbCode.ValueMember = "PDAUserName"
btnBack.Text = Me._exit
End Sub
Private Sub ViCoLogin_Closed(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Closed
Me.InputPanel.Enabled = False
End Sub
Private Sub btnBack_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBack.Click
FormResult = FormResult.ExitApplication
Me.Close()
End Sub
Private Sub txtContraseña_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtContraseña.GotFocus
Me.InputPanel.Enabled = True
End Sub
Private Sub txtContraseña_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtContraseña.LostFocus
Me.InputPanel.Enabled = False
End Sub
#End Region
#Region " Public Methods "
Public Sub New()
' This call is required by the Windows Form Designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(Me.GetType.Namespace & ".Resources", Me.GetType.Assembly)
Me._msbBlankNextMsg = resources.GetString("vicoLogin_msbBlankNextMsg")
Me._msbValidNextMsg = resources.GetString("vicoLogin_msbValidNextMsg")
Me._exit = resources.GetString("vicoLogin_exit")
End Sub
#End Region
#Region " Protected Methods "
''' <summary>
''' Checks the username and password
''' </summary>
''' <returns><c>True</c> if valid, <c>False</c> otherwise.</returns>
Protected Overrides Function CanGoNext() As Boolean
Dim code As String = CStr(cmbCode.SelectedValue)
Dim password As String = txtContraseña.Text
If code = "" Or password = "" Then
MsgBox(_msbBlankNextMsg)
Return False
Else
_user = BO.User.Login(code, password)
If _user Is Nothing Then
MsgBox(_msbValidNextMsg)
Return False
End If
End If
Return True
End Function
''' <summary>
''' Set the current user
''' </summary>
Protected Overrides Sub GoNext()
CurrentUser = _user
End Sub
#End Region
End Class
|
QMDevTeam/QMPDA
|
QM.PDA.App/ViCoLogin.vb
|
Visual Basic
|
apache-2.0
| 2,986
|
Imports System.Collections.Generic
Public Interface IRelatedObject
Sub RegisterChildObject(ByVal child As IRelatedObject, Optional ByVal childPostingType As RelatedPostOrder = RelatedPostOrder.PostFirst)
Sub UnRegisterChildObject(ByVal child As IRelatedObject)
Function HasChanges() As Boolean
Function ValidateData() As Boolean
Function LoadData(ByRef id As Object) As Boolean
Function GetChildKey(ByVal child As IRelatedObject) As Object
Property DBService() As db.BaseDbService
Property ParentObject() As IRelatedObject
Property baseDataSet() As DataSet
Property [ReadOnly]() As Boolean
ReadOnly Property Children() As List(Of IRelatedObject)
End Interface
|
EIDSS/EIDSS-Legacy
|
EIDSS v5/vb/Shared/bvwin_common/BaseForms/IRelatedForm.vb
|
Visual Basic
|
bsd-2-clause
| 720
|
Imports System.IO
Imports System.Runtime.InteropServices
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim objApplication As SolidEdgeFramework.Application = Nothing
Dim SEInstallDir As DirectoryInfo
Dim objAssemblyDocument As SolidEdgeAssembly.AssemblyDocument = Nothing
Dim objAsmPatterns As SolidEdgeAssembly.AssemblyPatterns = Nothing
Dim objAsmPattern As SolidEdgeAssembly.AssemblyPattern = Nothing
Dim PartsToPattern(3) As Object
Dim ToOccurrences(2) As Object
Dim FromOccurrence As Object
Try
' Create/get the application with specific settings
objApplication = Marshal.GetActiveObject("SolidEdge.Application")
SEInstallDir = GetTrainingFolder()
' open the document.
objAssemblyDocument = objApplication.Documents.Open(SEInstallDir.FullName + "\carrier.asm")
PartsToPattern(0) = objAssemblyDocument.Occurrences.Item(1)
ToOccurrences(0) = objAssemblyDocument.Occurrences.Item(4)
objAsmPatterns = objAssemblyDocument.AssemblyPatterns
FromOccurrence = objAssemblyDocument.Occurrences.Item(3)
objAsmPattern = objAsmPatterns.CreateDuplicate("Duplicate Test", 1, PartsToPattern, FromOccurrence, 1, ToOccurrences)
Dim msg = MsgBox("Do you want to edit this duplicate Component?", MsgBoxStyle.YesNo, "Create Duplicate")
If msg = MsgBoxResult.Yes Then
objAsmPattern.EditDuplicate(1, PartsToPattern, FromOccurrence, 1, ToOccurrences, "Rename Duplicate")
End If
objAssemblyDocument.UpdatePathfinder(SolidEdgeAssembly.AssemblyPathfinderUpdateConstants.seRebuild)
Catch ex As Exception
MsgBox(Err.ToString)
End Try
End Sub
Function GetTrainingFolder() As DirectoryInfo
Dim objInstallData As SEInstallDataLib.SEInstallData = Nothing
Dim objInstallFolder As DirectoryInfo = Nothing
Dim objTrainingFolder As DirectoryInfo = Nothing
Try
objInstallData = New SEInstallDataLib.SEInstallData
objInstallFolder = New DirectoryInfo(objInstallData.GetInstalledPath())
objTrainingFolder = New DirectoryInfo(Path.Combine(objInstallFolder.Parent.FullName, "Training"))
Catch
Finally
If Not (objInstallData Is Nothing) Then
Marshal.FinalReleaseComObject(objInstallData)
objInstallData = Nothing
End If
End Try
Return objTrainingFolder
End Function
End Class
|
SolidEdgeCommunity/docs
|
docfx_project/snippets/SolidEdgeAssembly.AssemblyPatterns.CreateDuplicate.vb
|
Visual Basic
|
mit
| 2,669
|
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System.Collections.Immutable
Imports System.Composition
Imports System.Runtime.InteropServices
Imports System.Threading
Imports Microsoft.CodeAnalysis.Differencing
Imports Microsoft.CodeAnalysis.EditAndContinue
Imports Microsoft.CodeAnalysis.Host.Mef
Imports Microsoft.CodeAnalysis.Text
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Namespace Microsoft.CodeAnalysis.VisualBasic.EditAndContinue
<ExportLanguageService(GetType(IEditAndContinueAnalyzer), LanguageNames.VisualBasic), [Shared]>
Friend NotInheritable Class VisualBasicEditAndContinueAnalyzer
Inherits AbstractEditAndContinueAnalyzer
#Region "Syntax Analysis"
''' <returns>
''' <see cref="MethodBlockBaseSyntax"/> for methods, constructors, operators and accessors.
''' <see cref="PropertyStatementSyntax"/> for auto-properties.
''' <see cref="VariableDeclaratorSyntax"/> for fields with simple initialization "Dim a = 1", or "Dim a As New C"
''' <see cref="ModifiedIdentifierSyntax"/> for fields with shared AsNew initialization "Dim a, b As New C" or array initializer "Dim a(n), b(n)".
''' A null reference otherwise.
''' </returns>
Friend Overrides Function FindMemberDeclaration(rootOpt As SyntaxNode, node As SyntaxNode) As SyntaxNode
While node IsNot rootOpt
Select Case node.Kind
Case SyntaxKind.SubBlock,
SyntaxKind.FunctionBlock,
SyntaxKind.ConstructorBlock,
SyntaxKind.OperatorBlock,
SyntaxKind.GetAccessorBlock,
SyntaxKind.SetAccessorBlock,
SyntaxKind.AddHandlerAccessorBlock,
SyntaxKind.RemoveHandlerAccessorBlock,
SyntaxKind.RaiseEventAccessorBlock
Return node
Case SyntaxKind.PropertyStatement
' Property [|a As Integer = 1|]
' Property [|a As New C()|]
If Not node.Parent.IsKind(SyntaxKind.PropertyBlock) Then
Return node
End If
Case SyntaxKind.VariableDeclarator
If node.Parent.IsKind(SyntaxKind.FieldDeclaration) Then
' Dim [|a = 0|]
' Dim [|a = 0|], [|b = 0|]
' Dim [|b as Integer = 0|]
' Dim [|v1 As New C|]
' Dim v1, v2 As New C(Sub [|Foo()|])
Return node
End If
Case SyntaxKind.ModifiedIdentifier
' Dim [|a(n)|], [|b(n)|] As Integer
' Dim [|v1|], [|v2|] As New C
If Not node.Parent.Parent.IsKind(SyntaxKind.FieldDeclaration) Then
Exit Select
End If
If DirectCast(node, ModifiedIdentifierSyntax).ArrayBounds IsNot Nothing OrElse
DirectCast(node.Parent, VariableDeclaratorSyntax).Names.Count > 1 Then
Return node
End If
End Select
node = node.Parent
End While
Return Nothing
End Function
''' <returns>
''' Given a node representing a declaration (<paramref name="isMember"/> = true) or a top-level edit node (<paramref name="isMember"/> = false) returns:
''' - <see cref="MethodBlockBaseSyntax"/> for methods, constructors, operators and accessors.
''' - <see cref="ExpressionSyntax"/> for auto-properties and fields with initializer or AsNew clause.
''' - <see cref="ArgumentListSyntax"/> for fields with array initializer, e.g. "Dim a(1) As Integer".
''' A null reference otherwise.
''' </returns>
Friend Overrides Function TryGetDeclarationBody(node As SyntaxNode, isMember As Boolean) As SyntaxNode
Select Case node.Kind
Case SyntaxKind.SubBlock,
SyntaxKind.FunctionBlock,
SyntaxKind.ConstructorBlock,
SyntaxKind.OperatorBlock,
SyntaxKind.GetAccessorBlock,
SyntaxKind.SetAccessorBlock,
SyntaxKind.AddHandlerAccessorBlock,
SyntaxKind.RemoveHandlerAccessorBlock,
SyntaxKind.RaiseEventAccessorBlock
' the body is the Statements list of the block
Return node
Case SyntaxKind.PropertyStatement
' the body is the initializer expression/new expression (if any)
Dim propertyStatement = DirectCast(node, PropertyStatementSyntax)
If propertyStatement.Initializer IsNot Nothing Then
Return propertyStatement.Initializer.Value
End If
If HasAsNewClause(propertyStatement) Then
Return DirectCast(propertyStatement.AsClause, AsNewClauseSyntax).NewExpression
End If
Return Nothing
Case SyntaxKind.VariableDeclarator
If Not node.Parent.IsKind(SyntaxKind.FieldDeclaration) Then
Return Nothing
End If
' Dim a = initializer
Dim variableDeclarator = DirectCast(node, VariableDeclaratorSyntax)
If variableDeclarator.Initializer IsNot Nothing Then
Return variableDeclarator.Initializer.Value
End If
If HasAsNewClause(variableDeclarator) Then
' Dim a As New C()
' Dim a, b As New C(), but only if the specified node isn't already a member declaration representative.
' -- This is to handle an edit in AsNew clause because such an edit doesn't affect the modified identifier that would otherwise represent the member.
If variableDeclarator.Names.Count = 1 OrElse Not isMember Then
Return DirectCast(variableDeclarator.AsClause, AsNewClauseSyntax).NewExpression
End If
End If
Return Nothing
Case SyntaxKind.ModifiedIdentifier
If Not node.Parent.Parent.IsKind(SyntaxKind.FieldDeclaration) Then
Return Nothing
End If
' Dim a, b As New C()
Dim variableDeclarator = DirectCast(node.Parent, VariableDeclaratorSyntax)
If HasMultiAsNewInitializer(variableDeclarator) Then
Return DirectCast(variableDeclarator.AsClause, AsNewClauseSyntax).NewExpression
End If
' Dim a(n)
' Dim a(n), b(n) As Integer
' Dim a(n1, n2, n3) As Integer
Dim modifiedIdentifier = DirectCast(node, ModifiedIdentifierSyntax)
If modifiedIdentifier.ArrayBounds IsNot Nothing Then
Return modifiedIdentifier.ArrayBounds
End If
Return Nothing
Case Else
' Note: A method without body is represented by a SubStatement.
Return Nothing
End Select
End Function
Protected Overrides Function GetCapturedVariables(model As SemanticModel, memberBody As SyntaxNode) As ImmutableArray(Of ISymbol)
Dim methodBlock = TryCast(memberBody, MethodBlockBaseSyntax)
If methodBlock IsNot Nothing Then
If methodBlock.Statements.IsEmpty Then
Return ImmutableArray(Of ISymbol).Empty
End If
Return model.AnalyzeDataFlow(methodBlock.Statements.First, methodBlock.Statements.Last).Captured
End If
Dim expression = TryCast(memberBody, ExpressionSyntax)
If expression IsNot Nothing Then
Return model.AnalyzeDataFlow(expression).Captured
End If
' Edge case, no need to be efficient, currently there can either be no captured variables or just "Me".
' Dim a((Function(n) n + 1).Invoke(1), (Function(n) n + 2).Invoke(2)) As Integer
Dim arrayBounds = TryCast(memberBody, ArgumentListSyntax)
If arrayBounds IsNot Nothing Then
Return ImmutableArray.CreateRange(
arrayBounds.Arguments.
SelectMany(AddressOf GetArgumentExpressions).
SelectMany(Function(expr) model.AnalyzeDataFlow(expr).Captured).
Distinct())
End If
Throw ExceptionUtilities.UnexpectedValue(memberBody)
End Function
Private Shared Iterator Function GetArgumentExpressions(argument As ArgumentSyntax) As IEnumerable(Of ExpressionSyntax)
Select Case argument.Kind
Case SyntaxKind.SimpleArgument
Yield DirectCast(argument, SimpleArgumentSyntax).Expression
Case SyntaxKind.RangeArgument
Dim range = DirectCast(argument, RangeArgumentSyntax)
Yield range.LowerBound
Yield range.UpperBound
Case SyntaxKind.OmittedArgument
Case Else
Throw ExceptionUtilities.UnexpectedValue(argument.Kind)
End Select
End Function
Friend Overrides Function HasParameterClosureScope(member As ISymbol) As Boolean
Return False
End Function
Protected Overrides Function GetVariableUseSites(roots As IEnumerable(Of SyntaxNode), localOrParameter As ISymbol, model As SemanticModel, cancellationToken As CancellationToken) As IEnumerable(Of SyntaxNode)
Debug.Assert(TypeOf localOrParameter Is IParameterSymbol OrElse TypeOf localOrParameter Is ILocalSymbol OrElse TypeOf localOrParameter Is IRangeVariableSymbol)
' Not supported (it's non trivial to find all places where "this" is used):
Debug.Assert(Not localOrParameter.IsThisParameter())
Return From root In roots
From node In root.DescendantNodesAndSelf()
Where node.IsKind(SyntaxKind.IdentifierName)
Let identifier = DirectCast(node, IdentifierNameSyntax)
Where String.Equals(DirectCast(identifier.Identifier.Value, String), localOrParameter.Name, StringComparison.OrdinalIgnoreCase) AndAlso
If(model.GetSymbolInfo(identifier, cancellationToken).Symbol?.Equals(localOrParameter), False)
Select node
End Function
Private Shared Function HasSimpleAsNewInitializer(variableDeclarator As VariableDeclaratorSyntax) As Boolean
Return variableDeclarator.Names.Count = 1 AndAlso HasAsNewClause(variableDeclarator)
End Function
Private Shared Function HasMultiAsNewInitializer(variableDeclarator As VariableDeclaratorSyntax) As Boolean
Return variableDeclarator.Names.Count > 1 AndAlso HasAsNewClause(variableDeclarator)
End Function
Private Shared Function HasAsNewClause(variableDeclarator As VariableDeclaratorSyntax) As Boolean
Return variableDeclarator.AsClause IsNot Nothing AndAlso variableDeclarator.AsClause.IsKind(SyntaxKind.AsNewClause)
End Function
Private Shared Function HasAsNewClause(propertyStatement As PropertyStatementSyntax) As Boolean
Return propertyStatement.AsClause IsNot Nothing AndAlso propertyStatement.AsClause.IsKind(SyntaxKind.AsNewClause)
End Function
''' <returns>
''' Methods, operators, constructors, property and event accessors:
''' - We need to return the entire block declaration since the Begin and End statements are covered by breakpoint spans.
''' Field declarations in form of "Dim a, b, c As New C()"
''' - Breakpoint spans cover "a", "b" and "c" and also "New C()" since the expression may contain lambdas.
''' For simplicity we don't allow moving the new expression independently of the field name.
''' Field declarations with array initializers "Dim a(n), b(n) As Integer"
''' - Breakpoint spans cover "a(n)" and "b(n)".
''' </returns>
Friend Overrides Function TryGetActiveTokens(node As SyntaxNode) As IEnumerable(Of SyntaxToken)
Select Case node.Kind
Case SyntaxKind.SubBlock,
SyntaxKind.FunctionBlock,
SyntaxKind.ConstructorBlock,
SyntaxKind.OperatorBlock,
SyntaxKind.GetAccessorBlock,
SyntaxKind.SetAccessorBlock,
SyntaxKind.AddHandlerAccessorBlock,
SyntaxKind.RemoveHandlerAccessorBlock,
SyntaxKind.RaiseEventAccessorBlock
' the body is the Statements list of the block
Return node.DescendantTokens()
Case SyntaxKind.PropertyStatement
' Property: Attributes Modifiers [|Identifier AsClause Initializer|] ImplementsClause
' Property: Attributes Modifiers [|Identifier$ Initializer|] ImplementsClause
Dim propertyStatement = DirectCast(node, PropertyStatementSyntax)
If propertyStatement.Initializer IsNot Nothing Then
Return {propertyStatement.Identifier}.Concat(If(propertyStatement.AsClause?.DescendantTokens(),
Array.Empty(Of SyntaxToken))).Concat(propertyStatement.Initializer.DescendantTokens())
End If
If HasAsNewClause(propertyStatement) Then
Return {propertyStatement.Identifier}.Concat(propertyStatement.AsClause.DescendantTokens())
End If
Return Nothing
Case SyntaxKind.VariableDeclarator
If Not node.Parent.IsKind(SyntaxKind.FieldDeclaration) Then
Return Nothing
End If
' Field: Attributes Modifiers Declarators
Dim fieldDeclaration = DirectCast(node.Parent, FieldDeclarationSyntax)
If fieldDeclaration.Modifiers.Any(SyntaxKind.ConstKeyword) Then
Return Nothing
End If
' Dim a = initializer
Dim variableDeclarator = DirectCast(node, VariableDeclaratorSyntax)
If variableDeclarator.Initializer IsNot Nothing Then
Return variableDeclarator.DescendantTokens()
End If
' Dim a As New C()
If HasSimpleAsNewInitializer(variableDeclarator) Then
Return variableDeclarator.DescendantTokens()
End If
Return Nothing
Case SyntaxKind.ModifiedIdentifier
If Not node.Parent.Parent.IsKind(SyntaxKind.FieldDeclaration) Then
Return Nothing
End If
' Dim a, b As New C()
Dim variableDeclarator = DirectCast(node.Parent, VariableDeclaratorSyntax)
If HasMultiAsNewInitializer(variableDeclarator) Then
Return node.DescendantTokens().Concat(DirectCast(variableDeclarator.AsClause, AsNewClauseSyntax).NewExpression.DescendantTokens())
End If
' Dim a(n)
' Dim a(n), b(n) As Integer
Dim modifiedIdentifier = DirectCast(node, ModifiedIdentifierSyntax)
If modifiedIdentifier.ArrayBounds IsNot Nothing Then
Return node.DescendantTokens()
End If
Return Nothing
Case Else
Return Nothing
End Select
End Function
Protected Overrides Function GetEncompassingAncestorImpl(bodyOrMatchRoot As SyntaxNode) As SyntaxNode
' AsNewClause is a match root for field/property As New initializer
' EqualsClause is a match root for field/property initializer
If bodyOrMatchRoot.IsKind(SyntaxKind.AsNewClause) OrElse bodyOrMatchRoot.IsKind(SyntaxKind.EqualsValue) Then
Debug.Assert(bodyOrMatchRoot.Parent.IsKind(SyntaxKind.VariableDeclarator) OrElse
bodyOrMatchRoot.Parent.IsKind(SyntaxKind.PropertyStatement))
Return bodyOrMatchRoot.Parent
End If
' ArgumentList is a match root for an array initialized field
If bodyOrMatchRoot.IsKind(SyntaxKind.ArgumentList) Then
Debug.Assert(bodyOrMatchRoot.Parent.IsKind(SyntaxKind.ModifiedIdentifier))
Return bodyOrMatchRoot.Parent
End If
' The following active nodes are outside of the initializer body,
' we need to return a node that encompasses them.
' Dim [|a = <<Body>>|]
' Dim [|a As Integer = <<Body>>|]
' Dim [|a As <<Body>>|]
' Dim [|a|], [|b|], [|c|] As <<Body>>
' Property [|P As Integer = <<Body>>|]
' Property [|P As <<Body>>|]
If bodyOrMatchRoot.Parent.IsKind(SyntaxKind.AsNewClause) OrElse
bodyOrMatchRoot.Parent.IsKind(SyntaxKind.EqualsValue) Then
Return bodyOrMatchRoot.Parent.Parent
End If
Return bodyOrMatchRoot
End Function
Protected Overrides Function FindStatementAndPartner(declarationBody As SyntaxNode,
position As Integer,
partnerDeclarationBodyOpt As SyntaxNode,
<Out> ByRef partnerOpt As SyntaxNode,
<Out> ByRef statementPart As Integer) As SyntaxNode
SyntaxUtilities.AssertIsBody(declarationBody, allowLambda:=False)
Debug.Assert(partnerDeclarationBodyOpt Is Nothing OrElse partnerDeclarationBodyOpt.RawKind = declarationBody.RawKind)
' Only field and property initializers may have an [|active statement|] starting outside of the <<body>>.
' Simple field initializers: Dim [|a = <<expr>>|]
' Dim [|a As Integer = <<expr>>|]
' Dim [|a = <<expr>>|], [|b = <<expr>>|], [|c As Integer = <<expr>>|]
' Dim [|a As <<New C>>|]
' Array initialized fields: Dim [|a<<(array bounds)>>|] As Integer
' Shared initializers: Dim [|a|], [|b|] As <<New C(Function() [|...|])>>
' Property initializers: Property [|p As Integer = <<body>>|]
' Property [|p As <<New C()>>|]
If position < declarationBody.SpanStart Then
If declarationBody.Parent.Parent.IsKind(SyntaxKind.PropertyStatement) Then
' Property [|p As Integer = <<body>>|]
' Property [|p As <<New C()>>|]
If partnerDeclarationBodyOpt IsNot Nothing Then
partnerOpt = partnerDeclarationBodyOpt.Parent.Parent
End If
Debug.Assert(declarationBody.Parent.Parent.IsKind(SyntaxKind.PropertyStatement))
Return declarationBody.Parent.Parent
End If
If declarationBody.IsKind(SyntaxKind.ArgumentList) Then
' Dim a<<ArgumentList>> As Integer
If partnerDeclarationBodyOpt IsNot Nothing Then
partnerOpt = partnerDeclarationBodyOpt.Parent
End If
Debug.Assert(declarationBody.Parent.IsKind(SyntaxKind.ModifiedIdentifier))
Return declarationBody.Parent
End If
If declarationBody.Parent.IsKind(SyntaxKind.AsNewClause) Then
Dim variableDeclarator = DirectCast(declarationBody.Parent.Parent, VariableDeclaratorSyntax)
If variableDeclarator.Names.Count > 1 Then
' Dim a, b, c As <<NewExpression>>
Dim nameIndex = GetItemIndexByPosition(variableDeclarator.Names, position)
If partnerDeclarationBodyOpt IsNot Nothing Then
partnerOpt = DirectCast(partnerDeclarationBodyOpt.Parent.Parent, VariableDeclaratorSyntax).Names(nameIndex)
End If
Return variableDeclarator.Names(nameIndex)
Else
If partnerDeclarationBodyOpt IsNot Nothing Then
partnerOpt = partnerDeclarationBodyOpt.Parent.Parent
End If
' Dim a As <<NewExpression>>
Return variableDeclarator
End If
End If
If declarationBody.Parent.IsKind(SyntaxKind.EqualsValue) Then
Debug.Assert(declarationBody.Parent.Parent.IsKind(SyntaxKind.VariableDeclarator) AndAlso
declarationBody.Parent.Parent.Parent.IsKind(SyntaxKind.FieldDeclaration))
If partnerDeclarationBodyOpt IsNot Nothing Then
partnerOpt = partnerDeclarationBodyOpt.Parent.Parent
End If
Return declarationBody.Parent.Parent
End If
End If
If Not declarationBody.FullSpan.Contains(position) Then
' invalid position, let's find a labeled node that encompasses the body:
position = declarationBody.SpanStart
End If
Dim node As SyntaxNode = Nothing
If partnerDeclarationBodyOpt IsNot Nothing Then
SyntaxUtilities.FindLeafNodeAndPartner(declarationBody, position, partnerDeclarationBodyOpt, node, partnerOpt)
Else
node = declarationBody.FindToken(position).Parent
partnerOpt = Nothing
End If
Debug.Assert(node IsNot Nothing)
While node IsNot declarationBody AndAlso
Not StatementSyntaxComparer.HasLabel(node) AndAlso
Not LambdaUtilities.IsLambdaBodyStatementOrExpression(node)
node = node.Parent
If partnerOpt IsNot Nothing Then
partnerOpt = partnerOpt.Parent
End If
End While
' In case of local variable declaration an active statement may start with a modified identifier.
' If it is a declaration with a simple initializer we want the resulting statement to be the declaration,
' not the identifier.
If node.IsKind(SyntaxKind.ModifiedIdentifier) AndAlso
node.Parent.IsKind(SyntaxKind.VariableDeclarator) AndAlso
DirectCast(node.Parent, VariableDeclaratorSyntax).Names.Count = 1 Then
node = node.Parent
End If
Return node
End Function
Friend Overrides Function FindPartnerInMemberInitializer(leftModel As SemanticModel, leftType As INamedTypeSymbol, leftNode As SyntaxNode, rightType As INamedTypeSymbol, cancellationToken As CancellationToken) As SyntaxNode
Dim leftInitializer = leftNode.FirstAncestorOrSelf(Of SyntaxNode)(
Function(node)
Return node.IsKind(SyntaxKind.EqualsValue) AndAlso (node.Parent.Parent.IsKind(SyntaxKind.FieldDeclaration) OrElse node.Parent.IsKind(SyntaxKind.PropertyStatement)) OrElse
node.IsKind(SyntaxKind.AsNewClause) AndAlso node.Parent.Parent.IsKind(SyntaxKind.FieldDeclaration) OrElse
IsArrayBoundsArgument(node)
End Function)
If leftInitializer Is Nothing Then
Return Nothing
End If
Dim rightInitializer As SyntaxNode
If leftInitializer.Parent.IsKind(SyntaxKind.PropertyStatement) Then
' property initializer
Dim leftDeclaration = DirectCast(leftInitializer.Parent, PropertyStatementSyntax)
Dim leftSymbol = leftModel.GetDeclaredSymbol(leftDeclaration, cancellationToken)
Debug.Assert(leftSymbol IsNot Nothing)
Dim rightProperty = rightType.GetMembers(leftSymbol.Name).Single()
Dim rightDeclaration = DirectCast(GetSymbolSyntax(rightProperty, cancellationToken), PropertyStatementSyntax)
rightInitializer = rightDeclaration.Initializer
ElseIf leftInitializer.Parent.Parent.IsKind(SyntaxKind.FieldDeclaration)
' field initializer or AsNewClause
Dim leftDeclarator = DirectCast(leftInitializer.Parent, VariableDeclaratorSyntax)
Dim leftSymbol = leftModel.GetDeclaredSymbol(leftDeclarator.Names.First(), cancellationToken)
Debug.Assert(leftSymbol IsNot Nothing)
Dim rightSymbol = rightType.GetMembers(leftSymbol.Name).Single()
Dim rightDeclarator = DirectCast(GetSymbolSyntax(rightSymbol, cancellationToken).Parent, VariableDeclaratorSyntax)
rightInitializer = If(leftInitializer.IsKind(SyntaxKind.EqualsValue), rightDeclarator.Initializer, DirectCast(rightDeclarator.AsClause, SyntaxNode))
Else
' ArrayBounds argument
Dim leftArguments = DirectCast(leftInitializer.Parent, ArgumentListSyntax)
Dim argumentIndex = GetItemIndexByPosition(leftArguments.Arguments, leftInitializer.Span.Start)
Dim leftIdentifier = leftArguments.Parent
Debug.Assert(leftIdentifier.IsKind(SyntaxKind.ModifiedIdentifier))
Dim leftSymbol = leftModel.GetDeclaredSymbol(leftIdentifier, cancellationToken)
Debug.Assert(leftSymbol IsNot Nothing)
Dim rightSymbol = rightType.GetMembers(leftSymbol.Name).Single()
Dim rightIdentifier = DirectCast(GetSymbolSyntax(rightSymbol, cancellationToken), ModifiedIdentifierSyntax)
rightInitializer = rightIdentifier.ArrayBounds.Arguments(argumentIndex)
End If
If rightInitializer Is Nothing Then
Return Nothing
End If
Return FindPartner(leftInitializer, rightInitializer, leftNode)
End Function
Friend Overrides Function FindPartner(leftRoot As SyntaxNode, rightRoot As SyntaxNode, leftNode As SyntaxNode) As SyntaxNode
Return SyntaxUtilities.FindPartner(leftRoot, rightRoot, leftNode)
End Function
Private Shared Function IsArrayBoundsArgument(node As SyntaxNode) As Boolean
Dim argumentSyntax = TryCast(node, ArgumentSyntax)
If argumentSyntax IsNot Nothing Then
Debug.Assert(argumentSyntax.Parent.IsKind(SyntaxKind.ArgumentList))
Dim identifier = argumentSyntax.Parent.Parent
Return identifier.IsKind(SyntaxKind.ModifiedIdentifier) AndAlso identifier.Parent.Parent.IsKind(SyntaxKind.FieldDeclaration)
End If
Return False
End Function
Friend Overrides Function IsClosureScope(node As SyntaxNode) As Boolean
Return LambdaUtilities.IsClosureScope(node)
End Function
Protected Overrides Function FindEnclosingLambdaBody(containerOpt As SyntaxNode, node As SyntaxNode) As SyntaxNode
Dim root As SyntaxNode = GetEncompassingAncestor(containerOpt)
While node IsNot root And node IsNot Nothing
Dim body As SyntaxNode = Nothing
If LambdaUtilities.IsLambdaBodyStatementOrExpression(node, body) Then
Return body
End If
node = node.Parent
End While
Return Nothing
End Function
Protected Overrides Function TryGetPartnerLambdaBody(oldBody As SyntaxNode, newLambda As SyntaxNode) As SyntaxNode
Return LambdaUtilities.GetCorrespondingLambdaBody(oldBody, newLambda)
End Function
Protected Overrides Function ComputeTopLevelMatch(oldCompilationUnit As SyntaxNode, newCompilationUnit As SyntaxNode) As Match(Of SyntaxNode)
Return TopSyntaxComparer.Instance.ComputeMatch(oldCompilationUnit, newCompilationUnit)
End Function
Protected Overrides Function ComputeBodyMatch(oldBody As SyntaxNode, newBody As SyntaxNode, knownMatches As IEnumerable(Of KeyValuePair(Of SyntaxNode, SyntaxNode))) As Match(Of SyntaxNode)
SyntaxUtilities.AssertIsBody(oldBody, allowLambda:=True)
SyntaxUtilities.AssertIsBody(newBody, allowLambda:=True)
Debug.Assert((TypeOf oldBody.Parent Is LambdaExpressionSyntax) = (TypeOf oldBody.Parent Is LambdaExpressionSyntax))
Debug.Assert((TypeOf oldBody Is ExpressionSyntax) = (TypeOf newBody Is ExpressionSyntax))
Debug.Assert((TypeOf oldBody Is ArgumentListSyntax) = (TypeOf newBody Is ArgumentListSyntax))
If TypeOf oldBody.Parent Is LambdaExpressionSyntax Then
' The root is a single/multi line sub/function lambda.
Return New StatementSyntaxComparer(oldBody.Parent, oldBody.Parent.ChildNodes(), newBody.Parent, newBody.Parent.ChildNodes(), matchingLambdas:=True).
ComputeMatch(oldBody.Parent, newBody.Parent, knownMatches)
End If
If TypeOf oldBody Is ExpressionSyntax Then
' Dim a = <Expression>
' Dim a As <NewExpression>
' Dim a, b, c As <NewExpression>
' Queries: The root is a query clause, the body is the expression.
Return New StatementSyntaxComparer(oldBody.Parent, {oldBody}, newBody.Parent, {newBody}, matchingLambdas:=False).
ComputeMatch(oldBody.Parent, newBody.Parent, knownMatches)
End If
' Method, accessor, operator, etc. bodies are represented by the declaring block, which is also the root.
' The body of an array initialized fields is an ArgumentListSyntax, which is the match root.
Return StatementSyntaxComparer.Default.ComputeMatch(oldBody, newBody, knownMatches)
End Function
Protected Overrides Function TryMatchActiveStatement(oldStatement As SyntaxNode,
statementPart As Integer,
oldBody As SyntaxNode,
newBody As SyntaxNode,
<Out> ByRef newStatement As SyntaxNode) As Boolean
SyntaxUtilities.AssertIsBody(oldBody, allowLambda:=True)
SyntaxUtilities.AssertIsBody(newBody, allowLambda:=True)
' only statements in bodies of the same kind can be matched
Debug.Assert((TypeOf oldBody Is MethodBlockBaseSyntax) = (TypeOf newBody Is MethodBlockBaseSyntax))
Debug.Assert((TypeOf oldBody Is ExpressionSyntax) = (TypeOf newBody Is ExpressionSyntax))
Debug.Assert((TypeOf oldBody Is ArgumentListSyntax) = (TypeOf newBody Is ArgumentListSyntax))
Debug.Assert((TypeOf oldBody Is LambdaHeaderSyntax) = (TypeOf newBody Is LambdaHeaderSyntax))
Debug.Assert(oldBody.Parent.Parent.Parent.IsKind(SyntaxKind.FieldDeclaration) = newBody.Parent.Parent.Parent.IsKind(SyntaxKind.FieldDeclaration))
Debug.Assert(oldBody.Parent.Parent.IsKind(SyntaxKind.PropertyStatement) = newBody.Parent.Parent.IsKind(SyntaxKind.PropertyStatement))
' methods
If TypeOf oldBody Is MethodBlockBaseSyntax Then
newStatement = Nothing
Return False
End If
' lambdas
If oldBody.IsKind(SyntaxKind.FunctionLambdaHeader) OrElse oldBody.IsKind(SyntaxKind.SubLambdaHeader) Then
Dim oldSingleLineLambda = TryCast(oldBody.Parent, SingleLineLambdaExpressionSyntax)
Dim newSingleLineLambda = TryCast(newBody.Parent, SingleLineLambdaExpressionSyntax)
If oldSingleLineLambda IsNot Nothing AndAlso
newSingleLineLambda IsNot Nothing AndAlso
oldStatement Is oldSingleLineLambda.Body Then
newStatement = newSingleLineLambda.Body
Return True
End If
newStatement = Nothing
Return False
End If
' array initialized fields
If newBody.IsKind(SyntaxKind.ArgumentList) Then
' the parent ModifiedIdentifier is the active statement
If oldStatement Is oldBody.Parent Then
newStatement = newBody.Parent
Return True
End If
newStatement = Nothing
Return False
End If
' field and property initializers
If TypeOf newBody Is ExpressionSyntax Then
If newBody.Parent.Parent.Parent.IsKind(SyntaxKind.FieldDeclaration) Then
' field
Dim newDeclarator = DirectCast(newBody.Parent.Parent, VariableDeclaratorSyntax)
Dim oldName As SyntaxToken
If oldStatement.IsKind(SyntaxKind.VariableDeclarator) Then
oldName = DirectCast(oldStatement, VariableDeclaratorSyntax).Names.Single.Identifier
Else
oldName = DirectCast(oldStatement, ModifiedIdentifierSyntax).Identifier
End If
For Each newName In newDeclarator.Names
If SyntaxFactory.AreEquivalent(newName.Identifier, oldName) Then
newStatement = newName
Return True
End If
Next
newStatement = Nothing
Return False
ElseIf newBody.Parent.Parent.IsKind(SyntaxKind.PropertyStatement) Then
' property
If oldStatement Is oldBody.Parent.Parent Then
newStatement = newBody.Parent.Parent
Return True
End If
newStatement = newBody
Return True
End If
End If
' queries
If oldStatement Is oldBody Then
newStatement = newBody
Return True
End If
newStatement = Nothing
Return False
End Function
#End Region
#Region "Syntax And Semantic Utils"
Protected Overrides Function GetSyntaxSequenceEdits(oldNodes As ImmutableArray(Of SyntaxNode), newNodes As ImmutableArray(Of SyntaxNode)) As IEnumerable(Of SequenceEdit)
Return SyntaxComparer.GetSequenceEdits(oldNodes, newNodes)
End Function
Friend Overrides ReadOnly Property EmptyCompilationUnit As SyntaxNode
Get
Return SyntaxFactory.CompilationUnit()
End Get
End Property
Friend Overrides Function ExperimentalFeaturesEnabled(tree As SyntaxTree) As Boolean
' There are no experimental features at this time.
Return False
End Function
Protected Overrides Function StatementLabelEquals(node1 As SyntaxNode, node2 As SyntaxNode) As Boolean
Return StatementSyntaxComparer.GetLabelImpl(node1) = StatementSyntaxComparer.GetLabelImpl(node2)
End Function
Private Shared Function GetItemIndexByPosition(Of TNode As SyntaxNode)(list As SeparatedSyntaxList(Of TNode), position As Integer) As Integer
For i = list.SeparatorCount - 1 To 0 Step -1
If position > list.GetSeparator(i).SpanStart Then
Return i + 1
End If
Next
Return 0
End Function
Private Shared Function ChildrenCompiledInBody(node As SyntaxNode) As Boolean
Return Not node.IsKind(SyntaxKind.MultiLineFunctionLambdaExpression) AndAlso
Not node.IsKind(SyntaxKind.SingleLineFunctionLambdaExpression) AndAlso
Not node.IsKind(SyntaxKind.MultiLineSubLambdaExpression) AndAlso
Not node.IsKind(SyntaxKind.SingleLineSubLambdaExpression)
End Function
Protected Overrides Function TryGetEnclosingBreakpointSpan(root As SyntaxNode, position As Integer, <Out> ByRef span As TextSpan) As Boolean
Return BreakpointSpans.TryGetEnclosingBreakpointSpan(root, position, span)
End Function
Protected Overrides Function TryGetActiveSpan(node As SyntaxNode, statementPart As Integer, <Out> ByRef span As TextSpan) As Boolean
Return BreakpointSpans.TryGetEnclosingBreakpointSpan(node, node.SpanStart, span)
End Function
Protected Overrides Iterator Function EnumerateNearStatements(statement As SyntaxNode) As IEnumerable(Of KeyValuePair(Of SyntaxNode, Integer))
Dim direction As Integer = +1
Dim nodeOrToken As SyntaxNodeOrToken = statement
Dim propertyOrFieldModifiers As SyntaxTokenList? = GetFieldOrPropertyModifiers(statement)
While True
' If the current statement is the last statement of if-block or try-block statements
' pretend there are no siblings following it.
Dim lastBlockStatement As SyntaxNode = Nothing
If nodeOrToken.Parent IsNot Nothing Then
If nodeOrToken.Parent.IsKind(SyntaxKind.MultiLineIfBlock) Then
lastBlockStatement = DirectCast(nodeOrToken.Parent, MultiLineIfBlockSyntax).Statements.LastOrDefault()
ElseIf nodeOrToken.Parent.IsKind(SyntaxKind.SingleLineIfStatement) Then
lastBlockStatement = DirectCast(nodeOrToken.Parent, SingleLineIfStatementSyntax).Statements.LastOrDefault()
ElseIf nodeOrToken.Parent.IsKind(SyntaxKind.TryBlock) Then
lastBlockStatement = DirectCast(nodeOrToken.Parent, TryBlockSyntax).Statements.LastOrDefault()
End If
End If
If direction > 0 Then
If lastBlockStatement IsNot Nothing AndAlso nodeOrToken.AsNode() Is lastBlockStatement Then
nodeOrToken = Nothing
Else
nodeOrToken = nodeOrToken.GetNextSibling()
End If
Else
nodeOrToken = nodeOrToken.GetPreviousSibling()
If lastBlockStatement IsNot Nothing AndAlso nodeOrToken.AsNode() Is lastBlockStatement Then
nodeOrToken = Nothing
End If
End If
If nodeOrToken.RawKind = 0 Then
Dim parent = statement.Parent
If parent Is Nothing Then
Return
End If
If direction > 0 Then
nodeOrToken = statement
direction = -1
Continue While
End If
If propertyOrFieldModifiers.HasValue Then
Yield KeyValuePair.Create(statement, -1)
End If
nodeOrToken = parent
statement = parent
propertyOrFieldModifiers = GetFieldOrPropertyModifiers(statement)
direction = +1
End If
Dim node = nodeOrToken.AsNode()
If node Is Nothing Then
Continue While
End If
If propertyOrFieldModifiers.HasValue Then
Dim nodeModifiers = GetFieldOrPropertyModifiers(node)
If Not nodeModifiers.HasValue OrElse
propertyOrFieldModifiers.Value.Any(SyntaxKind.SharedKeyword) <> nodeModifiers.Value.Any(SyntaxKind.SharedKeyword) Then
Continue While
End If
End If
Yield KeyValuePair.Create(node, 0)
End While
End Function
Private Shared Function GetFieldOrPropertyModifiers(node As SyntaxNode) As SyntaxTokenList?
If node.IsKind(SyntaxKind.FieldDeclaration) Then
Return DirectCast(node, FieldDeclarationSyntax).Modifiers
ElseIf node.IsKind(SyntaxKind.PropertyStatement) Then
Return DirectCast(node, PropertyStatementSyntax).Modifiers
Else
Return Nothing
End If
End Function
Protected Overrides Function AreEquivalent(left As SyntaxNode, right As SyntaxNode) As Boolean
Return SyntaxFactory.AreEquivalent(left, right)
End Function
Private Shared Function AreEquivalentIgnoringLambdaBodies(left As SyntaxNode, right As SyntaxNode) As Boolean
' usual case
If SyntaxFactory.AreEquivalent(left, right) Then
Return True
End If
Return LambdaUtilities.AreEquivalentIgnoringLambdaBodies(left, right)
End Function
Protected Overrides Function AreEquivalentActiveStatements(oldStatement As SyntaxNode, newStatement As SyntaxNode, statementPart As Integer) As Boolean
If oldStatement.RawKind <> newStatement.RawKind Then
Return False
End If
' Dim a,b,c As <NewExpression>
' We need to check the actual initializer expression in addition to the identifier.
If HasMultiInitializer(oldStatement) Then
Return AreEquivalentIgnoringLambdaBodies(oldStatement, newStatement) AndAlso
AreEquivalentIgnoringLambdaBodies(DirectCast(oldStatement.Parent, VariableDeclaratorSyntax).AsClause,
DirectCast(newStatement.Parent, VariableDeclaratorSyntax).AsClause)
End If
Select Case oldStatement.Kind
Case SyntaxKind.SubNewStatement,
SyntaxKind.SubStatement,
SyntaxKind.SubNewStatement,
SyntaxKind.FunctionStatement,
SyntaxKind.OperatorStatement,
SyntaxKind.GetAccessorStatement,
SyntaxKind.SetAccessorStatement,
SyntaxKind.AddHandlerAccessorStatement,
SyntaxKind.RemoveHandlerAccessorStatement,
SyntaxKind.RaiseEventAccessorStatement
' Header statements are nops. Changes in the header statements are changes in top-level surface
' which should not be reported as active statement rude edits.
Return True
Case Else
Return AreEquivalentIgnoringLambdaBodies(oldStatement, newStatement)
End Select
End Function
Private Shared Function HasMultiInitializer(modifiedIdentifier As SyntaxNode) As Boolean
Return modifiedIdentifier.Parent.IsKind(SyntaxKind.VariableDeclarator) AndAlso
DirectCast(modifiedIdentifier.Parent, VariableDeclaratorSyntax).Names.Count > 1
End Function
Friend Overrides Function IsMethod(declaration As SyntaxNode) As Boolean
Return SyntaxUtilities.IsMethod(declaration)
End Function
Friend Overrides Function TryGetContainingTypeDeclaration(memberDeclaration As SyntaxNode) As SyntaxNode
Return memberDeclaration.Parent.FirstAncestorOrSelf(Of TypeBlockSyntax)()
End Function
Friend Overrides Function HasBackingField(propertyDeclaration As SyntaxNode) As Boolean
Return SyntaxUtilities.HasBackingField(propertyDeclaration)
End Function
Friend Overrides Function IsDeclarationWithInitializer(declaration As SyntaxNode) As Boolean
Select Case declaration.Kind
Case SyntaxKind.VariableDeclarator
Dim declarator = DirectCast(declaration, VariableDeclaratorSyntax)
Return GetInitializerExpression(declarator.Initializer, declarator.AsClause) IsNot Nothing
Case SyntaxKind.ModifiedIdentifier
Debug.Assert(declaration.Parent.IsKind(SyntaxKind.VariableDeclarator) OrElse
declaration.Parent.IsKind(SyntaxKind.Parameter))
If Not declaration.Parent.IsKind(SyntaxKind.VariableDeclarator) Then
Return False
End If
Dim declarator = DirectCast(declaration.Parent, VariableDeclaratorSyntax)
Dim identifier = DirectCast(declaration, ModifiedIdentifierSyntax)
Return identifier.ArrayBounds IsNot Nothing OrElse
GetInitializerExpression(declarator.Initializer, declarator.AsClause) IsNot Nothing
Case SyntaxKind.PropertyStatement
Dim propertyStatement = DirectCast(declaration, PropertyStatementSyntax)
Return GetInitializerExpression(propertyStatement.Initializer, propertyStatement.AsClause) IsNot Nothing
Case Else
Return False
End Select
End Function
Private Shared Function GetInitializerExpression(equalsValue As EqualsValueSyntax, asClause As AsClauseSyntax) As ExpressionSyntax
If equalsValue IsNot Nothing Then
Return equalsValue.Value
End If
If asClause IsNot Nothing AndAlso asClause.IsKind(SyntaxKind.AsNewClause) Then
Return DirectCast(asClause, AsNewClauseSyntax).NewExpression
End If
Return Nothing
End Function
Friend Overrides Function IsConstructorWithMemberInitializers(declaration As SyntaxNode) As Boolean
Dim ctor = TryCast(declaration, ConstructorBlockSyntax)
If ctor Is Nothing Then
Return False
End If
' Constructor includes field initializers if the first statement
' isn't a call to another constructor of the declaring class or module.
If ctor.Statements.Count = 0 Then
Return True
End If
Dim firstStatement = ctor.Statements.First
If Not firstStatement.IsKind(SyntaxKind.ExpressionStatement) Then
Return True
End If
Dim expressionStatement = DirectCast(firstStatement, ExpressionStatementSyntax)
If Not expressionStatement.Expression.IsKind(SyntaxKind.InvocationExpression) Then
Return True
End If
Dim invocation = DirectCast(expressionStatement.Expression, InvocationExpressionSyntax)
If Not invocation.Expression.IsKind(SyntaxKind.SimpleMemberAccessExpression) Then
Return True
End If
Dim memberAccess = DirectCast(invocation.Expression, MemberAccessExpressionSyntax)
If Not memberAccess.Name.IsKind(SyntaxKind.IdentifierName) OrElse
Not memberAccess.Name.Identifier.IsKind(SyntaxKind.IdentifierToken) Then
Return True
End If
' Note that ValueText returns "New" for both New and [New]
If Not String.Equals(memberAccess.Name.Identifier.ToString(), "New", StringComparison.OrdinalIgnoreCase) Then
Return True
End If
Return memberAccess.Expression.IsKind(SyntaxKind.MyBaseKeyword)
End Function
Friend Overrides Function IsPartial(type As INamedTypeSymbol) As Boolean
Dim syntaxRefs = type.DeclaringSyntaxReferences
Return syntaxRefs.Length > 1 OrElse
DirectCast(syntaxRefs.Single().GetSyntax(), TypeStatementSyntax).Modifiers.Any(SyntaxKind.PartialKeyword)
End Function
Protected Overrides Function GetSymbolForEdit(model As SemanticModel, node As SyntaxNode, editKind As EditKind, editMap As Dictionary(Of SyntaxNode, EditKind), cancellationToken As CancellationToken) As ISymbol
' Avoid duplicate semantic edits - don't return symbols for statements within blocks.
Select Case node.Kind()
Case SyntaxKind.OperatorStatement,
SyntaxKind.SubNewStatement,
SyntaxKind.SetAccessorStatement,
SyntaxKind.GetAccessorStatement,
SyntaxKind.AddHandlerAccessorStatement,
SyntaxKind.RemoveHandlerAccessorStatement,
SyntaxKind.RaiseEventAccessorStatement,
SyntaxKind.DeclareSubStatement,
SyntaxKind.DeclareFunctionStatement,
SyntaxKind.ClassStatement,
SyntaxKind.StructureStatement,
SyntaxKind.InterfaceStatement,
SyntaxKind.ModuleStatement,
SyntaxKind.EnumStatement,
SyntaxKind.NamespaceStatement
Return Nothing
Case SyntaxKind.EventStatement
If node.Parent.IsKind(SyntaxKind.EventBlock) Then
Return Nothing
End If
Case SyntaxKind.PropertyStatement ' autoprop or interface property
If node.Parent.IsKind(SyntaxKind.PropertyBlock) Then
Return Nothing
End If
Case SyntaxKind.SubStatement ' interface method
If node.Parent.IsKind(SyntaxKind.SubBlock) Then
Return Nothing
End If
Case SyntaxKind.FunctionStatement ' interface method
If node.Parent.IsKind(SyntaxKind.FunctionBlock) Then
Return Nothing
End If
Case SyntaxKind.Parameter
Return Nothing
Case SyntaxKind.ModifiedIdentifier
If node.Parent.IsKind(SyntaxKind.Parameter) Then
Return Nothing
End If
Case SyntaxKind.VariableDeclarator
' An update to a field variable declarator might either be
' 1) variable declarator update (an initializer is changes)
' 2) modified identifier update (an array bound changes)
' Handle the first one here.
If editKind = EditKind.Update AndAlso node.Parent.IsKind(SyntaxKind.FieldDeclaration) Then
' If multiple fields are defined by this declaration pick the first one.
' We want to analyze the associated initializer just once. Any of the fields is good.
node = DirectCast(node, VariableDeclaratorSyntax).Names.First()
End If
End Select
Return model.GetDeclaredSymbol(node, cancellationToken)
End Function
Friend Overrides Function ContainsLambda(declaration As SyntaxNode) As Boolean
Return declaration.DescendantNodes().Any(AddressOf LambdaUtilities.IsLambda)
End Function
Friend Overrides Function IsLambda(node As SyntaxNode) As Boolean
Return LambdaUtilities.IsLambda(node)
End Function
Friend Overrides Function IsLambdaExpression(node As SyntaxNode) As Boolean
Return TypeOf node Is LambdaExpressionSyntax
End Function
Friend Overrides Function TryGetLambdaBodies(node As SyntaxNode, ByRef body1 As SyntaxNode, ByRef body2 As SyntaxNode) As Boolean
Return LambdaUtilities.TryGetLambdaBodies(node, body1, body2)
End Function
Friend Overrides Function GetLambda(lambdaBody As SyntaxNode) As SyntaxNode
Return LambdaUtilities.GetLambda(lambdaBody)
End Function
Protected Overrides Function GetLambdaBodyExpressionsAndStatements(lambdaBody As SyntaxNode) As IEnumerable(Of SyntaxNode)
Return LambdaUtilities.GetLambdaBodyExpressionsAndStatements(lambdaBody)
End Function
Friend Overrides Function GetLambdaExpressionSymbol(model As SemanticModel, lambdaExpression As SyntaxNode, cancellationToken As CancellationToken) As IMethodSymbol
Dim lambdaExpressionSyntax = DirectCast(lambdaExpression, LambdaExpressionSyntax)
' The semantic model only returns the lambda symbol for positions that are within the body of the lambda (not the header)
Return DirectCast(model.GetEnclosingSymbol(lambdaExpressionSyntax.SubOrFunctionHeader.Span.End, cancellationToken), IMethodSymbol)
End Function
Friend Overrides Function GetContainingQueryExpression(node As SyntaxNode) As SyntaxNode
Return node.FirstAncestorOrSelf(Of QueryExpressionSyntax)
End Function
Friend Overrides Function QueryClauseLambdasTypeEquivalent(oldModel As SemanticModel, oldNode As SyntaxNode, newModel As SemanticModel, newNode As SyntaxNode, cancellationToken As CancellationToken) As Boolean
Select Case oldNode.Kind
Case SyntaxKind.AggregateClause
Dim oldInfo = oldModel.GetAggregateClauseSymbolInfo(DirectCast(oldNode, AggregateClauseSyntax), cancellationToken)
Dim newInfo = newModel.GetAggregateClauseSymbolInfo(DirectCast(newNode, AggregateClauseSyntax), cancellationToken)
Return MemberSignaturesEquivalent(oldInfo.Select1.Symbol, newInfo.Select1.Symbol) AndAlso
MemberSignaturesEquivalent(oldInfo.Select2.Symbol, newInfo.Select2.Symbol)
Case SyntaxKind.CollectionRangeVariable
Dim oldInfo = oldModel.GetCollectionRangeVariableSymbolInfo(DirectCast(oldNode, CollectionRangeVariableSyntax), cancellationToken)
Dim newInfo = newModel.GetCollectionRangeVariableSymbolInfo(DirectCast(newNode, CollectionRangeVariableSyntax), cancellationToken)
Return MemberSignaturesEquivalent(oldInfo.AsClauseConversion.Symbol, newInfo.AsClauseConversion.Symbol) AndAlso
MemberSignaturesEquivalent(oldInfo.SelectMany.Symbol, newInfo.SelectMany.Symbol) AndAlso
MemberSignaturesEquivalent(oldInfo.ToQueryableCollectionConversion.Symbol, newInfo.ToQueryableCollectionConversion.Symbol)
Case SyntaxKind.FunctionAggregation
Dim oldInfo = oldModel.GetSymbolInfo(DirectCast(oldNode, FunctionAggregationSyntax), cancellationToken)
Dim newInfo = newModel.GetSymbolInfo(DirectCast(newNode, FunctionAggregationSyntax), cancellationToken)
Return MemberSignaturesEquivalent(oldInfo.Symbol, newInfo.Symbol)
Case SyntaxKind.ExpressionRangeVariable
Dim oldInfo = oldModel.GetSymbolInfo(DirectCast(oldNode, ExpressionRangeVariableSyntax), cancellationToken)
Dim newInfo = newModel.GetSymbolInfo(DirectCast(newNode, ExpressionRangeVariableSyntax), cancellationToken)
Return MemberSignaturesEquivalent(oldInfo.Symbol, newInfo.Symbol)
Case SyntaxKind.AscendingOrdering,
SyntaxKind.DescendingOrdering
Dim oldInfo = oldModel.GetSymbolInfo(DirectCast(oldNode, OrderingSyntax), cancellationToken)
Dim newInfo = newModel.GetSymbolInfo(DirectCast(newNode, OrderingSyntax), cancellationToken)
Return MemberSignaturesEquivalent(oldInfo.Symbol, newInfo.Symbol)
Case SyntaxKind.FromClause,
SyntaxKind.WhereClause,
SyntaxKind.SkipClause,
SyntaxKind.TakeClause,
SyntaxKind.SkipWhileClause,
SyntaxKind.TakeWhileClause,
SyntaxKind.GroupByClause,
SyntaxKind.SimpleJoinClause,
SyntaxKind.GroupJoinClause,
SyntaxKind.SelectClause
Dim oldInfo = oldModel.GetSymbolInfo(DirectCast(oldNode, QueryClauseSyntax), cancellationToken)
Dim newInfo = newModel.GetSymbolInfo(DirectCast(newNode, QueryClauseSyntax), cancellationToken)
Return MemberSignaturesEquivalent(oldInfo.Symbol, newInfo.Symbol)
Case Else
Return True
End Select
End Function
#End Region
#Region "Diagnostic Info"
Protected Overrides ReadOnly Property ErrorDisplayFormat As SymbolDisplayFormat
Get
Return SymbolDisplayFormat.VisualBasicShortErrorMessageFormat
End Get
End Property
Protected Overrides Function GetDiagnosticSpan(node As SyntaxNode, editKind As EditKind) As TextSpan
Return GetDiagnosticSpanImpl(node, editKind)
End Function
Private Shared Function GetDiagnosticSpanImpl(node As SyntaxNode, editKind As EditKind) As TextSpan
Return GetDiagnosticSpanImpl(node.Kind, node, editKind)
End Function
' internal for testing; kind is passed explicitly for testing as well
Friend Shared Function GetDiagnosticSpanImpl(kind As SyntaxKind, node As SyntaxNode, editKind As EditKind) As TextSpan
Select Case kind
Case SyntaxKind.CompilationUnit
Return Nothing
Case SyntaxKind.OptionStatement,
SyntaxKind.ImportsStatement
Return node.Span
Case SyntaxKind.NamespaceBlock
Return GetDiagnosticSpan(DirectCast(node, NamespaceBlockSyntax).NamespaceStatement)
Case SyntaxKind.NamespaceStatement
Return GetDiagnosticSpan(DirectCast(node, NamespaceStatementSyntax))
Case SyntaxKind.ClassBlock,
SyntaxKind.StructureBlock,
SyntaxKind.InterfaceBlock,
SyntaxKind.ModuleBlock
Return GetDiagnosticSpan(DirectCast(node, TypeBlockSyntax).BlockStatement)
Case SyntaxKind.ClassStatement,
SyntaxKind.StructureStatement,
SyntaxKind.InterfaceStatement,
SyntaxKind.ModuleStatement
Return GetDiagnosticSpan(DirectCast(node, TypeStatementSyntax))
Case SyntaxKind.EnumBlock
Return GetDiagnosticSpanImpl(DirectCast(node, EnumBlockSyntax).EnumStatement, editKind)
Case SyntaxKind.EnumStatement
Dim enumStatement = DirectCast(node, EnumStatementSyntax)
Return GetDiagnosticSpan(enumStatement.Modifiers, enumStatement.EnumKeyword, enumStatement.Identifier)
Case SyntaxKind.SubBlock,
SyntaxKind.FunctionBlock,
SyntaxKind.OperatorBlock,
SyntaxKind.ConstructorBlock,
SyntaxKind.EventBlock,
SyntaxKind.SetAccessorBlock,
SyntaxKind.GetAccessorBlock,
SyntaxKind.AddHandlerAccessorBlock,
SyntaxKind.RemoveHandlerAccessorBlock,
SyntaxKind.RaiseEventAccessorBlock
Return GetDiagnosticSpan(DirectCast(node, MethodBlockBaseSyntax).BlockStatement)
Case SyntaxKind.SubStatement,
SyntaxKind.FunctionStatement,
SyntaxKind.OperatorStatement,
SyntaxKind.SubNewStatement,
SyntaxKind.EventStatement,
SyntaxKind.SetAccessorStatement,
SyntaxKind.GetAccessorStatement,
SyntaxKind.AddHandlerAccessorStatement,
SyntaxKind.RemoveHandlerAccessorStatement,
SyntaxKind.RaiseEventAccessorStatement,
SyntaxKind.DeclareSubStatement,
SyntaxKind.DeclareFunctionStatement,
SyntaxKind.DelegateSubStatement,
SyntaxKind.DelegateFunctionStatement
Return GetDiagnosticSpan(DirectCast(node, MethodBaseSyntax))
Case SyntaxKind.PropertyBlock
Return GetDiagnosticSpan(DirectCast(node, PropertyBlockSyntax).PropertyStatement)
Case SyntaxKind.PropertyStatement
Return GetDiagnosticSpan(DirectCast(node, PropertyStatementSyntax))
Case SyntaxKind.FieldDeclaration
Dim fieldDeclaration = DirectCast(node, FieldDeclarationSyntax)
Return GetDiagnosticSpan(fieldDeclaration.Modifiers, fieldDeclaration.Declarators.First, fieldDeclaration.Declarators.Last)
Case SyntaxKind.VariableDeclarator,
SyntaxKind.ModifiedIdentifier,
SyntaxKind.EnumMemberDeclaration,
SyntaxKind.TypeParameterSingleConstraintClause,
SyntaxKind.TypeParameterMultipleConstraintClause,
SyntaxKind.ClassConstraint,
SyntaxKind.StructureConstraint,
SyntaxKind.NewConstraint,
SyntaxKind.TypeConstraint
Return node.Span
Case SyntaxKind.TypeParameter
Return DirectCast(node, TypeParameterSyntax).Identifier.Span
Case SyntaxKind.TypeParameterList,
SyntaxKind.ParameterList,
SyntaxKind.AttributeList,
SyntaxKind.SimpleAsClause
If editKind = EditKind.Delete Then
Return GetDiagnosticSpanImpl(node.Parent, editKind)
Else
Return node.Span
End If
Case SyntaxKind.AttributesStatement,
SyntaxKind.Attribute
Return node.Span
Case SyntaxKind.Parameter
Dim parameter = DirectCast(node, ParameterSyntax)
Return GetDiagnosticSpan(parameter.Modifiers, parameter.Identifier, parameter)
Case SyntaxKind.MultiLineFunctionLambdaExpression,
SyntaxKind.SingleLineFunctionLambdaExpression,
SyntaxKind.MultiLineSubLambdaExpression,
SyntaxKind.SingleLineSubLambdaExpression
Return GetDiagnosticSpan(DirectCast(node, LambdaExpressionSyntax).SubOrFunctionHeader)
Case SyntaxKind.MultiLineIfBlock
Dim ifStatement = DirectCast(node, MultiLineIfBlockSyntax).IfStatement
Return GetDiagnosticSpan(ifStatement.IfKeyword, ifStatement.Condition, ifStatement.ThenKeyword)
Case SyntaxKind.ElseIfBlock
Dim elseIfStatement = DirectCast(node, ElseIfBlockSyntax).ElseIfStatement
Return GetDiagnosticSpan(elseIfStatement.ElseIfKeyword, elseIfStatement.Condition, elseIfStatement.ThenKeyword)
Case SyntaxKind.SingleLineIfStatement
Dim ifStatement = DirectCast(node, SingleLineIfStatementSyntax)
Return GetDiagnosticSpan(ifStatement.IfKeyword, ifStatement.Condition, ifStatement.ThenKeyword)
Case SyntaxKind.SingleLineElseClause
Return DirectCast(node, SingleLineElseClauseSyntax).ElseKeyword.Span
Case SyntaxKind.TryBlock
Return DirectCast(node, TryBlockSyntax).TryStatement.TryKeyword.Span
Case SyntaxKind.CatchBlock
Return DirectCast(node, CatchBlockSyntax).CatchStatement.CatchKeyword.Span
Case SyntaxKind.FinallyBlock
Return DirectCast(node, FinallyBlockSyntax).FinallyStatement.FinallyKeyword.Span
Case SyntaxKind.SyncLockBlock
Return DirectCast(node, SyncLockBlockSyntax).SyncLockStatement.Span
Case SyntaxKind.WithBlock
Return DirectCast(node, WithBlockSyntax).WithStatement.Span
Case SyntaxKind.UsingBlock
Return DirectCast(node, UsingBlockSyntax).UsingStatement.Span
Case SyntaxKind.SimpleDoLoopBlock,
SyntaxKind.DoWhileLoopBlock,
SyntaxKind.DoUntilLoopBlock,
SyntaxKind.DoLoopWhileBlock,
SyntaxKind.DoLoopUntilBlock
Return DirectCast(node, DoLoopBlockSyntax).DoStatement.Span
Case SyntaxKind.WhileBlock
Return DirectCast(node, WhileBlockSyntax).WhileStatement.Span
Case SyntaxKind.ForEachBlock,
SyntaxKind.ForBlock
Return DirectCast(node, ForOrForEachBlockSyntax).ForOrForEachStatement.Span
Case SyntaxKind.AwaitExpression
Return DirectCast(node, AwaitExpressionSyntax).AwaitKeyword.Span
Case SyntaxKind.AnonymousObjectCreationExpression
Dim newWith = DirectCast(node, AnonymousObjectCreationExpressionSyntax)
Return TextSpan.FromBounds(newWith.NewKeyword.Span.Start,
newWith.Initializer.WithKeyword.Span.End)
Case SyntaxKind.SingleLineFunctionLambdaExpression,
SyntaxKind.SingleLineSubLambdaExpression,
SyntaxKind.MultiLineFunctionLambdaExpression,
SyntaxKind.MultiLineSubLambdaExpression
Return DirectCast(node, LambdaExpressionSyntax).SubOrFunctionHeader.Span
Case SyntaxKind.QueryExpression
Return GetDiagnosticSpanImpl(DirectCast(node, QueryExpressionSyntax).Clauses.First(), editKind)
Case SyntaxKind.WhereClause
Return DirectCast(node, WhereClauseSyntax).WhereKeyword.Span
Case SyntaxKind.SelectClause
Return DirectCast(node, SelectClauseSyntax).SelectKeyword.Span
Case SyntaxKind.FromClause
Return DirectCast(node, FromClauseSyntax).FromKeyword.Span
Case SyntaxKind.AggregateClause
Return DirectCast(node, AggregateClauseSyntax).AggregateKeyword.Span
Case SyntaxKind.LetClause
Return DirectCast(node, LetClauseSyntax).LetKeyword.Span
Case SyntaxKind.SimpleJoinClause
Return DirectCast(node, SimpleJoinClauseSyntax).JoinKeyword.Span
Case SyntaxKind.GroupJoinClause
Dim groupJoin = DirectCast(node, GroupJoinClauseSyntax)
Return TextSpan.FromBounds(groupJoin.GroupKeyword.SpanStart, groupJoin.JoinKeyword.Span.End)
Case SyntaxKind.GroupByClause
Return DirectCast(node, GroupByClauseSyntax).GroupKeyword.Span
Case SyntaxKind.FunctionAggregation
Return node.Span
Case SyntaxKind.CollectionRangeVariable,
SyntaxKind.ExpressionRangeVariable
Return GetDiagnosticSpanImpl(node.Parent, editKind)
Case SyntaxKind.TakeWhileClause,
SyntaxKind.SkipWhileClause
Dim partition = DirectCast(node, PartitionWhileClauseSyntax)
Return TextSpan.FromBounds(partition.SkipOrTakeKeyword.SpanStart, partition.WhileKeyword.Span.End)
Case SyntaxKind.AscendingOrdering,
SyntaxKind.DescendingOrdering
Return node.Span
Case SyntaxKind.JoinCondition
Return DirectCast(node, JoinConditionSyntax).EqualsKeyword.Span
Case Else
Return node.Span
End Select
End Function
Private Overloads Shared Function GetDiagnosticSpan(ifKeyword As SyntaxToken, condition As SyntaxNode, thenKeywordOpt As SyntaxToken) As TextSpan
Return TextSpan.FromBounds(ifKeyword.Span.Start,
If(thenKeywordOpt.RawKind <> 0, thenKeywordOpt.Span.End, condition.Span.End))
End Function
Private Overloads Shared Function GetDiagnosticSpan(node As NamespaceStatementSyntax) As TextSpan
Return TextSpan.FromBounds(node.NamespaceKeyword.SpanStart, node.Name.Span.End)
End Function
Private Overloads Shared Function GetDiagnosticSpan(node As TypeStatementSyntax) As TextSpan
Return GetDiagnosticSpan(node.Modifiers,
node.DeclarationKeyword,
If(node.TypeParameterList, CType(node.Identifier, SyntaxNodeOrToken)))
End Function
Private Overloads Shared Function GetDiagnosticSpan(modifiers As SyntaxTokenList, start As SyntaxNodeOrToken, endNode As SyntaxNodeOrToken) As TextSpan
Return TextSpan.FromBounds(If(modifiers.Count <> 0, modifiers.First.SpanStart, start.SpanStart),
endNode.Span.End)
End Function
Private Overloads Shared Function GetDiagnosticSpan(header As MethodBaseSyntax) As TextSpan
Dim startToken As SyntaxToken
Dim endToken As SyntaxToken
If header.Modifiers.Count > 0 Then
startToken = header.Modifiers.First
Else
Select Case header.Kind
Case SyntaxKind.DelegateFunctionStatement,
SyntaxKind.DelegateSubStatement
startToken = DirectCast(header, DelegateStatementSyntax).DelegateKeyword
Case SyntaxKind.DeclareSubStatement,
SyntaxKind.DeclareFunctionStatement
startToken = DirectCast(header, DeclareStatementSyntax).DeclareKeyword
Case Else
startToken = header.DeclarationKeyword
End Select
End If
If header.ParameterList IsNot Nothing Then
endToken = header.ParameterList.CloseParenToken
Else
Select Case header.Kind
Case SyntaxKind.SubStatement,
SyntaxKind.FunctionStatement
endToken = DirectCast(header, MethodStatementSyntax).Identifier
Case SyntaxKind.DeclareSubStatement,
SyntaxKind.DeclareFunctionStatement
endToken = DirectCast(header, DeclareStatementSyntax).LibraryName.Token
Case SyntaxKind.OperatorStatement
endToken = DirectCast(header, OperatorStatementSyntax).OperatorToken
Case SyntaxKind.SubNewStatement
endToken = DirectCast(header, SubNewStatementSyntax).NewKeyword
Case SyntaxKind.PropertyStatement
endToken = DirectCast(header, PropertyStatementSyntax).Identifier
Case SyntaxKind.EventStatement
endToken = DirectCast(header, EventStatementSyntax).Identifier
Case SyntaxKind.DelegateFunctionStatement,
SyntaxKind.DelegateSubStatement
endToken = DirectCast(header, DelegateStatementSyntax).Identifier
Case SyntaxKind.SetAccessorStatement,
SyntaxKind.GetAccessorStatement,
SyntaxKind.AddHandlerAccessorStatement,
SyntaxKind.RemoveHandlerAccessorStatement,
SyntaxKind.RaiseEventAccessorStatement
endToken = header.DeclarationKeyword
Case Else
Throw ExceptionUtilities.UnexpectedValue(header.Kind)
End Select
End If
Return TextSpan.FromBounds(startToken.SpanStart, endToken.Span.End)
End Function
Private Overloads Shared Function GetDiagnosticSpan(lambda As LambdaHeaderSyntax) As TextSpan
Dim startToken = If(lambda.Modifiers.Count <> 0, lambda.Modifiers.First, lambda.DeclarationKeyword)
Dim endToken As SyntaxToken
If lambda.ParameterList IsNot Nothing Then
endToken = lambda.ParameterList.CloseParenToken
Else
endToken = lambda.DeclarationKeyword
End If
Return TextSpan.FromBounds(startToken.SpanStart, endToken.Span.End)
End Function
Friend Overrides Function GetLambdaParameterDiagnosticSpan(lambda As SyntaxNode, ordinal As Integer) As TextSpan
Select Case lambda.Kind
Case SyntaxKind.MultiLineFunctionLambdaExpression,
SyntaxKind.SingleLineFunctionLambdaExpression,
SyntaxKind.MultiLineSubLambdaExpression,
SyntaxKind.SingleLineSubLambdaExpression
Return DirectCast(lambda, LambdaExpressionSyntax).SubOrFunctionHeader.ParameterList.Parameters(ordinal).Identifier.Span
Case Else
Return lambda.Span
End Select
End Function
Protected Overrides Function GetTopLevelDisplayName(node As SyntaxNode, editKind As EditKind) As String
Return GetTopLevelDisplayNameImpl(node)
End Function
Protected Overrides Function GetStatementDisplayName(node As SyntaxNode, editKind As EditKind) As String
Return GetStatementDisplayNameImpl(node, editKind)
End Function
Protected Overrides Function GetLambdaDisplayName(lambda As SyntaxNode) As String
Return GetStatementDisplayNameImpl(lambda, EditKind.Update)
End Function
' internal for testing
Friend Shared Function GetTopLevelDisplayNameImpl(node As SyntaxNode) As String
Select Case node.Kind
Case SyntaxKind.OptionStatement
Return VBFeaturesResources.option_
Case SyntaxKind.ImportsStatement
Return VBFeaturesResources.import
Case SyntaxKind.NamespaceBlock,
SyntaxKind.NamespaceStatement
Return FeaturesResources.namespace_
Case SyntaxKind.ClassBlock,
SyntaxKind.ClassStatement
Return FeaturesResources.class_
Case SyntaxKind.StructureBlock,
SyntaxKind.StructureStatement
Return VBFeaturesResources.structure_
Case SyntaxKind.InterfaceBlock,
SyntaxKind.InterfaceStatement
Return FeaturesResources.interface_
Case SyntaxKind.ModuleBlock,
SyntaxKind.ModuleStatement
Return VBFeaturesResources.module_
Case SyntaxKind.EnumBlock,
SyntaxKind.EnumStatement
Return FeaturesResources.enum_
Case SyntaxKind.DelegateSubStatement,
SyntaxKind.DelegateFunctionStatement
Return FeaturesResources.delegate_
Case SyntaxKind.FieldDeclaration
Dim declaration = DirectCast(node, FieldDeclarationSyntax)
Return If(declaration.Modifiers.Any(SyntaxKind.WithEventsKeyword), VBFeaturesResources.WithEvents_field,
If(declaration.Modifiers.Any(SyntaxKind.ConstKeyword), FeaturesResources.const_field, FeaturesResources.field))
Case SyntaxKind.VariableDeclarator,
SyntaxKind.ModifiedIdentifier
Return GetTopLevelDisplayNameImpl(node.Parent)
Case SyntaxKind.SubBlock,
SyntaxKind.FunctionBlock,
SyntaxKind.SubStatement,
SyntaxKind.FunctionStatement,
SyntaxKind.DeclareSubStatement,
SyntaxKind.DeclareFunctionStatement
Return FeaturesResources.method
Case SyntaxKind.OperatorBlock,
SyntaxKind.OperatorStatement
Return FeaturesResources.operator_
Case SyntaxKind.ConstructorBlock,
SyntaxKind.SubNewStatement
Return FeaturesResources.constructor
Case SyntaxKind.PropertyBlock
Return FeaturesResources.property_
Case SyntaxKind.PropertyStatement
Return If(node.IsParentKind(SyntaxKind.PropertyBlock),
FeaturesResources.property_,
FeaturesResources.auto_property)
Case SyntaxKind.EventBlock,
SyntaxKind.EventStatement
Return FeaturesResources.event_
Case SyntaxKind.EnumMemberDeclaration
Return FeaturesResources.enum_value
Case SyntaxKind.GetAccessorBlock,
SyntaxKind.SetAccessorBlock,
SyntaxKind.GetAccessorStatement,
SyntaxKind.SetAccessorStatement
Return VBFeaturesResources.property_accessor
Case SyntaxKind.AddHandlerAccessorBlock,
SyntaxKind.RemoveHandlerAccessorBlock,
SyntaxKind.RaiseEventAccessorBlock,
SyntaxKind.AddHandlerAccessorStatement,
SyntaxKind.RemoveHandlerAccessorStatement,
SyntaxKind.RaiseEventAccessorStatement
Return FeaturesResources.event_accessor
Case SyntaxKind.TypeParameterSingleConstraintClause,
SyntaxKind.TypeParameterMultipleConstraintClause,
SyntaxKind.ClassConstraint,
SyntaxKind.StructureConstraint,
SyntaxKind.NewConstraint,
SyntaxKind.TypeConstraint
Return FeaturesResources.type_constraint
Case SyntaxKind.SimpleAsClause
Return VBFeaturesResources.as_clause
Case SyntaxKind.TypeParameterList
Return VBFeaturesResources.type_parameters
Case SyntaxKind.TypeParameter
Return FeaturesResources.type_parameter
Case SyntaxKind.ParameterList
Return VBFeaturesResources.parameters
Case SyntaxKind.Parameter
Return FeaturesResources.parameter
Case SyntaxKind.AttributeList,
SyntaxKind.AttributesStatement
Return VBFeaturesResources.attributes
Case SyntaxKind.Attribute
Return FeaturesResources.attribute
Case Else
Throw ExceptionUtilities.UnexpectedValue(node.Kind())
End Select
End Function
' internal for testing
Friend Shared Function GetStatementDisplayNameImpl(node As SyntaxNode, kind As EditKind) As String
Select Case node.Kind
Case SyntaxKind.TryBlock
Return VBFeaturesResources.Try_block
Case SyntaxKind.CatchBlock
Return VBFeaturesResources.Catch_clause
Case SyntaxKind.FinallyBlock
Return VBFeaturesResources.Finally_clause
Case SyntaxKind.UsingBlock
Return If(kind = EditKind.Update, VBFeaturesResources.Using_statement, VBFeaturesResources.Using_block)
Case SyntaxKind.WithBlock
Return If(kind = EditKind.Update, VBFeaturesResources.With_statement, VBFeaturesResources.With_block)
Case SyntaxKind.SyncLockBlock
Return If(kind = EditKind.Update, VBFeaturesResources.SyncLock_statement, VBFeaturesResources.SyncLock_block)
Case SyntaxKind.ForEachBlock
Return If(kind = EditKind.Update, VBFeaturesResources.For_Each_statement, VBFeaturesResources.For_Each_block)
Case SyntaxKind.OnErrorGoToMinusOneStatement,
SyntaxKind.OnErrorGoToZeroStatement,
SyntaxKind.OnErrorResumeNextStatement,
SyntaxKind.OnErrorGoToLabelStatement
Return VBFeaturesResources.On_Error_statement
Case SyntaxKind.ResumeStatement,
SyntaxKind.ResumeNextStatement,
SyntaxKind.ResumeLabelStatement
Return VBFeaturesResources.Resume_statement
Case SyntaxKind.YieldStatement
Return VBFeaturesResources.Yield_statement
Case SyntaxKind.AwaitExpression
Return VBFeaturesResources.Await_expression
Case SyntaxKind.MultiLineFunctionLambdaExpression,
SyntaxKind.SingleLineFunctionLambdaExpression,
SyntaxKind.MultiLineSubLambdaExpression,
SyntaxKind.SingleLineSubLambdaExpression
Return VBFeaturesResources.Lambda
Case SyntaxKind.WhereClause
Return VBFeaturesResources.Where_clause
Case SyntaxKind.SelectClause
Return VBFeaturesResources.Select_clause
Case SyntaxKind.FromClause
Return VBFeaturesResources.From_clause
Case SyntaxKind.AggregateClause
Return VBFeaturesResources.Aggregate_clause
Case SyntaxKind.LetClause
Return VBFeaturesResources.Let_clause
Case SyntaxKind.SimpleJoinClause
Return VBFeaturesResources.Join_clause
Case SyntaxKind.GroupJoinClause
Return VBFeaturesResources.Group_Join_clause
Case SyntaxKind.GroupByClause
Return VBFeaturesResources.Group_By_clause
Case SyntaxKind.FunctionAggregation
Return VBFeaturesResources.Function_aggregation
Case SyntaxKind.CollectionRangeVariable,
SyntaxKind.ExpressionRangeVariable
Return GetStatementDisplayNameImpl(node.Parent, kind)
Case SyntaxKind.TakeWhileClause
Return VBFeaturesResources.Take_While_clause
Case SyntaxKind.SkipWhileClause
Return VBFeaturesResources.Skip_While_clause
Case SyntaxKind.AscendingOrdering,
SyntaxKind.DescendingOrdering
Return VBFeaturesResources.Ordering_clause
Case SyntaxKind.JoinCondition
Return VBFeaturesResources.Join_condition
Case Else
Throw ExceptionUtilities.UnexpectedValue(node.Kind())
End Select
End Function
#End Region
#Region "Top-level Syntactic Rude Edits"
Private Structure EditClassifier
Private ReadOnly _analyzer As VisualBasicEditAndContinueAnalyzer
Private ReadOnly _diagnostics As List(Of RudeEditDiagnostic)
Private ReadOnly _match As Match(Of SyntaxNode)
Private ReadOnly _oldNode As SyntaxNode
Private ReadOnly _newNode As SyntaxNode
Private ReadOnly _kind As EditKind
Private ReadOnly _span As TextSpan?
Public Sub New(analyzer As VisualBasicEditAndContinueAnalyzer,
diagnostics As List(Of RudeEditDiagnostic),
oldNode As SyntaxNode,
newNode As SyntaxNode,
kind As EditKind,
Optional match As Match(Of SyntaxNode) = Nothing,
Optional span As TextSpan? = Nothing)
Me._analyzer = analyzer
Me._diagnostics = diagnostics
Me._oldNode = oldNode
Me._newNode = newNode
Me._kind = kind
Me._span = span
Me._match = match
End Sub
Private Sub ReportError(kind As RudeEditKind)
ReportError(kind, {GetDisplayName()})
End Sub
Private Sub ReportError(kind As RudeEditKind, args As String())
_diagnostics.Add(New RudeEditDiagnostic(kind, GetSpan(), If(_newNode, _oldNode), args))
End Sub
Private Sub ReportError(kind As RudeEditKind, spanNode As SyntaxNode, displayNode As SyntaxNode)
_diagnostics.Add(New RudeEditDiagnostic(kind, GetDiagnosticSpanImpl(spanNode, Me._kind), displayNode, {GetTopLevelDisplayNameImpl(displayNode)}))
End Sub
Private Function GetSpan() As TextSpan
If _span.HasValue Then
Return _span.Value
End If
If _newNode Is Nothing Then
Return _analyzer.GetDeletedNodeDiagnosticSpan(_match.Matches, _oldNode)
Else
Return GetDiagnosticSpanImpl(_newNode, _kind)
End If
End Function
Private Function GetDisplayName() As String
Return GetTopLevelDisplayNameImpl(If(_newNode, _oldNode))
End Function
Public Sub ClassifyEdit()
Select Case _kind
Case EditKind.Delete
ClassifyDelete(_oldNode)
Return
Case EditKind.Update
ClassifyUpdate(_oldNode, _newNode)
Return
Case EditKind.Move
ClassifyMove(_oldNode, _newNode)
Return
Case EditKind.Insert
ClassifyInsert(_newNode)
Return
Case EditKind.Reorder
ClassifyReorder(_oldNode, _newNode)
Return
Case Else
Throw ExceptionUtilities.UnexpectedValue(_kind)
End Select
End Sub
#Region "Move and Reorder"
Private Sub ClassifyMove(oldNode As SyntaxNode, newNode As SyntaxNode)
ReportError(RudeEditKind.Move)
End Sub
Private Sub ClassifyReorder(oldNode As SyntaxNode, newNode As SyntaxNode)
Select Case newNode.Kind
Case SyntaxKind.OptionStatement,
SyntaxKind.ImportsStatement,
SyntaxKind.AttributesStatement,
SyntaxKind.NamespaceBlock,
SyntaxKind.ClassBlock,
SyntaxKind.StructureBlock,
SyntaxKind.InterfaceBlock,
SyntaxKind.ModuleBlock,
SyntaxKind.EnumBlock,
SyntaxKind.DelegateFunctionStatement,
SyntaxKind.DelegateSubStatement,
SyntaxKind.SubBlock,
SyntaxKind.FunctionBlock,
SyntaxKind.DeclareSubStatement,
SyntaxKind.DeclareFunctionStatement,
SyntaxKind.ConstructorBlock,
SyntaxKind.OperatorBlock,
SyntaxKind.PropertyBlock,
SyntaxKind.EventBlock,
SyntaxKind.GetAccessorBlock,
SyntaxKind.SetAccessorBlock,
SyntaxKind.AddHandlerAccessorBlock,
SyntaxKind.RemoveHandlerAccessorBlock,
SyntaxKind.RaiseEventAccessorBlock,
SyntaxKind.ClassConstraint,
SyntaxKind.StructureConstraint,
SyntaxKind.NewConstraint,
SyntaxKind.TypeConstraint,
SyntaxKind.AttributeList,
SyntaxKind.Attribute
' We'll ignore these edits. A general policy is to ignore edits that are only discoverable via reflection.
Return
Case SyntaxKind.SubStatement,
SyntaxKind.FunctionStatement
' Interface methods. We could allow reordering of non-COM interface methods.
Debug.Assert(oldNode.Parent.IsKind(SyntaxKind.InterfaceBlock) AndAlso newNode.Parent.IsKind(SyntaxKind.InterfaceBlock))
ReportError(RudeEditKind.Move)
Return
Case SyntaxKind.PropertyStatement,
SyntaxKind.FieldDeclaration,
SyntaxKind.EventStatement,
SyntaxKind.VariableDeclarator
' Maybe we could allow changing order of field declarations unless the containing type layout is sequential,
' and it's not a COM interface.
ReportError(RudeEditKind.Move)
Return
Case SyntaxKind.EnumMemberDeclaration
' To allow this change we would need to check that values of all fields of the enum
' are preserved, or make sure we can update all method bodies that accessed those that changed.
ReportError(RudeEditKind.Move)
Return
Case SyntaxKind.TypeParameter,
SyntaxKind.Parameter
ReportError(RudeEditKind.Move)
Return
Case SyntaxKind.ModifiedIdentifier
' Identifier can only moved from one VariableDeclarator to another if both are part of
' the same declaration. We could allow these moves if the order and types of variables
' didn't change.
ReportError(RudeEditKind.Move)
Return
Case Else
Throw ExceptionUtilities.UnexpectedValue(newNode.Kind)
End Select
End Sub
#End Region
#Region "Insert"
Private Sub ClassifyInsert(node As SyntaxNode)
Select Case node.Kind
Case SyntaxKind.OptionStatement,
SyntaxKind.ImportsStatement,
SyntaxKind.NamespaceBlock
ReportError(RudeEditKind.Insert)
Return
Case SyntaxKind.ClassBlock,
SyntaxKind.StructureBlock
ClassifyTypeWithPossibleExternMembersInsert(DirectCast(node, TypeBlockSyntax))
Return
Case SyntaxKind.InterfaceBlock
ClassifyTypeInsert(DirectCast(node, TypeBlockSyntax).BlockStatement.Modifiers)
Return
Case SyntaxKind.EnumBlock
ClassifyTypeInsert(DirectCast(node, EnumBlockSyntax).EnumStatement.Modifiers)
Return
Case SyntaxKind.ModuleBlock
' Modules can't be nested or private
ReportError(RudeEditKind.Insert)
Return
Case SyntaxKind.DelegateSubStatement,
SyntaxKind.DelegateFunctionStatement
ClassifyTypeInsert(DirectCast(node, DelegateStatementSyntax).Modifiers)
Return
Case SyntaxKind.SubStatement, ' interface method
SyntaxKind.FunctionStatement ' interface method
ReportError(RudeEditKind.Insert)
Return
Case SyntaxKind.PropertyBlock
ClassifyModifiedMemberInsert(DirectCast(node, PropertyBlockSyntax).PropertyStatement.Modifiers)
Return
Case SyntaxKind.PropertyStatement ' autoprop or interface property
' We don't need to check whether the container is an interface, since we disallow
' adding public methods And all methods in interface declarations are public.
ClassifyModifiedMemberInsert(DirectCast(node, PropertyStatementSyntax).Modifiers)
Return
Case SyntaxKind.EventBlock
ClassifyModifiedMemberInsert(DirectCast(node, EventBlockSyntax).EventStatement.Modifiers)
Return
Case SyntaxKind.EventStatement
ClassifyModifiedMemberInsert(DirectCast(node, EventStatementSyntax).Modifiers)
Return
Case SyntaxKind.OperatorBlock
ReportError(RudeEditKind.InsertOperator)
Return
Case SyntaxKind.SubBlock,
SyntaxKind.FunctionBlock
ClassifyMethodInsert(DirectCast(node, MethodBlockSyntax).SubOrFunctionStatement)
Return
Case SyntaxKind.DeclareSubStatement,
SyntaxKind.DeclareFunctionStatement
' CLR doesn't support adding P/Invokes
ReportError(RudeEditKind.Insert)
Return
Case SyntaxKind.ConstructorBlock
If SyntaxUtilities.IsParameterlessConstructor(node) Then
Return
End If
ClassifyModifiedMemberInsert(DirectCast(node, MethodBlockBaseSyntax).BlockStatement.Modifiers)
Return
Case SyntaxKind.GetAccessorBlock,
SyntaxKind.SetAccessorBlock,
SyntaxKind.AddHandlerAccessorBlock,
SyntaxKind.RemoveHandlerAccessorBlock,
SyntaxKind.RaiseEventAccessorBlock
Return
Case SyntaxKind.FieldDeclaration
ClassifyFieldInsert(DirectCast(node, FieldDeclarationSyntax))
Return
Case SyntaxKind.VariableDeclarator
' Ignore, errors will be reported for children (ModifiedIdentifier, AsClause)
Return
Case SyntaxKind.ModifiedIdentifier
ClassifyFieldInsert(DirectCast(node, ModifiedIdentifierSyntax))
Return
Case SyntaxKind.EnumMemberDeclaration,
SyntaxKind.TypeParameter,
SyntaxKind.StructureConstraint,
SyntaxKind.TypeParameterSingleConstraintClause,
SyntaxKind.TypeParameterMultipleConstraintClause,
SyntaxKind.ClassConstraint,
SyntaxKind.StructureConstraint,
SyntaxKind.NewConstraint,
SyntaxKind.TypeConstraint,
SyntaxKind.TypeParameterList,
SyntaxKind.Parameter,
SyntaxKind.Attribute,
SyntaxKind.AttributeList,
SyntaxKind.AttributesStatement,
SyntaxKind.SimpleAsClause
ReportError(RudeEditKind.Insert)
Return
Case SyntaxKind.ParameterList
ClassifyParameterInsert(DirectCast(node, ParameterListSyntax))
Return
Case Else
Throw ExceptionUtilities.UnexpectedValue(node.Kind())
End Select
End Sub
Private Function ClassifyModifiedMemberInsert(modifiers As SyntaxTokenList) As Boolean
If modifiers.Any(SyntaxKind.OverridableKeyword) OrElse
modifiers.Any(SyntaxKind.MustOverrideKeyword) OrElse
modifiers.Any(SyntaxKind.OverridesKeyword) Then
ReportError(RudeEditKind.InsertVirtual)
Return False
End If
Return True
End Function
Private Function ClassifyTypeInsert(modifiers As SyntaxTokenList) As Boolean
Return ClassifyModifiedMemberInsert(modifiers)
End Function
Private Sub ClassifyTypeWithPossibleExternMembersInsert(type As TypeBlockSyntax)
If Not ClassifyTypeInsert(type.BlockStatement.Modifiers) Then
Return
End If
For Each member In type.Members
Dim modifiers As SyntaxTokenList = Nothing
Select Case member.Kind
Case SyntaxKind.DeclareFunctionStatement,
SyntaxKind.DeclareSubStatement
ReportError(RudeEditKind.Insert, member, member)
Case SyntaxKind.PropertyStatement
modifiers = DirectCast(member, PropertyStatementSyntax).Modifiers
Case SyntaxKind.SubBlock,
SyntaxKind.FunctionBlock
modifiers = DirectCast(member, MethodBlockBaseSyntax).BlockStatement.Modifiers
End Select
' TODO: DllImport/Declare?
'If (modifiers.Any(SyntaxKind.MustOverrideKeyword)) Then
' ReportError(RudeEditKind.InsertMustOverride, member, member)
'End If
Next
End Sub
Private Sub ClassifyMethodInsert(method As MethodStatementSyntax)
If method.TypeParameterList IsNot Nothing Then
ReportError(RudeEditKind.InsertGenericMethod)
End If
If method.HandlesClause IsNot Nothing Then
ReportError(RudeEditKind.InsertHandlesClause)
End If
ClassifyModifiedMemberInsert(method.Modifiers)
End Sub
Private Sub ClassifyFieldInsert(field As FieldDeclarationSyntax)
' Can't insert WithEvents field since it is effectively a virtual property.
If field.Modifiers.Any(SyntaxKind.WithEventsKeyword) Then
ReportError(RudeEditKind.Insert)
Return
End If
Dim containingType = field.Parent
If containingType.IsKind(SyntaxKind.ModuleBlock) Then
ReportError(RudeEditKind.Insert)
Return
End If
End Sub
Private Sub ClassifyFieldInsert(fieldVariableName As ModifiedIdentifierSyntax)
ClassifyFieldInsert(DirectCast(fieldVariableName.Parent.Parent, FieldDeclarationSyntax))
End Sub
Private Sub ClassifyParameterInsert(parameterList As ParameterListSyntax)
' Sub M -> Sub M() is ok
If parameterList.Parameters.Count = 0 Then
Return
End If
ReportError(RudeEditKind.Insert)
End Sub
#End Region
#Region "Delete"
Private Sub ClassifyDelete(oldNode As SyntaxNode)
Select Case oldNode.Kind
Case SyntaxKind.OptionStatement,
SyntaxKind.ImportsStatement,
SyntaxKind.AttributesStatement,
SyntaxKind.NamespaceBlock,
SyntaxKind.ClassBlock,
SyntaxKind.StructureBlock,
SyntaxKind.InterfaceBlock,
SyntaxKind.ModuleBlock,
SyntaxKind.DelegateFunctionStatement,
SyntaxKind.DelegateSubStatement,
SyntaxKind.EnumBlock,
SyntaxKind.FieldDeclaration,
SyntaxKind.ModifiedIdentifier,
SyntaxKind.SubBlock,
SyntaxKind.FunctionBlock,
SyntaxKind.SubStatement,
SyntaxKind.FunctionStatement,
SyntaxKind.OperatorBlock,
SyntaxKind.PropertyBlock,
SyntaxKind.PropertyStatement,
SyntaxKind.EventBlock,
SyntaxKind.EventStatement,
SyntaxKind.DeclareSubStatement,
SyntaxKind.DeclareFunctionStatement
' To allow removal of declarations we would need to update method bodies that
' were previously binding to them but now are binding to another symbol that was previously hidden.
ReportError(RudeEditKind.Delete)
Return
Case SyntaxKind.ConstructorBlock
' Allow deletion of a parameterless constructor.
' Semantic analysis reports an error if the parameterless ctor isn't replaced by a default ctor.
If Not SyntaxUtilities.IsParameterlessConstructor(oldNode) Then
ReportError(RudeEditKind.Delete)
End If
Return
Case SyntaxKind.GetAccessorBlock,
SyntaxKind.SetAccessorBlock,
SyntaxKind.AddHandlerAccessorBlock,
SyntaxKind.RemoveHandlerAccessorBlock,
SyntaxKind.RaiseEventAccessorBlock
' An accessor can be removed. Accessors are not hiding other symbols.
' If the new compilation still uses the removed accessor a semantic error will be reported.
' For simplicity though we disallow deletion of accessors for now.
ReportError(RudeEditKind.Delete)
Return
Case SyntaxKind.AttributeList,
SyntaxKind.Attribute
' To allow removal of attributes we would need to check if the removed attribute
' is a pseudo-custom attribute that CLR allows us to change, or if it is a compiler well-know attribute
' that affects the generated IL.
ReportError(RudeEditKind.Delete)
Return
Case SyntaxKind.EnumMemberDeclaration
' We could allow removing enum member if it didn't affect the values of other enum members.
' If the updated compilation binds without errors it means that the enum value wasn't used.
ReportError(RudeEditKind.Delete)
Return
Case SyntaxKind.TypeParameter,
SyntaxKind.TypeParameterList,
SyntaxKind.Parameter,
SyntaxKind.TypeParameterSingleConstraintClause,
SyntaxKind.TypeParameterMultipleConstraintClause,
SyntaxKind.ClassConstraint,
SyntaxKind.StructureConstraint,
SyntaxKind.NewConstraint,
SyntaxKind.TypeConstraint,
SyntaxKind.SimpleAsClause
ReportError(RudeEditKind.Delete)
Return
Case SyntaxKind.ParameterList
ClassifyDelete(DirectCast(oldNode, ParameterListSyntax))
Case SyntaxKind.VariableDeclarator
' Ignore, errors will be reported for children (ModifiedIdentifier, AsClause)
Return
Case Else
Throw ExceptionUtilities.UnexpectedValue(oldNode.Kind)
End Select
End Sub
Private Sub ClassifyDelete(oldNode As ParameterListSyntax)
' Sub Foo() -> Sub Foo is ok
If oldNode.Parameters.Count = 0 Then
Return
End If
ReportError(RudeEditKind.Delete)
End Sub
#End Region
#Region "Update"
Private Sub ClassifyUpdate(oldNode As SyntaxNode, newNode As SyntaxNode)
Select Case newNode.Kind
Case SyntaxKind.OptionStatement
ReportError(RudeEditKind.Update)
Return
Case SyntaxKind.ImportsStatement
ReportError(RudeEditKind.Update)
Return
Case SyntaxKind.NamespaceBlock
Return
Case SyntaxKind.NamespaceStatement
ClassifyUpdate(DirectCast(oldNode, NamespaceStatementSyntax), DirectCast(newNode, NamespaceStatementSyntax))
Return
Case SyntaxKind.ClassBlock,
SyntaxKind.StructureBlock,
SyntaxKind.InterfaceBlock,
SyntaxKind.ModuleBlock
ClassifyUpdate(DirectCast(oldNode, TypeBlockSyntax), DirectCast(newNode, TypeBlockSyntax))
Return
Case SyntaxKind.ClassStatement,
SyntaxKind.StructureStatement,
SyntaxKind.InterfaceStatement,
SyntaxKind.ModuleStatement
ClassifyUpdate(DirectCast(oldNode, TypeStatementSyntax), DirectCast(newNode, TypeStatementSyntax))
Return
Case SyntaxKind.EnumBlock
Return
Case SyntaxKind.EnumStatement
ClassifyUpdate(DirectCast(oldNode, EnumStatementSyntax), DirectCast(newNode, EnumStatementSyntax))
Return
Case SyntaxKind.DelegateSubStatement,
SyntaxKind.DelegateFunctionStatement
ClassifyUpdate(DirectCast(oldNode, DelegateStatementSyntax), DirectCast(newNode, DelegateStatementSyntax))
Return
Case SyntaxKind.FieldDeclaration
ClassifyUpdate(DirectCast(oldNode, FieldDeclarationSyntax), DirectCast(newNode, FieldDeclarationSyntax))
Return
Case SyntaxKind.VariableDeclarator
ClassifyUpdate(DirectCast(oldNode, VariableDeclaratorSyntax), DirectCast(newNode, VariableDeclaratorSyntax))
Return
Case SyntaxKind.ModifiedIdentifier
ClassifyUpdate(DirectCast(oldNode, ModifiedIdentifierSyntax), DirectCast(newNode, ModifiedIdentifierSyntax))
Return
Case SyntaxKind.SubBlock,
SyntaxKind.FunctionBlock
ClassifyUpdate(DirectCast(oldNode, MethodBlockSyntax), DirectCast(newNode, MethodBlockSyntax))
Return
Case SyntaxKind.DeclareSubStatement,
SyntaxKind.DeclareFunctionStatement
ClassifyUpdate(DirectCast(oldNode, DeclareStatementSyntax), DirectCast(newNode, DeclareStatementSyntax))
Return
Case SyntaxKind.SubStatement,
SyntaxKind.FunctionStatement
ClassifyUpdate(DirectCast(oldNode, MethodStatementSyntax), DirectCast(newNode, MethodStatementSyntax))
Return
Case SyntaxKind.SimpleAsClause
ClassifyUpdate(DirectCast(oldNode, SimpleAsClauseSyntax), DirectCast(newNode, SimpleAsClauseSyntax))
Return
Case SyntaxKind.OperatorBlock
ClassifyUpdate(DirectCast(oldNode, OperatorBlockSyntax), DirectCast(newNode, OperatorBlockSyntax))
Return
Case SyntaxKind.OperatorStatement
ClassifyUpdate(DirectCast(oldNode, OperatorStatementSyntax), DirectCast(newNode, OperatorStatementSyntax))
Return
Case SyntaxKind.ConstructorBlock
ClassifyUpdate(DirectCast(oldNode, ConstructorBlockSyntax), DirectCast(newNode, ConstructorBlockSyntax))
Return
Case SyntaxKind.SubNewStatement
ClassifyUpdate(DirectCast(oldNode, SubNewStatementSyntax), DirectCast(newNode, SubNewStatementSyntax))
Return
Case SyntaxKind.PropertyBlock
Return
Case SyntaxKind.PropertyStatement
ClassifyUpdate(DirectCast(oldNode, PropertyStatementSyntax), DirectCast(newNode, PropertyStatementSyntax))
Return
Case SyntaxKind.EventBlock
Return
Case SyntaxKind.EventStatement
ClassifyUpdate(DirectCast(oldNode, EventStatementSyntax), DirectCast(newNode, EventStatementSyntax))
Return
Case SyntaxKind.GetAccessorStatement,
SyntaxKind.SetAccessorStatement,
SyntaxKind.AddHandlerAccessorStatement,
SyntaxKind.RemoveHandlerAccessorStatement,
SyntaxKind.RaiseEventAccessorStatement
Return
Case SyntaxKind.GetAccessorBlock,
SyntaxKind.SetAccessorBlock,
SyntaxKind.AddHandlerAccessorBlock,
SyntaxKind.RemoveHandlerAccessorBlock,
SyntaxKind.RaiseEventAccessorBlock
ClassifyUpdate(DirectCast(oldNode, AccessorBlockSyntax), DirectCast(newNode, AccessorBlockSyntax))
Return
Case SyntaxKind.EnumMemberDeclaration
ClassifyUpdate(DirectCast(oldNode, EnumMemberDeclarationSyntax), DirectCast(newNode, EnumMemberDeclarationSyntax))
Return
Case SyntaxKind.StructureConstraint,
SyntaxKind.ClassConstraint,
SyntaxKind.NewConstraint
ReportError(RudeEditKind.ConstraintKindUpdate,
{DirectCast(oldNode, SpecialConstraintSyntax).ConstraintKeyword.ValueText,
DirectCast(newNode, SpecialConstraintSyntax).ConstraintKeyword.ValueText})
Return
Case SyntaxKind.TypeConstraint
ReportError(RudeEditKind.TypeUpdate)
Return
Case SyntaxKind.TypeParameterMultipleConstraintClause,
SyntaxKind.TypeParameterSingleConstraintClause
Return
Case SyntaxKind.TypeParameter
ClassifyUpdate(DirectCast(oldNode, TypeParameterSyntax), DirectCast(newNode, TypeParameterSyntax))
Return
Case SyntaxKind.Parameter
ClassifyUpdate(DirectCast(oldNode, ParameterSyntax), DirectCast(newNode, ParameterSyntax))
Return
Case SyntaxKind.Attribute
ReportError(RudeEditKind.Update)
Return
Case SyntaxKind.TypeParameterList,
SyntaxKind.ParameterList,
SyntaxKind.AttributeList
Return
Case Else
Throw ExceptionUtilities.UnexpectedValue(newNode.Kind)
End Select
End Sub
Private Sub ClassifyUpdate(oldNode As NamespaceStatementSyntax, newNode As NamespaceStatementSyntax)
Debug.Assert(Not SyntaxFactory.AreEquivalent(oldNode.Name, newNode.Name))
ReportError(RudeEditKind.Renamed)
End Sub
Private Sub ClassifyUpdate(oldNode As TypeStatementSyntax, newNode As TypeStatementSyntax)
If oldNode.RawKind <> newNode.RawKind Then
ReportError(RudeEditKind.TypeKindUpdate)
Return
End If
If Not SyntaxFactory.AreEquivalent(oldNode.Modifiers, newNode.Modifiers) Then
ReportError(RudeEditKind.ModifiersUpdate)
Return
End If
Debug.Assert(Not SyntaxFactory.AreEquivalent(oldNode.Identifier, newNode.Identifier))
ReportError(RudeEditKind.Renamed)
End Sub
Private Sub ClassifyUpdate(oldNode As TypeBlockSyntax, newNode As TypeBlockSyntax)
If Not SyntaxFactory.AreEquivalent(oldNode.Inherits, newNode.Inherits) OrElse
Not SyntaxFactory.AreEquivalent(oldNode.Implements, newNode.Implements) Then
ReportError(RudeEditKind.BaseTypeOrInterfaceUpdate)
End If
' type member list separators
End Sub
Private Sub ClassifyUpdate(oldNode As EnumStatementSyntax, newNode As EnumStatementSyntax)
If Not SyntaxFactory.AreEquivalent(oldNode.Identifier, newNode.Identifier) Then
ReportError(RudeEditKind.Renamed)
Return
End If
If Not SyntaxFactory.AreEquivalent(oldNode.Modifiers, newNode.Modifiers) Then
ReportError(RudeEditKind.ModifiersUpdate)
Return
End If
Debug.Assert(Not SyntaxFactory.AreEquivalent(oldNode.UnderlyingType, newNode.UnderlyingType))
ReportError(RudeEditKind.EnumUnderlyingTypeUpdate)
End Sub
Private Sub ClassifyUpdate(oldNode As DelegateStatementSyntax, newNode As DelegateStatementSyntax)
If Not SyntaxFactory.AreEquivalent(oldNode.Modifiers, newNode.Modifiers) Then
ReportError(RudeEditKind.ModifiersUpdate)
Return
End If
' Function changed to Sub or vice versa. Note that Function doesn't need to have AsClause.
If oldNode.RawKind <> newNode.RawKind Then
ReportError(RudeEditKind.TypeUpdate)
Return
End If
If Not SyntaxFactory.AreEquivalent(oldNode.AsClause, newNode.AsClause) Then
ReportError(RudeEditKind.TypeUpdate)
Return
End If
Debug.Assert(Not SyntaxFactory.AreEquivalent(oldNode.Identifier, newNode.Identifier))
ReportError(RudeEditKind.Renamed)
End Sub
Private Sub ClassifyUpdate(oldNode As FieldDeclarationSyntax, newNode As FieldDeclarationSyntax)
If Not SyntaxFactory.AreEquivalent(oldNode.Modifiers, newNode.Modifiers) Then
ReportError(RudeEditKind.ModifiersUpdate)
End If
' VariableDeclarator separators were modified
End Sub
Private Sub ClassifyUpdate(oldNode As ModifiedIdentifierSyntax, newNode As ModifiedIdentifierSyntax)
If Not SyntaxFactory.AreEquivalent(oldNode.Identifier, newNode.Identifier) Then
ReportError(RudeEditKind.Renamed)
Return
End If
' TODO (tomat): We could be smarter and consider the following syntax changes to be legal:
' Dim a? As Integer <-> Dim a As Integer?
' Dim a() As Integer <-> Dim a As Integer()
If Not SyntaxFactory.AreEquivalent(oldNode.ArrayRankSpecifiers, newNode.ArrayRankSpecifiers) OrElse
Not SyntaxFactory.AreEquivalent(oldNode.Nullable, newNode.Nullable) Then
ReportError(RudeEditKind.TypeUpdate)
Return
End If
Debug.Assert(Not SyntaxFactory.AreEquivalent(oldNode.ArrayBounds, newNode.ArrayBounds))
If oldNode.ArrayBounds Is Nothing OrElse
newNode.ArrayBounds Is Nothing OrElse
oldNode.ArrayBounds.Arguments.Count <> newNode.ArrayBounds.Arguments.Count Then
ReportError(RudeEditKind.TypeUpdate)
Return
End If
' Otherwise only the size of the array changed, which is a legal initializer update
' unless it contains lambdas, queries etc.
ClassifyDeclarationBodyRudeUpdates(newNode)
End Sub
Private Sub ClassifyUpdate(oldNode As VariableDeclaratorSyntax, newNode As VariableDeclaratorSyntax)
Dim typeDeclaration = DirectCast(oldNode.Parent.Parent, TypeBlockSyntax)
If typeDeclaration.BlockStatement.Arity > 0 Then
ReportError(RudeEditKind.GenericTypeInitializerUpdate)
Return
End If
If ClassifyTypeAndInitializerUpdates(oldNode.Initializer,
oldNode.AsClause,
newNode.Initializer,
newNode.AsClause) Then
' Check if a constant field is updated:
Dim fieldDeclaration = DirectCast(oldNode.Parent, FieldDeclarationSyntax)
If fieldDeclaration.Modifiers.Any(SyntaxKind.ConstKeyword) Then
ReportError(RudeEditKind.Update)
Return
End If
End If
End Sub
Private Sub ClassifyUpdate(oldNode As PropertyStatementSyntax, newNode As PropertyStatementSyntax)
If Not IncludesSignificantPropertyModifiers(oldNode.Modifiers, newNode.Modifiers) OrElse
Not IncludesSignificantPropertyModifiers(newNode.Modifiers, oldNode.Modifiers) Then
ReportError(RudeEditKind.ModifiersUpdate)
Return
End If
If Not SyntaxFactory.AreEquivalent(oldNode.Identifier, newNode.Identifier) Then
ReportError(RudeEditKind.Renamed)
Return
End If
If Not SyntaxFactory.AreEquivalent(oldNode.ImplementsClause, newNode.ImplementsClause) Then
ReportError(RudeEditKind.ImplementsClauseUpdate)
Return
End If
If ClassifyTypeAndInitializerUpdates(oldNode.Initializer, oldNode.AsClause, newNode.Initializer, newNode.AsClause) Then
' change in an initializer of an auto-property
Dim typeDeclaration = DirectCast(oldNode.Parent, TypeBlockSyntax)
If typeDeclaration.BlockStatement.Arity > 0 Then
ReportError(RudeEditKind.GenericTypeInitializerUpdate)
Return
End If
End If
End Sub
Private Shared Function IncludesSignificantPropertyModifiers(subset As SyntaxTokenList, superset As SyntaxTokenList) As Boolean
For Each modifier In subset
' ReadOnly and WriteOnly keywords are redundant, it would be a semantic error if they Then didn't match the present accessors.
' We want to allow adding an accessor to a property, which requires change in the RO/WO modifiers.
If modifier.IsKind(SyntaxKind.ReadOnlyKeyword) OrElse
modifier.IsKind(SyntaxKind.WriteOnlyKeyword) Then
Continue For
End If
If Not superset.Any(modifier.Kind) Then
Return False
End If
Next
Return True
End Function
' Returns true if the initializer has changed.
Private Function ClassifyTypeAndInitializerUpdates(oldEqualsValue As EqualsValueSyntax,
oldClause As AsClauseSyntax,
newEqualsValue As EqualsValueSyntax,
newClause As AsClauseSyntax) As Boolean
Dim oldInitializer = GetInitializerExpression(oldEqualsValue, oldClause)
Dim newInitializer = GetInitializerExpression(newEqualsValue, newClause)
If newInitializer IsNot Nothing AndAlso Not SyntaxFactory.AreEquivalent(oldInitializer, newInitializer) Then
ClassifyDeclarationBodyRudeUpdates(newInitializer)
Return True
End If
Return False
End Function
Private Sub ClassifyUpdate(oldNode As EventStatementSyntax, newNode As EventStatementSyntax)
' A custom event can't be matched with a field event and vice versa:
Debug.Assert(SyntaxFactory.AreEquivalent(oldNode.CustomKeyword, newNode.CustomKeyword))
If Not SyntaxFactory.AreEquivalent(oldNode.Modifiers, newNode.Modifiers) Then
ReportError(RudeEditKind.ModifiersUpdate)
End If
If Not SyntaxFactory.AreEquivalent(oldNode.Identifier, newNode.Identifier) Then
ReportError(RudeEditKind.Renamed)
Return
End If
If Not SyntaxFactory.AreEquivalent(oldNode.ImplementsClause, newNode.ImplementsClause) Then
ReportError(RudeEditKind.ImplementsClauseUpdate)
Return
End If
Dim oldHasGeneratedType = oldNode.ParameterList IsNot Nothing
Dim newHasGeneratedType = newNode.ParameterList IsNot Nothing
Debug.Assert(oldHasGeneratedType <> newHasGeneratedType)
ReportError(RudeEditKind.TypeUpdate)
End Sub
Private Sub ClassifyUpdate(oldNode As MethodBlockSyntax, newNode As MethodBlockSyntax)
ClassifyMethodBodyRudeUpdate(oldNode,
newNode,
containingMethod:=newNode,
containingType:=DirectCast(newNode.Parent, TypeBlockSyntax))
End Sub
Private Sub ClassifyUpdate(oldNode As MethodStatementSyntax, newNode As MethodStatementSyntax)
If Not SyntaxFactory.AreEquivalent(oldNode.DeclarationKeyword, newNode.DeclarationKeyword) Then
ReportError(RudeEditKind.MethodKindUpdate)
Return
End If
If Not SyntaxFactory.AreEquivalent(oldNode.Identifier, newNode.Identifier) Then
ReportError(RudeEditKind.Renamed)
Return
End If
If Not ClassifyMethodModifierUpdate(oldNode.Modifiers, newNode.Modifiers) Then
ReportError(RudeEditKind.ModifiersUpdate)
Return
End If
' TODO (tomat): We can support this
If Not SyntaxFactory.AreEquivalent(oldNode.HandlesClause, newNode.HandlesClause) Then
ReportError(RudeEditKind.HandlesClauseUpdate)
Return
End If
If Not SyntaxFactory.AreEquivalent(oldNode.ImplementsClause, newNode.ImplementsClause) Then
ReportError(RudeEditKind.ImplementsClauseUpdate)
Return
End If
End Sub
Private Function ClassifyMethodModifierUpdate(oldModifiers As SyntaxTokenList, newModifiers As SyntaxTokenList) As Boolean
Dim oldAsyncIndex = oldModifiers.IndexOf(SyntaxKind.AsyncKeyword)
Dim newAsyncIndex = newModifiers.IndexOf(SyntaxKind.AsyncKeyword)
If oldAsyncIndex >= 0 Then
oldModifiers = oldModifiers.RemoveAt(oldAsyncIndex)
End If
If newAsyncIndex >= 0 Then
newModifiers = newModifiers.RemoveAt(newAsyncIndex)
End If
' 'async' keyword is allowed to add, but not to remove
If oldAsyncIndex >= 0 AndAlso newAsyncIndex < 0 Then
Return False
End If
Dim oldIteratorIndex = oldModifiers.IndexOf(SyntaxKind.IteratorKeyword)
Dim newIteratorIndex = newModifiers.IndexOf(SyntaxKind.IteratorKeyword)
If oldIteratorIndex >= 0 Then
oldModifiers = oldModifiers.RemoveAt(oldIteratorIndex)
End If
If newIteratorIndex >= 0 Then
newModifiers = newModifiers.RemoveAt(newIteratorIndex)
End If
' 'iterator' keyword is allowed to add, but not to remove
If oldIteratorIndex >= 0 AndAlso newIteratorIndex < 0 Then
Return False
End If
Return SyntaxFactory.AreEquivalent(oldModifiers, newModifiers)
End Function
Private Sub ClassifyUpdate(oldNode As DeclareStatementSyntax, newNode As DeclareStatementSyntax)
If Not SyntaxFactory.AreEquivalent(oldNode.Identifier, newNode.Identifier) Then
ReportError(RudeEditKind.Renamed)
Return
End If
If Not SyntaxFactory.AreEquivalent(oldNode.Modifiers, newNode.Modifiers) Then
ReportError(RudeEditKind.ModifiersUpdate)
Return
End If
If Not SyntaxFactory.AreEquivalent(oldNode.CharsetKeyword, newNode.CharsetKeyword) Then
ReportError(RudeEditKind.ModifiersUpdate)
Return
End If
If Not SyntaxFactory.AreEquivalent(oldNode.LibraryName, newNode.LibraryName) Then
ReportError(RudeEditKind.DeclareLibraryUpdate)
Return
End If
Debug.Assert(Not SyntaxFactory.AreEquivalent(oldNode.AliasName, newNode.AliasName))
ReportError(RudeEditKind.DeclareAliasUpdate)
End Sub
Private Sub ClassifyUpdate(oldNode As OperatorBlockSyntax, newNode As OperatorBlockSyntax)
ClassifyMethodBodyRudeUpdate(oldNode,
newNode,
containingMethod:=Nothing,
containingType:=DirectCast(newNode.Parent, TypeBlockSyntax))
End Sub
Private Sub ClassifyUpdate(oldNode As OperatorStatementSyntax, newNode As OperatorStatementSyntax)
If Not SyntaxFactory.AreEquivalent(oldNode.Modifiers, newNode.Modifiers) Then
ReportError(RudeEditKind.ModifiersUpdate)
Return
End If
Debug.Assert(Not SyntaxFactory.AreEquivalent(oldNode.OperatorToken, newNode.OperatorToken))
ReportError(RudeEditKind.Renamed)
End Sub
Private Sub ClassifyUpdate(oldNode As AccessorBlockSyntax, newNode As AccessorBlockSyntax)
Debug.Assert(newNode.Parent.IsKind(SyntaxKind.EventBlock) OrElse
newNode.Parent.IsKind(SyntaxKind.PropertyBlock))
ClassifyMethodBodyRudeUpdate(oldNode,
newNode,
containingMethod:=Nothing,
containingType:=DirectCast(newNode.Parent.Parent, TypeBlockSyntax))
End Sub
Private Sub ClassifyUpdate(oldNode As AccessorStatementSyntax, newNode As AccessorStatementSyntax)
If oldNode.RawKind <> newNode.RawKind Then
ReportError(RudeEditKind.AccessorKindUpdate)
Return
End If
If Not SyntaxFactory.AreEquivalent(oldNode.Modifiers, newNode.Modifiers) Then
ReportError(RudeEditKind.ModifiersUpdate)
Return
End If
End Sub
Private Sub ClassifyUpdate(oldNode As EnumMemberDeclarationSyntax, newNode As EnumMemberDeclarationSyntax)
If Not SyntaxFactory.AreEquivalent(oldNode.Identifier, newNode.Identifier) Then
ReportError(RudeEditKind.Renamed)
Return
End If
Debug.Assert(Not SyntaxFactory.AreEquivalent(oldNode.Initializer, newNode.Initializer))
ReportError(RudeEditKind.InitializerUpdate)
End Sub
Private Sub ClassifyUpdate(oldNode As ConstructorBlockSyntax, newNode As ConstructorBlockSyntax)
ClassifyMethodBodyRudeUpdate(oldNode,
newNode,
containingMethod:=Nothing,
containingType:=DirectCast(newNode.Parent, TypeBlockSyntax))
End Sub
Private Sub ClassifyUpdate(oldNode As SubNewStatementSyntax, newNode As SubNewStatementSyntax)
If Not SyntaxFactory.AreEquivalent(oldNode.Modifiers, newNode.Modifiers) Then
ReportError(RudeEditKind.ModifiersUpdate)
Return
End If
End Sub
Private Sub ClassifyUpdate(oldNode As SimpleAsClauseSyntax, newNode As SimpleAsClauseSyntax)
Debug.Assert(Not SyntaxFactory.AreEquivalent(oldNode.Type, newNode.Type))
ReportError(RudeEditKind.TypeUpdate, newNode.Parent, newNode.Parent)
End Sub
Private Sub ClassifyUpdate(oldNode As TypeParameterSyntax, newNode As TypeParameterSyntax)
If Not SyntaxFactory.AreEquivalent(oldNode.Identifier, newNode.Identifier) Then
ReportError(RudeEditKind.Renamed)
Return
End If
Debug.Assert(Not SyntaxFactory.AreEquivalent(oldNode.VarianceKeyword, newNode.VarianceKeyword))
ReportError(RudeEditKind.VarianceUpdate)
End Sub
Private Sub ClassifyUpdate(oldNode As ParameterSyntax, newNode As ParameterSyntax)
If Not SyntaxFactory.AreEquivalent(oldNode.Identifier, newNode.Identifier) Then
ReportError(RudeEditKind.Renamed)
Return
End If
If Not SyntaxFactory.AreEquivalent(oldNode.Modifiers, newNode.Modifiers) Then
ReportError(RudeEditKind.ModifiersUpdate)
Return
End If
If Not SyntaxFactory.AreEquivalent(oldNode.Default, newNode.Default) Then
ReportError(RudeEditKind.InitializerUpdate)
Return
End If
If ClassifyTypeAndInitializerUpdates(oldNode.Default, oldNode.AsClause, newNode.Default, newNode.AsClause) Then
Return
End If
ClassifyUpdate(oldNode.Identifier, newNode.Identifier)
End Sub
Private Sub ClassifyMethodBodyRudeUpdate(oldBody As MethodBlockBaseSyntax,
newBody As MethodBlockBaseSyntax,
containingMethod As MethodBlockSyntax,
containingType As TypeBlockSyntax)
If (oldBody.EndBlockStatement Is Nothing) <> (newBody.EndBlockStatement Is Nothing) Then
If oldBody.EndBlockStatement Is Nothing Then
ReportError(RudeEditKind.MethodBodyAdd)
Return
Else
ReportError(RudeEditKind.MethodBodyDelete)
Return
End If
End If
' The method only gets called if there are no other changes to the method declaration.
' Since we got the update edit something has to be different in the body.
Debug.Assert(newBody.EndBlockStatement IsNot Nothing)
ClassifyMemberBodyRudeUpdate(containingMethod, containingType, isTriviaUpdate:=False)
ClassifyDeclarationBodyRudeUpdates(newBody)
End Sub
Public Sub ClassifyMemberBodyRudeUpdate(containingMethodOpt As MethodBlockSyntax, containingTypeOpt As TypeBlockSyntax, isTriviaUpdate As Boolean)
If containingMethodOpt?.SubOrFunctionStatement.TypeParameterList IsNot Nothing Then
ReportError(If(isTriviaUpdate, RudeEditKind.GenericMethodTriviaUpdate, RudeEditKind.GenericMethodUpdate))
Return
End If
If containingTypeOpt?.BlockStatement.Arity > 0 Then
ReportError(If(isTriviaUpdate, RudeEditKind.GenericTypeTriviaUpdate, RudeEditKind.GenericTypeUpdate))
Return
End If
End Sub
Public Sub ClassifyDeclarationBodyRudeUpdates(newDeclarationOrBody As SyntaxNode)
For Each node In newDeclarationOrBody.DescendantNodesAndSelf()
Select Case node.Kind
Case SyntaxKind.AggregateClause,
SyntaxKind.GroupByClause,
SyntaxKind.SimpleJoinClause,
SyntaxKind.GroupJoinClause
ReportError(RudeEditKind.RUDE_EDIT_COMPLEX_QUERY_EXPRESSION, node, Me._newNode)
Return
Case SyntaxKind.LocalDeclarationStatement
Dim declaration = DirectCast(node, LocalDeclarationStatementSyntax)
If declaration.Modifiers.Any(SyntaxKind.StaticKeyword) Then
ReportError(RudeEditKind.UpdateStaticLocal)
End If
End Select
Next
End Sub
#End Region
End Structure
Friend Overrides Sub ReportSyntacticRudeEdits(diagnostics As List(Of RudeEditDiagnostic),
match As Match(Of SyntaxNode),
edit As Edit(Of SyntaxNode),
editMap As Dictionary(Of SyntaxNode, EditKind))
' For most nodes we ignore Insert and Delete edits if their parent was also inserted or deleted, respectively.
' For ModifiedIdentifiers though we check the grandparent instead because variables can move across
' VariableDeclarators. Moving a variable from a VariableDeclarator that only has a single variable results in
' deletion of that declarator. We don't want to report that delete. Similarly for moving to a new VariableDeclarator.
If edit.Kind = EditKind.Delete AndAlso
edit.OldNode.IsKind(SyntaxKind.ModifiedIdentifier) AndAlso
edit.OldNode.Parent.IsKind(SyntaxKind.VariableDeclarator) Then
If HasEdit(editMap, edit.OldNode.Parent.Parent, EditKind.Delete) Then
Return
End If
ElseIf edit.Kind = EditKind.Insert AndAlso
edit.NewNode.IsKind(SyntaxKind.ModifiedIdentifier) AndAlso
edit.NewNode.Parent.IsKind(SyntaxKind.VariableDeclarator) Then
If HasEdit(editMap, edit.NewNode.Parent.Parent, EditKind.Insert) Then
Return
End If
ElseIf HasParentEdit(editMap, edit) Then
Return
End If
Dim classifier = New EditClassifier(Me, diagnostics, edit.OldNode, edit.NewNode, edit.Kind, match)
classifier.ClassifyEdit()
End Sub
Friend Overrides Sub ReportMemberUpdateRudeEdits(diagnostics As List(Of RudeEditDiagnostic), newMember As SyntaxNode, span As TextSpan?)
Dim classifier = New EditClassifier(Me, diagnostics, Nothing, newMember, EditKind.Update, span:=span)
classifier.ClassifyMemberBodyRudeUpdate(
TryCast(newMember, MethodBlockSyntax),
newMember.FirstAncestorOrSelf(Of TypeBlockSyntax)(),
isTriviaUpdate:=True)
classifier.ClassifyDeclarationBodyRudeUpdates(newMember)
End Sub
#End Region
#Region "Semantic Rude Edits"
Friend Overrides Sub ReportInsertedMemberSymbolRudeEdits(diagnostics As List(Of RudeEditDiagnostic), newSymbol As ISymbol)
' CLR doesn't support adding P/Invokes.
' VB needs to check if the type doesn't contain methods with DllImport attribute.
If newSymbol.IsKind(SymbolKind.NamedType) Then
For Each member In DirectCast(newSymbol, INamedTypeSymbol).GetMembers()
ReportDllImportInsertRudeEdit(diagnostics, member)
Next
Else
ReportDllImportInsertRudeEdit(diagnostics, newSymbol)
End If
End Sub
Private Shared Sub ReportDllImportInsertRudeEdit(diagnostics As List(Of RudeEditDiagnostic), member As ISymbol)
If member.IsKind(SymbolKind.Method) AndAlso
DirectCast(member, IMethodSymbol).GetDllImportData() IsNot Nothing Then
diagnostics.Add(New RudeEditDiagnostic(RudeEditKind.InsertDllImport,
member.Locations.First().SourceSpan))
End If
End Sub
#End Region
#Region "Exception Handling Rude Edits"
Protected Overrides Function GetExceptionHandlingAncestors(node As SyntaxNode, isLeaf As Boolean) As List(Of SyntaxNode)
Dim result = New List(Of SyntaxNode)()
Dim initialNode = node
While node IsNot Nothing
Dim kind = node.Kind
Select Case kind
Case SyntaxKind.TryBlock
If Not isLeaf Then
result.Add(node)
End If
Case SyntaxKind.CatchBlock,
SyntaxKind.FinallyBlock
result.Add(node)
Debug.Assert(node.Parent.Kind = SyntaxKind.TryBlock)
node = node.Parent
Case SyntaxKind.ClassBlock,
SyntaxKind.StructureBlock
' stop at type declaration
Exit While
End Select
' stop at lambda
If LambdaUtilities.IsLambda(node) Then
Exit While
End If
node = node.Parent
End While
Return result
End Function
Friend Overrides Sub ReportEnclosingExceptionHandlingRudeEdits(diagnostics As List(Of RudeEditDiagnostic),
exceptionHandlingEdits As IEnumerable(Of Edit(Of SyntaxNode)),
oldStatement As SyntaxNode,
newStatementSpan As TextSpan)
For Each edit In exceptionHandlingEdits
Debug.Assert(edit.Kind <> EditKind.Update OrElse edit.OldNode.RawKind = edit.NewNode.RawKind)
If edit.Kind <> EditKind.Update OrElse Not AreExceptionHandlingPartsEquivalent(edit.OldNode, edit.NewNode) Then
AddRudeDiagnostic(diagnostics, edit.OldNode, edit.NewNode, newStatementSpan)
End If
Next
End Sub
Private Shared Function AreExceptionHandlingPartsEquivalent(oldNode As SyntaxNode, newNode As SyntaxNode) As Boolean
Select Case oldNode.Kind
Case SyntaxKind.TryBlock
Dim oldTryBlock = DirectCast(oldNode, TryBlockSyntax)
Dim newTryBlock = DirectCast(newNode, TryBlockSyntax)
Return SyntaxFactory.AreEquivalent(oldTryBlock.FinallyBlock, newTryBlock.FinallyBlock) AndAlso
SyntaxFactory.AreEquivalent(oldTryBlock.CatchBlocks, newTryBlock.CatchBlocks)
Case SyntaxKind.CatchBlock,
SyntaxKind.FinallyBlock
Return SyntaxFactory.AreEquivalent(oldNode, newNode)
Case Else
Throw ExceptionUtilities.UnexpectedValue(oldNode.Kind)
End Select
End Function
''' <summary>
''' An active statement (leaf or not) inside a "Catch" makes the Catch part readonly.
''' An active statement (leaf or not) inside a "Finally" makes the whole Try/Catch/Finally part read-only.
''' An active statement (non leaf) inside a "Try" makes the Catch/Finally part read-only.
''' </summary>
Protected Overrides Function GetExceptionHandlingRegion(node As SyntaxNode, <Out> ByRef coversAllChildren As Boolean) As TextSpan
Select Case node.Kind
Case SyntaxKind.TryBlock
Dim tryBlock = DirectCast(node, TryBlockSyntax)
coversAllChildren = False
If tryBlock.CatchBlocks.Count = 0 Then
Debug.Assert(tryBlock.FinallyBlock IsNot Nothing)
Return TextSpan.FromBounds(tryBlock.FinallyBlock.SpanStart, tryBlock.EndTryStatement.Span.End)
End If
Return TextSpan.FromBounds(tryBlock.CatchBlocks.First().SpanStart, tryBlock.EndTryStatement.Span.End)
Case SyntaxKind.CatchBlock
coversAllChildren = True
Return node.Span
Case SyntaxKind.FinallyBlock
coversAllChildren = True
Return DirectCast(node.Parent, TryBlockSyntax).Span
Case Else
Throw ExceptionUtilities.UnexpectedValue(node.Kind)
End Select
End Function
#End Region
#Region "State Machines"
Friend Overrides Function IsStateMachineMethod(declaration As SyntaxNode) As Boolean
Return SyntaxUtilities.IsAsyncMethodOrLambda(declaration) OrElse
SyntaxUtilities.IsIteratorMethodOrLambda(declaration)
End Function
Protected Overrides Sub GetStateMachineInfo(body As SyntaxNode, ByRef suspensionPoints As ImmutableArray(Of SyntaxNode), ByRef kind As StateMachineKind)
' In VB declaration and body are represented by the same node for both lambdas and methods (unlike C#)
If SyntaxUtilities.IsAsyncMethodOrLambda(body) Then
suspensionPoints = SyntaxUtilities.GetAwaitExpressions(body)
kind = StateMachineKind.Async
ElseIf SyntaxUtilities.IsIteratorMethodOrLambda(body) Then
suspensionPoints = SyntaxUtilities.GetYieldStatements(body)
kind = StateMachineKind.Iterator
Else
suspensionPoints = ImmutableArray(Of SyntaxNode).Empty
kind = StateMachineKind.None
End If
End Sub
Friend Overrides Sub ReportStateMachineSuspensionPointRudeEdits(diagnostics As List(Of RudeEditDiagnostic), oldNode As SyntaxNode, newNode As SyntaxNode)
' TODO: changes around suspension points (foreach, lock, using, etc.)
If newNode.IsKind(SyntaxKind.AwaitExpression) Then
Dim oldContainingStatementPart = FindContainingStatementPart(oldNode)
Dim newContainingStatementPart = FindContainingStatementPart(newNode)
' If the old statement has spilled state and the new doesn't, the edit is ok. We'll just not use the spilled state.
If Not SyntaxFactory.AreEquivalent(oldContainingStatementPart, newContainingStatementPart) AndAlso
Not HasNoSpilledState(newNode, newContainingStatementPart) Then
diagnostics.Add(New RudeEditDiagnostic(RudeEditKind.AwaitStatementUpdate, newContainingStatementPart.Span))
End If
End If
End Sub
Private Shared Function FindContainingStatementPart(node As SyntaxNode) As SyntaxNode
Dim statement = TryCast(node, StatementSyntax)
While statement Is Nothing
Select Case node.Parent.Kind()
Case SyntaxKind.ForStatement,
SyntaxKind.ForEachStatement,
SyntaxKind.IfStatement,
SyntaxKind.WhileStatement,
SyntaxKind.SimpleDoStatement,
SyntaxKind.SelectStatement,
SyntaxKind.UsingStatement
Return node
End Select
If LambdaUtilities.IsLambdaBodyStatementOrExpression(node) Then
Return node
End If
node = node.Parent
statement = TryCast(node, StatementSyntax)
End While
Return statement
End Function
Private Shared Function HasNoSpilledState(awaitExpression As SyntaxNode, containingStatementPart As SyntaxNode) As Boolean
Debug.Assert(awaitExpression.IsKind(SyntaxKind.AwaitExpression))
' There is nothing within the statement part surrounding the await expression.
If containingStatementPart Is awaitExpression Then
Return True
End If
Select Case containingStatementPart.Kind()
Case SyntaxKind.ExpressionStatement,
SyntaxKind.ReturnStatement
Dim expression = GetExpressionFromStatementPart(containingStatementPart)
' Await <expr>
' Return Await <expr>
If expression Is awaitExpression Then
Return True
End If
' <ident> = Await <expr>
' Return <ident> = Await <expr>
Return IsSimpleAwaitAssignment(expression, awaitExpression)
Case SyntaxKind.VariableDeclarator
' <ident> = Await <expr> in using, for, etc
' EqualsValue -> VariableDeclarator
Return awaitExpression.Parent.Parent Is containingStatementPart
Case SyntaxKind.LoopUntilStatement,
SyntaxKind.LoopWhileStatement,
SyntaxKind.DoUntilStatement,
SyntaxKind.DoWhileStatement
' Until Await <expr>
' UntilClause -> LoopUntilStatement
Return awaitExpression.Parent.Parent Is containingStatementPart
Case SyntaxKind.LocalDeclarationStatement
' Dim <ident> = Await <expr>
' EqualsValue -> VariableDeclarator -> LocalDeclarationStatement
Return awaitExpression.Parent.Parent.Parent Is containingStatementPart
End Select
Return IsSimpleAwaitAssignment(containingStatementPart, awaitExpression)
End Function
Private Shared Function GetExpressionFromStatementPart(statement As SyntaxNode) As ExpressionSyntax
Select Case statement.Kind()
Case SyntaxKind.ExpressionStatement
Return DirectCast(statement, ExpressionStatementSyntax).Expression
Case SyntaxKind.ReturnStatement
Return DirectCast(statement, ReturnStatementSyntax).Expression
Case Else
Throw ExceptionUtilities.UnexpectedValue(statement.Kind())
End Select
End Function
Private Shared Function IsSimpleAwaitAssignment(node As SyntaxNode, awaitExpression As SyntaxNode) As Boolean
If node.IsKind(SyntaxKind.SimpleAssignmentStatement) Then
Dim assignment = DirectCast(node, AssignmentStatementSyntax)
Return assignment.Left.IsKind(SyntaxKind.IdentifierName) AndAlso assignment.Right Is awaitExpression
End If
Return False
End Function
#End Region
#Region "Rude Edits around Active Statement"
Friend Overrides Sub ReportOtherRudeEditsAroundActiveStatement(diagnostics As List(Of RudeEditDiagnostic),
match As Match(Of SyntaxNode),
oldActiveStatement As SyntaxNode,
newActiveStatement As SyntaxNode,
isLeaf As Boolean)
Dim onErrorOrResumeStatement = FindOnErrorOrResumeStatement(match.NewRoot)
If onErrorOrResumeStatement IsNot Nothing Then
AddRudeDiagnostic(diagnostics, oldActiveStatement, onErrorOrResumeStatement, newActiveStatement.Span)
End If
ReportRudeEditsForAncestorsDeclaringInterStatementTemps(diagnostics, match, oldActiveStatement, newActiveStatement, isLeaf)
End Sub
Private Shared Function FindOnErrorOrResumeStatement(newDeclarationOrBody As SyntaxNode) As SyntaxNode
For Each node In newDeclarationOrBody.DescendantNodes(AddressOf ChildrenCompiledInBody)
Select Case node.Kind
Case SyntaxKind.OnErrorGoToLabelStatement,
SyntaxKind.OnErrorGoToMinusOneStatement,
SyntaxKind.OnErrorGoToZeroStatement,
SyntaxKind.OnErrorResumeNextStatement,
SyntaxKind.ResumeStatement,
SyntaxKind.ResumeNextStatement,
SyntaxKind.ResumeLabelStatement
Return node
End Select
Next
Return Nothing
End Function
Private Sub ReportRudeEditsForAncestorsDeclaringInterStatementTemps(diagnostics As List(Of RudeEditDiagnostic),
match As Match(Of SyntaxNode),
oldActiveStatement As SyntaxNode,
newActiveStatement As SyntaxNode,
isLeaf As Boolean)
' Rude Edits for Using/SyncLock/With/ForEach statements that are added/updated around an active statement.
' Although such changes are technically possible, they might lead to confusion since
' the temporary variables these statements generate won't be properly initialized.
'
' We use a simple algorithm to match each New node with its old counterpart.
' If all nodes match this algorithm Is linear, otherwise it's quadratic.
'
' Unlike exception regions matching where we use LCS, we allow reordering of the statements.
ReportUnmatchedStatements(Of SyncLockBlockSyntax)(diagnostics, match, New Integer() {SyntaxKind.SyncLockBlock}, oldActiveStatement, newActiveStatement,
areEquivalent:=Function(n1, n2) AreEquivalentIgnoringLambdaBodies(n1.SyncLockStatement.Expression, n2.SyncLockStatement.Expression),
areSimilar:=Nothing)
ReportUnmatchedStatements(Of WithBlockSyntax)(diagnostics, match, New Integer() {SyntaxKind.WithBlock}, oldActiveStatement, newActiveStatement,
areEquivalent:=Function(n1, n2) AreEquivalentIgnoringLambdaBodies(n1.WithStatement.Expression, n2.WithStatement.Expression),
areSimilar:=Nothing)
ReportUnmatchedStatements(Of UsingBlockSyntax)(diagnostics, match, New Integer() {SyntaxKind.UsingBlock}, oldActiveStatement, newActiveStatement,
areEquivalent:=Function(n1, n2) AreEquivalentIgnoringLambdaBodies(n1.UsingStatement.Expression, n2.UsingStatement.Expression),
areSimilar:=Nothing)
ReportUnmatchedStatements(Of ForOrForEachBlockSyntax)(diagnostics, match, New Integer() {SyntaxKind.ForEachBlock}, oldActiveStatement, newActiveStatement,
areEquivalent:=Function(n1, n2) AreEquivalentIgnoringLambdaBodies(n1.ForOrForEachStatement, n2.ForOrForEachStatement),
areSimilar:=Function(n1, n2) AreEquivalentIgnoringLambdaBodies(DirectCast(n1.ForOrForEachStatement, ForEachStatementSyntax).ControlVariable,
DirectCast(n2.ForOrForEachStatement, ForEachStatementSyntax).ControlVariable))
End Sub
#End Region
End Class
End Namespace
|
yeaicc/roslyn
|
src/Features/VisualBasic/Portable/EditAndContinue/VisualBasicEditAndContinueAnalyzer.vb
|
Visual Basic
|
apache-2.0
| 156,519
|
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System.Threading.Tasks
Namespace Microsoft.CodeAnalysis.Editor.UnitTests.IntelliSense
<[UseExportProvider]>
Public Class CSharpCompletionCommandHandlerTests_InternalsVisibleTo
<WpfFact, Trait(Traits.Feature, Traits.Features.Completion)>
Public Async Function CodeCompletionContainsOtherAssembliesOfSolution() As Task
Using state = TestState.CreateTestStateFromWorkspace(
<Workspace>
<Project Language="C#" CommonReferences="true" AssemblyName="ClassLibrary1"/>
<Project Language="C#" CommonReferences="true" AssemblyName="ClassLibrary2"/>
<Project Language="C#" CommonReferences="true" AssemblyName="ClassLibrary3"/>
<Project Language="C#" CommonReferences="true" AssemblyName="TestAssembly">
<Document FilePath="C.cs">
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("$$
</Document>
</Project>
</Workspace>)
state.SendInvokeCompletionList()
Await state.AssertCompletionSession()
Assert.True(state.CompletionItemsContainsAll({"ClassLibrary1", "ClassLibrary2", "ClassLibrary3"}))
End Using
End Function
<WpfFact, Trait(Traits.Feature, Traits.Features.Completion)>
Public Async Function CodeCompletionContainsOtherAssemblyIfAttributeSuffixIsPresent() As Task
Using state = TestState.CreateTestStateFromWorkspace(
<Workspace>
<Project Language="C#" CommonReferences="true" AssemblyName="ClassLibrary1"/>
<Project Language="C#" CommonReferences="true" AssemblyName="TestAssembly">
<Document FilePath="C.cs">
[assembly: System.Runtime.CompilerServices.InternalsVisibleToAttribute("$$
</Document>
</Project>
</Workspace>)
state.SendInvokeCompletionList()
Await state.AssertCompletionSession()
Assert.True(state.CompletionItemsContainsAll({"ClassLibrary1"}))
End Using
End Function
<WpfFact, Trait(Traits.Feature, Traits.Features.Completion)>
Public Async Function CodeCompletionIsTriggeredWhenDoubleQuoteIsEntered() As Task
Using state = TestState.CreateTestStateFromWorkspace(
<Workspace>
<Project Language="C#" CommonReferences="true" AssemblyName="ClassLibrary1"/>
<Project Language="C#" CommonReferences="true" AssemblyName="TestAssembly">
<Document FilePath="C.cs">
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo($$
</Document>
</Project>
</Workspace>)
Await state.AssertNoCompletionSession()
state.SendTypeChars(""""c)
Await state.AssertCompletionSession()
Assert.True(state.CompletionItemsContainsAll({"ClassLibrary1"}))
End Using
End Function
<WpfFact, Trait(Traits.Feature, Traits.Features.Completion)>
Public Async Function CodeCompletionIsEmptyUntilDoubleQuotesAreEntered() As Task
Using state = TestState.CreateTestStateFromWorkspace(
<Workspace>
<Project Language="C#" CommonReferences="true" AssemblyName="ClassLibrary1"/>
<Project Language="C#" CommonReferences="true" AssemblyName="TestAssembly">
<Document FilePath="C.cs">
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo$$
</Document>
</Project>
</Workspace>)
Await state.AssertNoCompletionSession()
state.SendInvokeCompletionList()
Await state.WaitForAsynchronousOperationsAsync()
Assert.False(state.CompletionItemsContainsAny({"ClassLibrary1"}))
state.SendTypeChars("("c)
Await state.AssertNoCompletionSession()
state.SendInvokeCompletionList()
Await state.WaitForAsynchronousOperationsAsync()
Assert.False(state.CompletionItemsContainsAny({"ClassLibrary1"}))
state.SendTypeChars(""""c)
Await state.AssertCompletionSession()
Assert.True(state.CompletionItemsContainsAll({"ClassLibrary1"}))
End Using
End Function
<WpfFact, Trait(Traits.Feature, Traits.Features.Completion)>
Public Async Function CodeCompletionIsTriggeredWhenCharacterIsEnteredAfterOpeningDoubleQuote() As Task
Using state = TestState.CreateTestStateFromWorkspace(
<Workspace>
<Project Language="C#" CommonReferences="true" AssemblyName="ClassLibrary1"/>
<Project Language="C#" CommonReferences="true" AssemblyName="TestAssembly">
<Document FilePath="C.cs">
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("$$")]
</Document>
</Project>
</Workspace>)
Await state.AssertNoCompletionSession()
state.SendTypeChars("a"c)
Await state.AssertCompletionSession()
Assert.True(state.CompletionItemsContainsAll({"ClassLibrary1"}))
End Using
End Function
<WpfFact, Trait(Traits.Feature, Traits.Features.Completion)>
Public Async Function CodeCompletionIsNotTriggeredWhenCharacterIsEnteredThatIsNotRightBesideTheOpeniningDoubleQuote() As Task
Using state = TestState.CreateTestStateFromWorkspace(
<Workspace>
<Project Language="C#" CommonReferences="true" AssemblyName="ClassLibrary1"/>
<Project Language="C#" CommonReferences="true" AssemblyName="TestAssembly">
<Document FilePath="C.cs">
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("a$$")]
</Document>
</Project>
</Workspace>)
Await state.AssertNoCompletionSession()
state.SendTypeChars("b"c)
Await state.AssertNoCompletionSession()
End Using
End Function
<WpfFact, Trait(Traits.Feature, Traits.Features.Completion)>
Public Async Function CodeCompletionIsNotTriggeredWhenDoubleQuoteIsEnteredAtStartOfFile() As Task
Using state = TestState.CreateTestStateFromWorkspace(
<Workspace>
<Project Language="C#" CommonReferences="true" AssemblyName="ClassLibrary1"/>
<Project Language="C#" CommonReferences="true" AssemblyName="TestAssembly">
<Document FilePath="C.cs">$$
</Document>
</Project>
</Workspace>)
Await state.AssertNoCompletionSession()
state.SendTypeChars("a"c)
Await state.WaitForAsynchronousOperationsAsync()
Assert.False(state.CompletionItemsContainsAny({"ClassLibrary1"}))
End Using
End Function
<WpfFact, Trait(Traits.Feature, Traits.Features.Completion)>
Public Async Function CodeCompletionIsNotTriggeredByArrayElementAccess() As Task
Using state = TestState.CreateTestStateFromWorkspace(
<Workspace>
<Project Language="C#" CommonReferences="true" AssemblyName="ClassLibrary1"/>
<Project Language="C#" CommonReferences="true" AssemblyName="TestAssembly">
<Document FilePath="C.cs"><![CDATA[
namespace A
{
public class C
{
public void M()
{
var d = new System.Collections.Generic.Dictionary<string, string>();
var v = d$$;
}
}
}
]]>
</Document>
</Project>
</Workspace>)
Dim AssertNoCompletionAndCompletionDoesNotContainClassLibrary1 As Func(Of Task) =
Async Function()
Await state.AssertNoCompletionSession()
state.SendInvokeCompletionList()
Await state.WaitForAsynchronousOperationsAsync()
Assert.True(
state.CurrentCompletionPresenterSession Is Nothing OrElse
Not state.CompletionItemsContainsAny({"ClassLibrary1"}))
End Function
Await AssertNoCompletionAndCompletionDoesNotContainClassLibrary1()
state.SendTypeChars("["c)
Await AssertNoCompletionAndCompletionDoesNotContainClassLibrary1()
state.SendTypeChars(""""c)
Await AssertNoCompletionAndCompletionDoesNotContainClassLibrary1()
End Using
End Function
Private Async Function AssertCompletionListHasItems(code As String, hasItems As Boolean) As Task
Using state = TestState.CreateTestStateFromWorkspace(
<Workspace>
<Project Language="C#" CommonReferences="true" AssemblyName="ClassLibrary1"/>
<Project Language="C#" CommonReferences="true" AssemblyName="TestAssembly">
<Document FilePath="C.cs">
using System.Runtime.CompilerServices;
using System.Reflection;
<%= code %>
</Document>
</Project>
</Workspace>)
state.SendInvokeCompletionList()
Await state.WaitForAsynchronousOperationsAsync()
If hasItems Then
Await state.AssertCompletionSession()
Assert.True(state.CompletionItemsContainsAll({"ClassLibrary1"}))
Else
Await state.AssertNoCompletionSession
End If
End Using
End Function
<WpfFact, Trait(Traits.Feature, Traits.Features.Completion)>
Public Async Function AssertCompletionListHasItems_AfterSingleDoubleQuoteAndClosing() As Task
Await AssertCompletionListHasItems("[assembly: InternalsVisibleTo(""$$)]", True)
End Function
<WpfFact, Trait(Traits.Feature, Traits.Features.Completion)>
Public Async Function AssertCompletionListHasItems_AfterText() As Task
Await AssertCompletionListHasItems("[assembly: InternalsVisibleTo(""Test$$)]", True)
End Function
<WpfFact, Trait(Traits.Feature, Traits.Features.Completion)>
Public Async Function AssertCompletionListHasItems_IfCursorIsInSecondParameter() As Task
Await AssertCompletionListHasItems("[assembly: InternalsVisibleTo(""Test"", ""$$", True)
End Function
<WpfFact, Trait(Traits.Feature, Traits.Features.Completion)>
Public Async Function AssertCompletionListHasNoItems_IfCursorIsClosingDoubleQuote1() As Task
Await AssertCompletionListHasItems("[assembly: InternalsVisibleTo(""Test""$$", False)
End Function
<WpfFact, Trait(Traits.Feature, Traits.Features.Completion)>
Public Async Function AssertCompletionListHasNoItems_IfCursorIsClosingDoubleQuote2() As Task
Await AssertCompletionListHasItems("[assembly: InternalsVisibleTo(""""$$", False)
End Function
<WpfFact, Trait(Traits.Feature, Traits.Features.Completion)>
Public Async Function AssertCompletionListHasItems_IfNamedParameterIsPresent() As Task
Await AssertCompletionListHasItems("[assembly: InternalsVisibleTo(""$$, AllInternalsVisible = true)]", True)
End Function
<WpfFact, Trait(Traits.Feature, Traits.Features.Completion)>
Public Async Function AssertCompletionListHasItems_IfNamedParameterAndNamedPositionalParametersArePresent() As Task
Await AssertCompletionListHasItems("[assembly: InternalsVisibleTo(assemblyName: ""$$, AllInternalsVisible = true)]", True)
End Function
<WpfFact, Trait(Traits.Feature, Traits.Features.Completion)>
Public Async Function AssertCompletionListHasNoItems_IfNumberIsEntered() As Task
Await AssertCompletionListHasItems("[assembly: InternalsVisibleTo(1$$2)]", False)
End Function
<WpfFact, Trait(Traits.Feature, Traits.Features.Completion)>
Public Async Function AssertCompletionListHasNoItems_IfNotInternalsVisibleToAttribute() As Task
Await AssertCompletionListHasItems("[assembly: AssemblyVersion(""$$"")]", False)
End Function
<WpfFact, Trait(Traits.Feature, Traits.Features.Completion)>
Public Async Function AssertCompletionListHasItems_IfOtherAttributeIsPresent1() As Task
Await AssertCompletionListHasItems("[assembly: AssemblyVersion(""1.0.0.0""), InternalsVisibleTo(""$$", True)
End Function
<WpfFact, Trait(Traits.Feature, Traits.Features.Completion)>
Public Async Function AssertCompletionListHasItems_IfOtherAttributeIsPresent2() As Task
Await AssertCompletionListHasItems("[assembly: InternalsVisibleTo(""$$""), AssemblyVersion(""1.0.0.0"")]", True)
End Function
<WpfFact, Trait(Traits.Feature, Traits.Features.Completion)>
Public Async Function AssertCompletionListHasItems_IfOtherAttributesAreAhead() As Task
Await AssertCompletionListHasItems("
[assembly: AssemblyVersion(""1.0.0.0"")]
[assembly: InternalsVisibleTo(""$$", True)
End Function
<WpfFact, Trait(Traits.Feature, Traits.Features.Completion)>
Public Async Function AssertCompletionListHasItems_IfOtherAttributesAreFollowing() As Task
Await AssertCompletionListHasItems("
[assembly: InternalsVisibleTo(""$$
[assembly: AssemblyVersion(""1.0.0.0"")]
[assembly: AssemblyCompany(""Test"")]", True)
End Function
<WpfFact, Trait(Traits.Feature, Traits.Features.Completion)>
Public Async Function AssertCompletionListHasItems_IfNamespaceIsFollowing() As Task
Await AssertCompletionListHasItems("
[assembly: InternalsVisibleTo(""$$
namespace A {
public class A { }
}", True)
End Function
<WpfFact, Trait(Traits.Feature, Traits.Features.Completion)>
Public Async Function CodeCompletionHasItemsIfInteralVisibleToIsReferencedByTypeAlias() As Task
Using state = TestState.CreateTestStateFromWorkspace(
<Workspace>
<Project Language="C#" CommonReferences="true" AssemblyName="ClassLibrary1"/>
<Project Language="C#" CommonReferences="true" AssemblyName="TestAssembly">
<Document FilePath="C.cs">
using IVT = System.Runtime.CompilerServices.InternalsVisibleToAttribute;
[assembly: IVT("$$
</Document>
</Project>
</Workspace>)
state.SendInvokeCompletionList()
Await state.AssertCompletionSession()
Assert.True(state.CompletionItemsContainsAll({"ClassLibrary1"}))
End Using
End Function
<WpfFact, Trait(Traits.Feature, Traits.Features.Completion)>
Public Async Function CodeCompletionDoesNotContainCurrentAssembly() As Task
Using state = TestState.CreateTestStateFromWorkspace(
<Workspace>
<Project Language="C#" CommonReferences="true" AssemblyName="ClassLibrary1"/>
<Project Language="C#" CommonReferences="true" AssemblyName="TestAssembly">
<Document FilePath="C.cs">
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("$$")]
</Document>
</Project>
</Workspace>)
state.SendInvokeCompletionList()
Await state.AssertCompletionSession()
Assert.False(state.CompletionItemsContainsAny({"TestAssembly"}))
End Using
End Function
<WpfFact, Trait(Traits.Feature, Traits.Features.Completion)>
Public Async Function CodeCompletionInsertsAssemblyNameOnCommit() As Task
Using state = TestState.CreateTestStateFromWorkspace(
<Workspace>
<Project Language="C#" CommonReferences="true" AssemblyName="ClassLibrary1">
</Project>
<Project Language="C#" CommonReferences="true" AssemblyName="TestAssembly">
<Document>
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("$$")]
</Document>
</Project>
</Workspace>)
state.SendInvokeCompletionList()
Await state.AssertSelectedCompletionItem("ClassLibrary1")
state.SendTab()
Await state.WaitForAsynchronousOperationsAsync()
state.AssertMatchesTextStartingAtLine(1, "[assembly: System.Runtime.CompilerServices.InternalsVisibleTo(""ClassLibrary1"")]")
End Using
End Function
<WpfFact, Trait(Traits.Feature, Traits.Features.Completion)>
Public Async Function CodeCompletionInsertsPublicKeyOnCommit() As Task
Using state = TestState.CreateTestStateFromWorkspace(
<Workspace>
<Project Language="C#" CommonReferences="true" AssemblyName="ClassLibrary1">
<CompilationOptions
CryptoKeyFile=<%= SigningTestHelpers.PublicKeyFile %>
StrongNameProvider=<%= SigningTestHelpers.s_defaultDesktopProvider.GetType().AssemblyQualifiedName %>/>
</Project>
<Project Language="C#" CommonReferences="true" AssemblyName="TestAssembly">
<Document>
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("$$")]
</Document>
</Project>
</Workspace>)
state.SendInvokeCompletionList()
Await state.AssertSelectedCompletionItem("ClassLibrary1")
state.SendTab()
Await state.WaitForAsynchronousOperationsAsync()
state.AssertMatchesTextStartingAtLine(1, "[assembly: System.Runtime.CompilerServices.InternalsVisibleTo(""ClassLibrary1, PublicKey=00240000048000009400000006020000002400005253413100040000010001002b986f6b5ea5717d35c72d38561f413e267029efa9b5f107b9331d83df657381325b3a67b75812f63a9436ceccb49494de8f574f8e639d4d26c0fcf8b0e9a1a196b80b6f6ed053628d10d027e032df2ed1d60835e5f47d32c9ef6da10d0366a319573362c821b5f8fa5abc5bb22241de6f666a85d82d6ba8c3090d01636bd2bb"")]")
End Using
End Function
<WpfFact, Trait(Traits.Feature, Traits.Features.Completion)>
Public Async Function CodeCompletionContainsPublicKeyIfKeyIsSpecifiedByAttribute() As Task
Using state = TestState.CreateTestStateFromWorkspace(
<Workspace>
<Project Language="C#" CommonReferences="true" AssemblyName="ClassLibrary1">
<CompilationOptions
StrongNameProvider=<%= SigningTestHelpers.s_defaultDesktopProvider.GetType().AssemblyQualifiedName %>/>
<Document>
[assembly: System.Reflection.AssemblyKeyFile("<%= SigningTestHelpers.PublicKeyFile.Replace("\", "\\") %>")]
</Document>
</Project>
<Project Language="C#" CommonReferences="true" AssemblyName="TestAssembly">
<Document>
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("$$")]
</Document>
</Project>
</Workspace>)
state.SendInvokeCompletionList()
Await state.AssertSelectedCompletionItem("ClassLibrary1")
state.SendTab()
Await state.WaitForAsynchronousOperationsAsync()
state.AssertMatchesTextStartingAtLine(1, "[assembly: System.Runtime.CompilerServices.InternalsVisibleTo(""ClassLibrary1, PublicKey=00240000048000009400000006020000002400005253413100040000010001002b986f6b5ea5717d35c72d38561f413e267029efa9b5f107b9331d83df657381325b3a67b75812f63a9436ceccb49494de8f574f8e639d4d26c0fcf8b0e9a1a196b80b6f6ed053628d10d027e032df2ed1d60835e5f47d32c9ef6da10d0366a319573362c821b5f8fa5abc5bb22241de6f666a85d82d6ba8c3090d01636bd2bb"")]")
End Using
End Function
<WpfFact, Trait(Traits.Feature, Traits.Features.Completion)>
Public Async Function CodeCompletionContainsPublicKeyIfDelayedSigningIsEnabled() As Task
Using state = TestState.CreateTestStateFromWorkspace(
<Workspace>
<Project Language="C#" CommonReferences="true" AssemblyName="ClassLibrary1">
<CompilationOptions
CryptoKeyFile=<%= SigningTestHelpers.PublicKeyFile %>
StrongNameProvider=<%= SigningTestHelpers.s_defaultDesktopProvider.GetType().AssemblyQualifiedName %>
DelaySign="True"/>
</Project>
<Project Language="C#" CommonReferences="true" AssemblyName="TestAssembly">
<Document>
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("$$")]
</Document>
</Project>
</Workspace>)
state.SendInvokeCompletionList()
Await state.AssertSelectedCompletionItem("ClassLibrary1")
state.SendTab()
Await state.WaitForAsynchronousOperationsAsync()
state.AssertMatchesTextStartingAtLine(1, "[assembly: System.Runtime.CompilerServices.InternalsVisibleTo(""ClassLibrary1, PublicKey=00240000048000009400000006020000002400005253413100040000010001002b986f6b5ea5717d35c72d38561f413e267029efa9b5f107b9331d83df657381325b3a67b75812f63a9436ceccb49494de8f574f8e639d4d26c0fcf8b0e9a1a196b80b6f6ed053628d10d027e032df2ed1d60835e5f47d32c9ef6da10d0366a319573362c821b5f8fa5abc5bb22241de6f666a85d82d6ba8c3090d01636bd2bb"")]")
End Using
End Function
<WpfFact, Trait(Traits.Feature, Traits.Features.Completion)>
Public Async Function CodeCompletionListIsEmptyIfAttributeIsNotTheBCLAttribute() As Task
Using state = TestState.CreateTestStateFromWorkspace(
<Workspace>
<Project Language="C#" CommonReferences="true" AssemblyName="ClassLibrary1"/>
<Project Language="C#" CommonReferences="true" AssemblyName="TestAssembly">
<Document FilePath="C.cs">
[assembly: Test.InternalsVisibleTo("$$")]
namespace Test
{
[System.AttributeUsage(System.AttributeTargets.Assembly)]
public sealed class InternalsVisibleToAttribute: System.Attribute
{
public InternalsVisibleToAttribute(string ignore)
{
}
}
}
</Document>
</Project>
</Workspace>)
state.SendInvokeCompletionList()
Await state.AssertNoCompletionSession()
End Using
End Function
<WpfFact, Trait(Traits.Feature, Traits.Features.Completion)>
Public Async Function CodeCompletionContainsOnlyAssembliesThatAreNotAlreadyIVT() As Task
Using state = TestState.CreateTestStateFromWorkspace(
<Workspace>
<Project Language="C#" CommonReferences="true" AssemblyName="ClassLibrary1"/>
<Project Language="C#" CommonReferences="true" AssemblyName="ClassLibrary2"/>
<Project Language="C#" CommonReferences="true" AssemblyName="ClassLibrary3"/>
<Project Language="C#" CommonReferences="true" AssemblyName="TestAssembly">
<Document FilePath="C.cs">
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("ClassLibrary1")]
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("ClassLibrary2")]
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("$$
</Document>
</Project>
</Workspace>)
state.SendInvokeCompletionList()
Await state.AssertCompletionSession()
Assert.False(state.CompletionItemsContainsAny({"ClassLibrary1", "ClassLibrary2"}))
Assert.True(state.CompletionItemsContainsAll({"ClassLibrary3"}))
End Using
End Function
<WpfFact, Trait(Traits.Feature, Traits.Features.Completion)>
Public Async Function CodeCompletionContainsOnlyAssembliesThatAreNotAlreadyIVTIfAssemblyNameIsAConstant() As Task
Using state = TestState.CreateTestStateFromWorkspace(
<Workspace>
<Project Language="C#" CommonReferences="true" AssemblyName="ClassLibrary1"/>
<Project Language="C#" CommonReferences="true" AssemblyName="ClassLibrary2"/>
<Project Language="C#" CommonReferences="true" AssemblyName="ClassLibrary3"/>
<Project Language="C#" CommonReferences="true" AssemblyName="TestAssembly">
<MetadataReferenceFromSource Language="C#" CommonReferences="true">
<Document FilePath="ReferencedDocument.cs">
namespace A {
public static class Constants
{
public const string AssemblyName1 = "ClassLibrary1";
}
}
</Document>
</MetadataReferenceFromSource>
<Document FilePath="C.cs">
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo(A.Constants.AssemblyName1)]
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("ClassLibrary2")]
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("$$
</Document>
</Project>
</Workspace>)
state.SendInvokeCompletionList()
Await state.AssertCompletionSession()
Assert.False(state.CompletionItemsContainsAny({"ClassLibrary1", "ClassLibrary2"}))
Assert.True(state.CompletionItemsContainsAll({"ClassLibrary3"}))
End Using
End Function
<WpfFact, Trait(Traits.Feature, Traits.Features.Completion)>
Public Async Function CodeCompletionContainsOnlyAssembliesThatAreNotAlreadyIVTForDifferentSyntax() As Task
Using state = TestState.CreateTestStateFromWorkspace(
<Workspace>
<Project Language="C#" CommonReferences="true" AssemblyName="ClassLibrary1"/>
<Project Language="C#" CommonReferences="true" AssemblyName="ClassLibrary2"/>
<Project Language="C#" CommonReferences="true" AssemblyName="ClassLibrary3"/>
<Project Language="C#" CommonReferences="true" AssemblyName="ClassLibrary4"/>
<Project Language="C#" CommonReferences="true" AssemblyName="ClassLibrary5"/>
<Project Language="C#" CommonReferences="true" AssemblyName="ClassLibrary6"/>
<Project Language="C#" CommonReferences="true" AssemblyName="ClassLibrary7"/>
<Project Language="C#" CommonReferences="true" AssemblyName="ClassLibrary8"/>
<Project Language="C#" CommonReferences="true" AssemblyName="ClassLibrary9"/>
<Project Language="C#" CommonReferences="true" AssemblyName="TestAssembly">
<Document FilePath="C.cs">
// Code comment
using System.Runtime.CompilerServices;
using System.Reflection;
using IVT = System.Runtime.CompilerServices.InternalsVisibleToAttribute;
// Code comment
[assembly: InternalsVisibleTo("ClassLibrary1", AllInternalsVisible = true)]
[assembly: InternalsVisibleTo(assemblyName: "ClassLibrary2", AllInternalsVisible = true)]
[assembly: AssemblyVersion("1.0.0.0"), InternalsVisibleTo("ClassLibrary3")]
[assembly: InternalsVisibleTo("ClassLibrary4"), AssemblyCopyright("Copyright")]
[assembly: AssemblyDescription("Description")]
[assembly: InternalsVisibleTo("ClassLibrary5")]
[assembly: InternalsVisibleTo("ClassLibrary6, PublicKey=00240000048000009400000006020000002400005253413100040000010001002b986f6b5ea5717d35c72d38561f413e267029efa9b5f107b9331d83df657381325b3a67b75812f63a9436ceccb49494de8f574f8e639d4d26c0fcf8b0e9a1a196b80b6f6ed053628d10d027e032df2ed1d60835e5f47d32c9ef6da10d0366a319573362c821b5f8fa5abc5bb22241de6f666a85d82d6ba8c3090d01636bd2bb")]
[assembly: InternalsVisibleTo("ClassLibrary" + "7")]
[assembly: IVT("ClassLibrary8")]
[assembly: InternalsVisibleTo("$$
namespace A {
public class A { }
}
</Document>
</Project>
</Workspace>)
state.SendInvokeCompletionList()
Await state.AssertCompletionSession()
Assert.False(state.CompletionItemsContainsAny({"ClassLibrary1", "ClassLibrary2", "ClassLibrary3", "ClassLibrary4", "ClassLibrary5", "ClassLibrary6", "ClassLibrary7", "ClassLibrary8"}))
Assert.True(state.CompletionItemsContainsAll({"ClassLibrary9"}))
End Using
End Function
<WpfFact, Trait(Traits.Feature, Traits.Features.Completion)>
Public Async Function CodeCompletionContainsOnlyAssembliesThatAreNotAlreadyIVTWithSyntaxError() As Task
Using state = TestState.CreateTestStateFromWorkspace(
<Workspace>
<Project Language="C#" CommonReferences="true" AssemblyName="ClassLibrary1"/>
<Project Language="C#" CommonReferences="true" AssemblyName="TestAssembly">
<Document FilePath="C.cs">
using System.Runtime.CompilerServices;
using System.Reflection;
[assembly: InternalsVisibleTo("ClassLibrary" + 1)] // Not a constant
[assembly: InternalsVisibleTo("$$
</Document>
</Project>
</Workspace>)
state.SendInvokeCompletionList()
Await state.AssertCompletionSession()
' ClassLibrary1 must be listed because the existing attribute argument can't be resolved to a constant.
Assert.True(state.CompletionItemsContainsAll({"ClassLibrary1"}))
End Using
End Function
<WpfFact, Trait(Traits.Feature, Traits.Features.Completion)>
Public Async Function CodeCompletionContainsOnlyAssembliesThatAreNotAlreadyIVTWithMoreThanOneDocument() As Task
Using state = TestState.CreateTestStateFromWorkspace(
<Workspace>
<Project Language="C#" CommonReferences="true" AssemblyName="ClassLibrary1"/>
<Project Language="C#" CommonReferences="true" AssemblyName="ClassLibrary2"/>
<Project Language="C#" CommonReferences="true" AssemblyName="TestAssembly">
<Document FilePath="OtherDocument.cs">
using System.Runtime.CompilerServices;
using System.Reflection;
[assembly: InternalsVisibleTo("ClassLibrary1")]
[assembly: AssemblyDescription("Description")]
</Document>
<Document FilePath="C.cs">
using System.Runtime.CompilerServices;
using System.Reflection;
[assembly: InternalsVisibleTo("$$
</Document>
</Project>
</Workspace>)
state.SendInvokeCompletionList()
Await state.AssertCompletionSession()
Assert.False(state.CompletionItemsContainsAny({"ClassLibrary1"}))
Assert.True(state.CompletionItemsContainsAll({"ClassLibrary2"}))
End Using
End Function
End Class
End Namespace
|
OmarTawfik/roslyn
|
src/EditorFeatures/Test2/IntelliSense/CSharpCompletionCommandHandlerTests_InternalsVisibleTo.vb
|
Visual Basic
|
apache-2.0
| 32,459
|
'------------------------------------------------------------------------------
' <auto-generated>
' This code was generated by a tool.
' Runtime Version:4.0.30319.34014
'
' Changes to this file may cause incorrect behavior and will be lost if
' the code is regenerated.
' </auto-generated>
'------------------------------------------------------------------------------
Option Strict On
Option Explicit On
Namespace My
<Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0"), _
Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Partial Friend NotInheritable Class MySettings
Inherits Global.System.Configuration.ApplicationSettingsBase
Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings), MySettings)
#Region "My.Settings Auto-Save Functionality"
#If _MyType = "WindowsForms" Then
Private Shared addedHandler As Boolean
Private Shared addedHandlerLockObject As New Object
<Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs)
If My.Application.SaveMySettingsOnExit Then
My.Settings.Save()
End If
End Sub
#End If
#End Region
Public Shared ReadOnly Property [Default]() As MySettings
Get
#If _MyType = "WindowsForms" Then
If Not addedHandler Then
SyncLock addedHandlerLockObject
If Not addedHandler Then
AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings
addedHandler = True
End If
End SyncLock
End If
#End If
Return defaultInstance
End Get
End Property
End Class
End Namespace
Namespace My
<Global.Microsoft.VisualBasic.HideModuleNameAttribute(), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute()> _
Friend Module MySettingsProperty
<Global.System.ComponentModel.Design.HelpKeywordAttribute("My.Settings")> _
Friend ReadOnly Property Settings() As Global.Interfaces.My.MySettings
Get
Return Global.Interfaces.My.MySettings.Default
End Get
End Property
End Module
End Namespace
|
TedDBarr/orleans
|
Samples/VBHelloWorld/Interfaces/My Project/Settings.Designer.vb
|
Visual Basic
|
mit
| 2,926
|
Imports System
Imports System.Reflection
Imports System.Runtime.InteropServices
' General Information about an assembly is controlled through the following
' set of attributes. Change these attribute values to modify the information
' associated with an assembly.
' Review the values of the assembly attributes
<Assembly: AssemblyTitle("QuantConnect.Algorithm.VisualBasic")>
<Assembly: AssemblyDescription("")>
<Assembly: AssemblyCompany("")>
<Assembly: AssemblyProduct("QuantConnect.Algorithm.VisualBasic")>
<Assembly: AssemblyCopyright("Copyright © 2015")>
<Assembly: AssemblyTrademark("")>
<Assembly: ComVisible(False)>
'The following GUID is for the ID of the typelib if this project is exposed to COM
<Assembly: Guid("9a4acee7-b4e5-41a4-9cea-d645ea4e4ede")>
' Version information for an assembly consists of the following four values:
'
' Major Version
' Minor Version
' Build Number
' Revision
'
' You can specify all the values or you can default the Build and Revision Numbers
' by using the '*' as shown below:
' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("1.0.0.0")>
<Assembly: AssemblyFileVersion("1.0.0.0")>
|
AnshulYADAV007/Lean
|
Algorithm.VisualBasic/AssemblyInfo.vb
|
Visual Basic
|
apache-2.0
| 1,184
|
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System.Threading
Imports Microsoft.CodeAnalysis.Editor.Implementation.Highlighting
Imports Microsoft.CodeAnalysis.Text
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.KeywordHighlighting
<ExportHighlighter(LanguageNames.VisualBasic)>
Friend Class OperatorDeclarationHighlighter
Inherits AbstractKeywordHighlighter(Of SyntaxNode)
Protected Overloads Overrides Function GetHighlights(node As SyntaxNode, cancellationToken As CancellationToken) As IEnumerable(Of TextSpan)
Dim methodBlock = node.GetAncestor(Of MethodBlockBaseSyntax)()
If methodBlock Is Nothing OrElse Not TypeOf methodBlock.BlockStatement Is OperatorStatementSyntax Then
Return SpecializedCollections.EmptyEnumerable(Of TextSpan)()
End If
Dim highlights As New List(Of TextSpan)()
With methodBlock
With DirectCast(.BlockStatement, OperatorStatementSyntax)
Dim firstKeyword = If(.Modifiers.Count > 0, .Modifiers.First(), .DeclarationKeyword)
highlights.Add(TextSpan.FromBounds(firstKeyword.SpanStart, .DeclarationKeyword.Span.End))
End With
highlights.AddRange(
methodBlock.GetRelatedStatementHighlights(
blockKind:=SyntaxKind.None,
checkReturns:=True))
highlights.Add(.EndBlockStatement.Span)
End With
Return highlights
End Function
End Class
End Namespace
|
jhendrixMSFT/roslyn
|
src/EditorFeatures/VisualBasic/Highlighting/KeywordHighlighters/OperatorDeclarationHighlighter.vb
|
Visual Basic
|
apache-2.0
| 1,760
|
Imports System
Imports System.Reflection
Imports System.Runtime.InteropServices
' General Information about an assembly is controlled through the following
' set of attributes. Change these attribute values to modify the information
' associated with an assembly.
' Review the values of the assembly attributes
<Assembly: AssemblyTitle("_02.AdvancedFunctions")>
<Assembly: AssemblyDescription("")>
<Assembly: AssemblyCompany("Microsoft")>
<Assembly: AssemblyProduct("_02.AdvancedFunctions")>
<Assembly: AssemblyCopyright("Copyright © Microsoft 2013")>
<Assembly: AssemblyTrademark("")>
<Assembly: ComVisible(False)>
'The following GUID is for the ID of the typelib if this project is exposed to COM
<Assembly: Guid("7dc9cbbc-69ce-4cda-825f-8599fde14b25")>
' Version information for an assembly consists of the following four values:
'
' Major Version
' Minor Version
' Build Number
' Revision
'
' You can specify all the values or you can default the Build and Revision Numbers
' by using the '*' as shown below:
' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("1.0.0.0")>
<Assembly: AssemblyFileVersion("1.0.0.0")>
|
Ico093/TelerikAcademy
|
JavaScript#2/Homework/02.AdvancedFunctions/02.AdvancedFunctions/02.AdvancedFunctions/My Project/AssemblyInfo.vb
|
Visual Basic
|
mit
| 1,177
|
Imports NUnit.Framework
Imports System.Collections.Generic
Namespace CompuMaster.Test.Data.DataQuery
<TestFixture(Category:="DataQueryTestFile")> Public Class DataQueryTestFile
Private Shared Sub CreateAndDispose(ByVal testFileType As CompuMaster.Data.DataQuery.TestFile.TestFileType)
Dim testFile As New CompuMaster.Data.DataQuery.TestFile(testFileType)
Assert.IsTrue(System.IO.File.Exists(testFile.FilePath), "File exists")
Dim filepath As String = testFile.FilePath
testFile.Dispose()
Assert.IsFalse(System.IO.File.Exists(filepath), "File was deleted")
Dim cachedPath As String = Nothing
Using tsFile As New CompuMaster.Data.DataQuery.TestFile(testFileType)
Assert.IsTrue(System.IO.File.Exists(tsFile.FilePath), "File exists")
cachedPath = tsFile.FilePath
End Using
Assert.IsFalse(System.IO.File.Exists(cachedPath), "File was deleted")
End Sub
' <Test> Public Sub CreateAndDisposeMsAccess()
'#Disable Warning BC40000 ' Typ oder Element ist veraltet
' CreateAndDispose(CompuMaster.Data.DataQuery.TestFile.TestFileType.MsAccess)
'#Enable Warning BC40000 ' Typ oder Element ist veraltet
' End Sub
<Test> Public Sub CreateAndDisposeMsAccessAccdb()
CreateAndDispose(CompuMaster.Data.DataQuery.TestFile.TestFileType.MsAccessAccdb)
End Sub
<Test> Public Sub CreateAndDisposeMsAccessMdb()
CreateAndDispose(CompuMaster.Data.DataQuery.TestFile.TestFileType.MsAccessMdb)
End Sub
<Test> Public Sub CreateAndDisposeMsExcel95Xls()
CreateAndDispose(CompuMaster.Data.DataQuery.TestFile.TestFileType.MsExcel95Xls)
End Sub
<Test> Public Sub CreateAndDisposeMsExcel2007Xlsx()
CreateAndDispose(CompuMaster.Data.DataQuery.TestFile.TestFileType.MsExcel2007Xlsx)
End Sub
End Class
End Namespace
|
CompuMasterGmbH/CompuMaster.Data
|
CompuMaster.Test.Tools.Data/DataQuery.TestFile.vb
|
Visual Basic
|
mit
| 2,031
|
Imports System
Imports System.Reflection
Imports System.Runtime.InteropServices
' General Information about an assembly is controlled through the following
' set of attributes. Change these attribute values to modify the information
' associated with an assembly.
' Review the values of the assembly attributes
<Assembly: AssemblyTitle("BurnSoft Application Profiler Manager")>
<Assembly: AssemblyDescription("This is the main process that will look to see if any of the applications are running on the system. If they are it will launch the AppMonitor to gather the information from that process")>
<Assembly: AssemblyCompany("BurnSoft, www.burnsoft.net")>
<Assembly: AssemblyProduct("BurnSoft Application Profiler")>
<Assembly: AssemblyCopyright("Copyright © 2017-2019 BurnSoft, www.burnsoft.net")>
<Assembly: AssemblyTrademark("BurnSoft, www.burnsoft.net")>
<Assembly: ComVisible(False)>
'The following GUID is for the ID of the typelib if this project is exposed to COM
<Assembly: Guid("cede9fc9-2e30-4cef-b8f9-2673694246e9")>
' Version information for an assembly consists of the following four values:
'
' Major Version
' Minor Version
' Build Number
' Revision
'
' You can specify all the values or you can default the Build and Revision Numbers
' by using the '*' as shown below:
' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("1.0.0.*")>
<Assembly: AssemblyFileVersion("1.0.0.12")>
|
burnsoftnet/BSApplicationProfiler
|
BSApplicationProfiler/My Project/AssemblyInfo.vb
|
Visual Basic
|
mit
| 1,482
|
'------------------------------------------------------------------------------
' <generado automáticamente>
' Este código fue generado por una herramienta.
'
' Los cambios en este archivo podrían causar un comportamiento incorrecto y se perderán si
' se vuelve a generar el código.
' </generado automáticamente>
'------------------------------------------------------------------------------
Option Strict On
Option Explicit On
Partial Public Class ReporteAnticiposRendiciones
'''<summary>
'''Control Head1.
'''</summary>
'''<remarks>
'''Campo generado automáticamente.
'''Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente.
'''</remarks>
Protected WithEvents Head1 As Global.System.Web.UI.HtmlControls.HtmlHead
'''<summary>
'''Control form1.
'''</summary>
'''<remarks>
'''Campo generado automáticamente.
'''Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente.
'''</remarks>
Protected WithEvents form1 As Global.System.Web.UI.HtmlControls.HtmlForm
'''<summary>
'''Control ReportViewer1.
'''</summary>
'''<remarks>
'''Campo generado automáticamente.
'''Para modificarlo, mueva la declaración del campo del archivo del diseñador al archivo de código subyacente.
'''</remarks>
Protected WithEvents ReportViewer1 As Global.Telerik.ReportViewer.WebForms.ReportViewer
End Class
|
crackper/SistFoncreagro
|
SistFoncreagro.WebSite/Contabilidad/Formularios/ReporteAnticiposRendiciones.aspx.designer.vb
|
Visual Basic
|
mit
| 1,520
|
Option Infer On
Imports System
Imports System.Runtime.InteropServices
Namespace Examples
Friend Class Program
<STAThread>
Shared Sub Main(ByVal args() As String)
Dim application As SolidEdgeFramework.Application = Nothing
Dim partDocument As SolidEdgePart.PartDocument = Nothing
Dim models As SolidEdgePart.Models = Nothing
Dim model As SolidEdgePart.Model = Nothing
Dim body As SolidEdgeGeometry.Body = Nothing
Dim faces As SolidEdgeGeometry.Faces = Nothing
Dim face As SolidEdgeGeometry.Face = Nothing
Try
' See "Handling 'Application is Busy' and 'Call was Rejected By Callee' errors" topic.
OleMessageFilter.Register()
' Attempt to connect to a running instance of Solid Edge.
application = DirectCast(Marshal.GetActiveObject("SolidEdge.Application"), SolidEdgeFramework.Application)
partDocument = TryCast(application.ActiveDocument, SolidEdgePart.PartDocument)
If partDocument IsNot Nothing Then
models = partDocument.Models
model = models.Item(1)
body = CType(model.Body, SolidEdgeGeometry.Body)
Dim FaceType = SolidEdgeGeometry.FeatureTopologyQueryTypeConstants.igQueryAll
faces = CType(body.Faces(FaceType), SolidEdgeGeometry.Faces)
Dim CollectionType = SolidEdgeGeometry.TopologyCollectionTypeConstants.seFaceCollection
Dim faceCollection = CType(body.CreateCollection(CollectionType), SolidEdgeGeometry.Faces)
faceCollection.Add(faces.Item(1))
faceCollection.Add(faces.Item(2))
faceCollection.Remove(faces.Item(1))
End If
Catch ex As System.Exception
Console.WriteLine(ex)
Finally
OleMessageFilter.Unregister()
End Try
End Sub
End Class
End Namespace
|
SolidEdgeCommunity/docs
|
docfx_project/snippets/SolidEdgeGeometry.Faces.Remove.vb
|
Visual Basic
|
mit
| 2,081
|
Imports System.Resources
Imports System
Imports System.Reflection
Imports System.Runtime.InteropServices
' General Information about an assembly is controlled through the following
' set of attributes. Change these attribute values to modify the information
' associated with an assembly.
' Review the values of the assembly attributes
<Assembly: AssemblyTitle("LOL Mastery Manager New Client")>
<Assembly: AssemblyDescription("A tool for managing mastery pages in League of Legends.")>
<Assembly: AssemblyCompany("dewster.hu")>
<Assembly: AssemblyProduct("LOL Mastery Manager")>
<Assembly: AssemblyCopyright("Copyright © Dewster Morningstar 2017")>
<Assembly: AssemblyTrademark("")>
<Assembly: ComVisible(False)>
'The following GUID is for the ID of the typelib if this project is exposed to COM
<Assembly: Guid("3cd9f460-93ee-49e9-8f2f-22ecb0918fc9")>
' Version information for an assembly consists of the following four values:
'
' Major Version
' Minor Version
' Build Number
' Revision
'
' You can specify all the values or you can default the Build and Revision Numbers
' by using the '*' as shown below:
' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("1.2.2.0")>
<Assembly: AssemblyFileVersion("1.2.2.0")>
<Assembly: NeutralResourcesLanguage("en-US")>
|
dewster/lol-mastery-manager-new-client
|
LoLMasteryManager/My Project/AssemblyInfo.vb
|
Visual Basic
|
mit
| 1,313
|
'
' +---------------------------------------------------------------------+
' | AjGenesis - Code and Artifacts Generator in .NET |
' +---------------------------------------------------------------------+
' | Copyright (c) 2003-2011 Angel J. Lopez. All rights reserved. |
' | http://www.ajlopez.com |
' | http://www.ajlopez.net |
' +---------------------------------------------------------------------+
' | This source file is subject to the ajgenesis Software License, |
' | Version 1.0, that is bundled with this package in the file LICENSE. |
' | If you did not receive a copy of this file, you may read it online |
' | at http://www.ajlopez.net/ajgenesis/license.php. |
' +---------------------------------------------------------------------+
'
'
Imports System.IO
Imports System.Xml
Imports System.Collections.Specialized
Imports AjGenesis.Core
Public Class ModelBuilder
Implements IModelBuilder
Private mCurrentPath As String = Nothing
Private mProjectBuilder As ProjectBuilder = Nothing
Public Sub New()
End Sub
Public Sub New(ByVal prjbuilder As ProjectBuilder)
mProjectBuilder = prjbuilder
End Sub
Property CurrentPath() As String
Get
If mCurrentPath Is Nothing And Not mProjectBuilder Is Nothing Then
Return ProjectBuilder.CurrentPath
End If
Return mCurrentPath
End Get
Set(ByVal Value As String)
mCurrentPath = Value
End Set
End Property
Public Function GetObject(ByVal filename As String) As Object
Dim CurrPath As String
Dim docxml As New XmlDocument()
CurrPath = CurrentPath
Try
filename = Path.Combine(CurrentPath, filename)
CurrentPath = (New FileInfo(filename)).Directory.ToString
docxml.Load(filename)
Return GetObject(docxml.DocumentElement)
Finally
CurrentPath = CurrPath
End Try
End Function
Private Function GetObject(ByVal node As XmlNode) As Object
If Not node.Attributes("Source") Is Nothing Then
Return GetObject(node.Attributes("Source").Value)
End If
If node.ChildNodes.Count = 1 AndAlso node.FirstChild.NodeType = XmlNodeType.Text Then
Return node.FirstChild.Value
End If
Dim dynobj As DynamicObject
Dim child As XmlNode
Dim lastname As String = Nothing
Dim repeatedname As String = Nothing
For Each child In node.ChildNodes
If child.Name.Equals(lastname) Then
repeatedname = child.Name
End If
lastname = child.Name
Next
If repeatedname Is Nothing Then
dynobj = New DynamicObject()
Else
dynobj = New DynamicListObject()
End If
Dim attr As XmlAttribute
For Each attr In node.Attributes
dynobj.SetValue(attr.Name, attr.Value)
Next
For Each child In node.ChildNodes
Dim childobj As Object = GetObject(child)
If child.Name.Equals(repeatedname) Then
DirectCast(dynobj, DynamicListObject).AddValue(childobj)
Else
dynobj.SetValue(child.Name, childobj)
End If
Next
Return dynobj
End Function
Public Function GetModel(ByVal node As XmlNode) As IModel Implements IModelBuilder.GetModel
If node.Name <> "Model" Then
Throw New ArgumentException("It's not a Model")
End If
Dim model As New model()
Dim attr As XmlAttribute
For Each attr In node.Attributes
model.SetValue(attr.Name, attr.Value)
Next
Dim child As XmlNode
For Each child In node.ChildNodes
model.SetValue(child.Name, GetObject(child))
Next
Return model
End Function
Public Function GetModel(ByVal input As TextReader) As IModel Implements IModelBuilder.GetModel
Dim docxml As New XmlDocument()
docxml.Load(input)
Return GetModel(docxml.DocumentElement)
End Function
Public Function GetModel(ByVal filename As String) As IModel Implements IModelBuilder.GetModel
Dim CurrPath As String
Dim docxml As New XmlDocument()
CurrPath = CurrentPath
Try
filename = Path.Combine(CurrentPath, filename)
CurrentPath = (New FileInfo(filename)).Directory.ToString
docxml.Load(filename)
Return GetModel(docxml.DocumentElement)
Finally
CurrentPath = CurrPath
End Try
End Function
End Class
|
ajlopez/AjGenesis
|
src/AjGenesis.DynamicModel/ModelBuilder.vb
|
Visual Basic
|
mit
| 4,967
|
'------------------------------------------------------------------------------
' <auto-generated>
' This code was generated by a tool.
' Runtime Version:4.0.30319.42000
'
' Changes to this file may cause incorrect behavior and will be lost if
' the code is regenerated.
' </auto-generated>
'------------------------------------------------------------------------------
Option Strict On
Option Explicit On
Namespace My.Resources
'This class was auto-generated by the StronglyTypedResourceBuilder
'class via a tool like ResGen or Visual Studio.
'To add or remove a member, edit your .ResX file then rerun ResGen
'with the /str option, or rebuild your VS project.
'''<summary>
''' A strongly-typed resource class, for looking up localized strings, etc.
'''</summary>
<Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0"), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
Global.Microsoft.VisualBasic.HideModuleNameAttribute()> _
Friend Module Resources
Private resourceMan As Global.System.Resources.ResourceManager
Private resourceCulture As Global.System.Globalization.CultureInfo
'''<summary>
''' Returns the cached ResourceManager instance used by this class.
'''</summary>
<Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager
Get
If Object.ReferenceEquals(resourceMan, Nothing) Then
Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("RedHerrings.Resources", GetType(Resources).Assembly)
resourceMan = temp
End If
Return resourceMan
End Get
End Property
'''<summary>
''' Overrides the current thread's CurrentUICulture property for all
''' resource lookups using this strongly typed resource class.
'''</summary>
<Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Friend Property Culture() As Global.System.Globalization.CultureInfo
Get
Return resourceCulture
End Get
Set(ByVal value As Global.System.Globalization.CultureInfo)
resourceCulture = value
End Set
End Property
End Module
End Namespace
|
jyuch/RedHerrings
|
RedHerrings/My Project/Resources.Designer.vb
|
Visual Basic
|
mit
| 2,720
|
Imports System
Imports System.Reflection
Imports System.Runtime.InteropServices
' General Information about an assembly is controlled through the following
' set of attributes. Change these attribute values to modify the information
' associated with an assembly.
' Review the values of the assembly attributes
<Assembly: AssemblyTitle("_06.BTV")>
<Assembly: AssemblyDescription("")>
<Assembly: AssemblyCompany("Microsoft")>
<Assembly: AssemblyProduct("_06.BTV")>
<Assembly: AssemblyCopyright("Copyright © Microsoft 2013")>
<Assembly: AssemblyTrademark("")>
<Assembly: ComVisible(False)>
'The following GUID is for the ID of the typelib if this project is exposed to COM
<Assembly: Guid("f5676f96-74bb-4aea-bb15-579c842fa155")>
' Version information for an assembly consists of the following four values:
'
' Major Version
' Minor Version
' Build Number
' Revision
'
' You can specify all the values or you can default the Build and Revision Numbers
' by using the '*' as shown below:
' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("1.0.0.0")>
<Assembly: AssemblyFileVersion("1.0.0.0")>
|
Ico093/TelerikAcademy
|
CSS/Homework/03.CSSLayout/CSSLayout/06.BTV/My Project/AssemblyInfo.vb
|
Visual Basic
|
mit
| 1,149
|
Module StringFunctions
Public Function IsEmpty(S As String) As Boolean
Return S Is Nothing OrElse S = ""
End Function
Public Function isnotempty(S As String) As Boolean
Return Not IsEmpty(S)
End Function
End Module
|
jakubjenis/lecture.net
|
Vb.Net/Skolenie/Casting/StringFunctions.vb
|
Visual Basic
|
mit
| 253
|
'------------------------------------------------------------------------------
' <auto-generated>
' This code was generated by a tool.
' Runtime Version:4.0.30319.17929
'
' Changes to this file may cause incorrect behavior and will be lost if
' the code is regenerated.
' </auto-generated>
'------------------------------------------------------------------------------
Option Strict On
Option Explicit On
Namespace My
<Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0"), _
Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Partial Friend NotInheritable Class MySettings
Inherits Global.System.Configuration.ApplicationSettingsBase
Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings), MySettings)
#Region "My.Settings Auto-Save Functionality"
#If _MyType = "WindowsForms" Then
Private Shared addedHandler As Boolean
Private Shared addedHandlerLockObject As New Object
<Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs)
If My.Application.SaveMySettingsOnExit Then
My.Settings.Save()
End If
End Sub
#End If
#End Region
Public Shared ReadOnly Property [Default]() As MySettings
Get
#If _MyType = "WindowsForms" Then
If Not addedHandler Then
SyncLock addedHandlerLockObject
If Not addedHandler Then
AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings
addedHandler = True
End If
End SyncLock
End If
#End If
Return defaultInstance
End Get
End Property
End Class
End Namespace
Namespace My
<Global.Microsoft.VisualBasic.HideModuleNameAttribute(), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute()> _
Friend Module MySettingsProperty
<Global.System.ComponentModel.Design.HelpKeywordAttribute("My.Settings")> _
Friend ReadOnly Property Settings() As Global.TestMtApi.My.MySettings
Get
Return Global.TestMtApi.My.MySettings.Default
End Get
End Property
End Module
End Namespace
|
MongkonEiadon/mtapi
|
TestClients/TestMtApi/TestMtApi/My Project/Settings.Designer.vb
|
Visual Basic
|
mit
| 2,997
|
Imports System
Imports System.Configuration
Imports System.Data
Imports System.Data.SqlClient
Imports Telerik.Web.UI
Imports SistFoncreagro.BussinesLogic
Imports SistFoncreagro.BussinessEntities
Imports System.Collections
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Imports System.Data.OleDb
Public Class FrmRepListRequi
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Protected Sub GridRequi_ItemCommand(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles GridRequi.ItemCommand
If e.CommandName = "detalle" Then
Dim idRequerimiento As String = (CType(e.Item, GridDataItem)).OwnerTableView.DataKeyValues(e.Item.ItemIndex)("idRequerimiento").ToString
Dim radalertscript As String = "<script language='javascript'>function f(){radopen('DetalleReq.aspx?idReq=" + idRequerimiento.ToString + "','Formulario'); Sys.Application.remove_load(f);}; Sys.Application.add_load(f);</script>"
Page.ClientScript.RegisterStartupScript(Me.[GetType](), "radalert", radalertscript)
e.Canceled = True
End If
End Sub
End Class
|
crackper/SistFoncreagro
|
SistFoncreagro.WebSite/Logistica/FrmRepListRequi.aspx.vb
|
Visual Basic
|
mit
| 1,340
|
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
'//-------------------------------------------------------------------------------------------------
'//
'// Error code and strings for Compiler errors
'//
'// ERRIDs should be defined in the following ranges:
'//
'// 500 - 999 - non localized ERRID (main DLL)
'// 30000 - 59999 - localized ERRID (intl DLL)
'//
'// The convention for naming ERRID's that take replacement strings is to give
'// them a number following the name (from 1-9) that indicates how many
'// arguments they expect.
'//
'// DO NOT USE ANY NUMBERS EXCEPT THOSE EXPLICITLY LISTED AS BEING AVAILABLE.
'// IF YOU REUSE A NUMBER, LOCALIZATION WILL BE SCREWED UP!
'//
'//-------------------------------------------------------------------------------------------------
' //-------------------------------------------------------------------------------------------------
' //
' //
' // Manages the parse and compile errors.
' //
' //-------------------------------------------------------------------------------------------------
Namespace Microsoft.CodeAnalysis.VisualBasic
Friend Enum ERRID
Void = InternalErrorCode.Void
Unknown = InternalErrorCode.Unknown
ERR_None = 0
' ERR_InitError = 2000 unused in Roslyn
ERR_FileNotFound = 2001
' WRN_FileAlreadyIncluded = 2002 'unused in Roslyn.
'ERR_DuplicateResponseFile = 2003 unused in Roslyn.
'ERR_NoMemory = 2004
ERR_ArgumentRequired = 2006
WRN_BadSwitch = 2007
ERR_NoSources = 2008
ERR_SwitchNeedsBool = 2009
'ERR_CompileFailed = 2010 unused in Roslyn.
ERR_NoResponseFile = 2011
ERR_CantOpenFileWrite = 2012
ERR_InvalidSwitchValue = 2014
ERR_BinaryFile = 2015
ERR_BadCodepage = 2016
ERR_LibNotFound = 2017
'ERR_MaximumErrors = 2020 unused in Roslyn.
ERR_IconFileAndWin32ResFile = 2023
'WRN_ReservedReference = 2024 ' unused by native compiler due to bug.
WRN_NoConfigInResponseFile = 2025
' WRN_InvalidWarningId = 2026 ' unused in Roslyn.
'ERR_WatsonSendNotOptedIn = 2027
' WRN_SwitchNoBool = 2028 'unused in Roslyn
ERR_NoSourcesOut = 2029
ERR_NeedModule = 2030
ERR_InvalidAssemblyName = 2031
FTL_InputFileNameTooLong = 2032 ' new in Roslyn
ERR_ConflictingManifestSwitches = 2033
WRN_IgnoreModuleManifest = 2034
'ERR_NoDefaultManifest = 2035
'ERR_InvalidSwitchValue1 = 2036
WRN_BadUILang = 2038 ' new in Roslyn
ERR_VBCoreNetModuleConflict = 2042
ERR_InvalidFormatForGuidForOption = 2043
ERR_MissingGuidForOption = 2044
ERR_BadChecksumAlgorithm = 2045
ERR_MutuallyExclusiveOptions = 2046
'// The naming convention is that if your error requires arguments, to append
'// the number of args taken, e.g. AmbiguousName2
'//
ERR_InvalidInNamespace = 30001
ERR_UndefinedType1 = 30002
ERR_MissingNext = 30003
ERR_IllegalCharConstant = 30004
'//If you make any change involving these errors, such as creating more specific versions for use
'//in other contexts, please make sure to appropriately modify Bindable::ResolveOverloadingShouldSkipBadMember
ERR_UnreferencedAssemblyEvent3 = 30005
ERR_UnreferencedModuleEvent3 = 30006
' ERR_UnreferencedAssemblyBase3 = 30007
ERR_UnreferencedModuleBase3 = 30008
' ERR_UnreferencedAssemblyImplements3 = 30009
ERR_UnreferencedModuleImplements3 = 30010
'ERR_CodegenError = 30011
ERR_LbExpectedEndIf = 30012
ERR_LbNoMatchingIf = 30013
ERR_LbBadElseif = 30014
ERR_InheritsFromRestrictedType1 = 30015
ERR_InvOutsideProc = 30016
ERR_DelegateCantImplement = 30018
ERR_DelegateCantHandleEvents = 30019
ERR_IsOperatorRequiresReferenceTypes1 = 30020
ERR_TypeOfRequiresReferenceType1 = 30021
ERR_ReadOnlyHasSet = 30022
ERR_WriteOnlyHasGet = 30023
ERR_InvInsideProc = 30024
ERR_EndProp = 30025
ERR_EndSubExpected = 30026
ERR_EndFunctionExpected = 30027
ERR_LbElseNoMatchingIf = 30028
ERR_CantRaiseBaseEvent = 30029
ERR_TryWithoutCatchOrFinally = 30030
' ERR_FullyQualifiedNameTooLong1 = 30031 ' Deprecated in favor of ERR_TooLongMetadataName
ERR_EventsCantBeFunctions = 30032
' ERR_IdTooLong = 30033 ' Deprecated in favor of ERR_TooLongMetadataName
ERR_MissingEndBrack = 30034
ERR_Syntax = 30035
ERR_Overflow = 30036
ERR_IllegalChar = 30037
ERR_StrictDisallowsObjectOperand1 = 30038
ERR_LoopControlMustNotBeProperty = 30039
ERR_MethodBodyNotAtLineStart = 30040
ERR_MaximumNumberOfErrors = 30041
ERR_UseOfKeywordNotInInstanceMethod1 = 30043
ERR_UseOfKeywordFromStructure1 = 30044
ERR_BadAttributeConstructor1 = 30045
ERR_ParamArrayWithOptArgs = 30046
ERR_ExpectedArray1 = 30049
ERR_ParamArrayNotArray = 30050
ERR_ParamArrayRank = 30051
ERR_ArrayRankLimit = 30052
ERR_AsNewArray = 30053
ERR_TooManyArgs1 = 30057
ERR_ExpectedCase = 30058
ERR_RequiredConstExpr = 30059
ERR_RequiredConstConversion2 = 30060
ERR_InvalidMe = 30062
ERR_ReadOnlyAssignment = 30064
ERR_ExitSubOfFunc = 30065
ERR_ExitPropNot = 30066
ERR_ExitFuncOfSub = 30067
ERR_LValueRequired = 30068
ERR_ForIndexInUse1 = 30069
ERR_NextForMismatch1 = 30070
ERR_CaseElseNoSelect = 30071
ERR_CaseNoSelect = 30072
ERR_CantAssignToConst = 30074
ERR_NamedSubscript = 30075
ERR_ExpectedEndIf = 30081
ERR_ExpectedEndWhile = 30082
ERR_ExpectedLoop = 30083
ERR_ExpectedNext = 30084
ERR_ExpectedEndWith = 30085
ERR_ElseNoMatchingIf = 30086
ERR_EndIfNoMatchingIf = 30087
ERR_EndSelectNoSelect = 30088
ERR_ExitDoNotWithinDo = 30089
ERR_EndWhileNoWhile = 30090
ERR_LoopNoMatchingDo = 30091
ERR_NextNoMatchingFor = 30092
ERR_EndWithWithoutWith = 30093
ERR_MultiplyDefined1 = 30094
ERR_ExpectedEndSelect = 30095
ERR_ExitForNotWithinFor = 30096
ERR_ExitWhileNotWithinWhile = 30097
ERR_ReadOnlyProperty1 = 30098
ERR_ExitSelectNotWithinSelect = 30099
ERR_BranchOutOfFinally = 30101
ERR_QualNotObjectRecord1 = 30103
ERR_TooFewIndices = 30105
ERR_TooManyIndices = 30106
ERR_EnumNotExpression1 = 30107
ERR_TypeNotExpression1 = 30108
ERR_ClassNotExpression1 = 30109
ERR_StructureNotExpression1 = 30110
ERR_InterfaceNotExpression1 = 30111
ERR_NamespaceNotExpression1 = 30112
ERR_BadNamespaceName1 = 30113
ERR_XmlPrefixNotExpression = 30114
ERR_MultipleExtends = 30121
'ERR_NoStopInDebugger = 30122
'ERR_NoEndInDebugger = 30123
ERR_PropMustHaveGetSet = 30124
ERR_WriteOnlyHasNoWrite = 30125
ERR_ReadOnlyHasNoGet = 30126
ERR_BadAttribute1 = 30127
' ERR_BadSecurityAttribute1 = 30128 ' we're now reporting more detailed diagnostics: ERR_SecurityAttributeMissingAction or ERR_SecurityAttributeInvalidAction
'ERR_BadAssemblyAttribute1 = 30129
'ERR_BadModuleAttribute1 = 30130
' ERR_ModuleSecurityAttributeNotAllowed1 = 30131 ' We now report ERR_SecurityAttributeInvalidTarget instead.
ERR_LabelNotDefined1 = 30132
'ERR_NoGotosInDebugger = 30133
'ERR_NoLabelsInDebugger = 30134
'ERR_NoSyncLocksInDebugger = 30135
ERR_ErrorCreatingWin32ResourceFile = 30136
'ERR_ErrorSavingWin32ResourceFile = 30137 abandoned. no longer "saving" a temporary resource file.
ERR_UnableToCreateTempFile = 30138 'changed from ERR_UnableToCreateTempFileInPath1. now takes only one argument
'ERR_ErrorSettingManifestOption = 30139
'ERR_ErrorCreatingManifest = 30140
'ERR_UnableToCreateALinkAPI = 30141
'ERR_UnableToGenerateRefToMetaDataFile1 = 30142
'ERR_UnableToEmbedResourceFile1 = 30143 ' We now report ERR_UnableToOpenResourceFile1 instead.
'ERR_UnableToLinkResourceFile1 = 30144 ' We now report ERR_UnableToOpenResourceFile1 instead.
'ERR_UnableToEmitAssembly = 30145
'ERR_UnableToSignAssembly = 30146
'ERR_NoReturnsInDebugger = 30147
ERR_RequiredNewCall2 = 30148
ERR_UnimplementedMember3 = 30149
' ERR_UnimplementedProperty3 = 30154
ERR_BadWithRef = 30157
' ERR_ExpectedNewableClass1 = 30166 unused in Roslyn. We now report nothing
' ERR_TypeConflict7 = 30175 unused in Roslyn. We now report BC30179
ERR_DuplicateAccessCategoryUsed = 30176
ERR_DuplicateModifierCategoryUsed = 30177
ERR_DuplicateSpecifier = 30178
ERR_TypeConflict6 = 30179
ERR_UnrecognizedTypeKeyword = 30180
ERR_ExtraSpecifiers = 30181
ERR_UnrecognizedType = 30182
ERR_InvalidUseOfKeyword = 30183
ERR_InvalidEndEnum = 30184
ERR_MissingEndEnum = 30185
'ERR_NoUsingInDebugger = 30186
ERR_ExpectedDeclaration = 30188
ERR_ParamArrayMustBeLast = 30192
ERR_SpecifiersInvalidOnInheritsImplOpt = 30193
ERR_ExpectedSpecifier = 30195
ERR_ExpectedComma = 30196
ERR_ExpectedAs = 30197
ERR_ExpectedRparen = 30198
ERR_ExpectedLparen = 30199
ERR_InvalidNewInType = 30200
ERR_ExpectedExpression = 30201
ERR_ExpectedOptional = 30202
ERR_ExpectedIdentifier = 30203
ERR_ExpectedIntLiteral = 30204
ERR_ExpectedEOS = 30205
ERR_ExpectedForOptionStmt = 30206
ERR_InvalidOptionCompare = 30207
ERR_ExpectedOptionCompare = 30208
ERR_StrictDisallowImplicitObject = 30209
ERR_StrictDisallowsImplicitProc = 30210
ERR_StrictDisallowsImplicitArgs = 30211
ERR_InvalidParameterSyntax = 30213
ERR_ExpectedSubFunction = 30215
ERR_ExpectedStringLiteral = 30217
ERR_MissingLibInDeclare = 30218
ERR_DelegateNoInvoke1 = 30220
ERR_MissingIsInTypeOf = 30224
ERR_DuplicateOption1 = 30225
ERR_ModuleCantInherit = 30230
ERR_ModuleCantImplement = 30231
ERR_BadImplementsType = 30232
ERR_BadConstFlags1 = 30233
ERR_BadWithEventsFlags1 = 30234
ERR_BadDimFlags1 = 30235
ERR_DuplicateParamName1 = 30237
ERR_LoopDoubleCondition = 30238
ERR_ExpectedRelational = 30239
ERR_ExpectedExitKind = 30240
ERR_ExpectedNamedArgument = 30241
ERR_BadMethodFlags1 = 30242
ERR_BadEventFlags1 = 30243
ERR_BadDeclareFlags1 = 30244
ERR_BadLocalConstFlags1 = 30246
ERR_BadLocalDimFlags1 = 30247
ERR_ExpectedConditionalDirective = 30248
ERR_ExpectedEQ = 30249
ERR_ConstructorNotFound1 = 30251
ERR_InvalidEndInterface = 30252
ERR_MissingEndInterface = 30253
ERR_InheritsFrom2 = 30256
ERR_InheritanceCycle1 = 30257
ERR_InheritsFromNonClass = 30258
ERR_MultiplyDefinedType3 = 30260
ERR_BadOverrideAccess2 = 30266
ERR_CantOverrideNotOverridable2 = 30267
ERR_DuplicateProcDef1 = 30269
ERR_BadInterfaceMethodFlags1 = 30270
ERR_NamedParamNotFound2 = 30272
ERR_BadInterfacePropertyFlags1 = 30273
ERR_NamedArgUsedTwice2 = 30274
ERR_InterfaceCantUseEventSpecifier1 = 30275
ERR_TypecharNoMatch2 = 30277
ERR_ExpectedSubOrFunction = 30278
ERR_BadEmptyEnum1 = 30280
ERR_InvalidConstructorCall = 30282
ERR_CantOverrideConstructor = 30283
ERR_OverrideNotNeeded3 = 30284
ERR_ExpectedDot = 30287
ERR_DuplicateLocals1 = 30288
ERR_InvInsideEndsProc = 30289
ERR_LocalSameAsFunc = 30290
ERR_RecordEmbeds2 = 30293
ERR_RecordCycle2 = 30294
ERR_InterfaceCycle1 = 30296
ERR_SubNewCycle2 = 30297
ERR_SubNewCycle1 = 30298
ERR_InheritsFromCantInherit3 = 30299
ERR_OverloadWithOptional2 = 30300
ERR_OverloadWithReturnType2 = 30301
ERR_TypeCharWithType1 = 30302
ERR_TypeCharOnSub = 30303
ERR_OverloadWithDefault2 = 30305
ERR_MissingSubscript = 30306
ERR_OverrideWithDefault2 = 30307
ERR_OverrideWithOptional2 = 30308
ERR_FieldOfValueFieldOfMarshalByRef3 = 30310
ERR_TypeMismatch2 = 30311
ERR_CaseAfterCaseElse = 30321
ERR_ConvertArrayMismatch4 = 30332
ERR_ConvertObjectArrayMismatch3 = 30333
ERR_ForLoopType1 = 30337
ERR_OverloadWithByref2 = 30345
ERR_InheritsFromNonInterface = 30354
ERR_BadInterfaceOrderOnInherits = 30357
ERR_DuplicateDefaultProps1 = 30359
ERR_DefaultMissingFromProperty2 = 30361
ERR_OverridingPropertyKind2 = 30362
ERR_NewInInterface = 30363
ERR_BadFlagsOnNew1 = 30364
ERR_OverloadingPropertyKind2 = 30366
ERR_NoDefaultNotExtend1 = 30367
ERR_OverloadWithArrayVsParamArray2 = 30368
ERR_BadInstanceMemberAccess = 30369
ERR_ExpectedRbrace = 30370
ERR_ModuleAsType1 = 30371
ERR_NewIfNullOnNonClass = 30375
'ERR_NewIfNullOnAbstractClass1 = 30376
ERR_CatchAfterFinally = 30379
ERR_CatchNoMatchingTry = 30380
ERR_FinallyAfterFinally = 30381
ERR_FinallyNoMatchingTry = 30382
ERR_EndTryNoTry = 30383
ERR_ExpectedEndTry = 30384
ERR_BadDelegateFlags1 = 30385
ERR_NoConstructorOnBase2 = 30387
ERR_InaccessibleSymbol2 = 30389
ERR_InaccessibleMember3 = 30390
ERR_CatchNotException1 = 30392
ERR_ExitTryNotWithinTry = 30393
ERR_BadRecordFlags1 = 30395
ERR_BadEnumFlags1 = 30396
ERR_BadInterfaceFlags1 = 30397
ERR_OverrideWithByref2 = 30398
ERR_MyBaseAbstractCall1 = 30399
ERR_IdentNotMemberOfInterface4 = 30401
'//We intentionally use argument '3' for the delegate name. This makes generating overload resolution errors
'//easy. To make it more clear that were doing this, we name the message DelegateBindingMismatch3_2.
'//This differentiates its from DelegateBindingMismatch3_3, which actually takes 3 parameters instead of 2.
'//This is a workaround, but it makes the logic for reporting overload resolution errors easier error report more straight forward.
'ERR_DelegateBindingMismatch3_2 = 30408
ERR_WithEventsRequiresClass = 30412
ERR_WithEventsAsStruct = 30413
ERR_ConvertArrayRankMismatch2 = 30414
ERR_RedimRankMismatch = 30415
ERR_StartupCodeNotFound1 = 30420
ERR_ConstAsNonConstant = 30424
ERR_InvalidEndSub = 30429
ERR_InvalidEndFunction = 30430
ERR_InvalidEndProperty = 30431
ERR_ModuleCantUseMethodSpecifier1 = 30433
ERR_ModuleCantUseEventSpecifier1 = 30434
ERR_StructCantUseVarSpecifier1 = 30435
'ERR_ModuleCantUseMemberSpecifier1 = 30436 Now reporting BC30735
ERR_InvalidOverrideDueToReturn2 = 30437
ERR_ConstantWithNoValue = 30438
ERR_ExpressionOverflow1 = 30439
'ERR_ExpectedEndTryCatch = 30441 - No Longer Reported. Removed per bug 926779
'ERR_ExpectedEndTryFinally = 30442 - No Longer Reported. Removed per bug 926779
ERR_DuplicatePropertyGet = 30443
ERR_DuplicatePropertySet = 30444
' ERR_ConstAggregate = 30445 Now giving BC30424
ERR_NameNotDeclared1 = 30451
ERR_BinaryOperands3 = 30452
ERR_ExpectedProcedure = 30454
ERR_OmittedArgument2 = 30455
ERR_NameNotMember2 = 30456
'ERR_NoTypeNamesAvailable = 30458
ERR_EndClassNoClass = 30460
ERR_BadClassFlags1 = 30461
ERR_ImportsMustBeFirst = 30465
ERR_NonNamespaceOrClassOnImport2 = 30467
ERR_TypecharNotallowed = 30468
ERR_ObjectReferenceNotSupplied = 30469
ERR_MyClassNotInClass = 30470
ERR_IndexedNotArrayOrProc = 30471
ERR_EventSourceIsArray = 30476
ERR_SharedConstructorWithParams = 30479
ERR_SharedConstructorIllegalSpec1 = 30480
ERR_ExpectedEndClass = 30481
ERR_UnaryOperand2 = 30487
ERR_BadFlagsWithDefault1 = 30490
ERR_VoidValue = 30491
ERR_ConstructorFunction = 30493
'ERR_LineTooLong = 30494 - No longer reported. Removed per 926916
ERR_InvalidLiteralExponent = 30495
ERR_NewCannotHandleEvents = 30497
ERR_CircularEvaluation1 = 30500
ERR_BadFlagsOnSharedMeth1 = 30501
ERR_BadFlagsOnSharedProperty1 = 30502
ERR_BadFlagsOnStdModuleProperty1 = 30503
ERR_SharedOnProcThatImpl = 30505
ERR_NoWithEventsVarOnHandlesList = 30506
ERR_AccessMismatch6 = 30508
ERR_InheritanceAccessMismatch5 = 30509
ERR_NarrowingConversionDisallowed2 = 30512
ERR_NoArgumentCountOverloadCandidates1 = 30516
ERR_NoViableOverloadCandidates1 = 30517
ERR_NoCallableOverloadCandidates2 = 30518
ERR_NoNonNarrowingOverloadCandidates2 = 30519
ERR_ArgumentNarrowing3 = 30520
ERR_NoMostSpecificOverload2 = 30521
ERR_NotMostSpecificOverload = 30522
ERR_OverloadCandidate2 = 30523
ERR_NoGetProperty1 = 30524
ERR_NoSetProperty1 = 30526
'ERR_ArrayType2 = 30528
ERR_ParamTypingInconsistency = 30529
ERR_ParamNameFunctionNameCollision = 30530
ERR_DateToDoubleConversion = 30532
ERR_DoubleToDateConversion = 30533
ERR_ZeroDivide = 30542
ERR_TryAndOnErrorDoNotMix = 30544
ERR_PropertyAccessIgnored = 30545
ERR_InterfaceNoDefault1 = 30547
ERR_InvalidAssemblyAttribute1 = 30548
ERR_InvalidModuleAttribute1 = 30549
ERR_AmbiguousInUnnamedNamespace1 = 30554
ERR_DefaultMemberNotProperty1 = 30555
ERR_AmbiguousInNamespace2 = 30560
ERR_AmbiguousInImports2 = 30561
ERR_AmbiguousInModules2 = 30562
' ERR_AmbiguousInApplicationObject2 = 30563 ' comment out in Dev10
ERR_ArrayInitializerTooFewDimensions = 30565
ERR_ArrayInitializerTooManyDimensions = 30566
ERR_InitializerTooFewElements1 = 30567
ERR_InitializerTooManyElements1 = 30568
ERR_NewOnAbstractClass = 30569
ERR_DuplicateNamedImportAlias1 = 30572
ERR_DuplicatePrefix = 30573
ERR_StrictDisallowsLateBinding = 30574
' ERR_PropertyMemberSyntax = 30576 unused in Roslyn
ERR_AddressOfOperandNotMethod = 30577
ERR_EndExternalSource = 30578
ERR_ExpectedEndExternalSource = 30579
ERR_NestedExternalSource = 30580
ERR_AddressOfNotDelegate1 = 30581
ERR_SyncLockRequiresReferenceType1 = 30582
ERR_MethodAlreadyImplemented2 = 30583
ERR_DuplicateInInherits1 = 30584
ERR_NamedParamArrayArgument = 30587
ERR_OmittedParamArrayArgument = 30588
ERR_ParamArrayArgumentMismatch = 30589
ERR_EventNotFound1 = 30590
'ERR_NoDefaultSource = 30591
ERR_ModuleCantUseVariableSpecifier1 = 30593
ERR_SharedEventNeedsSharedHandler = 30594
ERR_ExpectedMinus = 30601
ERR_InterfaceMemberSyntax = 30602
ERR_InvInsideInterface = 30603
ERR_InvInsideEndsInterface = 30604
ERR_BadFlagsInNotInheritableClass1 = 30607
ERR_UnimplementedMustOverride = 30609 ' substituted into ERR_BaseOnlyClassesMustBeExplicit2
ERR_BaseOnlyClassesMustBeExplicit2 = 30610
ERR_NegativeArraySize = 30611
ERR_MyClassAbstractCall1 = 30614
ERR_EndDisallowedInDllProjects = 30615
ERR_BlockLocalShadowing1 = 30616
ERR_ModuleNotAtNamespace = 30617
ERR_NamespaceNotAtNamespace = 30618
ERR_InvInsideEndsEnum = 30619
ERR_InvalidOptionStrict = 30620
ERR_EndStructureNoStructure = 30621
ERR_EndModuleNoModule = 30622
ERR_EndNamespaceNoNamespace = 30623
ERR_ExpectedEndStructure = 30624
ERR_ExpectedEndModule = 30625
ERR_ExpectedEndNamespace = 30626
ERR_OptionStmtWrongOrder = 30627
ERR_StructCantInherit = 30628
ERR_NewInStruct = 30629
ERR_InvalidEndGet = 30630
ERR_MissingEndGet = 30631
ERR_InvalidEndSet = 30632
ERR_MissingEndSet = 30633
ERR_InvInsideEndsProperty = 30634
ERR_DuplicateWriteabilityCategoryUsed = 30635
ERR_ExpectedGreater = 30636
ERR_AttributeStmtWrongOrder = 30637
ERR_NoExplicitArraySizes = 30638
ERR_BadPropertyFlags1 = 30639
ERR_InvalidOptionExplicit = 30640
ERR_MultipleParameterSpecifiers = 30641
ERR_MultipleOptionalParameterSpecifiers = 30642
ERR_UnsupportedProperty1 = 30643
ERR_InvalidOptionalParameterUsage1 = 30645
ERR_ReturnFromNonFunction = 30647
ERR_UnterminatedStringLiteral = 30648
ERR_UnsupportedType1 = 30649
ERR_InvalidEnumBase = 30650
ERR_ByRefIllegal1 = 30651
'//If you make any change involving these errors, such as creating more specific versions for use
'//in other contexts, please make sure to appropriately modify Bindable::ResolveOverloadingShouldSkipBadMember
ERR_UnreferencedAssembly3 = 30652
ERR_UnreferencedModule3 = 30653
ERR_ReturnWithoutValue = 30654
' ERR_CantLoadStdLibrary1 = 30655 roslyn doesn't use special messages when well-known assemblies cannot be loaded.
ERR_UnsupportedField1 = 30656
ERR_UnsupportedMethod1 = 30657
ERR_NoNonIndexProperty1 = 30658
ERR_BadAttributePropertyType1 = 30659
ERR_LocalsCannotHaveAttributes = 30660
ERR_PropertyOrFieldNotDefined1 = 30661
ERR_InvalidAttributeUsage2 = 30662
ERR_InvalidMultipleAttributeUsage1 = 30663
ERR_CantThrowNonException = 30665
ERR_MustBeInCatchToRethrow = 30666
ERR_ParamArrayMustBeByVal = 30667
ERR_UseOfObsoleteSymbol2 = 30668
ERR_RedimNoSizes = 30670
ERR_InitWithMultipleDeclarators = 30671
ERR_InitWithExplicitArraySizes = 30672
ERR_EndSyncLockNoSyncLock = 30674
ERR_ExpectedEndSyncLock = 30675
ERR_NameNotEvent2 = 30676
ERR_AddOrRemoveHandlerEvent = 30677
ERR_UnrecognizedEnd = 30678
ERR_ArrayInitForNonArray2 = 30679
ERR_EndRegionNoRegion = 30680
ERR_ExpectedEndRegion = 30681
ERR_InheritsStmtWrongOrder = 30683
ERR_AmbiguousAcrossInterfaces3 = 30685
ERR_DefaultPropertyAmbiguousAcrossInterfaces4 = 30686
ERR_InterfaceEventCantUse1 = 30688
ERR_ExecutableAsDeclaration = 30689
ERR_StructureNoDefault1 = 30690
' ERR_TypeMemberAsExpression2 = 30691 Now giving BC30109
ERR_MustShadow2 = 30695
'ERR_OverloadWithOptionalTypes2 = 30696
ERR_OverrideWithOptionalTypes2 = 30697
'ERR_UnableToGetTempPath = 30698
'ERR_NameNotDeclaredDebug1 = 30699
'// This error should never be seen.
'ERR_NoSideEffects = 30700
'ERR_InvalidNothing = 30701
'ERR_IndexOutOfRange1 = 30702
'ERR_RuntimeException2 = 30703
'ERR_RuntimeException = 30704
'ERR_ObjectReferenceIsNothing1 = 30705
'// This error should never be seen.
'ERR_ExpressionNotValidInEE = 30706
'ERR_UnableToEvaluateExpression = 30707
'ERR_UnableToEvaluateLoops = 30708
'ERR_NoDimsInDebugger = 30709
ERR_ExpectedEndOfExpression = 30710
'ERR_SetValueNotAllowedOnNonLeafFrame = 30711
'ERR_UnableToClassInformation1 = 30712
'ERR_NoExitInDebugger = 30713
'ERR_NoResumeInDebugger = 30714
'ERR_NoCatchInDebugger = 30715
'ERR_NoFinallyInDebugger = 30716
'ERR_NoTryInDebugger = 30717
'ERR_NoSelectInDebugger = 30718
'ERR_NoCaseInDebugger = 30719
'ERR_NoOnErrorInDebugger = 30720
'ERR_EvaluationAborted = 30721
'ERR_EvaluationTimeout = 30722
'ERR_EvaluationNoReturnValue = 30723
'ERR_NoErrorStatementInDebugger = 30724
'ERR_NoThrowStatementInDebugger = 30725
'ERR_NoWithContextInDebugger = 30726
ERR_StructsCannotHandleEvents = 30728
ERR_OverridesImpliesOverridable = 30730
'ERR_NoAddressOfInDebugger = 30731
'ERR_EvaluationOfWebMethods = 30732
ERR_LocalNamedSameAsParam1 = 30734
ERR_ModuleCantUseTypeSpecifier1 = 30735
'ERR_EvaluationBadStartPoint = 30736
ERR_InValidSubMainsFound1 = 30737
ERR_MoreThanOneValidMainWasFound2 = 30738
'ERR_NoRaiseEventOfInDebugger = 30739
'ERR_InvalidCast2 = 30741
ERR_CannotConvertValue2 = 30742
'ERR_ArrayElementIsNothing = 30744
'ERR_InternalCompilerError = 30747
'ERR_InvalidCast1 = 30748
'ERR_UnableToGetValue = 30749
'ERR_UnableToLoadType1 = 30750
'ERR_UnableToGetTypeInformationFor1 = 30751
ERR_OnErrorInSyncLock = 30752
ERR_NarrowingConversionCollection2 = 30753
ERR_GotoIntoTryHandler = 30754
ERR_GotoIntoSyncLock = 30755
ERR_GotoIntoWith = 30756
ERR_GotoIntoFor = 30757
ERR_BadAttributeNonPublicConstructor = 30758
'ERR_ArrayElementIsNothing1 = 30759
'ERR_ObjectReferenceIsNothing = 30760
' ERR_StarliteDisallowsLateBinding = 30762
' ERR_StarliteBadDeclareFlags = 30763
' ERR_NoStarliteOverloadResolution = 30764
'ERR_NoSupportFileIOKeywords1 = 30766
' ERR_NoSupportGetStatement = 30767 - starlite error message
' ERR_NoSupportLineKeyword = 30768 cut from Roslyn
' ERR_StarliteDisallowsEndStatement = 30769 cut from Roslyn
ERR_DefaultEventNotFound1 = 30770
ERR_InvalidNonSerializedUsage = 30772
'ERR_NoContinueInDebugger = 30780
ERR_ExpectedContinueKind = 30781
ERR_ContinueDoNotWithinDo = 30782
ERR_ContinueForNotWithinFor = 30783
ERR_ContinueWhileNotWithinWhile = 30784
ERR_DuplicateParameterSpecifier = 30785
ERR_ModuleCantUseDLLDeclareSpecifier1 = 30786
ERR_StructCantUseDLLDeclareSpecifier1 = 30791
ERR_TryCastOfValueType1 = 30792
ERR_TryCastOfUnconstrainedTypeParam1 = 30793
ERR_AmbiguousDelegateBinding2 = 30794
ERR_SharedStructMemberCannotSpecifyNew = 30795
ERR_GenericSubMainsFound1 = 30796
ERR_GeneralProjectImportsError3 = 30797
ERR_InvalidTypeForAliasesImport2 = 30798
ERR_UnsupportedConstant2 = 30799
ERR_ObsoleteArgumentsNeedParens = 30800
ERR_ObsoleteLineNumbersAreLabels = 30801
ERR_ObsoleteStructureNotType = 30802
'ERR_ObsoleteDecimalNotCurrency = 30803 cut from Roslyn
ERR_ObsoleteObjectNotVariant = 30804
'ERR_ObsoleteArrayBounds = 30805 unused in Roslyn
ERR_ObsoleteLetSetNotNeeded = 30807
ERR_ObsoletePropertyGetLetSet = 30808
ERR_ObsoleteWhileWend = 30809
'ERR_ObsoleteStaticMethod = 30810 cut from Roslyn
ERR_ObsoleteRedimAs = 30811
ERR_ObsoleteOptionalWithoutValue = 30812
ERR_ObsoleteGosub = 30814
'ERR_ObsoleteFileIOKeywords1 = 30815 cut from Roslyn
'ERR_ObsoleteDebugKeyword1 = 30816 cut from Roslyn
ERR_ObsoleteOnGotoGosub = 30817
'ERR_ObsoleteMathCompatKeywords1 = 30818 cut from Roslyn
'ERR_ObsoleteMathKeywords2 = 30819 cut from Roslyn
'ERR_ObsoleteLsetKeyword1 = 30820 cut from Roslyn
'ERR_ObsoleteRsetKeyword1 = 30821 cut from Roslyn
'ERR_ObsoleteNullKeyword1 = 30822 cut from Roslyn
'ERR_ObsoleteEmptyKeyword1 = 30823 cut from Roslyn
ERR_ObsoleteEndIf = 30826
ERR_ObsoleteExponent = 30827
ERR_ObsoleteAsAny = 30828
ERR_ObsoleteGetStatement = 30829
'ERR_ObsoleteLineKeyword = 30830 cut from Roslyn
ERR_OverrideWithArrayVsParamArray2 = 30906
'// CONSIDER :harishk - improve this error message
ERR_CircularBaseDependencies4 = 30907
ERR_NestedBase2 = 30908
ERR_AccessMismatchOutsideAssembly4 = 30909
ERR_InheritanceAccessMismatchOutside3 = 30910
ERR_UseOfObsoletePropertyAccessor3 = 30911
ERR_UseOfObsoletePropertyAccessor2 = 30912
ERR_AccessMismatchImplementedEvent6 = 30914
ERR_AccessMismatchImplementedEvent4 = 30915
ERR_InheritanceCycleInImportedType1 = 30916
ERR_NoNonObsoleteConstructorOnBase3 = 30917
ERR_NoNonObsoleteConstructorOnBase4 = 30918
ERR_RequiredNonObsoleteNewCall3 = 30919
ERR_RequiredNonObsoleteNewCall4 = 30920
ERR_InheritsTypeArgAccessMismatch7 = 30921
ERR_InheritsTypeArgAccessMismatchOutside5 = 30922
'ERR_AccessMismatchTypeArgImplEvent7 = 30923 unused in Roslyn
'ERR_AccessMismatchTypeArgImplEvent5 = 30924 unused in Roslyn
ERR_PartialTypeAccessMismatch3 = 30925
ERR_PartialTypeBadMustInherit1 = 30926
ERR_MustOverOnNotInheritPartClsMem1 = 30927
ERR_BaseMismatchForPartialClass3 = 30928
ERR_PartialTypeTypeParamNameMismatch3 = 30931
ERR_PartialTypeConstraintMismatch1 = 30932
ERR_LateBoundOverloadInterfaceCall1 = 30933
ERR_RequiredAttributeConstConversion2 = 30934
ERR_AmbiguousOverrides3 = 30935
ERR_OverriddenCandidate1 = 30936
ERR_AmbiguousImplements3 = 30937
ERR_AddressOfNotCreatableDelegate1 = 30939
'ERR_ReturnFromEventMethod = 30940 unused in Roslyn
'ERR_BadEmptyStructWithCustomEvent1 = 30941
ERR_ComClassGenericMethod = 30943
ERR_SyntaxInCastOp = 30944
'ERR_UnimplementedBadMemberEvent = 30945 Cut in Roslyn
'ERR_EvaluationStopRequested = 30946
'ERR_EvaluationSuspendRequested = 30947
'ERR_EvaluationUnscheduledFiber = 30948
ERR_ArrayInitializerForNonConstDim = 30949
ERR_DelegateBindingFailure3 = 30950
'ERR_DelegateBindingTypeInferenceFails2 = 30952
'ERR_ConstraintViolationError1 = 30953
'ERR_ConstraintsFailedForInferredArgs2 = 30954
'ERR_TypeMismatchDLLProjectMix6 = 30955
'ERR_EvaluationPriorTimeout = 30957
'ERR_EvaluationENCObjectOutdated = 30958
' Obsolete ERR_TypeRefFromMetadataToVBUndef = 30960
'ERR_TypeMismatchMixedDLLs6 = 30961
'ERR_ReferencedAssemblyCausesCycle3 = 30962
'ERR_AssemblyRefAssembly2 = 30963
'ERR_AssemblyRefProject2 = 30964
'ERR_ProjectRefAssembly2 = 30965
'ERR_ProjectRefProject2 = 30966
'ERR_ReferencedAssembliesAmbiguous4 = 30967
'ERR_ReferencedAssembliesAmbiguous6 = 30968
'ERR_ReferencedProjectsAmbiguous4 = 30969
'ERR_GeneralErrorMixedDLLs5 = 30970
'ERR_GeneralErrorDLLProjectMix5 = 30971
ERR_StructLayoutAttributeNotAllowed = 30972
'ERR_ClassNotLoadedDuringDebugging = 30973
'ERR_UnableToEvaluateComment = 30974
'ERR_ForIndexInUse = 30975
'ERR_NextForMismatch = 30976
ERR_IterationVariableShadowLocal1 = 30978
ERR_InvalidOptionInfer = 30979
ERR_CircularInference1 = 30980
ERR_InAccessibleOverridingMethod5 = 30981
ERR_NoSuitableWidestType1 = 30982
ERR_AmbiguousWidestType3 = 30983
ERR_ExpectedAssignmentOperatorInInit = 30984
ERR_ExpectedQualifiedNameInInit = 30985
ERR_ExpectedLbrace = 30987
ERR_UnrecognizedTypeOrWith = 30988
ERR_DuplicateAggrMemberInit1 = 30989
ERR_NonFieldPropertyAggrMemberInit1 = 30990
ERR_SharedMemberAggrMemberInit1 = 30991
ERR_ParameterizedPropertyInAggrInit1 = 30992
ERR_NoZeroCountArgumentInitCandidates1 = 30993
ERR_AggrInitInvalidForObject = 30994
'ERR_BadWithRefInConstExpr = 30995
ERR_InitializerExpected = 30996
ERR_LineContWithCommentOrNoPrecSpace = 30999
' ERR_MemberNotFoundForNoPia = 31000 not used in Roslyn. This looks to be a VB EE message
ERR_InvInsideEnum = 31001
ERR_InvInsideBlock = 31002
ERR_UnexpectedExpressionStatement = 31003
ERR_WinRTEventWithoutDelegate = 31004
ERR_SecurityCriticalAsyncInClassOrStruct = 31005
ERR_SecurityCriticalAsync = 31006
ERR_BadModuleFile1 = 31007
ERR_BadRefLib1 = 31011
'ERR_UnableToLoadDll1 = 31013
'ERR_BadDllEntrypoint2 = 31014
'ERR_BadOutputFile1 = 31019
'ERR_BadOutputStream = 31020
'ERR_DeadBackgroundThread = 31021
'ERR_XMLParserError = 31023
'ERR_UnableToCreateMetaDataAPI = 31024
'ERR_UnableToOpenFile1 = 31027
ERR_EventHandlerSignatureIncompatible2 = 31029
ERR_ProjectCCError1 = 31030
'ERR_ProjectCCError0 = 31031
ERR_InterfaceImplementedTwice1 = 31033
ERR_InterfaceNotImplemented1 = 31035
ERR_AmbiguousImplementsMember3 = 31040
'ERR_BadInterfaceMember = 31041
ERR_ImplementsOnNew = 31042
ERR_ArrayInitInStruct = 31043
ERR_EventTypeNotDelegate = 31044
ERR_ProtectedTypeOutsideClass = 31047
ERR_DefaultPropertyWithNoParams = 31048
ERR_InitializerInStruct = 31049
ERR_DuplicateImport1 = 31051
ERR_BadModuleFlags1 = 31052
ERR_ImplementsStmtWrongOrder = 31053
ERR_MemberConflictWithSynth4 = 31058
ERR_SynthMemberClashesWithSynth7 = 31059
ERR_SynthMemberClashesWithMember5 = 31060
ERR_MemberClashesWithSynth6 = 31061
ERR_SetHasOnlyOneParam = 31063
ERR_SetValueNotPropertyType = 31064
ERR_SetHasToBeByVal1 = 31065
ERR_StructureCantUseProtected = 31067
ERR_BadInterfaceDelegateSpecifier1 = 31068
ERR_BadInterfaceEnumSpecifier1 = 31069
ERR_BadInterfaceClassSpecifier1 = 31070
ERR_BadInterfaceStructSpecifier1 = 31071
'ERR_WarningTreatedAsError = 31072
'ERR_DelegateConstructorMissing1 = 31074 unused in Roslyn
ERR_UseOfObsoleteSymbolNoMessage1 = 31075
ERR_MetaDataIsNotAssembly = 31076
ERR_MetaDataIsNotModule = 31077
ERR_ReferenceComparison3 = 31080
ERR_CatchVariableNotLocal1 = 31082
ERR_ModuleMemberCantImplement = 31083
ERR_EventDelegatesCantBeFunctions = 31084
ERR_InvalidDate = 31085
ERR_CantOverride4 = 31086
ERR_CantSpecifyArraysOnBoth = 31087
ERR_NotOverridableRequiresOverrides = 31088
ERR_PrivateTypeOutsideType = 31089
ERR_TypeRefResolutionError3 = 31091
ERR_ParamArrayWrongType = 31092
ERR_CoClassMissing2 = 31094
ERR_InvalidMeReference = 31095
ERR_InvalidImplicitMeReference = 31096
ERR_RuntimeMemberNotFound2 = 31097
'ERR_RuntimeClassNotFound1 = 31098
ERR_BadPropertyAccessorFlags = 31099
ERR_BadPropertyAccessorFlagsRestrict = 31100
ERR_OnlyOneAccessorForGetSet = 31101
ERR_NoAccessibleSet = 31102
ERR_NoAccessibleGet = 31103
ERR_WriteOnlyNoAccessorFlag = 31104
ERR_ReadOnlyNoAccessorFlag = 31105
ERR_BadPropertyAccessorFlags1 = 31106
ERR_BadPropertyAccessorFlags2 = 31107
ERR_BadPropertyAccessorFlags3 = 31108
ERR_InAccessibleCoClass3 = 31109
ERR_MissingValuesForArraysInApplAttrs = 31110
ERR_ExitEventMemberNotInvalid = 31111
ERR_InvInsideEndsEvent = 31112
'ERR_EventMemberSyntax = 31113 abandoned per KevinH analysis. Roslyn bug 1637
ERR_MissingEndEvent = 31114
ERR_MissingEndAddHandler = 31115
ERR_MissingEndRemoveHandler = 31116
ERR_MissingEndRaiseEvent = 31117
'ERR_EndAddHandlerNotAtLineStart = 31118
'ERR_EndRemoveHandlerNotAtLineStart = 31119
'ERR_EndRaiseEventNotAtLineStart = 31120
ERR_CustomEventInvInInterface = 31121
ERR_CustomEventRequiresAs = 31122
ERR_InvalidEndEvent = 31123
ERR_InvalidEndAddHandler = 31124
ERR_InvalidEndRemoveHandler = 31125
ERR_InvalidEndRaiseEvent = 31126
ERR_DuplicateAddHandlerDef = 31127
ERR_DuplicateRemoveHandlerDef = 31128
ERR_DuplicateRaiseEventDef = 31129
ERR_MissingAddHandlerDef1 = 31130
ERR_MissingRemoveHandlerDef1 = 31131
ERR_MissingRaiseEventDef1 = 31132
ERR_EventAddRemoveHasOnlyOneParam = 31133
ERR_EventAddRemoveByrefParamIllegal = 31134
ERR_SpecifiersInvOnEventMethod = 31135
ERR_AddRemoveParamNotEventType = 31136
ERR_RaiseEventShapeMismatch1 = 31137
ERR_EventMethodOptionalParamIllegal1 = 31138
ERR_CantReferToMyGroupInsideGroupType1 = 31139
ERR_InvalidUseOfCustomModifier = 31140
ERR_InvalidOptionStrictCustom = 31141
ERR_ObsoleteInvalidOnEventMember = 31142
ERR_DelegateBindingIncompatible2 = 31143
ERR_ExpectedXmlName = 31146
ERR_UndefinedXmlPrefix = 31148
ERR_DuplicateXmlAttribute = 31149
ERR_MismatchedXmlEndTag = 31150
ERR_MissingXmlEndTag = 31151
ERR_ReservedXmlPrefix = 31152
ERR_MissingVersionInXmlDecl = 31153
ERR_IllegalAttributeInXmlDecl = 31154
ERR_QuotedEmbeddedExpression = 31155
ERR_VersionMustBeFirstInXmlDecl = 31156
ERR_AttributeOrder = 31157
'ERR_UnexpectedXmlName = 31158
ERR_ExpectedXmlEndEmbedded = 31159
ERR_ExpectedXmlEndPI = 31160
ERR_ExpectedXmlEndComment = 31161
ERR_ExpectedXmlEndCData = 31162
ERR_ExpectedSQuote = 31163
ERR_ExpectedQuote = 31164
ERR_ExpectedLT = 31165
ERR_StartAttributeValue = 31166
ERR_ExpectedDiv = 31167
ERR_NoXmlAxesLateBinding = 31168
ERR_IllegalXmlStartNameChar = 31169
ERR_IllegalXmlNameChar = 31170
ERR_IllegalXmlCommentChar = 31171
ERR_EmbeddedExpression = 31172
ERR_ExpectedXmlWhiteSpace = 31173
ERR_IllegalProcessingInstructionName = 31174
ERR_DTDNotSupported = 31175
'ERR_IllegalXmlChar = 31176 unused in Dev10
ERR_IllegalXmlWhiteSpace = 31177
ERR_ExpectedSColon = 31178
ERR_ExpectedXmlBeginEmbedded = 31179
ERR_XmlEntityReference = 31180
ERR_InvalidAttributeValue1 = 31181
ERR_InvalidAttributeValue2 = 31182
ERR_ReservedXmlNamespace = 31183
ERR_IllegalDefaultNamespace = 31184
'ERR_RequireAggregateInitializationImpl = 31185
ERR_QualifiedNameNotAllowed = 31186
ERR_ExpectedXmlns = 31187
'ERR_DefaultNamespaceNotSupported = 31188 Not reported by Dev10.
ERR_IllegalXmlnsPrefix = 31189
ERR_XmlFeaturesNotAvailable = 31190
'ERR_UnableToEmbedUacManifest = 31191 now reporting ErrorCreatingWin32ResourceFile
ERR_UnableToReadUacManifest2 = 31192
'ERR_UseValueForXmlExpression3 = 31193 ' Replaced by WRN_UseValueForXmlExpression3
ERR_TypeMismatchForXml3 = 31194
ERR_BinaryOperandsForXml4 = 31195
'ERR_XmlFeaturesNotAvailableDebugger = 31196
ERR_FullWidthAsXmlDelimiter = 31197
'ERR_XmlRequiresParens = 31198 No Longer Reported. Removed per 926946.
ERR_XmlEndCDataNotAllowedInContent = 31198
'ERR_UacALink3Missing = 31199 not used in Roslyn.
'ERR_XmlFeaturesNotSupported = 31200 not detected by the Roslyn compiler
ERR_EventImplRemoveHandlerParamWrong = 31201
ERR_MixingWinRTAndNETEvents = 31202
ERR_AddParamWrongForWinRT = 31203
ERR_RemoveParamWrongForWinRT = 31204
ERR_ReImplementingWinRTInterface5 = 31205
ERR_ReImplementingWinRTInterface4 = 31206
ERR_XmlEndElementNoMatchingStart = 31207
ERR_UndefinedTypeOrNamespace1 = 31208
ERR_BadInterfaceInterfaceSpecifier1 = 31209
ERR_TypeClashesWithVbCoreType4 = 31210
ERR_SecurityAttributeMissingAction = 31211
ERR_SecurityAttributeInvalidAction = 31212
ERR_SecurityAttributeInvalidActionAssembly = 31213
ERR_SecurityAttributeInvalidActionTypeOrMethod = 31214
ERR_PrincipalPermissionInvalidAction = 31215
ERR_PermissionSetAttributeInvalidFile = 31216
ERR_PermissionSetAttributeFileReadError = 31217
ERR_ExpectedWarningKeyword = 31218
'// NOTE: If you add any new errors that may be attached to a symbol during meta-import when it is marked as bad,
'// particularly if it applies to method symbols, please appropriately modify Bindable::ResolveOverloadingShouldSkipBadMember.
'// Failure to do so may break customer code.
'// AVAILABLE 31219-31390
ERR_InvalidSubsystemVersion = 31391
ERR_LibAnycpu32bitPreferredConflict = 31392
ERR_RestrictedAccess = 31393
ERR_RestrictedConversion1 = 31394
ERR_NoTypecharInLabel = 31395
ERR_RestrictedType1 = 31396
ERR_NoTypecharInAlias = 31398
ERR_NoAccessibleConstructorOnBase = 31399
ERR_BadStaticLocalInStruct = 31400
ERR_DuplicateLocalStatic1 = 31401
ERR_ImportAliasConflictsWithType2 = 31403
ERR_CantShadowAMustOverride1 = 31404
'ERR_OptionalsCantBeStructs = 31405
ERR_MultipleEventImplMismatch3 = 31407
ERR_BadSpecifierCombo2 = 31408
ERR_MustBeOverloads2 = 31409
'ERR_CantOverloadOnMultipleInheritance = 31410
ERR_MustOverridesInClass1 = 31411
ERR_HandlesSyntaxInClass = 31412
ERR_SynthMemberShadowsMustOverride5 = 31413
'ERR_CantImplementNonVirtual3 = 31415 unused in Roslyn
' ERR_MemberShadowsSynthMustOverride5 = 31416 unused in Roslyn
ERR_CannotOverrideInAccessibleMember = 31417
ERR_HandlesSyntaxInModule = 31418
ERR_IsNotOpRequiresReferenceTypes1 = 31419
ERR_ClashWithReservedEnumMember1 = 31420
ERR_MultiplyDefinedEnumMember2 = 31421
ERR_BadUseOfVoid = 31422
ERR_EventImplMismatch5 = 31423
ERR_ForwardedTypeUnavailable3 = 31424
ERR_TypeFwdCycle2 = 31425
ERR_BadTypeInCCExpression = 31426
ERR_BadCCExpression = 31427
ERR_VoidArrayDisallowed = 31428
ERR_MetadataMembersAmbiguous3 = 31429
ERR_TypeOfExprAlwaysFalse2 = 31430
ERR_OnlyPrivatePartialMethods1 = 31431
ERR_PartialMethodsMustBePrivate = 31432
ERR_OnlyOnePartialMethodAllowed2 = 31433
ERR_OnlyOneImplementingMethodAllowed3 = 31434
ERR_PartialMethodMustBeEmpty = 31435
ERR_PartialMethodsMustBeSub1 = 31437
ERR_PartialMethodGenericConstraints2 = 31438
ERR_PartialDeclarationImplements1 = 31439
ERR_NoPartialMethodInAddressOf1 = 31440
ERR_ImplementationMustBePrivate2 = 31441
ERR_PartialMethodParamNamesMustMatch3 = 31442
ERR_PartialMethodTypeParamNameMismatch3 = 31443
ERR_PropertyDoesntImplementAllAccessors = 31444
ERR_InvalidAttributeUsageOnAccessor = 31445
ERR_NestedTypeInInheritsClause2 = 31446
ERR_TypeInItsInheritsClause1 = 31447
ERR_BaseTypeReferences2 = 31448
ERR_IllegalBaseTypeReferences3 = 31449
ERR_InvalidCoClass1 = 31450
ERR_InvalidOutputName = 31451
ERR_InvalidFileAlignment = 31452
ERR_InvalidDebugInformationFormat = 31453
'// NOTE: If you add any new errors that may be attached to a symbol during meta-import when it is marked as bad,
'// particularly if it applies to method symbols, please appropriately modify Bindable::ResolveOverloadingShouldSkipBadMember.
'// Failure to do so may break customer code.
'// AVAILABLE 31451 - 31497
ERR_ConstantStringTooLong = 31498
ERR_MustInheritEventNotOverridden = 31499
ERR_BadAttributeSharedProperty1 = 31500
ERR_BadAttributeReadOnlyProperty1 = 31501
ERR_DuplicateResourceName1 = 31502
ERR_AttributeMustBeClassNotStruct1 = 31503
ERR_AttributeMustInheritSysAttr = 31504
'ERR_AttributeMustHaveAttrUsageAttr = 31505 unused in Roslyn.
ERR_AttributeCannotBeAbstract = 31506
' ERR_AttributeCannotHaveMustOverride = 31507 - reported by dev10 but error is redundant. ERR_AttributeCannotBeAbstract covers this case.
'ERR_CantFindCORSystemDirectory = 31508
ERR_UnableToOpenResourceFile1 = 31509
'ERR_BadAttributeConstField1 = 31510
ERR_BadAttributeNonPublicProperty1 = 31511
ERR_STAThreadAndMTAThread0 = 31512
'ERR_STAThreadAndMTAThread1 = 31513
'//If you make any change involving this error, such as creating a more specific version for use
'//in a particular context, please make sure to appropriately modify Bindable::ResolveOverloadingShouldSkipBadMember
ERR_IndirectUnreferencedAssembly4 = 31515
ERR_BadAttributeNonPublicType1 = 31516
ERR_BadAttributeNonPublicContType2 = 31517
'ERR_AlinkManifestFilepathTooLong = 31518 this scenario reports a more generic error
ERR_BadMetaDataReference1 = 31519
' ERR_ErrorApplyingSecurityAttribute1 = 31520 ' ' we're now reporting more detailed diagnostics: ERR_SecurityAttributeMissingAction, ERR_SecurityAttributeInvalidAction, ERR_SecurityAttributeInvalidActionAssembly or ERR_SecurityAttributeInvalidActionTypeOrMethod
'ERR_DuplicateModuleAttribute1 = 31521
ERR_DllImportOnNonEmptySubOrFunction = 31522
ERR_DllImportNotLegalOnDeclare = 31523
ERR_DllImportNotLegalOnGetOrSet = 31524
'ERR_TypeImportedFromDiffAssemVersions3 = 31525
ERR_DllImportOnGenericSubOrFunction = 31526
ERR_ComClassOnGeneric = 31527
'//If you make any change involving this error, such as creating a more specific version for use
'//in a particular context, please make sure to appropriately modify Bindable::ResolveOverloadingShouldSkipBadMember
'ERR_IndirectUnreferencedAssembly3 = 31528
ERR_DllImportOnInstanceMethod = 31529
ERR_DllImportOnInterfaceMethod = 31530
ERR_DllImportNotLegalOnEventMethod = 31531
'//If you make any change involving these errors, such as creating more specific versions for use
'//in other contexts, please make sure to appropriately modify Bindable::ResolveOverloadingShouldSkipBadMember
'ERR_IndirectUnreferencedProject3 = 31532
'ERR_IndirectUnreferencedProject2 = 31533
ERR_FriendAssemblyBadArguments = 31534
ERR_FriendAssemblyStrongNameRequired = 31535
'ERR_FriendAssemblyRejectBinding = 31536 EDMAURER This has been replaced with two, more specific errors ERR_FriendRefNotEqualToThis and ERR_FriendRefSigningMismatch.
ERR_FriendAssemblyNameInvalid = 31537
ERR_FriendAssemblyBadAccessOverride2 = 31538
ERR_AbsentReferenceToPIA1 = 31539
'ERR_CorlibMissingPIAClasses1 = 31540 EDMAURER Roslyn uses the ordinary missing required type message
ERR_CannotLinkClassWithNoPIA1 = 31541
ERR_InvalidStructMemberNoPIA1 = 31542
ERR_NoPIAAttributeMissing2 = 31543
ERR_NestedGlobalNamespace = 31544
'ERR_NewCoClassNoPIA = 31545 EDMAURER Roslyn gives 31541
'ERR_EventNoPIANoDispID = 31546
'ERR_EventNoPIANoGuid1 = 31547
'ERR_EventNoPIANoComEventInterface1 = 31548
ERR_PIAHasNoAssemblyGuid1 = 31549
'ERR_StructureExplicitFieldLacksOffset = 31550
'ERR_CannotLinkEventInterfaceWithNoPIA1 = 31551
ERR_DuplicateLocalTypes3 = 31552
ERR_PIAHasNoTypeLibAttribute1 = 31553
' ERR_NoPiaEventsMissingSystemCore = 31554 use ordinary missing required type
' ERR_SourceInterfaceMustExist = 31555
ERR_SourceInterfaceMustBeInterface = 31556
ERR_EventNoPIANoBackingMember = 31557
ERR_NestedInteropType = 31558 ' used to be ERR_InvalidInteropType
ERR_IsNestedIn2 = 31559
ERR_LocalTypeNameClash2 = 31560
ERR_InteropMethodWithBody1 = 31561
ERR_UseOfLocalBeforeDeclaration1 = 32000
ERR_UseOfKeywordFromModule1 = 32001
'ERR_UseOfKeywordOutsideClass1 = 32002
'ERR_SymbolFromUnreferencedProject3 = 32004
ERR_BogusWithinLineIf = 32005
ERR_CharToIntegralTypeMismatch1 = 32006
ERR_IntegralToCharTypeMismatch1 = 32007
ERR_NoDirectDelegateConstruction1 = 32008
ERR_MethodMustBeFirstStatementOnLine = 32009
ERR_AttrAssignmentNotFieldOrProp1 = 32010
ERR_StrictDisallowsObjectComparison1 = 32013
ERR_NoConstituentArraySizes = 32014
ERR_FileAttributeNotAssemblyOrModule = 32015
ERR_FunctionResultCannotBeIndexed1 = 32016
ERR_ArgumentSyntax = 32017
ERR_ExpectedResumeOrGoto = 32019
ERR_ExpectedAssignmentOperator = 32020
ERR_NamedArgAlsoOmitted2 = 32021
ERR_CannotCallEvent1 = 32022
ERR_ForEachCollectionDesignPattern1 = 32023
ERR_DefaultValueForNonOptionalParam = 32024
' ERR_RegionWithinMethod = 32025 removed this limitation in Roslyn
'ERR_SpecifiersInvalidOnNamespace = 32026 abandoned, now giving 'Specifiers and attributes are not valid on this statement.'
ERR_ExpectedDotAfterMyBase = 32027
ERR_ExpectedDotAfterMyClass = 32028
ERR_StrictArgumentCopyBackNarrowing3 = 32029
ERR_LbElseifAfterElse = 32030
'ERR_EndSubNotAtLineStart = 32031
'ERR_EndFunctionNotAtLineStart = 32032
'ERR_EndGetNotAtLineStart = 32033
'ERR_EndSetNotAtLineStart = 32034
ERR_StandaloneAttribute = 32035
ERR_NoUniqueConstructorOnBase2 = 32036
ERR_ExtraNextVariable = 32037
ERR_RequiredNewCallTooMany2 = 32038
ERR_ForCtlVarArraySizesSpecified = 32039
ERR_BadFlagsOnNewOverloads = 32040
ERR_TypeCharOnGenericParam = 32041
ERR_TooFewGenericArguments1 = 32042
ERR_TooManyGenericArguments1 = 32043
ERR_GenericConstraintNotSatisfied2 = 32044
ERR_TypeOrMemberNotGeneric1 = 32045
ERR_NewIfNullOnGenericParam = 32046
ERR_MultipleClassConstraints1 = 32047
ERR_ConstNotClassInterfaceOrTypeParam1 = 32048
ERR_DuplicateTypeParamName1 = 32049
ERR_UnboundTypeParam2 = 32050
ERR_IsOperatorGenericParam1 = 32052
ERR_ArgumentCopyBackNarrowing3 = 32053
ERR_ShadowingGenericParamWithMember1 = 32054
ERR_GenericParamBase2 = 32055
ERR_ImplementsGenericParam = 32056
'ERR_ExpressionCannotBeGeneric1 = 32058 unused in Roslyn
ERR_OnlyNullLowerBound = 32059
ERR_ClassConstraintNotInheritable1 = 32060
ERR_ConstraintIsRestrictedType1 = 32061
ERR_GenericParamsOnInvalidMember = 32065
ERR_GenericArgsOnAttributeSpecifier = 32066
ERR_AttrCannotBeGenerics = 32067
ERR_BadStaticLocalInGenericMethod = 32068
ERR_SyntMemberShadowsGenericParam3 = 32070
ERR_ConstraintAlreadyExists1 = 32071
ERR_InterfacePossiblyImplTwice2 = 32072
ERR_ModulesCannotBeGeneric = 32073
ERR_GenericClassCannotInheritAttr = 32074
ERR_DeclaresCantBeInGeneric = 32075
'ERR_GenericTypeRequiresTypeArgs1 = 32076
ERR_OverrideWithConstraintMismatch2 = 32077
ERR_ImplementsWithConstraintMismatch3 = 32078
ERR_OpenTypeDisallowed = 32079
ERR_HandlesInvalidOnGenericMethod = 32080
ERR_MultipleNewConstraints = 32081
ERR_MustInheritForNewConstraint2 = 32082
ERR_NoSuitableNewForNewConstraint2 = 32083
ERR_BadGenericParamForNewConstraint2 = 32084
ERR_NewArgsDisallowedForTypeParam = 32085
ERR_DuplicateRawGenericTypeImport1 = 32086
ERR_NoTypeArgumentCountOverloadCand1 = 32087
ERR_TypeArgsUnexpected = 32088
ERR_NameSameAsMethodTypeParam1 = 32089
ERR_TypeParamNameFunctionNameCollision = 32090
'ERR_OverloadsMayUnify2 = 32091 unused in Roslyn
ERR_BadConstraintSyntax = 32092
ERR_OfExpected = 32093
ERR_ArrayOfRawGenericInvalid = 32095
ERR_ForEachAmbiguousIEnumerable1 = 32096
ERR_IsNotOperatorGenericParam1 = 32097
ERR_TypeParamQualifierDisallowed = 32098
ERR_TypeParamMissingCommaOrRParen = 32099
ERR_TypeParamMissingAsCommaOrRParen = 32100
ERR_MultipleReferenceConstraints = 32101
ERR_MultipleValueConstraints = 32102
ERR_NewAndValueConstraintsCombined = 32103
ERR_RefAndValueConstraintsCombined = 32104
ERR_BadTypeArgForStructConstraint2 = 32105
ERR_BadTypeArgForRefConstraint2 = 32106
ERR_RefAndClassTypeConstrCombined = 32107
ERR_ValueAndClassTypeConstrCombined = 32108
ERR_ConstraintClashIndirectIndirect4 = 32109
ERR_ConstraintClashDirectIndirect3 = 32110
ERR_ConstraintClashIndirectDirect3 = 32111
ERR_ConstraintCycleLink2 = 32112
ERR_ConstraintCycle2 = 32113
ERR_TypeParamWithStructConstAsConst = 32114
ERR_NullableDisallowedForStructConstr1 = 32115
'ERR_NoAccessibleNonGeneric1 = 32117
'ERR_NoAccessibleGeneric1 = 32118
ERR_ConflictingDirectConstraints3 = 32119
ERR_InterfaceUnifiesWithInterface2 = 32120
ERR_BaseUnifiesWithInterfaces3 = 32121
ERR_InterfaceBaseUnifiesWithBase4 = 32122
ERR_InterfaceUnifiesWithBase3 = 32123
ERR_OptionalsCantBeStructGenericParams = 32124 'TODO: remove
'ERR_InterfaceMethodImplsUnify3 = 32125
ERR_AddressOfNullableMethod = 32126
ERR_IsOperatorNullable1 = 32127
ERR_IsNotOperatorNullable1 = 32128
'ERR_NullableOnEnum = 32129
'ERR_NoNullableType = 32130 unused in Roslyn
ERR_ClassInheritsBaseUnifiesWithInterfaces3 = 32131
ERR_ClassInheritsInterfaceBaseUnifiesWithBase4 = 32132
ERR_ClassInheritsInterfaceUnifiesWithBase3 = 32133
ERR_ShadowingTypeOutsideClass1 = 32200
ERR_PropertySetParamCollisionWithValue = 32201
'ERR_EventNameTooLong = 32204 ' Deprecated in favor of ERR_TooLongMetadataName
'ERR_WithEventsNameTooLong = 32205 ' Deprecated in favor of ERR_TooLongMetadataName
ERR_SxSIndirectRefHigherThanDirectRef3 = 32207
ERR_DuplicateReference2 = 32208
'ERR_SxSLowerVerIndirectRefNotEmitted4 = 32209 not used in Roslyn
ERR_DuplicateReferenceStrong = 32210
ERR_IllegalCallOrIndex = 32303
ERR_ConflictDefaultPropertyAttribute = 32304
'ERR_ClassCannotCreated = 32400
ERR_BadAttributeUuid2 = 32500
ERR_ComClassAndReservedAttribute1 = 32501
ERR_ComClassRequiresPublicClass2 = 32504
ERR_ComClassReservedDispIdZero1 = 32505
ERR_ComClassReservedDispId1 = 32506
ERR_ComClassDuplicateGuids1 = 32507
ERR_ComClassCantBeAbstract0 = 32508
ERR_ComClassRequiresPublicClass1 = 32509
'ERR_DefaultCharSetAttributeNotSupported = 32510
ERR_UnknownOperator = 33000
ERR_DuplicateConversionCategoryUsed = 33001
ERR_OperatorNotOverloadable = 33002
ERR_InvalidHandles = 33003
ERR_InvalidImplements = 33004
ERR_EndOperatorExpected = 33005
ERR_EndOperatorNotAtLineStart = 33006
ERR_InvalidEndOperator = 33007
ERR_ExitOperatorNotValid = 33008
ERR_ParamArrayIllegal1 = 33009
ERR_OptionalIllegal1 = 33010
ERR_OperatorMustBePublic = 33011
ERR_OperatorMustBeShared = 33012
ERR_BadOperatorFlags1 = 33013
ERR_OneParameterRequired1 = 33014
ERR_TwoParametersRequired1 = 33015
ERR_OneOrTwoParametersRequired1 = 33016
ERR_ConvMustBeWideningOrNarrowing = 33017
ERR_OperatorDeclaredInModule = 33018
ERR_InvalidSpecifierOnNonConversion1 = 33019
ERR_UnaryParamMustBeContainingType1 = 33020
ERR_BinaryParamMustBeContainingType1 = 33021
ERR_ConvParamMustBeContainingType1 = 33022
ERR_OperatorRequiresBoolReturnType1 = 33023
ERR_ConversionToSameType = 33024
ERR_ConversionToInterfaceType = 33025
ERR_ConversionToBaseType = 33026
ERR_ConversionToDerivedType = 33027
ERR_ConversionToObject = 33028
ERR_ConversionFromInterfaceType = 33029
ERR_ConversionFromBaseType = 33030
ERR_ConversionFromDerivedType = 33031
ERR_ConversionFromObject = 33032
ERR_MatchingOperatorExpected2 = 33033
ERR_UnacceptableLogicalOperator3 = 33034
ERR_ConditionOperatorRequired3 = 33035
ERR_CopyBackTypeMismatch3 = 33037
ERR_ForLoopOperatorRequired2 = 33038
ERR_UnacceptableForLoopOperator2 = 33039
ERR_UnacceptableForLoopRelOperator2 = 33040
ERR_OperatorRequiresIntegerParameter1 = 33041
ERR_CantSpecifyNullableOnBoth = 33100
ERR_BadTypeArgForStructConstraintNull = 33101
ERR_CantSpecifyArrayAndNullableOnBoth = 33102
ERR_CantSpecifyTypeCharacterOnIIF = 33103
ERR_IllegalOperandInIIFCount = 33104
ERR_IllegalOperandInIIFName = 33105
ERR_IllegalOperandInIIFConversion = 33106
ERR_IllegalCondTypeInIIF = 33107
ERR_CantCallIIF = 33108
ERR_CantSpecifyAsNewAndNullable = 33109
ERR_IllegalOperandInIIFConversion2 = 33110
ERR_BadNullTypeInCCExpression = 33111
ERR_NullableImplicit = 33112
'// NOTE: If you add any new errors that may be attached to a symbol during meta-import when it is marked as bad,
'// particularly if it applies to method symbols, please appropriately modify Bindable::ResolveOverloadingShouldSkipBadMember.
'// Failure to do so may break customer code.
'// AVAILABLE 33113 - 34999
ERR_MissingRuntimeHelper = 35000
'ERR_NoStdModuleAttribute = 35001 ' Note: we're now reporting a use site error in this case.
'ERR_NoOptionTextAttribute = 35002
ERR_DuplicateResourceFileName1 = 35003
ERR_ExpectedDotAfterGlobalNameSpace = 36000
ERR_NoGlobalExpectedIdentifier = 36001
ERR_NoGlobalInHandles = 36002
ERR_ElseIfNoMatchingIf = 36005
ERR_BadAttributeConstructor2 = 36006
ERR_EndUsingWithoutUsing = 36007
ERR_ExpectedEndUsing = 36008
ERR_GotoIntoUsing = 36009
ERR_UsingRequiresDisposePattern = 36010
ERR_UsingResourceVarNeedsInitializer = 36011
ERR_UsingResourceVarCantBeArray = 36012
ERR_OnErrorInUsing = 36013
ERR_PropertyNameConflictInMyCollection = 36015
ERR_InvalidImplicitVar = 36016
ERR_ObjectInitializerRequiresFieldName = 36530
ERR_ExpectedFrom = 36531
ERR_LambdaBindingMismatch1 = 36532
ERR_CannotLiftByRefParamQuery1 = 36533
ERR_ExpressionTreeNotSupported = 36534
ERR_CannotLiftStructureMeQuery = 36535
ERR_InferringNonArrayType1 = 36536
ERR_ByRefParamInExpressionTree = 36538
'ERR_ObjectInitializerBadValue = 36543
'// If you change this message, make sure to change message for QueryDuplicateAnonTypeMemberName1 as well!
ERR_DuplicateAnonTypeMemberName1 = 36547
ERR_BadAnonymousTypeForExprTree = 36548
ERR_CannotLiftAnonymousType1 = 36549
ERR_ExtensionOnlyAllowedOnModuleSubOrFunction = 36550
ERR_ExtensionMethodNotInModule = 36551
ERR_ExtensionMethodNoParams = 36552
ERR_ExtensionMethodOptionalFirstArg = 36553
ERR_ExtensionMethodParamArrayFirstArg = 36554
'// If you change this message, make sure to change message for QueryAnonymousTypeFieldNameInference as well!
'ERR_BadOrCircularInitializerReference = 36555
ERR_AnonymousTypeFieldNameInference = 36556
ERR_NameNotMemberOfAnonymousType2 = 36557
ERR_ExtensionAttributeInvalid = 36558
ERR_AnonymousTypePropertyOutOfOrder1 = 36559
'// If you change this message, make sure to change message for QueryAnonymousTypeDisallowsTypeChar as well!
ERR_AnonymousTypeDisallowsTypeChar = 36560
ERR_ExtensionMethodUncallable1 = 36561
ERR_ExtensionMethodOverloadCandidate3 = 36562
ERR_DelegateBindingMismatch = 36563
ERR_DelegateBindingTypeInferenceFails = 36564
ERR_TooManyArgs = 36565
ERR_NamedArgAlsoOmitted1 = 36566
ERR_NamedArgUsedTwice1 = 36567
ERR_NamedParamNotFound1 = 36568
ERR_OmittedArgument1 = 36569
ERR_UnboundTypeParam1 = 36572
ERR_ExtensionMethodOverloadCandidate2 = 36573
ERR_AnonymousTypeNeedField = 36574
ERR_AnonymousTypeNameWithoutPeriod = 36575
ERR_AnonymousTypeExpectedIdentifier = 36576
'ERR_NoAnonymousTypeInitializersInDebugger = 36577
'ERR_TooFewGenericArguments = 36578
'ERR_TooManyGenericArguments = 36579
'ERR_DelegateBindingMismatch3_3 = 36580 unused in Roslyn
'ERR_DelegateBindingTypeInferenceFails3 = 36581
ERR_TooManyArgs2 = 36582
ERR_NamedArgAlsoOmitted3 = 36583
ERR_NamedArgUsedTwice3 = 36584
ERR_NamedParamNotFound3 = 36585
ERR_OmittedArgument3 = 36586
ERR_UnboundTypeParam3 = 36589
ERR_TooFewGenericArguments2 = 36590
ERR_TooManyGenericArguments2 = 36591
ERR_ExpectedInOrEq = 36592
ERR_ExpectedQueryableSource = 36593
ERR_QueryOperatorNotFound = 36594
ERR_CannotUseOnErrorGotoWithClosure = 36595
ERR_CannotGotoNonScopeBlocksWithClosure = 36597
ERR_CannotLiftRestrictedTypeQuery = 36598
ERR_QueryAnonymousTypeFieldNameInference = 36599
ERR_QueryDuplicateAnonTypeMemberName1 = 36600
ERR_QueryAnonymousTypeDisallowsTypeChar = 36601
ERR_ReadOnlyInClosure = 36602
ERR_ExprTreeNoMultiDimArrayCreation = 36603
ERR_ExprTreeNoLateBind = 36604
ERR_ExpectedBy = 36605
ERR_QueryInvalidControlVariableName1 = 36606
ERR_ExpectedIn = 36607
'ERR_QueryStartsWithLet = 36608
'ERR_NoQueryExpressionsInDebugger = 36609
ERR_QueryNameNotDeclared = 36610
'// Available 36611
ERR_NestedFunctionArgumentNarrowing3 = 36612
'// If you change this message, make sure to change message for QueryAnonTypeFieldXMLNameInference as well!
ERR_AnonTypeFieldXMLNameInference = 36613
ERR_QueryAnonTypeFieldXMLNameInference = 36614
ERR_ExpectedInto = 36615
'ERR_AggregateStartsWithLet = 36616
ERR_TypeCharOnAggregation = 36617
ERR_ExpectedOn = 36618
ERR_ExpectedEquals = 36619
ERR_ExpectedAnd = 36620
ERR_EqualsTypeMismatch = 36621
ERR_EqualsOperandIsBad = 36622
'// see 30581 (lambda version of addressof)
ERR_LambdaNotDelegate1 = 36625
'// see 30939 (lambda version of addressof)
ERR_LambdaNotCreatableDelegate1 = 36626
'ERR_NoLambdaExpressionsInDebugger = 36627
ERR_CannotInferNullableForVariable1 = 36628
ERR_NullableTypeInferenceNotSupported = 36629
ERR_ExpectedJoin = 36631
ERR_NullableParameterMustSpecifyType = 36632
ERR_IterationVariableShadowLocal2 = 36633
ERR_LambdasCannotHaveAttributes = 36634
ERR_LambdaInSelectCaseExpr = 36635
ERR_AddressOfInSelectCaseExpr = 36636
ERR_NullableCharNotSupported = 36637
'// The follow error messages are paired with other query specific messages above. Please
'// make sure to keep the two in sync
ERR_CannotLiftStructureMeLambda = 36638
ERR_CannotLiftByRefParamLambda1 = 36639
ERR_CannotLiftRestrictedTypeLambda = 36640
ERR_LambdaParamShadowLocal1 = 36641
ERR_StrictDisallowImplicitObjectLambda = 36642
ERR_CantSpecifyParamsOnLambdaParamNoType = 36643
ERR_TypeInferenceFailure1 = 36644
ERR_TypeInferenceFailure2 = 36645
ERR_TypeInferenceFailure3 = 36646
ERR_TypeInferenceFailureNoExplicit1 = 36647
ERR_TypeInferenceFailureNoExplicit2 = 36648
ERR_TypeInferenceFailureNoExplicit3 = 36649
ERR_TypeInferenceFailureAmbiguous1 = 36650
ERR_TypeInferenceFailureAmbiguous2 = 36651
ERR_TypeInferenceFailureAmbiguous3 = 36652
ERR_TypeInferenceFailureNoExplicitAmbiguous1 = 36653
ERR_TypeInferenceFailureNoExplicitAmbiguous2 = 36654
ERR_TypeInferenceFailureNoExplicitAmbiguous3 = 36655
ERR_TypeInferenceFailureNoBest1 = 36656
ERR_TypeInferenceFailureNoBest2 = 36657
ERR_TypeInferenceFailureNoBest3 = 36658
ERR_TypeInferenceFailureNoExplicitNoBest1 = 36659
ERR_TypeInferenceFailureNoExplicitNoBest2 = 36660
ERR_TypeInferenceFailureNoExplicitNoBest3 = 36661
ERR_DelegateBindingMismatchStrictOff2 = 36663
'ERR_TooDeepNestingOfParensInLambdaParam = 36664 - No Longer Reported. Removed per 926942
' ERR_InaccessibleReturnTypeOfSymbol1 = 36665
ERR_InaccessibleReturnTypeOfMember2 = 36666
ERR_LocalNamedSameAsParamInLambda1 = 36667
ERR_MultilineLambdasCannotContainOnError = 36668
'ERR_BranchOutOfMultilineLambda = 36669 obsolete - was not even reported in Dev10 any more.
ERR_LambdaBindingMismatch2 = 36670
ERR_MultilineLambdaShadowLocal1 = 36671
ERR_StaticInLambda = 36672
ERR_MultilineLambdaMissingSub = 36673
ERR_MultilineLambdaMissingFunction = 36674
ERR_StatementLambdaInExpressionTree = 36675
' //ERR_StrictDisallowsImplicitLambda = 36676
' // replaced by LambdaNoType and LambdaNoTypeObjectDisallowed and LambdaTooManyTypesObjectDisallowed
ERR_AttributeOnLambdaReturnType = 36677
ERR_ExpectedIdentifierOrGroup = 36707
ERR_UnexpectedGroup = 36708
ERR_DelegateBindingMismatchStrictOff3 = 36709
ERR_DelegateBindingIncompatible3 = 36710
ERR_ArgumentNarrowing2 = 36711
ERR_OverloadCandidate1 = 36712
ERR_AutoPropertyInitializedInStructure = 36713
ERR_InitializedExpandedProperty = 36714
ERR_NewExpandedProperty = 36715
ERR_LanguageVersion = 36716
ERR_ArrayInitNoType = 36717
ERR_NotACollection1 = 36718
ERR_NoAddMethod1 = 36719
ERR_CantCombineInitializers = 36720
ERR_EmptyAggregateInitializer = 36721
ERR_VarianceDisallowedHere = 36722
ERR_VarianceInterfaceNesting = 36723
ERR_VarianceOutParamDisallowed1 = 36724
ERR_VarianceInParamDisallowed1 = 36725
ERR_VarianceOutParamDisallowedForGeneric3 = 36726
ERR_VarianceInParamDisallowedForGeneric3 = 36727
ERR_VarianceOutParamDisallowedHere2 = 36728
ERR_VarianceInParamDisallowedHere2 = 36729
ERR_VarianceOutParamDisallowedHereForGeneric4 = 36730
ERR_VarianceInParamDisallowedHereForGeneric4 = 36731
ERR_VarianceTypeDisallowed2 = 36732
ERR_VarianceTypeDisallowedForGeneric4 = 36733
ERR_LambdaTooManyTypesObjectDisallowed = 36734
ERR_VarianceTypeDisallowedHere3 = 36735
ERR_VarianceTypeDisallowedHereForGeneric5 = 36736
ERR_AmbiguousCastConversion2 = 36737
ERR_VariancePreventsSynthesizedEvents2 = 36738
ERR_NestingViolatesCLS1 = 36739
ERR_VarianceOutNullableDisallowed2 = 36740
ERR_VarianceInNullableDisallowed2 = 36741
ERR_VarianceOutByValDisallowed1 = 36742
ERR_VarianceInReturnDisallowed1 = 36743
ERR_VarianceOutConstraintDisallowed1 = 36744
ERR_VarianceInReadOnlyPropertyDisallowed1 = 36745
ERR_VarianceOutWriteOnlyPropertyDisallowed1 = 36746
ERR_VarianceOutPropertyDisallowed1 = 36747
ERR_VarianceInPropertyDisallowed1 = 36748
ERR_VarianceOutByRefDisallowed1 = 36749
ERR_VarianceInByRefDisallowed1 = 36750
ERR_LambdaNoType = 36751
' //ERR_NoReturnStatementsForMultilineLambda = 36752
' // replaced by LambdaNoType and LambdaNoTypeObjectDisallowed
'ERR_CollectionInitializerArity2 = 36753
ERR_VarianceConversionFailedOut6 = 36754
ERR_VarianceConversionFailedIn6 = 36755
ERR_VarianceIEnumerableSuggestion3 = 36756
ERR_VarianceConversionFailedTryOut4 = 36757
ERR_VarianceConversionFailedTryIn4 = 36758
ERR_AutoPropertyCantHaveParams = 36759
ERR_IdentityDirectCastForFloat = 36760
ERR_TypeDisallowsElements = 36807
ERR_TypeDisallowsAttributes = 36808
ERR_TypeDisallowsDescendants = 36809
'ERR_XmlSchemaCompileError = 36810
ERR_TypeOrMemberNotGeneric2 = 36907
ERR_ExtensionMethodCannotBeLateBound = 36908
ERR_TypeInferenceArrayRankMismatch1 = 36909
ERR_QueryStrictDisallowImplicitObject = 36910
ERR_IfNoType = 36911
ERR_IfNoTypeObjectDisallowed = 36912
ERR_IfTooManyTypesObjectDisallowed = 36913
ERR_ArrayInitNoTypeObjectDisallowed = 36914
ERR_ArrayInitTooManyTypesObjectDisallowed = 36915
ERR_LambdaNoTypeObjectDisallowed = 36916
ERR_OverloadsModifierInModule = 36917
ERR_SubRequiresSingleStatement = 36918
ERR_SubDisallowsStatement = 36919
ERR_SubRequiresParenthesesLParen = 36920
ERR_SubRequiresParenthesesDot = 36921
ERR_SubRequiresParenthesesBang = 36922
ERR_CannotEmbedInterfaceWithGeneric = 36923
ERR_CannotUseGenericTypeAcrossAssemblyBoundaries = 36924
ERR_CannotUseGenericBaseTypeAcrossAssemblyBoundaries = 36925
ERR_BadAsyncByRefParam = 36926
ERR_BadIteratorByRefParam = 36927
ERR_BadAsyncExpressionLambda = 36928
ERR_BadAsyncInQuery = 36929
ERR_BadGetAwaiterMethod1 = 36930
'ERR_ExpressionTreeContainsAwait = 36931
ERR_RestrictedResumableType1 = 36932
ERR_BadAwaitNothing = 36933
ERR_AsyncSubMain = 36934
ERR_PartialMethodsMustNotBeAsync1 = 36935
ERR_InvalidAsyncIteratorModifiers = 36936
ERR_BadAwaitNotInAsyncMethodOrLambda = 36937
ERR_BadIteratorReturn = 36938
ERR_BadYieldInTryHandler = 36939
ERR_BadYieldInNonIteratorMethod = 36940
'// unused 36941
ERR_BadReturnValueInIterator = 36942
ERR_BadAwaitInTryHandler = 36943
ERR_BadAwaitObject = 36944
ERR_BadAsyncReturn = 36945
ERR_BadResumableAccessReturnVariable = 36946
ERR_BadIteratorExpressionLambda = 36947
'ERR_AwaitLibraryMissing = 36948
'ERR_AwaitPattern1 = 36949
ERR_ConstructorAsync = 36950
ERR_InvalidLambdaModifier = 36951
ERR_ReturnFromNonGenericTaskAsync = 36952
ERR_BadAutoPropertyFlags1 = 36953
ERR_BadOverloadCandidates2 = 36954
ERR_BadStaticInitializerInResumable = 36955
ERR_ResumablesCannotContainOnError = 36956
ERR_FriendRefNotEqualToThis = 36957
ERR_FriendRefSigningMismatch = 36958
ERR_FailureSigningAssembly = 36960
ERR_SignButNoPrivateKey = 36961
ERR_InvalidVersionFormat = 36962
ERR_ExpectedSingleScript = 36963
ERR_ReferenceDirectiveOnlyAllowedInScripts = 36964
ERR_NamespaceNotAllowedInScript = 36965
ERR_KeywordNotAllowedInScript = 36966
ERR_ReservedAssemblyName = 36968
ERR_ConstructorCannotBeDeclaredPartial = 36969
ERR_ModuleEmitFailure = 36970
ERR_ParameterNotValidForType = 36971
ERR_MarshalUnmanagedTypeNotValidForFields = 36972
ERR_MarshalUnmanagedTypeOnlyValidForFields = 36973
ERR_AttributeParameterRequired1 = 36974
ERR_AttributeParameterRequired2 = 36975
ERR_InvalidVersionFormat2 = 36976
ERR_InvalidAssemblyCultureForExe = 36977
ERR_InvalidMultipleAttributeUsageInNetModule2 = 36978
ERR_SecurityAttributeInvalidTarget = 36979
ERR_PublicKeyFileFailure = 36980
ERR_PublicKeyContainerFailure = 36981
ERR_InvalidAssemblyCulture = 36982
ERR_EncUpdateFailedMissingAttribute = 36983
ERR_CantAwaitAsyncSub1 = 37001
ERR_ResumableLambdaInExpressionTree = 37050
ERR_DllImportOnResumableMethod = 37051
ERR_CannotLiftRestrictedTypeResumable1 = 37052
ERR_BadIsCompletedOnCompletedGetResult2 = 37053
ERR_SynchronizedAsyncMethod = 37054
ERR_BadAsyncReturnOperand1 = 37055
ERR_DoesntImplementAwaitInterface2 = 37056
ERR_BadAwaitInNonAsyncMethod = 37057
ERR_BadAwaitInNonAsyncVoidMethod = 37058
ERR_BadAwaitInNonAsyncLambda = 37059
ERR_LoopControlMustNotAwait = 37060
ERR_MyGroupCollectionAttributeCycle = 37201
ERR_LiteralExpected = 37202
ERR_PartialMethodDefaultParameterValueMismatch2 = 37203
ERR_PartialMethodParamArrayMismatch2 = 37204
ERR_NetModuleNameMismatch = 37205
ERR_BadCompilationOption = 37206
ERR_CmdOptionConflictsSource = 37207
' unused 37208
ERR_InvalidSignaturePublicKey = 37209
ERR_CollisionWithPublicTypeInModule = 37210
ERR_ExportedTypeConflictsWithDeclaration = 37211
ERR_ExportedTypesConflict = 37212
ERR_AgnosticToMachineModule = 37213
ERR_ConflictingMachineModule = 37214
ERR_CryptoHashFailed = 37215
ERR_CantHaveWin32ResAndManifest = 37216
ERR_ForwardedTypeConflictsWithDeclaration = 37217
ERR_ForwardedTypeConflictsWithExportedType = 37218
ERR_ForwardedTypesConflict = 37219
ERR_TooLongMetadataName = 37220
ERR_MissingNetModuleReference = 37221
ERR_UnsupportedModule1 = 37222
ERR_UnsupportedEvent1 = 37223
ERR_NetModuleNameMustBeUnique = 37224
ERR_PDBWritingFailed = 37225
ERR_ParamDefaultValueDiffersFromAttribute = 37226
ERR_ResourceInModule = 37227
ERR_FieldHasMultipleDistinctConstantValues = 37228
ERR_AmbiguousInNamespaces2 = 37229
ERR_EncNoPIAReference = 37230
ERR_LinkedNetmoduleMetadataMustProvideFullPEImage = 37231
ERR_CantReadRulesetFile = 37232
ERR_MetadataReferencesNotSupported = 37233
ERR_PlatformDoesntSupport = 37234
ERR_CantUseRequiredAttribute = 37235
ERR_EncodinglessSyntaxTree = 37236
ERR_InvalidFormatSpecifier = 37237
ERR_CannotBeMadeNullable1 = 37238
ERR_BadConditionalWithRef = 37239
ERR_NullPropagatingOpInExpressionTree = 37240
ERR_TooLongOrComplexExpression = 37241
ERR_BadPdbData = 37242
ERR_AutoPropertyCantBeWriteOnly = 37243
ERR_ExpressionDoesntHaveName = 37244
ERR_InvalidNameOfSubExpression = 37245
ERR_MethodTypeArgsUnexpected = 37246
ERR_InReferencedAssembly = 37247
ERR_EncReferenceToAddedMember = 37248
ERR_InterpolationFormatWhitespace = 37249
ERR_InterpolationAlignmentOutOfRange = 37250
ERR_InterpolatedStringFactoryError = 37251
ERR_DebugEntryPointNotSourceMethodDefinition = 37252
ERR_InvalidPathMap = 37253
ERR_PublicSignNoKey = 37254
ERR_TooManyUserStrings = 37255
ERR_PeWritingFailure = 37256
ERR_OptionMustBeAbsolutePath = 37257
ERR_LastPlusOne
'// WARNINGS BEGIN HERE
WRN_UseOfObsoleteSymbol2 = 40000
WRN_MustOverloadBase4 = 40003
WRN_OverrideType5 = 40004
WRN_MustOverride2 = 40005
WRN_DefaultnessShadowed4 = 40007
WRN_UseOfObsoleteSymbolNoMessage1 = 40008
WRN_AssemblyGeneration0 = 40009
WRN_AssemblyGeneration1 = 40010
WRN_ComClassNoMembers1 = 40011
WRN_SynthMemberShadowsMember5 = 40012
WRN_MemberShadowsSynthMember6 = 40014
WRN_SynthMemberShadowsSynthMember7 = 40018
WRN_UseOfObsoletePropertyAccessor3 = 40019
WRN_UseOfObsoletePropertyAccessor2 = 40020
' WRN_MemberShadowsMemberInModule5 = 40021 ' no repro in legacy test, most probably not reachable. Unused in Roslyn.
' WRN_SynthMemberShadowsMemberInModule5 = 40022 ' no repro in legacy test, most probably not reachable. Unused in Roslyn.
' WRN_MemberShadowsSynthMemberInModule6 = 40023 ' no repro in legacy test, most probably not reachable. Unused in Roslyn.
' WRN_SynthMemberShadowsSynthMemberMod7 = 40024 ' no repro in legacy test, most probably not reachable. Unused in Roslyn.
WRN_FieldNotCLSCompliant1 = 40025
WRN_BaseClassNotCLSCompliant2 = 40026
WRN_ProcTypeNotCLSCompliant1 = 40027
WRN_ParamNotCLSCompliant1 = 40028
WRN_InheritedInterfaceNotCLSCompliant2 = 40029
WRN_CLSMemberInNonCLSType3 = 40030
WRN_NameNotCLSCompliant1 = 40031
WRN_EnumUnderlyingTypeNotCLS1 = 40032
WRN_NonCLSMemberInCLSInterface1 = 40033
WRN_NonCLSMustOverrideInCLSType1 = 40034
WRN_ArrayOverloadsNonCLS2 = 40035
WRN_RootNamespaceNotCLSCompliant1 = 40038
WRN_RootNamespaceNotCLSCompliant2 = 40039
WRN_GenericConstraintNotCLSCompliant1 = 40040
WRN_TypeNotCLSCompliant1 = 40041
WRN_OptionalValueNotCLSCompliant1 = 40042
WRN_CLSAttrInvalidOnGetSet = 40043
WRN_TypeConflictButMerged6 = 40046
' WRN_TypeConflictButMerged7 = 40047 ' deprecated
WRN_ShadowingGenericParamWithParam1 = 40048
WRN_CannotFindStandardLibrary1 = 40049
WRN_EventDelegateTypeNotCLSCompliant2 = 40050
WRN_DebuggerHiddenIgnoredOnProperties = 40051
WRN_SelectCaseInvalidRange = 40052
WRN_CLSEventMethodInNonCLSType3 = 40053
WRN_ExpectedInitComponentCall2 = 40054
WRN_NamespaceCaseMismatch3 = 40055
WRN_UndefinedOrEmptyNamespaceOrClass1 = 40056
WRN_UndefinedOrEmptyProjectNamespaceOrClass1 = 40057
'WRN_InterfacesWithNoPIAMustHaveGuid1 = 40058 ' Not reported by Dev11.
WRN_IndirectRefToLinkedAssembly2 = 40059
WRN_DelaySignButNoKey = 40060
WRN_UnimplementedCommandLineSwitch = 40998
' WRN_DuplicateAssemblyAttribute1 = 41000 'unused in Roslyn
WRN_NoNonObsoleteConstructorOnBase3 = 41001
WRN_NoNonObsoleteConstructorOnBase4 = 41002
WRN_RequiredNonObsoleteNewCall3 = 41003
WRN_RequiredNonObsoleteNewCall4 = 41004
WRN_MissingAsClauseinOperator = 41005
WRN_ConstraintsFailedForInferredArgs2 = 41006
WRN_ConditionalNotValidOnFunction = 41007
WRN_UseSwitchInsteadOfAttribute = 41008
'// AVAILABLE 41009 - 41199
WRN_ReferencedAssemblyDoesNotHaveStrongName = 41997
WRN_RecursiveAddHandlerCall = 41998
WRN_ImplicitConversionCopyBack = 41999
WRN_MustShadowOnMultipleInheritance2 = 42000
' WRN_ObsoleteClassInitialize = 42001 ' deprecated
' WRN_ObsoleteClassTerminate = 42002 ' deprecated
WRN_RecursiveOperatorCall = 42004
' WRN_IndirectlyImplementedBaseMember5 = 42014 ' deprecated
' WRN_ImplementedBaseMember4 = 42015 ' deprecated
WRN_ImplicitConversionSubst1 = 42016 '// populated by 42350/42332/42336/42337/42338/42339/42340
WRN_LateBindingResolution = 42017
WRN_ObjectMath1 = 42018
WRN_ObjectMath2 = 42019
WRN_ObjectAssumedVar1 = 42020 ' // populated by 42111/42346
WRN_ObjectAssumed1 = 42021 ' // populated by 42347/41005/42341/42342/42344/42345/42334/42343
WRN_ObjectAssumedProperty1 = 42022 ' // populated by 42348
'// AVAILABLE 42023
WRN_UnusedLocal = 42024
WRN_SharedMemberThroughInstance = 42025
WRN_RecursivePropertyCall = 42026
WRN_OverlappingCatch = 42029
WRN_DefAsgUseNullRefByRef = 42030
WRN_DuplicateCatch = 42031
WRN_ObjectMath1Not = 42032
WRN_BadChecksumValExtChecksum = 42033
WRN_MultipleDeclFileExtChecksum = 42034
WRN_BadGUIDFormatExtChecksum = 42035
WRN_ObjectMathSelectCase = 42036
WRN_EqualToLiteralNothing = 42037
WRN_NotEqualToLiteralNothing = 42038
'// AVAILABLE 42039 - 42098
WRN_UnusedLocalConst = 42099
'// UNAVAILABLE 42100
WRN_ComClassInterfaceShadows5 = 42101
WRN_ComClassPropertySetObject1 = 42102
'// only reference types are considered for definite assignment.
'// DefAsg's are all under VB_advanced
WRN_DefAsgUseNullRef = 42104
WRN_DefAsgNoRetValFuncRef1 = 42105
WRN_DefAsgNoRetValOpRef1 = 42106
WRN_DefAsgNoRetValPropRef1 = 42107
WRN_DefAsgUseNullRefByRefStr = 42108
WRN_DefAsgUseNullRefStr = 42109
' WRN_FieldInForNotExplicit = 42110 'unused in Roslyn
WRN_StaticLocalNoInference = 42111
'// AVAILABLE 42112 - 42202
' WRN_SxSHigherIndirectRefEmitted4 = 42203 'unused in Roslyn
' WRN_ReferencedAssembliesAmbiguous6 = 42204 'unused in Roslyn
' WRN_ReferencedAssembliesAmbiguous4 = 42205 'unused in Roslyn
' WRN_MaximumNumberOfWarnings = 42206 'unused in Roslyn
WRN_InvalidAssemblyName = 42207
'// AVAILABLE 42209 - 42299
WRN_XMLDocBadXMLLine = 42300
WRN_XMLDocMoreThanOneCommentBlock = 42301
WRN_XMLDocNotFirstOnLine = 42302
WRN_XMLDocInsideMethod = 42303
WRN_XMLDocParseError1 = 42304
WRN_XMLDocDuplicateXMLNode1 = 42305
WRN_XMLDocIllegalTagOnElement2 = 42306
WRN_XMLDocBadParamTag2 = 42307
WRN_XMLDocParamTagWithoutName = 42308
WRN_XMLDocCrefAttributeNotFound1 = 42309
WRN_XMLMissingFileOrPathAttribute1 = 42310
WRN_XMLCannotWriteToXMLDocFile2 = 42311
WRN_XMLDocWithoutLanguageElement = 42312
WRN_XMLDocReturnsOnWriteOnlyProperty = 42313
WRN_XMLDocOnAPartialType = 42314
WRN_XMLDocReturnsOnADeclareSub = 42315
WRN_XMLDocStartTagWithNoEndTag = 42316
WRN_XMLDocBadGenericParamTag2 = 42317
WRN_XMLDocGenericParamTagWithoutName = 42318
WRN_XMLDocExceptionTagWithoutCRef = 42319
WRN_XMLDocInvalidXMLFragment = 42320
WRN_XMLDocBadFormedXML = 42321
WRN_InterfaceConversion2 = 42322
WRN_LiftControlVariableLambda = 42324
' 42325 unused, was abandoned, now used in unit test "EnsureLegacyWarningsAreMaintained". Please update test if you are going to use this number.
WRN_LambdaPassedToRemoveHandler = 42326
WRN_LiftControlVariableQuery = 42327
WRN_RelDelegatePassedToRemoveHandler = 42328
' WRN_QueryMissingAsClauseinVarDecl = 42329 ' unused in Roslyn.
' WRN_LiftUsingVariableInLambda1 = 42330 ' unused in Roslyn.
' WRN_LiftUsingVariableInQuery1 = 42331 ' unused in Roslyn.
WRN_AmbiguousCastConversion2 = 42332 '// substitutes into 42016
WRN_VarianceDeclarationAmbiguous3 = 42333
WRN_ArrayInitNoTypeObjectAssumed = 42334
WRN_TypeInferenceAssumed3 = 42335
WRN_VarianceConversionFailedOut6 = 42336 '// substitutes into 42016
WRN_VarianceConversionFailedIn6 = 42337 '// substitutes into 42016
WRN_VarianceIEnumerableSuggestion3 = 42338 '// substitutes into 42016
WRN_VarianceConversionFailedTryOut4 = 42339 '// substitutes into 42016
WRN_VarianceConversionFailedTryIn4 = 42340 '// substitutes into 42016
WRN_IfNoTypeObjectAssumed = 42341
WRN_IfTooManyTypesObjectAssumed = 42342
WRN_ArrayInitTooManyTypesObjectAssumed = 42343
WRN_LambdaNoTypeObjectAssumed = 42344
WRN_LambdaTooManyTypesObjectAssumed = 42345
WRN_MissingAsClauseinVarDecl = 42346
WRN_MissingAsClauseinFunction = 42347
WRN_MissingAsClauseinProperty = 42348
WRN_ObsoleteIdentityDirectCastForValueType = 42349
WRN_ImplicitConversion2 = 42350 ' // substitutes into 42016
WRN_MutableStructureInUsing = 42351
WRN_MutableGenericStructureInUsing = 42352
WRN_DefAsgNoRetValFuncVal1 = 42353
WRN_DefAsgNoRetValOpVal1 = 42354
WRN_DefAsgNoRetValPropVal1 = 42355
WRN_AsyncLacksAwaits = 42356
WRN_AsyncSubCouldBeFunction = 42357
WRN_UnobservedAwaitableExpression = 42358
WRN_UnobservedAwaitableDelegate = 42359
WRN_PrefixAndXmlnsLocalName = 42360
WRN_UseValueForXmlExpression3 = 42361 ' Replaces ERR_UseValueForXmlExpression3
'WRN_PDBConstantStringValueTooLong = 42363 we gave up on this warning. See comments in commonCompilation.Emit()
WRN_ReturnTypeAttributeOnWriteOnlyProperty = 42364
' // AVAILABLE 42365
WRN_InvalidVersionFormat = 42366
WRN_MainIgnored = 42367
WRN_EmptyPrefixAndXmlnsLocalName = 42368
WRN_DefAsgNoRetValWinRtEventVal1 = 42369
WRN_AssemblyAttributeFromModuleIsOverridden = 42370
WRN_RefCultureMismatch = 42371
WRN_ConflictingMachineAssembly = 42372
WRN_PdbLocalNameTooLong = 42373
WRN_PdbUsingNameTooLong = 42374
WRN_XMLDocCrefToTypeParameter = 42375
WRN_AnalyzerCannotBeCreated = 42376
WRN_NoAnalyzerInAssembly = 42377
WRN_UnableToLoadAnalyzer = 42378
' // AVAILABLE 42379 - 49998
ERRWRN_Last = WRN_UnableToLoadAnalyzer + 1
'// HIDDENS AND INFOS BEGIN HERE
HDN_UnusedImportClause = 50000
HDN_UnusedImportStatement = 50001
INF_UnableToLoadSomeTypesInAnalyzer = 50002
' // AVAILABLE 50003 - 54999
' Adding diagnostic arguments from resx file
IDS_ProjectSettingsLocationName = 56000
IDS_FunctionReturnType = 56001
IDS_TheSystemCannotFindThePathSpecified = 56002
IDS_UnrecognizedFileFormat = 56003
IDS_MSG_ADDMODULE = 56004
IDS_MSG_ADDLINKREFERENCE = 56005
IDS_MSG_ADDREFERENCE = 56006
IDS_LogoLine1 = 56007
IDS_LogoLine2 = 56008
IDS_VBCHelp = 56009
IDS_InvalidPreprocessorConstantType = 56010
IDS_ToolName = 56011
' Feature codes
FEATURE_AutoProperties
FEATURE_LineContinuation
FEATURE_StatementLambdas
FEATURE_CoContraVariance
FEATURE_CollectionInitializers
FEATURE_SubLambdas
FEATURE_ArrayLiterals
FEATURE_AsyncExpressions
FEATURE_Iterators
FEATURE_GlobalNamespace
FEATURE_NullPropagatingOperator
FEATURE_NameOfExpressions
FEATURE_ReadonlyAutoProperties
FEATURE_RegionsEverywhere
FEATURE_MultilineStringLiterals
FEATURE_CObjInAttributeArguments
FEATURE_LineContinuationComments
FEATURE_TypeOfIsNot
FEATURE_YearFirstDateLiterals
FEATURE_WarningDirectives
FEATURE_PartialModules
FEATURE_PartialInterfaces
FEATURE_ImplementingReadonlyOrWriteonlyPropertyWithReadwrite
FEATURE_IOperation
End Enum
End Namespace
|
sharadagrawal/Roslyn
|
src/Compilers/VisualBasic/Portable/Errors/Errors.vb
|
Visual Basic
|
apache-2.0
| 87,973
|
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System.Threading.Tasks
Imports Microsoft.CodeAnalysis.CodeFixes
Imports Microsoft.CodeAnalysis.CSharp.CodeFixes.AddImport
Imports Microsoft.CodeAnalysis.Diagnostics
Imports Microsoft.CodeAnalysis.VisualBasic.CodeFixes.AddImport
Namespace Microsoft.CodeAnalysis.Editor.UnitTests.Diagnostics.AddImport
Public Class AddImportCrossLanguageTests
Inherits AbstractCrossLanguageUserDiagnosticTest
Friend Overrides Function CreateDiagnosticProviderAndFixer(workspace As Workspace, language As String) As Tuple(Of DiagnosticAnalyzer, CodeFixProvider)
Dim fixer As CodeFixProvider
If language = LanguageNames.CSharp Then
fixer = New CSharpAddImportCodeFixProvider()
Else
fixer = New VisualBasicAddImportCodeFixProvider()
End If
Return Tuple.Create(Of DiagnosticAnalyzer, CodeFixProvider)(Nothing, fixer)
End Function
<WpfFact, Trait(Traits.Feature, Traits.Features.CodeActionsAddImport)>
Public Async Function Test_CSharpToVisualBasic1() As Task
Dim input =
<Workspace>
<Project Language='C#' AssemblyName='CSharpAssembly1' CommonReferences='true'>
<ProjectReference>VBAssembly1</ProjectReference>
<Document FilePath="Test1.vb">
public class Class1
{
public void Foo()
{
var x = new Cl$$ass2();
}
}
</Document>
</Project>
<Project Language='Visual Basic' AssemblyName='VBAssembly1' CommonReferences='true'>
<Document FilePath='Test2.vb'>
namespace NS2
public class Class2
end class
end namespace
</Document>
</Project>
</Workspace>
Dim expected =
<text>
using NS2;
public class Class1
{
public void Foo()
{
var x = new Class2();
}
}
</text>.Value.Trim()
Await TestAsync(input, expected)
End Function
<WpfFact, Trait(Traits.Feature, Traits.Features.CodeActionsAddImport)>
Public Async Function Test_VisualBasicToCSharp1() As Task
Dim input =
<Workspace>
<Project Language='Visual Basic' AssemblyName='VBAssembly1' CommonReferences='true'>
<ProjectReference>CSAssembly1</ProjectReference>
<Document FilePath="Test1.vb">
public class Class1
public sub Foo()
dim x as new Cl$$ass2()
end sub
end class
</Document>
</Project>
<Project Language='C#' AssemblyName='CSAssembly1' CommonReferences='true'>
<Document FilePath='Test2.cs'>
namespace NS2
{
public class Class2
{
}
}
</Document>
</Project>
</Workspace>
Dim expected =
<text>
Imports NS2
Public Class Class1
Public Sub Foo()
Dim x As New Class2()
End Sub
End Class
</text>.Value.Trim()
Await TestAsync(input, expected)
End Function
<WorkItem(1083419)>
<WpfFact, Trait(Traits.Feature, Traits.Features.CodeActionsAddImport)>
Public Async Function TestExtensionMethods1() As Task
Dim input =
<Workspace>
<Project Language='Visual Basic' AssemblyName='VBAssembly1' CommonReferences='true'>
<Document FilePath="Test1.vb">
Imports System.Collections.Generic
Imports System.Runtime.CompilerServices
Namespace VBAssembly1
Public Module Module1
<Extension>
Public Function [Select](x As List(Of Integer)) As IEnumerable(Of Integer)
Return Nothing
End Function
End Module
End Namespace
</Document>
</Project>
<Project Language='C#' AssemblyName='CSAssembly1' CommonReferences='true'>
<ProjectReference>VBAssembly1</ProjectReference>
<Document FilePath='Test1.cs'>
using System.Collections.Generic;
namespace CSAssembly1
{
class Program
{
static void Main()
{
var l = new List<int>();
l.Se$$lect();
}
}
}
</Document>
</Project>
</Workspace>
Dim expected =
<text>
using System.Collections.Generic;
using VBAssembly1;
namespace CSAssembly1
{
class Program
{
static void Main()
{
var l = new List<int>();
l.Select();
}
}
}
</text>.Value.Trim()
Await TestAsync(input, expected, codeActionIndex:=1)
End Function
<WorkItem(1083419)>
<WpfFact, Trait(Traits.Feature, Traits.Features.CodeActionsAddImport)>
Public Async Function TestExtensionMethods2() As Task
Dim input =
<Workspace>
<Project Language='C#' AssemblyName='CSAssembly1' CommonReferences='true'>
<Document FilePath='Test1.cs'>
using System.Collections.Generic;
namespace CSAssembly1
{
public static class Program
{
public static IEnumerable<int> Select(this List<int> x)
{
return null;
}
}
}
</Document>
</Project>
<Project Language='Visual Basic' AssemblyName='VBAssembly1' CommonReferences='true'>
<ProjectReference>CSAssembly1</ProjectReference>
<CompilationOptions></CompilationOptions>
<Document FilePath="Test1.vb">
Imports System.Collections.Generic
Namespace VBAssembly1
Module Module1
Sub Main()
Dim l = New List(Of Integer)()
l.Se$$lect()
End Sub
End Module
End Namespace
</Document>
</Project>
</Workspace>
Dim expected =
<text>
Imports System.Collections.Generic
Imports CSAssembly1
Namespace VBAssembly1
Module Module1
Sub Main()
Dim l = New List(Of Integer)()
l.Select()
End Sub
End Module
End Namespace
</text>.Value.Trim()
Await TestAsync(input, expected, codeActionIndex:=0)
End Function
End Class
End Namespace
|
mseamari/Stuff
|
src/EditorFeatures/Test2/Diagnostics/AddImport/AddImportCrossLanguageTests.vb
|
Visual Basic
|
apache-2.0
| 7,798
|
Imports System
Imports System.Drawing
Imports System.Collections
Imports System.ComponentModel
Imports System.Windows.Forms
Imports System.Diagnostics
Imports AnimatGuiCtrls.Controls
Imports AnimatGUI
Imports AnimatGUI.Framework
Imports AnimatGUI.DataObjects
Imports System.Drawing.Imaging
Namespace Forms.BodyPlan
Public Class EditAttachments
Inherits AnimatGUI.Forms.AnimatDialog
#Region " Attributes "
Protected m_aryAttachments As Collections.Attachments
Protected m_doStructure As DataObjects.Physical.PhysicalStructure
Protected m_bIsDirty As Boolean = False
Protected m_iMaxAttachmentsAllowed As Integer = -1
#End Region
#Region " Properties "
Public Property Attachments() As Collections.Attachments
Get
Return m_aryAttachments
End Get
Set(ByVal value As Collections.Attachments)
m_aryAttachments = value
End Set
End Property
Public Property ParentStructure() As DataObjects.Physical.PhysicalStructure
Get
Return m_doStructure
End Get
Set(ByVal value As DataObjects.Physical.PhysicalStructure)
m_doStructure = value
End Set
End Property
Public Property MaxAttachmentsAllowed() As Integer
Get
Return m_iMaxAttachmentsAllowed
End Get
Set(ByVal value As Integer)
m_iMaxAttachmentsAllowed = value
End Set
End Property
#End Region
#Region " Methods "
Protected Function FindListItem(ByVal lView As ListView, ByVal strID As String, ByVal bThrowError As Boolean) As ListViewItem
For Each liItem As ListViewItem In lView.Items
If Not liItem.Tag Is Nothing AndAlso Util.IsTypeOf(liItem.Tag.GetType, GetType(AnimatGUI.Framework.DataObject), True) Then
Dim doObject As AnimatGUI.Framework.DataObject = DirectCast(liItem.Tag, AnimatGUI.Framework.DataObject)
If doObject.ID = strID Then
Return liItem
End If
End If
Next
If bThrowError Then
Throw New System.Exception("No attachment was found with the ID: " & strID)
End If
Return Nothing
End Function
Protected Function FindListItemByName(ByVal lView As ListView, ByVal strName As String, ByVal bThrowError As Boolean) As ListViewItem
For Each liItem As ListViewItem In lView.Items
If Not liItem.Tag Is Nothing AndAlso Util.IsTypeOf(liItem.Tag.GetType, GetType(AnimatGUI.Framework.DataObject), True) Then
Dim doObject As AnimatGUI.Framework.DataObject = DirectCast(liItem.Tag, AnimatGUI.Framework.DataObject)
If doObject.Name = strName Then
Return liItem
End If
End If
Next
If bThrowError Then
Throw New System.Exception("No attachment was found with the name: " & strName)
End If
Return Nothing
End Function
#End Region
#Region " Events "
Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)
MyBase.OnLoad(e)
Try
m_btnOk = Me.btnOk
m_btnCancel = Me.btnCancel
m_lvItems = lvMuscleAttachments
If m_aryAttachments Is Nothing Then
Throw New System.Exception("The attachments array is not defined.")
End If
If m_doStructure Is Nothing Then
Throw New System.Exception("The parent structure is not defined.")
End If
'now lets populate the drop down box with all of the muscle attachments.
Dim aryAttachments As Collections.DataObjects = New Collections.DataObjects(Nothing)
m_doStructure.FindChildrenOfType(GetType(DataObjects.Physical.Bodies.Attachment), aryAttachments)
'Now lets populate the list view with the current muscle attachments.
For Each doAttach As DataObjects.Physical.Bodies.Attachment In aryAttachments
Dim liItem As New ListViewItem(doAttach.ToString)
liItem.Tag = doAttach
lvAttachments.Items.Add(liItem)
Next
'Now lets populate the list box with the current muscle attachments.
Dim liFindItem As ListViewItem
For Each doAttach As DataObjects.Physical.Bodies.Attachment In m_aryAttachments
Dim liItem As New ListViewItem(doAttach.ToString)
liItem.Tag = doAttach
lvMuscleAttachments.Items.Add(liItem)
liFindItem = FindListItem(lvAttachments, doAttach.ID, False)
If Not liFindItem Is Nothing Then
lvAttachments.Items.Remove(liFindItem)
End If
Next
Catch ex As System.Exception
Util.DisplayError(ex)
End Try
End Sub
Private Sub btnUp_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUp.Click
Try
If lvMuscleAttachments.SelectedItems.Count <= 0 Then
Throw New System.Exception("Please select an item to move up.")
End If
If lvMuscleAttachments.SelectedItems.Count > 1 Then
Throw New System.Exception("You can only move one item up at a time.")
End If
Dim liItem As ListViewItem = lvMuscleAttachments.SelectedItems(0)
Dim iIndex As Integer = liItem.Index
If iIndex > 0 Then
lvMuscleAttachments.Items.Remove(liItem)
lvMuscleAttachments.Items.Insert(iIndex - 1, liItem)
End If
m_bIsDirty = True
Catch ex As System.Exception
Util.DisplayError(ex)
End Try
End Sub
Private Sub btnDown_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDown.Click
Try
If lvMuscleAttachments.SelectedItems.Count <= 0 Then
Throw New System.Exception("Please select an item to move down.")
End If
If lvMuscleAttachments.SelectedItems.Count > 1 Then
Throw New System.Exception("You can only move one item down at a time.")
End If
Dim liItem As ListViewItem = lvMuscleAttachments.SelectedItems(0)
Dim iIndex As Integer = liItem.Index
If iIndex > 0 Then
lvMuscleAttachments.Items.Remove(liItem)
lvMuscleAttachments.Items.Insert(iIndex + 1, liItem)
End If
m_bIsDirty = True
Catch ex As System.Exception
Util.DisplayError(ex)
End Try
End Sub
Protected Sub AddAttachment(ByVal liSelItem As ListViewItem, ByVal aryItems As ArrayList)
Try
For Each liTempItem As ListViewItem In lvMuscleAttachments.Items
If liTempItem.Tag Is liSelItem.Tag Then
Dim doAttach1 As DataObjects.Physical.Bodies.Attachment = DirectCast(liTempItem.Tag, DataObjects.Physical.Bodies.Attachment)
Throw New System.Exception("The muscle attachment '" + doAttach1.Name + "' is already in the list.")
End If
Next
Dim doAttach As DataObjects.Physical.Bodies.Attachment = DirectCast(liSelItem.Tag, DataObjects.Physical.Bodies.Attachment)
Dim liItem As New ListViewItem(doAttach.ToString())
liItem.Tag = doAttach
lvMuscleAttachments.Items.Add(liItem)
aryItems.Add(liSelItem)
Catch ex As System.Exception
Util.DisplayError(ex)
End Try
End Sub
Private Sub btnAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAdd.Click
Try
If lvAttachments.SelectedItems.Count <= 0 Then
Throw New System.Exception("you must select a muscle attachment to add.")
End If
Dim aryItems As New ArrayList()
For Each liItem As ListViewItem In lvAttachments.SelectedItems
AddAttachment(liItem, aryItems)
Next
'now remove all the selected attachments that were added
For Each liItem As ListViewItem In aryItems
lvAttachments.Items.Remove(liItem)
Next
If lvAttachments.Items.Count > 0 Then
lvAttachments.Items(0).Selected = True
End If
m_bIsDirty = True
Catch ex As System.Exception
Util.DisplayError(ex)
End Try
End Sub
Private Sub btnDelete_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDelete.Click
Try
Dim aryList As New ArrayList()
For Each liItem As ListViewItem In lvMuscleAttachments.SelectedItems
aryList.Add(liItem)
Next
For Each liItem As ListViewItem In aryList
lvMuscleAttachments.Items.Remove(liItem)
lvAttachments.Items.Add(liItem)
Next
If lvMuscleAttachments.Items.Count > 0 Then
lvMuscleAttachments.Items(0).Selected = True
End If
m_bIsDirty = True
Catch ex As System.Exception
Util.DisplayError(ex)
End Try
End Sub
Private Sub btnOk_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnOk.Click
Try
If m_bIsDirty Then
'Verify that the number of attachments that were selected is not more than the number allowed
If m_iMaxAttachmentsAllowed > 0 AndAlso lvMuscleAttachments.Items.Count > m_iMaxAttachmentsAllowed Then
Throw New System.Exception("Only " & m_iMaxAttachmentsAllowed & " are allowed for this part type. " & _
"Please reduce the number of attachments to this number.")
End If
m_aryAttachments.Clear()
For Each liItem As ListViewItem In lvMuscleAttachments.Items
m_aryAttachments.Add(DirectCast(liItem.Tag, DataObjects.Physical.Bodies.Attachment))
Next
Me.DialogResult = System.Windows.Forms.DialogResult.OK
Else
Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
End If
Me.Close()
Catch ex As System.Exception
Util.DisplayError(ex)
End Try
End Sub
Public Sub Automation_AddAttachment(ByVal strName As String)
Dim liItem As ListViewItem = FindListItemByName(Me.lvAttachments, strName, True)
lvAttachments.SelectedItems.Clear()
liItem.Selected = True
btnAdd_Click(Nothing, Nothing)
End Sub
Public Sub Automation_RemoveAttachment(ByVal strName As String)
Dim liItem As ListViewItem = FindListItemByName(Me.lvMuscleAttachments, strName, True)
lvMuscleAttachments.SelectedItems.Clear()
liItem.Selected = True
btnDelete_Click(Nothing, Nothing)
End Sub
Public Sub Automation_AttachmentUp(ByVal strName As String)
Dim liItem As ListViewItem = FindListItemByName(Me.lvMuscleAttachments, strName, True)
lvMuscleAttachments.SelectedItems.Clear()
liItem.Selected = True
btnUp_Click(Nothing, Nothing)
End Sub
Public Sub Automation_AttachmentDown(ByVal strName As String)
Dim liItem As ListViewItem = FindListItemByName(Me.lvMuscleAttachments, strName, True)
lvMuscleAttachments.SelectedItems.Clear()
liItem.Selected = True
btnDown_Click(Nothing, Nothing)
End Sub
#End Region
End Class
End Namespace
|
NeuroRoboticTech/AnimatLabPublicSource
|
Libraries/AnimatGUI/Forms/BodyPlan/EditAttachments.vb
|
Visual Basic
|
bsd-3-clause
| 12,953
|
'------------------------------------------------------------------------------
' <auto-generated>
' This code was generated by a tool.
' Runtime Version:4.0.30319.17379
'
' Changes to this file may cause incorrect behavior and will be lost if
' the code is regenerated.
' </auto-generated>
'------------------------------------------------------------------------------
Option Strict On
Option Explicit On
Imports System
Namespace My.Resources
'This class was auto-generated by the StronglyTypedResourceBuilder
'class via a tool like ResGen or Visual Studio.
'To add or remove a member, edit your .ResX file then rerun ResGen
'with the /str option, or rebuild your VS project.
'''<summary>
''' A strongly-typed resource class, for looking up localized strings, etc.
'''</summary>
<Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0"), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
Global.Microsoft.VisualBasic.HideModuleNameAttribute()> _
Friend Module Resources
Private resourceMan As Global.System.Resources.ResourceManager
Private resourceCulture As Global.System.Globalization.CultureInfo
'''<summary>
''' Returns the cached ResourceManager instance used by this class.
'''</summary>
<Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager
Get
If Object.ReferenceEquals(resourceMan, Nothing) Then
Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("ArcGIS4LocalGovernment.Resources", GetType(Resources).Assembly)
resourceMan = temp
End If
Return resourceMan
End Get
End Property
'''<summary>
''' Overrides the current thread's CurrentUICulture property for all
''' resource lookups using this strongly typed resource class.
'''</summary>
<Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Friend Property Culture() As Global.System.Globalization.CultureInfo
Get
Return resourceCulture
End Get
Set
resourceCulture = value
End Set
End Property
Friend ReadOnly Property CIPAddIn() As System.Drawing.Icon
Get
Dim obj As Object = ResourceManager.GetObject("CIPAddIn", resourceCulture)
Return CType(obj,System.Drawing.Icon)
End Get
End Property
Friend ReadOnly Property CIPCreateAssetSmall() As System.Drawing.Bitmap
Get
Dim obj As Object = ResourceManager.GetObject("CIPCreateAssetSmall", resourceCulture)
Return CType(obj,System.Drawing.Bitmap)
End Get
End Property
Friend ReadOnly Property CIPdeleteSmall() As System.Drawing.Bitmap
Get
Dim obj As Object = ResourceManager.GetObject("CIPdeleteSmall", resourceCulture)
Return CType(obj,System.Drawing.Bitmap)
End Get
End Property
Friend ReadOnly Property CIPSelectAsset2Small() As System.Drawing.Bitmap
Get
Dim obj As Object = ResourceManager.GetObject("CIPSelectAsset2Small", resourceCulture)
Return CType(obj,System.Drawing.Bitmap)
End Get
End Property
Friend ReadOnly Property CIPSelectAssetExistingProjectSmall() As System.Drawing.Bitmap
Get
Dim obj As Object = ResourceManager.GetObject("CIPSelectAssetExistingProjectSmall", resourceCulture)
Return CType(obj,System.Drawing.Bitmap)
End Get
End Property
Friend ReadOnly Property CIPSelectAssetSmall() As System.Drawing.Bitmap
Get
Dim obj As Object = ResourceManager.GetObject("CIPSelectAssetSmall", resourceCulture)
Return CType(obj,System.Drawing.Bitmap)
End Get
End Property
Friend ReadOnly Property Delete() As System.Drawing.Bitmap
Get
Dim obj As Object = ResourceManager.GetObject("Delete", resourceCulture)
Return CType(obj,System.Drawing.Bitmap)
End Get
End Property
Friend ReadOnly Property Flash() As System.Drawing.Bitmap
Get
Dim obj As Object = ResourceManager.GetObject("Flash", resourceCulture)
Return CType(obj,System.Drawing.Bitmap)
End Get
End Property
Friend ReadOnly Property FlashZoom() As System.Drawing.Bitmap
Get
Dim obj As Object = ResourceManager.GetObject("FlashZoom", resourceCulture)
Return CType(obj,System.Drawing.Bitmap)
End Get
End Property
Friend ReadOnly Property Open2() As System.Drawing.Bitmap
Get
Dim obj As Object = ResourceManager.GetObject("Open2", resourceCulture)
Return CType(obj,System.Drawing.Bitmap)
End Get
End Property
Friend ReadOnly Property SaveEdits() As System.Drawing.Bitmap
Get
Dim obj As Object = ResourceManager.GetObject("SaveEdits", resourceCulture)
Return CType(obj,System.Drawing.Bitmap)
End Get
End Property
Friend ReadOnly Property savePrj() As System.Drawing.Bitmap
Get
Dim obj As Object = ResourceManager.GetObject("savePrj", resourceCulture)
Return CType(obj,System.Drawing.Bitmap)
End Get
End Property
Friend ReadOnly Property split() As System.Drawing.Bitmap
Get
Dim obj As Object = ResourceManager.GetObject("split", resourceCulture)
Return CType(obj,System.Drawing.Bitmap)
End Get
End Property
Friend ReadOnly Property splitSelected() As System.Drawing.Bitmap
Get
Dim obj As Object = ResourceManager.GetObject("splitSelected", resourceCulture)
Return CType(obj,System.Drawing.Bitmap)
End Get
End Property
Friend ReadOnly Property StartEditing() As System.Drawing.Bitmap
Get
Dim obj As Object = ResourceManager.GetObject("StartEditing", resourceCulture)
Return CType(obj,System.Drawing.Bitmap)
End Get
End Property
Friend ReadOnly Property StopEditing() As System.Drawing.Bitmap
Get
Dim obj As Object = ResourceManager.GetObject("StopEditing", resourceCulture)
Return CType(obj,System.Drawing.Bitmap)
End Get
End Property
Friend ReadOnly Property Trim() As System.Drawing.Bitmap
Get
Dim obj As Object = ResourceManager.GetObject("Trim", resourceCulture)
Return CType(obj,System.Drawing.Bitmap)
End Get
End Property
Friend ReadOnly Property ZoomTo() As System.Drawing.Bitmap
Get
Dim obj As Object = ResourceManager.GetObject("ZoomTo", resourceCulture)
Return CType(obj,System.Drawing.Bitmap)
End Get
End Property
End Module
End Namespace
|
chinasio/local-government-desktop-addins
|
Project Cost Estimating/My Project/Resources.Designer.vb
|
Visual Basic
|
apache-2.0
| 7,924
|
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System.Threading
Imports System.Threading.Tasks
Imports Microsoft.CodeAnalysis
Imports Microsoft.CodeAnalysis.FindSymbols
Imports Microsoft.CodeAnalysis.Host
Imports Microsoft.CodeAnalysis.LanguageServices
Imports Microsoft.CodeAnalysis.Rename
Imports Microsoft.CodeAnalysis.Rename.ConflictEngine
Imports Microsoft.CodeAnalysis.Simplification
Imports Microsoft.CodeAnalysis.Text
Imports Microsoft.CodeAnalysis.VisualBasic.Symbols
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Imports Microsoft.CodeAnalysis.VisualBasic.Utilities
Namespace Microsoft.CodeAnalysis.VisualBasic.Rename
Friend Class VisualBasicRenameRewriterLanguageService
Implements IRenameRewriterLanguageService
Private ReadOnly _languageServiceProvider As HostLanguageServices
Public Sub New(provider As HostLanguageServices)
_languageServiceProvider = provider
End Sub
#Region "Annotate"
Public Function AnnotateAndRename(parameters As RenameRewriterParameters) As SyntaxNode Implements IRenameRewriterLanguageService.AnnotateAndRename
Dim renameRewriter = New RenameRewriter(parameters)
Return renameRewriter.Visit(parameters.SyntaxRoot)
End Function
Private Class RenameRewriter
Inherits VisualBasicSyntaxRewriter
Private ReadOnly _documentId As DocumentId
Private ReadOnly _renameRenamableSymbolDeclaration As RenameAnnotation
Private ReadOnly _solution As Solution
Private ReadOnly _replacementText As String
Private ReadOnly _originalText As String
Private ReadOnly _possibleNameConflicts As ICollection(Of String)
Private ReadOnly _renameLocations As Dictionary(Of TextSpan, RenameLocation)
Private ReadOnly _conflictLocations As IEnumerable(Of TextSpan)
Private ReadOnly _semanticModel As SemanticModel
Private ReadOnly _cancellationToken As CancellationToken
Private ReadOnly _renamedSymbol As ISymbol
Private ReadOnly _aliasSymbol As IAliasSymbol
Private ReadOnly _renamableDeclarationLocation As Location
Private ReadOnly _renameSpansTracker As RenamedSpansTracker
Private ReadOnly _isVerbatim As Boolean
Private ReadOnly _replacementTextValid As Boolean
Private ReadOnly _isRenamingInStrings As Boolean
Private ReadOnly _isRenamingInComments As Boolean
Private ReadOnly _stringAndCommentTextSpans As ISet(Of TextSpan)
Private ReadOnly _simplificationService As ISimplificationService
Private ReadOnly _annotatedIdentifierTokens As New HashSet(Of SyntaxToken)
Private ReadOnly _invocationExpressionsNeedingConflictChecks As New HashSet(Of InvocationExpressionSyntax)
Private ReadOnly _syntaxFactsService As ISyntaxFactsService
Private ReadOnly _semanticFactsService As ISemanticFactsService
Private ReadOnly _renameAnnotations As AnnotationTable(Of RenameAnnotation)
Private ReadOnly Property AnnotateForComplexification As Boolean
Get
Return Me._skipRenameForComplexification > 0 AndAlso Not Me._isProcessingComplexifiedSpans
End Get
End Property
Private _skipRenameForComplexification As Integer = 0
Private _isProcessingComplexifiedSpans As Boolean
Private _modifiedSubSpans As List(Of ValueTuple(Of TextSpan, TextSpan)) = Nothing
Private _speculativeModel As SemanticModel
Private _isProcessingStructuredTrivia As Integer
Private ReadOnly _complexifiedSpans As HashSet(Of TextSpan) = New HashSet(Of TextSpan)
Private Sub AddModifiedSpan(oldSpan As TextSpan, newSpan As TextSpan)
newSpan = New TextSpan(oldSpan.Start, newSpan.Length)
If Not Me._isProcessingComplexifiedSpans Then
_renameSpansTracker.AddModifiedSpan(_documentId, oldSpan, newSpan)
Else
Me._modifiedSubSpans.Add(ValueTuple.Create(oldSpan, newSpan))
End If
End Sub
Public Sub New(parameters As RenameRewriterParameters)
MyBase.New(visitIntoStructuredTrivia:=True)
Me._documentId = parameters.Document.Id
Me._renameRenamableSymbolDeclaration = parameters.RenamedSymbolDeclarationAnnotation
Me._solution = parameters.OriginalSolution
Me._replacementText = parameters.ReplacementText
Me._originalText = parameters.OriginalText
Me._possibleNameConflicts = parameters.PossibleNameConflicts
Me._renameLocations = parameters.RenameLocations
Me._conflictLocations = parameters.ConflictLocationSpans
Me._cancellationToken = parameters.CancellationToken
Me._semanticModel = DirectCast(parameters.SemanticModel, SemanticModel)
Me._renamedSymbol = parameters.RenameSymbol
Me._replacementTextValid = parameters.ReplacementTextValid
Me._renameSpansTracker = parameters.RenameSpansTracker
Me._isRenamingInStrings = parameters.OptionSet.GetOption(RenameOptions.RenameInStrings)
Me._isRenamingInComments = parameters.OptionSet.GetOption(RenameOptions.RenameInComments)
Me._stringAndCommentTextSpans = parameters.StringAndCommentTextSpans
Me._aliasSymbol = TryCast(Me._renamedSymbol, IAliasSymbol)
Me._renamableDeclarationLocation = Me._renamedSymbol.Locations.Where(Function(loc) loc.IsInSource AndAlso loc.SourceTree Is _semanticModel.SyntaxTree).FirstOrDefault()
Me._simplificationService = parameters.Document.Project.LanguageServices.GetService(Of ISimplificationService)()
Me._syntaxFactsService = parameters.Document.Project.LanguageServices.GetService(Of ISyntaxFactsService)()
Me._semanticFactsService = parameters.Document.Project.LanguageServices.GetService(Of ISemanticFactsService)()
Me._isVerbatim = Me._syntaxFactsService.IsVerbatimIdentifier(_replacementText)
Me._renameAnnotations = parameters.RenameAnnotations
End Sub
Public Overrides Function Visit(node As SyntaxNode) As SyntaxNode
If node Is Nothing Then
Return node
End If
Dim isInConflictLambdaBody = False
Dim lambdas = node.GetAncestorsOrThis(Of MultiLineLambdaExpressionSyntax)()
If lambdas.Count() <> 0 Then
For Each lambda In lambdas
If Me._conflictLocations.Any(Function(cf)
Return cf.Contains(lambda.Span)
End Function) Then
isInConflictLambdaBody = True
Exit For
End If
Next
End If
Dim shouldComplexifyNode = Me.ShouldComplexifyNode(node, isInConflictLambdaBody)
Dim result As SyntaxNode
If shouldComplexifyNode Then
Me._skipRenameForComplexification += 1
result = MyBase.Visit(node)
Me._skipRenameForComplexification -= 1
result = Complexify(node, result)
Else
result = MyBase.Visit(node)
End If
Return result
End Function
Private Function ShouldComplexifyNode(node As SyntaxNode, isInConflictLambdaBody As Boolean) As Boolean
Return Not isInConflictLambdaBody AndAlso
_skipRenameForComplexification = 0 AndAlso
Not _isProcessingComplexifiedSpans AndAlso
_conflictLocations.Contains(node.Span) AndAlso
(TypeOf node Is ExpressionSyntax OrElse
TypeOf node Is StatementSyntax OrElse
TypeOf node Is AttributeSyntax OrElse
TypeOf node Is SimpleArgumentSyntax OrElse
TypeOf node Is CrefReferenceSyntax OrElse
TypeOf node Is TypeConstraintSyntax)
End Function
Private Function Complexify(originalNode As SyntaxNode, newNode As SyntaxNode) As SyntaxNode
If Me._complexifiedSpans.Contains(originalNode.Span) Then
Return newNode
Else
Me._complexifiedSpans.Add(originalNode.Span)
End If
Me._isProcessingComplexifiedSpans = True
Me._modifiedSubSpans = New List(Of ValueTuple(Of TextSpan, TextSpan))()
Dim annotation = New SyntaxAnnotation()
newNode = newNode.WithAdditionalAnnotations(annotation)
Dim speculativeTree = originalNode.SyntaxTree.GetRoot(_cancellationToken).ReplaceNode(originalNode, newNode)
newNode = speculativeTree.GetAnnotatedNodes(Of SyntaxNode)(annotation).First()
Me._speculativeModel = GetSemanticModelForNode(newNode, Me._semanticModel)
Debug.Assert(_speculativeModel IsNot Nothing, "expanding a syntax node which cannot be speculated?")
Dim oldSpan = originalNode.Span
Dim expandParameter = originalNode.GetAncestorsOrThis(Of LambdaExpressionSyntax).Count() = 0
Dim expandedNewNode = DirectCast(_simplificationService.Expand(newNode,
_speculativeModel,
annotationForReplacedAliasIdentifier:=Nothing,
expandInsideNode:=AddressOf IsExpandWithinMultiLineLambda,
expandParameter:=expandParameter,
cancellationToken:=_cancellationToken), SyntaxNode)
Dim annotationForSpeculativeNode = New SyntaxAnnotation()
expandedNewNode = expandedNewNode.WithAdditionalAnnotations(annotationForSpeculativeNode)
speculativeTree = originalNode.SyntaxTree.GetRoot(_cancellationToken).ReplaceNode(originalNode, expandedNewNode)
Dim probableRenameNode = speculativeTree.GetAnnotatedNodes(Of SyntaxNode)(annotation).First()
Dim speculativeNewNode = speculativeTree.GetAnnotatedNodes(Of SyntaxNode)(annotationForSpeculativeNode).First()
Me._speculativeModel = GetSemanticModelForNode(speculativeNewNode, Me._semanticModel)
Debug.Assert(_speculativeModel IsNot Nothing, "expanding a syntax node which cannot be speculated?")
Dim renamedNode = MyBase.Visit(probableRenameNode)
If Not ReferenceEquals(renamedNode, probableRenameNode) Then
renamedNode = renamedNode.WithoutAnnotations(annotation)
probableRenameNode = expandedNewNode.GetAnnotatedNodes(Of SyntaxNode)(annotation).First()
expandedNewNode = expandedNewNode.ReplaceNode(probableRenameNode, renamedNode)
End If
Dim newSpan = expandedNewNode.Span
probableRenameNode = probableRenameNode.WithoutAnnotations(annotation)
expandedNewNode = Me._renameAnnotations.WithAdditionalAnnotations(expandedNewNode, New RenameNodeSimplificationAnnotation() With {.OriginalTextSpan = oldSpan})
Me._renameSpansTracker.AddComplexifiedSpan(Me._documentId, oldSpan, New TextSpan(oldSpan.Start, newSpan.Length), Me._modifiedSubSpans)
Me._modifiedSubSpans = Nothing
Me._isProcessingComplexifiedSpans = False
Me._speculativeModel = Nothing
Return expandedNewNode
End Function
Private Function IsExpandWithinMultiLineLambda(node As SyntaxNode) As Boolean
If node Is Nothing Then
Return False
End If
If Me._conflictLocations.Contains(node.Span) Then
Return True
End If
If node.IsParentKind(SyntaxKind.MultiLineSubLambdaExpression) OrElse
node.IsParentKind(SyntaxKind.MultiLineFunctionLambdaExpression) Then
Dim parent = DirectCast(node.Parent, MultiLineLambdaExpressionSyntax)
If ReferenceEquals(parent.SubOrFunctionHeader, node) Then
Return True
Else
Return False
End If
End If
Return True
End Function
Private Function IsPossibleNameConflict(possibleNameConflicts As ICollection(Of String), candidate As String) As Boolean
For Each possibleNameConflict In possibleNameConflicts
If CaseInsensitiveComparison.Equals(possibleNameConflict, candidate) Then
Return True
End If
Next
Return False
End Function
Private Function UpdateAliasAnnotation(newToken As SyntaxToken) As SyntaxToken
If Me._aliasSymbol IsNot Nothing AndAlso Not Me.AnnotateForComplexification AndAlso newToken.HasAnnotations(AliasAnnotation.Kind) Then
newToken = RenameUtilities.UpdateAliasAnnotation(newToken, Me._aliasSymbol, Me._replacementText)
End If
Return newToken
End Function
Private Async Function RenameAndAnnotateAsync(token As SyntaxToken, newToken As SyntaxToken, isRenameLocation As Boolean, isOldText As Boolean) As Task(Of SyntaxToken)
If Me._isProcessingComplexifiedSpans Then
If isRenameLocation Then
Dim annotation = Me._renameAnnotations.GetAnnotations(Of RenameActionAnnotation)(token).FirstOrDefault()
If annotation IsNot Nothing Then
newToken = RenameToken(token, newToken, annotation.Prefix, annotation.Suffix)
AddModifiedSpan(annotation.OriginalSpan, New TextSpan(token.Span.Start, newToken.Span.Length))
Else
newToken = RenameToken(token, newToken, prefix:=Nothing, suffix:=Nothing)
End If
End If
Return newToken
End If
Dim symbols = RenameUtilities.GetSymbolsTouchingPosition(token.Span.Start, Me._semanticModel, Me._solution.Workspace, Me._cancellationToken)
' this is the compiler generated backing field of a non custom event. We need to store a "Event" suffix to properly rename it later on.
Dim prefix = If(isRenameLocation AndAlso Me._renameLocations(token.Span).IsRenamableAccessor, newToken.ValueText.Substring(0, newToken.ValueText.IndexOf("_"c) + 1), String.Empty)
Dim suffix As String = Nothing
If symbols.Count() = 1 Then
Dim symbol = symbols.Single()
If symbol.IsConstructor() Then
symbol = symbol.ContainingSymbol
End If
If symbol.Kind = SymbolKind.Field AndAlso symbol.IsImplicitlyDeclared Then
Dim fieldSymbol = DirectCast(symbol, IFieldSymbol)
If fieldSymbol.Type.IsDelegateType AndAlso
fieldSymbol.Type.IsImplicitlyDeclared AndAlso
DirectCast(fieldSymbol.Type, INamedTypeSymbol).AssociatedSymbol IsNot Nothing Then
suffix = "Event"
End If
If fieldSymbol.AssociatedSymbol IsNot Nothing AndAlso
fieldSymbol.AssociatedSymbol.IsKind(SymbolKind.Property) AndAlso
fieldSymbol.Name = "_" + fieldSymbol.AssociatedSymbol.Name Then
prefix = "_"
End If
ElseIf symbol.IsConstructor AndAlso
symbol.ContainingType.IsImplicitlyDeclared AndAlso
symbol.ContainingType.IsDelegateType AndAlso
symbol.ContainingType.AssociatedSymbol IsNot Nothing Then
suffix = "EventHandler"
ElseIf TypeOf symbol Is INamedTypeSymbol Then
Dim namedTypeSymbol = DirectCast(symbol, INamedTypeSymbol)
If namedTypeSymbol.IsImplicitlyDeclared AndAlso
namedTypeSymbol.IsDelegateType() AndAlso
namedTypeSymbol.AssociatedSymbol IsNot Nothing Then
suffix = "EventHandler"
End If
End If
If Not isRenameLocation AndAlso TypeOf (symbol) Is INamespaceSymbol AndAlso token.GetPreviousToken().Kind = SyntaxKind.NamespaceKeyword Then
Return newToken
End If
End If
If isRenameLocation AndAlso Not Me.AnnotateForComplexification Then
Dim oldSpan = token.Span
newToken = RenameToken(token, newToken, prefix:=prefix, suffix:=suffix)
AddModifiedSpan(oldSpan, newToken.Span)
End If
Dim renameDeclarationLocations As RenameDeclarationLocationReference() =
Await ConflictResolver.CreateDeclarationLocationAnnotationsAsync(_solution, symbols, _cancellationToken).ConfigureAwait(False)
Dim isNamespaceDeclarationReference = False
If isRenameLocation AndAlso token.GetPreviousToken().Kind = SyntaxKind.NamespaceKeyword Then
isNamespaceDeclarationReference = True
End If
Dim isMemberGroupReference = _semanticFactsService.IsNameOfContext(_semanticModel, token.Span.Start, _cancellationToken)
Dim renameAnnotation = New RenameActionAnnotation(
token.Span,
isRenameLocation,
prefix,
suffix,
isOldText,
renameDeclarationLocations,
isNamespaceDeclarationReference,
isInvocationExpression:=False,
isMemberGroupReference:=isMemberGroupReference)
_annotatedIdentifierTokens.Add(token)
newToken = Me._renameAnnotations.WithAdditionalAnnotations(newToken, renameAnnotation, New RenameTokenSimplificationAnnotation() With {.OriginalTextSpan = token.Span})
If Me._renameRenamableSymbolDeclaration IsNot Nothing AndAlso _renamableDeclarationLocation = token.GetLocation() Then
newToken = Me._renameAnnotations.WithAdditionalAnnotations(newToken, Me._renameRenamableSymbolDeclaration)
End If
Return newToken
End Function
Private Function IsInRenameLocation(token As SyntaxToken) As Boolean
If Not Me._isProcessingComplexifiedSpans Then
Return Me._renameLocations.ContainsKey(token.Span)
Else
If token.HasAnnotations(AliasAnnotation.Kind) Then
Return False
End If
If Me._renameAnnotations.HasAnnotations(Of RenameActionAnnotation)(token) Then
Return Me._renameAnnotations.GetAnnotations(Of RenameActionAnnotation)(token).First().IsRenameLocation
End If
If TypeOf token.Parent Is SimpleNameSyntax AndAlso token.Kind <> SyntaxKind.GlobalKeyword AndAlso token.Parent.Parent.IsKind(SyntaxKind.QualifiedName, SyntaxKind.QualifiedCrefOperatorReference) Then
Dim symbol = Me._speculativeModel.GetSymbolInfo(token.Parent, Me._cancellationToken).Symbol
If symbol IsNot Nothing AndAlso Me._renamedSymbol.Kind <> SymbolKind.Local AndAlso Me._renamedSymbol.Kind <> SymbolKind.RangeVariable AndAlso
(symbol Is Me._renamedSymbol OrElse SymbolKey.GetComparer(ignoreCase:=True, ignoreAssemblyKeys:=False).Equals(symbol.GetSymbolKey(), Me._renamedSymbol.GetSymbolKey())) Then
Return True
End If
End If
Return False
End If
End Function
Public Overrides Function VisitToken(oldToken As SyntaxToken) As SyntaxToken
If oldToken = Nothing Then
Return oldToken
End If
Dim newToken = oldToken
Dim shouldCheckTrivia = Me._stringAndCommentTextSpans.Contains(oldToken.Span)
If shouldCheckTrivia Then
Me._isProcessingStructuredTrivia += 1
newToken = MyBase.VisitToken(newToken)
Me._isProcessingStructuredTrivia -= 1
Else
newToken = MyBase.VisitToken(newToken)
End If
newToken = UpdateAliasAnnotation(newToken)
' Rename matches in strings and comments
newToken = RenameWithinToken(oldToken, newToken)
' We don't want to annotate XmlName with RenameActionAnnotation
If newToken.Kind = SyntaxKind.XmlNameToken Then
Return newToken
End If
Dim isRenameLocation = IsInRenameLocation(oldToken)
Dim isOldText = CaseInsensitiveComparison.Equals(oldToken.ValueText, _originalText)
Dim tokenNeedsConflictCheck = isRenameLocation OrElse
isOldText OrElse
CaseInsensitiveComparison.Equals(oldToken.ValueText, _replacementText) OrElse
IsPossibleNameConflict(_possibleNameConflicts, oldToken.ValueText)
If tokenNeedsConflictCheck Then
newToken = RenameAndAnnotateAsync(oldToken, newToken, isRenameLocation, isOldText).WaitAndGetResult_CanCallOnBackground(_cancellationToken)
If Not Me._isProcessingComplexifiedSpans Then
_invocationExpressionsNeedingConflictChecks.AddRange(oldToken.GetAncestors(Of InvocationExpressionSyntax)())
End If
End If
Return newToken
End Function
Private Function GetAnnotationForInvocationExpression(invocationExpression As InvocationExpressionSyntax) As RenameActionAnnotation
Dim identifierToken As SyntaxToken = Nothing
Dim expressionOfInvocation = invocationExpression.Expression
While expressionOfInvocation IsNot Nothing
Select Case expressionOfInvocation.Kind
Case SyntaxKind.IdentifierName, SyntaxKind.GenericName
identifierToken = DirectCast(expressionOfInvocation, SimpleNameSyntax).Identifier
Exit While
Case SyntaxKind.SimpleMemberAccessExpression
identifierToken = DirectCast(expressionOfInvocation, MemberAccessExpressionSyntax).Name.Identifier
Exit While
Case SyntaxKind.QualifiedName
identifierToken = DirectCast(expressionOfInvocation, QualifiedNameSyntax).Right.Identifier
Exit While
Case SyntaxKind.ParenthesizedExpression
expressionOfInvocation = DirectCast(expressionOfInvocation, ParenthesizedExpressionSyntax).Expression
Case SyntaxKind.MeExpression
Exit While
Case Else
' This isn't actually an invocation, so there's no member name to check.
Return Nothing
End Select
End While
If identifierToken <> Nothing AndAlso Not Me._annotatedIdentifierTokens.Contains(identifierToken) Then
Dim symbolInfo = Me._semanticModel.GetSymbolInfo(invocationExpression, Me._cancellationToken)
Dim symbols As IEnumerable(Of ISymbol) = Nothing
If symbolInfo.Symbol Is Nothing Then
Return Nothing
Else
symbols = SpecializedCollections.SingletonEnumerable(symbolInfo.Symbol)
End If
Dim renameDeclarationLocations As RenameDeclarationLocationReference() =
ConflictResolver.CreateDeclarationLocationAnnotationsAsync(_solution, symbols, _cancellationToken).WaitAndGetResult_CanCallOnBackground(_cancellationToken)
Dim renameAnnotation = New RenameActionAnnotation(
identifierToken.Span,
isRenameLocation:=False,
prefix:=Nothing,
suffix:=Nothing,
renameDeclarationLocations:=renameDeclarationLocations,
isOriginalTextLocation:=False,
isNamespaceDeclarationReference:=False,
isInvocationExpression:=True,
isMemberGroupReference:=False)
Return renameAnnotation
End If
Return Nothing
End Function
Public Overrides Function VisitInvocationExpression(node As InvocationExpressionSyntax) As SyntaxNode
Dim result = MyBase.VisitInvocationExpression(node)
If _invocationExpressionsNeedingConflictChecks.Contains(node) Then
Dim renameAnnotation = GetAnnotationForInvocationExpression(node)
If renameAnnotation IsNot Nothing Then
result = Me._renameAnnotations.WithAdditionalAnnotations(result, renameAnnotation)
End If
End If
Return result
End Function
Private Function RenameToken(oldToken As SyntaxToken, newToken As SyntaxToken, prefix As String, suffix As String) As SyntaxToken
Dim parent = oldToken.Parent
Dim currentNewIdentifier = Me._replacementText
Dim oldIdentifier = newToken.ValueText
Dim isAttributeName = SyntaxFacts.IsAttributeName(parent)
If isAttributeName Then
Debug.Assert(Me._renamedSymbol.IsAttribute() OrElse Me._aliasSymbol.Target.IsAttribute())
If oldIdentifier <> Me._renamedSymbol.Name Then
Dim withoutSuffix = String.Empty
If currentNewIdentifier.TryReduceAttributeSuffix(withoutSuffix) Then
currentNewIdentifier = withoutSuffix
End If
End If
Else
If Not String.IsNullOrEmpty(prefix) Then
currentNewIdentifier = prefix + currentNewIdentifier
End If
If Not String.IsNullOrEmpty(suffix) Then
currentNewIdentifier = currentNewIdentifier + suffix
End If
End If
' determine the canonical identifier name (unescaped, no type char, ...)
Dim valueText = currentNewIdentifier
Dim name = SyntaxFactory.ParseName(currentNewIdentifier)
If name.ContainsDiagnostics Then
name = SyntaxFactory.IdentifierName(currentNewIdentifier)
End If
If name.IsKind(SyntaxKind.GlobalName) Then
valueText = currentNewIdentifier
ElseIf name.IsKind(SyntaxKind.IdentifierName) Then
valueText = DirectCast(name, IdentifierNameSyntax).Identifier.ValueText
End If
If Me._isVerbatim Then
newToken = newToken.CopyAnnotationsTo(SyntaxFactory.BracketedIdentifier(newToken.LeadingTrivia, valueText, newToken.TrailingTrivia))
Else
newToken = newToken.CopyAnnotationsTo(SyntaxFactory.Identifier(
newToken.LeadingTrivia,
If(oldToken.GetTypeCharacter() = TypeCharacter.None, currentNewIdentifier, currentNewIdentifier + oldToken.ToString().Last()),
False,
valueText,
oldToken.GetTypeCharacter(),
newToken.TrailingTrivia))
If Me._replacementTextValid AndAlso
oldToken.GetTypeCharacter() <> TypeCharacter.None AndAlso
(SyntaxFacts.GetKeywordKind(valueText) = SyntaxKind.REMKeyword OrElse Me._syntaxFactsService.IsVerbatimIdentifier(newToken)) Then
newToken = Me._renameAnnotations.WithAdditionalAnnotations(newToken, RenameInvalidIdentifierAnnotation.Instance)
End If
End If
If Me._replacementTextValid Then
If newToken.IsBracketed Then
' a reference location should always be tried to be unescaped, whether it was escaped before rename
' or the replacement itself is escaped.
newToken = newToken.WithAdditionalAnnotations(Simplifier.Annotation)
Else
Dim semanticModel = GetSemanticModelForNode(parent, If(Me._speculativeModel, Me._semanticModel))
newToken = Simplification.VisualBasicSimplificationService.TryEscapeIdentifierToken(newToken, semanticModel, oldToken)
End If
End If
Return newToken
End Function
Private Function RenameInStringLiteral(oldToken As SyntaxToken, newToken As SyntaxToken, createNewStringLiteral As Func(Of SyntaxTriviaList, String, String, SyntaxTriviaList, SyntaxToken)) As SyntaxToken
Dim originalString = newToken.ToString()
Dim replacedString As String = RenameLocations.ReferenceProcessing.ReplaceMatchingSubStrings(originalString, _originalText, _replacementText)
If replacedString <> originalString Then
Dim oldSpan = oldToken.Span
newToken = createNewStringLiteral(newToken.LeadingTrivia, replacedString, replacedString, newToken.TrailingTrivia)
AddModifiedSpan(oldSpan, newToken.Span)
Return newToken.CopyAnnotationsTo(Me._renameAnnotations.WithAdditionalAnnotations(newToken, New RenameTokenSimplificationAnnotation() With {.OriginalTextSpan = oldSpan}))
End If
Return newToken
End Function
Private Function RenameInCommentTrivia(trivia As SyntaxTrivia) As SyntaxTrivia
Dim originalString = trivia.ToString()
Dim replacedString As String = RenameLocations.ReferenceProcessing.ReplaceMatchingSubStrings(originalString, _originalText, _replacementText)
If replacedString <> originalString Then
Dim oldSpan = trivia.Span
Dim newTrivia = SyntaxFactory.CommentTrivia(replacedString)
AddModifiedSpan(oldSpan, newTrivia.Span)
Return trivia.CopyAnnotationsTo(Me._renameAnnotations.WithAdditionalAnnotations(newTrivia, New RenameTokenSimplificationAnnotation() With {.OriginalTextSpan = oldSpan}))
End If
Return trivia
End Function
Private Function RenameInTrivia(token As SyntaxToken, leadingOrTrailingTriviaList As IEnumerable(Of SyntaxTrivia)) As SyntaxToken
Return token.ReplaceTrivia(leadingOrTrailingTriviaList, Function(oldTrivia, newTrivia)
If newTrivia.Kind = SyntaxKind.CommentTrivia Then
Return RenameInCommentTrivia(newTrivia)
End If
Return newTrivia
End Function)
End Function
Private Function RenameWithinToken(oldToken As SyntaxToken, newToken As SyntaxToken) As SyntaxToken
If Me._isProcessingComplexifiedSpans OrElse
(Me._isProcessingStructuredTrivia = 0 AndAlso Not Me._stringAndCommentTextSpans.Contains(oldToken.Span)) Then
Return newToken
End If
If Me._isRenamingInStrings Then
If newToken.Kind = SyntaxKind.StringLiteralToken Then
newToken = RenameInStringLiteral(oldToken, newToken, AddressOf SyntaxFactory.StringLiteralToken)
ElseIf newToken.Kind = SyntaxKind.InterpolatedStringTextToken Then
newToken = RenameInStringLiteral(oldToken, newToken, AddressOf SyntaxFactory.InterpolatedStringTextToken)
End If
End If
If Me._isRenamingInComments Then
If newToken.Kind = SyntaxKind.XmlTextLiteralToken Then
newToken = RenameInStringLiteral(oldToken, newToken, AddressOf SyntaxFactory.XmlTextLiteralToken)
ElseIf newToken.Kind = 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)
End If
If newToken.HasLeadingTrivia Then
Dim updatedToken = RenameInTrivia(oldToken, oldToken.LeadingTrivia)
If updatedToken <> oldToken Then
newToken = newToken.WithLeadingTrivia(updatedToken.LeadingTrivia)
End If
End If
If newToken.HasTrailingTrivia Then
Dim updatedToken = RenameInTrivia(oldToken, oldToken.TrailingTrivia)
If updatedToken <> oldToken Then
newToken = newToken.WithTrailingTrivia(updatedToken.TrailingTrivia)
End If
End If
End If
Return newToken
End Function
End Class
#End Region
#Region "Declaration Conflicts"
Public Function LocalVariableConflict(
token As SyntaxToken,
newReferencedSymbols As IEnumerable(Of ISymbol)
) As Boolean Implements IRenameRewriterLanguageService.LocalVariableConflict
' This scenario is not present in VB and only in C#
Return False
End Function
Public Function ComputeDeclarationConflictsAsync(
replacementText As String,
renamedSymbol As ISymbol,
renameSymbol As ISymbol,
referencedSymbols As IEnumerable(Of ISymbol),
baseSolution As Solution,
newSolution As Solution,
reverseMappedLocations As IDictionary(Of Location, Location),
cancellationToken As CancellationToken
) As Task(Of IEnumerable(Of Location)) Implements IRenameRewriterLanguageService.ComputeDeclarationConflictsAsync
Dim conflicts As New List(Of Location)
If renamedSymbol.Kind = SymbolKind.Parameter OrElse
renamedSymbol.Kind = SymbolKind.Local OrElse
renamedSymbol.Kind = SymbolKind.RangeVariable Then
Dim token = renamedSymbol.Locations.Single().FindToken(cancellationToken)
' Find the method block or field declaration that we're in. Note the LastOrDefault
' so we find the uppermost one, since VariableDeclarators live in methods too.
Dim methodBase = token.Parent.AncestorsAndSelf.Where(Function(s) TypeOf s Is MethodBlockBaseSyntax OrElse TypeOf s Is VariableDeclaratorSyntax) _
.LastOrDefault()
Dim visitor As New LocalConflictVisitor(token, newSolution, cancellationToken)
visitor.Visit(methodBase)
conflicts.AddRange(visitor.ConflictingTokens.Select(Function(t) t.GetLocation()) _
.Select(Function(loc) reverseMappedLocations(loc)))
' 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.Equals(renamedSymbol.ContainingSymbol.Name, renamedSymbol.Name) Then
Dim propertySymbol = renamedSymbol.ContainingSymbol
While propertySymbol IsNot Nothing
conflicts.AddRange(renamedSymbol.ContainingSymbol.Locations _
.Select(Function(loc) reverseMappedLocations(loc)))
propertySymbol = propertySymbol.OverriddenMember
End While
End If
ElseIf renamedSymbol.Kind = SymbolKind.Label Then
Dim token = renamedSymbol.Locations.Single().FindToken(cancellationToken)
Dim containingMethod = token.Parent.FirstAncestorOrSelf(Of SyntaxNode)(
Function(s) TypeOf s Is MethodBlockBaseSyntax OrElse
TypeOf s Is LambdaExpressionSyntax)
Dim visitor As New LabelConflictVisitor(token)
visitor.Visit(containingMethod)
conflicts.AddRange(visitor.ConflictingTokens.Select(Function(t) t.GetLocation()) _
.Select(Function(loc) reverseMappedLocations(loc)))
ElseIf renamedSymbol.Kind = SymbolKind.Method Then
conflicts.AddRange(
DeclarationConflictHelpers.GetMembersWithConflictingSignatures(DirectCast(renamedSymbol, IMethodSymbol), trimOptionalParameters:=True) _
.Select(Function(loc) reverseMappedLocations(loc)))
ElseIf renamedSymbol.Kind = SymbolKind.Property Then
ConflictResolver.AddConflictingParametersOfProperties(referencedSymbols.Concat(renameSymbol).Where(Function(sym) sym.Kind = SymbolKind.Property),
renamedSymbol.Name,
conflicts)
ElseIf renamedSymbol.Kind = SymbolKind.TypeParameter Then
Dim Location = renamedSymbol.Locations.Single()
Dim token = renamedSymbol.Locations.Single().FindToken(cancellationToken)
Dim currentTypeParameter = token.Parent
For Each typeParameter In DirectCast(currentTypeParameter.Parent, TypeParameterListSyntax).Parameters
If typeParameter IsNot currentTypeParameter AndAlso CaseInsensitiveComparison.Equals(token.ValueText, typeParameter.Identifier.ValueText) Then
conflicts.Add(reverseMappedLocations(typeParameter.Identifier.GetLocation()))
End If
Next
End If
' if the renamed symbol is a type member, it's name should not conflict 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.Equals(typeParameter.Name, renamedSymbol.Name) Then
Dim typeParameterToken = typeParameter.Locations.Single().FindToken(cancellationToken)
conflicts.Add(reverseMappedLocations(typeParameterToken.GetLocation()))
End If
Next
End If
Return Task.FromResult(Of IEnumerable(Of Location))(conflicts)
End Function
Public Function ComputeImplicitReferenceConflicts(renameSymbol As ISymbol, renamedSymbol As ISymbol, implicitReferenceLocations As IEnumerable(Of ReferenceLocation), cancellationToken As CancellationToken) As IEnumerable(Of Location) Implements IRenameRewriterLanguageService.ComputeImplicitReferenceConflicts
' Handle renaming of symbols used for foreach
Dim implicitReferencesMightConflict = renameSymbol.Kind = SymbolKind.Property AndAlso
CaseInsensitiveComparison.Equals(renameSymbol.Name, "Current")
implicitReferencesMightConflict = implicitReferencesMightConflict OrElse
(renameSymbol.Kind = SymbolKind.Method AndAlso
(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 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.Kind = SyntaxKind.ForKeyword AndAlso token.Parent.IsKind(SyntaxKind.ForEachStatement) Then
Return SpecializedCollections.SingletonEnumerable(DirectCast(token.Parent, ForEachStatementSyntax).Expression.GetLocation())
End If
Next
End If
End If
Return SpecializedCollections.EmptyEnumerable(Of Location)()
End Function
#End Region
''' <summary>
''' Gets the top most enclosing statement as target to call MakeExplicit on.
''' It's either the enclosing statement, or if this statement is inside of a lambda expression, the enclosing
''' statement of this lambda.
''' </summary>
''' <param name="token">The token to get the complexification target for.</param>
Public Function GetExpansionTargetForLocation(token As SyntaxToken) As SyntaxNode Implements IRenameRewriterLanguageService.GetExpansionTargetForLocation
Return GetExpansionTarget(token)
End Function
Private Shared Function GetExpansionTarget(token As SyntaxToken) As SyntaxNode
' get the directly enclosing statement
Dim enclosingStatement = token.FirstAncestorOrSelf(Function(n) TypeOf (n) Is ExecutableStatementSyntax)
' for nodes in a using, for or for each statement, we do not need the enclosing _executable_ statement, which is the whole block.
' it's enough to expand the using, for or foreach statement.
Dim possibleSpecialStatement = token.FirstAncestorOrSelf(Function(n) n.Kind = SyntaxKind.ForStatement OrElse
n.Kind = SyntaxKind.ForEachStatement OrElse
n.Kind = SyntaxKind.UsingStatement OrElse
n.Kind = SyntaxKind.CatchBlock)
If possibleSpecialStatement IsNot Nothing Then
If enclosingStatement Is possibleSpecialStatement.Parent Then
enclosingStatement = If(possibleSpecialStatement.Kind = SyntaxKind.CatchBlock,
DirectCast(possibleSpecialStatement, CatchBlockSyntax).CatchStatement,
possibleSpecialStatement)
End If
End If
' see if there's an enclosing lambda expression
Dim possibleLambdaExpression As SyntaxNode = Nothing
If enclosingStatement Is Nothing Then
possibleLambdaExpression = token.FirstAncestorOrSelf(Function(n) TypeOf (n) Is LambdaExpressionSyntax)
End If
Dim enclosingCref = token.FirstAncestorOrSelf(Function(n) TypeOf (n) Is CrefReferenceSyntax)
If enclosingCref IsNot Nothing Then
Return enclosingCref
End If
' there seems to be no statement above this one. Let's see if we can at least get an SimpleNameSyntax
Return If(enclosingStatement, If(possibleLambdaExpression, token.FirstAncestorOrSelf(Function(n) TypeOf (n) Is SimpleNameSyntax)))
End Function
#Region "Helper Methods"
Public Function IsIdentifierValid(replacementText As String, syntaxFactsService As ISyntaxFactsService) As Boolean Implements IRenameRewriterLanguageService.IsIdentifierValid
replacementText = SyntaxFacts.MakeHalfWidthIdentifier(replacementText)
Dim possibleIdentifier As String
If syntaxFactsService.IsTypeCharacter(replacementText.Last()) Then
' We don't allow to use identifiers with type characters
Return False
Else
If replacementText.StartsWith("[", StringComparison.Ordinal) AndAlso replacementText.EndsWith("]", StringComparison.Ordinal) Then
possibleIdentifier = replacementText
Else
possibleIdentifier = "[" & replacementText & "]"
End If
End If
' Make sure we got an identifier.
If Not syntaxFactsService.IsValidIdentifier(possibleIdentifier) Then
' We still don't have an identifier, so let's fail
Return False
End If
' This is a valid Identifier
Return True
End Function
Public Function ComputePossibleImplicitUsageConflicts(
renamedSymbol As ISymbol,
semanticModel As SemanticModel,
originalDeclarationLocation As Location,
newDeclarationLocationStartingPosition As Integer,
cancellationToken As CancellationToken) As IEnumerable(Of Location) Implements IRenameRewriterLanguageService.ComputePossibleImplicitUsageConflicts
' TODO: support other implicitly used methods like dispose
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
If DirectCast(renamedSymbol, IMethodSymbol).IsOverloads AndAlso
(renamedSymbol.GetAllTypeArguments().Length <> 0 OrElse
DirectCast(renamedSymbol, IMethodSymbol).Parameters.Length <> 0) Then
Return SpecializedCollections.EmptyEnumerable(Of Location)()
End If
End If
If TypeOf renamedSymbol Is IPropertySymbol Then
If DirectCast(renamedSymbol, IPropertySymbol).IsOverloads Then
Return SpecializedCollections.EmptyEnumerable(Of Location)()
End If
End If
' TODO: Partial methods currently only show the location where the rename happens As a conflict.
' Consider showing both locations as a conflict.
Dim baseType = renamedSymbol.ContainingType.GetBaseTypes().FirstOrDefault()
If baseType IsNot Nothing Then
Dim implicitSymbols = semanticModel.LookupSymbols(
newDeclarationLocationStartingPosition,
baseType,
renamedSymbol.Name) _
.Where(Function(sym) Not sym.Equals(renamedSymbol))
For Each symbol In implicitSymbols
If symbol.GetAllTypeArguments().Length <> 0 Then
Continue For
End If
If symbol.Kind = SymbolKind.Method Then
Dim method = DirectCast(symbol, IMethodSymbol)
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.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
Not method.Parameters.Any() Then
Return SpecializedCollections.SingletonEnumerable(originalDeclarationLocation)
End If
End If
ElseIf CaseInsensitiveComparison.Equals(symbol.Name, "Current") Then
Dim [property] = DirectCast(symbol, IPropertySymbol)
If Not [property].Parameters.Any() AndAlso Not [property].IsWriteOnly Then
Return SpecializedCollections.SingletonEnumerable(originalDeclarationLocation)
End If
End If
Next
End If
End If
Return SpecializedCollections.EmptyEnumerable(Of Location)()
End Function
Public Sub TryAddPossibleNameConflicts(symbol As ISymbol, replacementText As String, possibleNameConflicts As ICollection(Of String)) Implements IRenameRewriterLanguageService.TryAddPossibleNameConflicts
Dim halfWidthReplacementText = SyntaxFacts.MakeHalfWidthIdentifier(replacementText)
Const AttributeSuffix As String = "Attribute"
Const AttributeSuffixLength As Integer = 9
Debug.Assert(AttributeSuffixLength = AttributeSuffix.Length, "Assert (AttributeSuffixLength = AttributeSuffix.Length) failed.")
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)
End If
End If
If symbol.Kind = SymbolKind.Property Then
For Each conflict In {"_" + replacementText, "get_" + replacementText, "set_" + replacementText}
If Not possibleNameConflicts.Contains(conflict) Then
possibleNameConflicts.Add(conflict)
End If
Next
End If
' consider both versions of the identifier (escaped and unescaped)
Dim valueText = replacementText
Dim kind = SyntaxFacts.GetKeywordKind(replacementText)
If kind <> SyntaxKind.None Then
valueText = SyntaxFacts.GetText(kind)
Else
Dim name = SyntaxFactory.ParseName(replacementText)
If name.Kind = SyntaxKind.IdentifierName Then
valueText = DirectCast(name, IdentifierNameSyntax).Identifier.ValueText
End If
End If
If Not CaseInsensitiveComparison.Equals(valueText, replacementText) Then
possibleNameConflicts.Add(valueText)
End If
End Sub
''' <summary>
''' Gets the semantic model for the given node.
''' If the node belongs to the syntax tree of the original semantic model, then returns originalSemanticModel.
''' Otherwise, returns a speculative model.
''' The assumption for the later case is that span start position of the given node in it's syntax tree is same as
''' the span start of the original node in the original syntax tree.
''' </summary>
''' <param name="node"></param>
''' <param name="originalSemanticModel"></param>
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.
Return originalSemanticModel
End If
Dim syntax = node
Dim nodeToSpeculate = syntax.GetAncestorsOrThis(Of SyntaxNode).Where(Function(n) SpeculationAnalyzer.CanSpeculateOnNode(n)).LastOrDefault
If nodeToSpeculate Is Nothing Then
If syntax.IsKind(SyntaxKind.CrefReference) Then
nodeToSpeculate = DirectCast(syntax, CrefReferenceSyntax).Name
ElseIf syntax.IsKind(SyntaxKind.TypeConstraint) Then
nodeToSpeculate = DirectCast(syntax, TypeConstraintSyntax).Type
Else
Return Nothing
End If
End If
Dim isInNamespaceOrTypeContext = SyntaxFacts.IsInNamespaceOrTypeContext(TryCast(syntax, ExpressionSyntax))
Dim position = nodeToSpeculate.SpanStart
Return SpeculationAnalyzer.CreateSpeculativeSemanticModelForNode(nodeToSpeculate, DirectCast(originalSemanticModel, SemanticModel), position, isInNamespaceOrTypeContext)
End Function
#End Region
End Class
End Namespace
|
HellBrick/roslyn
|
src/Workspaces/VisualBasic/Portable/Rename/VisualBasicRenameRewriterLanguageService.vb
|
Visual Basic
|
apache-2.0
| 56,607
|
Imports System
Imports System.Windows.Controls
Imports ESRI.ArcGIS.Client
Imports System.Windows
Partial Public Class EditToolsExplicitSave
Inherits UserControl
Public Sub New()
InitializeComponent()
End Sub
Private Sub CancelEditsButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
Dim editor As Editor = TryCast(LayoutRoot.Resources("MyEditor"), Editor)
For Each graphicsLayer As GraphicsLayer In editor.GraphicsLayers
If TypeOf graphicsLayer Is FeatureLayer Then
Dim featureLayer As FeatureLayer = TryCast(graphicsLayer, FeatureLayer)
If featureLayer.HasEdits Then
featureLayer.Update()
End If
End If
Next graphicsLayer
End Sub
End Class
|
Esri/arcgis-samples-silverlight
|
src/VBNet/ArcGISSilverlightSDK/Editing/EditToolsExplicitSave.xaml.vb
|
Visual Basic
|
apache-2.0
| 695
|
'*******************************************************************************************'
' '
' Download Free Evaluation Version From: https://bytescout.com/download/web-installer '
' '
' Also available as Web API! Get free API Key https://app.pdf.co/signup '
' '
' Copyright © 2017-2020 ByteScout, Inc. All rights reserved. '
' https://www.bytescout.com '
' https://www.pdf.co '
'*******************************************************************************************'
Imports Bytescout.PDF
''' <summary>
''' This example demonstrates how to flatten a filled PDF form (make it uneditable).
''' </summary>
Class Program
Shared Sub Main()
' Load filled PDF form
Dim pdfDocument = New Document("filled_form.pdf")
pdfDocument.RegistrationName = "demo"
pdfDocument.RegistrationKey = "demo"
' Flatten the form
pdfDocument.FlattenDocument()
' Save modified document
pdfDocument.Save("result.pdf")
' Cleanup
pdfDocument.Dispose()
' Open document in default PDF viewer app
Process.Start("result.pdf")
End Sub
End Class
|
bytescout/ByteScout-SDK-SourceCode
|
Premium Suite/VB.NET/Flatten pdf form with pdf sdk/Program.vb
|
Visual Basic
|
apache-2.0
| 1,616
|
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports Microsoft.CodeAnalysis.EditAndContinue
Namespace Microsoft.CodeAnalysis.VisualBasic.EditAndContinue.UnitTests
Public Class ActiveStatementTests
Inherits RudeEditTestBase
<Fact>
Public Sub Update_Inner()
Dim src1 = "
Class C
Shared Sub Main()
<AS:1>Foo(1)</AS:1>
End Sub
Shared Sub Foo(a As Integer)
<AS:0>Console.WriteLine(a)</AS:0>
End Sub
End Class
"
Dim src2 = "
Class C
Shared Sub Main()
While True
<AS:1>Foo(2)</AS:1>
End While
End Sub
Shared Sub Foo(a As Integer)
<AS:0>Console.WriteLine(a)</AS:0>
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.ActiveStatementUpdate, "Foo(2)"))
End Sub
<Fact>
Public Sub Update_Leaf()
Dim src1 = "
Class C
Shared Sub Main()
<AS:1>Foo(1)</AS:1>
End Sub
Shared Sub Foo(a As Integer)
<AS:0>Console.WriteLine(a)</AS:0>
End Sub
End Class
"
Dim src2 = "
Class C
Shared Sub Main()
While True
<AS:1>Foo(1)</AS:1>
End While
End Sub
Shared Sub Foo(a As Integer)
<AS:0>Console.WriteLine(a + 1)</AS:0>
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact>
Public Sub Update_Leaf_NewCommentAtEndOfActiveStatement()
Dim src1 = "
Class C
Shared Sub Main()
<AS:1>Foo(1)</AS:1>
End Sub
Shared Sub Foo(a As Integer)
<AS:0>Console.WriteLine(a)</AS:0>
End Sub
End Class
"
Dim src2 = "
Class C
Shared Sub Main()
<AS:1>Foo(1)</AS:1>
End Sub
Shared Sub Foo(a As Integer)
<AS:0>Console.WriteLine(a)</AS:0>'comment
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact>
Public Sub Update_Inner_NewCommentAtEndOfActiveStatement()
Dim src1 = "
Class C
Shared Sub Main()
<AS:1>Foo(1)</AS:1>
End Sub
Shared Sub Foo(a As Integer)
<AS:0>Console.WriteLine(a)</AS:0>
End Sub
End Class
"
Dim src2 = "
Class C
Shared Sub Main()
<AS:1>Foo(1)</AS:1>' comment
End Sub
Shared Sub Foo(a As Integer)
<AS:0>Console.WriteLine(a)</AS:0>
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact>
Public Sub Headers()
Dim src1 = "
Class C
Property P(a As Integer) As Integer
<AS:7>Get</AS:7>
<AS:0>Me.value = a</AS:0>
<AS:8>End Get</AS:8>
<AS:9>Set(value As Integer)</AS:9>
<AS:1>Me.value = a</AS:1>
<AS:10>End Set</AS:10>
End Property
Custom Event E As Action
<AS:11>AddHandler(value As Action)</AS:11>
<AS:2>Me.value = a</AS:2>
<AS:12>End AddHandler</AS:12>
<AS:13>RemoveHandler(value As Action)</AS:13>
<AS:3>Me.value = a</AS:3>
<AS:14>End RemoveHandler</AS:14>
<AS:15>RaiseEvent()</AS:15>
<AS:4>Me.value = a</AS:4>
<AS:16>End RaiseEvent</AS:16>
End Event
<AS:17>Shared Operator &(a As C, b As C) As C</AS:17>
<AS:5>Me.value = a</AS:5>
<AS:18>End Operator</AS:18>
<AS:19>Sub New(a As C, b As C)</AS:19>
<AS:6>Me.value = a</AS:6>
<AS:20>End Sub</AS:20>
<AS:21>Sub F(a As C, b As C)</AS:21>
<AS:22>Me.value = a</AS:22>
<AS:23>End Sub</AS:23>
<AS:24>Function F(a As C, b As C) As Integer</AS:24>
<AS:25>Me.value = a</AS:25>
Return 0
<AS:26>End Function</AS:26>
End Class
"
Dim src2 = "
Class C
Property P(a As Integer) As Integer
<AS:7>Get</AS:7>
<AS:0>Me.value = a*1</AS:0>
<AS:8>End Get</AS:8>
<AS:9>Set(value As Integer)</AS:9>
<AS:1>Me.value = a*2</AS:1>
<AS:10>End Set</AS:10>
End Property
Custom Event E As Action
<AS:11>AddHandler(value As Action)</AS:11>
<AS:2>Me.value = a*3</AS:2>
<AS:12>End AddHandler</AS:12>
<AS:13>RemoveHandler(value As Action)</AS:13>
<AS:3>Me.value = a*4</AS:3>
<AS:14>End RemoveHandler</AS:14>
<AS:15>RaiseEvent()</AS:15>
<AS:4>Me.value = a*5</AS:4>
<AS:16>End RaiseEvent</AS:16>
End Event
<AS:17>Shared Operator &(a As C, b As C) As C</AS:17>
<AS:5>Me.value = a*6</AS:5>
<AS:18>End Operator</AS:18>
<AS:19>Sub New(a As C, b As C)</AS:19>
<AS:6>Me.value = a*7</AS:6>
<AS:20>End Sub</AS:20>
<AS:21>Sub F(a As C, b As C)</AS:21>
<AS:22>Me.value = a*8</AS:22>
<AS:23>End Sub</AS:23>
<AS:24>Function F(a As C, b As C) As Integer</AS:24>
<AS:25>Me.value = a*8</AS:25>
<AS:26>End Function</AS:26>
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.ActiveStatementUpdate, "Me.value = a*6"),
Diagnostic(RudeEditKind.ActiveStatementUpdate, "Me.value = a*7"),
Diagnostic(RudeEditKind.ActiveStatementUpdate, "Me.value = a*8"),
Diagnostic(RudeEditKind.ActiveStatementUpdate, "Me.value = a*8"),
Diagnostic(RudeEditKind.ActiveStatementUpdate, "Me.value = a*2"),
Diagnostic(RudeEditKind.ActiveStatementUpdate, "Me.value = a*3"),
Diagnostic(RudeEditKind.ActiveStatementUpdate, "Me.value = a*4"),
Diagnostic(RudeEditKind.ActiveStatementUpdate, "Me.value = a*5"))
End Sub
#Region "Delete"
<Fact>
Public Sub Delete_Leaf_Method()
Dim src1 = "
Class C
Shared Sub Main()
<AS:1>Foo(1)</AS:1>
End Sub
Shared Sub Foo(a As Integer)
<AS:0>Console.WriteLine(a)</AS:0>
End Sub
End Class
"
Dim src2 = "
<AS:0>Class C</AS:0>
Shared Sub Main()
<AS:1>Foo(1)</AS:1>
End Sub
End Class
"
' TODO (bug 755959): better deleted active statement span
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.Delete, "Class C", FeaturesResources.Method))
End Sub
<Fact>
Public Sub Delete_All_SourceText()
Dim src1 = "
Class C
Shared Sub Main()
<AS:1>Foo(1)</AS:1>
End Sub
Shared Sub Foo(a As Integer)
<AS:0>Console.WriteLine(a)</AS:0>
End Sub
End Class
"
Dim src2 = ""
Dim edits = GetTopEdits(src1, src2)
edits.VerifyRudeDiagnostics(
Diagnostic(RudeEditKind.Delete, Nothing, FeaturesResources.Class))
End Sub
<Fact, WorkItem(755959, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/755959")>
Public Sub Delete_Inner()
Dim src1 = "
Class C
Shared Sub Main()
<AS:1>Foo(1)</AS:1>
End Sub
Shared Sub Foo(a As Integer)
<AS:0>Console.WriteLine(a)</AS:0>
End Sub
End Class
"
Dim src2 = "
Class C
Shared Sub Main()
While True
End While
<AS:1>End Sub</AS:1>
Shared Sub Foo(a As Integer)
<AS:0>Console.WriteLine(a)</AS:0>
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.DeleteActiveStatement, "Shared Sub Main()"))
End Sub
<Fact, WorkItem(755959, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/755959")>
Public Sub Delete_Inner_MultipleParents()
Dim src1 = "
Class C
Shared Sub Main()
Do
<AS:1>Foo(1)</AS:1>
Loop
If True
<AS:2>Foo(2)</AS:2>
Else
<AS:3>Foo(3)</AS:3>
End If
Dim x As Integer = 1
Select Case x
Case 1, 2
<AS:4>Foo(4)</AS:4>
Case Else
<AS:5>Foo(5)</AS:5>
End Select
While True
<AS:6>Foo(4)</AS:6>
End While
Do Until True
<AS:7>Foo(7)</AS:7>
Loop
If True Then <AS:8>Foo(8)</AS:8> Else <AS:9>Foo(9)</AS:9>
For i = 0 To 10 : <AS:10>Foo(10)</AS:10> : Next
For Each i in {1, 2} : <AS:11>Foo(11)</AS:11> : Next
Using z = new C() : <AS:12>Foo(12)</AS:12> : End Using
With expr
<AS:13>.Bar = Foo(13)</AS:13>
End With
<AS:14>label:</AS:14>
Console.WriteLine(1)
SyncLock Nothing : <AS:15>Foo(15)</AS:15> : End SyncLock
End Sub
Shared Sub Foo(a As Integer)
<AS:0>Console.WriteLine(a)</AS:0>
End Sub
End Class
"
Dim src2 = "
Class C
Shared Sub Main()
Do
<AS:1>Loop</AS:1>
<AS:2>If True</AS:2>
<AS:3>Else</AS:3>
End If
Dim x As Integer = 1
Select Case x
<AS:4>Case 1, 2</AS:4>
<AS:5>Case Else</AS:5>
End Select
While True
<AS:6>End While</AS:6>
Do Until True
<AS:7>Loop</AS:7>
<AS:8>If True Then</AS:8> <AS:9>Else</AS:9>
For i = 0 To 10 : <AS:10>Next</AS:10>
For Each i In {1, 2} : <AS:11>Next</AS:11>
Using z = New C() : <AS:12>End Using</AS:12>
With expr
<AS:13>End With</AS:13>
<AS:14>Console.WriteLine(1)</AS:14>
SyncLock Nothing : <AS:15>End SyncLock</AS:15>
End Sub
Shared Sub Foo(a As Integer)
<AS:0>Console.WriteLine(a)</AS:0>
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.DeleteActiveStatement, "Do"),
Diagnostic(RudeEditKind.DeleteActiveStatement, "If True"),
Diagnostic(RudeEditKind.DeleteActiveStatement, "Else"),
Diagnostic(RudeEditKind.DeleteActiveStatement, "Case 1, 2"),
Diagnostic(RudeEditKind.DeleteActiveStatement, "Case Else"),
Diagnostic(RudeEditKind.DeleteActiveStatement, "While True"),
Diagnostic(RudeEditKind.DeleteActiveStatement, "Do Until True"),
Diagnostic(RudeEditKind.DeleteActiveStatement, "If True Then"),
Diagnostic(RudeEditKind.DeleteActiveStatement, "Else"),
Diagnostic(RudeEditKind.DeleteActiveStatement, "For i = 0 To 10"),
Diagnostic(RudeEditKind.DeleteActiveStatement, "For Each i In {1, 2}"),
Diagnostic(RudeEditKind.DeleteActiveStatement, "Using z = New C()"),
Diagnostic(RudeEditKind.DeleteActiveStatement, "With expr"),
Diagnostic(RudeEditKind.DeleteActiveStatement, "Shared Sub Main()"),
Diagnostic(RudeEditKind.DeleteActiveStatement, "SyncLock Nothing"))
End Sub
<Fact>
Public Sub Delete_Inner_ElseIf1()
Dim src1 = <![CDATA[
Class C
Shared Sub Main()
If c1 Then
Console.WriteLine(1)
<AS:1>ElseIf c2 Then</AS:1>
Console.WriteLine(2)
ElseIf c3 Then
Console.WriteLine(3)
End If
End Sub
Shared Sub Foo(a As Integer)
<AS:0>Console.WriteLine(a)</AS:0>
End Sub
End Class
]]>.Value
Dim src2 = <![CDATA[
Class C
Shared Sub Main()
If c1 Then
Console.WriteLine(1)
<AS:1>ElseIf c3 Then</AS:1>
Console.WriteLine(3)
End If
End Sub
Shared Sub Foo(a As Integer)
<AS:0>Console.WriteLine(a)</AS:0>
End Sub
End Class
]]>.Value
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.DeleteActiveStatement, "If c1 Then"))
End Sub
<Fact>
Public Sub Delete_Inner_ElseIf2()
Dim src1 = <![CDATA[
Class C
Shared Sub Main()
If c1 Then
Console.WriteLine(1)
<AS:1>ElseIf c2 Then</AS:1>
Console.WriteLine(2)
End If
End Sub
Shared Sub Foo(a As Integer)
<AS:0>Console.WriteLine(a)</AS:0>
End Sub
End Class
]]>.Value
Dim src2 = <![CDATA[
Class C
Shared Sub Main()
If c1 Then
Console.WriteLine(1)
<AS:1>End If</AS:1>
End Sub
Shared Sub Foo(a As Integer)
<AS:0>Console.WriteLine(a)</AS:0>
End Sub
End Class
]]>.Value
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.DeleteActiveStatement, "If c1 Then"))
End Sub
<Fact, WorkItem(755959, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/755959")>
Public Sub Delete_Leaf()
Dim src1 = "
Class C
Sub Main()
<AS:1>Foo(1)</AS:1>
End Sub
Sub Foo(a As Integer)
<AS:0>Console.WriteLine(a)</AS:0>
End Sub
End Class
"
Dim src2 = "
Class C
Sub Main()
<AS:1>Foo(1)</AS:1>
End Sub
Sub Foo(a As Integer)
<AS:0>End Sub</AS:0>
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact, WorkItem(755959, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/755959")>
Public Sub Delete_Leaf_InTry()
Dim src1 = "
Class C
Sub Main()
<AS:1>Foo(1)</AS:1>
End Sub
Sub Foo(a As Integer)
Try
<AS:0>Console.WriteLine(a)</AS:0>
Catch
End Try
End Sub
End Class
"
Dim src2 = "
Class C
Sub Main()
<AS:1>Foo(1)</AS:1>
End Sub
Sub Foo(a As Integer)
<AS:0>Try</AS:0>
Catch
End Try
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact, WorkItem(755959, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/755959")>
Public Sub Delete_Leaf_InTry2()
Dim src1 = "
Class C
Sub Main()
<AS:1>Foo(1)</AS:1>
End Sub
Sub Foo(a As Integer)
Try
Try
<AS:0>Console.WriteLine(a)</AS:0>
Catch
End Try
Catch
End Try
End Sub
End Class
"
Dim src2 = "
Class C
Sub Main()
<AS:1>Foo(1)</AS:1>
End Sub
Sub Foo(a As Integer)
<AS:0>Try</AS:0>
Catch
End Try
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact, WorkItem(755959, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/755959")>
Public Sub Delete_Inner_CommentActiveStatement()
Dim src1 = "
Class C
Sub Main()
<AS:1>Foo(1)</AS:1>
End Sub
Sub Foo(a As Integer)
<AS:0>Console.WriteLine(a)</AS:0>
End Sub
End Class
"
Dim src2 = "
Class C
Sub Main()
'Foo(1)
<AS:1>End Sub</AS:1>
Sub Foo(a As Integer)
<AS:0>Console.WriteLine(a)</AS:0>
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.DeleteActiveStatement, "Sub Main()"))
End Sub
<Fact, WorkItem(755959, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/755959")>
Public Sub Delete_Leaf_CommentActiveStatement()
Dim src1 = "
Class C
Sub Main()
<AS:1>Foo(1)</AS:1>
End Sub
Sub Foo(a As Integer)
<AS:0>Console.WriteLine(a)</AS:0>
End Sub
End Class
"
Dim src2 = "
Class C
Sub Main()
<AS:1>Foo(1)</AS:1>
End Sub
Sub Foo(a As Integer)
'Console.WriteLine(a)
<AS:0>End Sub</AS:0>
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact>
Public Sub Delete_EntireNamespace()
Dim src1 = "
Module Module1
Sub Main()
<AS:0>Console.WriteLine(0)</AS:0>
End Sub
End Module
"
Dim src2 = "<AS:0></AS:0>"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.Delete, Nothing, "module"))
End Sub
#End Region
#Region "Constructors"
<Fact>
Public Sub Updated_Inner_Constructor()
Dim src1 = "
Class Program
Shared Sub Main()
Dim <AS:1>f As Foo = New Foo(5)</AS:1>
End Sub
End Class
Class Foo
Dim value As Integer
Sub New(a As Integer)
<AS:0>Me.value = a</AS:0>
End Sub
End Class
"
Dim src2 = "
Class Program
Shared Sub Main()
Dim <AS:1>f As Foo = New Foo(5*2)</AS:1>
End Sub
End Class
Class Foo
Dim value As Integer
Sub New(a As Integer)
<AS:0>Me.value = a</AS:0>
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.ActiveStatementUpdate, "f As Foo = New Foo(5*2)"))
End Sub
<WorkItem(741249, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/741249")>
<Fact>
Public Sub Updated_Leaf_Constructor()
Dim src1 = "
Class Program
Shared Sub Main()
Dim <AS:1>f As Foo = New Foo(5)</AS:1>
End Sub
End Class
Class Foo
Dim value As Integer
Sub New(a As Integer)
<AS:0>Me.value = a</AS:0>
End Sub
End Class
"
Dim src2 = "
Class Program
Shared Sub Main()
Dim <AS:1>f As Foo = New Foo(5)</AS:1>
End Sub
End Class
Class Foo
Dim value As Integer
Sub New(a As Integer)
<AS:0>Me.value = a*2</AS:0>
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact>
Public Sub Updated_Leaf_Constructor_Parameter()
Dim src1 = "
Class Program
Shared Sub Main()
Dim <AS:1>f = new Foo(5)</AS:1>
End Sub
End Class
Class Foo
Dim value As Integer
<AS:0>Public Sub New(Optional a As Integer = 1)</AS:0>
Me.value = a
End Sub
End Class
"
Dim src2 = "
Class Program
Shared Sub Main()
Dim <AS:1>f = new Foo(5)</AS:1>
End Sub
End Class
Class Foo
Dim value As Integer
<AS:0>Public Sub New(Optional a As Integer = 2)</AS:0>
Me.value = a
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.InitializerUpdate, "Optional a As Integer = 2", FeaturesResources.Parameter))
End Sub
<Fact>
Public Sub Updated_Leaf_Constructor_Parameter_DefaultValue()
Dim src1 = "
Class Foo
Dim value As Integer
Shared Sub Main()
Dim <AS:1>f = new Foo(5)</AS:1>
End Sub
<AS:0>Sub New(Optional a As Integer = 5)</AS:0>
Me.value = a
End Sub
End Class
"
Dim src2 = "
Class Foo
Dim value As Integer
Shared Sub Main()
Dim <AS:1>f = new Foo(5)</AS:1>
End Sub
<AS:0>Sub New(Optional a As Integer = 42)</AS:0>
Me.value = a
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.InitializerUpdate, "Optional a As Integer = 42", FeaturesResources.Parameter))
End Sub
<WorkItem(742334, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/742334")>
<Fact>
Public Sub Updated_Leaf_ConstructorChaining1()
Dim src1 = "
Class B
Inherits A
Sub Main
Dim <AS:1>b = new B(2, 3)</AS:1>
End Sub
Sub New(x As Integer, y As Integer)
<AS:0>MyBase.New(x + y, x - y)</AS:0>
End Sub
End Class
"
Dim src2 = "
Class B
Inherits A
Sub Main
Dim <AS:1>b = new B(2, 3)</AS:1>
End Sub
Sub New(x As Integer, y As Integer)
<AS:0>MyBase.New(x + y, x - y + 5)</AS:0>
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<WorkItem(742334, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/742334")>
<Fact>
Public Sub Updated_Leaf_ConstructorChaining2()
Dim src1 = "
Class Test
Sub Main()
Dim <AS:2>b = new B(2, 3)</AS:2>
End Sub
End Class
Class B
Inherits A
Sub New(x As Integer, y As Integer)
<AS:1>MyBase.New(x + y, x - y)</AS:1>
End Sub
End Class
Class A
Sub New(x As Integer, y As Integer)
<AS:0>Me.New(x, y, 0)</AS:0>
End Sub
Sub New(x As Integer, y As Integer, z As Integer) : End Sub
End Class
"
Dim src2 = "
Class Test
Sub Main()
Dim <AS:2>b = new B(2, 3)</AS:2>
End Sub
End Class
Class B
Inherits A
Sub New(x As Integer, y As Integer)
<AS:1>MyBase.New(x + y, x - y)</AS:1>
End Sub
End Class
Class A
Sub New(x As Integer, y As Integer)
<AS:0>Me.New(5 + x, y, 0)</AS:0>
End Sub
Sub New(x As Integer, y As Integer, z As Integer) : End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact>
Public Sub InstanceConstructorWithoutInitializer()
Dim src1 = "
Class C
Dim a As Integer = 5
<AS:0>Public Sub New(a As Integer)</AS:0>
End Sub
Sub Main()
Dim <AS:1>c = new C(3)</AS:1>
End Sub
End Class
"
Dim src2 = "
Class C
Dim a As Integer = 42
<AS:0>Public Sub New(a As Integer)</AS:0>
End Sub
Sub Main()
Dim <AS:1>c = new C(3)</AS:1>
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact>
Public Sub InstanceConstructorWithInitializer_Internal_Update1()
Dim src1 = "
Class C
Sub New(a As Integer)
<AS:2>MyClass.New(True)</AS:2>
End Sub
Sub New(b As Boolean)
<AS:1>MyBase.New(F())</AS:1>
End Sub
Shared Function F() As Integer
<AS:0>Return 1</AS:0>
End Function
Sub Main()
Dim <AS:3>c As C = New C(3)</AS:3>
End Sub
End Class
"
Dim src2 = "
Class C
Sub New(a As Integer)
<AS:2>MyClass.New(False)</AS:2>
End Sub
Sub New(b As Boolean)
<AS:1>MyBase.New(F())</AS:1>
End Sub
Shared Function F() As Integer
<AS:0>Return 1</AS:0>
End Function
Sub Main()
Dim <AS:3>c As C = New C(3)</AS:3>
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.ActiveStatementUpdate, "MyClass.New(False)"))
End Sub
<Fact>
Public Sub InstanceConstructorWithInitializer_Leaf_Update1()
Dim src1 = "
Class C
Public Sub New()
<AS:0>MyBase.New(1)</AS:0>
End Sub
Sub Main
Dim <AS:1>c = New C()</AS:1>
End Sub
End Class
"
Dim src2 = "
Class C
Public Sub New()
<AS:0>MyBase.New(2)</AS:0>
End Sub
Sub Main
Dim <AS:1>c = New C()</AS:1>
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact, WorkItem(755959, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/755959")>
Public Sub InstanceConstructorWithInitializer_Leaf_DeleteBaseCall()
Dim src1 = "
Class C
Sub New()
<AS:0>MyBase.New(2)</AS:0>
End Sub
Sub Main
Dim <AS:1>c = New C()</AS:1>
End Sub
End Class
"
Dim src2 = "
Class C
Sub New()
<AS:0>End Sub</AS:0>
Sub Main
Dim <AS:1>c = New C()</AS:1>
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact>
Public Sub InstanceConstructorWithInitializer_Leaf_InsertBaseCall()
Dim src1 = "
Class C
<AS:0>Public Sub New</AS:0>
End Sub
Sub Main
Dim <AS:1>c = new C()</AS:1>
End Sub
End Class
"
Dim src2 = "
Class C
<AS:0>Public Sub New</AS:0>
MyBase.New(2)
End Sub
Sub Main
Dim <AS:1>c = new C()</AS:1>
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
#End Region
#Region "Initializers"
<Fact, WorkItem(836523, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/836523")>
Public Sub Initializer_Unedited_Init()
Dim src1 = "
Class C
Dim <AS:0>a As Integer = 1</AS:0>
Sub Main
Dim <AS:1>b = 0</AS:1>
End Sub
End Class
"
Dim src2 = "
Class C
Dim <AS:0>a As Integer = 1</AS:0>
Sub Main
Dim <AS:1>b = 0</AS:1>
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact, WorkItem(836523, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/836523")>
Public Sub Initializer_Unedited_AsNew()
Dim src1 = "
Class C
Dim <AS:0>a As New Integer</AS:0>
Sub Main
Dim <AS:1>b = 0</AS:1>
End Sub
End Class
"
Dim src2 = "
Class C
Dim <AS:0>a As New Integer</AS:0>
Sub Main
Dim <AS:1>b = 0</AS:1>
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact, WorkItem(836523, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/836523")>
Public Sub Initializer_Unedited_SharedAsNew()
Dim src1 = "
Class C
Dim <AS:0>a</AS:0>, b, c As New Integer
Sub Main
Dim <AS:1>b = 0</AS:1>
End Sub
End Class
"
Dim src2 = "
Class C
Dim <AS:0>a</AS:0>, b, c As New Integer
Sub Main
Dim <AS:1>b = 0</AS:1>
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact, WorkItem(836523, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/836523")>
Public Sub Initializer_Unedited_PropertyInitializer()
Dim src1 = "
Class C
Property <AS:0>P As Integer = 1</AS:0>
Sub Main
Dim <AS:1>b = 0</AS:1>
End Sub
End Class
"
Dim src2 = "
Class C
Property <AS:0>P As Integer = 1</AS:0>
Sub Main
Dim <AS:1>b = 0</AS:1>
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact, WorkItem(836523, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/836523")>
Public Sub Initializer_Unedited_PropertyInitializerUntyped()
Dim src1 = "
Class C
Property <AS:0>P = 1</AS:0>
Sub Main
Dim <AS:1>b = 0</AS:1>
End Sub
End Class
"
Dim src2 = "
Class C
Property <AS:0>P = 1</AS:0>
Sub Main
Dim <AS:1>b = 0</AS:1>
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact, WorkItem(836523, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/836523")>
Public Sub Initializer_Unedited_PropertyAsNewInitializer()
Dim src1 = "
Class C
Property <AS:0>P As New C()</AS:0>
Sub Main
Dim <AS:1>b = 0</AS:1>
End Sub
End Class
"
Dim src2 = "
Class C
Property <AS:0>P As New C()</AS:0>
Sub Main
Dim <AS:1>b = 0</AS:1>
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact, WorkItem(836523, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/836523")>
Public Sub Initializer_Unedited_ArrayInitializer_Untyped()
Dim src1 = "
Class C
Dim <AS:0>A(10)</AS:0>
Sub Main
Dim <AS:1>A(10)</AS:1>
End Sub
End Class
"
Dim src2 = "
Class C
Dim <AS:0>A(10)</AS:0>
Sub Main
Dim <AS:1>A(10)</AS:1>
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact, WorkItem(836523, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/836523")>
Public Sub Initializer_Unedited_ArrayInitializer_Typed()
Dim src1 = "
Class C
Dim <AS:0>A(10)</AS:0>, B(2) As Integer
Sub Main
Dim <AS:1>A(10)</AS:1>, B(2) As Integer
End Sub
End Class
"
Dim src2 = "
Class C
Dim <AS:0>A(10)</AS:0>, B(2) As Integer
Sub Main
Dim <AS:1>A(10)</AS:1>, B(2) As Integer
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact>
Public Sub InstancePropertyInitializer_Update()
Dim src1 = "
Class C
Property <AS:0>P As Integer = 1</AS:0>
Sub Main
Dim <AS:1>c = New C()</AS:1>
End Sub
End Class
"
Dim src2 = "
Class C
Property <AS:0>P As Integer = 2</AS:0>
Sub Main
Dim <AS:1>c = New C()</AS:1>
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact>
Public Sub InstancePropertyAsNewInitializer_Update()
Dim src1 = "
Class C
Property <AS:0>P As New C(1)</AS:0>
Sub Main
Dim <AS:1>c = New C()</AS:1>
End Sub
End Class
"
Dim src2 = "
Class C
Property <AS:0>P As New C(2)</AS:0>
Sub Main
Dim <AS:1>c = New C()</AS:1>
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact>
Public Sub InstancePropertyInitializer_Delete()
Dim src1 = "
Class C
<AS:0>Property P As Integer = 1</AS:0>
Sub Main
Dim <AS:1>c = New C()</AS:1>
End Sub
End Class
"
Dim src2 = "
Class C
<AS:0>Property P As Integer</AS:0>
Sub Main
Dim <AS:1>c = New C()</AS:1>
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact, WorkItem(815933, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/815933")>
Public Sub Initializer_Update1()
Dim src1 = "
Class C
Dim <AS:0>a = 1</AS:0>, b = 2
Sub Main
Dim <AS:1>c = 1</AS:1>, d = 2
End Sub
End Class
"
Dim src2 = "
Class C
Dim <AS:0>a = 2</AS:0>, b = 2
Sub Main
Dim <AS:1>c = 2</AS:1>, d = 2
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.ActiveStatementUpdate, "c = 2"))
End Sub
<Fact, WorkItem(815933, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/815933")>
Public Sub Initializer_Update2()
Dim src1 = "
Class C
Dim a = 1, <AS:0>b = 2</AS:0>
Sub Main
Dim c = 1, <AS:1>d = 2</AS:1>
End Sub
End Class
"
Dim src2 = "
Class C
Dim a = 1, <AS:0>b = 3</AS:0>
Sub Main
Dim c = 1, <AS:1>d = 3</AS:1>
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.ActiveStatementUpdate, "d = 3"))
End Sub
<Fact, WorkItem(815933, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/815933")>
Public Sub FieldInitializer_AsNewToInit()
Dim src1 = "
Class C
Dim <AS:0>a As New Integer</AS:0>
Sub Main
Dim <AS:1>b As New Integer</AS:1>
End Sub
End Class
"
Dim src2 = "
Class C
Dim <AS:0>a = 0</AS:0>
Sub Main
Dim <AS:1>b = 0</AS:1>
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.ActiveStatementUpdate, "b = 0"))
End Sub
<Fact>
Public Sub PropertyInitializer_AsNewToInit()
Dim src1 = "
Class C
Property <AS:0>P As New Integer()</AS:0>
End Class
"
Dim src2 = "
Class C
Property <AS:0>P As Integer = 0</AS:0>
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.Insert, "As Integer", VBFeaturesResources.AsClause))
End Sub
<Fact, WorkItem(815933, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/815933")>
Public Sub Initializer_InitToAsNew()
Dim src1 = "
Class C
Dim <AS:0>a = 0</AS:0>
Sub Main
Dim <AS:1>b = 0</AS:1>
End Sub
End Class
"
Dim src2 = "
Class C
Dim <AS:0>a As New Integer</AS:0>
Sub Main
Dim <AS:1>b As New Integer</AS:1>
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.ActiveStatementUpdate, "b As New Integer"))
End Sub
<Fact, WorkItem(815933, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/815933")>
Public Sub Initializer_AsNewMulti_Update1()
Dim src1 = "
Class C
Dim <AS:0>a</AS:0>, b As New D(1)
Sub Main
Dim <AS:1>c</AS:1>, d As New D(1)
End Sub
End Class
"
Dim src2 = "
Class C
Dim <AS:0>a</AS:0>, b As New D(2)
Sub Main
Dim <AS:1>c</AS:1>, d As New D(2)
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.ActiveStatementUpdate, "c"))
End Sub
<Fact, WorkItem(815933, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/815933")>
Public Sub Initializer_AsNewMulti_Update2()
Dim src1 = "
Class C
Dim a, <AS:0>b</AS:0> As New D(1)
Sub Main
Dim c, <AS:1>d</AS:1> As New D(1)
End Sub
End Class
"
Dim src2 = "
Class C
Dim a, <AS:0>b</AS:0> As New D(2)
Sub Main
Dim c, <AS:1>d</AS:1> As New D(2)
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.ActiveStatementUpdate, "d"))
End Sub
<Fact, WorkItem(815933, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/815933")>
Public Sub Initializer_AsNewMulti_Update3()
Dim src1 = "
Class C
Private <AS:0>a As New D(1)</AS:0>
Private <AS:1>e As New D(1)</AS:1>
Sub Main
Dim <AS:2>c As New D(1)</AS:2>
End Sub
End Class
"
Dim src2 = "
Class C
Private <AS:0>a</AS:0>, b As New D(2)
Private <AS:1>e</AS:1>, f As New D(2)
Sub Main
Dim <AS:2>c</AS:2>, d As New D(2)
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.ActiveStatementUpdate, "c"),
Diagnostic(RudeEditKind.ActiveStatementUpdate, "e"))
End Sub
<Fact, WorkItem(815933, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/815933")>
Public Sub Initializer_AsNewMulti_Update4()
Dim src1 = "
Class C
Private <AS:0>a</AS:0>, b As New D(1)
Private <AS:1>e</AS:1>, f As New D(1)
Sub Main
Dim <AS:2>c</AS:2>, d As New D(1)
End Sub
End Class
"
Dim src2 = "
Class C
Private <AS:0>a As New D(2)</AS:0>
Private <AS:1>e As New D(2)</AS:1>
Sub Main
Dim <AS:2>c As New D(2)</AS:2>
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.ActiveStatementUpdate, "c As New D(2)"),
Diagnostic(RudeEditKind.ActiveStatementUpdate, "e As New D(2)"),
Diagnostic(RudeEditKind.Delete, "a As New D(2)", FeaturesResources.Field),
Diagnostic(RudeEditKind.Delete, "e As New D(2)", FeaturesResources.Field))
End Sub
<Fact>
Public Sub Initializer_AsNewMulti_WithLambda1()
Dim src1 = "
Class C
Private a As New D(Function() <AS:0>1</AS:0>)
End Class
"
Dim src2 = "
Class C
Private a As New D(Function() <AS:0>2</AS:0>)
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact, WorkItem(815933, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/815933")>
Public Sub Initializer_AsNewMulti_WithLambda2()
Dim src1 = "
Class C
Private a As New D(1, <AS:0>Sub()</AS:0>
End Sub)
End Class
"
Dim src2 = "
Class C
Private a As New D(2, <AS:0>Sub()</AS:0>
End Sub)
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact>
Public Sub Initializer_AsNewMulti_WithLambda3()
Dim src1 = "
Class C
Private a, b As New D(Function() <AS:0>1</AS:0>)
End Class
"
Dim src2 = "
Class C
Private a, b As New D(Function() <AS:0>2</AS:0>)
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact, WorkItem(849649, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/849649")>
Public Sub Initializer_Array_Update1()
Dim src1 = "
Class C
Dim <AS:0>a(1)</AS:0>, b(1) As Integer
Sub Main
Dim <AS:1>c(1)</AS:1>, d(1) As Integer
End Sub
End Class
"
Dim src2 = "
Class C
Dim <AS:0>a(2)</AS:0>, b(1) As Integer
Sub Main
Dim <AS:1>c(2)</AS:1>, d(1) As Integer
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.ActiveStatementUpdate, "c(2)"))
End Sub
<Fact, WorkItem(849649, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/849649")>
Public Sub Initializer_Array_Update2()
Dim src1 = "
Class C
Dim a(1), <AS:0>b(1)</AS:0> As Integer
Sub Main
Dim c(1), <AS:1>d(1)</AS:1> As Integer
End Sub
End Class
"
Dim src2 = "
Class C
Dim a(1), <AS:0>b(2)</AS:0> As Integer
Sub Main
Dim c(1), <AS:1>d(2)</AS:1> As Integer
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.ActiveStatementUpdate, "d(2)"))
End Sub
<Fact, WorkItem(849649, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/849649")>
Public Sub Initializer_Array_Update3()
Dim src1 = "
Class C
Private <AS:0>a(1)</AS:0>
Private <AS:1>e(1)</AS:1>
Private f(1)
Sub Main
Dim <AS:2>c(1)</AS:2>
End Sub
End Class
"
Dim src2 = "
Class C
Private <AS:0>a(1,2)</AS:0>
Private <AS:1>e(1,2)</AS:1>
Private f(1,2)
Sub Main
Dim <AS:2>c(1,2)</AS:2>
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.ActiveStatementUpdate, "c(1,2)"),
Diagnostic(RudeEditKind.TypeUpdate, "a(1,2)", FeaturesResources.Field),
Diagnostic(RudeEditKind.ActiveStatementUpdate, "e(1,2)"),
Diagnostic(RudeEditKind.TypeUpdate, "e(1,2)", FeaturesResources.Field),
Diagnostic(RudeEditKind.TypeUpdate, "f(1,2)", FeaturesResources.Field))
End Sub
<Fact, WorkItem(849649, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/849649")>
Public Sub Initializer_Array_WithLambda1()
Dim src1 = "
Class C
Private a(Function() <AS:0>1</AS:0>, Function() <AS:1>1</AS:1>)
End Class
"
Dim src2 = "
Class C
Private a(Function() <AS:0>2</AS:0>, Function() <AS:1>3</AS:1>)
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.ActiveStatementUpdate, "3"))
End Sub
<Fact, WorkItem(849649, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/849649")>
Public Sub Initializer_Array_WithLambda2()
Dim src1 = "
Class C
Private a(1, F(<AS:0>Sub()</AS:0>
End Sub))
End Class
"
Dim src2 = "
Class C
Private a(2, F(<AS:0>Sub()</AS:0>
End Sub))
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact>
Public Sub Initializer_Collection1()
Dim src1 = "
Class C
Dim <AS:0>A() = {1, 2, 3}</AS:0>
End Class
"
Dim src2 = "
Class C
Dim <AS:0>A() = {1, 2, 3, 4}</AS:0>
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact>
Public Sub Initializer_Collection2()
Dim src1 = "
Class C
Sub F
Dim <AS:0>A() = {1, 2, 3}</AS:0>
End Sub
End Class
"
Dim src2 = "
Class C
Sub F
Dim <AS:0>A() = {1, 2, 3, 4}</AS:0>
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact>
Public Sub FieldInitializer_InsertConst1()
Dim src1 = "
Class C
Private <AS:0>a As Integer = 1</AS:0>
End Class
"
Dim src2 = "
Class C
<AS:0>Private Const a As Integer = 1</AS:0>
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.ModifiersUpdate, "Private Const a As Integer = 1", FeaturesResources.ConstField))
End Sub
<Fact>
Public Sub LocalInitializer_InsertConst1()
Dim src1 = "
Class C
Sub Foo
Private <AS:0>a As Integer = 1</AS:0>
End Sub
End Class
"
Dim src2 = "
Class C
Sub Foo
Private Const a As Integer = 1
<AS:0>End Sub</AS:0>
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact>
Public Sub FieldInitializer_InsertConst2()
Dim src1 = "
Class C
Private <AS:0>a As Integer = 1</AS:0>, b As Integer = 2
End Class
"
Dim src2 = "
Class C
<AS:0>Private Const a As Integer = 1, b As Integer = 2</AS:0>
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.ModifiersUpdate, "Private Const a As Integer = 1, b As Integer = 2", FeaturesResources.ConstField))
End Sub
<Fact>
Public Sub LocalInitializer_InsertConst2()
Dim src1 = "
Class C
Sub Foo
Dim <AS:0>a As Integer = 1</AS:0>, b As Integer = 2
End Sub
End Class
"
Dim src2 = "
Class C
Sub Foo
Const a As Integer = 1, b As Integer = 2
<AS:0>End Sub</AS:0>
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact>
Public Sub FieldInitializer_Delete1()
Dim src1 = "
Class C
Dim <AS:0>a As Integer = 1</AS:0>
Dim b As Integer = 2
Sub New
End Sub
End Class
"
Dim src2 = "
Class C
Dim a As Integer
Dim <AS:0>b As Integer = 2</AS:0>
Sub New
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact>
Public Sub LocalInitializer_Delete1()
Dim src1 = "
Class C
Sub F
Dim <AS:0>a As Integer = 1</AS:0>
Dim b As Integer = 2
End Sub
End Class
"
Dim src2 = "
Class C
Sub F
Dim a As Integer
Dim <AS:0>b As Integer = 2</AS:0>
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact>
Public Sub FieldInitializer_Delete2()
Dim src1 = "
Class C
Dim b As Integer = 1
Dim c As Integer
Dim <AS:0>a = 1</AS:0>
Sub New
End Sub
End Class
"
Dim src2 = "
Class C
Dim <AS:0>b As Integer = 1</AS:0>
Dim c As Integer
Dim a
Sub New
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact>
Public Sub FieldInitializer_Delete3()
Dim src1 = "
Class C
Dim b As Integer = 1
Dim c As Integer
Dim <AS:0>a = 1</AS:0>
Sub New
End Sub
End Class
"
Dim src2 = "
Class C
Dim <AS:0>b As Integer = 1</AS:0>
Dim c As Integer
Sub New
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.Delete, "Class C", FeaturesResources.Field))
End Sub
<Fact>
Public Sub FieldInitializer_Delete_AsNew_Single()
Dim src1 = "
Class C
Dim <AS:0>a</AS:0> As New D()
Sub New
End Sub
End Class
"
Dim src2 = "
Class C
<AS:0>Dim a</AS:0>
Sub New
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact>
Public Sub FieldInitializer_Delete_AsNew_Multi1()
Dim src1 = "
Class C
Dim a,<AS:0>b</AS:0>,c As New D()
Sub New
End Sub
End Class
"
Dim src2 = "
Class C
Dim a,<AS:0>c</AS:0> As New D()
Sub New
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.Delete, "a, c As New D()", FeaturesResources.Field))
End Sub
<Fact>
Public Sub FieldInitializer_Delete_AsNew_Multi2()
Dim src1 = "
Class C
Dim a,b,<AS:0>c</AS:0> As New D()
Sub New
End Sub
End Class
"
Dim src2 = "
Class C
Dim a,<AS:0>b</AS:0> As New D()
Sub New
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.Delete, "a, b As New D()", FeaturesResources.Field))
End Sub
<Fact>
Public Sub FieldInitializer_Delete_AsNew_WithLambda()
Dim src1 = "
Class C
Dim a As New D(<AS:0>Sub()</AS:0>
End Sub)
Sub New
End Sub
End Class
"
Dim src2 = "
Class C
<AS:0>Dim a</AS:0>
Sub New
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact>
Public Sub FieldInitializer_Delete_Array1()
Dim src1 = "
Class C
Dim a,b,<AS:0>c(1)</AS:0> As Integer
Sub New
End Sub
End Class
"
Dim src2 = "
Class C
<AS:0>Dim a,b As Integer</AS:0>
Sub New
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.Delete, "a,b As Integer", FeaturesResources.Field))
End Sub
<Fact>
Public Sub FieldInitializer_Delete_Array2()
Dim src1 = "
Class C
Dim a,b(1),<AS:0>c(1)</AS:0> As Integer
Sub New
End Sub
End Class
"
Dim src2 = "
Class C
Dim a,<AS:0>b(1)</AS:0>,c As Integer
Sub New
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.TypeUpdate, "c", FeaturesResources.Field))
End Sub
<Fact>
Public Sub FieldInitializer_Delete_StaticInstanceMix1()
Dim src1 = "
Class C
Dim <AS:0>a As Integer = 1</AS:0>
Shared b As Integer = 1
Dim c As Integer = 1
End Class
"
Dim src2 = "
Class C
Dim a As Integer
Shared b As Integer = 1
Dim <AS:0>c As Integer = 1</AS:0>
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact>
Public Sub FieldInitializer_Delete_StaticInstanceMix2()
Dim src1 = "
Class C
Shared c As Integer = 1
Shared <AS:0>a As Integer = 1</AS:0>
Dim b As Integer = 1
End Class
"
Dim src2 = "
Class C
Shared <AS:0>c As Integer = 1</AS:0>
Shared a As Integer
Dim b As Integer = 1
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact>
Public Sub FieldInitializer_Delete_StaticInstanceMix3()
Dim src1 = "
Class C
Shared <AS:0>a As Integer = 1</AS:0>
Dim b As Integer = 1
End Class
"
Dim src2 = "
Class C
<AS:0>Shared a As Integer</AS:0>
Dim b As Integer = 1
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact>
Public Sub FieldInitializer_Delete_ArrayInit()
Dim src1 = "
Class C
Dim <AS:0>a As Integer = 1</AS:0>
Shared b As Integer = 1
Dim c(1) As Integer = 1
End Class
"
Dim src2 = "
Class C
Dim a As Integer
Shared b As Integer = 1
Dim <AS:0>c(1)</AS:0> As Integer
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact>
Public Sub PropertyInitializer_Delete_StaticInstanceMix()
Dim src1 = "
Class C
<AS:0>Shared Property a As Integer = 1</AS:0>
Property b As Integer = 1
End Class
"
Dim src2 = "
Class C
<AS:0>Shared Property a As Integer</AS:0>
Property b As Integer = 1
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact>
Public Sub PropertyFieldInitializer1()
Dim src1 = "
Class C
Property <AS:0>a As Integer = 1</AS:0>
Dim b As Integer = 1
Property c As Integer = 1
End Class
"
Dim src2 = "
Class C
Property a As Integer
Dim <AS:0>b As Integer = 1</AS:0>
Property c As Integer = 1
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact>
Public Sub PropertyFieldInitializer2()
Dim src1 = "
Class C
Dim <AS:0>a As Integer = 1</AS:0>
Property b As Integer = 1
Property c As Integer = 1
End Class
"
Dim src2 = "
Class C
Dim a As Integer
Property b As Integer
Property <AS:0>c As Integer = 1</AS:0>
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
#End Region
#Region "SyncLock"
<WorkItem(755749, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/755749")>
<Fact>
Public Sub SyncLock_Insert_Leaf()
Dim src1 = "
Class Test
Sub Main()
<AS:0>System.Console.Write(5)</AS:0>
End Sub
End Class
"
Dim src2 = "
Class Test
Sub Main()
SyncLock lockThis
<AS:0>System.Console.Write(5)</AS:0>
End SyncLock
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.InsertAroundActiveStatement, "SyncLock lockThis", VBFeaturesResources.SyncLockBlock))
End Sub
<Fact>
Public Sub SyncLock_Insert_Leaf4()
Dim src1 = "
Class Test
Sub Main()
SyncLock a
SyncLock b
SyncLock c
<AS:0>System.Console.Write()</AS:0>
End SyncLock
End SyncLock
End SyncLock
End Sub
End Class
"
Dim src2 = "
Class Test
Sub Main()
SyncLock b
SyncLock d
SyncLock a
SyncLock e
<AS:0>System.Console.Write()</AS:0>
End SyncLock
End SyncLock
End SyncLock
End SyncLock
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.InsertAroundActiveStatement, "SyncLock d", VBFeaturesResources.SyncLockBlock),
Diagnostic(RudeEditKind.InsertAroundActiveStatement, "SyncLock e", VBFeaturesResources.SyncLockBlock))
End Sub
<Fact>
Public Sub SyncLock_Insert_Leaf5()
Dim src1 = "
Class Test
Sub Main()
SyncLock a
SyncLock c
SyncLock b
SyncLock e
<AS:0>System.Console.Write()</AS:0>
End SyncLock
End SyncLock
End SyncLock
End SyncLock
End Sub
End Class
"
Dim src2 = "
Class Test
Sub Main()
SyncLock b
SyncLock d
SyncLock a
<AS:0>System.Console.Write()</AS:0>
End SyncLock
End SyncLock
End SyncLock
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.UpdateAroundActiveStatement, "SyncLock d", VBFeaturesResources.SyncLockStatement))
End Sub
<WorkItem(755752, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/755752")>
<Fact>
Public Sub SyncLock_Update_Leaf()
Dim src1 = "
Class Test
Sub Main()
SyncLock lockThis
<AS:0>System.Console.Write(5)</AS:0>
End SyncLock
End Sub
End Class
"
Dim src2 = "
Class Test
Sub Main()
SyncLock ""test""
<AS:0>System.Console.Write(5)</AS:0>
End SyncLock
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.UpdateAroundActiveStatement, "SyncLock ""test""", VBFeaturesResources.SyncLockStatement))
End Sub
<Fact>
Public Sub SyncLock_Update_Leaf2()
Dim src1 = "
Class Test
Sub Main()
SyncLock lockThis
System.Console.Write(5)
End SyncLock
<AS:0>System.Console.Write(5)</AS:0>
End Sub
End Class
"
Dim src2 = "
Class Test
Sub Main()
SyncLock ""test""
System.Console.Write(5)
End SyncLock
<AS:0>System.Console.Write(5)</AS:0>
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact>
Public Sub SyncLock_Delete_Leaf()
Dim src1 = "
Class Test
Sub Main()
SyncLock lockThis
<AS:0>System.Console.Write(5)</AS:0>
End SyncLock
End Sub
End Class
"
Dim src2 = "
Class Test
Sub Main()
<AS:0>System.Console.Write(5)</AS:0>
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact>
Public Sub SyncLock_Update_Lambda1()
Dim src1 = "
Class Test
Sub Main()
SyncLock F(Function(a) a)
<AS:0>System.Console.WriteLine(1)</AS:0>
End SyncLock
End Sub
End Class
"
Dim src2 = "
Class Test
Sub Main()
SyncLock F(Function(a) a + 1)
<AS:0>System.Console.WriteLine(2)</AS:0>
End SyncLock
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact>
Public Sub SyncLock_Update_Lambda2()
Dim src1 = "
Class Test
Sub Main()
SyncLock F(Function(a) a)
<AS:0>System.Console.WriteLine(1)</AS:0>
End SyncLock
End Sub
End Class
"
Dim src2 = "
Class Test
Sub Main()
SyncLock G(Function(a) a)
<AS:0>System.Console.WriteLine(2)</AS:0>
End SyncLock
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.UpdateAroundActiveStatement, "SyncLock G(Function(a) a)", VBFeaturesResources.SyncLockStatement))
End Sub
#End Region
#Region "ForEach"
<Fact>
Public Sub ForEach_Reorder_Leaf1()
Dim src1 = "
Class Test
Sub Main()
For Each a In e1
For Each b In e1
For Each c In e1
<AS:0>System.Console.Write()</AS:0>
Next
Next
Next
End Sub
End Class
"
Dim src2 = "
Class Test
Sub Main()
For Each b In e1
For Each c In e1
For Each a In e1
<AS:0>System.Console.Write()</AS:0>
Next
Next
Next
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact>
Public Sub ForEach_Update_Leaf1()
Dim src1 = "
Class Test
Sub Main()
For Each a In e1
For Each b In e1
For Each c In e1
<AS:0>System.Console.Write()</AS:0>
Next
Next
Next
End Sub
End Class
"
Dim src2 = "
Class Test
Sub Main()
For Each b In e1
For Each c In e1
For Each a In e1
<AS:0>System.Console.Write()</AS:0>
Next
Next
Next
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact>
Public Sub ForEach_Update_Leaf2()
Dim src1 = "
Class Test
Sub Main()
<AS:0>System.Console.Write()</AS:0>
End Sub
End Class
"
Dim src2 = "
Class Test
Sub Main()
For Each b In e1
For Each c In e1
For Each a In e1
<AS:0>System.Console.Write()</AS:0>
Next
Next
Next
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.InsertAroundActiveStatement, "For Each b In e1", VBFeaturesResources.ForEachBlock),
Diagnostic(RudeEditKind.InsertAroundActiveStatement, "For Each c In e1", VBFeaturesResources.ForEachBlock),
Diagnostic(RudeEditKind.InsertAroundActiveStatement, "For Each a In e1", VBFeaturesResources.ForEachBlock))
End Sub
<Fact>
Public Sub ForEach_Delete_Leaf1()
Dim src1 = "
Class Test
Sub Main()
For Each a In e1
For Each b In e1
For Each c In e1
<AS:0>System.Console.Write()</AS:0>
Next
Next
Next
End Sub
End Class
"
Dim src2 = "
Class Test
Sub Main()
For Each a In e1
For Each b In e1
<AS:0>System.Console.Write()</AS:0>
Next
Next
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact>
Public Sub ForEach_Delete_Leaf2()
Dim src1 = "
Class Test
Sub Main()
For Each a In e1
For Each b In e1
For Each c In e1
<AS:0>System.Console.Write()</AS:0>
Next
Next
Next
End Sub
End Class
"
Dim src2 = "
Class Test
Sub Main()
For Each b In e1
For Each c In e1
<AS:0>System.Console.Write()</AS:0>
Next
Next
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact>
Public Sub ForEach_Delete_Leaf3()
Dim src1 = "
Class Test
Sub Main()
For Each a In e1
For Each b In e1
For Each c In e1
<AS:0>System.Console.Write()</AS:0>
Next
Next
Next
End Sub
End Class
"
Dim src2 = "
Class Test
Sub Main()
For Each a In e1
For Each c In e1
<AS:0>System.Console.Write()</AS:0>
Next
Next
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact>
Public Sub ForEach_Lambda1()
Dim src1 = "
Class Test
Sub Main()
Dim a = Sub()
<AS:0>System.Console.Write()</AS:0>
End Sub
<AS:1>a()</AS:1>
End Sub
End Class
"
Dim src2 = "
Class Test
Sub Main()
For Each b In e1
For Each c In e1
Dim a = Sub()
For Each a In e1
<AS:0>System.Console.Write()</AS:0>
Next
End Sub
Next
<AS:1>a()</AS:1>
Next
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.InsertAroundActiveStatement, "For Each a In e1", VBFeaturesResources.ForEachBlock),
Diagnostic(RudeEditKind.InsertAroundActiveStatement, "For Each b In e1", VBFeaturesResources.ForEachBlock))
End Sub
<Fact>
Public Sub ForEach_Update_Lambda1()
Dim src1 = "
Class Test
Sub Main()
For Each a In F(Function(a) a)
<AS:0>System.Console.Write(1)</AS:0>
Next
End Sub
End Class
"
Dim src2 = "
Class Test
Sub Main()
For Each a In F(Function(a) a + 1)
<AS:0>System.Console.Write(2)</AS:0>
Next
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact>
Public Sub ForEach_Update_Lambda2()
Dim src1 = "
Class Test
Sub Main()
For Each a In F(Function(a) a)
<AS:0>System.Console.Write(1)</AS:0>
Next
End Sub
End Class
"
Dim src2 = "
Class Test
Sub Main()
For Each a In G(Function(a) a)
<AS:0>System.Console.Write(2)</AS:0>
Next
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.UpdateAroundActiveStatement, "For Each a In G(Function(a) a)", VBFeaturesResources.ForEachStatement))
End Sub
#End Region
#Region "Using"
<Fact>
Public Sub Using_Update_Leaf1()
Dim src1 = "
Class Test
Sub Main()
Using a
Using b
<AS:0>System.Console.Write()</AS:0>
End Using
End Using
End sub
End Class
"
Dim src2 = "
Class Test
Sub Main()
Using a
Using c
Using b
<AS:0>System.Console.Write()</AS:0>
End Using
End Using
End Using
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active, Diagnostic(RudeEditKind.InsertAroundActiveStatement, "Using c", VBFeaturesResources.UsingBlock))
End Sub
<Fact>
Public Sub Using_Lambda1()
Dim src1 = "
Class Test
Sub Main()
Using a
Dim z = Function()
Using b
<AS:0>Return 1</AS:0>
End Using
End Function
End Using
<AS:1>a()</AS:1>
End Sub
End Class
"
Dim src2 = "
Class Test
Sub Main()
Using d
Dim z = Function()
Using c
Using b
<AS:0>Return 1</AS:0>
End Using
End Using
End Function
End Using
<AS:1>a()</AS:1>
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.InsertAroundActiveStatement, "Using c", VBFeaturesResources.UsingBlock))
End Sub
<Fact>
Public Sub Using_Update_Lambda1()
Dim src1 = "
Class Test
Sub Main()
Using F(Function(a) a)
<AS:0>System.Console.Write(1)</AS:0>
End Using
End Sub
End Class
"
Dim src2 = "
Class Test
Sub Main()
Using F(Function(a) a + 1)
<AS:0>System.Console.Write(2)</AS:0>
End Using
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact>
Public Sub Using_Update_Lambda2()
Dim src1 = "
Class Test
Sub Main()
Using F(Function(a) a)
<AS:0>System.Console.Write(1)</AS:0>
End Using
End Sub
End Class
"
Dim src2 = "
Class Test
Sub Main()
Using G(Function(a) a)
<AS:0>System.Console.Write(2)</AS:0>
End Using
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.UpdateAroundActiveStatement, "Using G(Function(a) a)", VBFeaturesResources.UsingStatement))
End Sub
#End Region
#Region "With"
<Fact>
Public Sub With_Update_Leaf1()
Dim src1 = "
Class Test
Sub Main()
With a
With b
<AS:0>System.Console.Write()</AS:0>
End With
End With
End sub
End Class
"
Dim src2 = "
Class Test
Sub Main()
With a
With c
With b
<AS:0>System.Console.Write()</AS:0>
End With
End With
End With
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.InsertAroundActiveStatement, "With c", VBFeaturesResources.WithBlock))
End Sub
<Fact>
Public Sub With_Lambda1()
Dim src1 = "
Class Test
Sub Main()
With a
Dim z = Function()
With b
<AS:0>Return 1</AS:0>
End With
End Function
End With
<AS:1>a()</AS:1>
End Sub
End Class
"
Dim src2 = "
Class Test
Sub Main()
With d
Dim z = Function()
With c
With b
<AS:0>Return 1</AS:0>
End With
End With
End Function
End With
<AS:1>a()</AS:1>
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.InsertAroundActiveStatement, "With c", VBFeaturesResources.WithBlock))
End Sub
<Fact>
Public Sub With_Update_Lambda1()
Dim src1 = "
Class Test
Sub Main()
With F(Function(a) a)
<AS:0>System.Console.Write(1)</AS:0>
End With
End Sub
End Class
"
Dim src2 = "
Class Test
Sub Main()
With F(Function(a) a + 1)
<AS:0>System.Console.Write(1)</AS:0>
End With
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact>
Public Sub With_Update_Lambda2()
Dim src1 = "
Class Test
Sub Main()
With F(Function(a) a)
<AS:0>System.Console.Write(1)</AS:0>
End With
End Sub
End Class
"
Dim src2 = "
Class Test
Sub Main()
With G(Function(a) a)
<AS:0>System.Console.Write(1)</AS:0>
End With
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.UpdateAroundActiveStatement, "With G(Function(a) a)", VBFeaturesResources.WithStatement))
End Sub
#End Region
#Region "Try, Catch, Finally"
<Fact>
Public Sub Try_Add_Inner()
Dim src1 = "
Class C
Shared Sub Bar()
<AS:1>Foo()</AS:1>
End Sub
Shared Sub Foo()
<AS:0>Console.WriteLine(1)</AS:0>
End Sub
End Class
"
Dim src2 = "
Class C
Shared Sub Bar()
Try
<AS:1>Foo()</AS:1>
Catch
End Try
End Sub
Shared Sub Foo()
<AS:0>Console.WriteLine(1)</AS:0>
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.InsertAroundActiveStatement, "Try", VBFeaturesResources.TryBlock))
End Sub
<Fact>
Public Sub Try_Add_Leaf()
Dim src1 = "
Class C
Sub Main()
<AS:1>Foo()</AS:1>
End Sub
Sub Foo()
<AS:0>Console.WriteLine(1)</AS:0>
End Sub
End Class
"
Dim src2 = "
Class C
Sub Main()
<AS:1>Foo()</AS:1>
End Sub
Sub Foo()
Try
<AS:0>Console.WriteLine(1)</AS:0>
Catch
End Try
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact>
Public Sub Try_Delete_Inner()
Dim src1 = "
Class C
Sub Main()
Try
<AS:1>Foo()</AS:1>
Catch
End Try
End Sub
Sub Foo()
<AS:0>Console.WriteLine(1)</AS:0>
End Sub
End Class
"
Dim src2 = "
Class C
Sub Main()
<AS:1>Foo()</AS:1>
End Sub
Sub Foo()
<AS:0>Console.WriteLine(1)</AS:0>
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.DeleteAroundActiveStatement, "Foo()", VBFeaturesResources.TryBlock))
End Sub
<Fact>
Public Sub Try_Delete_Leaf()
Dim src1 = "
Class C
Sub Main()
<AS:1>Foo()</AS:1>
End Sub
Sub Foo()
Try
<AS:0>Console.WriteLine(1)</AS:0>
Catch
End Try
End Sub
End Class
"
Dim src2 = "
Class C
Sub Main()
<AS:1>Foo()</AS:1>
End Sub
Sub Foo()
<AS:0>Console.WriteLine(1)</AS:0>
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact>
Public Sub Try_Update_Inner()
Dim src1 = "
Class C
Sub Main()
Try
<AS:1>Foo()</AS:1>
Catch
End Try
End Sub
Sub Foo()
<AS:0>Console.WriteLine(1)</AS:0>
End Sub
End Class
"
Dim src2 = "
Class C
Sub Main()
Try
<AS:1>Foo()</AS:1>
Catch e As IOException
End Try
End Sub
Sub Foo()
<AS:0>Console.WriteLine(1)</AS:0>
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.UpdateAroundActiveStatement, "Try", VBFeaturesResources.TryBlock))
End Sub
<Fact>
Public Sub Try_Update_Inner2()
Dim src1 = "
Class C
Sub Main()
Try
<AS:1>Foo()</AS:1>
<ER:1.0>Catch
End Try</ER:1.0>
End Sub
Sub Foo()
<AS:0>Console.WriteLine(1)</AS:0>
End Sub
End Class
"
Dim src2 = "
Class C
Sub Main()
Try
<AS:1>Foo()</AS:1>
<ER:1.0>Catch
End Try</ER:1.0>
Console.WriteLine(2)
End Sub
Sub Foo()
<AS:0>Console.WriteLine(1)</AS:0>
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact>
Public Sub TryFinally_Update_Inner()
Dim src1 = "
Class C
Sub Main()
Try
<AS:1>Foo()</AS:1>
<ER:1.0>Finally
End Try</ER:1.0>
End Sub
Sub Foo()
<AS:0>Console.WriteLine(1)</AS:0>
End Sub
End Class
"
Dim src2 = "
Class C
Sub Main()
Try
<AS:1>Foo()</AS:1>
<ER:1.0>Finally
End Try</ER:1.0>
Console.WriteLine(2)
End Sub
Sub Foo()
<AS:0>Console.WriteLine(1)</AS:0>
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact>
Public Sub Try_Update_Leaf()
Dim src1 = "
Class C
Sub Main()
<AS:1>Foo()</AS:1>
End Sub
Sub Foo()
Try
<AS:0>Console.WriteLine(1)</AS:0>
Catch
End Try
End Sub
End Class
"
Dim src2 = "
Class C
Sub Main()
<AS:1>Foo()</AS:1>
End Sub
Sub Foo()
Try
<AS:0>Console.WriteLine(1)</AS:0>
Catch e As IOException
End Try
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact>
Public Sub TryFinally_DeleteStatement_Inner()
Dim src1 = "
Class C
Sub Main()
<AS:0>Console.WriteLine(0)</AS:0>
Try
<AS:1>Console.WriteLine(1)</AS:1>
<ER:1.0>Finally
Console.WriteLine(2)
End Try</ER:1.0>
End Sub
End Class
"
Dim src2 = "
Class C
Sub Main()
<AS:0>Console.WriteLine(0)</AS:0>
<AS:1>Try</AS:1>
Finally
Console.WriteLine(2)
End Try
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.DeleteActiveStatement, "Try"))
End Sub
<Fact>
Public Sub TryFinally_DeleteStatement_Leaf()
Dim src1 = "
Class C
Sub Main()
<ER:0.0>Try
Console.WriteLine(0)
Finally
<AS:0>Console.WriteLine(1)</AS:0>
End Try</ER:0.0>
End Sub
End Class
"
Dim src2 = "
Class C
Sub Main()
Try
Console.WriteLine(0)
<AS:0>Finally</AS:0>
End Try
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.UpdateAroundActiveStatement, "Finally", VBFeaturesResources.FinallyClause))
End Sub
<Fact>
Public Sub Try_DeleteStatement_Inner()
Dim src1 = "
Class C
Sub Main()
<AS:0>Console.WriteLine(0)</AS:0>
Try
<AS:1>Console.WriteLine(1)</AS:1>
Finally
Console.WriteLine(2)
End Try
End Sub
End Class
"
Dim src2 = "
Class C
Sub Main()
<AS:0>Console.WriteLine(0)</AS:0>
<AS:1>Try</AS:1>
Finally
Console.WriteLine(2)
End Try
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.DeleteActiveStatement, "Try"))
End Sub
<Fact>
Public Sub Try_DeleteStatement_Leaf()
Dim src1 = "
Class C
Sub Main()
Try
<AS:0>Console.WriteLine(1)</AS:0>
Finally
Console.WriteLine(2)
End Try
End Sub
End Class
"
Dim src2 = "
Class C
Sub Main()
<AS:0>Try</AS:0>
Finally
Console.WriteLine(2)
End Try
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact>
Public Sub Catch_Add_Inner()
Dim src1 = "
Class C
Sub Main()
<AS:1>Foo()</AS:1>
End Sub
Sub Foo()
<AS:0>Console.WriteLine(1)</AS:0>
End Sub
End Class
"
Dim src2 = "
Class C
Sub Main()
Try
Catch
<AS:1>Foo()</AS:1>
End Try
End Sub
Sub Foo()
<AS:0>Console.WriteLine(1)</AS:0>
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.InsertAroundActiveStatement, "Catch", VBFeaturesResources.CatchClause))
End Sub
<Fact>
Public Sub Catch_Add_Leaf()
Dim src1 = "
Class C
Sub Main()
<AS:1>Foo()</AS:1>
End Sub
Sub Foo()
<AS:0>Console.WriteLine(1)</AS:0>
End Sub
End Class
"
Dim src2 = "
Class C
Sub Main()
<AS:1>Foo()</AS:1>
End Sub
Sub Foo()
Try
Catch
<AS:0>Console.WriteLine(1)</AS:0>
End Try
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.InsertAroundActiveStatement, "Catch", VBFeaturesResources.CatchClause))
End Sub
<Fact>
Public Sub Catch_Delete_Inner()
Dim src1 = "
Class C
Sub Main()
Try
Catch
<AS:1>Foo()</AS:1>
End Try
End Sub
Sub Foo()
<AS:0>Console.WriteLine(1)</AS:0>
End Sub
End Class
"
Dim src2 = "
Class C
Sub Main()
<AS:1>Foo()</AS:1>
End Sub
Sub Foo()
<AS:0>Console.WriteLine(1)</AS:0>
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.DeleteAroundActiveStatement, "Foo()", VBFeaturesResources.CatchClause))
End Sub
<Fact>
Public Sub Catch_Delete_Leaf()
Dim src1 = "
Class C
Sub Main()
<AS:1>Foo()</AS:1>
End Sub
Sub Foo()
Try
Catch
<AS:0>Console.WriteLine(1)</AS:0>
End Try
End Sub
End Class
"
Dim src2 = "
Class C
Sub Main()
<AS:1>Foo()</AS:1>
End Sub
Sub Foo()
<AS:0>Console.WriteLine(1)</AS:0>
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.DeleteAroundActiveStatement, "Console.WriteLine(1)", VBFeaturesResources.CatchClause))
End Sub
<Fact>
Public Sub Catch_Update_Inner()
Dim src1 = "
Class C
Sub Main()
Try
Catch
<AS:1>Foo()</AS:1>
End Try
End Sub
Sub Foo()
<AS:0>Console.WriteLine(1)</AS:0>
End Sub
End Class
"
Dim src2 = "
Class C
Sub Main()
Try
Catch e As IOException
<AS:1>Foo()</AS:1>
End Try
End Sub
Sub Foo()
<AS:0>Console.WriteLine(1)</AS:0>
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.UpdateAroundActiveStatement, "Catch", VBFeaturesResources.CatchClause))
End Sub
<Fact>
Public Sub Catch_Update_Leaf()
Dim src1 = "
Class C
Sub Main()
<AS:1>Foo()</AS:1>
End Sub
Sub Foo()
Try
Catch
<AS:0>Console.WriteLine(1)</AS:0>
End Try
End Sub
End Class
"
Dim src2 = "
Class C
Sub Main()
<AS:1>Foo()</AS:1>
End Sub
Sub Foo()
Try
Catch e As IOException
<AS:0>Console.WriteLine(1)</AS:0>
End try
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.UpdateAroundActiveStatement, "Catch", VBFeaturesResources.CatchClause))
End Sub
<Fact>
Public Sub CatchFilter_Update_Inner()
Dim src1 = "
Class C
Sub Main()
<AS:0>Foo()</AS:0>
End Sub
Sub Foo()
Try
<AS:1>Catch e As IOException When Foo(1)</AS:1>
Console.WriteLine(1)
End Try
End Sub
End Class
"
Dim src2 = "
Class C
Sub Main()
<AS:0>Foo()</AS:0>
End Sub
Sub Foo()
Try
<AS:1>Catch e As IOException When Foo(2)</AS:1>
Console.WriteLine(1)
End Try
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.ActiveStatementUpdate, "Catch e As IOException When Foo(2)"),
Diagnostic(RudeEditKind.UpdateAroundActiveStatement, "Catch", VBFeaturesResources.CatchClause))
End Sub
<Fact>
Public Sub CatchFilter_Update_Leaf1()
Dim src1 = "
Class C
Sub Main()
<AS:1>Foo()</AS:1>
End Sub
Sub Foo()
Try
<AS:0>Catch e As IOException When Foo(1)</AS:0>
Console.WriteLine(1)
End Try
End Sub
End Class
"
Dim src2 = "
Class C
Sub Main()
<AS:1>Foo()</AS:1>
End Sub
Sub Foo()
Try
<AS:0>Catch e As IOException When Foo(2)</AS:0>
Console.WriteLine(1)
End Try
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.UpdateAroundActiveStatement, "Catch", VBFeaturesResources.CatchClause))
End Sub
<Fact>
Public Sub CatchFilter_Update_Leaf2()
Dim src1 = "
Class C
Sub Main()
<AS:1>Foo()</AS:1>
End Sub
Sub Foo()
Try
<AS:0>Catch e As IOException When Foo(1)</AS:0>
Console.WriteLine(1)
End Try
End Sub
End Class
"
Dim src2 = "
Class C
Sub Main()
<AS:1>Foo()</AS:1>
End Sub
Sub Foo()
Try
<AS:0>Catch e As Exception When Foo(1)</AS:0>
Console.WriteLine(1)
End Try
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.UpdateAroundActiveStatement, "Catch", VBFeaturesResources.CatchClause))
End Sub
<Fact>
Public Sub Finally_Add_Inner()
Dim src1 = "
Class C
Sub Main()
<AS:1>Foo()</AS:1>
End Sub
Sub Foo()
<AS:0>Console.WriteLine(1)</AS:0>
End Sub
End Class
"
Dim src2 = "
Class C
Sub Main()
Try
Finally
<AS:1>Foo()</AS:1>
End Try
End Sub
Sub Foo()
<AS:0>Console.WriteLine(1)</AS:0>
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.InsertAroundActiveStatement, "Finally", VBFeaturesResources.FinallyClause))
End Sub
<Fact>
Public Sub Finally_Add_Leaf()
Dim src1 = "
Class C
Sub Main()
<AS:1>Foo()</AS:1>
End Sub
Sub Foo()
<AS:0>Console.WriteLine(1)</AS:0>
End Sub
End Class
"
Dim src2 = "
Class C
Sub Main()
<AS:1>Foo()</AS:1>
End Sub
Sub Foo()
Try
Finally
<AS:0>Console.WriteLine(1)</AS:0>
End Try
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active, Diagnostic(RudeEditKind.InsertAroundActiveStatement, "Finally", VBFeaturesResources.FinallyClause))
End Sub
<Fact>
Public Sub Finally_Delete_Inner()
Dim src1 = "
Class C
Sub Main()
Try
Finally
<AS:1>Foo()</AS:1>
End Try
End Sub
Sub Foo()
<AS:0>Console.WriteLine(1)</AS:0>
End Sub
End Class
"
Dim src2 = "
Class C
Sub Main()
<AS:1>Foo()</AS:1>
End Sub
Sub Foo()
<AS:0>Console.WriteLine(1)</AS:0>
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.DeleteAroundActiveStatement, "Foo()", VBFeaturesResources.FinallyClause))
End Sub
<Fact>
Public Sub Finally_Delete_Leaf()
Dim src1 = "
Class C
Sub Main()
<AS:1>Foo()</AS:1>
End Sub
Sub Foo()
Try
Finally
<AS:0>Console.WriteLine(1)</AS:0>
End Try
End Sub
End Class
"
Dim src2 = "
Class C
Sub Main()
<AS:1>Foo()</AS:1>
End Sub
Sub Foo()
<AS:0>Console.WriteLine(1)</AS:0>
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.DeleteAroundActiveStatement, "Console.WriteLine(1)", VBFeaturesResources.FinallyClause))
End Sub
<Fact>
Public Sub TryCatchFinally()
Dim src1 = "
Class C
Sub Main()
Try
Catch e As IOException
Try
Try
Try
<AS:1>Foo()</AS:1>
Catch
End Try
Catch Exception
End Try
Finally
End Try
End Try
End Sub
Sub Foo()
<AS:0>Console.WriteLine(1)</AS:0>
End Sub
End Class
"
Dim src2 = "
Class C
Sub Main()
Try
Catch e As Exception
Try
Try
Finally
Try
<AS:1>Foo()</AS:1>
Catch
End Try
End Try
Catch e As Exception
End Try
End Try
End Sub
Sub Foo()
<AS:0>Console.WriteLine(1)</AS:0>
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.UpdateAroundActiveStatement, "Catch", VBFeaturesResources.CatchClause),
Diagnostic(RudeEditKind.UpdateAroundActiveStatement, "Try", VBFeaturesResources.TryBlock),
Diagnostic(RudeEditKind.DeleteAroundActiveStatement, "Foo()", VBFeaturesResources.TryBlock),
Diagnostic(RudeEditKind.InsertAroundActiveStatement, "Finally", VBFeaturesResources.FinallyClause))
End Sub
<Fact>
Public Sub TryCatchFinally_Regions()
Dim src1 = "
Class C
Sub Main()
Try
<ER:1.0>Catch e As IOException
Try
Try
Try
<AS:1>Foo()</AS:1>
Catch
End Try
Catch e As Exception
End Try
Finally
End Try</ER:1.0>
End Try
End Sub
Sub Foo()
<AS:0>Console.WriteLine(1)</AS:0>
End Sub
End Class
"
Dim src2 = "
Class C
Sub Main()
Try
<ER:1.0>Catch e As IOException
Try : Try : Try : <AS:1>Foo()</AS:1> : Catch : End Try : Catch e As Exception : End Try : Finally : End Try</ER:1.0>
End Try
End Sub
Sub Foo()
<AS:0>Console.WriteLine(1)</AS:0>
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact>
Public Sub Try_Lambda1()
Dim src1 = "
Class C
Function Foo(x As Integer) As Integer
<AS:0>Return 1</AS:0>
End Function
Sub Main()
Dim f As Func(Of Integer, Integer) = Nothing
Try
f = Function(x) <AS:1>1 + Foo(x)</AS:1>
Catch
End Try
<AS:2>Console.Write(f(2))</AS:2>
End Sub
End Class
"
Dim src2 = "
Class C
Function Foo(x As Integer) As Integer
<AS:0>Return 1</AS:0>
End Function
Sub Main()
Dim f As Func(Of Integer, Integer) = Nothing
f = Function(x) <AS:1>1 + Foo(x)</AS:1>
<AS:2>Console.Write(f(2))</AS:2>
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact>
Public Sub Try_Lambda2()
Dim src1 = "
Class C
Function Foo(x As Integer) As Integer
<AS:0>Return 1</AS:0>
End Function
Sub Main()
Dim f = Function(x)
Try
<AS:1>Return 1 + Foo(x)</AS:1>
Catch
End Try
End Function
<AS:2>Console.Write(f(2))</AS:2>
End Sub
End Class
"
Dim src2 = "
Class C
Function Foo(x As Integer) As Integer
<AS:0>Return 1</AS:0>
End Function
Sub Main()
Dim f = Function(x)
<AS:1>Return 1 + Foo(x)</AS:1>
End Function
<AS:2>Console.Write(f(2))</AS:2>
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.DeleteAroundActiveStatement, "Return 1 + Foo(x)", VBFeaturesResources.TryBlock))
End Sub
<Fact>
Public Sub Try_Query_Join1()
Dim src1 = "
Class C
Function Foo(x As Integer) As Integer
<AS:0>Return 1</AS:0>
End Function
Sub Main()
Try
q = From x In xs
Join y In ys On <AS:1>F()</AS:1> Equals G()
Select 1
Catch
End Try
<AS:2>q.ToArray()</AS:2>
End Sub
End Class
"
Dim src2 = "
Class C
Function Foo(x As Integer) As Integer
<AS:0>Return 1</AS:0>
End Function
Sub Main()
q = From x In xs
Join y In ys On <AS:1>F()</AS:1> Equals G()
Select 1
<AS:2>q.ToArray()</AS:2>
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.RUDE_EDIT_COMPLEX_QUERY_EXPRESSION, "Join", FeaturesResources.Method))
End Sub
<Fact>
Public Sub Try_Query_Join2()
Dim src1 = "
Class C
Function Foo(x As Integer) As Integer
<AS:0>Return 1</AS:0>
End Function
Sub Main()
Dim f = Sub()
Try
Dim q = From x In xs
Join y In ys On <AS:1>F()</AS:1> Equals G()
Select 1
Catch
End Try
<AS:2>q.ToArray()</AS:2>
End Sub
End Sub
End Class
"
Dim src2 = "
Class C
Function Foo(x As Integer) As Integer
<AS:0>Return 1</AS:0>
End Function
Sub Main()
Dim f = Sub()
Dim q = From x In xs
Join y In ys On <AS:1>F()</AS:1> Equals G()
Select 1
<AS:2>q.ToArray()</AS:2>
End Sub
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.RUDE_EDIT_COMPLEX_QUERY_EXPRESSION, "Join", FeaturesResources.Method))
End Sub
#End Region
#Region "Lambdas"
<Fact>
Public Sub Lambdas_SingleLineToMultiLine1()
Dim src1 = "
Class C
Sub Main()
Dim f = Function(a) <AS:0>1</AS:0>
End Sub
End Class
"
Dim src2 = "
Class C
Sub Main()
Dim f = <AS:0>Function(a)</AS:0>
Return 1
End Function
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact>
Public Sub Lambdas_SingleLineToMultiLine2()
Dim src1 = "
Class C
Sub Main()
Dim f = <AS:0>Function(a)</AS:0> 1
End Sub
End Class
"
Dim src2 = "
Class C
Sub Main()
Dim f = <AS:0>Function(a)</AS:0>
Return 1
End Function
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact>
Public Sub Lambdas_MultiLineToSingleLine1()
Dim src1 = "
Class C
Sub Main()
Dim f = Function(a)
<AS:0>Return 1</AS:0>
End Function
End Sub
End Class
"
Dim src2 = "
Class C
Sub Main()
Dim f = <AS:0>Function(a)</AS:0> 1
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact>
Public Sub Lambdas_MultiLineToSingleLine2()
Dim src1 = "
Class C
Sub Main()
Dim f = <AS:0>Function(a)</AS:0>
Return 1
End Function
End Sub
End Class
"
Dim src2 = "
Class C
Sub Main()
Dim f = <AS:0>Function(a)</AS:0> 1
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact>
Public Sub Lambdas_MultiLineToSingleLine3()
Dim src1 = "
Class C
Sub Main()
Dim f = Function(a)
Return 1
<AS:0>End Function</AS:0>
End Sub
End Class
"
Dim src2 = "
Class C
Sub Main()
Dim f = <AS:0>Function(a)</AS:0> 1
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact>
Public Sub Lambdas_ActiveStatementRemoved1()
Dim src1 = "
Class C
Sub Main()
Dim f = Function(a)
Return Function(b) <AS:0>b</AS:0>
End Function
Dim z = f(1)
<AS:1>z(2)</AS:1>
End Sub
End Class
"
Dim src2 = "
Class C
Sub Main()
Dim f = <AS:0>Function(b)</AS:0> b
Dim z = f
<AS:1>z(2)</AS:1>
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.ActiveStatementLambdaRemoved, "Function(b)", VBFeaturesResources.LambdaExpression))
End Sub
<Fact>
Public Sub Lambdas_ActiveStatementRemoved2()
Dim src1 = "
Class C
Sub Main()
Dim f = Function(a) Function(b) <AS:0>b</AS:0>
Dim z = f(1)
<AS:1>z(2)</AS:1>
End Sub
End Class
"
Dim src2 = "
Class C
Sub Main()
Dim f = <AS:0>Function(b)</AS:0> b
Dim z = f
<AS:1>z(2)</AS:1>
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.ActiveStatementLambdaRemoved, "Function(b)", VBFeaturesResources.LambdaExpression))
End Sub
<Fact>
Public Sub Lambdas_ActiveStatementRemoved3()
Dim src1 = "
Class C
Sub Main()
Dim f = Function(a)
Dim z As Func(Of Integer, Integer)
F(Function(b)
<AS:0>Return b</AS:0>
End Function, z)
Return z
End Function
Dim z = f(1)
<AS:1>z(2)</AS:1>
End Sub
End Class
"
Dim src2 = "
Class C
Sub Main()
Dim f = Function(b)
<AS:0>F(b)</AS:0>
Return 1
End Function
Dim z = f
<AS:1>z(2)</AS:1>
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.ActiveStatementLambdaRemoved, "F(b)", VBFeaturesResources.LambdaExpression))
End Sub
<Fact>
Public Sub Lambdas_ActiveStatementRemoved4()
Dim src1 = "
Class C
Shared Sub Main()
Dim f = Function(a)
<AS:1>z(2)</AS:1>
return Function (b)
<AS:0>Return b</AS:0>
End Function
End Function
End Sub
End Class"
Dim src2 = "
Class C
<AS:0,1>Shared Sub Main()</AS:0,1>
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.ActiveStatementLambdaRemoved, "Shared Sub Main()", VBFeaturesResources.LambdaExpression),
Diagnostic(RudeEditKind.ActiveStatementLambdaRemoved, "Shared Sub Main()", VBFeaturesResources.LambdaExpression))
End Sub
<Fact>
Public Sub Queries_ActiveStatementRemoved_WhereClause()
Dim src1 = "
Class C
Sub Main()
Dim s = From a In b Where <AS:0>b.foo</AS:0> Select b.bar
<AS:1>s.ToArray()</AS:1>
End Sub
End Class
"
Dim src2 = "
Class C
Sub Main()
Dim s = <AS:0>From</AS:0> a In b Select b.bar
<AS:1>s.ToArray()</AS:1>
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.ActiveStatementLambdaRemoved, "From", VBFeaturesResources.WhereClause))
End Sub
<Fact, WorkItem(841361, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/841361")>
Public Sub Queries_ActiveStatementRemoved_LetClause()
Dim src1 = "
Class C
Sub Main()
Dim s = From a In b Let x = <AS:0>a.foo</AS:0> Select x
<AS:1>s.ToArray()</AS:1>
End Sub
End Class
"
Dim src2 = "
Class C
Sub Main()
Dim s = <AS:0>From</AS:0> a In b Select x
<AS:1>s.ToArray()</AS:1>
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.ActiveStatementLambdaRemoved, "From", VBFeaturesResources.LetClause))
End Sub
<Fact>
Public Sub Queries_ActiveStatementRemoved_JoinClauseLeft()
Dim src1 = "
Class C
Sub Main()
Dim s = From a In b
Join c In d On <AS:0>a.foo</AS:0> Equals c.bar
Select a.bar
<AS:1>s.ToArray()</AS:1>
End Sub
End Class
"
Dim src2 = "
Class C
Sub Main()
Dim s = <AS:0>From</AS:0> a In b Select a.bar
<AS:1>s.ToArray()</AS:1>
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.ActiveStatementLambdaRemoved, "From", VBFeaturesResources.JoinCondition))
End Sub
<Fact>
Public Sub Queries_ActiveStatementRemoved_OrderBy1()
Dim src1 = "
Class C
Sub Main()
Dim s = From a In b
Order By <AS:0>a.x</AS:0>, a.y Descending, a.z Ascending
Select a
<AS:1>s.ToArray()</AS:1>
End Sub
End Class
"
Dim src2 = "
Class C
Sub Main()
Dim s = <AS:0>From</AS:0> a In b Select a.bar
<AS:1>s.ToArray()</AS:1>
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.ActiveStatementLambdaRemoved, "From", VBFeaturesResources.OrderingClause))
End Sub
<Fact>
Public Sub Queries_ActiveStatementRemoved_OrderBy2()
Dim src1 = "
Class C
Sub Main()
Dim s = From a in b
Order By a.x, <AS:0>a.y</AS:0> Descending, a.z Ascending
Select a
<AS:1>s.ToArray()</AS:1>
End Sub
End Class
"
Dim src2 = "
Class C
Sub Main()
Dim s = <AS:0>From</AS:0> a In b Select a.bar
<AS:1>s.ToArray()</AS:1>
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.ActiveStatementLambdaRemoved, "From", VBFeaturesResources.OrderingClause))
End Sub
<Fact>
Public Sub Queries_ActiveStatementRemoved_OrderBy3()
Dim src1 = "
Class C
Sub Main()
Dim s = From a in b
Order By a.x, a.y Descending, <AS:0>a.z</AS:0> Ascending
Select a
<AS:1>s.ToArray()</AS:1>
End Sub
End Class
"
Dim src2 = "
Class C
Sub Main()
Dim s = <AS:0>From</AS:0> a In b Select a.bar
<AS:1>s.ToArray()</AS:1>
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.ActiveStatementLambdaRemoved, "From", VBFeaturesResources.OrderingClause))
End Sub
<Fact>
Public Sub MisplacedActiveStatement1()
Dim src1 = "
<AS:1>Class C</AS:1>
Function F(a As Integer) As Integer
<AS:0>Return a</AS:0>
<AS:2>Return a</AS:2>
End Function
End Class
"
Dim src2 = "
Class C
Function F(a As Integer) As Integer
<AS:0>return a</AS:0>
<AS:2>return a</AS:2>
End Function
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact, WorkItem(1359, "https://github.com/dotnet/roslyn/issues/1359")>
Public Sub Lambdas_LeafEdits_GeneralStatement()
Dim src1 = "
Class C
Sub Main()
<AS:1>F(Function(a) <AS:0>1</AS:0>)</AS:1>
End Sub
End Class
"
Dim src2 = "
Class C
Sub Main()
<AS:1>F(Function(a) <AS:0>2</AS:0>)</AS:1>
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact, WorkItem(1359, "https://github.com/dotnet/roslyn/issues/1359")>
Public Sub Lambdas_LeafEdits_NestedLambda()
Dim src1 = "
Class C
Sub Main()
<AS:2>F(Function(b) <AS:1>F(Function(a) <AS:0>1</AS:0>)</AS:1>)</AS:2>
End Sub
End Class
"
Dim src2 = "
Class C
Sub Main()
<AS:2>F(Function(b) <AS:1>G(Function(a) <AS:0>1</AS:0>)</AS:1>)</AS:2>
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.ActiveStatementUpdate, "G(Function(a) 1 )"))
End Sub
#End Region
#Region "State Machines"
<Fact>
Public Sub MethodToIteratorMethod_WithActiveStatement()
Dim src1 = "
Imports System
Imports System.Collections.Generic
Class C
Function F() As IEnumerable(Of Integer)
<AS:0>Console.WriteLine(1)</AS:0>
Return {1, 1}
End Function
End Class
"
Dim src2 = "
Imports System
Imports System.Collections.Generic
Class C
Iterator Function F() As IEnumerable(Of Integer)
<AS:0>Console.WriteLine(1)</AS:0>
Yield 1
End Function
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.InsertAroundActiveStatement, "Yield 1", VBFeaturesResources.YieldStatement))
End Sub
<Fact>
Public Sub MethodToIteratorMethod_WithActiveStatementInLambda()
Dim src1 = "
Imports System
Imports System.Collections.Generic
Class C
Function F() As IEnumerable(Of Integer)
Dim a = Sub() <AS:0>Console.WriteLine(1)</AS:0>
a()
Return {1, 1}
End Function
End Class
"
Dim src2 = "
Imports System
Imports System.Collections.Generic
Class C
Iterator Function F() As IEnumerable(Of Integer)
Dim a = Sub() <AS:0>Console.WriteLine(1)</AS:0>
a()
Yield 1
End Function
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact>
Public Sub MethodToIteratorMethod_WithoutActiveStatement()
Dim src1 = "
Imports System
Imports System.Collections.Generic
Class C
Function F() As IEnumerable(Of Integer)
Console.WriteLine(1)
Return {1, 1}
End Function
End Class
"
Dim src2 = "
Imports System
Imports System.Collections.Generic
Class C
Iterator Function F() As IEnumerable(Of Integer)
Console.WriteLine(1)
Yield 1
End Function
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact>
Public Sub MethodToAsyncMethod_WithActiveStatement1()
Dim src1 = "
Imports System
Imports System.Threading.Tasks
Class C
Function F() As Task(Of Integer)
<AS:0>Console.WriteLine(1)</AS:0>
Return Task.FromResult(1)
End Function
End Class
"
Dim src2 = "
Imports System
Imports System.Threading.Tasks
Class C
Async Function F() As Task(Of Integer)
<AS:0>Console.WriteLine(1)</AS:0>
Return Await Task.FromResult(1)
End Function
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.InsertAroundActiveStatement, "Await", VBFeaturesResources.AwaitExpression))
End Sub
<Fact>
Public Sub MethodToAsyncMethod_WithActiveStatement2()
Dim src1 = "
Imports System
Imports System.Threading.Tasks
Class C
<AS:0>Function F() As Task(Of Integer)</AS:0>
Console.WriteLine(1)
Return Task.FromResult(1)
End Function
End Class
"
Dim src2 = "
Imports System
Imports System.Threading.Tasks
Class C
<AS:0>Async Function F() As Task(Of Integer)</AS:0>
Console.WriteLine(1)
Return 1
End Function
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.UpdatingStateMachineMethodAroundActiveStatement, "Async Function F()"))
End Sub
<Fact>
Public Sub MethodToAsyncMethod_WithActiveStatement3()
Dim src1 = "
Imports System
Imports System.Threading.Tasks
Class C
Function F() As Task(Of Integer)
<AS:0>Console.WriteLine(1)</AS:0>
Return Task.FromResult(1)
End Function
End Class
"
Dim src2 = "
Imports System
Imports System.Threading.Tasks
Class C
Async Function F() As Task(Of Integer)
<AS:0>Console.WriteLine(1)</AS:0>
Return 1
End Function
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.UpdatingStateMachineMethodAroundActiveStatement, "Async Function F()"))
End Sub
<Fact>
Public Sub MethodToAsyncMethod_WithActiveStatementInLambda1()
Dim src1 = "
Imports System
Imports System.Threading.Tasks
Class C
Function F() As Task(Of Integer)
Dim a = Sub() <AS:0>Console.WriteLine(1)</AS:0>
Return Task.FromResult(1)
End Function
End Class
"
Dim src2 = "
Imports System
Imports System.Threading.Tasks
Class C
Async Function F() As Task(Of Integer)
Dim a = Sub() <AS:0>Console.WriteLine(1)</AS:0>
Return Await Task.FromResult(1)
End Function
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact>
Public Sub MethodToAsyncMethod_WithActiveStatementInLambda2()
Dim src1 = "
Imports System
Imports System.Threading.Tasks
Class C
Function F() As Task(Of Integer)
Dim a = Sub() <AS:1>Console.WriteLine(1)</AS:1>
<AS:0>a()</AS:0>
Return Task.FromResult(1)
End Function
End Class
"
Dim src2 = "
Imports System
Imports System.Threading.Tasks
Class C
Async Function F() As Task(Of Integer)
Dim a = Sub() <AS:1>Console.WriteLine(1)</AS:1>
<AS:0>a()</AS:0>
Return 1
End Function
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.UpdatingStateMachineMethodAroundActiveStatement, "Async Function F()"))
End Sub
<Fact>
Public Sub MethodToAsyncMethod_WithActiveStatementInLambda3()
Dim src1 = "
Imports System
Imports System.Threading.Tasks
Class C
Sub F()
Dim a = Sub() <AS:0>Console.WriteLine(1)</AS:0>
Return
End Sub
End Class
"
Dim src2 = "
Imports System
Imports System.Threading.Tasks
Class C
Async Sub F()
Dim a = Async Sub() <AS:0>Console.WriteLine(1)</AS:0>
Return
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.UpdatingStateMachineMethodAroundActiveStatement, "Async Sub()"))
End Sub
<Fact>
Public Sub MethodToAsyncMethod_WithActiveStatementInLambda4()
Dim src1 = "
Imports System
Imports System.Threading.Tasks
Class C
Sub F()
Dim a = Function() <AS:0>Task.FromResult(1)</AS:0>
Return
End Sub
End Class
"
Dim src2 = "
Imports System
Imports System.Threading.Tasks
Class C
Async Sub F()
Dim a = Async Function() <AS:0>1</AS:0>
Return
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.UpdatingStateMachineMethodAroundActiveStatement, "Async Function()"))
End Sub
<Fact>
Public Sub MethodToAsyncMethod_WithoutActiveStatement1()
Dim src1 = "
Imports System
Imports System.Threading.Tasks
Class C
Function F() As Task(Of Integer)
Console.WriteLine(1)
Return Task.FromResult(1)
End Function
End Class
"
Dim src2 = "
Imports System
Imports System.Threading.Tasks
Class C
Async Function F() As Task(Of Integer)
Console.WriteLine(1)
Return Await Task.FromResult(1)
End Function
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
<Fact>
Public Sub MethodToAsyncMethod_WithoutActiveStatement2()
Dim src1 = "
Imports System
Imports System.Threading.Tasks
Class C
Sub F()
Console.WriteLine(1)
Return
End Sub
End Class
"
Dim src2 = "
Imports System
Imports System.Threading.Tasks
Class C
Async Sub F()
Console.WriteLine(1)
Return
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active)
End Sub
#End Region
#Region "On Error"
<Fact>
Public Sub MethodUpdate_OnError1()
Dim src1 = "Class C" & vbLf & "Sub M()" & vbLf & "label : <AS:0>Console.Write(1)</AS:0> : On Error GoTo label : End Sub : End Class"
Dim src2 = "Class C" & vbLf & "Sub M()" & vbLf & "label : <AS:0>Console.Write(2)</AS:0> : On Error GoTo label : End Sub : End Class"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.UpdateAroundActiveStatement, "On Error GoTo label", VBFeaturesResources.OnErrorStatement))
End Sub
<Fact>
Public Sub MethodUpdate_OnError2()
Dim src1 = "Class C" & vbLf & "<AS:0>Sub M()</AS:0>" & vbLf & "Console.Write(1) : On Error GoTo 0 : End Sub : End Class"
Dim src2 = "Class C" & vbLf & "<AS:0>Sub M()</AS:0>" & vbLf & "Console.Write(2) : On Error GoTo 0 : End Sub : End Class"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.UpdateAroundActiveStatement, "On Error GoTo 0", VBFeaturesResources.OnErrorStatement))
End Sub
<Fact>
Public Sub MethodUpdate_OnError3()
Dim src1 = "Class C" & vbLf & "Sub M()" & vbLf & "Console.Write(1) : <AS:0>On Error GoTo -1</AS:0> : End Sub : End Class"
Dim src2 = "Class C" & vbLf & "Sub M()" & vbLf & "Console.Write(2) : <AS:0>On Error GoTo -1</AS:0> : End Sub : End Class"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.UpdateAroundActiveStatement, "On Error GoTo -1", VBFeaturesResources.OnErrorStatement))
End Sub
<Fact>
Public Sub MethodUpdate_OnError4()
Dim src1 = "Class C" & vbLf & "Sub M()" & vbLf & "Console.Write(1) : On Error Resume Next : <AS:0>End Sub</AS:0> : End Class"
Dim src2 = "Class C" & vbLf & "Sub M()" & vbLf & "Console.Write(2) : On Error Resume Next : <AS:0>End Sub</AS:0> : End Class"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.UpdateAroundActiveStatement, "On Error Resume Next", VBFeaturesResources.OnErrorStatement))
End Sub
<Fact>
Public Sub MethodUpdate_Resume1()
Dim src1 = "Class C" & vbLf & "Sub M()" & vbLf & "Console.Write(1) : <AS:0>Resume</AS:0> : End Sub : End Class"
Dim src2 = "Class C" & vbLf & "Sub M()" & vbLf & "Console.Write(2) : <AS:0>Resume</AS:0> : End Sub : End Class"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.UpdateAroundActiveStatement, "Resume", VBFeaturesResources.ResumeStatement))
End Sub
<Fact>
Public Sub MethodUpdate_Resume2()
Dim src1 = "Class C" & vbLf & "Sub M()" & vbLf & "Console.Write(1) : <AS:0>Resume Next</AS:0> : End Sub : End Class"
Dim src2 = "Class C" & vbLf & "Sub M()" & vbLf & "Console.Write(2) : <AS:0>Resume Next</AS:0> : End Sub : End Class"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.UpdateAroundActiveStatement, "Resume Next", VBFeaturesResources.ResumeStatement))
End Sub
<Fact>
Public Sub MethodUpdate_Resume3()
Dim src1 = "Class C" & vbLf & "Sub M()" & vbLf & "<AS:0>label :</AS:0> Console.Write(1) : Resume label : End Sub : End Class"
Dim src2 = "Class C" & vbLf & "Sub M()" & vbLf & "<AS:0>label :</AS:0> Console.Write(2) : Resume label : End Sub : End Class"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.UpdateAroundActiveStatement, "Resume label", VBFeaturesResources.ResumeStatement))
End Sub
#End Region
#Region "Unmodified Documents"
<Fact>
Public Sub UnmodifiedDocument1()
Dim src1 = "
Module C
Sub Main(args As String())
Try
Catch As IOException
Foo<AS:1>(</AS:1>)
Foo()
End Try
End Sub
Sub Foo()
Console.WriteLine(<AS:0>1</AS:0>)
End Sub
End Module"
Dim src2 = "
Module C
Sub Main(args As String())
Try
<ER:1.0>Catch e As IOException
<AS:1>Foo()</AS:1>
Foo()</ER:1.0>
End Try
End Sub
Sub Foo()
<AS:0>Console.WriteLine(1)</AS:0>
End Sub
End Module"
Dim active = GetActiveStatements(src1, src2)
Extensions.VerifyUnchangedDocument(src2, active)
End Sub
<Fact>
Public Sub UnmodifiedDocument_BadSpans1()
Dim src1 = "
Module C
<AS:2>Const a As Integer = 1</AS:2>
Sub Main(args As String())
Foo()
End Sub
<AS:1>
Sub</AS:1> Foo()
<AS:3>Console.WriteLine(1)</AS:3>
End Sub
End Module
<AS:0></AS:0>
"
Dim src2 = "
Module C
Const a As Integer = 1
Sub Main(args As String())
Foo()
End Sub
<AS:1>Sub Foo()</AS:1>
<AS:3>Console.WriteLine(1)</AS:3>
End Sub
End Module"
Dim active = GetActiveStatements(src1, src2)
Extensions.VerifyUnchangedDocument(src2, active)
End Sub
#End Region
<Fact>
Public Sub PartiallyExecutedActiveStatement()
Dim src1 As String = "
Class C
Sub F()
<AS:0>Console.WriteLine(1)</AS:0>
<AS:1>Console.WriteLine(2)</AS:1>
<AS:2>Console.WriteLine(3)</AS:2>
<AS:3>Console.WriteLine(4)</AS:3>
End Sub
End Class
"
Dim src2 As String = "
Class C
Sub F()
<AS:0>Console.WriteLine(10)</AS:0>
<AS:1>Console.WriteLine(20)</AS:1>
<AS:2>Console.WriteLine(30)</AS:2>
<AS:3>Console.WriteLine(40)</AS:3>
End Sub
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
active.OldSpans(0) = New ActiveStatementSpan(ActiveStatementFlags.PartiallyExecuted Or ActiveStatementFlags.LeafFrame, active.OldSpans(0).Span)
active.OldSpans(1) = New ActiveStatementSpan(ActiveStatementFlags.PartiallyExecuted, active.OldSpans(1).Span)
active.OldSpans(2) = New ActiveStatementSpan(ActiveStatementFlags.LeafFrame, active.OldSpans(2).Span)
active.OldSpans(3) = New ActiveStatementSpan(ActiveStatementFlags.None, active.OldSpans(3).Span)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.PartiallyExecutedActiveStatementUpdate, "Console.WriteLine(10)"),
Diagnostic(RudeEditKind.ActiveStatementUpdate, "Console.WriteLine(20)"),
Diagnostic(RudeEditKind.ActiveStatementUpdate, "Console.WriteLine(40)"))
End Sub
<Fact>
Public Sub PartiallyExecutedActiveStatement_Delete()
Dim src1 As String = "
Class C
Sub F()
<AS:0>Console.WriteLine(1)</AS:0>
End Sub
End Class
"
Dim src2 As String = "
Class C
Sub F()
<AS:0>End Sub</AS:0>
End Class
"
Dim edits = GetTopEdits(src1, src2)
Dim active = GetActiveStatements(src1, src2)
active.OldSpans(0) = New ActiveStatementSpan(ActiveStatementFlags.PartiallyExecuted Or ActiveStatementFlags.LeafFrame, active.OldSpans(0).Span)
edits.VerifyRudeDiagnostics(active,
Diagnostic(RudeEditKind.PartiallyExecutedActiveStatementDelete, "Sub F()"))
End Sub
End Class
End Namespace
|
ValentinRueda/roslyn
|
src/EditorFeatures/VisualBasicTest/EditAndContinue/ActiveStatementTests.vb
|
Visual Basic
|
apache-2.0
| 130,307
|
' Licensed to the .NET Foundation under one or more agreements.
' The .NET Foundation licenses this file to you under the MIT license.
' See the LICENSE file in the project root for more information.
Imports System.Text
Imports System.Windows
Imports Microsoft.CodeAnalysis.Editor.CommandHandlers
Imports Microsoft.CodeAnalysis.Editor.UnitTests.Extensions
Imports Microsoft.CodeAnalysis.Editor.UnitTests.Utilities
Imports Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces
Imports Microsoft.VisualStudio.InteractiveWindow
Imports Microsoft.VisualStudio.Text.Editor.Commanding.Commands
Imports Microsoft.VisualStudio.Text.Operations
Namespace Microsoft.CodeAnalysis.Editor.UnitTests.InteractivePaste
<[UseExportProvider]>
Public Class InteractivePasteCommandhandlerTests
Private Const ClipboardLineBasedCutCopyTag As String = "VisualStudioEditorOperationsLineCutCopyClipboardTag"
Private Const BoxSelectionCutCopyTag As String = "MSDEVColumnSelect"
Private Shared Function CreateCommandHandler(workspace As TestWorkspace) As InteractivePasteCommandHandler
Dim handler = workspace.ExportProvider.GetCommandHandler(Of InteractivePasteCommandHandler)(PredefinedCommandHandlerNames.InteractivePaste)
handler.RoslynClipboard = New MockClipboard()
Return handler
End Function
<WpfFact>
<Trait(Traits.Feature, Traits.Features.Interactive)>
Public Sub PasteCommandWithInteractiveFormat()
Using workspace = TestWorkspace.Create(
<Workspace>
<Project Language="C#" CommonReferences="true">
<Document/>
</Project>
</Workspace>,
composition:=EditorTestCompositions.EditorFeaturesWpf)
Dim textView = workspace.Documents.Single().GetTextView()
Dim handler = CreateCommandHandler(workspace)
Dim clipboard = DirectCast(handler.RoslynClipboard, MockClipboard)
Dim json = "
[
{""content"":""a\u000d\u000abc"",""kind"":1},
{""content"":""> "",""kind"":0},
{""content"":""< "",""kind"":0},
{""content"":""12"",""kind"":2},
{""content"":""3"",""kind"":3},
]"
Dim text = $"a{vbCrLf}bc123"
CopyToClipboard(clipboard, text, json, includeRepl:=True, isLineCopy:=False, isBoxCopy:=False)
Assert.True(handler.ExecuteCommand(New PasteCommandArgs(textView, textView.TextBuffer), TestCommandExecutionContext.Create()))
Assert.Equal("a" & vbCrLf & "bc123", textView.TextBuffer.CurrentSnapshot.GetText())
End Using
End Sub
<WpfFact>
<Trait(Traits.Feature, Traits.Features.Interactive)>
Public Sub PasteCommandWithOutInteractiveFormat()
Using workspace = TestWorkspace.Create(
<Workspace>
<Project Language="C#" CommonReferences="true">
<Document/>
</Project>
</Workspace>,
composition:=EditorTestCompositions.EditorFeaturesWpf)
Dim textView = workspace.Documents.Single().GetTextView()
Dim editorOperations = workspace.GetService(Of IEditorOperationsFactoryService)().GetEditorOperations(textView)
Dim handler = CreateCommandHandler(workspace)
Dim clipboard = DirectCast(handler.RoslynClipboard, MockClipboard)
Dim json = "
[
{""content"":""a\u000d\u000abc"",""kind"":1},
{""content"":""> "",""kind"":0},
{""content"":""< "",""kind"":0},
{""content"":""12"",""kind"":2},
{""content"":""3"",""kind"":3}]
]"
Dim text = $"a{vbCrLf}bc123"
CopyToClipboard(clipboard, text, json, includeRepl:=False, isLineCopy:=False, isBoxCopy:=False)
If Not handler.ExecuteCommand(New PasteCommandArgs(textView, textView.TextBuffer), TestCommandExecutionContext.Create()) Then
editorOperations.InsertText("p")
End If
Assert.Equal("p", textView.TextBuffer.CurrentSnapshot.GetText())
End Using
End Sub
<WpfFact>
<Trait(Traits.Feature, Traits.Features.Interactive)>
Public Sub PasteCommandWithInteractiveFormatAsLineCopy()
Using workspace = TestWorkspace.Create(
<Workspace>
<Project Language="C#" CommonReferences="true">
<Document/>
</Project>
</Workspace>,
composition:=EditorTestCompositions.EditorFeaturesWpf)
Dim textView = workspace.Documents.Single().GetTextView()
Dim editorOperations = workspace.GetService(Of IEditorOperationsFactoryService)().GetEditorOperations(textView)
editorOperations.InsertText("line1")
editorOperations.InsertNewLine()
editorOperations.InsertText("line2")
Assert.Equal("line1" & vbCrLf & " line2", textView.TextBuffer.CurrentSnapshot.GetText())
Dim handler = CreateCommandHandler(workspace)
Dim clipboard = DirectCast(handler.RoslynClipboard, MockClipboard)
Dim json = "
[
{""content"":""> "",""kind"":0},
{""content"":""InsertedLine"",""kind"":2},
{""content"":""\u000d\u000a"",""kind"":4}]
]"
Dim text = $"InsertedLine{vbCrLf}"
CopyToClipboard(clipboard, text, json, includeRepl:=True, isLineCopy:=True, isBoxCopy:=False)
Assert.True(handler.ExecuteCommand(New PasteCommandArgs(textView, textView.TextBuffer), TestCommandExecutionContext.Create()))
Assert.Equal("line1" & vbCrLf & "InsertedLine" & vbCrLf & " line2", textView.TextBuffer.CurrentSnapshot.GetText())
End Using
End Sub
<WpfFact>
<Trait(Traits.Feature, Traits.Features.Interactive)>
Public Sub PasteCommandWithInteractiveFormatAsBoxCopy()
Using workspace = TestWorkspace.Create(
<Workspace>
<Project Language="C#" CommonReferences="true">
<Document/>
</Project>
</Workspace>,
composition:=EditorTestCompositions.EditorFeaturesWpf)
Dim textView = workspace.Documents.Single().GetTextView()
Dim editorOperations = workspace.GetService(Of IEditorOperationsFactoryService)().GetEditorOperations(textView)
editorOperations.InsertText("line1")
editorOperations.InsertNewLine()
editorOperations.InsertText("line2")
editorOperations.MoveLineUp(False)
editorOperations.MoveToPreviousCharacter(False)
Assert.Equal("line1" & vbCrLf & " line2", textView.TextBuffer.CurrentSnapshot.GetText())
Dim handler = CreateCommandHandler(workspace)
Dim clipboard = DirectCast(handler.RoslynClipboard, MockClipboard)
Dim json = "
[
{""content"":""> "",""kind"":0},
{""content"":""BoxLine1"",""kind"":2},
{""content"":""\u000d\u000a"",""kind"":4},
{""content"":""> "",""kind"":0},
{""content"":""BoxLine2"",""kind"":2},
{""content"":""\u000d\u000a"",""kind"":4}]
]"
Dim text = $"BoxLine1{vbCrLf}BoxLine2{vbCrLf}"
CopyToClipboard(clipboard, text, json, includeRepl:=True, isLineCopy:=False, isBoxCopy:=True)
Assert.True(handler.ExecuteCommand(New PasteCommandArgs(textView, textView.TextBuffer), TestCommandExecutionContext.Create()))
Assert.Equal("lineBoxLine11" & vbCrLf & " BoxLine2line2", textView.TextBuffer.CurrentSnapshot.GetText())
End Using
End Sub
<WpfFact>
<Trait(Traits.Feature, Traits.Features.Interactive)>
Public Sub PasteCommandWithInteractiveFormatAsBoxCopyOnBlankLine()
Using workspace = TestWorkspace.Create(
<Workspace>
<Project Language="C#" CommonReferences="true">
<Document/>
</Project>
</Workspace>,
composition:=EditorTestCompositions.EditorFeaturesWpf)
Dim textView = workspace.Documents.Single().GetTextView()
Dim editorOperations = workspace.GetService(Of IEditorOperationsFactoryService)().GetEditorOperations(textView)
editorOperations.InsertNewLine()
editorOperations.InsertText("line1")
editorOperations.InsertNewLine()
editorOperations.InsertText("line2")
editorOperations.MoveLineUp(False)
editorOperations.MoveLineUp(False)
Assert.Equal(vbCrLf & "line1" & vbCrLf & " line2", textView.TextBuffer.CurrentSnapshot.GetText())
Dim handler = CreateCommandHandler(workspace)
Dim clipboard = DirectCast(handler.RoslynClipboard, MockClipboard)
Dim json = "
[
{""content"":""> "",""kind"":0},
{""content"":""BoxLine1"",""kind"":2},
{""content"":""\u000d\u000a"",""kind"":4},
{""content"":""> "",""kind"":0},
{""content"":""BoxLine2"",""kind"":2},
{""content"":""\u000d\u000a"",""kind"":4}
]"
Dim text = $"> BoxLine1{vbCrLf}> BoxLine2{vbCrLf}"
CopyToClipboard(clipboard, text, json, includeRepl:=True, isLineCopy:=False, isBoxCopy:=True)
Assert.True(handler.ExecuteCommand(New PasteCommandArgs(textView, textView.TextBuffer), TestCommandExecutionContext.Create()))
Assert.Equal("BoxLine1" & vbCrLf & "BoxLine2" & vbCrLf & "line1" & vbCrLf & " line2", textView.TextBuffer.CurrentSnapshot.GetText())
End Using
End Sub
Private Shared Sub CopyToClipboard(clipboard As MockClipboard, text As String, json As String, includeRepl As Boolean, isLineCopy As Boolean, isBoxCopy As Boolean)
clipboard.Clear()
Dim data = New DataObject()
Dim builder = New StringBuilder()
data.SetData(DataFormats.UnicodeText, text)
data.SetData(DataFormats.StringFormat, text)
If includeRepl Then
data.SetData(InteractiveClipboardFormat.Tag, json)
End If
If isLineCopy Then
data.SetData(ClipboardLineBasedCutCopyTag, True)
End If
If isBoxCopy Then
data.SetData(BoxSelectionCutCopyTag, True)
End If
clipboard.SetDataObject(data)
End Sub
Private Class MockClipboard
Implements InteractivePasteCommandHandler.IRoslynClipboard
Private _data As DataObject
Friend Sub Clear()
_data = Nothing
End Sub
Friend Sub SetDataObject(data As Object)
_data = DirectCast(data, DataObject)
End Sub
Public Function ContainsData(format As String) As Boolean Implements InteractivePasteCommandHandler.IRoslynClipboard.ContainsData
Return _data IsNot Nothing And _data.GetData(format) IsNot Nothing
End Function
Public Function GetData(format As String) As Object Implements InteractivePasteCommandHandler.IRoslynClipboard.GetData
If _data Is Nothing Then
Return Nothing
Else
Return _data.GetData(format)
End If
End Function
Public Function GetDataObject() As IDataObject Implements InteractivePasteCommandHandler.IRoslynClipboard.GetDataObject
Return _data
End Function
End Class
End Class
End Namespace
|
physhi/roslyn
|
src/EditorFeatures/Test2/InteractivePaste/InteractivePasteCommandHandlerTests.vb
|
Visual Basic
|
apache-2.0
| 12,291
|
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports Microsoft.CodeAnalysis.Formatting
Imports Microsoft.CodeAnalysis.Options
Imports Microsoft.CodeAnalysis.Test.Utilities
Imports Microsoft.CodeAnalysis.Text
Imports Microsoft.CodeAnalysis.VisualBasic
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Imports Roslyn.Test.Utilities
Imports Xunit
Namespace Microsoft.CodeAnalysis.VisualBasic.UnitTests.Formatting
Public Class FormattingTest
Inherits VisualBasicFormattingTestBase
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function Format1() As Task
Dim code = <Code>
Namespace A
End Namespace </Code>
Dim expected = <Code>
Namespace A
End Namespace</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function NamespaceBlock() As Task
Dim code = <Code> Namespace A
Class C
End Class
End Namespace </Code>
Dim expected = <Code>Namespace A
Class C
End Class
End Namespace</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function TypeBlock() As Task
Dim code = <Code> Class C
Sub Method ( )
End Sub
End Class
</Code>
Dim expected = <Code>Class C
Sub Method()
End Sub
End Class
</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function MethodBlock() As Task
Dim code = <Code> Class C
Sub Method ( )
Dim a As Integer = 1
End Sub
End Class
</Code>
Dim expected = <Code>Class C
Sub Method()
Dim a As Integer = 1
End Sub
End Class
</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function StructBlock() As Task
Dim code = <Code> Structure C
Sub Method ( )
Dim a As Integer = 1
End Sub
Dim field As Integer
End Structure
</Code>
Dim expected = <Code>Structure C
Sub Method()
Dim a As Integer = 1
End Sub
Dim field As Integer
End Structure
</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function EnumBlock() As Task
Dim code = <Code> Enum C
A
B
X
Z
End Enum </Code>
Dim expected = <Code>Enum C
A
B
X
Z
End Enum</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function ModuleBlock() As Task
Dim code = <Code> Module module1
Sub foo()
End Sub
End Module </Code>
Dim expected = <Code>Module module1
Sub foo()
End Sub
End Module</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function InterfaceBlock() As Task
Dim code = <Code> Interface IFoo
Sub foo()
End Interface
</Code>
Dim expected = <Code>Interface IFoo
Sub foo()
End Interface
</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function PropertyBlock() As Task
Dim code = <Code> Class C
Property P ( ) As Integer
Get
Return 1
End Get
Set ( ByVal value As Integer )
End Set
End Property
End Class </Code>
Dim expected = <Code>Class C
Property P() As Integer
Get
Return 1
End Get
Set(ByVal value As Integer)
End Set
End Property
End Class</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function EventBlock() As Task
Dim code = <Code> Class C
Public Custom Event MouseDown As EventHandler
AddHandler ( ByVal Value As EventHandler )
Dim i As Integer = 1
End AddHandler
RemoveHandler ( ByVal Value As EventHandler )
Dim i As Integer = 1
End RemoveHandler
RaiseEvent ( ByVal sender As Object, ByVal e As Object )
Dim i As Integer = 1
End RaiseEvent
End Event
End Class </Code>
Dim expected = <Code>Class C
Public Custom Event MouseDown As EventHandler
AddHandler(ByVal Value As EventHandler)
Dim i As Integer = 1
End AddHandler
RemoveHandler(ByVal Value As EventHandler)
Dim i As Integer = 1
End RemoveHandler
RaiseEvent(ByVal sender As Object, ByVal e As Object)
Dim i As Integer = 1
End RaiseEvent
End Event
End Class</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function WhileBlockNode() As Task
Dim code = <Code>Class C
Sub Method ( )
While True
Dim i As Integer = 1
End While
End Sub
End Class</Code>
Dim expected = <Code>Class C
Sub Method()
While True
Dim i As Integer = 1
End While
End Sub
End Class</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function UsingBlockNode() As Task
Dim code = <Code>Class C
Sub Method()
Using TraceSource
Dim i = 1
End Using
End Sub
End Class</Code>
Dim expected = <Code>Class C
Sub Method()
Using TraceSource
Dim i = 1
End Using
End Sub
End Class</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function SyncLockBlockNode() As Task
Dim code = <Code>Class C
Sub Method()
SyncLock New Object
Dim i = 10
End SyncLock
End Sub
End Class</Code>
Dim expected = <Code>Class C
Sub Method()
SyncLock New Object
Dim i = 10
End SyncLock
End Sub
End Class</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function WithBlockNode() As Task
Dim code = <Code>Class C
Sub Method()
With New Object
Dim i As Integer = 1
End With
End Sub
End Class</Code>
Dim expected = <Code>Class C
Sub Method()
With New Object
Dim i As Integer = 1
End With
End Sub
End Class</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function IfBlockNode() As Task
Dim code = <Code>Class C
Sub Method()
If True Then
Dim i As Integer = 1
ElseIf True Then
Dim i As Integer = 1
Else
Dim i As Integer = 1
End If
End Sub
End Class</Code>
Dim expected = <Code>Class C
Sub Method()
If True Then
Dim i As Integer = 1
ElseIf True Then
Dim i As Integer = 1
Else
Dim i As Integer = 1
End If
End Sub
End Class</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function TryCatchBlockNode() As Task
Dim code = <Code>Class C
Sub Method()
Try
Dim i As Integer = 1
Catch e As Exception When TypeOf e Is ArgumentNullException
Try
Dim i As Integer = 1
Catch ex As ArgumentNullException
End Try
Catch e As Exception When TypeOf e Is ArgumentNullException
Dim i As Integer = 1
Finally
foo()
End Try
End Sub
End Class</Code>
Dim expected = <Code>Class C
Sub Method()
Try
Dim i As Integer = 1
Catch e As Exception When TypeOf e Is ArgumentNullException
Try
Dim i As Integer = 1
Catch ex As ArgumentNullException
End Try
Catch e As Exception When TypeOf e Is ArgumentNullException
Dim i As Integer = 1
Finally
foo()
End Try
End Sub
End Class</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function SelectBlockNode() As Task
Dim code = <Code>Class C
Sub Method()
Dim i = 1
Select Case i
Case 1 , 2 , 3
Dim i2 = 1
Case 1 To 3
Dim i2 = 1
Case Else
Dim i2 = 1
End Select
End Sub
End Class</Code>
Dim expected = <Code>Class C
Sub Method()
Dim i = 1
Select Case i
Case 1, 2, 3
Dim i2 = 1
Case 1 To 3
Dim i2 = 1
Case Else
Dim i2 = 1
End Select
End Sub
End Class</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function DoLoopBlockNode() As Task
Dim code = <Code>Class C
Sub Method()
Do
Dim i = 1
Loop
End Sub
End Class</Code>
Dim expected = <Code>Class C
Sub Method()
Do
Dim i = 1
Loop
End Sub
End Class</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function DoUntilBlockNode() As Task
Dim code = <Code>Class C
Sub Method()
Do Until False
foo()
Loop
End Sub
End Class</Code>
Dim expected = <Code>Class C
Sub Method()
Do Until False
foo()
Loop
End Sub
End Class</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function ForBlockNode() As Task
Dim code = <Code>Class C
Sub Method()
For i = 1 To 10 Step 1
Dim a = 1
Next
End Sub
End Class</Code>
Dim expected = <Code>Class C
Sub Method()
For i = 1 To 10 Step 1
Dim a = 1
Next
End Sub
End Class</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function AnchorStatement() As Task
Dim code = <Code>Imports System
Imports System.
Collections.
Generic</Code>
Dim expected = <Code>Imports System
Imports System.
Collections.
Generic</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function AnchorQueryStatement() As Task
Dim code = <Code>Class C
Sub Method()
Dim a = From q In
{1, 3, 5}
Where q > 10
Select q
End Sub
End Class</Code>
Dim expected = <Code>Class C
Sub Method()
Dim a = From q In
{1, 3, 5}
Where q > 10
Select q
End Sub
End Class</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function AlignQueryStatement() As Task
Dim code = <Code>Class C
Sub Method()
Dim a = From q In {1, 3, 5}
Where q > 10
Select q
End Sub
End Class</Code>
Dim expected = <Code>Class C
Sub Method()
Dim a = From q In {1, 3, 5}
Where q > 10
Select q
End Sub
End Class</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function Operators1() As Task
Dim code = <Code>Class C
Sub Method()
Dim a = - 1
Dim a2 = 1-1
Dim a3 = + 1
Dim a4 = 1+1
Dim a5 = 2+(3*-2)
Foo(2,(3))
End Sub
End Class
</Code>
Dim expected = <Code>Class C
Sub Method()
Dim a = -1
Dim a2 = 1 - 1
Dim a3 = +1
Dim a4 = 1 + 1
Dim a5 = 2 + (3 * -2)
Foo(2, (3))
End Sub
End Class
</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function Operators2() As Task
Dim code = <Code>Class C
Sub Method()
Dim myStr As String
myStr = "Hello" & " World"
End Sub
End Class</Code>
Dim expected = <Code>Class C
Sub Method()
Dim myStr As String
myStr = "Hello" & " World"
End Sub
End Class</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function Operators3() As Task
Dim code = <Code>Class C
Sub Method()
Dim a1 = 1 <= 2
Dim a2 = 2 >= 3
Dim a3 = 4 <> 5
Dim a4 = 5 ^ 4
Dim a5 = 0
a5 +=1
a5 -=1
a5 *=1
a5 /=1
a5 \=1
a5 ^=1
a5<<= 1
a5>>= 1
a5 &= 1
a5 = a5<< 1
a5 = a5>> 1
End Sub
End Class</Code>
Dim expected = <Code>Class C
Sub Method()
Dim a1 = 1 <= 2
Dim a2 = 2 >= 3
Dim a3 = 4 <> 5
Dim a4 = 5 ^ 4
Dim a5 = 0
a5 += 1
a5 -= 1
a5 *= 1
a5 /= 1
a5 \= 1
a5 ^= 1
a5 <<= 1
a5 >>= 1
a5 &= 1
a5 = a5 << 1
a5 = a5 >> 1
End Sub
End Class</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function Punctuation() As Task
Dim code = <Code> < Fact ( ) , Trait ( Traits . Feature , Traits . Features . Formatting ) >
Class A
End Class</Code>
Dim expected = <Code><Fact(), Trait(Traits.Feature, Traits.Features.Formatting)>
Class A
End Class</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function Punctuation2() As Task
Dim code = <Code>Class C
Sub Method(Optional ByVal i As Integer = 1)
Method(i := 1)
End Sub
End Class</Code>
Dim expected = <Code>Class C
Sub Method(Optional ByVal i As Integer = 1)
Method(i:=1)
End Sub
End Class</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function Punctuation3() As Task
Dim code = <Code><![CDATA[Class C
<Attribute(foo := "value")>
Sub Method()
End Sub
End Class]]></Code>
Dim expected = <Code><![CDATA[Class C
<Attribute(foo:="value")>
Sub Method()
End Sub
End Class]]></Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function Lambda1() As Task
Dim code = <Code>Class C
Sub Method(Optional ByVal i As Integer = 1)
Dim q = Function ( t ) 1
Dim q2=Sub ( t )Console . WriteLine ( t )
End Sub
End Class</Code>
Dim expected = <Code>Class C
Sub Method(Optional ByVal i As Integer = 1)
Dim q = Function(t) 1
Dim q2 = Sub(t) Console.WriteLine(t)
End Sub
End Class</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function Lambda2() As Task
Dim code = <Code>Class C
Sub Method(Optional ByVal i As Integer = 1)
Dim q = Function ( t )
Return 1
End Function
Dim q2 = Sub ( t )
Dim a = t
End Sub
End Sub
End Class</Code>
Dim expected = <Code>Class C
Sub Method(Optional ByVal i As Integer = 1)
Dim q = Function(t)
Return 1
End Function
Dim q2 = Sub(t)
Dim a = t
End Sub
End Sub
End Class</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function Lambda3() As Task
Dim code = <Code>Class C
Sub Method(Optional ByVal i As Integer = 1)
Dim q =
Function ( t )
Return 1
End Function
Dim q2 =
Sub ( t )
Dim a = t
End Sub
End Sub
End Class</Code>
Dim expected = <Code>Class C
Sub Method(Optional ByVal i As Integer = 1)
Dim q =
Function(t)
Return 1
End Function
Dim q2 =
Sub(t)
Dim a = t
End Sub
End Sub
End Class</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function Lambda4() As Task
Dim code = <Code>Class C
Sub Method(Optional ByVal i As Integer = 1)
Dim q =
Function ( t )
Return 1
End Function
Dim q2 =
Sub ( t )
Dim a = t
Dim bbb = Function(r)
Return r
End Function
End Sub
End Sub
End Class</Code>
Dim expected = <Code>Class C
Sub Method(Optional ByVal i As Integer = 1)
Dim q =
Function(t)
Return 1
End Function
Dim q2 =
Sub(t)
Dim a = t
Dim bbb = Function(r)
Return r
End Function
End Sub
End Sub
End Class</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function LineContinuation1() As Task
Dim code = <Code>Class C
Sub Method(Optional ByVal i As Integer = 1)
Dim a = 1 + _
2 + _
3
End Sub
End Class</Code>
Dim expected = <Code>Class C
Sub Method(Optional ByVal i As Integer = 1)
Dim a = 1 + _
2 + _
3
End Sub
End Class</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function LineContinuation2() As Task
Dim code = <Code>Class C
Sub Method(Optional ByVal i As Integer = 1)
Dim aa = 1 + _
2 + _
3
End Sub
End Class</Code>
Dim expected = <Code>Class C
Sub Method(Optional ByVal i As Integer = 1)
Dim aa = 1 + _
2 + _
3
End Sub
End Class</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function LineContinuation3() As Task
Dim code = <Code>Class C
Sub Method(Optional ByVal i As Integer = 1)
Dim aa = 1 + _
2 + _
3
End Sub
End Class</Code>
Dim expected = <Code>Class C
Sub Method(Optional ByVal i As Integer = 1)
Dim aa = 1 + _
2 + _
3
End Sub
End Class</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function LineContinuation4() As Task
Dim code = <Code>Class C
Sub Method(Optional ByVal i As Integer = 1)
Dim aa = 1 + _
_
_
_
_
_
2 + _
3
End Sub
End Class</Code>
Dim expected = <Code>Class C
Sub Method(Optional ByVal i As Integer = 1)
Dim aa = 1 + _
_
_
_
_
_
2 + _
3
End Sub
End Class</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function AnonType() As Task
Dim code = <Code>Class Foo
Sub FooMethod()
Dim SomeAnonType = New With {
.foo = "foo",
.answer = 42
}
End Sub
End Class</Code>
Dim expected = <Code>Class Foo
Sub FooMethod()
Dim SomeAnonType = New With {
.foo = "foo",
.answer = 42
}
End Sub
End Class</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function CollectionInitializer() As Task
Dim code = <Code>Class Foo
Sub FooMethod()
Dim somelist = New List(Of Integer) From {
1,
2,
3
}
End Sub
End Class</Code>
Dim expected = <Code>Class Foo
Sub FooMethod()
Dim somelist = New List(Of Integer) From {
1,
2,
3
}
End Sub
End Class</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function Label1() As Task
Dim code = <Code>Class C
Sub Method()
GoTo l
l: Stop
End Sub
End Class</Code>
Dim expected = <Code>Class C
Sub Method()
GoTo l
l: Stop
End Sub
End Class</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function Label2() As Task
Dim code = <Code>Class C
Sub Method()
GoTo foofoofoofoofoo
foofoofoofoofoo: Stop
End Sub
End Class</Code>
Dim expected = <Code>Class C
Sub Method()
GoTo foofoofoofoofoo
foofoofoofoofoo: Stop
End Sub
End Class</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function Label3() As Task
Dim code = <Code>Class C
Sub Foo()
foo()
x : foo()
y :
foo()
End Sub
End Class</Code>
Dim expected = <Code>Class C
Sub Foo()
foo()
x: foo()
y:
foo()
End Sub
End Class</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function Trivia1() As Task
Dim code = <Code>Class C
Sub Method(Optional ByVal i As Integer = 1)
' Test
' Test2
' Test 3
Dim a = 1
End Sub
End Class</Code>
Dim expected = <Code>Class C
Sub Method(Optional ByVal i As Integer = 1)
' Test
' Test2
' Test 3
Dim a = 1
End Sub
End Class</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function Trivia2() As Task
Dim code = <Code>Class C
Sub Method(Optional ByVal i As Integer = 1)
''' Test
''' Test2
''' Test 3
Dim a = 1
End Sub
End Class</Code>
Dim expected = <Code>Class C
Sub Method(Optional ByVal i As Integer = 1)
''' Test
''' Test2
''' Test 3
Dim a = 1
End Sub
End Class</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function Trivia3() As Task
Dim code = <Code>Class C
Sub Method(Optional ByVal i As Integer = 1)
Dim a = _
_
_
1
End Sub
End Class</Code>
Dim expected = <Code>Class C
Sub Method(Optional ByVal i As Integer = 1)
Dim a = _
_
_
1
End Sub
End Class</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<WorkItem(538354, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/538354")>
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function BugFix3939() As Task
Dim code = <Code>
Imports System.
Collections.
Generic </Code>
Dim expected = <Code>
Imports System.
Collections.
Generic</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<WorkItem(538579, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/538579")>
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function BugFix4235() As Task
Dim code = <Code>
#If False Then
#End If
</Code>
Dim expected = <Code>
#If False Then
#End If
</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function XmlLiterals1() As Task
Dim code = "Dim xml = < XML > </ XML > "
Dim expected = " Dim xml = <XML></XML>"
Await AssertFormatAsync(CreateMethod(code), CreateMethod(expected))
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function XmlLiterals2() As Task
Dim code = "Dim xml = < XML > <%= a %> </ XML > "
Dim expected = " Dim xml = <XML><%= a %></XML>"
Await AssertFormatAsync(CreateMethod(code), CreateMethod(expected))
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function XmlLiterals3() As Task
Dim code = "Dim xml = < local : XML > </ local : XML > "
Dim expected = " Dim xml = <local:XML></local:XML>"
Await AssertFormatAsync(CreateMethod(code), CreateMethod(expected))
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function XmlLiterals4() As Task
Dim code = "Dim xml = < local :<%= hello %> > </ > "
Dim expected = " Dim xml = <local:<%= hello %>></>"
Await AssertFormatAsync(CreateMethod(code), CreateMethod(expected))
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function XmlLiterals5() As Task
Dim code = "Dim xml = < <%= hello %> > </ > "
Dim expected = " Dim xml = <<%= hello %>></>"
Await AssertFormatAsync(CreateMethod(code), CreateMethod(expected))
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function XmlLiterals6() As Task
Dim code = "Dim xml = < <%= hello %> /> "
Dim expected = " Dim xml = <<%= hello %>/>"
Await AssertFormatAsync(CreateMethod(code), CreateMethod(expected))
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function XmlLiterals7() As Task
Dim code = "Dim xml = < xml attr = ""1"" /> "
Dim expected = " Dim xml = <xml attr=""1""/>"
Await AssertFormatAsync(CreateMethod(code), CreateMethod(expected))
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function XmlLiterals8() As Task
Dim code = "Dim xml = < xml attr = '1' /> "
Dim expected = " Dim xml = <xml attr='1'/>"
Await AssertFormatAsync(CreateMethod(code), CreateMethod(expected))
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function XmlLiterals9() As Task
Dim code = "Dim xml = < xml attr = '1' attr2 = ""2"" attr3 = <%= hello %> /> "
Dim expected = " Dim xml = <xml attr='1' attr2=""2"" attr3=<%= hello %>/>"
Await AssertFormatAsync(CreateMethod(code), CreateMethod(expected))
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function XmlLiterals10() As Task
Dim code = "Dim xml = < xml local:attr = '1' attr2 = ""2"" attr3 = <%= hello %> /> "
Dim expected = " Dim xml = <xml local:attr='1' attr2=""2"" attr3=<%= hello %>/>"
Await AssertFormatAsync(CreateMethod(code), CreateMethod(expected))
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function XmlLiterals11() As Task
Dim code = "Dim xml = < xml local:attr = '1' <%= attr2 %> = ""2"" local:<%= attr3 %> = <%= hello %> /> "
Dim expected = " Dim xml = <xml local:attr='1' <%= attr2 %>=""2"" local:<%= attr3 %>=<%= hello %>/>"
Await AssertFormatAsync(CreateMethod(code), CreateMethod(expected))
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function XmlLiterals12() As Task
Dim code = "Dim xml = < xml> test </xml > "
Dim expected = " Dim xml = <xml> test </xml>"
Await AssertFormatAsync(CreateMethod(code), CreateMethod(expected))
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function XmlLiterals13() As Task
Dim code = "Dim xml = < xml> test <%= test %> </xml > "
Dim expected = " Dim xml = <xml> test <%= test %></xml>"
Await AssertFormatAsync(CreateMethod(code), CreateMethod(expected))
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function XmlLiterals14() As Task
Dim code = "Dim xml = < xml> test <%= test %> <%= test2 %> </xml > "
Dim expected = " Dim xml = <xml> test <%= test %><%= test2 %></xml>"
Await AssertFormatAsync(CreateMethod(code), CreateMethod(expected))
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function XmlLiterals15() As Task
Dim code = "Dim xml = < xml> <%= test1 %> test <%= test %> <%= test2 %> </xml > "
Dim expected = " Dim xml = <xml><%= test1 %> test <%= test %><%= test2 %></xml>"
Await AssertFormatAsync(CreateMethod(code), CreateMethod(expected))
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function XmlLiterals16() As Task
Dim code = "Dim xml = < xml> <!-- test --> </xml > "
Dim expected = " Dim xml = <xml><!-- test --></xml>"
Await AssertFormatAsync(CreateMethod(code), CreateMethod(expected))
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function XmlLiterals17() As Task
Dim code = "Dim xml = <xml> <test/> <!-- test --> test <!-- test --> </xml> "
Dim expected = " Dim xml = <xml><test/><!-- test --> test <!-- test --></xml>"
Await AssertFormatAsync(CreateMethod(code), CreateMethod(expected))
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function XmlLiterals18() As Task
Dim code = "Dim xml = <!-- test -->"
Dim expected = " Dim xml = <!-- test -->"
Await AssertFormatAsync(CreateMethod(code), CreateMethod(expected))
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function XmlLiterals19() As Task
Dim code = "Dim xml = <?xml-stylesheet type = ""text/xsl"" href = ""show_book.xsl""?>"
Dim expected = " Dim xml = <?xml-stylesheet type = ""text/xsl"" href = ""show_book.xsl""?>"
Await AssertFormatAsync(CreateMethod(code), CreateMethod(expected))
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function XmlLiterals20() As Task
Dim code = "Dim xml = <xml> <test/> <!-- test --> test <!-- test --> <?xml-stylesheet type = 'text/xsl' href = show_book.xsl?> </xml> "
Dim expected = " Dim xml = <xml><test/><!-- test --> test <!-- test --><?xml-stylesheet type = 'text/xsl' href = show_book.xsl?></xml>"
Await AssertFormatAsync(CreateMethod(code), CreateMethod(expected))
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function XmlLiterals21() As Task
Dim code = "Dim xml = <xml> <test/> <!-- test --> test <!-- test --> test 2 <?xml-stylesheet type = 'text/xsl' href = show_book.xsl?> </xml> "
Dim expected = " Dim xml = <xml><test/><!-- test --> test <!-- test --> test 2 <?xml-stylesheet type = 'text/xsl' href = show_book.xsl?></xml>"
Await AssertFormatAsync(CreateMethod(code), CreateMethod(expected))
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function XmlLiterals22() As Task
Dim code = "Dim xml = <![CDATA[ Can contain literal <XML> tags ]]> "
Dim expected = " Dim xml = <![CDATA[ Can contain literal <XML> tags ]]>"
Await AssertFormatAsync(CreateMethod(code), CreateMethod(expected))
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function XmlLiterals23() As Task
Dim code = "Dim xml = <xml> <test/> <!-- test --> test <![CDATA[ Can contain literal <XML> tags ]]> <!-- test --> test 2 <?xml-stylesheet type = 'text/xsl' href = show_book.xsl?> </xml> "
Dim expected = " Dim xml = <xml><test/><!-- test --> test <![CDATA[ Can contain literal <XML> tags ]]><!-- test --> test 2 <?xml-stylesheet type = 'text/xsl' href = show_book.xsl?></xml>"
Await AssertFormatAsync(CreateMethod(code), CreateMethod(expected))
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function XmlLiterals24() As Task
Dim code = "Dim xml = <xml> <test> <%= <xml> <test id=""42""><%=42 %> <%= ""hello""%> </test> </xml> %> </test> </xml>"
Dim expected = " Dim xml = <xml><test><%= <xml><test id=""42""><%= 42 %><%= ""hello"" %></test></xml> %></test></xml>"
Await AssertFormatAsync(CreateMethod(code), CreateMethod(expected))
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function XmlLiterals25() As Task
Dim code = "Dim xml = <xml attr=""1""> </xml> "
Dim expected = " Dim xml = <xml attr=""1""></xml>"
Await AssertFormatAsync(CreateMethod(code), CreateMethod(expected))
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function XmlLiterals26() As Task
Dim code = My.Resources.XmlLiterals.Test1_Input
Dim expected = My.Resources.XmlLiterals.Test1_Output
Await AssertFormatAsync(code, expected)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function XmlLiterals27() As Task
Dim code = My.Resources.XmlLiterals.Test2_Input
Dim expected = My.Resources.XmlLiterals.Test2_Output
Await AssertFormatAsync(code, expected)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function XmlLiterals28() As Task
Dim code = My.Resources.XmlLiterals.Test3_Input
Dim expected = My.Resources.XmlLiterals.Test3_Output
Await AssertFormatAsync(code, expected)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function AttributeOnClass1() As Task
Dim code = <Code><![CDATA[Namespace SomeNamespace
<SomeAttribute()>
Class Foo
End Class
End Namespace]]></Code>
Dim expected = <Code><![CDATA[Namespace SomeNamespace
<SomeAttribute()>
Class Foo
End Class
End Namespace]]></Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<WorkItem(1087167, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1087167")>
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function MultipleAttributesOnClass() As Task
Dim code = <Code><![CDATA[Namespace SomeNamespace
<SomeAttribute()>
<SomeAttribute2()>
Class Foo
End Class
End Namespace]]></Code>
Dim expected = <Code><![CDATA[Namespace SomeNamespace
<SomeAttribute()>
<SomeAttribute2()>
Class Foo
End Class
End Namespace]]></Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<WorkItem(1087167, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1087167")>
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function MultipleAttributesOnParameter_1() As Task
Dim code = <Code><![CDATA[Class Program
Sub P(
<Foo>
<Foo>
som As Integer)
End Sub
End Class
Public Class Foo
Inherits Attribute
End Class]]></Code>
Await AssertFormatLf2CrLfAsync(code.Value, code.Value)
End Function
<WorkItem(1087167, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1087167")>
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function MultipleAttributesOnParameter_2() As Task
Dim code = <Code><![CDATA[Class Program
Sub P(
<Foo>
som As Integer)
End Sub
End Class
Public Class Foo
Inherits Attribute
End Class]]></Code>
Await AssertFormatLf2CrLfAsync(code.Value, code.Value)
End Function
<WorkItem(1087167, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1087167")>
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function MultipleAttributesOnParameter_3() As Task
Dim code = <Code><![CDATA[Class Program
Sub P( <Foo>
<Foo>
som As Integer)
End Sub
End Class
Public Class Foo
Inherits Attribute
End Class]]></Code>
Dim expected = <Code><![CDATA[Class Program
Sub P(<Foo>
<Foo>
som As Integer)
End Sub
End Class
Public Class Foo
Inherits Attribute
End Class]]></Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function InheritsImplementsOnClass() As Task
Dim code = <Code><![CDATA[Class SomeClass
Inherits BaseClass
Implements IFoo
End Class]]></Code>
Dim expected = <Code><![CDATA[Class SomeClass
Inherits BaseClass
Implements IFoo
End Class]]></Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function InheritsImplementsWithGenericsOnClass() As Task
Dim code = <Code><![CDATA[Class SomeClass(Of T)
Inherits BaseClass (Of T)
Implements IFoo ( Of String,
T)
End Class]]></Code>
Dim expected = <Code><![CDATA[Class SomeClass(Of T)
Inherits BaseClass(Of T)
Implements IFoo(Of String,
T)
End Class]]></Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function InheritsOnInterface() As Task
Dim code = <Code>Interface I
Inherits J
End Interface
Interface J
End Interface</Code>
Dim expected = <Code>Interface I
Inherits J
End Interface
Interface J
End Interface</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function WhitespaceMethodParens() As Task
Dim code = <Code>Class SomeClass
Sub Foo ( x As Integer )
Foo ( 42 )
End Sub
End Class</Code>
Dim expected = <Code>Class SomeClass
Sub Foo(x As Integer)
Foo(42)
End Sub
End Class</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function WhitespaceKeywordParens() As Task
Dim code = <Code>Class SomeClass
Sub Foo
If(x And(y Or(z)) Then Stop
End Sub
End Class</Code>
Dim expected = <Code>Class SomeClass
Sub Foo
If (x And (y Or (z)) Then Stop
End Sub
End Class</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function WhitespaceLiteralAndTypeCharacters() As Task
Dim code = <Code><![CDATA[Class SomeClass
Sub Method()
Dim someHex = &HFF
Dim someOct = &O33
Dim someShort = 42S+42S
Dim someInteger% = 42%+42%
Dim someOtherInteger = 42I+42I
Dim someLong& = 42&+42&
Dim someOtherLong = 42L+42L
Dim someDecimal@ = 42.42@+42.42@
Dim someOtherDecimal = 42.42D + 42.42D
Dim someSingle! = 42.42!+42.42!
Dim someOtherSingle = 42.42F+42.42F
Dim someDouble# = 42.4242#+42.4242#
Dim someOtherDouble = 42.42R+42.42R
Dim unsignedShort = 42US+42US
Dim unsignedLong = 42UL+42UL
Dim someDate = #3/3/2011 12:42:00 AM#+#2/2/2011#
Dim someChar = "x"c
Dim someString$ = "42"+"42"
Dim r = Foo&()
Dim s = FooString$()
End Sub
End Class]]></Code>
Dim expected = <Code><![CDATA[Class SomeClass
Sub Method()
Dim someHex = &HFF
Dim someOct = &O33
Dim someShort = 42S + 42S
Dim someInteger% = 42% + 42%
Dim someOtherInteger = 42I + 42I
Dim someLong& = 42& + 42&
Dim someOtherLong = 42L + 42L
Dim someDecimal@ = 42.42@ + 42.42@
Dim someOtherDecimal = 42.42D + 42.42D
Dim someSingle! = 42.42! + 42.42!
Dim someOtherSingle = 42.42F + 42.42F
Dim someDouble# = 42.4242# + 42.4242#
Dim someOtherDouble = 42.42R + 42.42R
Dim unsignedShort = 42US + 42US
Dim unsignedLong = 42UL + 42UL
Dim someDate = #3/3/2011 12:42:00 AM# + #2/2/2011#
Dim someChar = "x"c
Dim someString$ = "42" + "42"
Dim r = Foo&()
Dim s = FooString$()
End Sub
End Class]]></Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function WhitespaceNullable() As Task
Dim code = <Code>Class Foo
Property someprop As Integer ?
Function Method(arg1 ? As Integer) As Integer ?
Dim someVariable ? As Integer
End Function
End Class</Code>
Dim expected = <Code>Class Foo
Property someprop As Integer?
Function Method(arg1? As Integer) As Integer?
Dim someVariable? As Integer
End Function
End Class</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function WhitespaceArrayBraces() As Task
Dim code = <Code>Class Foo
Sub Method()
Dim arr() ={ 1, 2, 3 }
End Sub
End Class</Code>
Dim expected = <Code>Class Foo
Sub Method()
Dim arr() = {1, 2, 3}
End Sub
End Class</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function WhitespaceStatementSeparator() As Task
Dim code = <Code>Class Foo
Sub Method()
Dim x=2:Dim y=3:Dim z=4
End Sub
End Class</Code>
Dim expected = <Code>Class Foo
Sub Method()
Dim x = 2 : Dim y = 3 : Dim z = 4
End Sub
End Class</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function WhitespaceRemovedBeforeComment() As Task
Dim code = <Code>Class Foo
Sub Method()
Dim a = 4 ' This is a comment that doesn't move
' This is a comment that will have some preceding whitespace removed
Dim y = 4
End Sub
End Class</Code>
Dim expected = <Code>Class Foo
Sub Method()
Dim a = 4 ' This is a comment that doesn't move
' This is a comment that will have some preceding whitespace removed
Dim y = 4
End Sub
End Class</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function ReFormatWithTabsEnabled1() As Task
Dim code =
"Class SomeClass" + vbCrLf +
" Sub Foo()" + vbCrLf +
" Foo()" + vbCrLf +
" End Sub" + vbCrLf +
"End Class"
Dim expected =
"Class SomeClass" + vbCrLf +
vbTab + "Sub Foo()" + vbCrLf +
vbTab + vbTab + "Foo()" + vbCrLf +
vbTab + "End Sub" + vbCrLf +
"End Class"
Dim optionSet = New Dictionary(Of OptionKey, Object) From
{
{New OptionKey(FormattingOptions.UseTabs, LanguageNames.VisualBasic), True},
{New OptionKey(FormattingOptions.TabSize, LanguageNames.VisualBasic), 4},
{New OptionKey(FormattingOptions.IndentationSize, LanguageNames.VisualBasic), 4}
}
Await AssertFormatAsync(code, expected, changedOptionSet:=optionSet)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function ReFormatWithTabsEnabled2() As Task
' tabs after the first token on a line should be converted to spaces
Dim code =
"Class SomeClass" + vbCrLf +
vbTab + "Sub Foo()" + vbCrLf +
vbTab + vbTab + "Foo()" + vbTab + vbTab + "'comment" + vbCrLf +
vbTab + "End Sub" + vbCrLf +
"End Class"
Dim expected =
"Class SomeClass" + vbCrLf +
vbTab + "Sub Foo()" + vbCrLf +
vbTab + vbTab + "Foo() 'comment" + vbCrLf +
vbTab + "End Sub" + vbCrLf +
"End Class"
Dim optionSet = New Dictionary(Of OptionKey, Object) From
{
{New OptionKey(FormattingOptions.UseTabs, LanguageNames.VisualBasic), True},
{New OptionKey(FormattingOptions.TabSize, LanguageNames.VisualBasic), 4},
{New OptionKey(FormattingOptions.IndentationSize, LanguageNames.VisualBasic), 4}
}
Await AssertFormatAsync(code, expected, changedOptionSet:=optionSet)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function ReFormatWithTabsEnabled3() As Task
' This is a regression test for the assert: it may still not pass after the assert is fixed.
Dim code =
"Class SomeClass" + vbCrLf +
" Sub Foo() ' Comment" + vbCrLf +
" Foo() " + vbCrLf +
" End Sub" + vbCrLf +
"End Class"
Dim expected =
"Class SomeClass" + vbCrLf +
vbTab + "Sub Foo() ' Comment" + vbCrLf +
vbTab + vbTab + "Foo()" + vbCrLf +
vbTab + "End Sub" + vbCrLf +
"End Class"
Dim optionSet = New Dictionary(Of OptionKey, Object) From
{
{New OptionKey(FormattingOptions.UseTabs, LanguageNames.VisualBasic), True},
{New OptionKey(FormattingOptions.TabSize, LanguageNames.VisualBasic), 4},
{New OptionKey(FormattingOptions.IndentationSize, LanguageNames.VisualBasic), 4}
}
Await AssertFormatAsync(code, expected, changedOptionSet:=optionSet)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function ReFormatWithTabsEnabled4() As Task
Dim code =
"Class SomeClass" + vbCrLf +
" Sub Foo()" + vbCrLf +
" Dim abc = Sub()" + vbCrLf +
" Console.WriteLine(42)" + vbCrLf +
" End Sub" + vbCrLf +
" End Sub" + vbCrLf +
"End Class"
Dim expected =
"Class SomeClass" + vbCrLf +
vbTab + "Sub Foo()" + vbCrLf +
vbTab + vbTab + "Dim abc = Sub()" + vbCrLf +
vbTab + vbTab + vbTab + vbTab + vbTab + " Console.WriteLine(42)" + vbCrLf +
vbTab + vbTab + vbTab + vbTab + " End Sub" + vbCrLf +
vbTab + "End Sub" + vbCrLf +
"End Class"
Dim optionSet = New Dictionary(Of OptionKey, Object) From
{
{New OptionKey(FormattingOptions.UseTabs, LanguageNames.VisualBasic), True},
{New OptionKey(FormattingOptions.TabSize, LanguageNames.VisualBasic), 4},
{New OptionKey(FormattingOptions.IndentationSize, LanguageNames.VisualBasic), 4}
}
Await AssertFormatAsync(code, expected, changedOptionSet:=optionSet)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function ReFormatWithTabsEnabled5() As Task
Dim code =
"Class SomeClass" + vbCrLf +
" Sub Foo()" + vbCrLf +
" Dim abc = 2 + " + vbCrLf +
" 3 + " + vbCrLf +
" 4 " + vbCrLf +
" End Sub" + vbCrLf +
"End Class"
Dim expected =
"Class SomeClass" + vbCrLf +
vbTab + "Sub Foo()" + vbCrLf +
vbTab + vbTab + "Dim abc = 2 +" + vbCrLf +
vbTab + vbTab + vbTab + vbTab + vbTab + "3 +" + vbCrLf +
vbTab + vbTab + vbTab + vbTab + " 4" + vbCrLf +
vbTab + "End Sub" + vbCrLf +
"End Class"
Dim optionSet = New Dictionary(Of OptionKey, Object) From
{
{New OptionKey(FormattingOptions.UseTabs, LanguageNames.VisualBasic), True},
{New OptionKey(FormattingOptions.TabSize, LanguageNames.VisualBasic), 4},
{New OptionKey(FormattingOptions.IndentationSize, LanguageNames.VisualBasic), 4}
}
Await AssertFormatAsync(code, expected, changedOptionSet:=optionSet)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function ReFormatWithTabsDisabled() As Task
Dim code =
"Class SomeClass" + vbCrLf +
vbTab + "Sub Foo()" + vbCrLf +
vbTab + vbTab + "Foo()" + vbCrLf +
vbTab + "End Sub" + vbCrLf +
"End Class"
Dim expected =
"Class SomeClass" + vbCrLf +
" Sub Foo()" + vbCrLf +
" Foo()" + vbCrLf +
" End Sub" + vbCrLf +
"End Class"
Dim optionSet = New Dictionary(Of OptionKey, Object) From
{
{New OptionKey(FormattingOptions.UseTabs, LanguageNames.VisualBasic), False},
{New OptionKey(FormattingOptions.TabSize, LanguageNames.VisualBasic), 4},
{New OptionKey(FormattingOptions.IndentationSize, LanguageNames.VisualBasic), 4}
}
Await AssertFormatAsync(code, expected, changedOptionSet:=optionSet)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function ReFormatWithDifferentIndent1() As Task
Dim code =
"Class SomeClass" + vbCrLf +
" Sub Foo()" + vbCrLf +
" Foo()" + vbCrLf +
" End Sub" + vbCrLf +
"End Class"
Dim expected =
"Class SomeClass" + vbCrLf +
" Sub Foo()" + vbCrLf +
" Foo()" + vbCrLf +
" End Sub" + vbCrLf +
"End Class"
Dim optionSet = New Dictionary(Of OptionKey, Object) From
{
{New OptionKey(FormattingOptions.UseTabs, LanguageNames.VisualBasic), False},
{New OptionKey(FormattingOptions.TabSize, LanguageNames.VisualBasic), 4},
{New OptionKey(FormattingOptions.IndentationSize, LanguageNames.VisualBasic), 2}
}
Await AssertFormatAsync(code, expected, changedOptionSet:=optionSet)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function ReFormatWithDifferentIndent2() As Task
Dim code =
"Class SomeClass" + vbCrLf +
" Sub Foo()" + vbCrLf +
" Foo()" + vbCrLf +
" End Sub" + vbCrLf +
"End Class"
Dim expected =
"Class SomeClass" + vbCrLf +
" Sub Foo()" + vbCrLf +
" Foo()" + vbCrLf +
" End Sub" + vbCrLf +
"End Class"
Dim optionSet = New Dictionary(Of OptionKey, Object) From
{
{New OptionKey(FormattingOptions.UseTabs, LanguageNames.VisualBasic), False},
{New OptionKey(FormattingOptions.TabSize, LanguageNames.VisualBasic), 4},
{New OptionKey(FormattingOptions.IndentationSize, LanguageNames.VisualBasic), 6}
}
Await AssertFormatAsync(code, expected, changedOptionSet:=optionSet)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function ReFormatWithTabsEnabledSmallIndentAndLargeTab() As Task
Dim code =
"Class SomeClass" + vbCrLf +
" Sub Foo()" + vbCrLf +
" Foo()" + vbCrLf +
" End Sub" + vbCrLf +
"End Class"
Dim expected =
"Class SomeClass" + vbCrLf +
" Sub Foo()" + vbCrLf +
vbTab + " Foo()" + vbCrLf +
" End Sub" + vbCrLf +
"End Class"
Dim optionSet = New Dictionary(Of OptionKey, Object) From
{
{New OptionKey(FormattingOptions.UseTabs, LanguageNames.VisualBasic), True},
{New OptionKey(FormattingOptions.TabSize, LanguageNames.VisualBasic), 3},
{New OptionKey(FormattingOptions.IndentationSize, LanguageNames.VisualBasic), 2}
}
Await AssertFormatAsync(code, expected, changedOptionSet:=optionSet)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function RegressionCommentFollowsSubsequentIndent4173() As Task
Dim code =
"Class SomeClass" + vbCrLf +
" Sub Foo()" + vbCrLf +
" 'comment" + vbCrLf +
" End Sub" + vbCrLf +
"End Class"
Dim expected =
"Class SomeClass" + vbCrLf +
" Sub Foo()" + vbCrLf +
" 'comment" + vbCrLf +
" End Sub" + vbCrLf +
"End Class"
Await AssertFormatAsync(code, expected)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function FormatUsingOverloads() As Task
Dim code =
"Class SomeClass" + vbCrLf +
" Sub Foo()" + vbCrLf +
"Foo() " + vbCrLf +
" End Sub" + vbCrLf +
"End Class"
Dim expected =
"Class SomeClass" + vbCrLf +
" Sub Foo()" + vbCrLf +
" Foo()" + vbCrLf +
" End Sub" + vbCrLf +
"End Class"
Await AssertFormatUsingAllEntryPointsAsync(code, expected)
End Function
<WorkItem(538533, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/538533")>
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function BugFix4173_1() As Task
Dim code = "Dim a = <xml> <%=<xml></xml>%> </xml>"
Dim expected = " Dim a = <xml><%= <xml></xml> %></xml>"
Await AssertFormatAsync(CreateMethod(code), CreateMethod(expected))
End Function
<WorkItem(538533, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/538533")>
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function BugFix4173_2() As Task
Dim code = <Code>Class Foo
Sub Foo() ' Comment
Foo()
End Sub
End Class</Code>
Dim expected = <Code>Class Foo
Sub Foo() ' Comment
Foo()
End Sub
End Class</Code>
Dim optionSet = New Dictionary(Of OptionKey, Object) From
{
{New OptionKey(FormattingOptions.UseTabs, LanguageNames.VisualBasic), True}
}
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value, optionSet)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function FormatUsingAutoGeneratedCodeOperationProvider() As Task
Dim code =
"Class SomeClass" + vbCrLf +
" Sub Foo()" + vbCrLf +
"Foo() " + vbCrLf +
" End Sub" + vbCrLf +
"End Class"
Dim expected =
"Class SomeClass" + vbCrLf +
" Sub Foo()" + vbCrLf +
" Foo()" + vbCrLf +
" End Sub" + vbCrLf +
"End Class"
Await AssertFormatAsync(code, expected)
End Function
<WorkItem(538533, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/538533")>
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function BugFix4173_3() As Task
Dim code = My.Resources.XmlLiterals.Test4_Input
Dim expected = My.Resources.XmlLiterals.Test4_Output
Await AssertFormatAsync(code, expected)
End Function
<WorkItem(538533, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/538533")>
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function BugFix4173_4() As Task
Dim code = <code>Class C
Sub Main(args As String())
Dim r = 2
'foo
End Sub
End Class</code>
Dim expected = <code>Class C
Sub Main(args As String())
Dim r = 2
'foo
End Sub
End Class</code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<WorkItem(538533, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/538533")>
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function BugFix4173_5() As Task
Dim code = <code>Module Module1
Public Sub foo
()
End Sub
End Module</code>
Await AssertFormatLf2CrLfAsync(code.Value, code.Value)
End Function
<WorkItem(538533, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/538533")>
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function BugFix4173_6() As Task
Dim code = <code>Module module1
#If True Then
#End If: foo()
End Module</code>
Await AssertFormatLf2CrLfAsync(code.Value, code.Value)
End Function
<WorkItem(538533, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/538533")>
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function BugFix4173_7() As Task
Dim code = <code>Module Module1
Sub Main()
Dim x = Sub()
End Sub : Dim y = Sub()
End Sub ' Incorrect indent
End Sub
End Module</code>
Dim expected = <code>Module Module1
Sub Main()
Dim x = Sub()
End Sub : Dim y = Sub()
End Sub ' Incorrect indent
End Sub
End Module</code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<WorkItem(538533, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/538533")>
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function BugFix4173_8() As Task
Dim code = <code>Module Module1
Sub Main()
'
'
End Sub
End Module</code>
Dim expected = <code>Module Module1
Sub Main()
'
'
End Sub
End Module</code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<WorkItem(538533, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/538533")>
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function BugFix4173_9() As Task
Dim code = <code>Module Module1
Sub Main()
#If True Then
Dim foo as Integer
#End If
End Sub
End Module</code>
Dim expected = <code>Module Module1
Sub Main()
#If True Then
Dim foo as Integer
#End If
End Sub
End Module</code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<WorkItem(538772, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/538772")>
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function BugFix4482() As Task
Dim code = <code>_' Public Function GroupBy(Of K, R)( _
_' ByVal key As KeyFunc(Of K), _
_' ByVal selector As SelectorFunc(Of K, QueryableCollection(Of T), R)) _
' As QueryableCollection(Of R)</code>
Await AssertFormatLf2CrLfAsync(code.Value, code.Value)
End Function
<WorkItem(538754, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/538754")>
<Fact>
<Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function BugFix4459() As Task
Dim code = <Code>Option Strict Off
Module Module1
Sub Main()
End Sub
Dim x As New List(Of Action(Of Integer)) From {Sub(a As Integer)
Dim z As Integer = New Integer
End Sub, Sub() IsNothing(Nothing), Function() As Integer
Dim z As Integer = New Integer
End Function}
End Module
</Code>
Dim expected = <Code>Option Strict Off
Module Module1
Sub Main()
End Sub
Dim x As New List(Of Action(Of Integer)) From {Sub(a As Integer)
Dim z As Integer = New Integer
End Sub, Sub() IsNothing(Nothing), Function() As Integer
Dim z As Integer = New Integer
End Function}
End Module
</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<WorkItem(538675, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/538675")>
<Fact>
<Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function BugFix4352() As Task
Dim code = <Code>Imports System
Imports System.Collections.Generic
Imports System.Linq
Module Program
Sub Main(args As String())
0: End
End Sub
End Module</Code>
Dim expected = <Code>Imports System
Imports System.Collections.Generic
Imports System.Linq
Module Program
Sub Main(args As String())
0: End
End Sub
End Module</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<WorkItem(538703, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/538703")>
<Fact>
<Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function BugFix4394() As Task
Await AssertFormatAsync(My.Resources.XmlLiterals.Test5_Input, My.Resources.XmlLiterals.Test5_Output)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function GetTypeTest() As Task
Dim code = "Dim a = GetType ( Object )"
Dim expected = " Dim a = GetType(Object)"
Await AssertFormatAsync(CreateMethod(code), CreateMethod(expected))
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function NewObjectTest() As Task
Dim code = "Dim a = New Object ( )"
Dim expected = " Dim a = New Object()"
Await AssertFormatAsync(CreateMethod(code), CreateMethod(expected), debugMode:=True)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function CTypeTest() As Task
Dim code = "Dim a = CType ( args , String ( ) ) "
Dim expected = " Dim a = CType(args, String())"
Await AssertFormatAsync(CreateMethod(code), CreateMethod(expected))
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function TernaryConditionTest() As Task
Dim code = "Dim a = If ( True , 1, 2)"
Dim expected = " Dim a = If(True, 1, 2)"
Await AssertFormatAsync(CreateMethod(code), CreateMethod(expected))
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function TryCastTest() As Task
Dim code = "Dim a = TryCast ( args , String())"
Dim expected = " Dim a = TryCast(args, String())"
Await AssertFormatAsync(CreateMethod(code), CreateMethod(expected))
End Function
<WorkItem(538703, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/538703")>
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function BugFix4394_1() As Task
Dim code = My.Resources.XmlLiterals.Test6_Input
Dim expected = My.Resources.XmlLiterals.Test6_Output
Await AssertFormatAsync(code, expected)
End Function
<WorkItem(538889, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/538889")>
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function BugFix4639() As Task
Dim code = "Imports <xmlns=""http://DefaultNamespace"" > "
Dim expected = "Imports <xmlns=""http://DefaultNamespace"">"
Await AssertFormatAsync(code, expected)
End Function
<WorkItem(538891, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/538891")>
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function BugFix4641() As Task
Dim code = <Code>Module module1
Structure C
End Structure
Sub foo()
Dim cc As C ? = New C ? ( )
End Sub
End Module</Code>
Dim expected = <Code>Module module1
Structure C
End Structure
Sub foo()
Dim cc As C? = New C?()
End Sub
End Module</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<WorkItem(538892, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/538892")>
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function BugFix4642() As Task
Dim code = <Code>_
</Code>
Dim expected = <Code> _
</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<WorkItem(538894, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/538894")>
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function BugFix4644() As Task
Dim code = <Code>Option Explicit Off
Module Module1
Sub Main()
Dim mmm = Sub(ByRef x As String, _
y As Integer)
Console.WriteLine(x & y)
End Sub, kkk = Sub(y, _
x)
mmm(y, _
x)
End Sub
lll = Sub(x _
)
Console.WriteLine(x)
End Sub
End Sub
End Module</Code>
Dim expected = <Code>Option Explicit Off
Module Module1
Sub Main()
Dim mmm = Sub(ByRef x As String, _
y As Integer)
Console.WriteLine(x & y)
End Sub, kkk = Sub(y, _
x)
mmm(y, _
x)
End Sub
lll = Sub(x _
)
Console.WriteLine(x)
End Sub
End Sub
End Module</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<WorkItem(538897, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/538897")>
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function BugFix4647() As Task
Dim code = <Code>Option Explicit Off
Module Module1
Sub Main()
Dim mmm = Sub(ByRef x As String, _
y As Integer)
Console.WriteLine(x & y)
End Sub, kkk = Sub(y, _
x)
mmm(y, _
x)
End Sub : Dim _
lll = Sub(x _
)
Console.WriteLine(x)
End Sub
End Sub
End Module
</Code>
Dim expected = <Code>Option Explicit Off
Module Module1
Sub Main()
Dim mmm = Sub(ByRef x As String, _
y As Integer)
Console.WriteLine(x & y)
End Sub, kkk = Sub(y, _
x)
mmm(y, _
x)
End Sub : Dim _
lll = Sub(x _
)
Console.WriteLine(x)
End Sub
End Sub
End Module
</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<WorkItem(538962, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/538962")>
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function WorkItem4737() As Task
Dim code = "Dim x = <?xml version =""1.0""?><code></code>"
Dim expected = " Dim x = <?xml version=""1.0""?><code></code>"
Await AssertFormatAsync(CreateMethod(code), CreateMethod(expected))
End Function
<WorkItem(539031, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/539031")>
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function BugFix4826() As Task
Dim code = <Code>Imports <xmlns:a="">
Module Program
Sub Main()
Dim x As New Dictionary(Of String, XElement) From {{"Root", <x/>}}
x!Root%.<nodes>...<a:subnodes>.@a:b.ToString$
With x
!Root.@a:b.EndsWith("").ToString$()
With !Root
.<b>.Value.StartsWith("")
...<c>(0).Value.ToString$()
.ToString()
Call .ToString()
End With
End With
Dim buffer As New Byte(1023) {}
End Sub
End Module
</Code>
Await AssertFormatLf2CrLfAsync(code.Value, code.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function Parentheses() As Task
Dim code = <Code>Class GenericMethod
Sub Method(Of T)(t1 As T)
NewMethod(Of T)(t1)
End Sub
Private Shared Sub NewMethod(Of T)(t1 As T)
Dim a As T
a = t1
End Sub
End Class
</Code>
Await AssertFormatLf2CrLfAsync(code.Value, code.Value)
End Function
<WorkItem(539170, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/539170")>
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function BugFix5022() As Task
Dim code = <Code>Class A
: _
Dim x
End Class</Code>
Dim expected = <Code>Class A
: _
Dim x
End Class</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<WorkItem(539324, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/539324")>
<Fact>
<Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function BugFix5232() As Task
Dim code = <Code>Imports System
Module M
Sub Main()
If False Then If True Then Else Else Console.WriteLine(1)
End Sub
End Module</Code>
Dim expected = <Code>Imports System
Module M
Sub Main()
If False Then If True Then Else Else Console.WriteLine(1)
End Sub
End Module</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<WorkItem(539353, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/539353")>
<Fact>
<Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function BugFix5270() As Task
Dim code = <Code>Imports System
Imports System.Collections.Generic
Imports System.Linq
Module Program
Sub Main(args As String())
Dim q = 2 + REM
3
End Sub
End Module</Code>
Dim expected = <Code>Imports System
Imports System.Collections.Generic
Imports System.Linq
Module Program
Sub Main(args As String())
Dim q = 2 + REM
3
End Sub
End Module</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<WorkItem(539358, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/539358")>
<Fact>
<Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function BugFix5277() As Task
Dim code = <Code>
#If True Then
#End If
</Code>
Dim expected = <Code>
#If True Then
#End If
</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<WorkItem(539455, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/539455")>
<Fact>
<Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function BugFix5432() As Task
Dim code = <Code>Imports System
Imports System.Collections.Generic
Imports System.Linq
Module Program
Sub Main(args As String())
dim q = 2 + _
'comment
End Sub
End Module</Code>
Dim expected = <Code>Imports System
Imports System.Collections.Generic
Imports System.Linq
Module Program
Sub Main(args As String())
dim q = 2 + _
'comment
End Sub
End Module</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<WorkItem(539351, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/539351")>
<Fact>
<Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function BugFix5268() As Task
Dim code = <Code>
#If True _
</Code>
Await AssertFormatLf2CrLfAsync(code.Value, code.Value)
End Function
<WorkItem(539351, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/539351")>
<Fact>
<Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function BugFix5268_1() As Task
Dim code = <Code>Imports System
Imports System.Collections.Generic
Imports System.Linq
Module Program
#If True _
End Module</Code>
Await AssertFormatLf2CrLfAsync(code.Value, code.Value)
End Function
<WorkItem(539473, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/539473")>
<Fact>
<Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function BugFix5456() As Task
Dim code = <Code>Imports System
Imports System.Collections.Generic
Imports System.Linq
Module Program
Sub Main()
Dim foo = New With {.foo = "foo",.bar = "bar"}
End Sub
End Module</Code>
Dim expected = <Code>Imports System
Imports System.Collections.Generic
Imports System.Linq
Module Program
Sub Main()
Dim foo = New With {.foo = "foo", .bar = "bar"}
End Sub
End Module</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<WorkItem(539474, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/539474")>
<Fact>
<Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function BugFix5457() As Task
Dim code = <Code>Module module1
Sub main()
Dim var1 As New Class1
[|var1.foofoo = 42
End Sub
Sub something()
something()
End Sub
End Module
Public Class Class1
Public foofoo As String|]
End Class</Code>
Dim expected = <Code>Module module1
Sub main()
Dim var1 As New Class1
var1.foofoo = 42
End Sub
Sub something()
something()
End Sub
End Module
Public Class Class1
Public foofoo As String
End Class</Code>
Await AssertFormatSpanAsync(code.Value.Replace(vbLf, vbCrLf), expected.Value.Replace(vbLf, vbCrLf))
End Function
<WorkItem(539503, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/539503")>
<Fact>
<Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function BugFix5492() As Task
Dim code = <Code>Imports System
Imports System.Collections.Generic
Imports System.Linq
Module Program
Sub Main(args As String())
Dim classNum As Integer 'comment
: classNum += 1 : Dim i As Integer
End Sub
End Module
</Code>
Dim expected = <Code>Imports System
Imports System.Collections.Generic
Imports System.Linq
Module Program
Sub Main(args As String())
Dim classNum As Integer 'comment
: classNum += 1 : Dim i As Integer
End Sub
End Module
</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<WorkItem(539508, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/539508")>
<Fact>
<Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function BugFix5497() As Task
Dim code = <Code>Imports System
Imports System.Collections.Generic
Imports System.Linq
Module Program
Sub Main(args As String())
: 'comment
End Sub
End Module</Code>
Dim expected = <Code>Imports System
Imports System.Collections.Generic
Imports System.Linq
Module Program
Sub Main(args As String())
: 'comment
End Sub
End Module</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<WorkItem(539581, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/539581")>
<Fact>
<Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function BugFix5594() As Task
Dim code = <Code>
<Assembly : MyAttr()>
<Module : MyAttr()>
Module Module1
Class MyAttr
Inherits Attribute
End Class
Sub main()
End Sub
End Module
</Code>
Dim expected = <Code>
<Assembly: MyAttr()>
<Module: MyAttr()>
Module Module1
Class MyAttr
Inherits Attribute
End Class
Sub main()
End Sub
End Module
</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<WorkItem(539582, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/539582")>
<Fact>
<Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function BugFix5595() As Task
Dim code = <Code>
Imports System.Xml
<SomeAttr()> Module Module1
Sub Main()
End Sub
End Module
</Code>
Dim expected = <Code>
Imports System.Xml
<SomeAttr()> Module Module1
Sub Main()
End Sub
End Module
</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<WorkItem(539616, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/539616")>
<Fact>
<Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function BugFix5637() As Task
Dim code = <Code>Public Class Class1
'this line is comment line
Sub sub1(ByVal aa As Integer)
End Sub
End Class</Code>
Dim expected = <Code>Public Class Class1
'this line is comment line
Sub sub1(ByVal aa As Integer)
End Sub
End Class</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact>
<Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function XmlTest() As Task
Await AssertFormatAsync(My.Resources.XmlLiterals.XmlTest1_Input, My.Resources.XmlLiterals.XmlTest1_Output)
End Function
<Fact>
<Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function XmlDocument() As Task
Await AssertFormatAsync(My.Resources.XmlLiterals.XmlTest2_Input, My.Resources.XmlLiterals.XmlTest2_Output)
End Function
<Fact>
<WorkItem(539458, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/539458")>
<WorkItem(539459, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/539459")>
<Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function XmlProcessingInstruction() As Task
Await AssertFormatAsync(My.Resources.XmlLiterals.XmlTest3_Input, My.Resources.XmlLiterals.XmlTest3_Output)
End Function
<WorkItem(539463, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/539463")>
<WorkItem(530597, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/530597")>
<Fact>
<Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function XmlTest5442() As Task
Using workspace = New AdhocWorkspace()
Dim project = workspace.CurrentSolution.AddProject("Project", "Project.dll", LanguageNames.VisualBasic)
Dim document = project.AddDocument("Document", SourceText.From(My.Resources.XmlLiterals.XmlTest4_Input_Output))
Dim root = Await document.GetSyntaxRootAsync()
' format first time
Dim result = Await Formatter.GetFormattedTextChangesAsync(root, workspace)
AssertResult(My.Resources.XmlLiterals.XmlTest4_Input_Output, Await document.GetTextAsync(), result)
Dim document2 = document.WithText((Await document.GetTextAsync()).WithChanges(result))
Dim root2 = Await document2.GetSyntaxRootAsync()
' format second time
Dim result2 = Await Formatter.GetFormattedTextChangesAsync(root, workspace)
AssertResult(My.Resources.XmlLiterals.XmlTest4_Input_Output, Await document2.GetTextAsync(), result2)
End Using
End Function
<WorkItem(539687, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/539687")>
<Fact>
<Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function BugFix5731() As Task
Dim code = <Code>Imports System
Imports System.Collections.Generic
Imports System.Linq
Module Program
Sub Main(args As String())
If True Then : 'comment
End If
End Sub
End Module</Code>
Dim expected = <Code>Imports System
Imports System.Collections.Generic
Imports System.Linq
Module Program
Sub Main(args As String())
If True Then : 'comment
End If
End Sub
End Module</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<WorkItem(539545, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/539545")>
<Fact>
<Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function BugFix5547() As Task
Dim code = <Code>Imports System
Imports System.Collections.Generic
Imports System.Linq
Module Program
Sub Main(args As String())
Select Case True
Case True
'comment
End Select
End Sub
End Module</Code>
Dim expected = <Code>Imports System
Imports System.Collections.Generic
Imports System.Linq
Module Program
Sub Main(args As String())
Select Case True
Case True
'comment
End Select
End Sub
End Module</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<WorkItem(539453, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/539453")>
<Fact>
<Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function BugFix5430() As Task
Dim code = My.Resources.XmlLiterals.IndentationTest1
Await AssertFormatAsync(code, code)
End Function
<WorkItem(539889, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/539889")>
<Fact>
<Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function BugFix5989() As Task
Dim code = <Code>Imports System
Module Program
Sub Main(args As String())
Console.WriteLine(CInt (42))
End Sub
End Module
</Code>
Dim expected = <Code>Imports System
Module Program
Sub Main(args As String())
Console.WriteLine(CInt(42))
End Sub
End Module
</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<WorkItem(539409, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/539409")>
<Fact>
<Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function BugFix6367() As Task
Dim code = <Code>Module Program
Sub Main(args As String())
Dim a As Integer = 1'Test
End Sub
End Module
</Code>
Dim expected = <Code>Module Program
Sub Main(args As String())
Dim a As Integer = 1 'Test
End Sub
End Module
</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<WorkItem(539409, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/539409")>
<Fact>
<Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function BugFix6367_1() As Task
Dim code = <Code>Module Program
Sub Main(args As String())
Dim a As Integer = 1 'Test
End Sub
End Module
</Code>
Await AssertFormatLf2CrLfAsync(code.Value, code.Value)
End Function
<WorkItem(540678, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/540678")>
<Fact>
<Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function BugFix7023_1() As Task
Dim code = <Code>Module Program
Public Operator +(x As Integer, y As Integer)
Console.WriteLine("FOO")
End Operator
End Module
</Code>
Await AssertFormatLf2CrLfAsync(code.Value, code.Value)
End Function
<Fact>
<Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function XmlTextWithEmbededExpression1() As Task
Await AssertFormatAsync(My.Resources.XmlLiterals.XmlTest5_Input, My.Resources.XmlLiterals.XmlTest5_Output)
End Function
<Fact>
<Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function XmlTextWithEmbededExpression2() As Task
Await AssertFormatAsync(My.Resources.XmlLiterals.XmlTest6_Input, My.Resources.XmlLiterals.XmlTest6_Output)
End Function
<Fact>
<Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function XmlText() As Task
Await AssertFormatAsync(My.Resources.XmlLiterals.XmlTest7_Input, My.Resources.XmlLiterals.XmlTest7_Output)
End Function
<Fact>
<Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function XmlTextWithComment() As Task
Await AssertFormatAsync(My.Resources.XmlLiterals.XmlTest8_Input, My.Resources.XmlLiterals.XmlTest8_Output)
End Function
<WorkItem(541628, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/541628")>
<Fact>
<Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function MultipleControlVariables() As Task
Dim code = <Code>Module Program
Sub Main(args As String())
Dim i, j As Integer
For i = 0 To 1
For j = 0 To 1
Next j, i
End Sub
End Module</Code>
Dim expected = <Code>Module Program
Sub Main(args As String())
Dim i, j As Integer
For i = 0 To 1
For j = 0 To 1
Next j, i
End Sub
End Module</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<WorkItem(541561, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/541561")>
<Fact>
<Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function ColonTrivia() As Task
Dim code = <Code>Module Program
Sub Foo3()
: End Sub
Sub Main()
End Sub
End Module</Code>
Dim expected = <Code>Module Program
Sub Foo3()
: End Sub
Sub Main()
End Sub
End Module</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact>
<Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function MemberAccessInObjectMemberInitializer() As Task
Dim code = <Code>Module Program
Sub Main()
Dim aw = New With {.a = 1, .b = 2+.a}
End Sub
End Module</Code>
Dim expected = <Code>Module Program
Sub Main()
Dim aw = New With {.a = 1, .b = 2 + .a}
End Sub
End Module</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact>
<Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function BinaryConditionalExpression() As Task
Dim code = <Code>Module Program
Sub Main()
Dim x = If(Nothing, "") ' Inline
x.ToString
End Sub
End Module</Code>
Dim expected = <Code>Module Program
Sub Main()
Dim x = If(Nothing, "") ' Inline
x.ToString
End Sub
End Module</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact>
<WorkItem(539574, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/539574")>
<Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function Preprocessors() As Task
Dim code = <Code>Imports System
Imports System.Collections.Generic
Imports System.Linq
Module Program
Sub Main(args As String())
#Const [PUBLIC] = 3
#Const foo = 23
#Const foo2=23
#Const foo3 = 23
#Const foo4 = 23
#Const foo5 = 23
End Sub
End Module</Code>
Dim expected = <Code>Imports System
Imports System.Collections.Generic
Imports System.Linq
Module Program
Sub Main(args As String())
#Const [PUBLIC] = 3
#Const foo = 23
#Const foo2 = 23
#Const foo3 = 23
#Const foo4 = 23
#Const foo5 = 23
End Sub
End Module</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact>
<WorkItem(10027, "DevDiv_Projects/Roslyn")>
<Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function RandomCode1() As Task
Dim code = <Code>'Imports alias 'foo' conflicts with 'foo' declared in the root namespace'</Code>
Dim expected = <Code>'Imports alias 'foo' conflicts with 'foo' declared in the root namespace'</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact>
<WorkItem(10027, "DevDiv_Projects/Roslyn")>
<Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function RandomCode2() As Task
Dim code = <Code>'Imports alias 'foo' conflicts with 'foo' declared in the root
namespace'</Code>
Dim expected = <Code>'Imports alias 'foo' conflicts with 'foo' declared in the root
namespace'</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact>
<WorkItem(542698, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/542698")>
<Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function ColonTrivia1() As Task
Dim code = <Code>Imports _
System.Collections.Generic _
:
: Imports _
System
Imports System.Linq
Module Program
Sub Main(args As String())
Console.WriteLine("TEST")
End Sub
End Module
</Code>
Dim expected = <Code>Imports _
System.Collections.Generic _
:
: Imports _
System
Imports System.Linq
Module Program
Sub Main(args As String())
Console.WriteLine("TEST")
End Sub
End Module
</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact>
<WorkItem(542698, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/542698")>
<Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function ColonTrivia2() As Task
Dim code = <Code>Imports _
System.Collections.Generic _
:
: Imports _
System
Imports System.Linq
Module Program
Sub Main(args As String())
Console.WriteLine("TEST")
End Sub
End Module
</Code>
Await AssertFormatLf2CrLfAsync(code.Value, code.Value)
End Function
<Fact>
<WorkItem(543197, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543197")>
<Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function KeyInAnonymousType() As Task
Dim code = <Code>Class C
Sub S()
Dim product = New With {Key.Name = "foo"}
End Sub
End Class
</Code>
Dim expected = <Code>Class C
Sub S()
Dim product = New With {Key .Name = "foo"}
End Sub
End Class
</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact>
<WorkItem(544008, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544008")>
<Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function TestGetXmlNamespace() As Task
Dim code = <Code>Class C
Sub S()
Dim x = GetXmlNamespace(asdf)
End Sub
End Class
</Code>
Dim expected = <Code>Class C
Sub S()
Dim x = GetXmlNamespace(asdf)
End Sub
End Class
</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact>
<WorkItem(539409, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/539409")>
<Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function StructuredTrivia() As Task
Dim code = <Code>#const foo=2.0d</Code>
Dim expected = <Code>#const foo = 2.0d</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact>
<Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function FormatComment1() As Task
Dim code = <Code>Class A
Sub Test()
Console.WriteLine()
:
' test
Console.WriteLine()
End Sub
End Class</Code>
Dim expected = <Code>Class A
Sub Test()
Console.WriteLine()
:
' test
Console.WriteLine()
End Sub
End Class</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact>
<Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function FormatComment2() As Task
Dim code = <Code>Class A
Sub Test()
Console.WriteLine()
' test
Console.WriteLine()
End Sub
End Class</Code>
Dim expected = <Code>Class A
Sub Test()
Console.WriteLine()
' test
Console.WriteLine()
End Sub
End Class</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact>
<WorkItem(543248, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543248")>
<Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function FormatBadCode() As Task
Dim code = <Code>Imports System
Class Program
Shared Sub Main(args As String())
SyncLock From y As Char i, j As Char In String.Empty
End SyncLock
End Sub
End Class</Code>
Await AssertFormatLf2CrLfAsync(code.Value, code.Value)
End Function
<Fact>
<WorkItem(544496, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544496")>
<Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function AttributeInParameterList() As Task
Dim code = <Code>Module Program
Sub Main( <Description> args As String())
End Sub
End Module</Code>
Dim expected = <Code>Module Program
Sub Main(<Description> args As String())
End Sub
End Module</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact>
<WorkItem(544980, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544980")>
<Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function XmlElement_Expression() As Task
Dim code = <Code>Module Program
Dim x = <x <%= "" %> />
End Module</Code>
Dim expected = <Code>Module Program
Dim x = <x <%= "" %>/>
End Module</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact>
<WorkItem(542976, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/542976")>
<Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function XmlElementStartTag() As Task
Dim code = <Code>Module Program
Dim x = <code
>
</code>
End Module</Code>
Dim expected = <Code>Module Program
Dim x = <code
>
</code>
End Module</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact>
<WorkItem(545088, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/545088")>
<Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function ForNext_MultipleVariables() As Task
Dim code = <Code>Module Program
Sub Method()
For a = 0 To 1
For b = 0 To 1
For c = 0 To 1
Next c, b, a
End Sub
End Module</Code>
Dim expected = <Code>Module Program
Sub Method()
For a = 0 To 1
For b = 0 To 1
For c = 0 To 1
Next c, b, a
End Sub
End Module</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact>
<WorkItem(545088, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/545088")>
<Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function ForNext_MultipleVariables2() As Task
Dim code = <Code>Module Program
Sub Method()
For z = 0 To 1
For a = 0 To 1
For b = 0 To 1
For c = 0 To 1
Next c, b, a
Next z
End Sub
End Module</Code>
Dim expected = <Code>Module Program
Sub Method()
For z = 0 To 1
For a = 0 To 1
For b = 0 To 1
For c = 0 To 1
Next c, b, a
Next z
End Sub
End Module</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact>
<WorkItem(544459, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544459")>
<Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function DictionaryAccessOperator() As Task
Dim code = <Code>Class S
Default Property Def(s As String) As String
Get
Return Nothing
End Get
Set(value As String)
End Set
End Property
Property Y As String
End Class
Module Program
Sub Main(args As String())
Dim c As New S With {.Y =!Hello}
End Sub
End Module</Code>
Dim expected = <Code>Class S
Default Property Def(s As String) As String
Get
Return Nothing
End Get
Set(value As String)
End Set
End Property
Property Y As String
End Class
Module Program
Sub Main(args As String())
Dim c As New S With {.Y = !Hello}
End Sub
End Module</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact>
<WorkItem(542976, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/542976")>
<Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function XmlElementStartTag1() As Task
Await AssertFormatAsync(My.Resources.XmlLiterals.XmlElementStartTag1_Input, My.Resources.XmlLiterals.XmlElementStartTag1_Output)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function ElasticNewlines() As Task
Dim text = <text>Class C
Implements INotifyPropertyChanged
Dim _p As Integer
Property P As Integer
Get
Return 0
End Get
Set(value As Integer)
SetProperty(_p, value, "P")
End Set
End Property
Sub SetProperty(Of T)(ByRef field As T, value As T, name As String)
If Not EqualityComparer(Of T).Default.Equals(field, value) Then
field = value
RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(name))
End If
End Sub
End Class</text>.Value.Replace(vbLf, vbCrLf)
Dim expected = <text>Class C
Implements INotifyPropertyChanged
Dim _p As Integer
Property P As Integer
Get
Return 0
End Get
Set(value As Integer)
SetProperty(_p, value, "P")
End Set
End Property
Sub SetProperty(Of T)(ByRef field As T, value As T, name As String)
If Not EqualityComparer(Of T).Default.Equals(field, value) Then
field = value
RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(name))
End If
End Sub
End Class</text>.Value.Replace(vbLf, vbCrLf)
Dim root = SyntaxFactory.ParseCompilationUnit(text)
Dim foo As New SyntaxAnnotation()
Dim implementsStatement = DirectCast(root.Members(0), ClassBlockSyntax).Implements.First()
root = root.ReplaceNode(implementsStatement, implementsStatement.NormalizeWhitespace(elasticTrivia:=True).WithAdditionalAnnotations(foo))
Dim field = DirectCast(root.Members(0), ClassBlockSyntax).Members(0)
root = root.ReplaceNode(field, field.NormalizeWhitespace(elasticTrivia:=True).WithAdditionalAnnotations(foo))
Dim prop = DirectCast(root.Members(0), ClassBlockSyntax).Members(1)
root = root.ReplaceNode(prop, prop.NormalizeWhitespace(elasticTrivia:=True).WithAdditionalAnnotations(foo))
Dim method = DirectCast(root.Members(0), ClassBlockSyntax).Members(2)
root = root.ReplaceNode(method, method.NormalizeWhitespace(elasticTrivia:=True).WithAdditionalAnnotations(foo))
Using workspace = New AdhocWorkspace()
Dim result = (Await Formatter.FormatAsync(root, foo, workspace)).ToString()
Assert.Equal(expected, result)
End Using
End Function
<Fact>
<WorkItem(545630, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/545630")>
<Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function SpacesInXmlStrings() As Task
Dim text = "Imports <xmlns:x='F'>"
Await AssertFormatAsync(text, text)
End Function
<Fact>
<WorkItem(545680, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/545680")>
<Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function SpaceBetweenPercentGreaterThanAndXmlName() As Task
Dim text = <code>Module Program
Sub Main(args As String())
End Sub
Public Function GetXml() As XElement
Return <field name=<%= 1 %> type=<%= 2 %>></field>
End Function
End Module</code>
Await AssertFormatLf2CrLfAsync(text.Value, text.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function SpacingAroundXmlEntityLiterals() As Task
Dim code =
<Code><![CDATA[Class C
Sub Bar()
Dim foo = <Code><></Code>
End Sub
End Class
]]></Code>
Await AssertFormatLf2CrLfAsync(code.Value, code.Value)
End Function
<WorkItem(547005, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/547005")>
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function BadDirectivesAreValidRanges() As Task
Dim code = <Code>
#If False Then
#end Region
#End If
#If False Then
#end
#End If
</Code>
Dim expected = <Code>
#If False Then
#end Region
#End If
#If False Then
#end
#End If
</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
<WorkItem(17313, "DevDiv_Projects/Roslyn")>
Public Async Function TestElseIfFormatting_Directive() As Task
Dim code =
<Code><![CDATA[
#If True Then
#Else If False Then
#End If
]]></Code>
Dim expected =
<Code><![CDATA[
#If True Then
#ElseIf False Then
#End If
]]></Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
<WorkItem(529899, "DevDiv_Projects/Roslyn")>
Public Async Function IndentContinuedLineOfSingleLineLambdaToFunctionKeyword() As Task
Dim code =
<Code><![CDATA[
Module Program
Sub Main(ByVal args As String())
Dim a1 = Function() args(0) _
+ 1
End Sub
End Module
]]></Code>
Dim expected =
<Code><![CDATA[
Module Program
Sub Main(ByVal args As String())
Dim a1 = Function() args(0) _
+ 1
End Sub
End Module
]]></Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
<WorkItem(604032, "DevDiv_Projects/Roslyn")>
Public Async Function TestSpaceBetweenEqualsAndDotOfXml() As Task
Dim code =
<Code><![CDATA[
Module Program
Sub Main(args As String())
Dim xml = <Order id="1">
<Customer>
<Name>Bob</Name>
</Customer>
<Contents>
<Item productId="1" quantity="2"/>
<Item productId="2" quantity="1"/>
</Contents>
</Order>
With xml
Dim customerName =.<Customer>.<Name>.Value
Dim itemCount =...<Item>.Count
Dim orderId =.@id
End With
End Sub
End Module
]]></Code>
Dim expected =
<Code><![CDATA[
Module Program
Sub Main(args As String())
Dim xml = <Order id="1">
<Customer>
<Name>Bob</Name>
</Customer>
<Contents>
<Item productId="1" quantity="2"/>
<Item productId="2" quantity="1"/>
</Contents>
</Order>
With xml
Dim customerName = .<Customer>.<Name>.Value
Dim itemCount = ...<Item>.Count
Dim orderId = .@id
End With
End Sub
End Module
]]></Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
<WorkItem(604092, "DevDiv_Projects/Roslyn")>
Public Async Function AnchorIndentToTheFirstTokenOfXmlBlock() As Task
Dim code =
<Code><![CDATA[
Module Program
Sub Main(args As String())
With <a>
</a>
Dim s = 1
End With
SyncLock <b>
</b>
Return
End SyncLock
Using <c>
</c>
Return
End Using
For Each reallyReallyReallyLongIdentifierNameHere In <d>
</d>
Return
Next
End Sub
End Module
]]></Code>
Dim expected =
<Code><![CDATA[
Module Program
Sub Main(args As String())
With <a>
</a>
Dim s = 1
End With
SyncLock <b>
</b>
Return
End SyncLock
Using <c>
</c>
Return
End Using
For Each reallyReallyReallyLongIdentifierNameHere In <d>
</d>
Return
Next
End Sub
End Module
]]></Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
<WorkItem(530366, "DevDiv_Projects/Roslyn")>
Public Async Function ForcedSpaceBetweenXmlNameTokenAndPercentGreaterThanToken() As Task
Dim code =
<Code><![CDATA[
Module Module1
Sub Main()
Dim e As XElement
Dim y = <root><%= e.@test %></root>
End Sub
End Module
]]></Code>
Dim expected =
<Code><![CDATA[
Module Module1
Sub Main()
Dim e As XElement
Dim y = <root><%= e.@test %></root>
End Sub
End Module
]]></Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
<WorkItem(531444, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/531444")>
Public Async Function TestElseIfFormattingForNestedSingleLineIf() As Task
Dim code =
<Code><![CDATA[
If True Then Console.WriteLine(1) Else If True Then Return
]]></Code>
Dim actual = CreateMethod(code.Value)
' Verify "Else If" doesn't get formatted to "ElseIf"
Await AssertFormatLf2CrLfAsync(actual, actual)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function TestDontCrashOnMissingTokenWithComment() As Task
Dim code =
<Code><![CDATA[
Namespace NS
Class CL
Sub Method()
Dim foo = Sub(x) 'Comment
]]></Code>
Await AssertFormatLf2CrLfAsync(code.Value, code.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function TestBang() As Task
Dim code =
<Code><![CDATA[
Imports System.Collections
Module Program
Sub Main()
Dim x As New Hashtable
Dim y = x ! _
Foo
End Sub
End Module
]]></Code>
Dim expected =
<Code><![CDATA[
Imports System.Collections
Module Program
Sub Main()
Dim x As New Hashtable
Dim y = x ! _
Foo
End Sub
End Module
]]></Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
<WorkItem(679864, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/679864")>
Public Async Function InsertSpaceBetweenXMLMemberAttributeAccessAndEqualsToken() As Task
Dim expected =
<Code><![CDATA[
Imports System
Imports System.Collections
Module Program
Sub Main(args As String())
Dim element = <element></element>
Dim foo = element.Single(Function(e) e.@Id = 1)
End Sub
End Module
]]></Code>
Dim code =
<Code><![CDATA[
Imports System
Imports System.Collections
Module Program
Sub Main(args As String())
Dim element = <element></element>
Dim foo = element.Single(Function(e) e.@Id = 1)
End Sub
End Module
]]></Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
<WorkItem(923172, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/923172")>
Public Async Function TestMemberAccessAfterOpenParen() As Task
Dim expected =
<Code><![CDATA[
Imports System
Imports System.Collections.Generic
Imports System.Linq
Module Program
Sub Main(args As String())
With args
If .IsNew = True Then
Return Nothing
Else
Return CTypeDynamic(Of T)(.Value, .Hello)
End If
End With
End Sub
End Module
]]></Code>
Dim code =
<Code><![CDATA[
Imports System
Imports System.Collections.Generic
Imports System.Linq
Module Program
Sub Main(args As String())
With args
If .IsNew = True Then
Return Nothing
Else
Return CTypeDynamic(Of T)( .Value, .Hello)
End If
End With
End Sub
End Module
]]></Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
<WorkItem(923180, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/923180")>
Public Async Function TestXmlMemberAccessDot() As Task
Dim expected =
<Code><![CDATA[
Imports System
Imports System.Collections.Generic
Imports System.Linq
Module Program
Sub Main(args As String())
With x.<Service>.First
If .<WorkerServiceType>.Count > 0 Then
Main(.<A>.Value, .<B>.Value)
Dim i = .<A>.Value + .<B>.Value
End If
End With
End Sub
End Module
]]></Code>
Dim code =
<Code><![CDATA[
Imports System
Imports System.Collections.Generic
Imports System.Linq
Module Program
Sub Main(args As String())
With x.<Service>.First
If.<WorkerServiceType>.Count > 0 Then
Main(.<A>.Value,.<B>.Value)
Dim i = .<A>.Value +.<B>.Value
End If
End With
End Sub
End Module
]]></Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
<WorkItem(530601, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/530601")>
Public Async Function TestElasticFormattingPropertySetter() As Task
Dim parameterList = SyntaxFactory.ParseParameterList(String.Format("(value As {0})", "Integer"))
Dim setter = SyntaxFactory.AccessorBlock(SyntaxKind.SetAccessorBlock,
SyntaxFactory.AccessorStatement(SyntaxKind.SetAccessorStatement, SyntaxFactory.Token(SyntaxKind.SetKeyword)).
WithParameterList(parameterList),
SyntaxFactory.EndBlockStatement(SyntaxKind.EndSetStatement, SyntaxFactory.Token(SyntaxKind.SetKeyword)))
Dim setPropertyStatement = SyntaxFactory.ParseExecutableStatement(String.Format("SetProperty({0}, value, ""{1}"")", "field", "Property")).WithLeadingTrivia(SyntaxFactory.ElasticMarker)
setter = setter.WithStatements(SyntaxFactory.SingletonList(setPropertyStatement))
Dim solution = New AdhocWorkspace().CurrentSolution
Dim project = solution.AddProject("proj", "proj", LanguageNames.VisualBasic)
Dim document = project.AddDocument("foo.vb", <text>Class C
WriteOnly Property Prop As Integer
End Property
End Class</text>.Value)
Dim propertyBlock = (Await document.GetSyntaxRootAsync()).DescendantNodes().OfType(Of PropertyBlockSyntax).Single()
document = Await Formatter.FormatAsync(document.WithSyntaxRoot(
(Await document.GetSyntaxRootAsync()).ReplaceNode(propertyBlock, propertyBlock.WithAccessors(SyntaxFactory.SingletonList(setter)))))
Dim actual = (Await document.GetTextAsync()).ToString()
Assert.Equal(actual, actual)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function TestWarningDirectives() As Task
Dim text = <Code>
# enable warning[BC000],bc123, ap456,_789' comment
Module Program
# disable warning 'Comment
Sub Main()
#disable warning bc123, bC456,someId789
End Sub
End Module
# enable warning
</Code>
Dim expected = <Code>
#enable warning [BC000], bc123, ap456, _789' comment
Module Program
#disable warning 'Comment
Sub Main()
#disable warning bc123, bC456, someId789
End Sub
End Module
#enable warning
</Code>
Await AssertFormatLf2CrLfAsync(text.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function TestIncompleteWarningDirectives() As Task
Dim text = <Code>
# disable
Module M1
# enable warning[bc123], ' Comment
End Module
</Code>
Dim expected = <Code>
#disable
Module M1
#enable warning [bc123], ' Comment
End Module
</Code>
Await AssertFormatLf2CrLfAsync(text.Value, expected.Value)
End Function
<WorkItem(796562, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/796562")>
<WorkItem(3293, "https://github.com/dotnet/roslyn/issues/3293")>
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function TriviaAtEndOfCaseBelongsToNextCase() As Task
Dim text = <Code>
Class X
Function F(x As Integer) As Integer
Select Case x
Case 1
Return 2
' This comment describes case 1
' This comment describes case 2
Case 2,
Return 3
End Select
Return 5
End Function
End Class
</Code>
Dim expected = <Code>
Class X
Function F(x As Integer) As Integer
Select Case x
Case 1
Return 2
' This comment describes case 1
' This comment describes case 2
Case 2,
Return 3
End Select
Return 5
End Function
End Class
</Code>
Await AssertFormatLf2CrLfAsync(text.Value, expected.Value)
End Function
<WorkItem(938188, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/938188")>
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function XelementAttributeSpacing() As Task
Dim text = <Code>
Class X
Function F(x As Integer) As Integer
Dim x As XElement
x.@Foo= "Hello"
End Function
End Class
</Code>
Dim expected = <Code>
Class X
Function F(x As Integer) As Integer
Dim x As XElement
x.@Foo = "Hello"
End Function
End Class
</Code>
Await AssertFormatLf2CrLfAsync(text.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function ConditionalAccessFormatting() As Task
Const code = "
Module Module1
Class G
Public t As String
End Class
Sub Main()
Dim x = New G()
Dim q = x ? . t ? ( 0 )
Dim me = Me ? . ToString()
Dim mb = MyBase ? . ToString()
Dim mc = MyClass ? . ToString()
Dim i = New With {.a = 3} ? . ToString()
Dim s = ""Test"" ? . ToString()
Dim s2 = $""Test"" ? . ToString()
Dim x1 = <a></a> ? . <b>
Dim x2 = <a/> ? . <b>
End Sub
End Module
"
Const expected = "
Module Module1
Class G
Public t As String
End Class
Sub Main()
Dim x = New G()
Dim q = x?.t?(0)
Dim me = Me?.ToString()
Dim mb = MyBase?.ToString()
Dim mc = MyClass?.ToString()
Dim i = New With {.a = 3}?.ToString()
Dim s = ""Test""?.ToString()
Dim s2 = $""Test""?.ToString()
Dim x1 = <a></a>?.<b>
Dim x2 = <a/>?.<b>
End Sub
End Module
"
Await AssertFormatAsync(code, expected)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function ChainedConditionalAccessFormatting() As Task
Const code = "
Module Module1
Class G
Public t As String
End Class
Sub Main()
Dim x = New G()
Dim q = x ? . t ? . ToString() ? . ToString ( 0 )
Dim me = Me ? . ToString() ? . Length
Dim mb = MyBase ? . ToString() ? . Length
Dim mc = MyClass ? . ToString() ? . Length
Dim i = New With {.a = 3} ? . ToString() ? . Length
Dim s = ""Test"" ? . ToString() ? . Length
Dim s2 = $""Test"" ? . ToString() ? . Length
Dim x1 = <a></a> ? . <b> ? . <c>
Dim x2 = <a/> ? . <b> ? . <c>
End Sub
End Module
"
Const expected = "
Module Module1
Class G
Public t As String
End Class
Sub Main()
Dim x = New G()
Dim q = x?.t?.ToString()?.ToString(0)
Dim me = Me?.ToString()?.Length
Dim mb = MyBase?.ToString()?.Length
Dim mc = MyClass?.ToString()?.Length
Dim i = New With {.a = 3}?.ToString()?.Length
Dim s = ""Test""?.ToString()?.Length
Dim s2 = $""Test""?.ToString()?.Length
Dim x1 = <a></a>?.<b>?.<c>
Dim x2 = <a/>?.<b>?.<c>
End Sub
End Module
"
Await AssertFormatAsync(code, expected)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function NameOfFormatting() As Task
Dim text = <Code>
Module M
Dim s = NameOf ( M )
End Module
</Code>
Dim expected = <Code>
Module M
Dim s = NameOf(M)
End Module
</Code>
Await AssertFormatLf2CrLfAsync(text.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function InterpolatedString1() As Task
Dim text = <Code>
Class C
Sub M()
Dim a = "World"
Dim b =$"Hello, {a}"
End Sub
End Class
</Code>
Dim expected = <Code>
Class C
Sub M()
Dim a = "World"
Dim b = $"Hello, {a}"
End Sub
End Class
</Code>
Await AssertFormatLf2CrLfAsync(text.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function InterpolatedString2() As Task
Dim text = <Code>
Class C
Sub M()
Dim a = "Hello"
Dim b = "World"
Dim c = $"{a}, {b}"
End Sub
End Class
</Code>
Dim expected = <Code>
Class C
Sub M()
Dim a = "Hello"
Dim b = "World"
Dim c = $"{a}, {b}"
End Sub
End Class
</Code>
Await AssertFormatLf2CrLfAsync(text.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function InterpolatedString3() As Task
Dim text = <Code>
Class C
Sub M()
Dim a = "World"
Dim b = $"Hello, { a }"
End Sub
End Class
</Code>
Dim expected = <Code>
Class C
Sub M()
Dim a = "World"
Dim b = $"Hello, { a }"
End Sub
End Class
</Code>
Await AssertFormatLf2CrLfAsync(text.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function InterpolatedString4() As Task
Dim text = <Code>
Class C
Sub M()
Dim a = "Hello"
Dim b = "World"
Dim c = $"{ a }, { b }"
End Sub
End Class
</Code>
Dim expected = <Code>
Class C
Sub M()
Dim a = "Hello"
Dim b = "World"
Dim c = $"{ a }, { b }"
End Sub
End Class
</Code>
Await AssertFormatLf2CrLfAsync(text.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function InterpolatedString5() As Task
Dim text = <Code>
Class C
Sub M()
Dim s = $"{42 , -4 :x}"
End Sub
End Class
</Code>
Dim expected = <Code>
Class C
Sub M()
Dim s = $"{42,-4:x}"
End Sub
End Class
</Code>
Await AssertFormatLf2CrLfAsync(text.Value, expected.Value)
End Function
<WorkItem(3293, "https://github.com/dotnet/roslyn/issues/3293")>
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function CaseCommentsRemainsUndisturbed() As Task
Dim text = <Code>
Class Program
Sub Main(args As String())
Dim s = 0
Select Case s
Case 0
' Comment should not be indented
Case 2
' comment
Console.WriteLine(s)
Case 4
End Select
End Sub
End Class
</Code>
Dim expected = <Code>
Class Program
Sub Main(args As String())
Dim s = 0
Select Case s
Case 0
' Comment should not be indented
Case 2
' comment
Console.WriteLine(s)
Case 4
End Select
End Sub
End Class
</Code>
Await AssertFormatLf2CrLfAsync(text.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
Public Async Function NewLineOption_LineFeedOnly() As Task
Dim tree = SyntaxFactory.ParseCompilationUnit("Class C" & vbCrLf & "End Class")
' replace all EOL trivia with elastic markers to force the formatter to add EOL back
tree = tree.ReplaceTrivia(tree.DescendantTrivia().Where(Function(tr) tr.IsKind(SyntaxKind.EndOfLineTrivia)), Function(o, r) SyntaxFactory.ElasticMarker)
Dim formatted = Await Formatter.FormatAsync(tree, DefaultWorkspace, DefaultWorkspace.Options.WithChangedOption(FormattingOptions.NewLine, LanguageNames.VisualBasic, vbLf))
Dim actual = formatted.ToFullString()
Dim expected = "Class C" & vbLf & "End Class"
Assert.Equal(expected, actual)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
<WorkItem(2822, "https://github.com/dotnet/roslyn/issues/2822")>
Public Async Function FormatLabelFollowedByDotExpression() As Task
Dim code = <Code>
Module Module1
Sub Main()
With New List(Of Integer)
lab: .Capacity = 15
End With
End Sub
End Module
</Code>
Dim expected = <Code>
Module Module1
Sub Main()
With New List(Of Integer)
lab: .Capacity = 15
End With
End Sub
End Module
</Code>
Await AssertFormatLf2CrLfAsync(code.Value, expected.Value)
End Function
<Fact, Trait(Traits.Feature, Traits.Features.Formatting)>
<WorkItem(2822, "https://github.com/dotnet/roslyn/issues/2822")>
Public Async Function FormatOmittedArgument() As Task
Dim code = <Code>
Class C
Sub M()
Call M(
a,
,
a
)
End Sub
End Class</Code>
Await AssertFormatLf2CrLfAsync(code.Value, code.Value)
End Function
End Class
End Namespace
|
thomaslevesque/roslyn
|
src/Workspaces/VisualBasicTest/Formatting/FormattingTests.vb
|
Visual Basic
|
apache-2.0
| 142,040
|
' Copyright (c) Microsoft. 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.Runtime.InteropServices
Imports System.Threading
Imports Microsoft.CodeAnalysis.RuntimeMembers
Imports Microsoft.CodeAnalysis.Text
Imports Microsoft.CodeAnalysis.VisualBasic.Symbols
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Imports TypeKind = Microsoft.CodeAnalysis.TypeKind
Namespace Microsoft.CodeAnalysis.VisualBasic
''' <summary>
''' This is a binder for use when early decoding of well known attributes. The binder will only bind expressions that can appear in an attribute.
''' Its purpose is to allow a symbol to safely decode any attribute without the possibility of any attribute related infinite recursion during binding.
''' If an attribute and its arguments are valid then this binder returns a BoundAttributeExpression otherwise it returns a BadExpression.
''' </summary>
Friend NotInheritable Class EarlyWellKnownAttributeBinder
Inherits Binder
Private _owner As Symbol
Friend Sub New(owner As Symbol, containingBinder As Binder)
MyBase.New(containingBinder, isEarlyAttributeBinder:=True)
Me._owner = owner
End Sub
Public Overrides ReadOnly Property ContainingMember As Symbol
Get
Return If(_owner, MyBase.ContainingMember)
End Get
End Property
' This binder is only used to bind expressions in an attribute context.
Public Overrides ReadOnly Property BindingLocation As BindingLocation
Get
Return BindingLocation.Attribute
End Get
End Property
' Hide the GetAttribute overload which takes a diagnostic bag.
' This ensures that diagnostics from the early bound attributes are never preserved.
Friend Shadows Function GetAttribute(node As AttributeSyntax, boundAttributeType As NamedTypeSymbol, <Out> ByRef generatedDiagnostics As Boolean) As SourceAttributeData
Dim diagnostics = DiagnosticBag.GetInstance()
Dim earlyAttribute = MyBase.GetAttribute(node, boundAttributeType, diagnostics)
generatedDiagnostics = Not diagnostics.IsEmptyWithoutResolution()
diagnostics.Free()
Return earlyAttribute
End Function
''' <summary>
''' Check that the syntax can appear in an attribute argument.
''' </summary>
Friend Shared Function CanBeValidAttributeArgument(node As ExpressionSyntax, memberAccessBinder As Binder) As Boolean
Debug.Assert(node IsNot Nothing)
' 11.2 Constant Expressions
'
'A constant expression is an expression whose value can be fully evaluated at compile time. The type of a constant expression can be Byte, SByte, UShort, Short, UInteger, Integer, ULong, Long, Char, Single, Double, Decimal, Date, Boolean, String, Object, or any enumeration type. The following constructs are permitted in constant expressions:
'
' Literals (including Nothing).
' References to constant type members or constant locals.
' References to members of enumeration types.
' Parenthesized subexpressions.
' Coercion expressions, provided the target type is one of the types listed above. Coercions to and from String are an exception to this rule and are only allowed on null values because String conversions are always done in the current culture of the execution environment at run time. Note that constant coercion expressions can only ever use intrinsic conversions.
' The +, – and Not unary operators, provided the operand and result is of a type listed above.
' The +, –, *, ^, Mod, /, \, <<, >>, &, And, Or, Xor, AndAlso, OrElse, =, <, >, <>, <=, and => binary operators, provided each operand and result is of a type listed above.
' The conditional operator If, provided each operand and result is of a type listed above.
' The following run-time functions:
' Microsoft.VisualBasic.Strings.ChrW
' Microsoft.VisualBasic.Strings.Chr, if the constant value is between 0 and 128
' Microsoft.VisualBasic.Strings.AscW, if the constant string is not empty
' Microsoft.VisualBasic.Strings.Asc, if the constant string is not empty
'
' In addition, attributes allow array expressions including both array literal and array creation expressions as well as GetType expressions.
Select Case node.Kind
Case _
SyntaxKind.NumericLiteralExpression,
SyntaxKind.StringLiteralExpression,
SyntaxKind.CharacterLiteralExpression,
SyntaxKind.TrueLiteralExpression,
SyntaxKind.FalseLiteralExpression,
SyntaxKind.NothingLiteralExpression,
SyntaxKind.DateLiteralExpression
' Literals (including Nothing).
Return True
Case _
SyntaxKind.SimpleMemberAccessExpression,
SyntaxKind.GlobalName,
SyntaxKind.IdentifierName
' References to constant type members or constant locals.
' References to members of enumeration types.
Return True
Case SyntaxKind.ParenthesizedExpression
' Parenthesized subexpressions.
Return True
Case _
SyntaxKind.CTypeExpression,
SyntaxKind.TryCastExpression,
SyntaxKind.DirectCastExpression,
SyntaxKind.PredefinedCastExpression
' Coercion expressions, provided the target type is one of the types listed above.
' Coercions to and from String are an exception to this rule and are only allowed on null values
' because String conversions are always done in the current culture of the execution environment
' at run time. Note that constant coercion expressions can only ever use intrinsic conversions.
Return True
Case _
SyntaxKind.UnaryPlusExpression,
SyntaxKind.UnaryMinusExpression,
SyntaxKind.NotExpression
' The +, – and Not unary operators, provided the operand and result is of a type listed above.
Return True
Case _
SyntaxKind.AddExpression,
SyntaxKind.SubtractExpression,
SyntaxKind.MultiplyExpression,
SyntaxKind.ExponentiateExpression,
SyntaxKind.DivideExpression,
SyntaxKind.ModuloExpression,
SyntaxKind.IntegerDivideExpression,
SyntaxKind.LeftShiftExpression,
SyntaxKind.RightShiftExpression,
SyntaxKind.ConcatenateExpression,
SyntaxKind.AndExpression,
SyntaxKind.OrExpression,
SyntaxKind.ExclusiveOrExpression,
SyntaxKind.AndAlsoExpression,
SyntaxKind.OrElseExpression,
SyntaxKind.EqualsExpression,
SyntaxKind.NotEqualsExpression,
SyntaxKind.LessThanOrEqualExpression,
SyntaxKind.GreaterThanOrEqualExpression,
SyntaxKind.LessThanExpression,
SyntaxKind.GreaterThanExpression
' The +, –, *, ^, Mod, /, \, <<, >>, &, And, Or, Xor, AndAlso, OrElse, =, <, >, <>, <=, and => binary operators,
' provided each operand and result is of a type listed above.
Return True
Case _
SyntaxKind.BinaryConditionalExpression,
SyntaxKind.TernaryConditionalExpression
' The conditional operator If, provided each operand and result is of a type listed above.
Return True
Case SyntaxKind.InvocationExpression
' The following run-time functions may appear in constant expressions:
' Microsoft.VisualBasic.Strings.ChrW
' Microsoft.VisualBasic.Strings.Chr, if the constant value is between 0 and 128
' Microsoft.VisualBasic.Strings.AscW, if the constant string is not empty
' Microsoft.VisualBasic.Strings.Asc, if the constant string is not empty
Dim memberAccess = TryCast(DirectCast(node, InvocationExpressionSyntax).Expression, MemberAccessExpressionSyntax)
If memberAccess IsNot Nothing Then
Dim diagnostics = DiagnosticBag.GetInstance
Dim boundExpression = memberAccessBinder.BindExpression(memberAccess, diagnostics)
diagnostics.Free()
If boundExpression.HasErrors Then
Return False
End If
Dim boundMethodGroup = TryCast(boundExpression, BoundMethodGroup)
If boundMethodGroup IsNot Nothing AndAlso boundMethodGroup.Methods.Count = 1 Then
Dim method = boundMethodGroup.Methods(0)
Dim compilation As VisualBasicCompilation = memberAccessBinder.Compilation
If method Is compilation.GetWellKnownTypeMember(WellKnownMember.Microsoft_VisualBasic_Strings__ChrWInt32Char) OrElse
method Is compilation.GetWellKnownTypeMember(WellKnownMember.Microsoft_VisualBasic_Strings__ChrInt32Char) OrElse
method Is compilation.GetWellKnownTypeMember(WellKnownMember.Microsoft_VisualBasic_Strings__AscWCharInt32) OrElse
method Is compilation.GetWellKnownTypeMember(WellKnownMember.Microsoft_VisualBasic_Strings__AscCharInt32) Then
Return True
End If
End If
End If
Return False
Case SyntaxKind.CollectionInitializer,
SyntaxKind.ArrayCreationExpression,
SyntaxKind.GetTypeExpression
' These are not constants and are special for attribute expressions.
' SyntaxKind.CollectionInitializer in this case really means ArrayLiteral, i.e.{1, 2, 3}.
' SyntaxKind.ArrayCreationExpression is array creation expression, i.e. new Char {'a'c, 'b'c}.
' SyntaxKind.GetTypeExpression is a GetType expression, i.e. GetType(System.String).
Return True
Case Else
Return False
End Select
End Function
Friend Overrides Function BinderSpecificLookupOptions(options As LookupOptions) As LookupOptions
' When early binding attributes, extension methods should always be ignored.
Return ContainingBinder.BinderSpecificLookupOptions(options) Or LookupOptions.IgnoreExtensionMethods
End Function
End Class
End Namespace
|
wschae/roslyn
|
src/Compilers/VisualBasic/Portable/Binding/EarlyWellKnownAttributeBinder.vb
|
Visual Basic
|
apache-2.0
| 11,784
|
' Licensed to the .NET Foundation under one or more agreements.
' The .NET Foundation licenses this file to you under the MIT license.
' See the LICENSE file in the project root for more information.
Imports System.Collections.Generic
Imports System.Diagnostics
Imports Microsoft.CodeAnalysis.Text
Imports Microsoft.CodeAnalysis.VisualBasic.Emit
Imports Microsoft.CodeAnalysis.VisualBasic.Symbols
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Imports Roslyn.Utilities
Namespace Microsoft.CodeAnalysis.VisualBasic
''' <summary>
''' Tracks synthesized fields that are needed in a submission being compiled.
''' </summary>
''' <remarks>
''' For every other submission referenced by this submission we add a field, so that we can access members of the target submission.
''' A field is also needed for the host object, if provided.
''' </remarks>
Friend Class SynthesizedSubmissionFields
Private ReadOnly _declaringSubmissionClass As NamedTypeSymbol
Private ReadOnly _compilation As VisualBasicCompilation
Private _hostObjectField As FieldSymbol
Private _previousSubmissionFieldMap As Dictionary(Of ImplicitNamedTypeSymbol, FieldSymbol)
Public Sub New(compilation As VisualBasicCompilation, submissionClass As NamedTypeSymbol)
Debug.Assert(compilation IsNot Nothing)
Debug.Assert(submissionClass.IsSubmissionClass)
_declaringSubmissionClass = submissionClass
_compilation = compilation
End Sub
Friend ReadOnly Property Count As Integer
Get
Return If(_previousSubmissionFieldMap Is Nothing, 0, _previousSubmissionFieldMap.Count)
End Get
End Property
Friend ReadOnly Property FieldSymbols As IEnumerable(Of FieldSymbol)
Get
Return If(_previousSubmissionFieldMap Is Nothing,
Array.Empty(Of FieldSymbol)(),
DirectCast(_previousSubmissionFieldMap.Values, IEnumerable(Of FieldSymbol)))
End Get
End Property
Friend Function GetHostObjectField() As FieldSymbol
If _hostObjectField IsNot Nothing Then
Return _hostObjectField
End If
' TODO (tomat): Dim hostObjectTypeSymbol = compilation.GetHostObjectTypeSymbol()
Dim hostObjectTypeSymbol As TypeSymbol = Nothing
If hostObjectTypeSymbol IsNot Nothing AndAlso hostObjectTypeSymbol.Kind <> SymbolKind.ErrorType Then
_hostObjectField = New SynthesizedFieldSymbol(_declaringSubmissionClass, _declaringSubmissionClass, hostObjectTypeSymbol, "<host-object>", accessibility:=Accessibility.Private, isReadOnly:=True, isShared:=False)
Return _hostObjectField
End If
Return Nothing
End Function
Friend Function GetOrMakeField(previousSubmissionType As ImplicitNamedTypeSymbol) As FieldSymbol
If _previousSubmissionFieldMap Is Nothing Then
_previousSubmissionFieldMap = New Dictionary(Of ImplicitNamedTypeSymbol, FieldSymbol)()
End If
Dim previousSubmissionField As FieldSymbol = Nothing
If Not _previousSubmissionFieldMap.TryGetValue(previousSubmissionType, previousSubmissionField) Then
previousSubmissionField = New SynthesizedFieldSymbol(
_declaringSubmissionClass,
implicitlyDefinedBy:=_declaringSubmissionClass,
Type:=previousSubmissionType,
name:="<" + previousSubmissionType.Name + ">",
isReadOnly:=True)
_previousSubmissionFieldMap.Add(previousSubmissionType, previousSubmissionField)
End If
Return previousSubmissionField
End Function
Friend Sub AddToType(containingType As NamedTypeSymbol, moduleBeingBuilt As PEModuleBuilder)
For Each field In FieldSymbols
moduleBeingBuilt.AddSynthesizedDefinition(containingType, field.GetCciAdapter())
Next
Dim hostObjectField As FieldSymbol = GetHostObjectField()
If hostObjectField IsNot Nothing Then
moduleBeingBuilt.AddSynthesizedDefinition(containingType, hostObjectField.GetCciAdapter())
End If
End Sub
End Class
End Namespace
|
AlekseyTs/roslyn
|
src/Compilers/VisualBasic/Portable/Lowering/SynthesizedSubmissionFields.vb
|
Visual Basic
|
mit
| 4,418
|
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System.Threading
Imports Microsoft.CodeAnalysis.Completion.Providers
Imports Microsoft.CodeAnalysis.VisualBasic.Extensions.ContextQuery
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Namespace Microsoft.CodeAnalysis.VisualBasic.Completion.KeywordRecommenders.Declarations
''' <summary>
''' Recommends the "As" keyword in all types of declarations.
''' </summary>
Friend Class AsKeywordRecommender
Inherits AbstractKeywordRecommender
Protected Overrides Function RecommendKeywords(context As VisualBasicSyntaxContext, cancellationToken As CancellationToken) As IEnumerable(Of RecommendedKeyword)
If context.FollowsEndOfStatement Then
Return SpecializedCollections.EmptyEnumerable(Of RecommendedKeyword)()
End If
Dim targetToken = context.TargetToken
Dim asKeyword = SpecializedCollections.SingletonEnumerable(
New RecommendedKeyword("As", VBFeaturesResources.Specifies_a_data_type_in_a_declaration_statement))
' Query: Aggregate x |
' Query: Group Join x |
If targetToken.IsFromIdentifierNode(Of CollectionRangeVariableSyntax)(Function(collectionRange) collectionRange.Identifier) Then
Return asKeyword
End If
' Query: Let x |
Dim expressionRangeVariable = targetToken.GetAncestor(Of ExpressionRangeVariableSyntax)()
If expressionRangeVariable IsNot Nothing AndAlso expressionRangeVariable.NameEquals IsNot Nothing Then
If targetToken.IsFromIdentifierNode(expressionRangeVariable.NameEquals.Identifier) Then
Return asKeyword
End If
End If
' For x |
If targetToken.IsFromIdentifierNode(Of ForStatementSyntax)(Function(forStatement) forStatement.ControlVariable) Then
Return asKeyword
End If
' For Each x |
If targetToken.IsFromIdentifierNode(Of ForEachStatementSyntax)(Function(forEachStatement) forEachStatement.ControlVariable) Then
Return asKeyword
End If
' All parameter types. In this case we have to drill into the parameter to make sure untyped
If targetToken.IsFromIdentifierNode(Of ParameterSyntax)(Function(parameter) parameter.Identifier) Then
Return asKeyword
End If
' Sub Goo(Of T |
If targetToken.IsChildToken(Of TypeParameterSyntax)(Function(typeParameter) typeParameter.Identifier) Then
Return asKeyword
End If
' Enum Goo |
If targetToken.IsChildToken(Of EnumStatementSyntax)(Function(enumDeclaration) enumDeclaration.Identifier) Then
Return asKeyword
End If
' Catch goo
If targetToken.IsFromIdentifierNode(Of CatchStatementSyntax)(Function(catchStatement) catchStatement.IdentifierName) Then
Return asKeyword
End If
' Function x() |
' Operator x() |
If targetToken.IsChildToken(Of ParameterListSyntax)(Function(paramList) paramList.CloseParenToken) Then
Dim methodDeclaration = targetToken.GetAncestor(Of MethodBaseSyntax)()
If methodDeclaration.IsKind(SyntaxKind.FunctionStatement, SyntaxKind.OperatorStatement,
SyntaxKind.DeclareFunctionStatement, SyntaxKind.DelegateFunctionStatement,
SyntaxKind.PropertyStatement, SyntaxKind.FunctionLambdaHeader) Then
Return asKeyword
End If
End If
' Function Goo |
If targetToken.IsChildToken(Of MethodStatementSyntax)(Function(functionDeclaration) functionDeclaration.Identifier) AndAlso
Not targetToken.GetAncestor(Of MethodBaseSyntax)().IsKind(SyntaxKind.SubStatement) Then
Return asKeyword
End If
' Property Goo |
If targetToken.IsChildToken(Of PropertyStatementSyntax)(Function(propertyDeclaration) propertyDeclaration.Identifier) Then
Return asKeyword
End If
' Custom Event Goo |
If targetToken.IsChildToken(Of EventStatementSyntax)(Function(eventDeclaration) eventDeclaration.Identifier) Then
Return asKeyword
End If
' Using goo |
Dim usingStatement = targetToken.GetAncestor(Of UsingStatementSyntax)()
If usingStatement IsNot Nothing AndAlso usingStatement.Expression IsNot Nothing AndAlso Not usingStatement.Expression.IsMissing Then
If usingStatement.Expression Is targetToken.Parent Then
Return asKeyword
End If
End If
' Public Async |
' Public Iterator |
' but not...
' Async |
' Iterator |
If context.IsTypeMemberDeclarationKeywordContext AndAlso
(targetToken.HasMatchingText(SyntaxKind.AsyncKeyword) OrElse targetToken.HasMatchingText(SyntaxKind.IteratorKeyword)) Then
Dim parentField = targetToken.Parent.FirstAncestorOrSelf(Of FieldDeclarationSyntax)()
If parentField IsNot Nothing AndAlso parentField.GetFirstToken() <> targetToken Then
Return asKeyword
Else
Return SpecializedCollections.EmptyEnumerable(Of RecommendedKeyword)()
End If
End If
' Dim goo |
' Using goo as new O, goo2 |
Dim variableDeclarator = targetToken.GetAncestor(Of VariableDeclaratorSyntax)()
If variableDeclarator IsNot Nothing Then
If variableDeclarator.Names.Any(Function(name) name.Identifier = targetToken AndAlso name.Identifier.GetTypeCharacter() = TypeCharacter.None) Then
Return asKeyword
End If
End If
Return SpecializedCollections.EmptyEnumerable(Of RecommendedKeyword)()
End Function
End Class
End Namespace
|
mmitche/roslyn
|
src/Features/VisualBasic/Portable/Completion/KeywordRecommenders/Declarations/AsKeywordRecommender.vb
|
Visual Basic
|
apache-2.0
| 6,403
|
Imports System
Imports System.Reflection
Imports System.Runtime.InteropServices
' General Information about an assembly is controlled through the following
' set of attributes. Change these attribute values to modify the information
' associated with an assembly.
' Review the values of the assembly attributes
<Assembly: AssemblyTitle("WDK.Providers.Logs.ApplicationLog")>
<Assembly: AssemblyDescription("")>
<Assembly: AssemblyCompany("Skitsanos")>
<Assembly: AssemblyProduct("WDK.Providers.Logs.ApplicationLog")>
<Assembly: AssemblyCopyright("Copyright © Skitsanos 2010")>
<Assembly: AssemblyTrademark("")>
<Assembly: ComVisible(False)>
'The following GUID is for the ID of the typelib if this project is exposed to COM
<Assembly: Guid("b97641ed-9d68-4c6a-a63b-ed9d69ee533b")>
' Version information for an assembly consists of the following four values:
'
' Major Version
' Minor Version
' Build Number
' Revision
'
' You can specify all the values or you can default the Build and Revision Numbers
' by using the '*' as shown below:
' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("10.0.*")>
|
skitsanos/WDK10
|
WDK.Providers.Logs/My Project/AssemblyInfo.vb
|
Visual Basic
|
mit
| 1,156
|
Public Class EstadosFinancieros
Public Property Codigo As String
Public Property Descripcion As String
Public Property IdEstFinanciero As Int32
End Class
|
crackper/SistFoncreagro
|
SistFoncreagro.BussinessEntities/EstadosFinancieros.vb
|
Visual Basic
|
mit
| 169
|
' The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
Imports Windows.UI.Popups
''' <summary>
''' An empty page that can be used on its own or navigated to within a Frame.
''' </summary>
Public NotInheritable Class MainPage
Inherits Page
Private Async Sub ButtonBase_OnClick(ByVal sender As Object, ByVal e As RoutedEventArgs)
Dim carToInsert = New Car()
carToInsert.Name = "Renault 4l"
carToInsert.IsElectric = False
Dim table = App.NotificationHubsSampleAMSClient.GetTable(Of Car)()
Await table.InsertAsync(carToInsert)
Dim dialog = New MessageDialog("Inserted.")
dialog.Commands.Add(New UICommand("OK"))
Await dialog.ShowAsync()
End Sub
End Class
|
saramgsilva/NotificationHubs
|
Using Azure Mobile Services/NotificationHubsSample.Win81-VB/MainPage.xaml.vb
|
Visual Basic
|
mit
| 773
|
'
' DotNetNuke® - http://www.dotnetnuke.com
' Copyright (c) 2002-2011
' by DotNetNuke Corporation
'
' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
' documentation files (the "Software"), to deal in the Software without restriction, including without limitation
' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
' to permit persons to whom the Software is furnished to do so, subject to the following conditions:
'
' The above copyright notice and this permission notice shall be included in all copies or substantial portions
' of the Software.
'
' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
' DEALINGS IN THE SOFTWARE.
'
Imports System
Imports System.Configuration
Imports System.Data
Imports DotNetNuke
Namespace DotNetNuke.Modules.Documents
''' -----------------------------------------------------------------------------
''' <summary>
''' The DocumentSettings Class provides the Documents Settings Object
''' </summary>
''' <remarks>
''' </remarks>
''' <history>
''' [aglenwright] 18 Feb 2006 Created
''' </history>
''' -----------------------------------------------------------------------------
Public Class DocumentsSettingsInfo
Sub New()
End Sub
Sub New(ByVal LocalResourceFile As String)
_LocalResourceFile = _LocalResourceFile
End Sub
#Region "Private Members"
Private _LocalResourceFile As String
Private _ModuleId As Integer
Private _ShowTitleLink As Boolean = True
Private _SortOrder As String
Private _DisplayColumns As String = _
DocumentsDisplayColumnInfo.COLUMN_TITLE & ";true," & _
DocumentsDisplayColumnInfo.COLUMN_OWNEDBY & ";true," & _
DocumentsDisplayColumnInfo.COLUMN_CATEGORY & ";true," & _
DocumentsDisplayColumnInfo.COLUMN_MODIFIEDDATE & ";true," & _
DocumentsDisplayColumnInfo.COLUMN_SIZE & ";true," & _
DocumentsDisplayColumnInfo.COLUMN_DOWNLOADLINK & ";true"
Private _UseCategoriesList As Boolean = False
Private _DefaultFolder As String = ""
Private _CategoriesListName As String = "Document Categories"
Private _AllowUserSort As Boolean
#End Region
#Region "Properties"
Public Property LocalResourceFile() As String
Get
Return _LocalResourceFile
End Get
Set(ByVal Value As String)
_LocalResourceFile = Value
End Set
End Property
Public Property ModuleId() As Integer
Get
Return _ModuleId
End Get
Set(ByVal Value As Integer)
_ModuleId = Value
End Set
End Property
Public Property ShowTitleLink() As Boolean
Get
Return _ShowTitleLink
End Get
Set(ByVal Value As Boolean)
_ShowTitleLink = Value
End Set
End Property
Public Property SortOrder() As String
Get
Return _SortOrder
End Get
Set(ByVal Value As String)
_SortOrder = Value
End Set
End Property
Public Property DisplayColumns() As String
Get
Return _DisplayColumns
End Get
Set(ByVal Value As String)
_DisplayColumns = Value
End Set
End Property
Public Property UseCategoriesList() As Boolean
Get
Return _UseCategoriesList
End Get
Set(ByVal Value As Boolean)
_UseCategoriesList = Value
End Set
End Property
Public Property AllowUserSort() As Boolean
Get
Return _AllowUserSort
End Get
Set(ByVal value As Boolean)
_AllowUserSort = value
End Set
End Property
Public Property DefaultFolder() As String
Get
Return _DefaultFolder
End Get
Set(ByVal value As String)
_DefaultFolder = value
End Set
End Property
Public Property CategoriesListName() As String
Get
Return _CategoriesListName
End Get
Set(ByVal value As String)
_CategoriesListName = value
End Set
End Property
Public ReadOnly Property DisplayColumnList() As ArrayList
Get
Dim strColumnData As String
Dim objColumnInfo As DocumentsDisplayColumnInfo
Dim objColumnSettings As New ArrayList
If Me.DisplayColumns <> String.Empty Then
' read "saved" column sort orders in first
For Each strColumnData In Me.DisplayColumns.Split(Char.Parse(","))
objColumnInfo = New DocumentsDisplayColumnInfo
objColumnInfo.ColumnName = strColumnData.Split(Char.Parse(";"))(0)
objColumnInfo.DisplayOrder = objColumnSettings.Count + 1
objColumnInfo.Visible = Boolean.Parse(strColumnData.Split(Char.Parse(";"))(1))
objColumnInfo.LocalizedColumnName = Services.Localization.Localization.GetString(objColumnInfo.ColumnName & ".Header", _LocalResourceFile)
objColumnSettings.Add(objColumnInfo)
Next
End If
Return objColumnSettings
End Get
End Property
Public ReadOnly Property SortColumnList() As ArrayList
Get
Dim objSortColumn As DocumentsSortColumnInfo
Dim strSortColumn As String
Dim objSortColumns As New ArrayList
If Me.SortOrder <> String.Empty Then
For Each strSortColumn In Me.SortOrder.Split(Char.Parse(","))
objSortColumn = New DocumentsSortColumnInfo
If Left(strSortColumn, 1) = "-" Then
objSortColumn.Direction = DocumentsSortColumnInfo.SortDirection.Descending
objSortColumn.ColumnName = strSortColumn.Substring(1)
Else
objSortColumn.Direction = DocumentsSortColumnInfo.SortDirection.Ascending
objSortColumn.ColumnName = strSortColumn
End If
objSortColumn.LocalizedColumnName = Services.Localization.Localization.GetString(objSortColumn.ColumnName & ".Header", _LocalResourceFile)
objSortColumns.Add(objSortColumn)
Next
End If
Return objSortColumns
End Get
End Property
Public Shared Function FindColumn(ByVal ColumnName As String, ByVal List As ArrayList, ByVal VisibleOnly As Boolean) As Integer
' Find a display column in the list and return it's index
Dim intIndex As Integer
For intIndex = 0 To List.Count - 1
With CType(List(intIndex), DocumentsDisplayColumnInfo)
If .ColumnName = ColumnName AndAlso (Not VisibleOnly OrElse .Visible) Then
Return intIndex
End If
End With
Next
Return -1
End Function
Public Shared Function FindGridColumn(ByVal ColumnName As String, ByVal List As ArrayList, ByVal VisibleOnly As Boolean) As Integer
' Find a display column in the list and return it's "column" index
' as it will be displayed within the grid. This function differs from FindColumn
' in that it "ignores" invisible columns when counting which column index to
' return.
Dim intIndex As Integer
Dim intResult As Integer
For intIndex = 0 To List.Count - 1
With CType(List(intIndex), DocumentsDisplayColumnInfo)
If .ColumnName = ColumnName AndAlso (Not VisibleOnly OrElse .Visible) Then
Return intResult
End If
If .Visible Then
intResult = intResult + 1
End If
End With
Next
Return -1
End Function
#End Region
End Class
End Namespace
|
mitchelsellers/dnnDocuments
|
Source/DnnDocuments/DocumentsSettingsInfo.vb
|
Visual Basic
|
mit
| 7,896
|
'
' Automatically generated by AjGenesis
' http://www.ajlopez.com/ajgenesis
'
Module Module1
Sub Main()
System.Console.WriteLine("")
End Sub
End Module
|
ajlopez/AjGenesis
|
src/AjGenesis.Recipes/HelloWorld.vb
|
Visual Basic
|
mit
| 183
|
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class frmAddDataSourceGeneratedCounter
Inherits System.Windows.Forms.Form
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(frmAddDataSourceGeneratedCounter))
Me.GroupBox2 = New System.Windows.Forms.GroupBox
Me.btnCounterInstanceExclusionRemove = New System.Windows.Forms.Button
Me.btnCounterInstanceExclusionAdd = New System.Windows.Forms.Button
Me.ListBoxCounterInstanceExclusions = New System.Windows.Forms.ListBox
Me.txtCollectionVarName = New System.Windows.Forms.TextBox
Me.LabelAvgVarName = New System.Windows.Forms.Label
Me.LabelDataSourceCounterDataType = New System.Windows.Forms.Label
Me.ComboBoxDataSourceCounterDataType = New System.Windows.Forms.ComboBox
Me.btnOK = New System.Windows.Forms.Button
Me.btnCancel = New System.Windows.Forms.Button
Me.txtCounterName = New System.Windows.Forms.TextBox
Me.lblAnalysisName = New System.Windows.Forms.Label
Me.lblDescription = New System.Windows.Forms.Label
Me.GroupBoxThresholdCode = New System.Windows.Forms.GroupBox
Me.txtCode = New System.Windows.Forms.TextBox
Me.GroupBoxThresholdVariables = New System.Windows.Forms.GroupBox
Me.Label2 = New System.Windows.Forms.Label
Me.txtVarName = New System.Windows.Forms.TextBox
Me.lblVarName = New System.Windows.Forms.Label
Me.txtVarDescription = New System.Windows.Forms.TextBox
Me.lblTVarDescription = New System.Windows.Forms.Label
Me.ListBoxThresholdVariables = New System.Windows.Forms.ListBox
Me.GroupBox2.SuspendLayout()
Me.GroupBoxThresholdCode.SuspendLayout()
Me.GroupBoxThresholdVariables.SuspendLayout()
Me.SuspendLayout()
'
'GroupBox2
'
Me.GroupBox2.Controls.Add(Me.btnCounterInstanceExclusionRemove)
Me.GroupBox2.Controls.Add(Me.btnCounterInstanceExclusionAdd)
Me.GroupBox2.Controls.Add(Me.ListBoxCounterInstanceExclusions)
Me.GroupBox2.Location = New System.Drawing.Point(8, 133)
Me.GroupBox2.Name = "GroupBox2"
Me.GroupBox2.Size = New System.Drawing.Size(310, 181)
Me.GroupBox2.TabIndex = 23
Me.GroupBox2.TabStop = False
Me.GroupBox2.Text = "Instance Exclusions"
'
'btnCounterInstanceExclusionRemove
'
Me.btnCounterInstanceExclusionRemove.Location = New System.Drawing.Point(67, 152)
Me.btnCounterInstanceExclusionRemove.Name = "btnCounterInstanceExclusionRemove"
Me.btnCounterInstanceExclusionRemove.Size = New System.Drawing.Size(62, 23)
Me.btnCounterInstanceExclusionRemove.TabIndex = 9
Me.btnCounterInstanceExclusionRemove.Text = "Remove"
Me.btnCounterInstanceExclusionRemove.UseVisualStyleBackColor = True
'
'btnCounterInstanceExclusionAdd
'
Me.btnCounterInstanceExclusionAdd.Location = New System.Drawing.Point(4, 152)
Me.btnCounterInstanceExclusionAdd.Name = "btnCounterInstanceExclusionAdd"
Me.btnCounterInstanceExclusionAdd.Size = New System.Drawing.Size(62, 23)
Me.btnCounterInstanceExclusionAdd.TabIndex = 8
Me.btnCounterInstanceExclusionAdd.Text = "Add..."
Me.btnCounterInstanceExclusionAdd.UseVisualStyleBackColor = True
'
'ListBoxCounterInstanceExclusions
'
Me.ListBoxCounterInstanceExclusions.FormattingEnabled = True
Me.ListBoxCounterInstanceExclusions.HorizontalScrollbar = True
Me.ListBoxCounterInstanceExclusions.Location = New System.Drawing.Point(7, 15)
Me.ListBoxCounterInstanceExclusions.Name = "ListBoxCounterInstanceExclusions"
Me.ListBoxCounterInstanceExclusions.Size = New System.Drawing.Size(297, 134)
Me.ListBoxCounterInstanceExclusions.TabIndex = 7
'
'txtCollectionVarName
'
Me.txtCollectionVarName.Location = New System.Drawing.Point(118, 107)
Me.txtCollectionVarName.Name = "txtCollectionVarName"
Me.txtCollectionVarName.Size = New System.Drawing.Size(199, 20)
Me.txtCollectionVarName.TabIndex = 4
Me.txtCollectionVarName.Text = "$CollectionOfGeneratedCounterInstances"
'
'LabelAvgVarName
'
Me.LabelAvgVarName.AutoSize = True
Me.LabelAvgVarName.Location = New System.Drawing.Point(12, 110)
Me.LabelAvgVarName.Name = "LabelAvgVarName"
Me.LabelAvgVarName.Size = New System.Drawing.Size(100, 13)
Me.LabelAvgVarName.TabIndex = 12
Me.LabelAvgVarName.Text = "CollectionVarName:"
'
'LabelDataSourceCounterDataType
'
Me.LabelDataSourceCounterDataType.AutoSize = True
Me.LabelDataSourceCounterDataType.Location = New System.Drawing.Point(12, 84)
Me.LabelDataSourceCounterDataType.Name = "LabelDataSourceCounterDataType"
Me.LabelDataSourceCounterDataType.Size = New System.Drawing.Size(60, 13)
Me.LabelDataSourceCounterDataType.TabIndex = 20
Me.LabelDataSourceCounterDataType.Text = "Data Type:"
'
'ComboBoxDataSourceCounterDataType
'
Me.ComboBoxDataSourceCounterDataType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
Me.ComboBoxDataSourceCounterDataType.FormattingEnabled = True
Me.ComboBoxDataSourceCounterDataType.Items.AddRange(New Object() {"integer", "round1", "round2", "round3", "round4", "round5", "round6"})
Me.ComboBoxDataSourceCounterDataType.Location = New System.Drawing.Point(75, 76)
Me.ComboBoxDataSourceCounterDataType.Name = "ComboBoxDataSourceCounterDataType"
Me.ComboBoxDataSourceCounterDataType.Size = New System.Drawing.Size(162, 21)
Me.ComboBoxDataSourceCounterDataType.TabIndex = 2
'
'btnOK
'
Me.btnOK.Location = New System.Drawing.Point(8, 320)
Me.btnOK.Name = "btnOK"
Me.btnOK.Size = New System.Drawing.Size(75, 23)
Me.btnOK.TabIndex = 10
Me.btnOK.Text = "OK"
Me.btnOK.UseVisualStyleBackColor = True
'
'btnCancel
'
Me.btnCancel.Location = New System.Drawing.Point(90, 320)
Me.btnCancel.Name = "btnCancel"
Me.btnCancel.Size = New System.Drawing.Size(75, 23)
Me.btnCancel.TabIndex = 11
Me.btnCancel.Text = "Cancel"
Me.btnCancel.UseVisualStyleBackColor = True
'
'txtCounterName
'
Me.txtCounterName.Location = New System.Drawing.Point(75, 50)
Me.txtCounterName.Name = "txtCounterName"
Me.txtCounterName.Size = New System.Drawing.Size(243, 20)
Me.txtCounterName.TabIndex = 1
Me.txtCounterName.Text = "\Object(*)\Counter"
'
'lblAnalysisName
'
Me.lblAnalysisName.AutoSize = True
Me.lblAnalysisName.Location = New System.Drawing.Point(12, 50)
Me.lblAnalysisName.Name = "lblAnalysisName"
Me.lblAnalysisName.Size = New System.Drawing.Size(38, 13)
Me.lblAnalysisName.TabIndex = 28
Me.lblAnalysisName.Text = "Name:"
'
'lblDescription
'
Me.lblDescription.Location = New System.Drawing.Point(13, 13)
Me.lblDescription.Name = "lblDescription"
Me.lblDescription.Size = New System.Drawing.Size(305, 33)
Me.lblDescription.TabIndex = 29
Me.lblDescription.Text = "Use this form to add generated counters as additional datasources used by the ana" & _
"lysis thresholds."
'
'GroupBoxThresholdCode
'
Me.GroupBoxThresholdCode.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.GroupBoxThresholdCode.Controls.Add(Me.txtCode)
Me.GroupBoxThresholdCode.Location = New System.Drawing.Point(324, 209)
Me.GroupBoxThresholdCode.Name = "GroupBoxThresholdCode"
Me.GroupBoxThresholdCode.Size = New System.Drawing.Size(458, 129)
Me.GroupBoxThresholdCode.TabIndex = 33
Me.GroupBoxThresholdCode.TabStop = False
Me.GroupBoxThresholdCode.Text = "PowerShell Counter Generation Code"
'
'txtCode
'
Me.txtCode.AcceptsReturn = True
Me.txtCode.AcceptsTab = True
Me.txtCode.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.txtCode.ImeMode = System.Windows.Forms.ImeMode.Off
Me.txtCode.Location = New System.Drawing.Point(6, 13)
Me.txtCode.Multiline = True
Me.txtCode.Name = "txtCode"
Me.txtCode.ScrollBars = System.Windows.Forms.ScrollBars.Both
Me.txtCode.Size = New System.Drawing.Size(446, 110)
Me.txtCode.TabIndex = 27
Me.txtCode.WordWrap = False
'
'GroupBoxThresholdVariables
'
Me.GroupBoxThresholdVariables.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.GroupBoxThresholdVariables.Controls.Add(Me.Label2)
Me.GroupBoxThresholdVariables.Controls.Add(Me.txtVarName)
Me.GroupBoxThresholdVariables.Controls.Add(Me.lblVarName)
Me.GroupBoxThresholdVariables.Controls.Add(Me.txtVarDescription)
Me.GroupBoxThresholdVariables.Controls.Add(Me.lblTVarDescription)
Me.GroupBoxThresholdVariables.Controls.Add(Me.ListBoxThresholdVariables)
Me.GroupBoxThresholdVariables.Location = New System.Drawing.Point(324, 13)
Me.GroupBoxThresholdVariables.Name = "GroupBoxThresholdVariables"
Me.GroupBoxThresholdVariables.Size = New System.Drawing.Size(458, 190)
Me.GroupBoxThresholdVariables.TabIndex = 38
Me.GroupBoxThresholdVariables.TabStop = False
Me.GroupBoxThresholdVariables.Text = "Variables"
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(6, 16)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(221, 34)
Me.Label2.TabIndex = 7
Me.Label2.Text = "Variables that are available to be used in this counter generation PowerShell cod" & _
"e."
'
'txtVarName
'
Me.txtVarName.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.txtVarName.Location = New System.Drawing.Point(277, 17)
Me.txtVarName.Name = "txtVarName"
Me.txtVarName.ReadOnly = True
Me.txtVarName.Size = New System.Drawing.Size(173, 20)
Me.txtVarName.TabIndex = 6
'
'lblVarName
'
Me.lblVarName.AutoSize = True
Me.lblVarName.Location = New System.Drawing.Point(233, 20)
Me.lblVarName.Name = "lblVarName"
Me.lblVarName.Size = New System.Drawing.Size(38, 13)
Me.lblVarName.TabIndex = 5
Me.lblVarName.Text = "Name:"
'
'txtVarDescription
'
Me.txtVarDescription.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.txtVarDescription.Location = New System.Drawing.Point(324, 58)
Me.txtVarDescription.Multiline = True
Me.txtVarDescription.Name = "txtVarDescription"
Me.txtVarDescription.ReadOnly = True
Me.txtVarDescription.ScrollBars = System.Windows.Forms.ScrollBars.Vertical
Me.txtVarDescription.Size = New System.Drawing.Size(128, 121)
Me.txtVarDescription.TabIndex = 4
'
'lblTVarDescription
'
Me.lblTVarDescription.AutoSize = True
Me.lblTVarDescription.Location = New System.Drawing.Point(387, 40)
Me.lblTVarDescription.Name = "lblTVarDescription"
Me.lblTVarDescription.Size = New System.Drawing.Size(63, 13)
Me.lblTVarDescription.TabIndex = 3
Me.lblTVarDescription.Text = "Description:"
'
'ListBoxThresholdVariables
'
Me.ListBoxThresholdVariables.FormattingEnabled = True
Me.ListBoxThresholdVariables.Location = New System.Drawing.Point(9, 58)
Me.ListBoxThresholdVariables.Name = "ListBoxThresholdVariables"
Me.ListBoxThresholdVariables.ScrollAlwaysVisible = True
Me.ListBoxThresholdVariables.Size = New System.Drawing.Size(309, 121)
Me.ListBoxThresholdVariables.Sorted = True
Me.ListBoxThresholdVariables.TabIndex = 0
'
'frmAddDataSourceGeneratedCounter
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink
Me.ClientSize = New System.Drawing.Size(794, 350)
Me.Controls.Add(Me.GroupBoxThresholdVariables)
Me.Controls.Add(Me.GroupBoxThresholdCode)
Me.Controls.Add(Me.lblDescription)
Me.Controls.Add(Me.lblAnalysisName)
Me.Controls.Add(Me.txtCounterName)
Me.Controls.Add(Me.txtCollectionVarName)
Me.Controls.Add(Me.btnCancel)
Me.Controls.Add(Me.btnOK)
Me.Controls.Add(Me.LabelAvgVarName)
Me.Controls.Add(Me.GroupBox2)
Me.Controls.Add(Me.LabelDataSourceCounterDataType)
Me.Controls.Add(Me.ComboBoxDataSourceCounterDataType)
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.MinimumSize = New System.Drawing.Size(800, 378)
Me.Name = "frmAddDataSourceGeneratedCounter"
Me.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Show
Me.Text = "Add a Generated DataSource Counter"
Me.GroupBox2.ResumeLayout(False)
Me.GroupBoxThresholdCode.ResumeLayout(False)
Me.GroupBoxThresholdCode.PerformLayout()
Me.GroupBoxThresholdVariables.ResumeLayout(False)
Me.GroupBoxThresholdVariables.PerformLayout()
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents GroupBox2 As System.Windows.Forms.GroupBox
Friend WithEvents btnCounterInstanceExclusionRemove As System.Windows.Forms.Button
Friend WithEvents btnCounterInstanceExclusionAdd As System.Windows.Forms.Button
Friend WithEvents ListBoxCounterInstanceExclusions As System.Windows.Forms.ListBox
Friend WithEvents txtCollectionVarName As System.Windows.Forms.TextBox
Friend WithEvents LabelAvgVarName As System.Windows.Forms.Label
Friend WithEvents LabelDataSourceCounterDataType As System.Windows.Forms.Label
Friend WithEvents ComboBoxDataSourceCounterDataType As System.Windows.Forms.ComboBox
Friend WithEvents btnOK As System.Windows.Forms.Button
Friend WithEvents btnCancel As System.Windows.Forms.Button
Friend WithEvents txtCounterName As System.Windows.Forms.TextBox
Friend WithEvents lblAnalysisName As System.Windows.Forms.Label
Friend WithEvents lblDescription As System.Windows.Forms.Label
Friend WithEvents GroupBoxThresholdCode As System.Windows.Forms.GroupBox
Friend WithEvents txtCode As System.Windows.Forms.TextBox
Friend WithEvents GroupBoxThresholdVariables As System.Windows.Forms.GroupBox
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents txtVarName As System.Windows.Forms.TextBox
Friend WithEvents lblVarName As System.Windows.Forms.Label
Friend WithEvents txtVarDescription As System.Windows.Forms.TextBox
Friend WithEvents lblTVarDescription As System.Windows.Forms.Label
Friend WithEvents ListBoxThresholdVariables As System.Windows.Forms.ListBox
End Class
|
clinthuffman/PAL
|
PAL2/PALWizard/frmAddDataSourceGenerated.Designer.vb
|
Visual Basic
|
mit
| 17,508
|
'------------------------------------------------------------------------------
' <auto-generated>
' This code was generated by a tool.
' Runtime Version:4.0.30319.42000
'
' Changes to this file may cause incorrect behavior and will be lost if
' the code is regenerated.
' </auto-generated>
'------------------------------------------------------------------------------
Option Strict On
Option Explicit On
Namespace My
<Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0"), _
Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Partial Friend NotInheritable Class MySettings
Inherits Global.System.Configuration.ApplicationSettingsBase
Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings()),MySettings)
#Region "My.Settings Auto-Save Functionality"
#If _MyType = "WindowsForms" Then
Private Shared addedHandler As Boolean
Private Shared addedHandlerLockObject As New Object
<Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs)
If My.Application.SaveMySettingsOnExit Then
My.Settings.Save()
End If
End Sub
#End If
#End Region
Public Shared ReadOnly Property [Default]() As MySettings
Get
#If _MyType = "WindowsForms" Then
If Not addedHandler Then
SyncLock addedHandlerLockObject
If Not addedHandler Then
AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings
addedHandler = True
End If
End SyncLock
End If
#End If
Return defaultInstance
End Get
End Property
End Class
End Namespace
Namespace My
<Global.Microsoft.VisualBasic.HideModuleNameAttribute(), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute()> _
Friend Module MySettingsProperty
<Global.System.ComponentModel.Design.HelpKeywordAttribute("My.Settings")> _
Friend ReadOnly Property Settings() As Global.LampService.My.MySettings
Get
Return Global.LampService.My.MySettings.Default
End Get
End Property
End Module
End Namespace
|
KameQuazi/Software-Major-Assignment-2k18
|
LampService/My Project/Settings.Designer.vb
|
Visual Basic
|
mit
| 2,912
|
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
' File: PayPal.aspx.vb
'
' Facility: The unit contains the PayPal class
'
' Abstract: This class is intended for interacting with PayPal with the
' help of the form of the payment request this class creates.
'
' Environment: VC 8.0
'
' Author: KB_Soft Group Ltd.
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Imports System.Configuration.ConfigurationManager
Partial Class PayPalLASTDIG
Inherits System.Web.UI.Page
Protected cmd As String = "_xclick"
Protected business As String = ""
Protected item_name As String = "2011 Last Dig In Denver Registration"
Protected item_number As String = "" 'used to hold person ID of the transaction
Protected amount As String = ""
'JPC TEST'
Protected return_url As String = "http://cgva.org/lastdigindenver/lastdigindenver_DEV/RegistrationSuccess.aspx"
Protected notify_url As String = "http://cgva.org/lastdigindenver/lastdigindenver_DEV/IPNHandler.aspx"
'JPC TEST'
Protected cancel_url As String = "http://cgva.org/lastdigindenver/lastdigindenver_DEV/registrationCancel.aspx"
Protected currency_code As String = AppSettings("CurrencyCode")
Protected paypaluser As String = ""
Protected pwd As String = ""
Protected signature As String = ""
Protected no_shipping As String = "1"
Protected URL As String
Protected custom As String = ""
Protected invoice As String = ""
Protected rm As String
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Me.Load
' the total cost of the cart
amount = Session("totalFee")
'TEST
'amount = "1"
'teamname_division_totalfee
custom = Session("custom")
'for Kevins reconciliation
' item_number = Session("transactionID")
' determining the URL to work with depending on whether sandbox or a real PayPal account should be used
'If AppSettings("UseSandbox").ToString = "true" Then
URL = "https://www.sandbox.paypal.com/cgi-bin/webscr"
business = AppSettings("devBusinessEmail")
paypaluser = AppSettings("devUSER")
pwd = AppSettings("devPWD")
signature = AppSettings("devSIGNATURE")
'Else
'URL = "https://www.paypal.com/cgi-bin/webscr"
'business = AppSettings("prodBusinessEmail")
'paypaluser = AppSettings("prodUSER")
'pwd = AppSettings("prodPWD")
'signature = AppSettings("prodSIGNATURE")
'End If
'This parameter determines the was information about successful transaction
'will be passed to the script
' specified in the return_url parameter.
' "1" - no parameters will be passed.
' "2" - the POST method will be used.
' "0" - the GET method will be used.
' The parameter is "0" by deault.
'If AppSettings("SendToReturnURL").ToString = "true" Then
rm = "2"
'Else
'rm = "1"
'End If
'Response.Write("Session(totalFee)" + amount.ToString)
'Response.Write("Session(custom)" + custom.ToString)
'Response.Write("Session(transactionID)" + item_number.ToString)
'Response.End()
End Sub
End Class
|
CGVA/cgva_asp_website
|
lastdigindenver_DEV/PayPalLASTDIG.aspx.vb
|
Visual Basic
|
apache-2.0
| 3,485
|
Namespace YahooManaged.Finance.Indicators
Public Class Momentum
Implements ISingleValueIndicator
Public ReadOnly Property Name() As String Implements IIndicator.Name
Get
Return "Momentum"
End Get
End Property
Public ReadOnly Property IsRealative As Boolean Implements IIndicator.IsRealative
Get
Return True
End Get
End Property
Public ReadOnly Property ScaleMaximum() As Double Implements IIndicator.ScaleMaximum
Get
Return Double.PositiveInfinity
End Get
End Property
Public ReadOnly Property ScaleMinimum() As Double Implements IIndicator.ScaleMinimum
Get
Return 0
End Get
End Property
Public Property Period() As Integer = 12 Implements IIndicator.Period
Public Function Calculate(ByVal values As IEnumerable(Of KeyValuePair(Of Date, Double))) As Dictionary(Of Date, Double)() Implements ISingleValueIndicator.Calculate
Dim momResult As New Dictionary(Of Date, Double)
Dim quoteValues As New List(Of KeyValuePair(Of Date, Double))(values)
quoteValues.Sort(New QuotesSorter)
If quoteValues.Count > 0 Then
For i As Integer = 0 To quoteValues.Count - 1
If i >= Me.Period Then
momResult.Add(quoteValues(i).Key, (quoteValues(i).Value / quoteValues(i - Me.Period).Value) * 100)
Else
momResult.Add(quoteValues(i).Key, (quoteValues(i).Value / quoteValues(0).Value) * 100)
End If
Next
End If
Return New Dictionary(Of Date, Double)() {momResult}
End Function
Public Overrides Function ToString() As String
Return Me.Name & " " & Me.Period
End Function
End Class
End Namespace
|
agassan/YahooManaged
|
MaasOne.YahooManaged/YahooManaged/Finance/Indicators/Momentum.vb
|
Visual Basic
|
apache-2.0
| 1,992
|
Namespace AW.Types
Public Class WorkOrders
Public Shared Function ActionRandomWorkOrder() As WorkOrder
Return GenericMenuFunctions.Random(Of WorkOrder)()
End Function
Public Shared Function ActionAllWorkOrders() As IQueryable(Of WorkOrder)
Return GenericMenuFunctions.ListAll(Of WorkOrder)()
End Function
Public Shared Function ActionCurrentWorkOrders() As IQueryable(Of WorkOrder)
Return From w In ThreadLocals.Container.AllInstances(Of WorkOrder)()
Where w.mappedEndDate Is Nothing
End Function
Public Shared Function SharedMenuOrder() As Menu
Dim main = New Menu("Work Orders")
main.AddAction(NameOf(ActionRandomWorkOrder)) _
.AddAction("ActionCurrentWorkOrders") _ 'To test that Action prefix is not added if already there
.AddAction("AllWorkOrders") 'To test that Action prefix is added & name is case insensitive
Return main
End Function
End Class
End Namespace
|
NakedObjectsGroup/NakedObjectsFramework
|
Test/NOF2.Demo.Model/WorkOrders.vb
|
Visual Basic
|
apache-2.0
| 1,064
|
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System.Composition
Imports System.Linq
Imports Microsoft.CodeAnalysis
Imports Microsoft.CodeAnalysis.CodeFixes
Imports Microsoft.CodeAnalysis.VisualBasic
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Namespace Microsoft.QualityGuidelines.Analyzers
''' <summary>
''' CA1802: Use literals where appropriate
''' </summary>
<ExportCodeFixProvider(LanguageNames.VisualBasic), [Shared]>
Public NotInheritable Class BasicUseLiteralsWhereAppropriateFixer
Inherits UseLiteralsWhereAppropriateFixer
End Class
End Namespace
|
mattwar/roslyn-analyzers
|
src/Microsoft.QualityGuidelines.Analyzers/VisualBasic/BasicUseLiteralsWhereAppropriate.Fixer.vb
|
Visual Basic
|
apache-2.0
| 726
|
Imports System.Windows.Forms
'TODO: Follow these steps to enable the Ribbon (XML) item:
'2. Create callback methods in the "Ribbon Callbacks" region of this class to handle user
' actions, such as clicking a button. Note: if you have exported this Ribbon from the
' Ribbon designer, move your code from the event handlers to the callback methods and
' modify the code to work with the Ribbon extensibility (RibbonX) programming model.
'3. Assign attributes to the control tags in the Ribbon XML file to identify the appropriate callback methods in your code.
'For more information, see the Ribbon XML documentation in the Visual Studio Tools for Office Help.
<Runtime.InteropServices.ComVisible(True)> _
Public Class Ribbon1
Implements Office.IRibbonExtensibility
Private ribbon As Office.IRibbonUI
Public Sub New()
End Sub
Public Function GetCustomUI(ByVal ribbonID As String) As String Implements Office.IRibbonExtensibility.GetCustomUI
Return GetResourceText("EmailSizer.Ribbon1.xml")
End Function
#Region "Ribbon Callbacks"
'Create callback methods here. For more information about adding callback methods, select the Ribbon XML item in Solution Explorer and then press F1.
Public Sub Ribbon_Load(ByVal ribbonUI As Office.IRibbonUI)
Me.ribbon = ribbonUI
'Via 'Invalidating Ribbon from Outside Ribbon' on MSDN Social...
Globals.QuotaTool.ribbon = Me.ribbon
End Sub
'This dynamically updates the button text (and sets a condition for if we haven't sized yet)
Public Function get_LabelName(ByVal control As Office.IRibbonControl) As String
If QuotaTool.RawSize = 0 Then
Return "Click me to update!"
Else
Return QuotaTool.PercentageQuota & " Percent Used"
End If
End Function
'This dynamically updates the ribbon image based on the percentage of used quota
Public Function showthebox(ByVal control As Office.IRibbonControl) As System.Drawing.Bitmap
If QuotaTool.PercentageQuota < 75 Then
Return My.Resources.Resource1.green
ElseIf (QuotaTool.PercentageQuota >= 75 And QuotaTool.PercentageQuota < 90) Then
Return My.Resources.Resource1.yellow
ElseIf QuotaTool.PercentageQuota >= 90 Then
Return My.Resources.Resource1.red
Else
'If all else fails, make the button yellow :) (alert!)
Return My.Resources.Resource1.yellow
End If
End Function
'Action on click -- display detailed statistics
Public Sub clickthebutton(ByVal control As Office.IRibbonControl)
ribbon.InvalidateControl("QuotaIconButton")
Dim detailsBox As New Details
detailsBox.Show()
End Sub
#End Region
#Region "Helpers"
Private Shared Function GetResourceText(ByVal resourceName As String) As String
Dim asm As Reflection.Assembly = Reflection.Assembly.GetExecutingAssembly()
Dim resourceNames() As String = asm.GetManifestResourceNames()
For i As Integer = 0 To resourceNames.Length - 1
If String.Compare(resourceName, resourceNames(i), StringComparison.OrdinalIgnoreCase) = 0 Then
Using resourceReader As IO.StreamReader = New IO.StreamReader(asm.GetManifestResourceStream(resourceNames(i)))
If resourceReader IsNot Nothing Then
Return resourceReader.ReadToEnd()
End If
End Using
End If
Next
Return Nothing
End Function
#End Region
End Class
|
davidschlachter/outlookquota
|
EmailSizer/Ribbon1.vb
|
Visual Basic
|
bsd-2-clause
| 3,576
|
' Licensed to the .NET Foundation under one or more agreements.
' The .NET Foundation licenses this file to you under the MIT license.
' See the LICENSE file in the project root for more information.
Imports System.Composition
Imports System.Threading
Imports Microsoft.CodeAnalysis.DocumentationComments
Imports Microsoft.CodeAnalysis.LanguageServices
Imports Microsoft.CodeAnalysis.SignatureHelp
Imports Microsoft.CodeAnalysis.Text
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Namespace Microsoft.CodeAnalysis.VisualBasic.SignatureHelp
<ExportSignatureHelpProvider("ObjectCreationExpressionSignatureHelpProvider", LanguageNames.VisualBasic), [Shared]>
Partial Friend Class ObjectCreationExpressionSignatureHelpProvider
Inherits AbstractVisualBasicSignatureHelpProvider
<ImportingConstructor>
Public Sub New()
End Sub
Public Overrides Function IsTriggerCharacter(ch As Char) As Boolean
Return ch = "("c OrElse ch = ","c
End Function
Public Overrides Function IsRetriggerCharacter(ch As Char) As Boolean
Return ch = ")"c
End Function
Public Overrides Function GetCurrentArgumentState(root As SyntaxNode, position As Integer, syntaxFacts As ISyntaxFactsService, currentSpan As TextSpan, cancellationToken As CancellationToken) As SignatureHelpState
Dim expression As ObjectCreationExpressionSyntax = Nothing
If TryGetObjectCreationExpression(root, position, syntaxFacts, SignatureHelpTriggerReason.InvokeSignatureHelpCommand, cancellationToken, expression) AndAlso
currentSpan.Start = SignatureHelpUtilities.GetSignatureHelpSpan(expression.ArgumentList).Start Then
Return SignatureHelpUtilities.GetSignatureHelpState(expression.ArgumentList, position)
End If
Return Nothing
End Function
Private Function TryGetObjectCreationExpression(root As SyntaxNode, position As Integer, syntaxFacts As ISyntaxFactsService, triggerReason As SignatureHelpTriggerReason, cancellationToken As CancellationToken, ByRef expression As ObjectCreationExpressionSyntax) As Boolean
If Not CommonSignatureHelpUtilities.TryGetSyntax(root, position, syntaxFacts, triggerReason, AddressOf IsTriggerToken, AddressOf IsArgumentListToken, cancellationToken, expression) Then
Return False
End If
Return expression.ArgumentList IsNot Nothing
End Function
Private Shared Function IsTriggerToken(token As SyntaxToken) As Boolean
Return (token.Kind = SyntaxKind.OpenParenToken OrElse token.Kind = SyntaxKind.CommaToken) AndAlso
TypeOf token.Parent Is ArgumentListSyntax AndAlso
TypeOf token.Parent.Parent Is ObjectCreationExpressionSyntax
End Function
Private Shared Function IsArgumentListToken(node As ObjectCreationExpressionSyntax, token As SyntaxToken) As Boolean
Return node.ArgumentList IsNot Nothing AndAlso
node.ArgumentList.Span.Contains(token.SpanStart) AndAlso
token <> node.ArgumentList.CloseParenToken
End Function
Protected Overrides Async Function GetItemsWorkerAsync(document As Document, position As Integer, triggerInfo As SignatureHelpTriggerInfo, cancellationToken As CancellationToken) As Task(Of SignatureHelpItems)
Dim root = Await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(False)
Dim objectCreationExpression As ObjectCreationExpressionSyntax = Nothing
If Not TryGetObjectCreationExpression(root, position, document.GetLanguageService(Of ISyntaxFactsService), triggerInfo.TriggerReason, cancellationToken, objectCreationExpression) Then
Return Nothing
End If
Dim semanticModel = Await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(False)
Dim type = TryCast(semanticModel.GetTypeInfo(objectCreationExpression, cancellationToken).Type, INamedTypeSymbol)
If type Is Nothing Then
Return Nothing
End If
Dim within = semanticModel.GetEnclosingNamedTypeOrAssembly(position, cancellationToken)
If within Is Nothing Then
Return Nothing
End If
Dim symbolDisplayService = document.GetLanguageService(Of ISymbolDisplayService)()
Dim anonymousTypeDisplayService = document.GetLanguageService(Of IAnonymousTypeDisplayService)()
Dim documentationCommentFormattingService = document.GetLanguageService(Of IDocumentationCommentFormattingService)()
Dim textSpan = SignatureHelpUtilities.GetSignatureHelpSpan(objectCreationExpression.ArgumentList)
Dim syntaxFacts = document.GetLanguageService(Of ISyntaxFactsService)
Dim itemsAndSelected = If(type.TypeKind = TypeKind.Delegate,
GetDelegateTypeConstructors(objectCreationExpression, semanticModel, symbolDisplayService, anonymousTypeDisplayService, documentationCommentFormattingService, type, within, cancellationToken),
GetNormalTypeConstructors(document, objectCreationExpression, semanticModel, symbolDisplayService, anonymousTypeDisplayService, type, within, cancellationToken))
Return CreateSignatureHelpItems(itemsAndSelected.Items,
textSpan,
GetCurrentArgumentState(root, position, syntaxFacts, textSpan, cancellationToken),
itemsAndSelected.SelectedItem)
End Function
End Class
End Namespace
|
abock/roslyn
|
src/Features/VisualBasic/Portable/SignatureHelp/ObjectCreationExpressionSignatureHelpProvider.vb
|
Visual Basic
|
mit
| 5,725
|
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports Microsoft.NetFramework.Analyzers
Imports Microsoft.CodeAnalysis
Imports Microsoft.CodeAnalysis.Diagnostics
Imports Microsoft.CodeAnalysis.VisualBasic
Imports Microsoft.NetFramework.Analyzers.Helpers
Imports Microsoft.NetFramework.VisualBasic.Analyzers.Helpers
Namespace Microsoft.NetFramework.VisualBasic.Analyzers
<DiagnosticAnalyzer(LanguageNames.VisualBasic)>
Public Class BasicDoNotUseInsecureDtdProcessingInApiDesignAnalyzer
Inherits DoNotUseInsecureDtdProcessingInApiDesignAnalyzer
Protected Overrides Function GetAnalyzer(context As CompilationStartAnalysisContext, types As CompilationSecurityTypes, targetFrameworkVersion As Version) As SymbolAndNodeAnalyzer
Dim analyzer As New SymbolAndNodeAnalyzer(types, BasicSyntaxNodeHelper.DefaultInstance, targetFrameworkVersion)
context.RegisterSyntaxNodeAction(AddressOf analyzer.AnalyzeNode, SyntaxKind.SubBlock, SyntaxKind.FunctionBlock, SyntaxKind.ConstructorBlock)
Return analyzer
End Function
End Class
End Namespace
|
natidea/roslyn-analyzers
|
src/Microsoft.NetFramework.Analyzers/VisualBasic/BasicDoNotUseInsecureDtdProcessingInApiDesign.vb
|
Visual Basic
|
apache-2.0
| 1,222
|
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System.Composition
Imports Microsoft.CodeAnalysis.EmbeddedLanguages.LanguageServices
Imports Microsoft.CodeAnalysis.Host.Mef
Imports Microsoft.CodeAnalysis.VisualBasic.EmbeddedLanguages.VirtualChars
Namespace Microsoft.CodeAnalysis.VisualBasic.EmbeddedLanguages.LanguageServices
<ExportLanguageService(GetType(IEmbeddedLanguagesProvider), LanguageNames.VisualBasic, ServiceLayer.Default), [Shared]>
Friend Class VisualBasicEmbeddedLanguagesProvider
Inherits AbstractEmbeddedLanguagesProvider
Public Shared Info As New EmbeddedLanguageInfo(
SyntaxKind.StringLiteralToken,
SyntaxKind.InterpolatedStringTextToken,
VisualBasicSyntaxFactsService.Instance,
VisualBasicSemanticFactsService.Instance,
VisualBasicVirtualCharService.Instance)
<ImportingConstructor>
<Obsolete(MefConstruction.ImportingConstructorMessage, True)>
Public Sub New()
MyBase.New(Info)
End Sub
End Class
End Namespace
|
aelij/roslyn
|
src/Workspaces/VisualBasic/Portable/EmbeddedLanguages/LanguageServices/VisualBasicEmbeddedLanguagesProvider.vb
|
Visual Basic
|
apache-2.0
| 1,191
|
' Copyright (c) 2015 ZZZ Projects. All rights reserved
' Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods)
' Website: http://www.zzzprojects.com/
' Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927
' All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library
Public Module Extensions_429
''' <summary>
''' An object extension method that converts this object to the s byte or default.
''' </summary>
''' <param name="this">The @this to act on.</param>
''' <returns>The given data converted to a sbyte.</returns>
<System.Runtime.CompilerServices.Extension> _
Public Function ToSByteOrDefault(this As Object) As SByte
Try
Return Convert.ToSByte(this)
Catch generatedExceptionName As Exception
Return 0
End Try
End Function
''' <summary>
''' An object extension method that converts this object to the s byte or default.
''' </summary>
''' <param name="this">The @this to act on.</param>
''' <param name="defaultValue">The default value.</param>
''' <returns>The given data converted to a sbyte.</returns>
<System.Runtime.CompilerServices.Extension> _
Public Function ToSByteOrDefault(this As Object, defaultValue As SByte) As SByte
Try
Return Convert.ToSByte(this)
Catch generatedExceptionName As Exception
Return defaultValue
End Try
End Function
''' <summary>
''' An object extension method that converts this object to the s byte or default.
''' </summary>
''' <param name="this">The @this to act on.</param>
''' <param name="defaultValueFactory">The default value factory.</param>
''' <returns>The given data converted to a sbyte.</returns>
<System.Runtime.CompilerServices.Extension> _
Public Function ToSByteOrDefault(this As Object, defaultValueFactory As Func(Of SByte)) As SByte
Try
Return Convert.ToSByte(this)
Catch generatedExceptionName As Exception
Return defaultValueFactory()
End Try
End Function
End Module
|
zzzprojects/Z.ExtensionMethods
|
src (VB.NET)/Z.ExtensionMethods.VB/Z.Core/System.Object/Convert/ToValueType/Object.ToSByteOrDefault.vb
|
Visual Basic
|
mit
| 2,023
|
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System.Threading.Tasks
Imports Microsoft.CodeAnalysis
Imports Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces
Imports Microsoft.CodeAnalysis.Text
Namespace Microsoft.CodeAnalysis.Editor.UnitTests.Expansion
Public Class ModuleNameExpansionTests
Inherits AbstractExpansionTest
<WpfFact, Trait(Traits.Feature, Traits.Features.Expansion)>
Public Async Function TestExpandModuleNameForSimpleName() As Task
Dim input =
<Workspace>
<Project Language="Visual Basic" CommonReferences="true">
<Document>
Imports N
Module Program
Sub Main()
{|Expand:Foo|}()
End Sub
End Module
Namespace N
Module X
Sub Foo()
End Sub
End Module
End Namespace
</Document>
</Project>
</Workspace>
Dim expected =
<code>
Imports N
Module Program
Sub Main()
Call Global.N.X.Foo()
End Sub
End Module
Namespace N
Module X
Sub Foo()
End Sub
End Module
End Namespace
</code>
Await TestAsync(input, expected)
End Function
<WpfFact, Trait(Traits.Feature, Traits.Features.Expansion)>
Public Async Function TestExpandModuleNameForQualifiedNameWithMissingModuleName() As Task
Dim input =
<Workspace>
<Project Language="Visual Basic" CommonReferences="true">
<Document>
Imports N
Module Program
Sub Main()
Dim bar As {|Expand:N.Foo|}
End Sub
End Module
Namespace N
Module X
Class Foo
End Class
End Module
End Namespace
</Document>
</Project>
</Workspace>
Dim expected =
<code>
Imports N
Module Program
Sub Main()
Dim bar As Global.N.X.Foo
End Sub
End Module
Namespace N
Module X
Class Foo
End Class
End Module
End Namespace
</code>
Await TestAsync(input, expected)
End Function
<WpfFact, Trait(Traits.Feature, Traits.Features.Expansion)>
Public Async Function TestExpandModuleNameForMemberAccessWithMissingModuleName() As Task
Dim input =
<Workspace>
<Project Language="Visual Basic" CommonReferences="true">
<Document>
Imports N
Module Program
Sub Main()
{|Expand:N.Foo()|}
End Sub
End Module
Namespace N
Module X
Sub Foo()
End Sub
End Module
End Namespace
</Document>
</Project>
</Workspace>
Dim expected =
<code>
Imports N
Module Program
Sub Main()
Global.N.X.Foo()
End Sub
End Module
Namespace N
Module X
Sub Foo()
End Sub
End Module
End Namespace
</code>
Await TestAsync(input, expected)
End Function
<WpfFact, Trait(Traits.Feature, Traits.Features.Expansion)>
Public Async Function TestExpandAndOmitModuleNameWhenConflicting() As Task
Dim input =
<Workspace>
<Project Language="Visual Basic" AssemblyName="Project1" CommonReferences="true">
<Document>
Namespace X
Public Module Y
Public Class C
End Class
End Module
End Namespace
</Document>
</Project>
<Project Language="Visual Basic" AssemblyName="Project2" CommonReferences="true">
<ProjectReference>Project1</ProjectReference>
<Document>
Namespace X
Namespace Y
Class D
Inherits {|Expand:C|}
End Class
End Namespace
End Namespace
</Document>
</Project>
</Workspace>
Dim expected =
<code>
Namespace X
Namespace Y
Class D
Inherits Global.X.C
End Class
End Namespace
End Namespace
</code>
Await TestAsync(input, expected, useLastProject:=True)
End Function
<WpfFact, Trait(Traits.Feature, Traits.Features.Expansion)>
Public Async Function TestExpandModuleNameForSimpleNameRoundtrip() As Task
Dim input =
<Workspace>
<Project Language="Visual Basic" CommonReferences="true">
<Document>
Imports N
Module Program
Sub Main()
{|ExpandAndSimplify:Foo|}()
End Sub
End Module
Namespace N
Module X
Sub Foo()
End Sub
End Module
End Namespace
</Document>
</Project>
</Workspace>
Dim expected =
<code>
Imports N
Module Program
Sub Main()
Foo()
End Sub
End Module
Namespace N
Module X
Sub Foo()
End Sub
End Module
End Namespace
</code>
Await TestAsync(input, expected)
End Function
<WpfFact, Trait(Traits.Feature, Traits.Features.Expansion)>
Public Async Function TestExpandModuleNameForQualifiedNameWithMissingModuleNameRoundtrip() As Task
Dim input =
<Workspace>
<Project Language="Visual Basic" CommonReferences="true">
<Document>
Imports N
Module Program
Sub Main()
Dim bar As {|ExpandAndSimplify:N.Foo|}
End Sub
End Module
Namespace N
Module X
Class Foo
End Class
End Module
End Namespace
</Document>
</Project>
</Workspace>
Dim expected =
<code>
Imports N
Module Program
Sub Main()
Dim bar As N.Foo
End Sub
End Module
Namespace N
Module X
Class Foo
End Class
End Module
End Namespace
</code>
Await TestAsync(input, expected)
End Function
End Class
End Namespace
|
managed-commons/roslyn
|
src/EditorFeatures/Test2/Expansion/ModuleNameExpansionTests.vb
|
Visual Basic
|
apache-2.0
| 6,102
|
' Licensed to the .NET Foundation under one or more agreements.
' The .NET Foundation licenses this file to you under the MIT license.
' See the LICENSE file in the project root for more information.
Imports System
Imports Microsoft.VisualBasic.CompilerServices.Utils
Namespace Microsoft.VisualBasic.CompilerServices
Friend Enum vbErrors
ObjNotSet = 91
IllegalFor = 92
End Enum
' Implements error utilities for Basic
Friend NotInheritable Class ExceptionUtils
' Prevent creation.
Private Sub New()
End Sub
Friend Shared Function VbMakeIllegalForException() As System.Exception
Return VbMakeExceptionEx(vbErrors.IllegalFor, GetResourceString(SR.ID92)) ' 92 - IllegaFor
End Function
Friend Shared Function VbMakeObjNotSetException() As System.Exception
Return VbMakeExceptionEx(vbErrors.IllegalFor, GetResourceString(SR.ID91)) ' 91 - ObjNotSet
End Function
Private Shared Function VbMakeExceptionEx(ByVal number As Integer, ByVal sMsg As String) As System.Exception
Dim vBDefinedError As Boolean
VbMakeExceptionEx = BuildException(number, sMsg, vBDefinedError)
If vBDefinedError Then
End If
End Function
Private Shared Function BuildException(ByVal number As Integer, ByVal description As String, ByRef vBDefinedError As Boolean) As System.Exception
vBDefinedError = True
Select Case number
Case vbErrors.ObjNotSet
Return New NullReferenceException(description)
Case Else
vBDefinedError = False
Return New Exception(description)
End Select
vBDefinedError = False
Return New Exception(description)
End Function
End Class
Public NotInheritable Class InternalErrorException
Inherits System.Exception
Public Sub New(ByVal message As String)
MyBase.New(message)
End Sub
Public Sub New(ByVal message As String, ByVal innerException As System.Exception)
MyBase.New(message, innerException)
End Sub
' default constructor
Public Sub New()
MyBase.New(GetResourceString(SR.InternalError))
End Sub
End Class
End Namespace
|
mafiya69/corefx
|
src/Microsoft.VisualBasic/src/Microsoft/VisualBasic/CompilerServices/ExceptionUtils.vb
|
Visual Basic
|
mit
| 2,388
|
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System.Xml.Linq
Imports Microsoft.CodeAnalysis.Editor.UnitTests.AutomaticCompletion
Imports Microsoft.CodeAnalysis.Editor.UnitTests.Extensions
Imports Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces
Imports Microsoft.CodeAnalysis.Editor.Implementation.AutomaticCompletion
Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.AutomaticCompletion
Public Class AutomaticInterpolatedStringExpressionCompletionTests
Inherits AbstractAutomaticBraceCompletionTests
<WpfFact, Trait(Traits.Feature, Traits.Features.AutomaticCompletion)>
Public Sub Creation()
Using session = CreateSession("$$")
Assert.NotNull(session)
End Using
End Sub
<WpfFact, Trait(Traits.Feature, Traits.Features.AutomaticCompletion)>
Public Sub InvalidLocation_String()
Dim code = <code>Class C
Dim s As String = "$$
End Class</code>
Using session = CreateSession(code)
Assert.Null(session)
End Using
End Sub
<WpfFact, Trait(Traits.Feature, Traits.Features.AutomaticCompletion)>
Public Sub InvalidLocation_Comment()
Dim code = <code>Class C
' $$
End Class</code>
Using session = CreateSession(code)
Assert.Null(session)
End Using
End Sub
<WpfFact, Trait(Traits.Feature, Traits.Features.AutomaticCompletion)>
Public Sub InvalidLocation_DocComment()
Dim code = <code>Class C
''' $$
End Class</code>
Using session = CreateSession(code)
Assert.Null(session)
End Using
End Sub
<WpfFact, Trait(Traits.Feature, Traits.Features.AutomaticCompletion)>
Public Sub AfterDollarSign()
Dim code = <code>Class C
Sub M()
Dim s = $$$
End Sub
End Class</code>
Using session = CreateSession(code)
Assert.NotNull(session)
CheckStart(session.Session)
End Using
End Sub
Friend Overloads Function CreateSession(code As XElement) As Holder
Return CreateSession(code.NormalizedValue())
End Function
Friend Overloads Function CreateSession(code As String) As Holder
Return CreateSession(
VisualBasicWorkspaceFactory.CreateWorkspaceFromFile(code),
BraceCompletionSessionProvider.DoubleQuote.OpenCharacter, BraceCompletionSessionProvider.DoubleQuote.CloseCharacter)
End Function
End Class
End Namespace
|
jbhensley/roslyn
|
src/EditorFeatures/VisualBasicTest/AutomaticCompletion/AutomaticInterpolatedStringExpressionCompletionTests.vb
|
Visual Basic
|
apache-2.0
| 2,747
|
' Copyright (c) Microsoft. 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.Linq
Imports System.Runtime.InteropServices
Imports System.Text
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
Partial Friend Class ExpressionLambdaRewriter
Private Function VisitUnaryOperator(node As BoundUnaryOperator) As BoundExpression
Dim origArg As BoundExpression = node.Operand
Dim origArgType As TypeSymbol = origArg.Type
Dim origArgNotNullableType As TypeSymbol = origArgType.GetNullableUnderlyingTypeOrSelf
Dim origArgUnderlyingType As TypeSymbol = origArgNotNullableType.GetEnumUnderlyingTypeOrSelf
Dim origArgUnderlyingSpecialType As SpecialType = origArgUnderlyingType.SpecialType
Debug.Assert(origArgType = node.Type)
Dim argument As BoundExpression = Visit(origArg)
Dim opKind As UnaryOperatorKind = node.OperatorKind And UnaryOperatorKind.OpMask
Dim isChecked As Boolean = node.Checked AndAlso origArgUnderlyingType.IsIntegralType
Dim helperName As String = Nothing
Debug.Assert((node.OperatorKind And UnaryOperatorKind.UserDefined) = 0)
Select Case opKind
Case UnaryOperatorKind.Plus
' DEV11 comment:
' Note that the unary plus operator itself is not encoded in the tree and treated
' as a nop currently. This is the orcas behavior.
If Not origArgType.IsReferenceType Then
Return argument
End If
Dim method As MethodSymbol = GetHelperForObjectUnaryOperation(opKind)
Return If(method Is Nothing, argument, ConvertRuntimeHelperToExpressionTree("UnaryPlus", argument, Me._factory.MethodInfo(method)))
Case UnaryOperatorKind.Minus
helperName = If(isChecked, "NegateChecked", "Negate")
GoTo lNotAndMinus
Case UnaryOperatorKind.Not
helperName = "Not"
lNotAndMinus:
' NOTE: Both '-' and 'Not' processed by the code below
Dim method As MethodSymbol = Nothing
If origArgType.IsReferenceType Then
method = GetHelperForObjectUnaryOperation(opKind)
ElseIf origArgUnderlyingType.IsDecimalType Then
method = GetHelperForDecimalUnaryOperation(opKind)
End If
If method IsNot Nothing Then
Return ConvertRuntimeHelperToExpressionTree(helperName, argument, Me._factory.MethodInfo(method))
End If
' No standard method
' convert i1, u1 to i4 if needed
Dim needToCastBackToByteOrSByte As Boolean = origArgUnderlyingSpecialType = SpecialType.System_Byte OrElse
origArgUnderlyingSpecialType = SpecialType.System_SByte
Dim origArgTypeIsNullable As Boolean = origArgType.IsNullableType
argument = GenerateCastsForBinaryAndUnaryOperator(argument,
origArgTypeIsNullable,
origArgNotNullableType,
isChecked AndAlso IsIntegralType(origArgUnderlyingType),
needToCastBackToByteOrSByte)
Dim result As BoundExpression = ConvertRuntimeHelperToExpressionTree(helperName, argument)
' convert i4 back to i1, u1
If needToCastBackToByteOrSByte Then
result = Convert(result, If(origArgTypeIsNullable, Me._factory.NullableOf(origArgUnderlyingType), origArgUnderlyingType), isChecked)
End If
' back to nullable
If origArgNotNullableType.IsEnumType Then
result = Convert(result, origArgType, False)
End If
Return result
Case Else
Throw ExceptionUtilities.UnexpectedValue(opKind)
End Select
End Function
Private Function VisitNullableIsTrueOperator(node As BoundNullableIsTrueOperator) As BoundExpression
Debug.Assert(node.Type.IsBooleanType())
Debug.Assert(node.Operand.Type.IsNullableOfBoolean())
' Rewrite into binary conditional expression
Dim operand As BoundExpression = node.Operand
Select Case operand.Kind
Case BoundKind.UserDefinedUnaryOperator
Dim userDefinedOperator = DirectCast(operand, BoundUserDefinedUnaryOperator)
Dim opKind As UnaryOperatorKind = userDefinedOperator.OperatorKind
If (opKind And UnaryOperatorKind.OpMask) <> UnaryOperatorKind.IsTrue OrElse (opKind And UnaryOperatorKind.Lifted) = 0 Then
Exit Select
End If
Dim [call] As BoundCall = userDefinedOperator.Call
' Type of the parameter
Dim udoOperandType As TypeSymbol = userDefinedOperator.Operand.Type
Dim paramSymbol As ParameterSymbol = CreateCoalesceLambdaParameterSymbol(udoOperandType)
Dim lambdaBody As BoundExpression = BuildLambdaBodyForCoalesce(userDefinedOperator.OperatorKind, [call], node.Type, paramSymbol)
Dim coalesceLambda As BoundExpression = BuildLambdaForCoalesceCall(node.Type, paramSymbol, lambdaBody)
Return ConvertRuntimeHelperToExpressionTree("Coalesce", Visit(userDefinedOperator.Operand), Visit(Me._factory.Literal(False)), coalesceLambda)
End Select
If operand.Kind = BoundKind.ObjectCreationExpression Then
Dim objCreation = DirectCast(operand, BoundObjectCreationExpression)
' Nullable<T> has only one ctor with parameters and only that one sets hasValue = true
If objCreation.Arguments.Length = 1 Then
Return VisitInternal(objCreation.Arguments(0))
End If
End If
Return ConvertRuntimeHelperToExpressionTree("Coalesce", Visit(operand), Visit(Me._factory.Literal(False)))
End Function
Private Function BuildLambdaBodyForCoalesce(opKind As UnaryOperatorKind, [call] As BoundCall, resultType As TypeSymbol, lambdaParameter As ParameterSymbol) As BoundExpression
Debug.Assert(resultType.IsBooleanType)
Debug.Assert(lambdaParameter.Type.IsNullableType)
' NOTE: AdjustCallForLiftedOperator will check if [operator] is a valid operator
Return AdjustCallForLiftedOperator(opKind,
[call].Update([call].Method,
Nothing,
Nothing,
ImmutableArray.Create(Of BoundExpression)(
CreateCoalesceLambdaParameter(lambdaParameter)),
Nothing,
True,
[call].Type),
resultType)
End Function
#Region "User Defined Operator Call"
Private Function VisitUserDefinedUnaryOperator(node As BoundUserDefinedUnaryOperator) As BoundExpression
Dim opKind As UnaryOperatorKind = node.OperatorKind And UnaryOperatorKind.OpMask
Dim isLifted As Boolean = (node.OperatorKind And UnaryOperatorKind.Lifted) <> 0
Select Case opKind
Case UnaryOperatorKind.IsTrue,
UnaryOperatorKind.IsFalse
Return RewriteUserDefinedOperator(node)
Case UnaryOperatorKind.Minus,
UnaryOperatorKind.Plus,
UnaryOperatorKind.Not
' See description in DiagnosticsPass.VisitUserDefinedUnaryOperator
Debug.Assert(Not isLifted OrElse Not node.Call.Method.ReturnType.IsNullableType)
Return ConvertRuntimeHelperToExpressionTree(GetUnaryOperatorMethodName(opKind, False),
Visit(node.Operand),
_factory.MethodInfo(node.Call.Method))
Case Else
Throw ExceptionUtilities.UnexpectedValue(opKind)
End Select
End Function
Private Function RewriteUserDefinedOperator(node As BoundUserDefinedUnaryOperator) As BoundExpression
Dim [call] As BoundCall = node.Call
Dim opKind As UnaryOperatorKind = node.OperatorKind
If (opKind And UnaryOperatorKind.Lifted) = 0 Then
Return VisitInternal([call])
End If
Return VisitInternal(AdjustCallForLiftedOperator(opKind, [call], node.Type))
End Function
#End Region
#Region "Utility"
Private Function GetHelperForDecimalUnaryOperation(opKind As UnaryOperatorKind) As MethodSymbol
opKind = opKind And UnaryOperatorKind.OpMask
Dim specialHelper As SpecialMember
Select Case opKind
Case UnaryOperatorKind.Minus,
UnaryOperatorKind.Not
specialHelper = SpecialMember.System_Decimal__NegateDecimal
Case Else
Throw ExceptionUtilities.UnexpectedValue(opKind)
End Select
Return DirectCast(_factory.SpecialMember(specialHelper), MethodSymbol)
End Function
Private Function GetHelperForObjectUnaryOperation(opKind As UnaryOperatorKind) As MethodSymbol
opKind = opKind And UnaryOperatorKind.OpMask
Dim wellKnownHelper As WellKnownMember
Select Case opKind
Case UnaryOperatorKind.Plus
wellKnownHelper = WellKnownMember.Microsoft_VisualBasic_CompilerServices_Operators__PlusObjectObject
Case UnaryOperatorKind.Minus
wellKnownHelper = WellKnownMember.Microsoft_VisualBasic_CompilerServices_Operators__NegateObjectObject
Case UnaryOperatorKind.Not
wellKnownHelper = WellKnownMember.Microsoft_VisualBasic_CompilerServices_Operators__NotObjectObject
Case Else
Throw ExceptionUtilities.UnexpectedValue(opKind)
End Select
Return Me._factory.WellKnownMember(Of MethodSymbol)(wellKnownHelper)
End Function
''' <summary>
''' Get the name of the expression tree function for a particular unary operator
''' </summary>
Private Shared Function GetUnaryOperatorMethodName(opKind As UnaryOperatorKind, isChecked As Boolean) As String
Select Case (opKind And UnaryOperatorKind.OpMask)
Case UnaryOperatorKind.Not
Return "Not"
Case UnaryOperatorKind.Plus
Return "UnaryPlus"
Case UnaryOperatorKind.Minus
Return If(isChecked, "NegateChecked", "Negate")
Case Else
Throw ExceptionUtilities.UnexpectedValue(opKind)
End Select
End Function
#End Region
End Class
End Namespace
|
MatthieuMEZIL/roslyn
|
src/Compilers/VisualBasic/Portable/Lowering/ExpressionLambdaRewriter/ExpressionLambdaRewriter_UnaryOperator.vb
|
Visual Basic
|
apache-2.0
| 12,339
|
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports Microsoft.CodeAnalysis
Imports Microsoft.CodeAnalysis.Test.Utilities
Imports Roslyn.Test.Utilities
Namespace Microsoft.CodeAnalysis.VisualBasic.UnitTests
Public Class CodeGenInterfaceImplementationTests
Inherits BasicTestBase
<WorkItem(540794, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/540794")>
<Fact>
Public Sub TestInterfaceMembersSignature()
Dim source =
<compilation>
<file name="a.vb">
Interface IFace
Sub SubRoutine()
Function Func() As Integer
Property Prop As Integer
End Interface
</file>
</compilation>
Dim verifier = CompileAndVerify(source, expectedSignatures:=
{
Signature("IFace", "SubRoutine", ".method public newslot strict abstract virtual instance System.Void SubRoutine() cil managed"),
Signature("IFace", "Func", ".method public newslot strict abstract virtual instance System.Int32 Func() cil managed"),
Signature("IFace", "get_Prop", ".method public newslot strict specialname abstract virtual instance System.Int32 get_Prop() cil managed"),
Signature("IFace", "set_Prop", ".method public newslot strict specialname abstract virtual instance System.Void set_Prop(System.Int32 Value) cil managed"),
Signature("IFace", "Prop", ".property readwrite instance System.Int32 Prop")
})
verifier.VerifyDiagnostics()
End Sub
<WorkItem(540794, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/540794")>
<WorkItem(540805, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/540805")>
<WorkItem(540861, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/540861")>
<WorkItem(540807, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/540807")>
<Fact>
Public Sub TestNestedInterface()
Dim source =
<compilation>
<file name="a.vb">
Class Class2
Implements Class2.InterfaceDerived
Interface InterfaceDerived
Inherits Class2.InterfaceBase
Sub AbcDef()
End Interface
Public Interface InterfaceBase
Property Bar As Integer
End Interface
Public Property Bar As Integer Implements InterfaceDerived.Bar
Get
Return 1
End Get
Set(value As Integer)
End Set
End Property
Public Sub AbcDef() Implements InterfaceDerived.AbcDef
End Sub
End Class
Class Class1
Implements Class1.Interface1
Public Interface Interface1
Sub Goo()
End Interface
Public Sub Goo() Implements Interface1.Goo
End Sub
End Class
</file>
</compilation>
Dim verifier = CompileAndVerify(source, expectedSignatures:=
{
Signature("Class2+InterfaceBase", "get_Bar", ".method public newslot strict specialname abstract virtual instance System.Int32 get_Bar() cil managed"),
Signature("Class2+InterfaceBase", "set_Bar", ".method public newslot strict specialname abstract virtual instance System.Void set_Bar(System.Int32 Value) cil managed"),
Signature("Class2+InterfaceBase", "Bar", ".property readwrite instance System.Int32 Bar"),
Signature("Class2+InterfaceDerived", "AbcDef", ".method public newslot strict abstract virtual instance System.Void AbcDef() cil managed"),
Signature("Class2", "get_Bar", ".method public newslot strict specialname virtual final instance System.Int32 get_Bar() cil managed"),
Signature("Class2", "set_Bar", ".method public newslot strict specialname virtual final instance System.Void set_Bar(System.Int32 value) cil managed"),
Signature("Class2", "AbcDef", ".method public newslot strict virtual final instance System.Void AbcDef() cil managed"),
Signature("Class2", "Bar", ".property readwrite instance System.Int32 Bar"),
Signature("Class1+Interface1", "Goo", ".method public newslot strict abstract virtual instance System.Void Goo() cil managed"),
Signature("Class1", "Goo", ".method public newslot strict virtual final instance System.Void Goo() cil managed")
})
verifier.VerifyDiagnostics()
End Sub
<WorkItem(543426, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543426")>
<Fact()>
Public Sub TestExplicitlyImplementInterfaceNestedInGenericType()
Dim source =
<compilation>
<file name="a.vb">
Class Outer(Of T)
Interface IInner
Sub M(t As T)
End Interface
Class Inner
Implements IInner
Private Sub M(t As T) Implements Outer(Of T).IInner.M
End Sub
End Class
End Class
</file>
</compilation>
Dim verifier = CompileAndVerify(source, expectedSignatures:=
{
Signature("Outer`1+IInner", "M", ".method public newslot strict abstract virtual instance System.Void M(T t) cil managed"),
Signature("Outer`1+Inner", "M", ".method private newslot strict virtual final instance System.Void M(T t) cil managed")
})
verifier.VerifyDiagnostics()
End Sub
End Class
End Namespace
|
mmitche/roslyn
|
src/Compilers/VisualBasic/Test/Emit/CodeGen/CodeGenInterfaceImplementation.vb
|
Visual Basic
|
apache-2.0
| 5,396
|
Imports System.Diagnostics
Imports Nini.Config
Public Class MainForm
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents loggingGroup As System.Windows.Forms.GroupBox
Friend WithEvents userNameText As System.Windows.Forms.TextBox
Friend WithEvents userNameLabel As System.Windows.Forms.Label
Friend WithEvents saveIniButton As System.Windows.Forms.Button
Friend WithEvents viewIniButton As System.Windows.Forms.Button
Friend WithEvents maxFileSizeText As System.Windows.Forms.TextBox
Friend WithEvents label1 As System.Windows.Forms.Label
Friend WithEvents logFileNameText As System.Windows.Forms.TextBox
Friend WithEvents logFileNameLabel As System.Windows.Forms.Label
Friend WithEvents userEmailText As System.Windows.Forms.TextBox
Friend WithEvents userEmailLabel As System.Windows.Forms.Label
Friend WithEvents closeButton As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.loggingGroup = New System.Windows.Forms.GroupBox()
Me.userNameText = New System.Windows.Forms.TextBox()
Me.userNameLabel = New System.Windows.Forms.Label()
Me.saveIniButton = New System.Windows.Forms.Button()
Me.viewIniButton = New System.Windows.Forms.Button()
Me.maxFileSizeText = New System.Windows.Forms.TextBox()
Me.label1 = New System.Windows.Forms.Label()
Me.logFileNameText = New System.Windows.Forms.TextBox()
Me.logFileNameLabel = New System.Windows.Forms.Label()
Me.userEmailText = New System.Windows.Forms.TextBox()
Me.userEmailLabel = New System.Windows.Forms.Label()
Me.closeButton = New System.Windows.Forms.Button()
Me.loggingGroup.SuspendLayout()
Me.SuspendLayout()
'
'loggingGroup
'
Me.loggingGroup.Controls.AddRange(New System.Windows.Forms.Control() {Me.closeButton, Me.userNameText, Me.userNameLabel, Me.saveIniButton, Me.viewIniButton, Me.maxFileSizeText, Me.label1, Me.logFileNameText, Me.logFileNameLabel, Me.userEmailText, Me.userEmailLabel})
Me.loggingGroup.Location = New System.Drawing.Point(8, 16)
Me.loggingGroup.Name = "loggingGroup"
Me.loggingGroup.Size = New System.Drawing.Size(440, 200)
Me.loggingGroup.TabIndex = 3
Me.loggingGroup.TabStop = False
Me.loggingGroup.Text = "IConfigs (Sections) in INI file"
'
'userNameText
'
Me.userNameText.Location = New System.Drawing.Point(128, 120)
Me.userNameText.Name = "userNameText"
Me.userNameText.Size = New System.Drawing.Size(152, 20)
Me.userNameText.TabIndex = 12
Me.userNameText.Text = ""
'
'userNameLabel
'
Me.userNameLabel.Location = New System.Drawing.Point(16, 120)
Me.userNameLabel.Name = "userNameLabel"
Me.userNameLabel.Size = New System.Drawing.Size(88, 16)
Me.userNameLabel.TabIndex = 11
Me.userNameLabel.Text = "User Name"
'
'saveIniButton
'
Me.saveIniButton.Location = New System.Drawing.Point(312, 32)
Me.saveIniButton.Name = "saveIniButton"
Me.saveIniButton.Size = New System.Drawing.Size(112, 23)
Me.saveIniButton.TabIndex = 8
Me.saveIniButton.Text = "Save Changes"
'
'viewIniButton
'
Me.viewIniButton.Location = New System.Drawing.Point(312, 72)
Me.viewIniButton.Name = "viewIniButton"
Me.viewIniButton.Size = New System.Drawing.Size(112, 23)
Me.viewIniButton.TabIndex = 7
Me.viewIniButton.Text = "View INI File"
'
'maxFileSizeText
'
Me.maxFileSizeText.Location = New System.Drawing.Point(128, 72)
Me.maxFileSizeText.Name = "maxFileSizeText"
Me.maxFileSizeText.Size = New System.Drawing.Size(152, 20)
Me.maxFileSizeText.TabIndex = 4
Me.maxFileSizeText.Text = ""
'
'label1
'
Me.label1.Location = New System.Drawing.Point(16, 72)
Me.label1.Name = "label1"
Me.label1.Size = New System.Drawing.Size(104, 16)
Me.label1.TabIndex = 3
Me.label1.Text = "Log File Max Size:"
'
'logFileNameText
'
Me.logFileNameText.Location = New System.Drawing.Point(128, 32)
Me.logFileNameText.Name = "logFileNameText"
Me.logFileNameText.Size = New System.Drawing.Size(152, 20)
Me.logFileNameText.TabIndex = 2
Me.logFileNameText.Text = ""
'
'logFileNameLabel
'
Me.logFileNameLabel.Location = New System.Drawing.Point(16, 32)
Me.logFileNameLabel.Name = "logFileNameLabel"
Me.logFileNameLabel.Size = New System.Drawing.Size(88, 16)
Me.logFileNameLabel.TabIndex = 1
Me.logFileNameLabel.Text = "Log File Name:"
'
'userEmailText
'
Me.userEmailText.Location = New System.Drawing.Point(128, 160)
Me.userEmailText.Name = "userEmailText"
Me.userEmailText.Size = New System.Drawing.Size(152, 20)
Me.userEmailText.TabIndex = 10
Me.userEmailText.Text = ""
'
'userEmailLabel
'
Me.userEmailLabel.Location = New System.Drawing.Point(16, 160)
Me.userEmailLabel.Name = "userEmailLabel"
Me.userEmailLabel.Size = New System.Drawing.Size(88, 16)
Me.userEmailLabel.TabIndex = 9
Me.userEmailLabel.Text = "User Email"
'
'closeButton
'
Me.closeButton.Location = New System.Drawing.Point(312, 120)
Me.closeButton.Name = "closeButton"
Me.closeButton.Size = New System.Drawing.Size(112, 23)
Me.closeButton.TabIndex = 13
Me.closeButton.Text = "Close"
'
'MainForm
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(456, 237)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.loggingGroup})
Me.Name = "MainForm"
Me.Text = "Nini VB.NET BasicApp"
Me.loggingGroup.ResumeLayout(False)
Me.ResumeLayout(False)
End Sub
#End Region
Private source As IniConfigSource
' Constructor
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
LoadConfigs()
End Sub
' Loads all configuration values into the UI controls.
Public Sub LoadConfigs()
' Load the configuration source file
source = New IniConfigSource("..\BasicApp.ini")
' Set the config to the Logging section of the INI file.
Dim config As IConfig
config = source.Configs("Logging")
' Load up some normal configuration values
logFileNameText.Text = config.Get("File Name")
maxFileSizeText.Text = config.Get("MaxFileSize")
userNameText.Text = source.Configs("User").Get("Name")
userEmailText.Text = source.Configs("User").Get("Email")
End Sub
' Handles saving the file.
Private Sub saveIniButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles saveIniButton.Click
source.Configs("Logging").Set("File Name", logFileNameText.Text)
source.Configs("Logging").Set("MaxFileSize", maxFileSizeText.Text)
source.Configs("User").Set("Name", userNameText.Text)
source.Configs("User").Set("Email", userEmailText.Text)
' Save the INI file
source.Save()
End Sub
' Loads up the INI file in whatever editor is the default.
Private Sub viewIniButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles viewIniButton.Click
Process.Start("notepad.exe", "..\BasicApp.ini")
End Sub
' Handles the close button event.
Private Sub closeButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles closeButton.Click
Me.Close()
End Sub
End Class
|
roblillack/monoberry
|
lib/nini/Examples/VbExamples/BasicApp/MainForm.vb
|
Visual Basic
|
mit
| 7,611
|
Option Infer On
Imports System
Imports System.Runtime.InteropServices
Namespace Examples
Friend Class Program
<STAThread>
Shared Sub Main(ByVal args() As String)
Dim application As SolidEdgeFramework.Application = Nothing
Dim assemblyDocument As SolidEdgeAssembly.AssemblyDocument = Nothing
Dim relations3d As SolidEdgeAssembly.Relations3d = Nothing
Dim axialRelation3d As SolidEdgeAssembly.AxialRelation3d = Nothing
Try
' See "Handling 'Application is Busy' and 'Call was Rejected By Callee' errors" topic.
OleMessageFilter.Register()
' Attempt to connect to a running instance of Solid Edge.
application = DirectCast(Marshal.GetActiveObject("SolidEdge.Application"), SolidEdgeFramework.Application)
assemblyDocument = TryCast(application.ActiveDocument, SolidEdgeAssembly.AssemblyDocument)
If assemblyDocument IsNot Nothing Then
relations3d = assemblyDocument.Relations3d
For i As Integer = 1 To relations3d.Count
axialRelation3d = TryCast(relations3d.Item(i), SolidEdgeAssembly.AxialRelation3d)
If axialRelation3d IsNot Nothing Then
Dim occurrence1 = axialRelation3d.Occurrence1
End If
Next i
End If
Catch ex As System.Exception
Console.WriteLine(ex)
Finally
OleMessageFilter.Unregister()
End Try
End Sub
End Class
End Namespace
|
SolidEdgeCommunity/docs
|
docfx_project/snippets/SolidEdgeAssembly.AxialRelation3d.Occurrence1.vb
|
Visual Basic
|
mit
| 1,673
|
Imports SistFoncreagro.BussinessEntities
Imports SistFoncreagro.DataAccess
Public Class EspecieAnimalBL : Implements IEspecieAnimalBL
Dim factoryrepository As IEspecieAnimalRepository
Public Sub New()
factoryrepository = New EspecieAnimalRepository
End Sub
Public Function GetAllFromEspecieAnimal() As System.Collections.Generic.List(Of BussinessEntities.EspecieAnimal) Implements IEspecieAnimalBL.GetAllFromEspecieAnimal
Return factoryrepository.GetAllFromEspecieAnimal
End Function
Public Function GetEspecieAnimalByIdRaza(ByVal idRaza As Integer) As BussinessEntities.EspecieAnimal Implements IEspecieAnimalBL.GetEspecieAnimalByIdRaza
Return factoryrepository.GetEspecieAnimalByIdRaza(idRaza)
End Function
End Class
|
crackper/SistFoncreagro
|
SistFoncreagro.BussinesLogic/EspecieAnimalBL.vb
|
Visual Basic
|
mit
| 777
|
'------------------------------------------------------------------------------
' <auto-generated>
' This code was generated by a tool.
'
' Changes to this file may cause incorrect behavior and will be lost if
' the code is regenerated.
' </auto-generated>
'------------------------------------------------------------------------------
Option Strict On
Option Explicit On
Namespace My
<Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0"), _
Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Partial Friend NotInheritable Class MySettings
Inherits Global.System.Configuration.ApplicationSettingsBase
Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings), MySettings)
#Region "My.Settings Auto-Save Functionality"
#If _MyType = "WindowsForms" Then
Private Shared addedHandler As Boolean
Private Shared addedHandlerLockObject As New Object
<Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs)
If My.Application.SaveMySettingsOnExit Then
My.Settings.Save()
End If
End Sub
#End If
#End Region
Public Shared ReadOnly Property [Default]() As MySettings
Get
#If _MyType = "WindowsForms" Then
If Not addedHandler Then
SyncLock addedHandlerLockObject
If Not addedHandler Then
AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings
addedHandler = True
End If
End SyncLock
End If
#End If
Return defaultInstance
End Get
End Property
End Class
End Namespace
Namespace My
<Global.Microsoft.VisualBasic.HideModuleNameAttribute(), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute()> _
Friend Module MySettingsProperty
<Global.System.ComponentModel.Design.HelpKeywordAttribute("My.Settings")> _
Friend ReadOnly Property Settings() As Global.Arrays_Homework.My.MySettings
Get
Return Global.Arrays_Homework.My.MySettings.Default
End Get
End Property
End Module
End Namespace
|
dushka-dragoeva/Telerik
|
Homeworks/Web and UI Technologies/JavaScriptFundament/Arrays-Homework/My Project/Settings.Designer.vb
|
Visual Basic
|
mit
| 2,897
|
'---------------------------------------------------------------------------------------
' Projet : SCG
' Module : oSCG [Module de classe]
' Version : 1.03
' Création : Le jeudi 26 juin 2008
' Auteur : P.B. [Philben] - <a href="http://www.developpez.net" target="_blank">http://www.developpez.net</a> (forum : Access -> Contribuez)
' Objet : Conversion de coordonnées planes ou géographiques de systèmes géodésiques
' Références : <a href="http://www.IGN.fr" target="_blank">http://www.IGN.fr</a> (Institut Géographique National - France)
' <a href="http://www.NGI.be" target="_blank">http://www.NGI.be</a> (Institut Géographique National - Belgique)
' Exemple : - Conversion de Lambert II étendu (X et Y en mètres) vers WGS84 (Lon, Lat)
' Dim oConv as oSCG
' Set oConv = New oSCG
' oConv.TypeConversion NTF_Lambert_II_Etendu, WGS84_Geo
' If Not oConv.IsErreur Then
' oConv.CalculSCG 647462, 2468321
' Debug.Print "Longitude : " & oConv.RadianToDegreDec(oConv.X)
' Debug.Print "Latitude : " & oConv.RadianToDegreDec(oConv.Y)
' endif
' Set oConv = Nothing
' Tests : - 3 fonctions permettent de vérifier les algorithmes, les conversions
' entres systèmes et les conversions entres les unités d'angle :
' Dim oConv as oSCG
' Set oConv = New oSCG
' oConv.TestAlgos
' oConv.TestAngles
' oConv.TestConversions
' Set oConv = Nothing
' -> Les Résultats sont affichés dans la fenêtre d'exécution de VBE (Debug.Print)
' Remarque : Seules certaines conversions sont vérifiées et sur un point seulement
' => cette classe ne doit être utilisée que dans un but ludo-éducatif
' v1.01 : - Désactivation des conversions pour la belgique car bug persistant...
' - Ajout test alg54 (bug corrigé)
' - Ajout de tests de conversion
' v1.02 : - Correction d'un bug dans AngleDMSToString pour les coordonnées négatives
' v1.03 : - Réactivation des conversions pour la Belgique (bugs corrigés)
' - Modification de quelques noms de fonction, enum, etc.
' - Correction de quelques bugs mineurs
' - Ajout fonction DistanceKm qui calcule la distance en km entre 2 Lon/Lat
'---------------------------------------------------------------------------------------
Option Compare Database
Option Explicit
'A vrai pour tester des conversions et/ou les algorithmes (TestAlgos)
#Const CCTEST = True
#If CCTEST Then
Private Enum eUnites
gr
rad
dms
m
DD
End Enum
Private Type tResults
dX As Double
dY As Double
sX As String
sY As String
End Type
#End If
'Enumération des projections et systèmes à convertir
Public Enum eSCG
BD72_Lambert72 'Projection Lambert 72 - Ellipsoïde Hayford 1924 - Belgique
BD72_Geo
ETRS89_Lambert08 'Projection Lambert 2008 - Ellipsoïde GRS80 - Belgique
ETRS89_Geo 'SG ETRS89 - Ellipsoïde GRS80 - Belgique
ED50_Geo 'SG European Datum 1950 - Ellipsoïde Hayford 1909
NTF_Lambert_I 'Projection Lambert I - Ellipsoïde NTF : Clarke 1880 - France
NTF_Lambert_II 'Projection Lambert II - Ellipsoïde NTF : Clarke 1880 - France
NTF_Lambert_III 'Projection Lambert III - Ellipsoïde NTF : Clarke 1880 - France
NTF_Lambert_IV 'Projection Lambert IV - Ellipsoïde NTF : Clarke 1880 - France
NTF_Lambert_II_Etendu 'Projection Lambert pour la France
NTF_Paris_Geo 'SG NTF : Nouvelle triangulation de la France (méridien Paris)
RGF93_Geo 'SG Réseau géodésique français - Ellipsoïde RGF : IAG GRS 80
RGF93_Lambert_93 'Projection Lambert 93 - RGF : Réseau géodésique Français 1993
WGS84_Geo 'SG World Geodetic System 1984
End Enum
'Transformations définies dans le programme
Private Enum eTypeTrans
NTFtoRGF93
NTFtoED50
NTFtoWGS84
RGF93toNTF
RGF93toED50
RGF93toWGS84
ED50toNTF
ED50toRGF93
ED50toWGS84
WGS84toNTF
WGS84toRGF93
WGS84toED50
ETRS89toBD72
BD72toETRS89
End Enum
'colonnes du tableau des conversions autorisées
'Abréviations :
' - PLA = Coordonnées planes d'une projection (X et Y en mètre) - Lambert seulement ici
' - GEO = Coordonnées géographiques d'un système géodésique (lambda et phi en radian)
' - CAR = Coordonnées cartésiennes d'un système géodésique
' - lambda = longitude en radian
' - phi = latitude en radian
'Schémas de conversion :
' 1) Passage de coordonnées cartographiques planes d'une projection d'un système
' géodésique vers les coordonnées d'une projection d'un autre système géodésique
' - PLA_1 -> GEO_1 -> CAR_1 -> CAR_2 -> GEO_2 -> PLA_2
' - Entrée/Sortie (E/S) : X_1 et Y_1 -> X_2 et Y_2 (en mètres)
' - Exemple : Lambert_I (NTF) vers Lambert93 (RGF93)
' 2) Passage de coordonnées cartographiques planes d'une projection d'un système
' géodésique vers les coordonnées géographiques d'un autre système géodésique
' - PLA_1 -> GEO_1 -> CAR_1 -> CAR_2 -> GEO_2
' - E/S : X_1 et Y_1 (en mètres) -> lambda_2 et phi_2 (angles en radians avec phi = latitude et lambda = longitude)
' - Exemple : Lambert_I vers WGS84 (système utilisé par les GPS)
' 3) Passage de coordonnées cartographiques planes d'une projection vers coordonnées
' cartographiques planes d'une autre projection d'un même système géodésique
' - PLA_1 -> GEO -> PLA_2
' - E/S : X_1 et Y_1 -> X_2 et Y_2 (en mètres)
' - Exemple : Lambert_I vers Lambert_II_étendu
' 4) Passage de coordonnées géographiques d'un système géodésique vers
' les coordonnées cartographiques planes d'une projection d'un autre système géodésique
' - GEO_1 -> CAR_1 -> CAR_2 -> GEO_2 -> PLA_2
' - E/S : lambda_1 et phi_1 (en radian) -> X_2 et Y_2 (en mètres)
' - Exemple : WGS84 vers Lambert93
' 5) Passage de coordonnées géographiques d'un système géodésique vers
' les coordonnées géographiques d'un autre système géodésique
' - GEO_1 -> CAR_1 -> CAR_2 -> GEO_2
' - E/S : lambda_1 et phi_1 -> lambda_2 et phi_2 (en radian)
' - Exemple : WGS84 vers ED50
'
'Les étapes possibles sont donc :
' 1) PLA -> GEO Fonction Alg04 - Passage d'une proj. Lambert vers coordonnées géographiques
' 2) GEO1 -> GEO2 Fonction Alg09 - Passage de coordonnées géographiques à des coord. cartésiennes
' Fonction Alg13 - Transformation d'un système géodésique à l'autre par coord. cartésiennes
' Fonction Alg12 - Passage de coordonnées cartésiennes à des coord. géographiques
' 3) GEO -> PLA Fonction Alg03 - Passage de coord. géographiques en projection conique conforme de Lambert
' Remarque :
' - il est possible de définir d'autres transformations en utilisant un système
' comme pivot si on ne connait pas la transformation directe
' CAR_1 -> CAR_1bis (PIVOT) -> CAR_2
Private Enum eSchema
eInitial = 0 'Système initial : Proj, Géo
eFinal 'Système final: Géo, Proj
bPLAtoGEO 'Etape 1
eTypeTrans 'Type de tranformation pour bGEOtoGEO ou NULL si aucun
bGEOtoPLA 'Etape 3
End Enum
'Paramètres de l'ellipsoïde du système initial et final
Private Type tEllipsoide
da As Double '1/2 grand axe de l'ellipsoïde (mètre)
db As Double '1/2 petit axe de l'ellipsoïde (mètre) - Non utilisé directement
df As Double 'Facteur d'aplatissement - Non utilisé directement
de As Double 'Première excentricité de l'ellipsoïde de référence
dh As Double 'Hauteur au dessus de l'ellipsoïde (en mètre)
End Type
'Paramètres de la projection
Private Type tProjection
eType As eSCG
dN As Double 'Exposant de la projection
dc As Double 'Constante de la projection
dXs As Double 'Coordonnées en projection du pôle
dYs As Double
dphi0 As Double 'Latitude du méridien d'origine (radian)
dlambda0 As Double 'Longitude du méridien d'origine (ou central ?) (radian)
dphi1 As Double 'Longitude du 1er parallèle automécoïque (radian)
dphi2 As Double 'Longitude du 2ème parallèle automécoïque (radian)
tEl As tEllipsoide 'Paramètres de l'ellipsoïde associée
End Type
'Paramètres de la transformation entre systèmes géo. cartésiens
Private Type tTransformation
dTx As Double
dTy As Double
dTz As Double
dRx As Double
dRy As Double
dRz As Double
dFacteurEchelle As Double
End Type
'Paramètres du Système de Conversion Géodésique
Private Type tSCG
avProcess As Variant
tInitial As tProjection
tTrans As tTransformation
tFinal As tProjection
End Type
Private Type t_XYZ
dX As Double
dY As Double
dZ As Double
End Type
Private gdpi As Double
Private gbInit As Boolean
Private gsErreur As String
Private gtXYZ As t_XYZ
Private gtSCG As tSCG
Private Sub class_initialize()
gdpi = 4 * Atn(1) 'Calcul de pi
End Sub
'Sélection du type de conversion
Public Sub TypeConversion(ByVal eDe As eSCG, ByVal eVers As eSCG)
Dim tTmpSCG As tSCG
Dim tTmpXYZ As t_XYZ
If eDe <> eVers Then
With tTmpSCG
'Récupère le processus de conversion
.avProcess = SetConversion(eDe, eVers)
'Conversion possible
If Not IsNull(.avProcess) Then
'Définir les systèmes
SetProjection .tInitial, eDe
SetProjection .tFinal, eVers
'Définir l'éventuelle transformation
If Not IsNull(.avProcess(eSchema.eTypeTrans)) Then
SetTransformation .tTrans, .avProcess(eSchema.eTypeTrans)
End If
gsErreur = vbNullString
gbInit = True
Else
gsErreur = "Conversion non définie..."
gbInit = False
End If
End With
Else
gsErreur = "Pas de conversion nécessaire..."
gbInit = False
End If
gtSCG = tTmpSCG
gtXYZ = tTmpXYZ
End Sub
'Conversion à partir des mètres ou des radians selon le système de conversion
Public Sub CalculSCG(ByVal dX As Double, dY As Double)
Dim tXYZ As t_XYZ
With tXYZ
If gbInit Then
'Si passage de coordonnées planes vers geographiques
If gtSCG.avProcess(eSchema.bPLAtoGEO) Then
tXYZ = alg04(dX, dY, gtSCG.tInitial)
Else
'dx : Tenir compte du méridien d'origine
.dX = dX + gtSCG.tInitial.dlambda0
.dY = dY
End If
'Si passage de GEO1 vers GEO2
If Not IsNull(gtSCG.avProcess(eSchema.eTypeTrans)) Then
tXYZ = alg09(.dX, .dY, gtSCG.tInitial.tEl) 'GEO1 -> CAR1
tXYZ = alg13(tXYZ, gtSCG.tTrans) 'CAR1 -> CAR2
tXYZ = alg12(tXYZ, gtSCG.tFinal.tEl) 'CAR2 -> GEO2
End If
'Si passage de GEO vers PLA
If gtSCG.avProcess(eSchema.bGEOtoPLA) Then
tXYZ = alg03(.dX, .dY, gtSCG.tFinal)
Else
'dx : Tenir compte du méridien d'origine du système final
.dX = .dX - gtSCG.tFinal.dlambda0
End If
Else
gsErreur = "Système de conversion non initialisé..."
End If
gtXYZ.dX = .dX
gtXYZ.dY = .dY
gtXYZ.dZ = .dZ
End With
End Sub
'Retourne le résultat : X en mètre ou en radian (longitude)
Public Property Get X() As Double
X = gtXYZ.dX
End Property
'Retourne le résultat : Y en mètre ou en radian (latitude)
Public Property Get Y() As Double
Y = gtXYZ.dY
End Property
Public Property Get pi() As Double
pi = gdpi
End Property
Public Property Get IsErreur() As Boolean
If Len(gsErreur) Then IsErreur = True
End Property
Public Property Get Erreur() As String
Erreur = gsErreur
End Property
'alg01 - Appel par alg03 et alg54 - Calcul de la latitude isométrique à partir de la latitude
Private Function alg01(ByVal dphi As Double, ByVal de As Double) As Double
Dim dTmp As Double
dTmp = de * Sin(dphi)
alg01 = Log(Tan(gdpi / 4 + dphi / 2) * ((1 - dTmp) / (1 + dTmp)) ^ (de / 2))
End Function
'alg02 - Appel par algo04 - Calcul la latitude à partir de la latitude isométrique
Private Function alg02(ByVal dphiIso As Double, ByVal de As Double, _
Optional ByVal depsilon As Double = 0.0000000001) As Double
Dim dCurphi As Double, dLastphi As Double
dCurphi = 2 * Atn(Exp(dphiIso)) - gdpi / 2
Do
dLastphi = dCurphi
dCurphi = 2 * Atn(((1 + de * Sin(dLastphi)) / (1 - de * Sin(dLastphi))) ^ (de / 2) * Exp(dphiIso)) - gdpi / 2
Loop Until Abs(dCurphi - dLastphi) < depsilon
alg02 = dCurphi
End Function
'alg03 - Transformation de coordonnées géographiques en projection conique conforme de Lambert
'Utilise la variable globale gtSCG pour les constantes de la projection finale
Private Function alg03(ByVal dlambda As Double, ByVal dphi As Double, _
ByRef tProj As tProjection) As t_XYZ
Dim dphiIso As Double, dTmp1 As Double, dtheta As Double
With tProj
dphiIso = alg01(dphi, .tEl.de)
dTmp1 = .dc * Exp(-.dN * dphiIso)
dtheta = .dN * (dlambda - .dlambda0)
alg03.dX = .dXs + dTmp1 * Sin(dtheta)
alg03.dY = .dYs - dTmp1 * Cos(dtheta)
End With
End Function
'alg04 - Passage d'une projection Lambert vers des coordonnées géographiques
'Utilise la variable globale gtSCG pour les constantes de la projection initiale
Private Function alg04(ByVal dX As Double, ByVal dY As Double, _
ByRef tProj As tProjection, _
Optional ByVal depsilon As Double = 0.0000000001) As t_XYZ
Dim dR As Double, dgamma As Double, dphiIso As Double
With tProj
dR = Sqr((dX - .dXs) ^ 2 + (dY - .dYs) ^ 2)
dgamma = Atn((dX - .dXs) / (.dYs - dY))
dphiIso = -1 / .dN * Log(Abs(dR / .dc))
alg04.dX = .dlambda0 + dgamma / .dN
alg04.dY = alg02(dphiIso, .tEl.de)
End With
End Function
'alg21 - Appel par algo09 et alg54
Private Function alg21(ByVal dphi As Double, ByVal da As Double, ByVal de As Double) As Double
alg21 = da / Sqr(1 - de ^ 2 * Sin(dphi) ^ 2)
End Function
'alg09 - Passage de coordonnées géographiques à cartésiennes
'Utilise la variable globale gtSCG pour l'ellipsoïde initiale
Private Function alg09(ByVal dlambda As Double, ByVal dphi As Double, _
ByRef tEl As tEllipsoide) As t_XYZ
Dim dN As Double
dlambda = dlambda
With tEl
dN = alg21(dphi, .da, .de)
alg09.dX = (dN + .dh) * Cos(dphi) * Cos(dlambda)
alg09.dY = (dN + .dh) * Cos(dphi) * Sin(dlambda)
alg09.dZ = (dN * (1 - .de ^ 2) + .dh) * Sin(dphi)
End With
End Function
'alg12 - Passage de coordonnées cartésiennes à géographiques
'Utilise la variable globale gtSCG pour l'ellipsoïde finale
Private Function alg12(ByRef tXYZ As t_XYZ, _
ByRef tEl As tEllipsoide, _
Optional ByVal depsilon As Double = 0.0000000001) As t_XYZ
Dim dCurphi As Double, dLastphi As Double, dTmp1 As Double, dTmp2 As Double
Dim deCarre As Double, da As Double
With tEl
deCarre = .de ^ 2
da = .da
End With
With tXYZ
alg12.dX = Atn(.dY / .dX)
dTmp1 = Sqr(.dX ^ 2 + .dY ^ 2)
dTmp2 = da * deCarre
dCurphi = Atn(.dZ / (dTmp1 * (1 - (dTmp2 / Sqr(.dX ^ 2 + .dY ^ 2 + .dZ ^ 2)))))
Do
dLastphi = dCurphi
dCurphi = Atn(.dZ / (dTmp1 * (1 - (dTmp2 * Cos(dLastphi) / _
(dTmp1 * Sqr(1 - deCarre * Sin(dLastphi) ^ 2))))))
Loop Until Abs(dCurphi - dLastphi) < depsilon
alg12.dY = dCurphi
alg12.dZ = dTmp1 / Cos(dCurphi) - (da / Sqr(1 - deCarre * Sin(dLastphi) ^ 2))
End With
End Function
'alg13 - Passage d'un SG à l'autre par coordonnées cartésiennes
'Utilise la variable globale gtSCG pour la transformation
'Modif algo : passage d'un facteur d'échelle additionné de 1
Private Function alg13(ByRef tXYZ As t_XYZ, ByRef tTrans As tTransformation) As t_XYZ
With tTrans
alg13.dX = .dTx + tXYZ.dX * .dFacteurEchelle + tXYZ.dZ * .dRy - tXYZ.dY * .dRz
alg13.dY = .dTy + tXYZ.dY * .dFacteurEchelle + tXYZ.dX * .dRz - tXYZ.dZ * .dRx
alg13.dZ = .dTz + tXYZ.dZ * .dFacteurEchelle + tXYZ.dY * .dRx - tXYZ.dX * .dRy
End With
End Function
'alg54 - Permet de calculer les constantes d'une projection conique conforme dans le cas sécant
Private Sub alg54(ByRef tProj As tProjection, ByVal dX0 As Double, ByVal dY0 As Double)
Dim dTmp1 As Double, dLatIso1 As Double
With tProj
dTmp1 = alg21(.dphi1, .tEl.da, .tEl.de) * Cos(.dphi1)
dLatIso1 = alg01(.dphi1, .tEl.de)
.dN = Log(alg21(.dphi2, .tEl.da, .tEl.de) * Cos(.dphi2) / dTmp1) / _
(dLatIso1 - alg01(.dphi2, .tEl.de))
.dc = (dTmp1 / .dN) * Exp(.dN * dLatIso1)
.dXs = dX0
If Arrondi(.dphi0, 9) <> Arrondi(gdpi / 2, 9) Then
.dYs = dY0 + .dc * Exp(-.dN * alg01(.dphi0, .tEl.de))
Else
.dYs = dY0
End If
End With
End Sub
Private Sub SetProjection(ByRef tProj As tProjection, ByVal eType As eSCG)
With tProj
.eType = eType
'Paramètres du Système géodésique
.tEl.dh = 100 'Hauteur au dessus de l'ellipsoïde, valeur par défaut
Select Case eType
Case eSCG.NTF_Lambert_I, _
eSCG.NTF_Lambert_II, _
eSCG.NTF_Lambert_III, _
eSCG.NTF_Lambert_IV, _
eSCG.NTF_Lambert_II_Etendu, _
eSCG.NTF_Paris_Geo 'Ellipsoïde de Clarke 1880
.dlambda0 = DMSToRadian(2, 20, 14.025) 'Paris = 2°20'14,025 E Greenwich
.tEl.da = 6378249.2
.tEl.db = 6356515#
.tEl.de = CalculPremiereExcentricite(.tEl.da, .tEl.db) '0.08248325676
Case eSCG.RGF93_Lambert_93, eSCG.RGF93_Geo 'Ellipsoïde IAG_GRS80
.dlambda0 = DegreDecToRadian(3)
.tEl.da = 6378137
.tEl.df = 1 / 298.257222101
.tEl.db = CalculDemiPetitAxe(.tEl.da, .tEl.df)
.tEl.de = CalculPremiereExcentricite(.tEl.da, .tEl.db)
Case eSCG.WGS84_Geo 'Ellipsoïde WGS84
.dlambda0 = 0
.tEl.da = 6378137
.tEl.df = 1 / 298.257223563
.tEl.db = CalculDemiPetitAxe(.tEl.da, .tEl.df)
.tEl.de = CalculPremiereExcentricite(.tEl.da, .tEl.db) '0.08181919106
Case eSCG.ETRS89_Geo, eSCG.ETRS89_Lambert08 'Ellipsoïde GRS80
.tEl.da = 6378137
.tEl.df = 1 / 298.257222101
.tEl.db = CalculDemiPetitAxe(.tEl.da, .tEl.df)
.tEl.de = CalculPremiereExcentricite(.tEl.da, .tEl.db) '0.08181919106
Case eSCG.ED50_Geo, eSCG.BD72_Geo, eSCG.BD72_Lambert72 'Ellipsoïde Hayford 1909 et International 1924 ?
.tEl.da = 6378388
.tEl.df = 1 / 297#
.tEl.db = CalculDemiPetitAxe(.tEl.da, .tEl.df)
.tEl.de = CalculPremiereExcentricite(.tEl.da, .tEl.db) '0.08199188998
End Select
'Paramètres de la projection
Select Case eType
Case eSCG.NTF_Lambert_I 'Nord France
.dphi0 = GradeToRadian(55#)
.dphi1 = DMSToRadian(48, 35, 54.682)
.dphi2 = DMSToRadian(50, 23, 45.282)
.dN = 0.7604059656
.dc = 11603796.98
.dXs = 600000#
.dYs = 5657616.674
Case eSCG.NTF_Lambert_II 'Centre France
.dphi0 = GradeToRadian(52#)
.dphi1 = DMSToRadian(45, 53, 56.108)
.dphi2 = DMSToRadian(47, 41, 45.652)
.dN = 0.7289686274
.dc = 11745793.39
.dXs = 600000#
.dYs = 6199695.768
Case eSCG.NTF_Lambert_III 'Sud France
.dphi0 = GradeToRadian(49#)
.dphi1 = DMSToRadian(43, 11, 57.449)
.dphi2 = DMSToRadian(44, 59, 45.938)
.dN = 0.6959127966
.dc = 11947992.52
.dXs = 600000#
.dYs = 6791905.085
Case eSCG.NTF_Lambert_IV 'Corse
.dphi0 = GradeToRadian(46.85)
.dphi1 = DMSToRadian(41, 33, 37.396)
.dphi2 = DMSToRadian(42, 46, 3.588)
.dN = 0.6712679322
.dc = 12136281.99
.dXs = 234.358
.dYs = 7239161.542
Case eSCG.NTF_Lambert_II_Etendu 'France entière
.dphi0 = GradeToRadian(52#)
.dphi1 = DMSToRadian(45, 53, 56.108)
.dphi2 = DMSToRadian(47, 41, 45.652)
.dN = 0.7289686274
.dc = 11745793.39
.dXs = 600000#
.dYs = 8199695.768
Case eSCG.RGF93_Lambert_93 'France entière
.dlambda0 = DegreDecToRadian(3)
.dphi0 = DMSToRadian(46, 30)
.dphi1 = DegreDecToRadian(44)
.dphi2 = DegreDecToRadian(49)
.dN = 0.725607765
.dc = 11754255.426
.dXs = 700000#
.dYs = 12655612.05
Case eSCG.BD72_Lambert72 'Belgique
.dlambda0 = DMSToRadian(4, 22, 2.952)
.dphi0 = DegreDecToRadian(90)
.dphi1 = DMSToRadian(49, 50, 0.00204)
.dphi2 = DMSToRadian(51, 10, 0.00204)
'Calcul les constantes
alg54 tProj, 150000.013, 5400088.438
Case eSCG.ETRS89_Lambert08 'Belgique
.dlambda0 = DMSToRadian(4, 21, 33.177)
.dphi0 = DMSToRadian(50, 47, 52.134)
.dphi1 = DMSToRadian(49, 50)
.dphi2 = DMSToRadian(51, 10)
'Calcul les constantes
alg54 tProj, 649328#, 665262#
End Select
End With
End Sub
'Paramètres de transformation d'un système à l'autre
Private Sub SetTransformation(ByRef tTrans As tTransformation, ByVal eTrans As eTypeTrans)
With tTrans
'Selon convention de l'IERS : Coordinate Frame Rotation ?
'Par défaut
.dFacteurEchelle = 1
Select Case eTrans
Case eTypeTrans.NTFtoRGF93, eTypeTrans.NTFtoWGS84, _
eTypeTrans.RGF93toNTF, eTypeTrans.WGS84toNTF
.dTx = -168
.dTy = -60
.dTz = 320
If eTrans = eTypeTrans.RGF93toNTF Or eTrans = eTypeTrans.WGS84toNTF Then
TransformationInverse tTrans
End If
Case eTypeTrans.NTFtoED50, eTypeTrans.ED50toNTF
.dTx = -84
.dTy = 37
.dTz = 437
If eTrans = eTypeTrans.ED50toNTF Then
TransformationInverse tTrans
End If
Case eTypeTrans.ED50toWGS84, eTypeTrans.ED50toRGF93, _
eTypeTrans.RGF93toED50, eTypeTrans.WGS84toED50
.dTx = -84
.dTy = -97
.dTz = -117
If eTrans = eTypeTrans.RGF93toED50 Or eTrans = eTypeTrans.WGS84toED50 Then
TransformationInverse tTrans
End If
Case eTypeTrans.ETRS89toBD72, eTypeTrans.BD72toETRS89
.dTx = 106.868628
.dTy = -52.297783
.dTz = 103.723893
.dRx = DMSToRadian(0, 0, 0.33657, True)
.dRy = DMSToRadian(0, 0, 0.456955)
.dRz = DMSToRadian(0, 0, 1.842183, True)
.dFacteurEchelle = 1 + 0.0000012747
If eTrans = eTypeTrans.BD72toETRS89 Then
TransformationInverse tTrans
End If
Case eTypeTrans.RGF93toWGS84, eTypeTrans.WGS84toRGF93
'pas de transformation entre ces systèmes
End Select
End With
End Sub
'Détermine les paramètres de la transformation inverse
Private Sub TransformationInverse(ByRef tTrans As tTransformation)
With tTrans
.dTx = -.dTx
.dTy = -.dTy
.dTz = -.dTz
.dRx = -.dRx
.dRy = -.dRy
.dRz = -.dRz
If .dFacteurEchelle <> 0 Then .dFacteurEchelle = 1 / .dFacteurEchelle
End With
End Sub
Private Function SetConversion(ByVal eDe As eSCG, ByVal eVers As eSCG) As Variant
Dim avC(0 To 63) As Variant
Dim i As Integer
avC(0) = VBA.Array(eSCG.NTF_Lambert_I, eSCG.NTF_Paris_Geo, True, Null, False)
avC(1) = VBA.Array(eSCG.NTF_Lambert_I, eSCG.NTF_Lambert_II_Etendu, True, Null, True)
avC(2) = VBA.Array(eSCG.NTF_Lambert_I, eSCG.RGF93_Geo, True, eTypeTrans.NTFtoRGF93, False)
avC(3) = VBA.Array(eSCG.NTF_Lambert_I, eSCG.RGF93_Lambert_93, True, eTypeTrans.NTFtoRGF93, True)
avC(4) = VBA.Array(eSCG.NTF_Lambert_I, eSCG.ED50_Geo, True, eTypeTrans.NTFtoED50, False)
avC(5) = VBA.Array(eSCG.NTF_Lambert_I, eSCG.WGS84_Geo, True, eTypeTrans.NTFtoWGS84, False)
avC(6) = VBA.Array(eSCG.NTF_Lambert_II, eSCG.NTF_Paris_Geo, True, Null, False)
avC(7) = VBA.Array(eSCG.NTF_Lambert_II, eSCG.NTF_Lambert_II_Etendu, True, Null, True)
avC(8) = VBA.Array(eSCG.NTF_Lambert_II, eSCG.RGF93_Geo, True, eTypeTrans.NTFtoRGF93, False)
avC(9) = VBA.Array(eSCG.NTF_Lambert_II, eSCG.RGF93_Lambert_93, True, eTypeTrans.NTFtoRGF93, True)
avC(10) = VBA.Array(eSCG.NTF_Lambert_II, eSCG.ED50_Geo, True, eTypeTrans.NTFtoED50, False)
avC(11) = VBA.Array(eSCG.NTF_Lambert_II, eSCG.WGS84_Geo, True, eTypeTrans.NTFtoWGS84, False)
avC(12) = VBA.Array(eSCG.NTF_Lambert_III, eSCG.NTF_Paris_Geo, True, Null, False)
avC(13) = VBA.Array(eSCG.NTF_Lambert_III, eSCG.NTF_Lambert_II_Etendu, True, Null, True)
avC(14) = VBA.Array(eSCG.NTF_Lambert_III, eSCG.RGF93_Geo, True, eTypeTrans.NTFtoRGF93, False)
avC(15) = VBA.Array(eSCG.NTF_Lambert_III, eSCG.RGF93_Lambert_93, True, eTypeTrans.NTFtoRGF93, True)
avC(16) = VBA.Array(eSCG.NTF_Lambert_III, eSCG.ED50_Geo, True, eTypeTrans.NTFtoED50, False)
avC(17) = VBA.Array(eSCG.NTF_Lambert_III, eSCG.WGS84_Geo, True, eTypeTrans.NTFtoWGS84, False)
avC(18) = VBA.Array(eSCG.NTF_Lambert_IV, eSCG.NTF_Paris_Geo, True, Null, False)
avC(19) = VBA.Array(eSCG.NTF_Lambert_IV, eSCG.NTF_Lambert_II_Etendu, True, Null, True)
avC(20) = VBA.Array(eSCG.NTF_Lambert_IV, eSCG.RGF93_Geo, True, eTypeTrans.NTFtoRGF93, False)
avC(21) = VBA.Array(eSCG.NTF_Lambert_IV, eSCG.RGF93_Lambert_93, True, eTypeTrans.NTFtoRGF93, True)
avC(22) = VBA.Array(eSCG.NTF_Lambert_IV, eSCG.ED50_Geo, True, eTypeTrans.NTFtoED50, False)
avC(23) = VBA.Array(eSCG.NTF_Lambert_IV, eSCG.WGS84_Geo, True, eTypeTrans.NTFtoWGS84, False)
avC(24) = VBA.Array(eSCG.NTF_Lambert_II_Etendu, eSCG.NTF_Paris_Geo, True, Null, False)
avC(25) = VBA.Array(eSCG.NTF_Lambert_II_Etendu, eSCG.RGF93_Geo, True, eTypeTrans.NTFtoRGF93, False)
avC(26) = VBA.Array(eSCG.NTF_Lambert_II_Etendu, eSCG.RGF93_Lambert_93, True, eTypeTrans.NTFtoRGF93, True)
avC(27) = VBA.Array(eSCG.NTF_Lambert_II_Etendu, eSCG.ED50_Geo, True, eTypeTrans.NTFtoED50, False)
avC(28) = VBA.Array(eSCG.NTF_Lambert_II_Etendu, eSCG.WGS84_Geo, True, eTypeTrans.NTFtoWGS84, False)
avC(29) = VBA.Array(eSCG.NTF_Paris_Geo, eSCG.NTF_Lambert_II_Etendu, False, Null, True)
avC(30) = VBA.Array(eSCG.NTF_Paris_Geo, eSCG.RGF93_Geo, False, eTypeTrans.NTFtoRGF93, False)
avC(31) = VBA.Array(eSCG.NTF_Paris_Geo, eSCG.RGF93_Lambert_93, False, eTypeTrans.NTFtoRGF93, True)
avC(32) = VBA.Array(eSCG.NTF_Paris_Geo, eSCG.ED50_Geo, False, eTypeTrans.NTFtoED50, False)
avC(33) = VBA.Array(eSCG.NTF_Paris_Geo, eSCG.WGS84_Geo, False, eTypeTrans.NTFtoWGS84, False)
avC(34) = VBA.Array(eSCG.RGF93_Geo, eSCG.NTF_Lambert_II_Etendu, False, eTypeTrans.RGF93toNTF, True)
avC(35) = VBA.Array(eSCG.RGF93_Geo, eSCG.NTF_Paris_Geo, False, eTypeTrans.RGF93toNTF, False)
avC(36) = VBA.Array(eSCG.RGF93_Geo, eSCG.RGF93_Lambert_93, False, Null, True)
avC(37) = VBA.Array(eSCG.RGF93_Geo, eSCG.ED50_Geo, False, eTypeTrans.RGF93toED50, False)
avC(38) = VBA.Array(eSCG.RGF93_Geo, eSCG.WGS84_Geo, False, eTypeTrans.RGF93toWGS84, False)
avC(39) = VBA.Array(eSCG.RGF93_Lambert_93, eSCG.NTF_Paris_Geo, True, eTypeTrans.RGF93toNTF, False)
avC(40) = VBA.Array(eSCG.RGF93_Lambert_93, eSCG.NTF_Lambert_II_Etendu, True, eTypeTrans.RGF93toNTF, True)
avC(41) = VBA.Array(eSCG.RGF93_Lambert_93, eSCG.RGF93_Geo, True, Null, False)
avC(42) = VBA.Array(eSCG.RGF93_Lambert_93, eSCG.ED50_Geo, True, eTypeTrans.RGF93toED50, False)
avC(43) = VBA.Array(eSCG.RGF93_Lambert_93, eSCG.WGS84_Geo, True, eTypeTrans.RGF93toWGS84, False)
avC(44) = VBA.Array(eSCG.ED50_Geo, eSCG.NTF_Paris_Geo, False, eTypeTrans.ED50toNTF, False)
avC(45) = VBA.Array(eSCG.ED50_Geo, eSCG.NTF_Lambert_II_Etendu, False, eTypeTrans.ED50toNTF, True)
avC(46) = VBA.Array(eSCG.ED50_Geo, eSCG.RGF93_Geo, False, eTypeTrans.ED50toRGF93, False)
avC(47) = VBA.Array(eSCG.ED50_Geo, eSCG.RGF93_Lambert_93, False, eTypeTrans.ED50toRGF93, True)
avC(48) = VBA.Array(eSCG.ED50_Geo, eSCG.WGS84_Geo, False, eTypeTrans.ED50toWGS84, False)
avC(49) = VBA.Array(eSCG.WGS84_Geo, eSCG.NTF_Paris_Geo, False, eTypeTrans.WGS84toNTF, False)
avC(50) = VBA.Array(eSCG.WGS84_Geo, eSCG.NTF_Lambert_II_Etendu, False, eTypeTrans.WGS84toNTF, True)
avC(51) = VBA.Array(eSCG.WGS84_Geo, eSCG.RGF93_Geo, False, eTypeTrans.WGS84toRGF93, False)
avC(52) = VBA.Array(eSCG.WGS84_Geo, eSCG.RGF93_Lambert_93, False, eTypeTrans.WGS84toRGF93, True)
avC(53) = VBA.Array(eSCG.WGS84_Geo, eSCG.ED50_Geo, False, eTypeTrans.WGS84toED50, False)
avC(54) = VBA.Array(eSCG.BD72_Lambert72, eSCG.ETRS89_Lambert08, True, eTypeTrans.BD72toETRS89, True)
avC(55) = VBA.Array(eSCG.BD72_Lambert72, eSCG.BD72_Geo, True, Null, False)
avC(56) = VBA.Array(eSCG.BD72_Lambert72, eSCG.ETRS89_Geo, True, eTypeTrans.BD72toETRS89, False)
avC(57) = VBA.Array(eSCG.BD72_Geo, eSCG.ETRS89_Geo, False, eTypeTrans.BD72toETRS89, False)
avC(58) = VBA.Array(eSCG.ETRS89_Lambert08, eSCG.BD72_Lambert72, True, eTypeTrans.ETRS89toBD72, True)
avC(59) = VBA.Array(eSCG.ETRS89_Lambert08, eSCG.BD72_Geo, True, eTypeTrans.ETRS89toBD72, False)
avC(60) = VBA.Array(eSCG.ETRS89_Lambert08, eSCG.ETRS89_Geo, True, Null, False)
avC(61) = VBA.Array(eSCG.ETRS89_Geo, eSCG.BD72_Lambert72, False, eTypeTrans.ETRS89toBD72, True)
avC(62) = VBA.Array(eSCG.ETRS89_Geo, eSCG.BD72_Geo, False, eTypeTrans.ETRS89toBD72, False)
avC(63) = VBA.Array(eSCG.ETRS89_Geo, eSCG.ETRS89_Lambert08, False, Null, True)
For i = 0 To UBound(avC)
If avC(i)(eSchema.eInitial) = eDe And avC(i)(eSchema.eFinal) = eVers Then
SetConversion = avC(i)
Exit For
End If
Next i
End Function
Private Function CalculDemiPetitAxe(ByVal da As Double, ByVal df As Double) As Double
CalculDemiPetitAxe = da * (1 - df)
End Function
Private Function CalculPremiereExcentricite(ByVal da As Double, ByVal db As Double) As Double
Dim daCarre As Double
daCarre = da ^ 2
CalculPremiereExcentricite = Sqr((daCarre - db ^ 2) / daCarre)
End Function
Public Function GradeToRadian(ByVal dAngle As Double)
GradeToRadian = gdpi * dAngle / 200
End Function
Public Function RadianToGrade(ByVal dAngle As Double)
RadianToGrade = 200 * dAngle / gdpi
End Function
Public Function DegreDecToRadian(ByVal dAngle As Double)
DegreDecToRadian = gdpi * dAngle / 180
End Function
Public Function RadianToDegreDec(ByVal dAngle As Double)
RadianToDegreDec = 180 * dAngle / gdpi
End Function
Public Function DMSToDegreDec(ByVal iDegre As Integer, Optional ByVal byMin As Byte = 0, _
Optional ByVal fSec As Single = 0, _
Optional bNegatif As Boolean = False) As Double
If byMin < 60 And fSec < 60 Then
DMSToDegreDec = Abs(iDegre) + byMin / 60 + Abs(fSec) / 3600
If bNegatif Then DMSToDegreDec = -DMSToDegreDec
End If
End Function
Public Function AngleDMSToDegreDec(ByVal dAngle As Double) As Double
Dim fSec As Single
Dim iDegre As Integer, iMin As Integer, iSigne As Integer
iSigne = Sgn(dAngle)
dAngle = Abs(dAngle)
iDegre = Int(dAngle)
iMin = Int((dAngle - iDegre) * 100)
fSec = (dAngle - iDegre - iMin / 100) * 10000
AngleDMSToDegreDec = (iDegre + iMin / 60 + fSec / 3600) * iSigne
End Function
Public Function DMSToRadian(ByVal iDegre As Integer, Optional ByVal byMin As Byte = 0, _
Optional ByVal fSec As Single = 0, _
Optional bNegatif As Boolean = False) As Double
DMSToRadian = DegreDecToRadian(DMSToDegreDec(iDegre, byMin, fSec, bNegatif))
End Function
Public Function AngleDMSToRadian(ByVal dAngle As Double) As Double
AngleDMSToRadian = DegreDecToRadian(AngleDMSToDegreDec(dAngle))
End Function
Public Function DegreDecToAngleDMS(ByVal dAngle As Double) As Double
Dim iDegre As Integer, iMin As Integer, iSigne As Integer
Dim fSec As Single
iSigne = Sgn(dAngle)
dAngle = Abs(dAngle)
iDegre = Int(dAngle)
iMin = Int((dAngle - iDegre) * 60)
fSec = (dAngle - iDegre - iMin / 60) * 3600
DegreDecToAngleDMS = Arrondi((iDegre + (iMin + fSec / 100) / 100) * iSigne, 7)
End Function
Public Function AngleDMSToString(ByVal dAngle As Double, ByVal bLatitude As Boolean) As String
Dim iDegre As Integer, iMin As Integer, iSigne As Integer
Dim fSec As Single
Dim s As String
iSigne = Sgn(dAngle)
dAngle = Abs(dAngle)
iDegre = Int(dAngle)
iMin = Int((dAngle - iDegre) * 100)
fSec = (dAngle - iDegre - iMin / 100) * 10000
s = iDegre & "°" & format(iMin, "00'") & format(fSec, "00.0##''")
If iSigne < 0 Then
s = s & IIf(bLatitude, "S", "W")
Else
s = s & IIf(bLatitude, "N", "E")
End If
AngleDMSToString = s
End Function
Public Function RadianToStringDMS(ByVal dAngle As Double, ByVal bLatitude As Boolean) As String
RadianToStringDMS = AngleDMSToString(DegreDecToAngleDMS(RadianToDegreDec(dAngle)), bLatitude)
End Function
Public Function Arrondi(ByVal dVal As Double, Optional ByVal iDec As Integer = 0) As Double
Arrondi = Int((dVal * (10 ^ iDec)) + 0.5) / (10 ^ iDec)
End Function
Public Function DistanceKm(ByVal dRadLon1 As Double, ByVal dRadLat1 As Double, _
ByVal dRadLon2 As Double, ByVal dRadLat2 As Double) As Double
DistanceKm = 6371 * ArcCosRad(Cos(dRadLat1) * Cos(dRadLat2) * Cos(dRadLon2 - dRadLon1) + _
(Sin(dRadLat1) * Sin(dRadLat2)))
End Function
Private Function ArcCosRad(dRadian As Double) As Double
If dRadian > -1 And dRadian < 1 Then
ArcCosRad = Atn(-dRadian / Sqr(-dRadian * dRadian + 1)) + gdpi / 2
ElseIf dRadian = -1 Then
ArcCosRad = gdpi
End If
End Function
#If CCTEST Then
Public Function TestAngles()
Dim sTabs As String
sTabs = vbTab & vbTab
Debug.Print "--- Vérification des conversions d'angles ---"
Debug.Print vbTab & "+ Grade -> Radian"
Debug.Print sTabs & "Entrée : " & 0 & " - Attendu : " & 0 & " - Obtenu : " & GradeToRadian(0)
Debug.Print sTabs & "Entrée : " & 200 & " - Attendu : " & gdpi & " - Obtenu : " & GradeToRadian(200)
Debug.Print sTabs & "Entrée : " & -200 & " - Attendu : " & -gdpi & " - Obtenu : " & GradeToRadian(-200)
Debug.Print sTabs & "Entrée : " & 600 & " - Attendu : " & (3 * gdpi) & " - Obtenu : " & GradeToRadian(600)
Debug.Print vbTab & "+ Radian -> Grade"
Debug.Print sTabs & "Entrée : " & 0 & " - Attendu : " & 0 & " - Obtenu : " & RadianToGrade(0)
Debug.Print sTabs & "Entrée : " & "pi" & " - Attendu : " & 200 & " - Obtenu : " & RadianToGrade(gdpi)
Debug.Print sTabs & "Entrée : " & "-pi" & " - Attendu : " & -200 & " - Obtenu : " & RadianToGrade(-gdpi)
Debug.Print sTabs & "Entrée : " & (3 * gdpi) & " - Attendu : " & 600 & " - Obtenu : " & RadianToGrade(3 * gdpi)
Debug.Print vbTab & "+ Degré décimal -> Radian"
Debug.Print sTabs & "Entrée : " & 0 & " - Attendu : " & 0 & " - Obtenu : " & DegreDecToRadian(0)
Debug.Print sTabs & "Entrée : " & 180 & " - Attendu : " & "pi" & " - Obtenu : " & DegreDecToRadian(180)
Debug.Print sTabs & "Entrée : " & -180 & " - Attendu : " & "-pi" & " - Obtenu : " & DegreDecToRadian(-180)
Debug.Print sTabs & "Entrée : " & 540 & " - Attendu : " & (3 * gdpi) & " - Obtenu : " & DegreDecToRadian(540)
Debug.Print vbTab & "+ Radian -> Degré décimal"
Debug.Print sTabs & "Entrée : " & 0 & " - Attendu : " & 0 & " - Obtenu : " & RadianToDegreDec(0)
Debug.Print sTabs & "Entrée : " & "pi" & " - Attendu : " & 180 & " - Obtenu : " & RadianToDegreDec(gdpi)
Debug.Print sTabs & "Entrée : " & "-pi" & " - Attendu : " & -180 & " - Obtenu : " & RadianToDegreDec(-gdpi)
Debug.Print sTabs & "Entrée : " & (3 * gdpi) & " - Attendu : " & 540 & " - Obtenu : " & RadianToDegreDec(3 * gdpi)
Debug.Print vbTab & "+ DMS(Deg,Min,Sec) -> Degré décimal"
Debug.Print sTabs & "Entrée : " & 0 & " - Attendu : " & 0 & " - Obtenu : " & DMSToDegreDec(0)
Debug.Print sTabs & "Entrée : " & 180 & " - Attendu : " & 180 & " - Obtenu : " & DMSToDegreDec(180)
Debug.Print sTabs & "Entrée : " & "45°35'25.566''" & " - Attendu : " & 45.590435 & " - Obtenu : " & Arrondi(DMSToDegreDec(45, 35, 25.567), 6)
Debug.Print sTabs & "Entrée : " & "-45°35'25.566''" & " - Attendu : " & -45.590435 & " - Obtenu : " & Arrondi(DMSToDegreDec(-45, 35, 25.566, True), 6)
Debug.Print sTabs & "Entrée : " & "-45°75'25.566''" & " - Attendu : " & 0 & " car erreur ! - Obtenu : " & Arrondi(DMSToDegreDec(-45, 75, 25.566, True), 6)
Debug.Print sTabs & "Entrée : " & "-45°35'85.566''" & " - Attendu : " & 0 & " car erreur ! - Obtenu : " & Arrondi(DMSToDegreDec(-45, 35, 85.566, True), 6)
Debug.Print vbTab & "+ Angle DMS (Degre.mmssxxx) -> Degré décimal"
Debug.Print sTabs & "Entrée : " & 0 & " - Attendu : " & 0 & " - Obtenu : " & AngleDMSToDegreDec(0)
Debug.Print sTabs & "Entrée : " & 180 & " - Attendu : " & 180 & " - Obtenu : " & AngleDMSToDegreDec(180)
Debug.Print sTabs & "Entrée : " & 45.3525566 & " - Attendu : " & 45.590435 & " - Obtenu : " & Arrondi(AngleDMSToDegreDec(45.3525566), 6)
Debug.Print sTabs & "Entrée : " & -45.3525566 & " - Attendu : " & -45.590435 & " - Obtenu : " & Arrondi(AngleDMSToDegreDec(-45.3525566), 6)
Debug.Print vbTab & "+ Degré décimal -> Angle DMS (Degre.mmssxxx)"
Debug.Print sTabs & "Entrée : " & 0 & " - Attendu : " & 0 & " - Obtenu : " & DegreDecToAngleDMS(0)
Debug.Print sTabs & "Entrée : " & 180 & " - Attendu : " & 180 & " - Obtenu : " & DegreDecToAngleDMS(180)
Debug.Print sTabs & "Entrée : " & 45.590435 & " - Attendu : " & 45.3525566 & " - Obtenu : " & Arrondi(DegreDecToAngleDMS(45.590435), 7)
Debug.Print sTabs & "Entrée : " & -45.590435 & " - Attendu : " & -45.3525566 & " - Obtenu : " & Arrondi(DegreDecToAngleDMS(-45.590435), 7)
Debug.Print vbTab & "+ Angle DMS (Degre.mmssxxx) -> String"
Debug.Print sTabs & "Entrée : " & 0 & " Lat - Attendu : " & "0°00'00,0''N" & " - Obtenu : " & AngleDMSToString(0, True)
Debug.Print sTabs & "Entrée : " & 45 & " Lon - Attendu : " & "45°00'00,0''E" & " - Obtenu : " & AngleDMSToString(45, False)
Debug.Print sTabs & "Entrée : " & 45.590435 & " Lat - Attendu : " & "45°59'04,35''N" & " - Obtenu : " & AngleDMSToString(45.590435, True)
Debug.Print sTabs & "Entrée : " & -45.3525566 & " Lat - Attendu : " & "45°35'25,566''S" & " - Obtenu : " & AngleDMSToString(-45.3525566, True)
Debug.Print "---"
End Function
Public Sub TestConversions()
Debug.Print "--- Vérification de certaines conversions ---"
Debug.Print vbTab & "+ NTF méridien de Paris -> ED50 Greenwich"
Test NTF_Paris_Geo, ED50_Geo, 6, 54, "7°44'16,4''", "48°36'03,3''", gr, dms
Debug.Print vbTab & "+ NTF méridien de Paris -> WGS84"
Test NTF_Paris_Geo, WGS84_Geo, 6, 54, "7°44'12,2''", "48°35'59,9''", gr, dms
Debug.Print vbTab & "+ NTF méridien de Paris -> NTF Lambert II étendu"
Test NTF_Paris_Geo, NTF_Lambert_II_Etendu, 6, 54, "998137m", "2413822m", gr, m, 0
Debug.Print vbTab & "+ NTF méridien de Paris -> RGF Lambert 93"
Test NTF_Paris_Geo, RGF93_Lambert_93, 6, 54, "1049052m", "6843777m", gr, m, 0
Debug.Print vbTab & "+ NTF Lambert I -> ED50 Greenwich"
Test NTF_Lambert_I, ED50_Geo, 997960, 114185, "7°44'16,4''", "48°36'03,3''", m, dms
Debug.Print vbTab & "+ NTF Lambert I -> WGS84"
Test NTF_Lambert_I, WGS84_Geo, 997960, 114185, "7°44'12,2''", "48°35'59,9''", m, dms
Debug.Print vbTab & "+ NTF Lambert I -> NTF Lambert II étendu"
Test NTF_Lambert_I, NTF_Lambert_II_Etendu, 997960, 114185, "998137m", "2413822m", m, m, 0
Debug.Print vbTab & "+ NTF Lambert I -> RGF Lambert 93"
Test NTF_Lambert_I, RGF93_Lambert_93, 997960, 114185, "1049052m", "6843777m", m, m, 0
Debug.Print vbTab & "+ NTF Lambert II étendu -> ED50 Greenwich"
Test NTF_Lambert_II_Etendu, ED50_Geo, 998137, 2413822, "7°44'16,4''", "48°36'03,3''", m, dms
Debug.Print vbTab & "+ NTF Lambert II étendu -> WGS84"
Test NTF_Lambert_II_Etendu, WGS84_Geo, 998137, 2413822, "7°44'12,2''", "48°35'59,9''", m, dms
Debug.Print vbTab & "+ NTF Lambert II étendu -> NTF méridien de Paris"
Test NTF_Lambert_II_Etendu, NTF_Paris_Geo, 998137, 2413822, "6gr", "54gr", m, gr, 0
Debug.Print vbTab & "+ NTF Lambert II étendu -> RGF Lambert 93"
Test NTF_Lambert_II_Etendu, RGF93_Lambert_93, 998137, 2413822, "1049052m", "6843777m", m, m, 1
Debug.Print vbTab & "+ RGF Lambert 93 -> NTF Lambert II étendu"
Test RGF93_Lambert_93, NTF_Lambert_II_Etendu, 1049052, 6843777, " 998137m", "2413822m", m, m, 1
Debug.Print vbTab & "+ BD72 Lambert 72 -> BD72"
Test BD72_Lambert72, BD72_Geo, 235000, 45000, "5°32'45.48188''", "49°42'40.06796''", m, dms
Debug.Print vbTab & "+ BD72 Lambert 72 -> ETRS89"
Test BD72_Lambert72, ETRS89_Geo, 235000, 45000, "5°32'50.09529''", "49°42'37.96785''", m, dms
Debug.Print vbTab & "+ ETRS Lambert 08 -> ETRS89"
Test ETRS89_Lambert08, ETRS89_Geo, 735000, 545000, "5°32'49.39407", "49°42'37.60005", m, dms
Debug.Print vbTab & "+ ETRS Lambert 08 -> BD72 Lambert 72"
Test ETRS89_Lambert08, BD72_Lambert72, 735000, 545000, "234986.1", "44988.4", m, m, 1
Debug.Print vbTab & "+ BD72 Lambert 72 -> ETRS Lambert 08"
Test BD72_Lambert72, ETRS89_Lambert08, 50000, 200000, "549996.807", "699988.150", m, m, 1
Debug.Print "---"
End Sub
Public Sub TestAlgos()
Dim tProj As tProjection
Dim tTrans As tTransformation
Dim tXYZ As t_XYZ
Dim dVal As Double
Dim av(0 To 2) As Variant
Dim i As Integer
Dim sTabs As String
sTabs = vbTab & vbTab
Debug.Print "--- Validation des algorithmes ---"
'utilisé par alg01 et 02
av(0) = VBA.Array(1.00552653648, 0.08199188998, 0.872664626)
av(1) = VBA.Array(-0.3026169006, 0.08199188998, -0.29999999997)
av(2) = VBA.Array(0.2, 0.08199188998, 0.19998903369)
'alg01
Debug.Print vbTab & "+ alg01 - Latitude isométrique à partir de la latitude"
For i = 0 To UBound(av)
Debug.Print sTabs & "Attendu -> phi(rad) : " & av(i)(0)
Debug.Print sTabs & "Obtenu -> phi(rad) : " & alg01(av(i)(2), av(i)(1))
Debug.Print sTabs & "---"
Next i
'alg02
Debug.Print vbTab & "+ alg02 - Latitude à partir de la latitude isométrique"
For i = 0 To UBound(av)
Debug.Print sTabs & "Attendu -> Lat iso : " & av(i)(2)
Debug.Print sTabs & "Obtenu -> Lat iso : " & alg02(av(i)(0), av(i)(1))
Debug.Print sTabs & "---"
Next i
'alg03
Debug.Print vbTab & "+ alg03 - Coordonnées géo vers Lambert"
Debug.Print sTabs & "Attendu -> X : " & 1029705.0818 & " m _ Y : " & 272723.851 & " m"
With tProj
.tEl.de = 0.0824832568
.dN = 0.760405966
.dc = 11603796.9767
.dlambda0 = 0.04079234433
.dXs = 600000
.dYs = 5657616.674
End With
tXYZ = alg03(0.145512099, 0.872664626, tProj)
Debug.Print sTabs & "Obtenu -> X : " & Arrondi(tXYZ.dX, 4) & " m _ Y : " & Arrondi(tXYZ.dY, 4) & " m"
Debug.Print sTabs & "---"
'alg04
Debug.Print vbTab & "+ alg04 - Lambert vers coordonnées géo "
Debug.Print sTabs & "Attendu -> lon : " & 0.14551209925 & " _ lat : " & 0.87266462567
With tProj
.tEl.de = 0.0824832568
.dN = 0.760405966
.dc = 11603796.9767
.dlambda0 = 0.04079234433
.dXs = 600000
.dYs = 5657616.674
End With
tXYZ = alg04(1029705.083, 272723.849, tProj)
Debug.Print sTabs & "Obtenu -> Lon : " & Arrondi(tXYZ.dX, 11) & " _ Lat : " & Arrondi(tXYZ.dY, 11)
Debug.Print sTabs & "---"
'alg21
Debug.Print vbTab & "+ alg21 - Calcul grande Normale"
Debug.Print sTabs & "Attendu -> N : " & 6393174.9755 & " m"
dVal = alg21(0.977384381, 6378388, 0.08199189)
Debug.Print sTabs & "Obtenu -> N : " & Arrondi(dVal, 4) & " m"
Debug.Print sTabs & "---"
'alg09
Debug.Print vbTab & "+ alg09 - Coordonnées géo vers cartésiennes"
Debug.Print sTabs & "Attendu -> X : " & 6376064.6955 & _
" m _ Y : " & 111294.623 & " m _ Z : " & 128984.725 & " m"
With tProj.tEl
.dh = 100
.da = 6378249.2
.de = 0.08248325679
End With
tXYZ = alg09(0.01745329248, 0.02036217457, tProj.tEl)
Debug.Print sTabs & "Obtenu -> X : " & Arrondi(tXYZ.dX, 4) & _
" m _ Y : " & Arrondi(tXYZ.dY, 4) & " m _ Z : " & Arrondi(tXYZ.dZ, 4) & " m"
Debug.Print sTabs & "---"
Debug.Print sTabs & "Attendu -> X : " & 6378232.2149 & _
" m _ Y : " & 18553.578 & " m _ Z : " & 0 & " m"
With tProj.tEl
.dh = 10
.da = 6378249.2
.de = 0.08248325679
End With
tXYZ = alg09(0.00290888212, 0, tProj.tEl)
Debug.Print sTabs & "Obtenu -> X : " & Arrondi(tXYZ.dX, 4) & _
" m _ Y : " & Arrondi(tXYZ.dY, 4) & " m _ Z : " & Arrondi(tXYZ.dZ, 4) & " m"
Debug.Print sTabs & "---"
'alg12
Debug.Print vbTab & "+ alg12 - Coordonnées cartésiennes vers géo"
Debug.Print sTabs & "Attendu -> Lon : " & 0.01745329248 & _
" _ Lat : " & 0.02036217457 & " _ h : " & 99.9995 & " m"
With tProj.tEl
.da = 6378249.2
.de = 0.08248325679
End With
With tXYZ
.dX = 6376064.695
.dY = 111294.623
.dZ = 128984.725
End With
tXYZ = alg12(tXYZ, tProj.tEl)
Debug.Print sTabs & "Obtenu -> Lon : " & Arrondi(tXYZ.dX, 11) & _
" _ Lat : " & Arrondi(tXYZ.dY, 11) & " _ h : " & Arrondi(tXYZ.dZ, 4) & " m"
Debug.Print sTabs & "---"
Debug.Print sTabs & "Attendu -> Lon : " & 0.00581776423 & _
" _ Lat : " & -0.03199770301 & " _ h : " & 2000.0001 & " m"
With tXYZ
.dX = 6376897.537
.dY = 37099.705
.dZ = -202730.907
End With
tXYZ = alg12(tXYZ, tProj.tEl)
Debug.Print sTabs & "Obtenu -> Lon : " & Arrondi(tXYZ.dX, 11) & _
" _ Lat : " & Arrondi(tXYZ.dY, 11) & " _ h : " & Arrondi(tXYZ.dZ, 4) & " m"
Debug.Print sTabs & "---"
'alg13
Debug.Print vbTab & "+ alg13 - Coordonnées cartésiennes vers cartésiennes"
Debug.Print sTabs & "Attendu -> Vx : " & 4154005.8099 & _
" m _ Vy : " & -80587.3284 & " m _ Vz : " & 4823289.5316 & " m"
With tTrans
.dTx = -69.4
.dTy = 18
.dTz = 452.2
.dRx = 0
.dRy = 0
.dRz = 0.00000499358
.dFacteurEchelle = 1 - 0.00000321
End With
With tXYZ
.dX = 4154088.142
.dY = -80626.331
.dZ = 4822852.813
End With
tXYZ = alg13(tXYZ, tTrans)
Debug.Print sTabs & "Obtenu -> Vx : " & Arrondi(tXYZ.dX, 4) & _
" m _ Vy : " & Arrondi(tXYZ.dY, 4) & " m _ Vz : " & Arrondi(tXYZ.dZ, 4) & " m"
Debug.Print sTabs & "---"
'alg54
Debug.Print vbTab & "+ alg54 - Calcul paramètres lambert dans le cas sécant"
Debug.Print sTabs & "Attendu -> c (m): " & 11565915.8294 & _
" m _ n : " & 0.7716421867 & " _ Xs : " & 150000 & " _ Ys : " & 5400000
With tProj
.tEl.da = 6378388
.tEl.de = 0.08199189
.dlambda0 = 0.07623554539
.dphi0 = 1.570796327
.dXs = 0
.dYs = 0
.dphi1 = 0.869755744
.dphi2 = 0.893026801
End With
alg54 tProj, 150000, 5400000
Debug.Print sTabs & "Obtenu -> c (m): " & tProj.dc & " m _ n : " & tProj.dN & _
" _ Xs : " & tProj.dXs & " _ Ys : " & tProj.dYs
Debug.Print sTabs & "---"
Debug.Print sTabs & "Attendu -> c (m): " & -12453174.1795 & _
" m _ n : " & -0.63049633 & " _ Xs : " & 0 & " _ Ys : " & -12453174.1795
With tProj
.tEl.da = 6378388
.tEl.de = 0.08199189
.dlambda0 = 0
.dphi0 = 0
.dXs = 0
.dYs = 0
.dphi1 = -0.575958653
.dphi2 = -0.785398163
End With
alg54 tProj, 0, 0
Debug.Print sTabs & "Obtenu -> c (m): " & tProj.dc & " m _ n : " & tProj.dN & _
" _ Xs : " & tProj.dXs & " _ Ys : " & tProj.dYs
Debug.Print sTabs & "---"
End Sub
Private Sub Test(ByVal eDep As eSCG, ByVal eFin As eSCG, _
ByVal dXi As Double, dYi As Double, _
ByVal sXf As String, sYf As String, _
ByVal eUniteIn As eUnites, ByVal eUniteOut As eUnites, _
Optional ByVal byDecimal As Byte = 1)
Dim tRes As tResults
Dim sTabs As String
sTabs = vbTab & vbTab
Me.TypeConversion eDep, eFin
If Me.IsErreur Then
Debug.Print sTabs & "Erreur : " & Me.Erreur
Else
tRes = SetUnites(dXi, dYi, eUniteIn, True)
With tRes
Me.CalculSCG .dX, .dY
Debug.Print sTabs & "Entrée - Xi : " & .sX & " - Yi : " & .sY
Debug.Print sTabs & "Attendu - Xf : " & sXf & " - Yf : " & sYf
tRes = SetUnites(Me.X, Me.Y, eUniteOut, False, byDecimal)
Debug.Print sTabs & "Obtenu - Xc : " & .sX & " - Yc : " & .sY
End With
End If
End Sub
Private Function SetUnites(ByVal dX As Double, ByVal dY As Double, _
ByVal eUn As eUnites, ByVal bIn As Boolean, _
Optional ByVal byDecimal As Byte = 1) As tResults
Dim tRes As tResults
With tRes
Select Case eUn
Case eUnites.dms
If bIn Then
.dX = AngleDMSToRadian(dX)
.dY = AngleDMSToRadian(dY)
.sX = AngleDMSToString(dX, False)
.sY = AngleDMSToString(dY, True)
Else
.sX = RadianToStringDMS(dX, False)
.sY = RadianToStringDMS(dY, True)
End If
Case eUnites.gr
If bIn Then
.dX = GradeToRadian(dX)
.dY = GradeToRadian(dY)
.sX = dX & "gr"
.sY = dY & "gr"
Else
.sX = Arrondi(RadianToGrade(dX), byDecimal) & "gr"
.sY = Arrondi(RadianToGrade(dY), byDecimal) & "gr"
End If
Case eUnites.m
If bIn Then
.dX = dX
.dY = dY
.sX = dX & "m"
.sY = dY & "m"
Else
.sX = Arrondi(dX, byDecimal) & "m"
.sY = Arrondi(dY, byDecimal) & "m"
End If
Case eUnites.rad
If bIn Then
.dX = dX
.dY = dY
.sX = dX & "rad"
.sY = dY & "rad"
Else
.sX = Arrondi(dX, byDecimal) & "rad"
.sY = Arrondi(dY, byDecimal) & "rad"
End If
Case eUnites.DD
If bIn Then
.dX = DegreDecToRadian(dX)
.dY = DegreDecToRadian(dY)
.sX = dX & "°"
.sY = dY & "°"
Else
.sX = Arrondi(RadianToDegreDec(dX), byDecimal) & "°"
.sY = Arrondi(RadianToDegreDec(dY), byDecimal) & "°"
End If
End Select
End With
SetUnites = tRes
End Function
#End If
|
gallandarakhneorg/afc
|
advanced/gis/giscore/src/main/java/org/arakhne/afc/gis/coordinate/projections.vb
|
Visual Basic
|
apache-2.0
| 50,562
|
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class notepadxp
Inherits System.Windows.Forms.Form
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container()
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(notepadxp))
Me.MenuStrip1 = New System.Windows.Forms.MenuStrip()
Me.FileToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
Me.NewCtrlNToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
Me.OpenCtrlOToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
Me.SaveCtrlSToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
Me.SaveAsToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
Me.PageSetupToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
Me.PrintCtrlPToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
Me.ExitToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
Me.EditToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
Me.UndoCtrlZToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
Me.CutCtrlXToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
Me.CopyCtrlCToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
Me.PasteCtrlVToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
Me.DeleteDelToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
Me.FindCtrlFToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
Me.FindNextF3ToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
Me.ReplaceCtrlHToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
Me.GoToCtrlGToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
Me.SelectAllCtrlAToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
Me.TimeDateF5ToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
Me.FormatToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
Me.WordWrapToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
Me.FontToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
Me.ViewToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
Me.StatusBarToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
Me.HelpToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
Me.HelptTopicsToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
Me.AboutNotepadToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
Me.pullbs = New System.Windows.Forms.Timer(Me.components)
Me.pullbottom = New System.Windows.Forms.Timer(Me.components)
Me.pullside = New System.Windows.Forms.Timer(Me.components)
Me.program = New System.Windows.Forms.Panel()
Me.TextBox1 = New System.Windows.Forms.TextBox()
Me.bottomleftcorner = New System.Windows.Forms.Panel()
Me.toprightcorner = New System.Windows.Forms.Panel()
Me.bottomrightcorner = New System.Windows.Forms.Panel()
Me.topleftcorner = New System.Windows.Forms.Panel()
Me.bottom = New System.Windows.Forms.Panel()
Me.top = New System.Windows.Forms.Panel()
Me.maximizebutton = New System.Windows.Forms.PictureBox()
Me.minimizebutton = New System.Windows.Forms.PictureBox()
Me.programname = New System.Windows.Forms.Label()
Me.closebutton = New System.Windows.Forms.PictureBox()
Me.right = New System.Windows.Forms.Panel()
Me.left = New System.Windows.Forms.Panel()
Me.look = New System.Windows.Forms.Timer(Me.components)
Me.MenuStrip1.SuspendLayout()
Me.program.SuspendLayout()
Me.top.SuspendLayout()
CType(Me.maximizebutton, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.minimizebutton, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.closebutton, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'MenuStrip1
'
Me.MenuStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.FileToolStripMenuItem, Me.EditToolStripMenuItem, Me.FormatToolStripMenuItem, Me.ViewToolStripMenuItem, Me.HelpToolStripMenuItem})
Me.MenuStrip1.Location = New System.Drawing.Point(4, 30)
Me.MenuStrip1.Name = "MenuStrip1"
Me.MenuStrip1.Size = New System.Drawing.Size(444, 24)
Me.MenuStrip1.TabIndex = 6
Me.MenuStrip1.Text = "MenuStrip1"
'
'FileToolStripMenuItem
'
Me.FileToolStripMenuItem.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.NewCtrlNToolStripMenuItem, Me.OpenCtrlOToolStripMenuItem, Me.SaveCtrlSToolStripMenuItem, Me.SaveAsToolStripMenuItem, Me.PageSetupToolStripMenuItem, Me.PrintCtrlPToolStripMenuItem, Me.ExitToolStripMenuItem})
Me.FileToolStripMenuItem.Name = "FileToolStripMenuItem"
Me.FileToolStripMenuItem.Size = New System.Drawing.Size(37, 20)
Me.FileToolStripMenuItem.Text = "File"
'
'NewCtrlNToolStripMenuItem
'
Me.NewCtrlNToolStripMenuItem.Name = "NewCtrlNToolStripMenuItem"
Me.NewCtrlNToolStripMenuItem.Size = New System.Drawing.Size(176, 22)
Me.NewCtrlNToolStripMenuItem.Text = "New Ctrl+N"
'
'OpenCtrlOToolStripMenuItem
'
Me.OpenCtrlOToolStripMenuItem.Name = "OpenCtrlOToolStripMenuItem"
Me.OpenCtrlOToolStripMenuItem.Size = New System.Drawing.Size(176, 22)
Me.OpenCtrlOToolStripMenuItem.Text = "Open... Ctrl+O"
'
'SaveCtrlSToolStripMenuItem
'
Me.SaveCtrlSToolStripMenuItem.Name = "SaveCtrlSToolStripMenuItem"
Me.SaveCtrlSToolStripMenuItem.Size = New System.Drawing.Size(176, 22)
Me.SaveCtrlSToolStripMenuItem.Text = "Save Ctrl+S"
'
'SaveAsToolStripMenuItem
'
Me.SaveAsToolStripMenuItem.Name = "SaveAsToolStripMenuItem"
Me.SaveAsToolStripMenuItem.Size = New System.Drawing.Size(176, 22)
Me.SaveAsToolStripMenuItem.Text = "Save As..."
'
'PageSetupToolStripMenuItem
'
Me.PageSetupToolStripMenuItem.Name = "PageSetupToolStripMenuItem"
Me.PageSetupToolStripMenuItem.Size = New System.Drawing.Size(176, 22)
Me.PageSetupToolStripMenuItem.Text = "Page Setup..."
'
'PrintCtrlPToolStripMenuItem
'
Me.PrintCtrlPToolStripMenuItem.Name = "PrintCtrlPToolStripMenuItem"
Me.PrintCtrlPToolStripMenuItem.Size = New System.Drawing.Size(176, 22)
Me.PrintCtrlPToolStripMenuItem.Text = "Print... Ctrl+P"
'
'ExitToolStripMenuItem
'
Me.ExitToolStripMenuItem.Name = "ExitToolStripMenuItem"
Me.ExitToolStripMenuItem.Size = New System.Drawing.Size(176, 22)
Me.ExitToolStripMenuItem.Text = "Exit"
'
'EditToolStripMenuItem
'
Me.EditToolStripMenuItem.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.UndoCtrlZToolStripMenuItem, Me.CutCtrlXToolStripMenuItem, Me.CopyCtrlCToolStripMenuItem, Me.PasteCtrlVToolStripMenuItem, Me.DeleteDelToolStripMenuItem, Me.FindCtrlFToolStripMenuItem, Me.FindNextF3ToolStripMenuItem, Me.ReplaceCtrlHToolStripMenuItem, Me.GoToCtrlGToolStripMenuItem, Me.SelectAllCtrlAToolStripMenuItem, Me.TimeDateF5ToolStripMenuItem})
Me.EditToolStripMenuItem.Name = "EditToolStripMenuItem"
Me.EditToolStripMenuItem.Size = New System.Drawing.Size(39, 20)
Me.EditToolStripMenuItem.Text = "Edit"
'
'UndoCtrlZToolStripMenuItem
'
Me.UndoCtrlZToolStripMenuItem.Name = "UndoCtrlZToolStripMenuItem"
Me.UndoCtrlZToolStripMenuItem.Size = New System.Drawing.Size(172, 22)
Me.UndoCtrlZToolStripMenuItem.Text = "Undo Ctrl+Z"
'
'CutCtrlXToolStripMenuItem
'
Me.CutCtrlXToolStripMenuItem.Name = "CutCtrlXToolStripMenuItem"
Me.CutCtrlXToolStripMenuItem.Size = New System.Drawing.Size(172, 22)
Me.CutCtrlXToolStripMenuItem.Text = "Cut Ctrl+X"
'
'CopyCtrlCToolStripMenuItem
'
Me.CopyCtrlCToolStripMenuItem.Name = "CopyCtrlCToolStripMenuItem"
Me.CopyCtrlCToolStripMenuItem.Size = New System.Drawing.Size(172, 22)
Me.CopyCtrlCToolStripMenuItem.Text = "Copy Ctrl+C"
'
'PasteCtrlVToolStripMenuItem
'
Me.PasteCtrlVToolStripMenuItem.Name = "PasteCtrlVToolStripMenuItem"
Me.PasteCtrlVToolStripMenuItem.Size = New System.Drawing.Size(172, 22)
Me.PasteCtrlVToolStripMenuItem.Text = "Paste Ctrl+V"
'
'DeleteDelToolStripMenuItem
'
Me.DeleteDelToolStripMenuItem.Name = "DeleteDelToolStripMenuItem"
Me.DeleteDelToolStripMenuItem.Size = New System.Drawing.Size(172, 22)
Me.DeleteDelToolStripMenuItem.Text = "Delete Del"
'
'FindCtrlFToolStripMenuItem
'
Me.FindCtrlFToolStripMenuItem.Name = "FindCtrlFToolStripMenuItem"
Me.FindCtrlFToolStripMenuItem.Size = New System.Drawing.Size(172, 22)
Me.FindCtrlFToolStripMenuItem.Text = "Find... Ctrl+F"
'
'FindNextF3ToolStripMenuItem
'
Me.FindNextF3ToolStripMenuItem.Name = "FindNextF3ToolStripMenuItem"
Me.FindNextF3ToolStripMenuItem.Size = New System.Drawing.Size(172, 22)
Me.FindNextF3ToolStripMenuItem.Text = "Find Next F3"
'
'ReplaceCtrlHToolStripMenuItem
'
Me.ReplaceCtrlHToolStripMenuItem.Name = "ReplaceCtrlHToolStripMenuItem"
Me.ReplaceCtrlHToolStripMenuItem.Size = New System.Drawing.Size(172, 22)
Me.ReplaceCtrlHToolStripMenuItem.Text = "Replace... Ctrl+H"
'
'GoToCtrlGToolStripMenuItem
'
Me.GoToCtrlGToolStripMenuItem.Name = "GoToCtrlGToolStripMenuItem"
Me.GoToCtrlGToolStripMenuItem.Size = New System.Drawing.Size(172, 22)
Me.GoToCtrlGToolStripMenuItem.Text = "Go To... Ctrl+G"
'
'SelectAllCtrlAToolStripMenuItem
'
Me.SelectAllCtrlAToolStripMenuItem.Name = "SelectAllCtrlAToolStripMenuItem"
Me.SelectAllCtrlAToolStripMenuItem.Size = New System.Drawing.Size(172, 22)
Me.SelectAllCtrlAToolStripMenuItem.Text = "Select All Ctrl+A"
'
'TimeDateF5ToolStripMenuItem
'
Me.TimeDateF5ToolStripMenuItem.Name = "TimeDateF5ToolStripMenuItem"
Me.TimeDateF5ToolStripMenuItem.Size = New System.Drawing.Size(172, 22)
Me.TimeDateF5ToolStripMenuItem.Text = "Time/Date F5"
'
'FormatToolStripMenuItem
'
Me.FormatToolStripMenuItem.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.WordWrapToolStripMenuItem, Me.FontToolStripMenuItem})
Me.FormatToolStripMenuItem.Name = "FormatToolStripMenuItem"
Me.FormatToolStripMenuItem.Size = New System.Drawing.Size(57, 20)
Me.FormatToolStripMenuItem.Text = "Format"
'
'WordWrapToolStripMenuItem
'
Me.WordWrapToolStripMenuItem.Name = "WordWrapToolStripMenuItem"
Me.WordWrapToolStripMenuItem.Size = New System.Drawing.Size(134, 22)
Me.WordWrapToolStripMenuItem.Text = "Word Wrap"
'
'FontToolStripMenuItem
'
Me.FontToolStripMenuItem.Name = "FontToolStripMenuItem"
Me.FontToolStripMenuItem.Size = New System.Drawing.Size(134, 22)
Me.FontToolStripMenuItem.Text = "Font..."
'
'ViewToolStripMenuItem
'
Me.ViewToolStripMenuItem.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.StatusBarToolStripMenuItem})
Me.ViewToolStripMenuItem.Name = "ViewToolStripMenuItem"
Me.ViewToolStripMenuItem.Size = New System.Drawing.Size(44, 20)
Me.ViewToolStripMenuItem.Text = "View"
'
'StatusBarToolStripMenuItem
'
Me.StatusBarToolStripMenuItem.Name = "StatusBarToolStripMenuItem"
Me.StatusBarToolStripMenuItem.Size = New System.Drawing.Size(126, 22)
Me.StatusBarToolStripMenuItem.Text = "Status Bar"
'
'HelpToolStripMenuItem
'
Me.HelpToolStripMenuItem.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.HelptTopicsToolStripMenuItem, Me.AboutNotepadToolStripMenuItem})
Me.HelpToolStripMenuItem.Name = "HelpToolStripMenuItem"
Me.HelpToolStripMenuItem.Size = New System.Drawing.Size(44, 20)
Me.HelpToolStripMenuItem.Text = "Help"
'
'HelptTopicsToolStripMenuItem
'
Me.HelptTopicsToolStripMenuItem.Name = "HelptTopicsToolStripMenuItem"
Me.HelptTopicsToolStripMenuItem.Size = New System.Drawing.Size(156, 22)
Me.HelptTopicsToolStripMenuItem.Text = "Help Topics"
'
'AboutNotepadToolStripMenuItem
'
Me.AboutNotepadToolStripMenuItem.Name = "AboutNotepadToolStripMenuItem"
Me.AboutNotepadToolStripMenuItem.Size = New System.Drawing.Size(156, 22)
Me.AboutNotepadToolStripMenuItem.Text = "About Notepad"
'
'pullbs
'
Me.pullbs.Interval = 1
'
'pullbottom
'
Me.pullbottom.Interval = 1
'
'pullside
'
Me.pullside.Interval = 1
'
'program
'
Me.program.BackColor = System.Drawing.Color.OldLace
Me.program.Controls.Add(Me.TextBox1)
Me.program.Controls.Add(Me.MenuStrip1)
Me.program.Controls.Add(Me.bottomleftcorner)
Me.program.Controls.Add(Me.toprightcorner)
Me.program.Controls.Add(Me.bottomrightcorner)
Me.program.Controls.Add(Me.topleftcorner)
Me.program.Controls.Add(Me.bottom)
Me.program.Controls.Add(Me.top)
Me.program.Controls.Add(Me.right)
Me.program.Controls.Add(Me.left)
Me.program.Dock = System.Windows.Forms.DockStyle.Fill
Me.program.Location = New System.Drawing.Point(0, 0)
Me.program.Name = "program"
Me.program.Size = New System.Drawing.Size(452, 366)
Me.program.TabIndex = 9
'
'TextBox1
'
Me.TextBox1.Dock = System.Windows.Forms.DockStyle.Fill
Me.TextBox1.Location = New System.Drawing.Point(4, 54)
Me.TextBox1.Multiline = True
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.ScrollBars = System.Windows.Forms.ScrollBars.Both
Me.TextBox1.Size = New System.Drawing.Size(444, 308)
Me.TextBox1.TabIndex = 11
'
'bottomleftcorner
'
Me.bottomleftcorner.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left), System.Windows.Forms.AnchorStyles)
Me.bottomleftcorner.BackgroundImage = Global.Histacom.My.Resources.Resources.windowsxpbottomleftcorner
Me.bottomleftcorner.Location = New System.Drawing.Point(0, 362)
Me.bottomleftcorner.Name = "bottomleftcorner"
Me.bottomleftcorner.Size = New System.Drawing.Size(5, 4)
Me.bottomleftcorner.TabIndex = 10
'
'toprightcorner
'
Me.toprightcorner.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.toprightcorner.BackColor = System.Drawing.Color.Magenta
Me.toprightcorner.BackgroundImage = CType(resources.GetObject("toprightcorner.BackgroundImage"), System.Drawing.Image)
Me.toprightcorner.Location = New System.Drawing.Point(446, 0)
Me.toprightcorner.Name = "toprightcorner"
Me.toprightcorner.Size = New System.Drawing.Size(6, 30)
Me.toprightcorner.TabIndex = 9
'
'bottomrightcorner
'
Me.bottomrightcorner.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.bottomrightcorner.BackgroundImage = Global.Histacom.My.Resources.Resources.windowsxpbottomcorner
Me.bottomrightcorner.Cursor = System.Windows.Forms.Cursors.SizeNWSE
Me.bottomrightcorner.Location = New System.Drawing.Point(448, 362)
Me.bottomrightcorner.Name = "bottomrightcorner"
Me.bottomrightcorner.Size = New System.Drawing.Size(4, 4)
Me.bottomrightcorner.TabIndex = 4
'
'topleftcorner
'
Me.topleftcorner.BackColor = System.Drawing.Color.Magenta
Me.topleftcorner.BackgroundImage = CType(resources.GetObject("topleftcorner.BackgroundImage"), System.Drawing.Image)
Me.topleftcorner.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None
Me.topleftcorner.Location = New System.Drawing.Point(0, 0)
Me.topleftcorner.Name = "topleftcorner"
Me.topleftcorner.Size = New System.Drawing.Size(7, 30)
Me.topleftcorner.TabIndex = 8
'
'bottom
'
Me.bottom.BackgroundImage = Global.Histacom.My.Resources.Resources.windowsxpbottom
Me.bottom.Cursor = System.Windows.Forms.Cursors.SizeNS
Me.bottom.Dock = System.Windows.Forms.DockStyle.Bottom
Me.bottom.Location = New System.Drawing.Point(4, 362)
Me.bottom.Name = "bottom"
Me.bottom.Size = New System.Drawing.Size(444, 4)
Me.bottom.TabIndex = 3
'
'top
'
Me.top.BackColor = System.Drawing.Color.Transparent
Me.top.BackgroundImage = Global.Histacom.My.Resources.Resources.windowsxptopbarmiddle
Me.top.Controls.Add(Me.maximizebutton)
Me.top.Controls.Add(Me.minimizebutton)
Me.top.Controls.Add(Me.programname)
Me.top.Controls.Add(Me.closebutton)
Me.top.Dock = System.Windows.Forms.DockStyle.Top
Me.top.Location = New System.Drawing.Point(4, 0)
Me.top.Name = "top"
Me.top.Size = New System.Drawing.Size(444, 30)
Me.top.TabIndex = 0
'
'maximizebutton
'
Me.maximizebutton.Anchor = System.Windows.Forms.AnchorStyles.Right
Me.maximizebutton.Image = Global.Histacom.My.Resources.Resources.windowsxpmaximizebutton
Me.maximizebutton.Location = New System.Drawing.Point(396, 5)
Me.maximizebutton.Name = "maximizebutton"
Me.maximizebutton.Size = New System.Drawing.Size(21, 21)
Me.maximizebutton.TabIndex = 6
Me.maximizebutton.TabStop = False
'
'minimizebutton
'
Me.minimizebutton.Anchor = System.Windows.Forms.AnchorStyles.Right
Me.minimizebutton.Image = Global.Histacom.My.Resources.Resources.windowsxpminimizebutton
Me.minimizebutton.Location = New System.Drawing.Point(373, 5)
Me.minimizebutton.Name = "minimizebutton"
Me.minimizebutton.Size = New System.Drawing.Size(21, 21)
Me.minimizebutton.TabIndex = 5
Me.minimizebutton.TabStop = False
'
'programname
'
Me.programname.AutoSize = True
Me.programname.BackColor = System.Drawing.Color.Transparent
Me.programname.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.programname.ForeColor = System.Drawing.Color.White
Me.programname.Location = New System.Drawing.Point(5, 8)
Me.programname.Name = "programname"
Me.programname.Size = New System.Drawing.Size(55, 13)
Me.programname.TabIndex = 3
Me.programname.Text = "Notepad"
'
'closebutton
'
Me.closebutton.Anchor = System.Windows.Forms.AnchorStyles.Right
Me.closebutton.Image = Global.Histacom.My.Resources.Resources.windowsxpclosebutton
Me.closebutton.Location = New System.Drawing.Point(419, 5)
Me.closebutton.Name = "closebutton"
Me.closebutton.Size = New System.Drawing.Size(21, 21)
Me.closebutton.TabIndex = 4
Me.closebutton.TabStop = False
'
'right
'
Me.right.BackgroundImage = Global.Histacom.My.Resources.Resources.windowsxprightside
Me.right.Cursor = System.Windows.Forms.Cursors.SizeWE
Me.right.Dock = System.Windows.Forms.DockStyle.Right
Me.right.Location = New System.Drawing.Point(448, 0)
Me.right.Name = "right"
Me.right.Size = New System.Drawing.Size(4, 366)
Me.right.TabIndex = 2
'
'left
'
Me.left.BackgroundImage = Global.Histacom.My.Resources.Resources.windowsxpleftside
Me.left.Dock = System.Windows.Forms.DockStyle.Left
Me.left.Location = New System.Drawing.Point(0, 0)
Me.left.Name = "left"
Me.left.Size = New System.Drawing.Size(4, 366)
Me.left.TabIndex = 1
'
'look
'
'
'notepadxp
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(452, 366)
Me.Controls.Add(Me.program)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None
Me.MainMenuStrip = Me.MenuStrip1
Me.Name = "notepadxp"
Me.Text = "notepadxp"
Me.TopMost = True
Me.TransparencyKey = System.Drawing.Color.Magenta
Me.MenuStrip1.ResumeLayout(False)
Me.MenuStrip1.PerformLayout()
Me.program.ResumeLayout(False)
Me.program.PerformLayout()
Me.top.ResumeLayout(False)
Me.top.PerformLayout()
CType(Me.maximizebutton, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.minimizebutton, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.closebutton, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
Friend WithEvents MenuStrip1 As System.Windows.Forms.MenuStrip
Friend WithEvents FileToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents NewCtrlNToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents OpenCtrlOToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents SaveCtrlSToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents SaveAsToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents PageSetupToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents PrintCtrlPToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents ExitToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents EditToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents UndoCtrlZToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents CutCtrlXToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents CopyCtrlCToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents PasteCtrlVToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents DeleteDelToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents FindCtrlFToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents FindNextF3ToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents ReplaceCtrlHToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents GoToCtrlGToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents SelectAllCtrlAToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents TimeDateF5ToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents FormatToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents WordWrapToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents FontToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents ViewToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents StatusBarToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents HelpToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents HelptTopicsToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents AboutNotepadToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem
Friend WithEvents pullbs As System.Windows.Forms.Timer
Friend WithEvents pullbottom As System.Windows.Forms.Timer
Friend WithEvents pullside As System.Windows.Forms.Timer
Friend WithEvents program As System.Windows.Forms.Panel
Friend WithEvents bottomleftcorner As System.Windows.Forms.Panel
Friend WithEvents toprightcorner As System.Windows.Forms.Panel
Friend WithEvents bottomrightcorner As System.Windows.Forms.Panel
Friend WithEvents bottom As System.Windows.Forms.Panel
Friend WithEvents right As System.Windows.Forms.Panel
Friend WithEvents topleftcorner As System.Windows.Forms.Panel
Friend WithEvents left As System.Windows.Forms.Panel
Friend WithEvents top As System.Windows.Forms.Panel
Friend WithEvents maximizebutton As System.Windows.Forms.PictureBox
Friend WithEvents minimizebutton As System.Windows.Forms.PictureBox
Friend WithEvents programname As System.Windows.Forms.Label
Friend WithEvents closebutton As System.Windows.Forms.PictureBox
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents look As System.Windows.Forms.Timer
End Class
|
Histacom/Histacom
|
windows 95/notepadxp.Designer.vb
|
Visual Basic
|
apache-2.0
| 27,132
|
'------------------------------------------------------------------------------
' <auto-generated>
' This code was generated by a tool.
' Runtime Version:4.0.30319.34209
'
' Changes to this file may cause incorrect behavior and will be lost if
' the code is regenerated.
' </auto-generated>
'------------------------------------------------------------------------------
Option Strict On
Option Explicit On
Namespace My.Resources
'This class was auto-generated by the StronglyTypedResourceBuilder
'class via a tool like ResGen or Visual Studio.
'To add or remove a member, edit your .ResX file then rerun ResGen
'with the /str option, or rebuild your VS project.
'''<summary>
''' A strongly-typed resource class, for looking up localized strings, etc.
'''</summary>
<Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0"), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
Global.Microsoft.VisualBasic.HideModuleNameAttribute()> _
Friend Module Resources
Private resourceMan As Global.System.Resources.ResourceManager
Private resourceCulture As Global.System.Globalization.CultureInfo
'''<summary>
''' Returns the cached ResourceManager instance used by this class.
'''</summary>
<Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager
Get
If Object.ReferenceEquals(resourceMan, Nothing) Then
Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("Al_Tor.Resources", GetType(Resources).Assembly)
resourceMan = temp
End If
Return resourceMan
End Get
End Property
'''<summary>
''' Overrides the current thread's CurrentUICulture property for all
''' resource lookups using this strongly typed resource class.
'''</summary>
<Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Friend Property Culture() As Global.System.Globalization.CultureInfo
Get
Return resourceCulture
End Get
Set(ByVal value As Global.System.Globalization.CultureInfo)
resourceCulture = value
End Set
End Property
End Module
End Namespace
|
Andronew/AlTor
|
Al Tor/Al Tor/My Project/Resources.Designer.vb
|
Visual Basic
|
apache-2.0
| 2,777
|
Imports bv.common.win
Imports bv.winclient.Core
Imports bv.common.Configuration
Imports bv.common.Core
Public Class BaseTaskBarForm
Inherits BvForm
#Region "Decalrations"
Private AnimationDisabled As Boolean = False
Friend WithEvents DefaultLookAndFeel1 As DevExpress.LookAndFeel.DefaultLookAndFeel
Private Shared systemShutdown As Boolean = False
#End Region
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
Me.DefaultLookAndFeel1.LookAndFeel.SkinName = BaseSettings.SkinName '"Money Twins"
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
Me.NotifyIcon1.Dispose()
GC.Collect()
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents NotifyIcon1 As System.Windows.Forms.NotifyIcon
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(BaseTaskBarForm))
Me.NotifyIcon1 = New System.Windows.Forms.NotifyIcon(Me.components)
Me.DefaultLookAndFeel1 = New DevExpress.LookAndFeel.DefaultLookAndFeel(Me.components)
Me.SuspendLayout()
'
'NotifyIcon1
'
resources.ApplyResources(Me.NotifyIcon1, "NotifyIcon1")
'
'BaseTaskBarForm
'
resources.ApplyResources(Me, "$this")
Me.Name = "BaseTaskBarForm"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Form_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Me.ShowInTaskbar = True
End Sub
Protected Overrides Sub OnClosing(ByVal e As System.ComponentModel.CancelEventArgs)
Try
If (systemShutdown = True) Then
e.Cancel = False
Else
e.Cancel = True
'Me.AnimateWindow()
Me.Visible = False
End If
Catch ex As Exception
End Try
MyBase.OnClosing(e)
End Sub
Protected Overrides Sub OnClosed(ByVal e As System.EventArgs)
Me.NotifyIcon1.Visible = False
Me.NotifyIcon1.Icon.Dispose()
Me.NotifyIcon1.Dispose()
MyBase.OnClosed(e)
End Sub
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
' Once the program recieves WM_QUERYENDSESSION message, set the boolean systemShutdown.
If (m.Msg = WindowsAPI.WM_QUERYENDSESSION) Then
systemShutdown = True
End If
MyBase.WndProc(m)
End Sub
Private m_ForceWindowShowing As Boolean = False
Protected Sub DefaultAction(ByVal sender As Object, ByVal e As System.EventArgs) Handles NotifyIcon1.DoubleClick
ShowMe()
End Sub
Protected Sub Finish()
Application.Exit()
End Sub
Public Sub ShowMe()
If Me.Visible = False Then
m_ForceWindowShowing = True
Me.Activate()
Me.Visible = True
End If
If (Me.WindowState = FormWindowState.Minimized) Then
Me.WindowState = FormWindowState.Normal
End If
Submain.ShowNotificationForm(Me)
If PopupMessage.Instance.Visible Then
PopupMessage.Instance.Hide()
End If
End Sub
End Class
|
EIDSS/EIDSS-Legacy
|
EIDSS v6.1/vb/EIDSS/EIDSS_ClientAgent/BaseTaskBarForm.vb
|
Visual Basic
|
bsd-2-clause
| 4,201
|
Imports System.IO
Imports System.Xml.Serialization
Friend Module Glob
Property AppSettings As AppSettings
Sub LoadSettings()
AppSettings = LoadSettingsXml()
End Sub
Public Function GetSettingPath() As String
Dim logFile = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)
logFile = Path.Combine(logFile, "Services+")
If Not Directory.Exists(logFile) Then
Directory.CreateDirectory(logFile)
End If
logFile = Path.Combine(logFile, "Services+.settings.xml")
Return logFile
End Function
Private Function LoadSettingsXml() As AppSettings
If Not IO.File.Exists(GetSettingPath) Then
Return New AppSettings
End If
Try
Dim temp As New AppSettings
Using objStreamReader As New StreamReader(GetSettingPath)
Dim x As New XmlSerializer(temp.GetType)
temp = x.Deserialize(objStreamReader)
objStreamReader.Close()
End Using
Return temp
Catch ex As Exception
Modules.PushLog(ex)
Return New AppSettings
End Try
End Function
End Module
|
fakoua/ServicesPlus
|
ServicesPlus/Glob.vb
|
Visual Basic
|
bsd-3-clause
| 1,218
|
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports System.Web
Partial Public Class Caching1
' This is only required for the sample to compile
Private Cache As System.Web.Caching.Cache = Nothing
Public Sub CacheSample1()
Dim myData = "... sample returned xml data ..."
' Cache the data for 5 minutes
Cache.Insert("UniqueKey", myData, Nothing, _
DateTime.Now.AddMinutes(5), _
System.Web.Caching.Cache.NoSlidingExpiration)
' Cache the data for 5 minutes from the previous time it was accessed
Cache.Insert("UniqueKey", myData, Nothing, _
System.Web.Caching.Cache.NoAbsoluteExpiration, _
TimeSpan.FromMinutes(5))
End Sub
End Class
|
smallsharptools/SmallSharpToolsDotNet
|
YahooPack/ThirdParty/Yahoo Developer Center/VBSamples/Caching1Sample.vb
|
Visual Basic
|
apache-2.0
| 715
|
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Data
Imports System.Windows.Input
Imports ESRI.ArcGIS.Client
Imports ESRI.ArcGIS.Client.Symbols
Imports ESRI.ArcGIS.Client.Tasks
Imports ESRI.ArcGIS.Client.ValueConverters
Partial Public Class SpatialQuery
Inherits UserControl
Private MyDrawObject As Draw
Private selectionGraphicslayer As GraphicsLayer
Public Sub New()
InitializeComponent()
selectionGraphicslayer = TryCast(MyMap.Layers("MySelectionGraphicsLayer"), GraphicsLayer)
MyDrawObject = New Draw(MyMap) With {.LineSymbol = TryCast(LayoutRoot.Resources("DefaultLineSymbol"), SimpleLineSymbol), .FillSymbol = TryCast(LayoutRoot.Resources("DefaultFillSymbol"), FillSymbol)}
AddHandler MyDrawObject.DrawComplete, AddressOf MyDrawSurface_DrawComplete
End Sub
Private Sub UnSelectTools()
For Each element As UIElement In MyStackPanel.Children
If TypeOf element Is Button Then
VisualStateManager.GoToState((TryCast(element, Button)), "UnSelected", False)
End If
Next element
End Sub
Private Sub Tool_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
UnSelectTools()
VisualStateManager.GoToState(TryCast(sender, Button), "Selected", False)
Select Case TryCast((TryCast(sender, Button)).Tag, String)
Case "DrawPoint"
MyDrawObject.DrawMode = DrawMode.Point
Case "DrawPolyline"
MyDrawObject.DrawMode = DrawMode.Polyline
Case "DrawPolygon"
MyDrawObject.DrawMode = DrawMode.Polygon
Case "DrawRectangle"
MyDrawObject.DrawMode = DrawMode.Rectangle
Case "DrawFreehand"
MyDrawObject.DrawMode = DrawMode.Freehand
Case "DrawCircle"
MyDrawObject.DrawMode = DrawMode.Circle
Case "DrawEllipse"
MyDrawObject.DrawMode = DrawMode.Ellipse
Case Else
MyDrawObject.DrawMode = DrawMode.None
selectionGraphicslayer.Graphics.Clear()
QueryDetailsDataGrid.ItemsSource = Nothing
ResultsDisplay.Visibility = Visibility.Collapsed
End Select
MyDrawObject.IsEnabled = (MyDrawObject.DrawMode <> DrawMode.None)
End Sub
Private Sub MyDrawSurface_DrawComplete(ByVal sender As Object, ByVal args As ESRI.ArcGIS.Client.DrawEventArgs)
ResultsDisplay.Visibility = Visibility.Collapsed
MyDrawObject.IsEnabled = False
selectionGraphicslayer.Graphics.Clear()
Dim queryTask As New QueryTask("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/5")
AddHandler queryTask.ExecuteCompleted, AddressOf QueryTask_ExecuteCompleted
AddHandler queryTask.Failed, AddressOf QueryTask_Failed
' Bind data grid to query results
Dim resultFeaturesBinding As New Binding("LastResult.Features")
resultFeaturesBinding.Source = queryTask
QueryDetailsDataGrid.SetBinding(DataGrid.ItemsSourceProperty, resultFeaturesBinding)
Dim query As Query = New ESRI.ArcGIS.Client.Tasks.Query()
' Specify fields to return from query
query.OutFields.AddRange(New String() {"STATE_NAME", "SUB_REGION", "STATE_FIPS", "STATE_ABBR", "POP2000", "POP2007"})
query.Geometry = args.Geometry
' Return geometry with result features
query.ReturnGeometry = True
query.OutSpatialReference = MyMap.SpatialReference
queryTask.ExecuteAsync(query)
End Sub
Private Sub QueryTask_ExecuteCompleted(ByVal sender As Object, ByVal args As ESRI.ArcGIS.Client.Tasks.QueryEventArgs)
Dim featureSet As FeatureSet = args.FeatureSet
If featureSet Is Nothing OrElse featureSet.Features.Count < 1 Then
MessageBox.Show("No features returned from query")
Return
End If
If featureSet IsNot Nothing AndAlso featureSet.Features.Count > 0 Then
For Each feature As Graphic In featureSet.Features
feature.Symbol = TryCast(LayoutRoot.Resources("ResultsFillSymbol"), FillSymbol)
selectionGraphicslayer.Graphics.Insert(0, feature)
Next feature
ResultsDisplay.Visibility = Visibility.Visible
End If
MyDrawObject.IsEnabled = True
End Sub
Private Sub QueryTask_Failed(ByVal sender As Object, ByVal args As TaskFailedEventArgs)
MessageBox.Show("Query failed: " & args.Error.ToString())
MyDrawObject.IsEnabled = True
End Sub
Private Sub GraphicsLayer_MouseEnter(ByVal sender As Object, ByVal args As GraphicMouseEventArgs)
QueryDetailsDataGrid.Focus()
QueryDetailsDataGrid.SelectedItem = args.Graphic
QueryDetailsDataGrid.CurrentColumn = QueryDetailsDataGrid.Columns(0)
QueryDetailsDataGrid.ScrollIntoView(QueryDetailsDataGrid.SelectedItem, QueryDetailsDataGrid.Columns(0))
End Sub
Private Sub GraphicsLayer_MouseLeave(ByVal sender As Object, ByVal args As GraphicMouseEventArgs)
QueryDetailsDataGrid.Focus()
QueryDetailsDataGrid.SelectedItem = Nothing
End Sub
Private Sub QueryDetailsDataGrid_SelectionChanged(ByVal sender As Object, ByVal e As SelectionChangedEventArgs)
For Each g As Graphic In e.AddedItems
g.Select()
Next g
For Each g As Graphic In e.RemovedItems
g.UnSelect()
Next g
End Sub
Private Sub QueryDetailsDataGrid_LoadingRow(ByVal sender As Object, ByVal e As DataGridRowEventArgs)
AddHandler e.Row.MouseEnter, AddressOf Row_MouseEnter
AddHandler e.Row.MouseLeave, AddressOf Row_MouseLeave
End Sub
Private Sub Row_MouseEnter(ByVal sender As Object, ByVal e As MouseEventArgs)
TryCast((CType(sender, System.Windows.FrameworkElement)).DataContext, Graphic).Select()
End Sub
Private Sub Row_MouseLeave(ByVal sender As Object, ByVal e As MouseEventArgs)
Dim row As DataGridRow = TryCast(sender, DataGridRow)
Dim g As Graphic = TryCast((CType(sender, System.Windows.FrameworkElement)).DataContext, Graphic)
If Not QueryDetailsDataGrid.SelectedItems.Contains(g) Then
g.UnSelect()
End If
End Sub
End Class
|
MrChen2015/arcgis-samples-silverlight
|
src/VBNet/ArcGISSilverlightSDK/Query/SpatialQuery.xaml.vb
|
Visual Basic
|
apache-2.0
| 5,892
|
Imports bv.winclient.BasePanel
Imports bv.winclient.Core
Imports System.ComponentModel
Imports EIDSS.model.Enums
Public Class DerivativeForSampleType
Dim DerivativeForSampleTypeDbService As DerivativeForSampleType_DB
Private m_Helper As ReferenceEditorHelper
Friend WithEvents RefView As DataView
Public Sub New()
' This call is required by the Windows Form Designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
DerivativeForSampleTypeDbService = New DerivativeForSampleType_DB
DbService = DerivativeForSampleTypeDbService
AuditObject = New AuditObject(EIDSSAuditObject.daoDerivativeForSampleType, AuditTable.trtDerivativeForSampleType)
m_Helper = New ReferenceEditorHelper(DerivativeGrid, Nothing, "idfsDerivativeType", "idfsDerivativeType")
m_Helper.ReferenceTable = "DerivativeForSampleType"
m_Helper.KeyField = "idfDerivativeForSampleType"
m_Helper.MasterTable = "SampleType"
m_Helper.MasterKeyField = "idfsSampleType"
PermissionObject = eidss.model.Enums.EIDSSPermissionObject.Reference
If Not EIDSS.model.Core.EidssUserContext.User.HasPermission(PermissionHelper.DeletePermission( _
EIDSS.model.Enums.EIDSSPermissionObject.Reference)) Then
btnDelete.Enabled = False
End If
DerivativeView.OptionsView.NewItemRowPosition = DevExpress.XtraGrid.Views.Grid.NewItemRowPosition.None
AddHandler OnBeforePost, AddressOf ReferenceEditorHelper.BeforePost
End Sub
#Region "Main form interface"
Private Shared m_Parent As Control
Public Shared Sub Register(ByVal ParentControl As System.Windows.Forms.Control)
m_Parent = ParentControl
Dim category As MenuAction = MenuActionManager.Instance.FindAction("MenuConfiguration", MenuActionManager.Instance.System, 960)
Dim ma As MenuAction = New MenuAction(AddressOf ShowMe, MenuActionManager.Instance, category, "MenuDerivativeForSampleType", 971, False, model.Enums.MenuIconsSmall.ReferenceMatrix, -1)
ma.SelectPermission = PermissionHelper.SelectPermission(eidss.model.Enums.EIDSSPermissionObject.Reference)
ma.Name = "btnDerivativeForSampleType"
End Sub
Public Shared Sub ShowMe()
BaseFormManager.ShowNormal(New DerivativeForSampleType, Nothing)
'BaseForm.ShowModal(New Test_For_DiseaseDetail)
End Sub
#End Region
Protected Overrides Sub DefineBinding()
m_DoDeleteAfterNo = False
RefView = m_Helper.BindView(baseDataSet, True)
Core.LookupBinder.BindSampleLookup(cbSampleType, baseDataSet, "SampleType.idfsSampleType", True)
eventManager.AttachDataHandler("SampleType.idfsSampleType", AddressOf m_Helper.RefType_Changed)
Core.LookupBinder.BindSampleRepositoryLookup(cbDerivativeType, HACode.All, True, False)
eventManager.Cascade("SampleType.idfsSampleType")
End Sub
Public Overrides Function HasChanges() As Boolean
Return Not baseDataSet.Tables("DerivativeForSampleType").GetChanges() Is Nothing
End Function
Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click
m_Helper.DeleteRow()
End Sub
Private Sub DerivativeView_ValidateRow(ByVal sender As Object, ByVal e As DevExpress.XtraGrid.Views.Base.ValidateRowEventArgs) Handles DerivativeView.ValidateRow
m_Helper.ValidateRow(e)
End Sub
<Browsable(False), Localizable(False), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
Public Overrides Property [ReadOnly]() As Boolean
Get
Return MyBase.ReadOnly
End Get
Set(ByVal value As Boolean)
MyBase.ReadOnly = value
If value Then
btnDelete.Visible = False
Else
If Not EIDSS.model.Core.EidssUserContext.User.HasPermission(PermissionHelper.DeletePermission( _
EIDSS.model.Enums.EIDSSPermissionObject.Reference)) Then
btnDelete.Visible = True
btnDelete.Enabled = False
End If
If Not EIDSS.model.Core.EidssUserContext.User.HasPermission(PermissionHelper.InsertPermission( _
EIDSS.model.Enums.EIDSSPermissionObject.Reference)) Then
If Not RefView Is Nothing Then RefView.AllowNew = False
End If
If Not EIDSS.model.Core.EidssUserContext.User.HasPermission(PermissionHelper.UpdatePermission( _
EIDSS.model.Enums.EIDSSPermissionObject.Reference)) Then
If Not RefView Is Nothing Then RefView.AllowEdit = False
End If
End If
End Set
End Property
End Class
|
EIDSS/EIDSS-Legacy
|
EIDSS v6/vb/EIDSS/EIDSS_Admin/LookupForms/DerivativeForSampleType.vb
|
Visual Basic
|
bsd-2-clause
| 5,072
|
'*******************************************************************************************'
' '
' Download Free Evaluation Version From: https://bytescout.com/download/web-installer '
' '
' Also available as Web API! Get free API Key https://app.pdf.co/signup '
' '
' Copyright © 2017-2020 ByteScout, Inc. All rights reserved. '
' https://www.bytescout.com '
' https://www.pdf.co '
'*******************************************************************************************'
Imports System.IO
Imports Bytescout.PDFExtractor
''' <summary>
''' The example demonstrates detection of empty pages, splitting the document to separate
''' pages excluding empty ones, then combine parts back to a single document.
''' </summary>
Module Module1
Dim InputFile = ".\sample.pdf"
Dim OutputFile = ".\result.pdf"
Dim TempFolder = ".\temp"
Sub Main()
' Create and setup Bytescout.PDFExtractor.TextExtractor instance
Dim extractor As New TextExtractor("demo", "demo")
' Load PDF document
extractor.LoadDocumentFromFile(InputFile)
' List to keep non-empty page numbers
Dim nonEmptyPages = New List(Of String)()
' Iterate through pages
For pageIndex = 0 To extractor.GetPageCount() - 1
' Extract page text
Dim pageText = extractor.GetTextFromPage(pageIndex)
' If extracted text is not empty keep the page number
If pageText.Length > 0 Then
nonEmptyPages.Add((pageIndex + 1).ToString())
End If
Next
' Cleanup
extractor.Dispose()
' Form comma-separated list of page numbers to split ("1,3,5")
Dim ranges As String = String.Join(",", nonEmptyPages)
' Create Bytescout.PDFExtractor.DocumentSplitter instance
Dim splitter = new DocumentSplitter("demo", "demo")
splitter.OptimizeSplittedDocuments = true
' Split document by non-empty in temp folder
Dim parts = splitter.Split(InputFile, ranges, TempFolder)
' Cleanup
splitter.Dispose()
' Create Bytescout.PDFExtractor.DocumentMerger instance
Dim merger = New DocumentMerger("demo", "demo")
' Merge parts
merger.Merge(parts, OutputFile)
' Cleanup
merger.Dispose()
' Delete temp folder
Directory.Delete(TempFolder, true)
' Open the result file in default PDF viewer (for demo purposes)
Process.Start(OutputFile)
End Sub
End Module
|
bytescout/ByteScout-SDK-SourceCode
|
Premium Suite/VB.NET/Remove empty pages with pdf extractor sdk/Module1.vb
|
Visual Basic
|
apache-2.0
| 3,087
|
' Licensed to the .NET Foundation under one or more agreements.
' The .NET Foundation licenses this file to you under the MIT license.
' See the LICENSE file in the project root for more information.
Imports System.Threading
Imports Microsoft.CodeAnalysis.FindUsages
Imports Microsoft.CodeAnalysis.GoToBase
Imports Microsoft.CodeAnalysis.Remote.Testing
Namespace Microsoft.CodeAnalysis.Editor.UnitTests.GoToBase
Public MustInherit Class GoToBaseTestsBase
Protected Shared Async Function TestAsync(workspaceDefinition As XElement, Optional shouldSucceed As Boolean = True,
Optional metadataDefinitions As String() = Nothing) As Task
Await GoToHelpers.TestAsync(
workspaceDefinition,
testHost:=TestHost.InProcess,
Async Function(document As Document, position As Integer, context As SimpleFindUsagesContext)
Dim gotoBaseService = document.GetLanguageService(Of IGoToBaseService)
Await gotoBaseService.FindBasesAsync(context, document, position, CancellationToken.None)
End Function,
shouldSucceed, metadataDefinitions)
End Function
Protected Shared Async Function TestAsync(source As String, language As String, Optional shouldSucceed As Boolean = True,
Optional metadataDefinitions As String() = Nothing) As Task
Await TestAsync(
<Workspace>
<Project Language=<%= language %> CommonReferences="true">
<Document>
<%= source %>
</Document>
</Project>
</Workspace>,
shouldSucceed, metadataDefinitions)
End Function
End Class
End Namespace
|
CyrusNajmabadi/roslyn
|
src/EditorFeatures/Test2/GoToBase/GoToBaseTestsBase.vb
|
Visual Basic
|
mit
| 1,896
|
' Licensed to the .NET Foundation under one or more agreements.
' The .NET Foundation licenses this file to you under the MIT license.
' See the LICENSE file in the project root for more information.
Imports Microsoft.CodeAnalysis.LanguageServices
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
#If CODE_STYLE Then
Imports Microsoft.CodeAnalysis.Internal.Editing
#Else
Imports Microsoft.CodeAnalysis.Editing
#End If
Namespace Microsoft.CodeAnalysis.VisualBasic.LanguageServices
Friend Class VisualBasicAccessibilityFacts
Implements IAccessibilityFacts
Public Shared ReadOnly Instance As IAccessibilityFacts = New VisualBasicAccessibilityFacts()
Private Sub New()
End Sub
Public Function CanHaveAccessibility(declaration As SyntaxNode) As Boolean Implements IAccessibilityFacts.CanHaveAccessibility
Select Case declaration.Kind
Case SyntaxKind.ClassBlock,
SyntaxKind.ClassStatement,
SyntaxKind.StructureBlock,
SyntaxKind.StructureStatement,
SyntaxKind.InterfaceBlock,
SyntaxKind.InterfaceStatement,
SyntaxKind.EnumBlock,
SyntaxKind.EnumStatement,
SyntaxKind.ModuleBlock,
SyntaxKind.ModuleStatement,
SyntaxKind.DelegateFunctionStatement,
SyntaxKind.DelegateSubStatement,
SyntaxKind.FieldDeclaration,
SyntaxKind.FunctionBlock,
SyntaxKind.SubBlock,
SyntaxKind.FunctionStatement,
SyntaxKind.SubStatement,
SyntaxKind.PropertyBlock,
SyntaxKind.PropertyStatement,
SyntaxKind.OperatorBlock,
SyntaxKind.OperatorStatement,
SyntaxKind.EventBlock,
SyntaxKind.EventStatement,
SyntaxKind.GetAccessorBlock,
SyntaxKind.GetAccessorStatement,
SyntaxKind.SetAccessorBlock,
SyntaxKind.SetAccessorStatement,
SyntaxKind.AddHandlerAccessorBlock,
SyntaxKind.AddHandlerAccessorStatement,
SyntaxKind.RemoveHandlerAccessorBlock,
SyntaxKind.RemoveHandlerAccessorStatement,
SyntaxKind.RaiseEventAccessorBlock,
SyntaxKind.RaiseEventAccessorStatement
Return True
Case SyntaxKind.ConstructorBlock,
SyntaxKind.SubNewStatement
' Shared constructor cannot have modifiers in VB.
' Module constructors are implicitly Shared and can't have accessibility modifier.
Return Not declaration.GetModifiers().Any(SyntaxKind.SharedKeyword) AndAlso
Not declaration.Parent.IsKind(SyntaxKind.ModuleBlock)
Case SyntaxKind.ModifiedIdentifier
Return If(IsChildOf(declaration, SyntaxKind.VariableDeclarator),
CanHaveAccessibility(declaration.Parent),
False)
Case SyntaxKind.VariableDeclarator
Return If(IsChildOfVariableDeclaration(declaration),
CanHaveAccessibility(declaration.Parent),
False)
Case Else
Return False
End Select
End Function
Private Shared Function IsChildOf(node As SyntaxNode, kind As SyntaxKind) As Boolean
Return VisualBasicSyntaxFacts.IsChildOf(node, kind)
End Function
Private Shared Function IsChildOfVariableDeclaration(node As SyntaxNode) As Boolean
Return VisualBasicSyntaxFacts.IsChildOfVariableDeclaration(node)
End Function
Public Function GetAccessibility(declaration As SyntaxNode) As Accessibility Implements IAccessibilityFacts.GetAccessibility
If Not CanHaveAccessibility(declaration) Then
Return Accessibility.NotApplicable
End If
Dim tokens = GetModifierTokens(declaration)
Dim acc As Accessibility
Dim mods As DeclarationModifiers
Dim isDefault As Boolean
GetAccessibilityAndModifiers(tokens, acc, mods, isDefault)
Return acc
End Function
Public Shared Function GetModifierTokens(declaration As SyntaxNode) As SyntaxTokenList
Select Case declaration.Kind
Case SyntaxKind.ClassBlock
Return DirectCast(declaration, ClassBlockSyntax).BlockStatement.Modifiers
Case SyntaxKind.ClassStatement
Return DirectCast(declaration, ClassStatementSyntax).Modifiers
Case SyntaxKind.StructureBlock
Return DirectCast(declaration, StructureBlockSyntax).BlockStatement.Modifiers
Case SyntaxKind.StructureStatement
Return DirectCast(declaration, StructureStatementSyntax).Modifiers
Case SyntaxKind.InterfaceBlock
Return DirectCast(declaration, InterfaceBlockSyntax).BlockStatement.Modifiers
Case SyntaxKind.InterfaceStatement
Return DirectCast(declaration, InterfaceStatementSyntax).Modifiers
Case SyntaxKind.EnumBlock
Return DirectCast(declaration, EnumBlockSyntax).EnumStatement.Modifiers
Case SyntaxKind.EnumStatement
Return DirectCast(declaration, EnumStatementSyntax).Modifiers
Case SyntaxKind.ModuleBlock
Return DirectCast(declaration, ModuleBlockSyntax).ModuleStatement.Modifiers
Case SyntaxKind.ModuleStatement
Return DirectCast(declaration, ModuleStatementSyntax).Modifiers
Case SyntaxKind.DelegateFunctionStatement,
SyntaxKind.DelegateSubStatement
Return DirectCast(declaration, DelegateStatementSyntax).Modifiers
Case SyntaxKind.FieldDeclaration
Return DirectCast(declaration, FieldDeclarationSyntax).Modifiers
Case SyntaxKind.FunctionBlock,
SyntaxKind.SubBlock
Return DirectCast(declaration, MethodBlockSyntax).BlockStatement.Modifiers
Case SyntaxKind.ConstructorBlock
Return DirectCast(declaration, ConstructorBlockSyntax).BlockStatement.Modifiers
Case SyntaxKind.FunctionStatement,
SyntaxKind.SubStatement
Return DirectCast(declaration, MethodStatementSyntax).Modifiers
Case SyntaxKind.MultiLineFunctionLambdaExpression,
SyntaxKind.MultiLineSubLambdaExpression
Return DirectCast(declaration, MultiLineLambdaExpressionSyntax).SubOrFunctionHeader.Modifiers
Case SyntaxKind.SingleLineFunctionLambdaExpression,
SyntaxKind.SingleLineSubLambdaExpression
Return DirectCast(declaration, SingleLineLambdaExpressionSyntax).SubOrFunctionHeader.Modifiers
Case SyntaxKind.SubNewStatement
Return DirectCast(declaration, SubNewStatementSyntax).Modifiers
Case SyntaxKind.PropertyBlock
Return DirectCast(declaration, PropertyBlockSyntax).PropertyStatement.Modifiers
Case SyntaxKind.PropertyStatement
Return DirectCast(declaration, PropertyStatementSyntax).Modifiers
Case SyntaxKind.OperatorBlock
Return DirectCast(declaration, OperatorBlockSyntax).BlockStatement.Modifiers
Case SyntaxKind.OperatorStatement
Return DirectCast(declaration, OperatorStatementSyntax).Modifiers
Case SyntaxKind.EventBlock
Return DirectCast(declaration, EventBlockSyntax).EventStatement.Modifiers
Case SyntaxKind.EventStatement
Return DirectCast(declaration, EventStatementSyntax).Modifiers
Case SyntaxKind.ModifiedIdentifier
If IsChildOf(declaration, SyntaxKind.VariableDeclarator) Then
Return GetModifierTokens(declaration.Parent)
End If
Case SyntaxKind.LocalDeclarationStatement
Return DirectCast(declaration, LocalDeclarationStatementSyntax).Modifiers
Case SyntaxKind.VariableDeclarator
If IsChildOfVariableDeclaration(declaration) Then
Return GetModifierTokens(declaration.Parent)
End If
Case SyntaxKind.GetAccessorBlock,
SyntaxKind.SetAccessorBlock,
SyntaxKind.AddHandlerAccessorBlock,
SyntaxKind.RemoveHandlerAccessorBlock,
SyntaxKind.RaiseEventAccessorBlock
Return GetModifierTokens(DirectCast(declaration, AccessorBlockSyntax).AccessorStatement)
Case SyntaxKind.GetAccessorStatement,
SyntaxKind.SetAccessorStatement,
SyntaxKind.AddHandlerAccessorStatement,
SyntaxKind.RemoveHandlerAccessorStatement,
SyntaxKind.RaiseEventAccessorStatement
Return DirectCast(declaration, AccessorStatementSyntax).Modifiers
Case Else
Return Nothing
End Select
End Function
Public Shared Sub GetAccessibilityAndModifiers(modifierTokens As SyntaxTokenList, ByRef accessibility As Accessibility, ByRef modifiers As DeclarationModifiers, ByRef isDefault As Boolean)
accessibility = Accessibility.NotApplicable
modifiers = DeclarationModifiers.None
isDefault = False
For Each token In modifierTokens
Select Case token.Kind
Case SyntaxKind.DefaultKeyword
isDefault = True
Case SyntaxKind.PublicKeyword
accessibility = Accessibility.Public
Case SyntaxKind.PrivateKeyword
If accessibility = Accessibility.Protected Then
accessibility = Accessibility.ProtectedAndFriend
Else
accessibility = Accessibility.Private
End If
Case SyntaxKind.FriendKeyword
If accessibility = Accessibility.Protected Then
accessibility = Accessibility.ProtectedOrFriend
Else
accessibility = Accessibility.Friend
End If
Case SyntaxKind.ProtectedKeyword
If accessibility = Accessibility.Friend Then
accessibility = Accessibility.ProtectedOrFriend
ElseIf accessibility = Accessibility.Private Then
accessibility = Accessibility.ProtectedAndFriend
Else
accessibility = Accessibility.Protected
End If
Case SyntaxKind.MustInheritKeyword, SyntaxKind.MustOverrideKeyword
modifiers = modifiers Or DeclarationModifiers.Abstract
Case SyntaxKind.ShadowsKeyword
modifiers = modifiers Or DeclarationModifiers.[New]
Case SyntaxKind.OverridesKeyword
modifiers = modifiers Or DeclarationModifiers.Override
Case SyntaxKind.OverridableKeyword
modifiers = modifiers Or DeclarationModifiers.Virtual
Case SyntaxKind.SharedKeyword
modifiers = modifiers Or DeclarationModifiers.Static
Case SyntaxKind.AsyncKeyword
modifiers = modifiers Or DeclarationModifiers.Async
Case SyntaxKind.ConstKeyword
modifiers = modifiers Or DeclarationModifiers.Const
Case SyntaxKind.ReadOnlyKeyword
modifiers = modifiers Or DeclarationModifiers.ReadOnly
Case SyntaxKind.WriteOnlyKeyword
modifiers = modifiers Or DeclarationModifiers.WriteOnly
Case SyntaxKind.NotInheritableKeyword, SyntaxKind.NotOverridableKeyword
modifiers = modifiers Or DeclarationModifiers.Sealed
Case SyntaxKind.WithEventsKeyword
modifiers = modifiers Or DeclarationModifiers.WithEvents
Case SyntaxKind.PartialKeyword
modifiers = modifiers Or DeclarationModifiers.Partial
End Select
Next
End Sub
End Class
End Namespace
|
mavasani/roslyn
|
src/Workspaces/SharedUtilitiesAndExtensions/Compiler/VisualBasic/Services/SyntaxFacts/VisualBasicAccessibilityFacts.vb
|
Visual Basic
|
mit
| 13,286
|
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System.Collections.Immutable
Imports System.ComponentModel.Composition
Imports System.Threading
Imports System.Threading.Tasks
Imports Microsoft.CodeAnalysis.CodeCleanup
Imports Microsoft.CodeAnalysis.CodeCleanup.Providers
Imports Microsoft.CodeAnalysis.Formatting
Imports Microsoft.CodeAnalysis.Formatting.Rules
Imports Microsoft.CodeAnalysis.Internal.Log
Imports Microsoft.CodeAnalysis.Options
Imports Microsoft.CodeAnalysis.Text
Imports Microsoft.VisualStudio.Text
Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.LineCommit
<Export(GetType(ICommitFormatter))>
Friend Class CommitFormatter
Implements ICommitFormatter
Private Shared ReadOnly s_codeCleanupPredicate As Func(Of ICodeCleanupProvider, Boolean) =
Function(p)
Return p.Name <> PredefinedCodeCleanupProviderNames.Simplification AndAlso
p.Name <> PredefinedCodeCleanupProviderNames.Format
End Function
Public Sub CommitRegion(spanToFormat As SnapshotSpan,
isExplicitFormat As Boolean,
useSemantics As Boolean,
dirtyRegion As SnapshotSpan,
baseSnapshot As ITextSnapshot,
baseTree As SyntaxTree,
cancellationToken As CancellationToken) Implements ICommitFormatter.CommitRegion
Using (Logger.LogBlock(FunctionId.LineCommit_CommitRegion, cancellationToken))
Dim buffer = spanToFormat.Snapshot.TextBuffer
Dim currentSnapshot = buffer.CurrentSnapshot
' make sure things are current
spanToFormat = spanToFormat.TranslateTo(currentSnapshot, SpanTrackingMode.EdgeInclusive)
dirtyRegion = dirtyRegion.TranslateTo(currentSnapshot, SpanTrackingMode.EdgeInclusive)
Dim document = currentSnapshot.GetOpenDocumentInCurrentContextWithChanges()
If document Is Nothing Then
Return
End If
Dim documentOptions = document.GetOptionsAsync(cancellationToken).WaitAndGetResult(cancellationToken)
If Not (isExplicitFormat OrElse documentOptions.GetOption(FeatureOnOffOptions.PrettyListing)) Then
Return
End If
Dim textSpanToFormat = spanToFormat.Span.ToTextSpan()
If AbortForDiagnostics(document, textSpanToFormat, cancellationToken) Then
Return
End If
' create commit formatting cleanup provider that has line commit specific behavior
Dim commitFormattingCleanup = GetCommitFormattingCleanupProvider(
document,
documentOptions,
spanToFormat,
baseSnapshot, baseTree,
dirtyRegion, document.GetSyntaxTreeSynchronously(cancellationToken),
cancellationToken)
Dim codeCleanups = CodeCleaner.GetDefaultProviders(document).
WhereAsArray(s_codeCleanupPredicate).
Concat(commitFormattingCleanup)
Dim finalDocument As Document
If useSemantics OrElse isExplicitFormat Then
finalDocument = CodeCleaner.CleanupAsync(document,
textSpanToFormat,
codeCleanups,
cancellationToken).WaitAndGetResult(cancellationToken)
Else
Dim root = document.GetSyntaxRootSynchronously(cancellationToken)
Dim newRoot = CodeCleaner.CleanupAsync(root,
textSpanToFormat,
document.Project.Solution.Workspace,
codeCleanups,
cancellationToken).WaitAndGetResult(cancellationToken)
If root Is newRoot Then
finalDocument = document
Else
Dim text As SourceText = Nothing
If newRoot.SyntaxTree IsNot Nothing AndAlso newRoot.SyntaxTree.TryGetText(text) Then
finalDocument = document.WithText(text)
Else
finalDocument = document.WithSyntaxRoot(newRoot)
End If
End If
End If
finalDocument.Project.Solution.Workspace.ApplyDocumentChanges(finalDocument, cancellationToken)
End Using
End Sub
Private Function AbortForDiagnostics(document As Document, textSpanToFormat As TextSpan, cancellationToken As CancellationToken) As Boolean
Const UnterminatedStringId = "BC30648"
Dim tree = document.GetSyntaxTreeSynchronously(cancellationToken)
' If we have any unterminated strings that overlap what we're trying to format, then
' bail out. It's quite likely the unterminated string will cause a bunch of code to
' swap between real code and string literals, and committing will just cause problems.
Dim diagnostics = tree.GetDiagnostics(cancellationToken).Where(
Function(d) d.Descriptor.Id = UnterminatedStringId)
Return diagnostics.Any()
End Function
Private Function GetCommitFormattingCleanupProvider(
document As Document,
documentOptions As DocumentOptionSet,
spanToFormat As SnapshotSpan,
oldSnapshot As ITextSnapshot,
oldTree As SyntaxTree,
newDirtySpan As SnapshotSpan,
newTree As SyntaxTree,
cancellationToken As CancellationToken) As ICodeCleanupProvider
Dim oldDirtySpan = newDirtySpan.TranslateTo(oldSnapshot, SpanTrackingMode.EdgeInclusive)
' based on changes made to dirty spans, get right formatting rules to apply
Dim rules = GetFormattingRules(document, documentOptions, spanToFormat, oldDirtySpan, oldTree, newDirtySpan, newTree, cancellationToken)
Return New SimpleCodeCleanupProvider(PredefinedCodeCleanupProviderNames.Format,
Function(doc, spans, c) FormatAsync(doc, spans, rules, c),
Function(r, spans, w, c) Format(r, spans, w, document.GetOptionsAsync(c).WaitAndGetResult(c), rules, c))
End Function
Private Async Function FormatAsync(document As Document, spans As ImmutableArray(Of TextSpan), rules As IEnumerable(Of IFormattingRule), cancellationToken As CancellationToken) As Task(Of Document)
' if old text already exist, use fast path for formatting
Dim oldText As SourceText = Nothing
Dim documentOptions = Await document.GetOptionsAsync(cancellationToken).ConfigureAwait(False)
If document.TryGetText(oldText) Then
Dim root = Await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(False)
Dim newText = oldText.WithChanges(Formatter.GetFormattedTextChanges(root, spans, document.Project.Solution.Workspace, documentOptions, rules, cancellationToken))
Return document.WithText(newText)
End If
Return Await Formatter.FormatAsync(document, spans, documentOptions, rules, cancellationToken).ConfigureAwait(False)
End Function
Private Function Format(root As SyntaxNode, spans As ImmutableArray(Of TextSpan), workspace As Workspace, options As OptionSet, rules As IEnumerable(Of IFormattingRule), cancellationToken As CancellationToken) As SyntaxNode
' if old text already exist, use fast path for formatting
Dim oldText As SourceText = Nothing
If root.SyntaxTree IsNot Nothing AndAlso root.SyntaxTree.TryGetText(oldText) Then
Dim changes = Formatter.GetFormattedTextChanges(root, spans, workspace, options, rules, cancellationToken)
' no change
If changes.Count = 0 Then
Return root
End If
Return root.SyntaxTree.WithChangedText(oldText.WithChanges(changes)).GetRoot(cancellationToken)
End If
Return Formatter.Format(root, spans, workspace, options, rules, cancellationToken)
End Function
Private Function GetFormattingRules(
document As Document,
documentOptions As DocumentOptionSet,
spanToFormat As SnapshotSpan,
oldDirtySpan As SnapshotSpan,
oldTree As SyntaxTree,
newDirtySpan As SnapshotSpan,
newTree As SyntaxTree,
cancellationToken As CancellationToken) As IEnumerable(Of IFormattingRule)
' if the span we are going to format is same as the span that got changed, don't bother to do anything special.
' just do full format of the span.
If spanToFormat = newDirtySpan Then
Return Formatter.GetDefaultFormattingRules(document)
End If
If oldTree Is Nothing OrElse newTree Is Nothing Then
Return Formatter.GetDefaultFormattingRules(document)
End If
' TODO: remove this in dev14
'
' workaround for VB razor case.
' if we are under VB razor, we always use anchor operation otherwise, due to our double formatting, everything will just get messed.
' this is really a hacky workaround we should remove this in dev14
Dim formattingRuleService = document.Project.Solution.Workspace.Services.GetService(Of IHostDependentFormattingRuleFactoryService)()
If formattingRuleService IsNot Nothing Then
If formattingRuleService.ShouldUseBaseIndentation(document) Then
Return Formatter.GetDefaultFormattingRules(document)
End If
End If
' when commit formatter formats given span, it formats the span with or without anchor operations.
' the way we determine which formatting rules are used for the span is based on whether the region user has changed would change indentation
' following the dirty (committed) region. if indentation has changed, we will format with anchor operations. if not, we will format without anchor operations.
'
' for example, for the code below
'[ ]|If True And
' False Then|
' Dim a = 1
' if the [] is changed, when line commit runs, it sees indentation right after the commit (|If .. Then|) is same, so formatter will run without anchor operations,
' meaning, "False Then" will stay as it is even if "If True And" is moved due to change in []
'
' if the [] is changed to
'[ If True Then
' ]|If True And
' False Then|
' Dim a = 1
' when line commit runs, it sees that indentation after the commit is changed (due to inserted "If True Then"), so formatter runs with anchor operations,
' meaning, "False Then" will move along with "If True And"
'
' for now, do very simple checking. basically, we see whether we get same number of indent operation for the give span. alternative, but little bit
' more expensive and complex, we can actually calculate indentation right after the span, and see whether that is changed. not sure whether that much granularity
' is needed.
If GetNumberOfIndentOperations(document, documentOptions, oldTree, oldDirtySpan, cancellationToken) =
GetNumberOfIndentOperations(document, documentOptions, newTree, newDirtySpan, cancellationToken) Then
Return (New NoAnchorFormatterRule()).Concat(Formatter.GetDefaultFormattingRules(document))
End If
Return Formatter.GetDefaultFormattingRules(document)
End Function
Private Function GetNumberOfIndentOperations(document As Document,
documentOptions As DocumentOptionSet,
SyntaxTree As SyntaxTree,
Span As SnapshotSpan,
CancellationToken As CancellationToken) As Integer
' find containing statement of the end point, and use its end point as position to get indent operation
Dim containingStatement = ContainingStatementInfo.GetInfo(Span.End, SyntaxTree, CancellationToken)
Dim endPosition = If(containingStatement Is Nothing, Span.End.Position + 1, containingStatement.TextSpan.End + 1)
' get token right after given span
Dim token = SyntaxTree.GetRoot(CancellationToken).FindToken(Math.Min(endPosition, SyntaxTree.GetRoot(CancellationToken).FullSpan.End))
Dim node = token.Parent
' collect all indent operation
Dim operations = New List(Of IndentBlockOperation)()
While node IsNot Nothing
operations.AddRange(FormattingOperations.GetIndentBlockOperations(
Formatter.GetDefaultFormattingRules(document), node, optionSet:=documentOptions))
node = node.Parent
End While
' get number of indent operation that affects the token.
Return operations.Where(Function(o) o.TextSpan.Contains(token.SpanStart)).Count()
End Function
Private Class NoAnchorFormatterRule
Inherits AbstractFormattingRule
Public Overrides Sub AddAnchorIndentationOperations(list As List(Of AnchorIndentationOperation), node As SyntaxNode, optionSet As OptionSet, nextOperation As NextAction(Of AnchorIndentationOperation))
' no anchor/relative formatting
Return
End Sub
End Class
End Class
End Namespace
|
DustinCampbell/roslyn
|
src/EditorFeatures/VisualBasic/LineCommit/CommitFormatter.vb
|
Visual Basic
|
apache-2.0
| 14,915
|
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System.Collections.Immutable
Imports System.Runtime.InteropServices
Imports Microsoft.CodeAnalysis.Text
Imports Microsoft.CodeAnalysis.VisualBasic.Symbols
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Imports TypeKind = Microsoft.CodeAnalysis.TypeKind
Namespace Microsoft.CodeAnalysis.VisualBasic.CodeGen
Partial Friend Class StackScheduler
''' <summary>
''' context of expression evaluation.
''' it will affect inference of stack behavior
''' it will also affect when expressions can be dup-reused
''' Example:
''' Foo(x, ref x) x cannot be duped as it is used in different context
''' </summary>
Private Enum ExprContext
None
Sideeffects
Value
Address
AssignmentTarget
Box
End Enum
''' <summary>
''' Analyzes the tree trying to figure which locals may live on stack. It is
''' a fairly delicate process and must be very familiar with how CodeGen works.
''' It is essentially a part of CodeGen.
'''
''' NOTE: It is always safe to mark a local as not eligible as a stack local
''' so when situation gets complicated we just refuse to schedule and move on.
''' </summary>
Private NotInheritable Class Analyzer
Inherits BoundTreeRewriter
Private ReadOnly _container As Symbol
Private _counter As Integer = 0
Private ReadOnly _evalStack As ArrayBuilder(Of (expression As BoundExpression, context As ExprContext))
Private ReadOnly _debugFriendly As Boolean
Private _context As ExprContext = ExprContext.None
Private _assignmentLocal As BoundLocal = Nothing
Private ReadOnly _locals As New Dictionary(Of LocalSymbol, LocalDefUseInfo)
''' <summary>
''' fake local that represents the eval stack. when we need to ensure that eval
''' stack is not blocked by stack Locals, we record an access to empty.
''' </summary>
Private ReadOnly _empty As DummyLocal
' we need to guarantee same stack patterns at branches and labels. we do that by placing
' a fake dummy local at one end of a branch and force that it is accessible at another.
' if any stack local tries to intervene and misbalance the stack, it will clash with
' the dummy and will be rejected.
Private ReadOnly _dummyVariables As New Dictionary(Of Object, DummyLocal)
Private _recursionDepth As Integer
Private Sub New(container As Symbol,
evalStack As ArrayBuilder(Of ValueTuple(Of BoundExpression, ExprContext)),
debugFriendly As Boolean)
Me._container = container
Me._evalStack = evalStack
Me._debugFriendly = debugFriendly
Me._empty = New DummyLocal(container)
' this is the top of eval stack
DeclareLocal(_empty, 0)
RecordDummyWrite(_empty)
End Sub
Public Shared Function Analyze(
container As Symbol,
node As BoundNode,
debugFriendly As Boolean,
<Out> ByRef locals As Dictionary(Of LocalSymbol, LocalDefUseInfo)) As BoundNode
Dim evalStack = ArrayBuilder(Of ValueTuple(Of BoundExpression, ExprContext)).GetInstance()
Dim analyzer = New Analyzer(container, evalStack, debugFriendly)
Dim rewritten As BoundNode = analyzer.Visit(node)
evalStack.Free()
locals = analyzer._locals
Return rewritten
End Function
Public Overrides Function Visit(node As BoundNode) As BoundNode
Dim result As BoundNode
Dim expr = TryCast(node, BoundExpression)
If expr IsNot Nothing Then
Debug.Assert(expr.Kind <> BoundKind.Label)
result = VisitExpression(expr, ExprContext.Value)
Else
result = VisitStatement(node)
End If
Return result
End Function
Private Function VisitExpressionCore(node As BoundExpression, context As ExprContext) As BoundExpression
If node Is Nothing Then
Me._counter += 1
Return node
End If
Dim prevContext As ExprContext = Me._context
Dim prevStack As Integer = Me.StackDepth()
Me._context = context
' Don not recurse into constant expressions. Their children do Not push any values.
Dim result = If(node.ConstantValueOpt Is Nothing,
DirectCast(MyBase.Visit(node), BoundExpression),
node)
_context = prevContext
_counter += 1
Select Case context
Case ExprContext.Sideeffects
SetStackDepth(prevStack)
Case ExprContext.AssignmentTarget
Exit Select
Case ExprContext.Value, ExprContext.Address, ExprContext.Box
SetStackDepth(prevStack)
PushEvalStack(node, context)
Case Else
Throw ExceptionUtilities.UnexpectedValue(context)
End Select
Return result
End Function
Private Sub PushEvalStack(result As BoundExpression, context As ExprContext)
Debug.Assert(result IsNot Nothing OrElse context = ExprContext.None)
_evalStack.Add((result, context))
End Sub
Private Function StackDepth() As Integer
Return _evalStack.Count
End Function
Private Function EvalStackIsEmpty() As Boolean
Return StackDepth() = 0
End Function
Private Sub SetStackDepth(depth As Integer)
_evalStack.Clip(depth)
End Sub
Private Sub PopEvalStack()
SetStackDepth(_evalStack.Count - 1)
End Sub
Private Sub ClearEvalStack()
_evalStack.Clear()
End Sub
Private Function VisitExpression(node As BoundExpression, context As ExprContext) As BoundExpression
Dim result As BoundExpression
_recursionDepth += 1
If _recursionDepth > 1 Then
StackGuard.EnsureSufficientExecutionStack(_recursionDepth)
result = VisitExpressionCore(node, context)
Else
result = VisitExpressionCoreWithStackGuard(node, context)
End If
_recursionDepth -= 1
Return result
End Function
Private Function VisitExpressionCoreWithStackGuard(node As BoundExpression, context As ExprContext) As BoundExpression
Debug.Assert(_recursionDepth = 1)
Try
Dim result = VisitExpressionCore(node, context)
Debug.Assert(_recursionDepth = 1)
Return result
Catch ex As Exception When StackGuard.IsInsufficientExecutionStackException(ex)
Throw New CancelledByStackGuardException(ex, node)
End Try
End Function
Protected Overrides Function VisitExpressionWithoutStackGuard(node As BoundExpression) As BoundExpression
Throw ExceptionUtilities.Unreachable
End Function
Public Overrides Function VisitSpillSequence(node As BoundSpillSequence) As BoundNode
Throw ExceptionUtilities.Unreachable
End Function
Private Function VisitStatement(node As BoundNode) As BoundNode
Debug.Assert(node Is Nothing OrElse EvalStackIsEmpty())
Dim origStack = StackDepth()
Dim prevContext As ExprContext = Me._context
Dim result As BoundNode = MyBase.Visit(node)
' prevent cross-statement local optimizations
' when emitting debug-friendly code.
If _debugFriendly Then
EnsureOnlyEvalStack()
End If
Me._context = prevContext
SetStackDepth(origStack)
_counter += 1
Return result
End Function
''' <summary>
''' here we have a case of indirect assignment: *t1 = expr;
''' normally we would need to push t1 and that will cause spilling of t2
'''
''' TODO: an interesting case arises in unused x[i]++ and ++x[i] :
''' we have trees that look like:
'''
''' t1 = &(x[0])
''' t2 = *t1
''' *t1 = t2 + 1
'''
''' t1 = &(x[0])
''' t2 = *t1 + 1
''' *t1 = t2
'''
''' in these cases, we could keep t2 on stack (dev10 does).
''' we are dealing with exactly 2 locals and access them in strict order
''' t1, t2, t1, t2 and we are not using t2 after that.
''' We may consider detecting exactly these cases and pretend that we do not need
''' to push either t1 or t2 in this case.
''' </summary>
Private Function LhsUsesStackWhenAssignedTo(node As BoundNode, context As ExprContext) As Boolean
Debug.Assert(context = ExprContext.AssignmentTarget)
If node Is Nothing Then
Return Nothing
End If
Select Case node.Kind
Case BoundKind.Local, BoundKind.Parameter
Return False
Case BoundKind.FieldAccess
Return Not DirectCast(node, BoundFieldAccess).FieldSymbol.IsShared
Case BoundKind.Sequence
Return LhsUsesStackWhenAssignedTo(DirectCast(node, BoundSequence).ValueOpt, context)
End Select
Return True
End Function
Public Overrides Function VisitBlock(node As BoundBlock) As BoundNode
Debug.Assert(EvalStackIsEmpty(), "entering blocks when evaluation stack is not empty?")
' normally we would not allow stack locals
' when evaluation stack is not empty.
DeclareLocals(node.Locals, 0)
Return MyBase.VisitBlock(node)
End Function
Public Overrides Function VisitSequence(node As BoundSequence) As BoundNode
' Normally we can only use stack for local scheduling if stack is not used for evaluation.
' In a context of a regular block that simply means that eval stack must be empty.
' Sequences, can be entered on a nonempty evaluation stack
' Ex:
' a.b = Seq{var y, y = 1, y} // a is on the stack for the duration of the sequence.
'
' However evaluation stack at the entry cannot be used inside the sequence, so such stack
' works as effective "empty" for locals declared in sequence.
' Therefore sequence locals can be stack scheduled at same stack as at the entry to the sequence.
' it may seem attractive to relax the stack requirement to be:
' "all uses must agree on stack depth".
' The following example illustrates a case where x is safely used at "declarationStack + 1"
' Ex:
' Seq{var x; y.a = Seq{x = 1; x}; y} // x is used while y is on the eval stack
'
' It is, however not safe assumption in general since eval stack may be accessed between usages.
' Ex:
' Seq{var x; y.a = Seq{x = 1; x}; y.z = x; y} // x blocks access to y
'
'
' ---------------------------------------------------
' NOTE: The following is not implemented in VB
'
' There is one case where we want to tweak the "use at declaration stack" rule - in the case of
' compound assignment that involves ByRef operand captures (like: x[y]++ ) .
'
' Those cases produce specific sequences of the shapes:
'
' prefix: Seq{var temp, ref operand; operand initializers; *operand = Seq{temp = (T)(operand + 1); temp;} result: temp}
' postfix: Seq{var temp, ref operand; operand initializers; *operand = Seq{temp = operand; ; (T)(temp + 1);} result: temp}
'
' 1) temp is used as the result of the sequence (and that is the only reason why it is declared in the outer sequence).
' 2) all side-effects except the last one do not use the temp.
' 3) last side-effect is an indirect assignment of a sequence (and target does not involve the temp).
'
' Note that in a case of side-effects context, the result value will be ignored and therefore
' all usages of the nested temp will be confined to the nested sequence that is executed at +1 stack.
'
' We will detect such case and indicate +1 as the desired stack depth at local accesses.
' ---------------------------------------------------
'
Dim declarationStack As Integer = Me.StackDepth()
Dim locals = node.Locals
If Not locals.IsEmpty Then
If Me._context = ExprContext.Sideeffects Then
DeclareLocals(locals, declarationStack)
' ---------------------------------------------------
' NOTE: not implemented workaround from above
' foreach (var local in locals)
' {
' if (IsNestedLocalOfCompoundOperator(local, node))
' {
' // special case
' DeclareLocal(local, declarationStack + 1);
' }
' else
' {
' DeclareLocal(local, declarationStack);
' }
' }
' }
' ---------------------------------------------------
Else
DeclareLocals(locals, declarationStack)
End If
End If
' rewrite operands
Dim origContext As ExprContext = Me._context
Dim sideeffects As ImmutableArray(Of BoundExpression) = node.SideEffects
Dim rewrittenSideeffects As ArrayBuilder(Of BoundExpression) = Nothing
If Not sideeffects.IsDefault Then
For i = 0 To sideeffects.Length - 1
Dim sideeffect As BoundExpression = sideeffects(i)
Dim rewrittenSideeffect As BoundExpression = Me.VisitExpression(sideeffect, ExprContext.Sideeffects)
If rewrittenSideeffects Is Nothing AndAlso rewrittenSideeffect IsNot sideeffect Then
rewrittenSideeffects = ArrayBuilder(Of BoundExpression).GetInstance()
rewrittenSideeffects.AddRange(sideeffects, i)
End If
If rewrittenSideeffects IsNot Nothing Then
rewrittenSideeffects.Add(rewrittenSideeffect)
End If
Next
End If
Dim value As BoundExpression = Me.VisitExpression(node.ValueOpt, origContext)
Return node.Update(node.Locals,
If(rewrittenSideeffects IsNot Nothing, rewrittenSideeffects.ToImmutableAndFree(), sideeffects),
value, node.Type)
End Function
#If False Then
'// detect a pattern used in compound operators
'// where a temp is declared in the outer sequence
'// only because it must be returned, otherwise all uses are
'// confined to the nested sequence that is indirectly assigned (and therefore has +1 stack)
'// in such case the desired stack for this local is +1
'private bool IsNestedLocalOfCompoundOperator(LocalSymbol local, BoundSequence node)
'{
' var value = node.Value;
' // local must be used as the value of the sequence.
' if (value != null && value.Kind == BoundKind.Local && ((BoundLocal)value).LocalSymbol == local)
' {
' var sideeffects = node.SideEffects;
' var lastSideeffect = sideeffects.LastOrDefault();
' if (lastSideeffect != null)
' {
' // last side-effect must be an indirect assignment of a sequence.
' if (lastSideeffect.Kind == BoundKind.AssignmentOperator)
' {
' var assignment = (BoundAssignmentOperator)lastSideeffect;
' if (IsIndirectAssignment(assignment) &&
' assignment.Right.Kind == BoundKind.Sequence)
' {
' // and no other side-effects should use the variable
' var localUsedWalker = new LocalUsedWalker(local);
' for (int i = 0; i < sideeffects.Count - 1; i++)
' {
' if (localUsedWalker.IsLocalUsedIn(sideeffects[i]))
' {
' return false;
' }
' }
' // and local is not used on the left of the assignment
' // (extra check, but better be safe)
' if (localUsedWalker.IsLocalUsedIn(assignment.Left))
' {
' return false;
' }
' // it should be used somewhere
' Debug.Assert(localUsedWalker.IsLocalUsedIn(assignment.Right), "who assigns the temp?");
' return true;
' }
' }
' }
' }
' return false;
'}
'private class LocalUsedWalker : BoundTreeWalker
'{
' private readonly LocalSymbol local;
' private bool found;
' internal LocalUsedWalker(LocalSymbol local)
' {
' this.local = local;
' }
' public bool IsLocalUsedIn(BoundExpression node)
' {
' this.found = false;
' this.Visit(node);
' return found;
' }
' public override BoundNode Visit(BoundNode node)
' {
' if (!found)
' {
' return base.Visit(node);
' }
' return null;
' }
' public override BoundNode VisitLocal(BoundLocal node)
' {
' if (node.LocalSymbol == local)
' {
' this.found = true;
' }
' return null;
' }
'}
#End If
Public Overrides Function VisitExpressionStatement(node As BoundExpressionStatement) As BoundNode
Return node.Update(Me.VisitExpression(node.Expression, ExprContext.Sideeffects))
End Function
Public Overrides Function VisitLocal(node As BoundLocal) As BoundNode
If node.ConstantValueOpt Is Nothing Then
Select Case Me._context
Case ExprContext.Address
If node.LocalSymbol.IsByRef Then
RecordVarRead(node.LocalSymbol)
Else
RecordVarRef(node.LocalSymbol)
End If
Case ExprContext.AssignmentTarget
Debug.Assert(Me._assignmentLocal Is Nothing)
' actual assignment will happen later, after Right is evaluated
' just remember what we are assigning to.
Me._assignmentLocal = node
Case ExprContext.Sideeffects
' do nothing
Case ExprContext.Value,
ExprContext.Box
RecordVarRead(node.LocalSymbol)
End Select
End If
Return MyBase.VisitLocal(node)
End Function
Public Overrides Function VisitReferenceAssignment(node As BoundReferenceAssignment) As BoundNode
' Visit a local in context of regular assignment
Dim left = DirectCast(VisitExpression(node.ByRefLocal, ExprContext.AssignmentTarget), BoundLocal)
Dim storedAssignmentLocal = Me._assignmentLocal
Me._assignmentLocal = Nothing
' Visit a l-value expression in context of 'address'
Dim right As BoundExpression = VisitExpression(node.LValue, ExprContext.Address)
' record the Write to the local
Debug.Assert(storedAssignmentLocal IsNot Nothing)
' this assert will fire if code relies on implicit CLR coercions
' - i.e assigns int value to a short local.
' in that case we should force lhs to be a real local
Debug.Assert(node.ByRefLocal.Type.IsSameTypeIgnoringAll(node.LValue.Type),
"cannot use stack when assignment involves implicit coercion of the value")
RecordVarWrite(storedAssignmentLocal.LocalSymbol)
Return node.Update(left, right, node.IsLValue, node.Type)
End Function
Public Overrides Function VisitAssignmentOperator(node As BoundAssignmentOperator) As BoundNode
Dim isIndirect As Boolean = IsIndirectAssignment(node)
Dim left As BoundExpression = VisitExpression(node.Left,
If(isIndirect,
ExprContext.Address,
ExprContext.AssignmentTarget))
' must delay recording a write until after RHS is evaluated
Dim storedAssignmentLocal = Me._assignmentLocal
Me._assignmentLocal = Nothing
Debug.Assert(Me._context <> ExprContext.AssignmentTarget, "assignment expression cannot be a target of another assignment")
' Left on the right should be Nothing by this time
Debug.Assert(node.LeftOnTheRightOpt Is Nothing)
' Do not visit "Left on the right"
'Me.counter += 1
Dim rhsContext As ExprContext
If Me._context = ExprContext.Address Then
' we need the address of rhs so we cannot have it on the stack.
rhsContext = ExprContext.Address
Else
Debug.Assert(Me._context = ExprContext.Value OrElse
Me._context = ExprContext.Box OrElse
Me._context = ExprContext.Sideeffects, "assignment expression cannot be a target of another assignment")
' we only need a value of rhs, so if otherwise possible it can be a stack value.
rhsContext = ExprContext.Value
End If
Dim right As BoundExpression = node.Right
' if right is a struct ctor, it may be optimized into in-place call
' Such call will push the receiver ref before the arguments
' so we need to ensure that arguments cannot use stack temps
Dim leftType As TypeSymbol = left.Type
Dim mayPushReceiver As Boolean = False
If right.Kind = BoundKind.ObjectCreationExpression Then
Dim ctor = DirectCast(right, BoundObjectCreationExpression).ConstructorOpt
If ctor IsNot Nothing AndAlso ctor.ParameterCount <> 0 Then
mayPushReceiver = True
End If
End If
If mayPushReceiver Then
'push unknown value just to prevent access to stack locals.
PushEvalStack(Nothing, ExprContext.None)
End If
right = VisitExpression(node.Right, rhsContext)
If mayPushReceiver Then
PopEvalStack()
End If
' if assigning to a local, now it is the time to record the Write
If storedAssignmentLocal IsNot Nothing Then
' this assert will fire if code relies on implicit CLR coercions
' - i.e assigns int value to a short local.
' in that case we should force lhs to be a real local
Debug.Assert(node.Left.Type.IsSameTypeIgnoringAll(node.Right.Type),
"cannot use stack when assignment involves implicit coercion of the value")
Debug.Assert(Not isIndirect, "indirect assignment is a read, not a write")
RecordVarWrite(storedAssignmentLocal.LocalSymbol)
End If
Return node.Update(left, Nothing, right, node.SuppressObjectClone, node.Type)
End Function
''' <summary>
''' VB uses a special node to assign references.
''' BoundAssignment is used only to assign values.
''' therefore an indirect assignment may only happen if lhs is a reference
''' </summary>
Private Shared Function IsIndirectAssignment(node As BoundAssignmentOperator) As Boolean
Return IsByRefVariable(node.Left)
End Function
Private Shared Function IsByRefVariable(node As BoundExpression) As Boolean
Select Case node.Kind
Case BoundKind.Parameter
Return DirectCast(node, BoundParameter).ParameterSymbol.IsByRef
Case BoundKind.Local
Return DirectCast(node, BoundLocal).LocalSymbol.IsByRef
Case BoundKind.Call
Return DirectCast(node, BoundCall).Method.ReturnsByRef
Case BoundKind.Sequence
Debug.Assert(Not IsByRefVariable(DirectCast(node, BoundSequence).ValueOpt))
Return False
Case BoundKind.PseudoVariable
Return True
Case BoundKind.ReferenceAssignment
Return True
Case BoundKind.ValueTypeMeReference
Return True
Case BoundKind.ModuleVersionId,
BoundKind.InstrumentationPayloadRoot
' same as static fields
Return False
Case BoundKind.FieldAccess,
BoundKind.ArrayAccess
' fields are never byref
Return False
Case Else
Throw ExceptionUtilities.UnexpectedValue(node.Kind)
End Select
End Function
Private Shared Function IsVerifierRef(type As TypeSymbol) As Boolean
Return Not type.TypeKind = TypeKind.TypeParameter AndAlso type.IsReferenceType
End Function
Private Shared Function IsVerifierVal(type As TypeSymbol) As Boolean
Return Not type.TypeKind = TypeKind.TypeParameter AndAlso type.IsValueType
End Function
Public Overrides Function VisitCall(node As BoundCall) As BoundNode
Dim receiver = node.ReceiverOpt
' matches or a bit stronger than EmitReceiverRef
' if there are any doubts that receiver is a ref type,
' assume we will need an address (that will prevent scheduling of receiver).
If Not node.Method.IsShared Then
Dim receiverType = receiver.Type
Dim context As ExprContext
If receiverType.IsReferenceType Then
If (receiverType.IsTypeParameter()) Then
' type param receiver that we statically know Is a reference will be boxed
context = ExprContext.Box
Else
' reference receivers will be used as values
context = ExprContext.Value
End If
Else
' everything else will get an address taken
context = ExprContext.Address
End If
receiver = VisitExpression(receiver, context)
Else
Me._counter += 1
Debug.Assert(receiver Is Nothing OrElse receiver.Kind = BoundKind.TypeExpression)
End If
Dim method As MethodSymbol = node.Method
Dim rewrittenArguments As ImmutableArray(Of BoundExpression) = VisitArguments(node.Arguments, method.Parameters)
Debug.Assert(node.MethodGroupOpt Is Nothing)
Return node.Update(
method,
node.MethodGroupOpt,
receiver,
rewrittenArguments,
node.ConstantValueOpt,
isLValue:=node.IsLValue,
suppressObjectClone:=node.SuppressObjectClone,
type:=node.Type)
End Function
Private Function VisitArguments(arguments As ImmutableArray(Of BoundExpression), parameters As ImmutableArray(Of ParameterSymbol)) As ImmutableArray(Of BoundExpression)
Debug.Assert(Not arguments.IsDefault)
Debug.Assert(Not parameters.IsDefault)
' If this is a varargs method then there will be one additional argument for the __arglist().
Debug.Assert(arguments.Length = parameters.Length OrElse arguments.Length = parameters.Length + 1)
Dim rewrittenArguments As ArrayBuilder(Of BoundExpression) = Nothing
For i = 0 To arguments.Length - 1
' Treat the __arglist() as a value parameter.
Dim context As ExprContext = If(i = parameters.Length OrElse Not parameters(i).IsByRef, ExprContext.Value, ExprContext.Address)
Dim arg As BoundExpression = arguments(i)
Dim rewrittenArg As BoundExpression = VisitExpression(arg, context)
If rewrittenArguments Is Nothing AndAlso arg IsNot rewrittenArg Then
rewrittenArguments = ArrayBuilder(Of BoundExpression).GetInstance()
rewrittenArguments.AddRange(arguments, i)
End If
If rewrittenArguments IsNot Nothing Then
rewrittenArguments.Add(rewrittenArg)
End If
Next
Return If(rewrittenArguments IsNot Nothing, rewrittenArguments.ToImmutableAndFree, arguments)
End Function
Public Overrides Function VisitObjectCreationExpression(node As BoundObjectCreationExpression) As BoundNode
Dim constructor As MethodSymbol = node.ConstructorOpt
Debug.Assert(constructor IsNot Nothing OrElse node.Arguments.Length = 0)
Dim rewrittenArguments As ImmutableArray(Of BoundExpression) = If(constructor Is Nothing, node.Arguments,
VisitArguments(node.Arguments, constructor.Parameters))
Debug.Assert(node.InitializerOpt Is Nothing)
Me._counter += 1
Return node.Update(constructor, rewrittenArguments, Nothing, node.Type)
End Function
Public Overrides Function VisitArrayAccess(node As BoundArrayAccess) As BoundNode
' regardless of purpose, array access visits its children as values
' TODO: do we need to save/restore old context here?
Dim oldContext = Me._context
Me._context = ExprContext.Value
Dim result As BoundNode = MyBase.VisitArrayAccess(node)
Me._context = oldContext
Return result
End Function
Public Overrides Function VisitFieldAccess(node As BoundFieldAccess) As BoundNode
Dim field As FieldSymbol = node.FieldSymbol
Dim receiver As BoundExpression = node.ReceiverOpt
' if there are any doubts that receiver is a ref type, assume we will
' need an address. (that will prevent scheduling of receiver).
If Not field.IsShared Then
If receiver.Type.IsTypeParameter Then
' type parameters must be boxed to access fields.
receiver = VisitExpression(receiver, ExprContext.Box)
Else
' need address when assigning to a field and receiver is not a reference
' when accessing a field of a struct unless we only need Value and Value is preferred.
If receiver.Type.IsValueType AndAlso
(_context = ExprContext.AssignmentTarget OrElse
_context = ExprContext.Address OrElse
CodeGenerator.FieldLoadMustUseRef(receiver)) Then
receiver = VisitExpression(receiver, ExprContext.Address)
Else
receiver = VisitExpression(receiver, ExprContext.Value)
End If
End If
Else
Me._counter += 1
receiver = Nothing
End If
Return node.Update(receiver, field, node.IsLValue, node.SuppressVirtualCalls, node.ConstantsInProgressOpt, node.Type)
End Function
Public Overrides Function VisitLabelStatement(node As BoundLabelStatement) As BoundNode
RecordLabel(node.Label)
Return MyBase.VisitLabelStatement(node)
End Function
Public Overrides Function VisitGotoStatement(node As BoundGotoStatement) As BoundNode
Dim result As BoundNode = MyBase.VisitGotoStatement(node)
RecordBranch(node.Label)
Return result
End Function
Public Overrides Function VisitConditionalGoto(node As BoundConditionalGoto) As BoundNode
Dim result As BoundNode = MyBase.VisitConditionalGoto(node)
Me.PopEvalStack() ' condition gets consumed
RecordBranch(node.Label)
Return result
End Function
Public Overrides Function VisitBinaryConditionalExpression(node As BoundBinaryConditionalExpression) As BoundNode
Dim origStack = Me.StackDepth
Dim testExpression As BoundExpression = DirectCast(Me.Visit(node.TestExpression), BoundExpression)
Debug.Assert(node.ConvertedTestExpression Is Nothing)
' Me.counter += 1 '' This child is not visited
Debug.Assert(node.TestExpressionPlaceholder Is Nothing)
' Me.counter += 1 '' This child is not visited
' implicit branch here
Dim cookie As Object = GetStackStateCookie()
Me.SetStackDepth(origStack) ' else expression is evaluated with original stack
Dim elseExpression As BoundExpression = DirectCast(Me.Visit(node.ElseExpression), BoundExpression)
' implicit label here
EnsureStackState(cookie)
Return node.Update(testExpression, Nothing, Nothing, elseExpression, node.ConstantValueOpt, node.Type)
End Function
Public Overrides Function VisitTernaryConditionalExpression(node As BoundTernaryConditionalExpression) As BoundNode
Dim origStack As Integer = Me.StackDepth
Dim condition = DirectCast(Me.Visit(node.Condition), BoundExpression)
Dim cookie As Object = GetStackStateCookie() ' implicit goto here
Me.SetStackDepth(origStack) ' consequence is evaluated with original stack
Dim whenTrue = DirectCast(Me.Visit(node.WhenTrue), BoundExpression)
EnsureStackState(cookie) ' implicit label here
Me.SetStackDepth(origStack) ' alternative is evaluated with original stack
Dim whenFalse = DirectCast(Me.Visit(node.WhenFalse), BoundExpression)
EnsureStackState(cookie) ' implicit label here
Return node.Update(condition, whenTrue, whenFalse, node.ConstantValueOpt, node.Type)
End Function
Public Overrides Function VisitLoweredConditionalAccess(node As BoundLoweredConditionalAccess) As BoundNode
If Not node.ReceiverOrCondition.Type.IsBooleanType() Then
' We may need to load a reference to the receiver, or may need to
' reload it after the null check. This won't work well
' with a stack local.
EnsureOnlyEvalStack()
End If
Dim origStack = StackDepth()
Dim receiverOrCondition = DirectCast(Me.Visit(node.ReceiverOrCondition), BoundExpression)
Dim cookie = GetStackStateCookie() ' implicit branch here
' access Is evaluated with original stack
' (this Is Not entirely true, codegen will keep receiver on the stack, but that Is irrelevant here)
Me.SetStackDepth(origStack)
Dim whenNotNull = DirectCast(Me.Visit(node.WhenNotNull), BoundExpression)
EnsureStackState(cookie) ' implicit label here
Dim whenNull As BoundExpression = Nothing
If node.WhenNullOpt IsNot Nothing Then
Me.SetStackDepth(origStack)
whenNull = DirectCast(Me.Visit(node.WhenNullOpt), BoundExpression)
EnsureStackState(cookie) ' implicit label here
End If
Return node.Update(receiverOrCondition, node.CaptureReceiver, node.PlaceholderId, whenNotNull, whenNull, node.Type)
End Function
Public Overrides Function VisitConditionalAccessReceiverPlaceholder(node As BoundConditionalAccessReceiverPlaceholder) As BoundNode
Return MyBase.VisitConditionalAccessReceiverPlaceholder(node)
End Function
Public Overrides Function VisitComplexConditionalAccessReceiver(node As BoundComplexConditionalAccessReceiver) As BoundNode
EnsureOnlyEvalStack()
Dim origStack As Integer = Me.StackDepth
Me.PushEvalStack(Nothing, ExprContext.None)
Dim cookie As Object = GetStackStateCookie() ' implicit goto here
Me.SetStackDepth(origStack) ' consequence is evaluated with original stack
Dim valueTypeReceiver = DirectCast(Me.Visit(node.ValueTypeReceiver), BoundExpression)
EnsureStackState(cookie) ' implicit label here
Me.SetStackDepth(origStack) ' alternative is evaluated with original stack
Dim referenceTypeReceiver = DirectCast(Me.Visit(node.ReferenceTypeReceiver), BoundExpression)
EnsureStackState(cookie) ' implicit label here
Return node.Update(valueTypeReceiver, referenceTypeReceiver, node.Type)
End Function
Public Overrides Function VisitBinaryOperator(node As BoundBinaryOperator) As BoundNode
' Do not blow the stack due to a deep recursion on the left.
Dim child As BoundExpression = node.Left
If child.Kind <> BoundKind.BinaryOperator OrElse child.ConstantValueOpt IsNot Nothing Then
Return VisitBinaryOperatorSimple(node)
End If
Dim stack = ArrayBuilder(Of BoundBinaryOperator).GetInstance()
stack.Push(node)
Dim binary As BoundBinaryOperator = DirectCast(child, BoundBinaryOperator)
Do
stack.Push(binary)
child = binary.Left
If child.Kind <> BoundKind.BinaryOperator OrElse child.ConstantValueOpt IsNot Nothing Then
Exit Do
End If
binary = DirectCast(child, BoundBinaryOperator)
Loop
Dim prevStack As Integer = Me.StackDepth()
Dim left = DirectCast(Me.Visit(child), BoundExpression)
Do
binary = stack.Pop()
' Short-circuit operators need to emulate implicit branch/label
Dim isLogical As Boolean
Dim cookie As Object = Nothing
Select Case (binary.OperatorKind And BinaryOperatorKind.OpMask)
Case BinaryOperatorKind.AndAlso, BinaryOperatorKind.OrElse
isLogical = True
' implicit branch here
cookie = GetStackStateCookie()
Me.SetStackDepth(prevStack) ' right is evaluated with original stack
Case Else
isLogical = False
End Select
Dim right = DirectCast(Me.Visit(binary.Right), BoundExpression)
If isLogical Then
' implicit label here
EnsureStackState(cookie)
End If
Dim type As TypeSymbol = Me.VisitType(binary.Type)
left = binary.Update(binary.OperatorKind, left, right, binary.Checked, binary.ConstantValueOpt, type)
If stack.Count = 0 Then
Exit Do
End If
_counter += 1
SetStackDepth(prevStack)
PushEvalStack(node, ExprContext.Value)
Loop
Debug.Assert(binary Is node)
stack.Free()
Return left
End Function
Private Function VisitBinaryOperatorSimple(node As BoundBinaryOperator) As BoundNode
Select Case (node.OperatorKind And BinaryOperatorKind.OpMask)
Case BinaryOperatorKind.AndAlso, BinaryOperatorKind.OrElse
' Short-circuit operators need to emulate implicit branch/label
Dim origStack = Me.StackDepth
Dim left As BoundExpression = DirectCast(Me.Visit(node.Left), BoundExpression)
' implicit branch here
Dim cookie As Object = GetStackStateCookie()
Me.SetStackDepth(origStack) ' right is evaluated with original stack
Dim right As BoundExpression = DirectCast(Me.Visit(node.Right), BoundExpression)
' implicit label here
EnsureStackState(cookie)
Return node.Update(node.OperatorKind, left, right, node.Checked, node.ConstantValueOpt, node.Type)
Case Else
Return MyBase.VisitBinaryOperator(node)
End Select
End Function
Public Overrides Function VisitUnaryOperator(node As BoundUnaryOperator) As BoundNode
' checked(-x) is emitted as "0 - x"
If node.Checked AndAlso (node.OperatorKind And UnaryOperatorKind.OpMask) = UnaryOperatorKind.Minus Then
Dim storedStack = Me.StackDepth
Me.PushEvalStack(Nothing, ExprContext.None)
Dim operand = DirectCast(Me.Visit(node.Operand), BoundExpression)
Me.SetStackDepth(storedStack)
Return node.Update(node.OperatorKind, operand, node.Checked, node.ConstantValueOpt, node.Type)
Else
Return MyBase.VisitUnaryOperator(node)
End If
End Function
Public Overrides Function VisitSelectStatement(node As BoundSelectStatement) As BoundNode
' switch requires that key local stays local
EnsureOnlyEvalStack()
Dim expressionStatement As BoundExpressionStatement = DirectCast(Me.Visit(node.ExpressionStatement), BoundExpressionStatement)
If expressionStatement.Expression.Kind = BoundKind.Local Then
' It is required by code gen that if node.ExpressionStatement
' is a local it should not be optimized out
Dim local = DirectCast(expressionStatement.Expression, BoundLocal).LocalSymbol
ShouldNotSchedule(local)
End If
Dim origStack = Me.StackDepth
EnsureOnlyEvalStack()
Dim exprPlaceholderOpt As BoundRValuePlaceholder = DirectCast(Me.Visit(node.ExprPlaceholderOpt), BoundRValuePlaceholder)
' expression value is consumed by the switch
Me.SetStackDepth(origStack)
EnsureOnlyEvalStack()
' case blocks
Dim caseBlocks As ImmutableArray(Of BoundCaseBlock) = Me.VisitList(node.CaseBlocks)
' exit label
Dim exitLabel = node.ExitLabel
If exitLabel IsNot Nothing Then
Me.RecordLabel(exitLabel)
End If
EnsureOnlyEvalStack()
Return node.Update(expressionStatement, exprPlaceholderOpt, caseBlocks, node.RecommendSwitchTable, exitLabel)
End Function
Public Overrides Function VisitCaseBlock(node As BoundCaseBlock) As BoundNode
EnsureOnlyEvalStack()
Dim caseStatement As BoundCaseStatement = DirectCast(Me.Visit(node.CaseStatement), BoundCaseStatement)
EnsureOnlyEvalStack()
Dim body As BoundBlock = DirectCast(Me.Visit(node.Body), BoundBlock)
EnsureOnlyEvalStack()
Return node.Update(caseStatement, body)
End Function
Public Overrides Function VisitUnstructuredExceptionOnErrorSwitch(node As BoundUnstructuredExceptionOnErrorSwitch) As BoundNode
Dim value = DirectCast(Visit(node.Value), BoundExpression)
Me.PopEvalStack() ' value gets consumed
Return node.Update(value, Me.VisitList(node.Jumps))
End Function
Public Overrides Function VisitUnstructuredExceptionResumeSwitch(node As BoundUnstructuredExceptionResumeSwitch) As BoundNode
Dim resumeLabel = DirectCast(Visit(node.ResumeLabel), BoundLabelStatement)
Dim resumeNextLabel = DirectCast(Visit(node.ResumeNextLabel), BoundLabelStatement)
Dim resumeTargetTemporary = DirectCast(Visit(node.ResumeTargetTemporary), BoundLocal)
Me.PopEvalStack() ' value gets consumed
Return node.Update(resumeTargetTemporary, resumeLabel, resumeNextLabel, node.Jumps)
End Function
Public Overrides Function VisitTryStatement(node As BoundTryStatement) As BoundNode
EnsureOnlyEvalStack()
Dim tryBlock = DirectCast(Me.Visit(node.TryBlock), BoundBlock)
EnsureOnlyEvalStack()
Dim catchBlocks As ImmutableArray(Of BoundCatchBlock) = Me.VisitList(node.CatchBlocks)
EnsureOnlyEvalStack()
Dim finallyBlock = DirectCast(Me.Visit(node.FinallyBlockOpt), BoundBlock)
EnsureOnlyEvalStack()
If node.ExitLabelOpt IsNot Nothing Then
RecordLabel(node.ExitLabelOpt)
End If
EnsureOnlyEvalStack()
Return node.Update(tryBlock, catchBlocks, finallyBlock, node.ExitLabelOpt)
End Function
Public Overrides Function VisitCatchBlock(node As BoundCatchBlock) As BoundNode
Dim origStack As Integer = Me.StackDepth
DeclareLocal(node.LocalOpt, origStack)
EnsureOnlyEvalStack()
Dim exceptionVariableOpt As BoundExpression = Me.VisitExpression(node.ExceptionSourceOpt, ExprContext.Value)
Me.SetStackDepth(origStack)
EnsureOnlyEvalStack()
Dim errorLineNumberOpt As BoundExpression = Me.VisitExpression(node.ErrorLineNumberOpt, ExprContext.Value)
Me.SetStackDepth(origStack)
EnsureOnlyEvalStack()
Dim exceptionFilterOpt As BoundExpression = Me.VisitExpression(node.ExceptionFilterOpt, ExprContext.Value)
Me.SetStackDepth(origStack)
EnsureOnlyEvalStack()
Dim body As BoundBlock = DirectCast(Me.Visit(node.Body), BoundBlock)
EnsureOnlyEvalStack()
Return node.Update(node.LocalOpt, exceptionVariableOpt, errorLineNumberOpt, exceptionFilterOpt, body, node.IsSynthesizedAsyncCatchAll)
End Function
Public Overrides Function VisitArrayInitialization(node As BoundArrayInitialization) As BoundNode
' nontrivial construct - may use dups, metadata blob helpers etc..
EnsureOnlyEvalStack()
Dim initializers As ImmutableArray(Of BoundExpression) = node.Initializers
Dim rewrittenInitializers As ArrayBuilder(Of BoundExpression) = Nothing
If Not initializers.IsDefault Then
For i = 0 To initializers.Length - 1
' array itself will be pushed on the stack here.
EnsureOnlyEvalStack()
Dim initializer As BoundExpression = initializers(i)
Dim rewrittenInitializer As BoundExpression = Me.VisitExpression(initializer, ExprContext.Value)
If rewrittenInitializers Is Nothing AndAlso rewrittenInitializer IsNot initializer Then
rewrittenInitializers = ArrayBuilder(Of BoundExpression).GetInstance()
rewrittenInitializers.AddRange(initializers, i)
End If
If rewrittenInitializers IsNot Nothing Then
rewrittenInitializers.Add(rewrittenInitializer)
End If
Next
End If
Return node.Update(If(rewrittenInitializers IsNot Nothing, rewrittenInitializers.ToImmutableAndFree(), initializers), node.Type)
End Function
Public Overrides Function VisitReturnStatement(node As BoundReturnStatement) As BoundNode
Dim expressionOpt = TryCast(Me.Visit(node.ExpressionOpt), BoundExpression)
' must not have locals on stack when returning
EnsureOnlyEvalStack()
Return node.Update(expressionOpt, node.FunctionLocalOpt, node.ExitLabelOpt)
End Function
''' <summary>
''' Ensures that there are no stack locals. It is done by accessing
''' virtual "empty" local that is at the bottom of all stack locals.
''' </summary>
''' <remarks></remarks>
Private Sub EnsureOnlyEvalStack()
RecordVarRead(_empty)
End Sub
Private Function GetStackStateCookie() As Object
' create a dummy and start tracing it
Dim dummy As New DummyLocal(Me._container)
Me._dummyVariables.Add(dummy, dummy)
Me._locals.Add(dummy, New LocalDefUseInfo(Me.StackDepth))
RecordDummyWrite(dummy)
Return dummy
End Function
Private Sub EnsureStackState(cookie As Object)
RecordVarRead(Me._dummyVariables(cookie))
End Sub
' called on branches and labels
Private Sub RecordBranch(label As LabelSymbol)
Dim dummy As DummyLocal = Nothing
If Me._dummyVariables.TryGetValue(label, dummy) Then
RecordVarRead(dummy)
Else
' create a dummy and start tracing it
dummy = New DummyLocal(Me._container)
Me._dummyVariables.Add(label, dummy)
Me._locals.Add(dummy, New LocalDefUseInfo(Me.StackDepth))
RecordDummyWrite(dummy)
End If
End Sub
Private Sub RecordLabel(label As LabelSymbol)
Dim dummy As DummyLocal = Nothing
If Me._dummyVariables.TryGetValue(label, dummy) Then
RecordVarRead(dummy)
Else
' this is a backwards jump with nontrivial stack requirements
' just use empty.
dummy = _empty
Me._dummyVariables.Add(label, dummy)
RecordVarRead(dummy)
End If
End Sub
Private Sub RecordVarRef(local As LocalSymbol)
Debug.Assert(Not local.IsByRef, "can't tke a ref of a ref")
If Not CanScheduleToStack(local) Then
Return
End If
' if we ever take a reference of a local, it must be a real local.
ShouldNotSchedule(local)
End Sub
Private Sub RecordVarRead(local As LocalSymbol)
If Not CanScheduleToStack(local) Then
Return
End If
Dim locInfo As LocalDefUseInfo = _locals(local)
If locInfo.CannotSchedule Then
Return
End If
If locInfo.localDefs.Count = 0 Then
' reading before writing.
locInfo.ShouldNotSchedule()
Return
End If
' if accessing real val, check stack
If Not TypeOf local Is DummyLocal Then
If locInfo.StackAtDeclaration <> StackDepth() AndAlso
Not EvalStackHasLocal(local) Then
' reading at different eval stack.
locInfo.ShouldNotSchedule()
Return
End If
Else
' dummy must be accessed on same stack.
Debug.Assert(local Is _empty OrElse locInfo.StackAtDeclaration = StackDepth())
End If
Dim definedAt As LocalDefUseSpan = locInfo.localDefs.Last()
definedAt.SetEnd(Me._counter)
Dim locDef As New LocalDefUseSpan(_counter)
locInfo.localDefs.Add(locDef)
End Sub
Private Function EvalStackHasLocal(local As LocalSymbol) As Boolean
Dim top = _evalStack.Last()
Return top.context = If(Not local.IsByRef, ExprContext.Value, ExprContext.Address) AndAlso
top.expression.Kind = BoundKind.Local AndAlso
DirectCast(top.expression, BoundLocal).LocalSymbol = local
End Function
Private Sub RecordVarWrite(local As LocalSymbol)
Debug.Assert(local.SynthesizedKind <> SynthesizedLocalKind.OptimizerTemp)
If Not CanScheduleToStack(local) Then
Return
End If
Dim locInfo = _locals(local)
If locInfo.CannotSchedule Then
Return
End If
' check stack
' -1 because real assignment "consumes" value.
Dim evalStack = Me.StackDepth - 1
If locInfo.StackAtDeclaration <> evalStack Then
' writing at different eval stack.
locInfo.ShouldNotSchedule()
Return
End If
Dim locDef = New LocalDefUseSpan(Me._counter)
locInfo.localDefs.Add(locDef)
End Sub
Private Sub RecordDummyWrite(local As LocalSymbol)
Debug.Assert(local.SynthesizedKind = SynthesizedLocalKind.OptimizerTemp)
Dim locInfo = _locals(local)
' dummy must be accessed on same stack.
Debug.Assert(local Is _empty OrElse locInfo.StackAtDeclaration = StackDepth())
Dim locDef = New LocalDefUseSpan(Me._counter)
locInfo.localDefs.Add(locDef)
End Sub
Private Sub ShouldNotSchedule(local As LocalSymbol)
Dim localDefInfo As LocalDefUseInfo = Nothing
If _locals.TryGetValue(local, localDefInfo) Then
localDefInfo.ShouldNotSchedule()
End If
End Sub
Private Function CanScheduleToStack(local As LocalSymbol) As Boolean
Return local.CanScheduleToStack AndAlso
(Not _debugFriendly OrElse Not local.SynthesizedKind.IsLongLived())
End Function
Private Sub DeclareLocals(locals As ImmutableArray(Of LocalSymbol), stack As Integer)
For Each local In locals
DeclareLocal(local, stack)
Next
End Sub
Private Sub DeclareLocal(local As LocalSymbol, stack As Integer)
If local IsNot Nothing Then
If CanScheduleToStack(local) Then
Me._locals.Add(local, New LocalDefUseInfo(stack))
End If
End If
End Sub
End Class
End Class
End Namespace
|
weltkante/roslyn
|
src/Compilers/VisualBasic/Portable/CodeGen/Optimizer/StackScheduler.Analyzer.vb
|
Visual Basic
|
apache-2.0
| 60,499
|
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System.Threading.Tasks
Imports Microsoft.CodeAnalysis.Editor.UnitTests.SignatureHelp
Imports Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces
Imports Microsoft.CodeAnalysis.Editor.VisualBasic.SignatureHelp
Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.SignatureHelp
Public Class GetXmlNamespaceExpressionSignatureHelpProviderTests
Inherits AbstractVisualBasicSignatureHelpProviderTests
Public Sub New(workspaceFixture As VisualBasicTestWorkspaceFixture)
MyBase.New(workspaceFixture)
End Sub
Friend Overrides Function CreateSignatureHelpProvider() As ISignatureHelpProvider
Return New GetXmlNamespaceExpressionSignatureHelpProvider()
End Function
<Fact, Trait(Traits.Feature, Traits.Features.SignatureHelp)>
Public Async Function TestInvocationForGetType() As Task
Dim markup = <a><![CDATA[
Class C
Sub Foo()
Dim x = GetXmlNamespace($$
End Sub
End Class
]]></a>.Value
Dim expectedOrderedItems = New List(Of SignatureHelpTestItem)()
expectedOrderedItems.Add(New SignatureHelpTestItem(
$"GetXmlNamespace([{XmlNamespacePrefix}]) As System.Xml.Linq.XNamespace",
ReturnsXNamespaceObject,
XMLNSToReturnObjectFor,
currentParameterIndex:=0))
Await TestAsync(markup, expectedOrderedItems)
End Function
End Class
End Namespace
|
ValentinRueda/roslyn
|
src/EditorFeatures/VisualBasicTest/SignatureHelp/GetXmlNamespaceExpressionSignatureHelpProviderTests.vb
|
Visual Basic
|
apache-2.0
| 1,716
|
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System.Collections.Immutable
Imports System.Threading
Imports Microsoft.CodeAnalysis.Text
Imports Microsoft.CodeAnalysis.VisualBasic.Symbols
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
''' <summary>
''' This class represent a compiler generated method
''' </summary>
Friend NotInheritable Class SynthesizedDelegateMethodSymbol
Inherits MethodSymbol
Private ReadOnly _name As String
Private ReadOnly _containingType As NamedTypeSymbol
Private ReadOnly _returnType As TypeSymbol
Private ReadOnly _flags As SourceMemberFlags
Private _parameters As ImmutableArray(Of ParameterSymbol)
''' <summary>
''' Initializes a new instance of the <see cref="SynthesizedDelegateMethodSymbol" /> class. The parameters are not initialized and need to be set
''' by using the <see cref="SetParameters" /> method.
''' </summary>
''' <param name="name">The name of this method.</param>
''' <param name="containingSymbol">The containing symbol.</param>
''' <param name="flags">The flags for this method.</param>
''' <param name="returnType">The return type.</param>
Public Sub New(name As String,
containingSymbol As NamedTypeSymbol,
flags As SourceMemberFlags,
returnType As TypeSymbol)
_name = name
_containingType = containingSymbol
_flags = flags
_returnType = returnType
End Sub
''' <summary>
''' Sets the parameters.
''' </summary>
''' <param name="parameters">The parameters.</param>
''' <remarks>
''' Note: This should be called at most once, immediately after the symbol is constructed. The parameters aren't
''' Note: passed to the constructor because they need to have their container set correctly.
''' </remarks>
Friend Sub SetParameters(parameters As ImmutableArray(Of ParameterSymbol))
Debug.Assert(Not parameters.IsDefault)
Debug.Assert(_parameters.IsDefault)
_parameters = parameters
End Sub
''' <summary>
''' Returns the arity of this method, or the number of type parameters it takes.
''' A non-generic method has zero arity.
''' </summary>
Public Overrides ReadOnly Property Arity As Integer
Get
Return 0
End Get
End Property
''' <summary>
''' If this method has MethodKind of MethodKind.PropertyGet or MethodKind.PropertySet,
''' returns the property that this method is the getter or setter for.
''' If this method has MethodKind of MethodKind.EventAdd or MethodKind.EventRemove,
''' returns the event that this method is the adder or remover for.
''' </summary>
Public Overrides ReadOnly Property AssociatedSymbol As Symbol
Get
Return Nothing
End Get
End Property
''' <summary>
''' Calling convention of the signature.
''' </summary>
Friend Overrides ReadOnly Property CallingConvention As Microsoft.Cci.CallingConvention
Get
Return Microsoft.Cci.CallingConvention.HasThis
End Get
End Property
''' <summary>
''' Gets the <see cref="ISymbol" /> for the immediately containing symbol.
''' </summary>
Public Overrides ReadOnly Property ContainingSymbol As Symbol
Get
Return _containingType
End Get
End Property
Public Overrides ReadOnly Property ContainingType As NamedTypeSymbol
Get
Return _containingType
End Get
End Property
''' <summary>
''' Gets a <see cref="Accessibility" /> indicating the declared accessibility for the symbol.
''' Returns NotApplicable if no accessibility is declared.
''' </summary>
Public Overrides ReadOnly Property DeclaredAccessibility As Accessibility
Get
Return Accessibility.Public
End Get
End Property
''' <summary>
''' Returns interface methods explicitly implemented by this method.
''' </summary>
Public Overrides ReadOnly Property ExplicitInterfaceImplementations As ImmutableArray(Of MethodSymbol)
Get
Return ImmutableArray(Of MethodSymbol).Empty
End Get
End Property
''' <summary>
''' Returns true if this method is an extension method.
''' </summary>
Public Overrides ReadOnly Property IsExtensionMethod As Boolean
Get
Return False
End Get
End Property
''' <summary>
''' Gets a value indicating whether this instance is external method.
''' </summary>
''' <value>
''' <c>true</c> if this instance is external method; otherwise, <c>false</c>.
''' </value>
Public Overrides ReadOnly Property IsExternalMethod As Boolean
Get
Return True
End Get
End Property
Public Overrides Function GetDllImportData() As DllImportData
Return Nothing
End Function
Friend Overrides ReadOnly Property ReturnTypeMarshallingInformation As MarshalPseudoCustomAttributeData
Get
Return Nothing
End Get
End Property
Friend Overrides ReadOnly Property ImplementationAttributes As Reflection.MethodImplAttributes
Get
Return Reflection.MethodImplAttributes.Runtime
End Get
End Property
Friend Overrides ReadOnly Property HasDeclarativeSecurity As Boolean
Get
Return False
End Get
End Property
Friend Overrides Function GetSecurityInformation() As IEnumerable(Of Microsoft.Cci.SecurityAttribute)
Throw ExceptionUtilities.Unreachable
End Function
''' <summary>
''' Gets a value indicating whether this instance is abstract or not.
''' </summary>
''' <value>
''' <c>true</c> if this instance is abstract; otherwise, <c>false</c>.
''' </value>
Public Overrides ReadOnly Property IsMustOverride As Boolean
Get
Return False
End Get
End Property
''' <summary>
''' Gets a value indicating whether this instance is not overridable.
''' </summary>
''' <value>
''' <c>true</c> if this instance is not overridable; otherwise, <c>false</c>.
''' </value>
Public Overrides ReadOnly Property IsNotOverridable As Boolean
Get
Return False
End Get
End Property
''' <summary>
''' Gets a value indicating whether this instance is overloads.
''' </summary>
''' <value>
''' <c>true</c> if this instance is overloads; otherwise, <c>false</c>.
''' </value>
Public Overrides ReadOnly Property IsOverloads As Boolean
Get
Return False
End Get
End Property
''' <summary>
''' Gets a value indicating whether this instance is overridable.
''' </summary>
''' <value>
''' <c>true</c> if this instance is overridable; otherwise, <c>false</c>.
''' </value>
Public Overrides ReadOnly Property IsOverridable As Boolean
Get
Return (_flags And SourceMemberFlags.Overridable) <> 0
End Get
End Property
''' <summary>
''' Gets a value indicating whether this instance is overrides.
''' </summary>
''' <value>
''' <c>true</c> if this instance is overrides; otherwise, <c>false</c>.
''' </value>
Public Overrides ReadOnly Property IsOverrides As Boolean
Get
Return False
End Get
End Property
''' <summary>
''' Gets a value indicating whether this instance is shared.
''' </summary>
''' <value>
''' <c>true</c> if this instance is shared; otherwise, <c>false</c>.
''' </value>
Public Overrides ReadOnly Property IsShared As Boolean
Get
Return False
End Get
End Property
''' <summary>
''' Gets a value indicating whether this instance is a sub.
''' </summary>
''' <value>
''' <c>true</c> if this instance is sub; otherwise, <c>false</c>.
''' </value>
Public Overrides ReadOnly Property IsSub As Boolean
Get
Return _returnType.SpecialType = SpecialType.System_Void
End Get
End Property
Public Overrides ReadOnly Property IsAsync As Boolean
Get
Return False
End Get
End Property
Public Overrides ReadOnly Property IsIterator As Boolean
Get
Return False
End Get
End Property
''' <summary>
''' Gets a value indicating whether this instance is vararg.
''' </summary>
''' <value>
''' <c>true</c> if this instance is vararg; otherwise, <c>false</c>.
''' </value>
Public Overrides ReadOnly Property IsVararg As Boolean
Get
Return False
End Get
End Property
Friend Overrides Function GetLexicalSortKey() As LexicalSortKey
Return _containingType.GetLexicalSortKey()
End Function
''' <summary>
''' A potentially empty collection of locations that correspond to this instance.
''' </summary>
Public Overrides ReadOnly Property Locations As ImmutableArray(Of Location)
Get
Return _containingType.Locations
End Get
End Property
Public Overrides ReadOnly Property DeclaringSyntaxReferences As ImmutableArray(Of SyntaxReference)
Get
Return ImmutableArray(Of SyntaxReference).Empty
End Get
End Property
''' <summary>
''' Gets what kind of method this is. There are several different kinds of things in the
''' VB language that are represented as methods. This property allow distinguishing those things
''' without having to decode the name of the method.
''' </summary>
Public Overrides ReadOnly Property MethodKind As MethodKind
Get
Return _flags.ToMethodKind()
End Get
End Property
Friend Overrides ReadOnly Property IsMethodKindBasedOnSyntax As Boolean
Get
Return False
End Get
End Property
''' <summary>
''' The parameters forming part of this signature.
''' </summary>
Public Overrides ReadOnly Property Parameters As ImmutableArray(Of ParameterSymbol)
Get
If Not _parameters.IsDefault Then
Return _parameters
Else
Return ImmutableArray(Of ParameterSymbol).Empty
End If
End Get
End Property
Public Overrides ReadOnly Property ReturnsByRef As Boolean
Get
Return False
End Get
End Property
''' <summary>
''' Gets the return type of the method.
''' </summary>
Public Overrides ReadOnly Property ReturnType As TypeSymbol
Get
Return _returnType
End Get
End Property
''' <summary>
''' Returns the list of attributes, if any, associated with the return type.
''' </summary>
Public Overrides Function GetReturnTypeAttributes() As ImmutableArray(Of VisualBasicAttributeData)
Return ImmutableArray(Of VisualBasicAttributeData).Empty
End Function
''' <summary>
''' Returns the list of custom modifiers, if any, associated with the returned value.
''' </summary>
Public Overrides ReadOnly Property ReturnTypeCustomModifiers As ImmutableArray(Of CustomModifier)
Get
Return ImmutableArray(Of CustomModifier).Empty
End Get
End Property
Public Overrides ReadOnly Property RefCustomModifiers As ImmutableArray(Of CustomModifier)
Get
Return ImmutableArray(Of CustomModifier).Empty
End Get
End Property
''' <summary>
''' Returns the type arguments that have been substituted for the type parameters.
''' If nothing has been substituted for a given type parameter,
''' then the type parameter itself is consider the type argument.
''' </summary>
Public Overrides ReadOnly Property TypeArguments As ImmutableArray(Of TypeSymbol)
Get
Return ImmutableArray(Of TypeSymbol).Empty
End Get
End Property
''' <summary>
''' Get the type parameters on this method. If the method has not generic,
''' returns an empty list.
''' </summary>
Public Overrides ReadOnly Property TypeParameters As ImmutableArray(Of TypeParameterSymbol)
Get
Return ImmutableArray(Of TypeParameterSymbol).Empty
End Get
End Property
''' <summary>
''' Gets a value indicating whether the symbol was generated by the compiler
''' rather than declared explicitly.
''' </summary>
Public Overrides ReadOnly Property IsImplicitlyDeclared As Boolean
Get
Return True
End Get
End Property
''' <summary>
''' Gets the symbol name. Returns the empty string if unnamed.
''' </summary>
Public Overrides ReadOnly Property Name As String
Get
Return _name
End Get
End Property
Friend Overrides ReadOnly Property HasSpecialName As Boolean
Get
Return Me.MethodKind = MethodKind.Constructor
End Get
End Property
Friend Overrides Function GetAppliedConditionalSymbols() As ImmutableArray(Of String)
Return ImmutableArray(Of String).Empty
End Function
Friend Overrides ReadOnly Property Syntax As SyntaxNode
Get
Return Nothing ' The methods are runtime implemented
End Get
End Property
Friend Overrides ReadOnly Property ObsoleteAttributeData As ObsoleteAttributeData
Get
Return Nothing
End Get
End Property
Friend Overrides Sub AddSynthesizedAttributes(compilationState As ModuleCompilationState, ByRef attributes As ArrayBuilder(Of SynthesizedAttributeData))
MyBase.AddSynthesizedAttributes(compilationState, attributes)
' Dev11 emits DebuggerNonUserCodeAttribute on methods of anon delegates but not of user defined delegates.
' In both cases the debugger hides these methods so no attribute is necessary.
' We expect other tools to also special case delegate methods.
End Sub
Friend Overrides ReadOnly Property GenerateDebugInfoImpl As Boolean
Get
Return False
End Get
End Property
Friend Overrides Function CalculateLocalSyntaxOffset(localPosition As Integer, localTree As SyntaxTree) As Integer
Throw ExceptionUtilities.Unreachable
End Function
End Class
End Namespace
|
weltkante/roslyn
|
src/Compilers/VisualBasic/Portable/Symbols/SynthesizedSymbols/SynthesizedDelegateMethodSymbol.vb
|
Visual Basic
|
apache-2.0
| 16,139
|
' Licensed to the .NET Foundation under one or more agreements.
' The .NET Foundation licenses this file to you under the MIT license.
' See the LICENSE file in the project root for more information.
Namespace Microsoft.CodeAnalysis.VisualBasic.Utilities.IntrinsicOperators
Friend NotInheritable Class BinaryConditionalExpressionDocumentation
Inherits AbstractIntrinsicOperatorDocumentation
Public Overrides ReadOnly Property DocumentationText As String
Get
Return VBWorkspaceResources.If_expression_evaluates_to_a_reference_or_Nullable_value_that_is_not_Nothing_the_function_returns_that_value_Otherwise_it_calculates_and_returns_expressionIfNothing
End Get
End Property
Public Overrides Function GetParameterDocumentation(index As Integer) As String
Select Case index
Case 0
Return VBWorkspaceResources.Returned_if_it_evaluates_to_a_reference_or_nullable_type_that_is_not_Nothing
Case 1
Return VBWorkspaceResources.Evaluated_and_returned_if_expression_evaluates_to_Nothing
Case Else
Throw New ArgumentException(NameOf(index))
End Select
End Function
Public Overrides Function GetParameterName(index As Integer) As String
Select Case index
Case 0
Return VBWorkspaceResources.expression
Case 1
Return VBWorkspaceResources.expressionIfNothing
Case Else
Throw New ArgumentException(NameOf(index))
End Select
End Function
Public Overrides ReadOnly Property IncludeAsType As Boolean
Get
Return True
End Get
End Property
Public Overrides ReadOnly Property ParameterCount As Integer
Get
Return 2
End Get
End Property
Public Overrides ReadOnly Property PrefixParts As IList(Of SymbolDisplayPart)
Get
Return {New SymbolDisplayPart(SymbolDisplayPartKind.Keyword, Nothing, "If"),
New SymbolDisplayPart(SymbolDisplayPartKind.Punctuation, Nothing, "(")}
End Get
End Property
End Class
End Namespace
|
physhi/roslyn
|
src/Workspaces/VisualBasic/Portable/Utilities/IntrinsicOperators/BinaryConditionalExpressionDocumentation.vb
|
Visual Basic
|
apache-2.0
| 2,357
|
Imports System
Imports System.Collections.Generic
Imports System.Runtime.InteropServices
Namespace Examples
Friend Class Program
<STAThread>
Shared Sub Main(ByVal args() As String)
Dim application As SolidEdgeFramework.Application = Nothing
Dim documents As SolidEdgeFramework.Documents = Nothing
Dim partDocument As SolidEdgePart.PartDocument = Nothing
Dim refPlanes As SolidEdgePart.RefPlanes = Nothing
Dim profileSets As SolidEdgePart.ProfileSets = Nothing
Dim profileSet As SolidEdgePart.ProfileSet = Nothing
Dim profiles As SolidEdgePart.Profiles = Nothing
Dim profile As SolidEdgePart.Profile = Nothing
Dim ellipses2d As SolidEdgeFrameworkSupport.Ellipses2d = Nothing
Dim ellipse2d As SolidEdgeFrameworkSupport.Ellipse2d = Nothing
Try
' See "Handling 'Application is Busy' and 'Call was Rejected By Callee' errors" topic.
OleMessageFilter.Register()
' Attempt to connect to a running instance of Solid Edge.
application = DirectCast(Marshal.GetActiveObject("SolidEdge.Application"), SolidEdgeFramework.Application)
documents = application.Documents
partDocument = CType(documents.Add("SolidEdge.PartDocument"), SolidEdgePart.PartDocument)
refPlanes = partDocument.RefPlanes
profileSets = partDocument.ProfileSets
profileSet = profileSets.Add()
profiles = profileSet.Profiles
profile = profiles.Add(refPlanes.Item(1))
ellipses2d = profile.Ellipses2d
Dim Orientation = SolidEdgeFrameworkSupport.Geom2dOrientationConstants.igGeom2dOrientClockwise
ellipse2d = ellipses2d.AddByCenter(0, 0, 0.01, 0, 0.5, Orientation)
ellipse2d.SetMajorAxis(0.1, 0)
Catch ex As System.Exception
Console.WriteLine(ex)
Finally
OleMessageFilter.Unregister()
End Try
End Sub
End Class
End Namespace
|
SolidEdgeCommunity/docs
|
docfx_project/snippets/SolidEdgeFrameworkSupport.Ellipse2d.SetMajorAxis.vb
|
Visual Basic
|
mit
| 2,158
|
Imports System.ComponentModel.Composition
Imports DevExpress.CodeRush.Common
<Export(GetType(IVsixPluginExtension))> _
Public Class CR_ToDoTabberExtension
Implements IVsixPluginExtension
End Class
|
RoryBecker/CR_TodoTabber
|
CR_ToDoTabber/CR_ToDoTabberExtension.vb
|
Visual Basic
|
mit
| 202
|
Public Class screenLoad
Private Sub screenLoad_Load(sender As Object, e As EventArgs) Handles Me.Load
Timer.Enabled = True
End Sub
Private Sub Timer_Tick(sender As Object, e As EventArgs) Handles Timer.Tick
My.Computer.Audio.Play(My.Resources.BatmanOpening, AudioPlayMode.WaitToComplete)
screenHome.Show()
Timer.Enabled = False
End Sub
End Class
|
OtherBarry/SDaD
|
BatMath/BatMath/screenLoad.vb
|
Visual Basic
|
mit
| 398
|
Imports Utilities
Imports InfoSoftGlobal
Partial Class ArrayExample_SingleSeries
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
' Generate chart in Literal Control
FCLiteral.Text = CreateChart()
End Sub
Public Function CreateChart() As String
'In this example, we plot a single series chart from data contained
'in an array. The array will have two columns - first one for data label
'and the next one for data values.
'Let's store the sales data for 6 products in our array). We also store
'the name of products.
Dim arrData(6, 2) As String
' Creating util Object
Dim util As New Util()
'Store Name of Products
arrData(0, 1) = "Product A"
arrData(1, 1) = "Product B"
arrData(2, 1) = "Product C"
arrData(3, 1) = "Product D"
arrData(4, 1) = "Product E"
arrData(5, 1) = "Product F"
'Store sales data
arrData(0, 2) = "567500"
arrData(1, 2) = "815300"
arrData(2, 2) = "556800"
arrData(3, 2) = "734500"
arrData(4, 2) = "676800"
arrData(5, 2) = "648500"
'Now, we need to convert this data into XML. We convert using string concatenation.
Dim strXML As String, i As Integer
'Initialize <graph> element
strXML = "<graph caption='Sales by Product' numberPrefix='$' formatNumberScale='0' decimalPrecision='0'>"
'Convert data to XML and append
For i = 0 To UBound(arrData) - 1
'add values using <set name='...' value='...' color='...'/>
strXML = strXML & "<set name='" & arrData(i, 1) & "' value='" & arrData(i, 2) & "' color='" & util.getFCColor() & "' />"
Next
'Close <graph> element
strXML = strXML & "</graph>"
'Create the chart - Column 3D Chart with data contained in strXML
Return FusionCharts.RenderChart("../FusionCharts/FCF_Column3D.swf", "", strXML, "productSales", "600", "300", False, False)
End Function
End Class
|
sigaind/cupon
|
web/bundles/sigaind/FusionChartsFree/Code/VBNET/ArrayExample/SingleSeries.aspx.vb
|
Visual Basic
|
mit
| 2,133
|
'------------------------------------------------------------------------------
' <auto-generated>
' This code was generated by a tool.
' Runtime Version:4.0.30319.18331
'
' Changes to this file may cause incorrect behavior and will be lost if
' the code is regenerated.
' </auto-generated>
'------------------------------------------------------------------------------
Option Strict On
Option Explicit On
Namespace My
<Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0"), _
Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Partial Friend NotInheritable Class MySettings
Inherits Global.System.Configuration.ApplicationSettingsBase
Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings), MySettings)
#Region "My.Settings Auto-Save Functionality"
#If _MyType = "WindowsForms" Then
Private Shared addedHandler As Boolean
Private Shared addedHandlerLockObject As New Object
<Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs)
If My.Application.SaveMySettingsOnExit Then
My.Settings.Save()
End If
End Sub
#End If
#End Region
Public Shared ReadOnly Property [Default]() As MySettings
Get
#If _MyType = "WindowsForms" Then
If Not addedHandler Then
SyncLock addedHandlerLockObject
If Not addedHandler Then
AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings
addedHandler = True
End If
End SyncLock
End If
#End If
Return defaultInstance
End Get
End Property
End Class
End Namespace
Namespace My
<Global.Microsoft.VisualBasic.HideModuleNameAttribute(), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute()> _
Friend Module MySettingsProperty
<Global.System.ComponentModel.Design.HelpKeywordAttribute("My.Settings")> _
Friend ReadOnly Property Settings() As Global.VBFindConversation.My.MySettings
Get
Return Global.VBFindConversation.My.MySettings.Default
End Get
End Property
End Module
End Namespace
|
age-killer/Electronic-invoice-document-processing
|
MailSort_CSHARP/packages/Independentsoft.Exchange.3.0.400/Tutorial/VBFindConversation/My Project/Settings.Designer.vb
|
Visual Basic
|
mit
| 2,942
|
#Region "Microsoft.VisualBasic::e5aec44abf7cc5ea1f166ce43b970ceb, src\metadb\Massbank\MetaLib\Match\SynonymIndex.vb"
' Author:
'
' xieguigang (gg.xie@bionovogene.com, BioNovoGene Co., LTD.)
'
' Copyright (c) 2018 gg.xie@bionovogene.com, BioNovoGene Co., LTD.
'
'
' MIT License
'
'
' Permission is hereby granted, free of charge, to any person obtaining a copy
' of this software and associated documentation files (the "Software"), to deal
' in the Software without restriction, including without limitation the rights
' to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
' copies of the Software, and to permit persons to whom the Software is
' furnished to do so, subject to the following conditions:
'
' The above copyright notice and this permission notice shall be included in all
' copies or substantial portions of the Software.
'
' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
' IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
' FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
' AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
' LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
' OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
' SOFTWARE.
' /********************************************************************************/
' Summaries:
' Interface ICompoundNames
'
' Function: GetSynonym
'
' Class SynonymIndex
'
' Constructor: (+1 Overloads) Sub New
'
' Function: BuildIndex, (+2 Overloads) FindCandidateCompounds, GetEnumerator, IEnumerable_GetEnumerator
'
' Sub: Add
'
'
' /********************************************************************************/
#End Region
Imports System.Runtime.CompilerServices
Imports Microsoft.VisualBasic.Data.Trinity
Imports Microsoft.VisualBasic.Linq
Namespace MetaLib
Public Interface ICompoundNames
Function GetSynonym() As IEnumerable(Of String)
End Interface
Public Class SynonymIndex(Of T As ICompoundNames) : Implements IEnumerable(Of T)
ReadOnly bin As WordSimilarityIndex(Of T)
Sub New(Optional equalsName As Double = 0.9)
bin = New WordSimilarityIndex(Of T)(New WordSimilarity(equalsName))
End Sub
Public Sub Add(compound As T)
For Each name As String In compound.GetSynonym
If Not bin.HaveKey(name) Then
Call bin.AddTerm(name, compound)
Else
Call $"{name} ({compound})".Warning
End If
Next
End Sub
Public Function BuildIndex(compounds As IEnumerable(Of T)) As SynonymIndex(Of T)
For Each compound As T In compounds
Call Add(compound)
Next
Return Me
End Function
<MethodImpl(MethodImplOptions.AggressiveInlining)>
Public Function FindCandidateCompounds(name As String) As IEnumerable(Of T)
Return bin.FindMatches(name)
End Function
<MethodImpl(MethodImplOptions.AggressiveInlining)>
Public Function FindCandidateCompounds(names As IEnumerable(Of String)) As IEnumerable(Of T)
Return names.Distinct.Select(Function(name) bin.FindMatches(name)).IteratesALL
End Function
Public Iterator Function GetEnumerator() As IEnumerator(Of T) Implements IEnumerable(Of T).GetEnumerator
For Each item As T In bin.AllValues
Yield item
Next
End Function
Private Iterator Function IEnumerable_GetEnumerator() As IEnumerator Implements IEnumerable.GetEnumerator
Yield GetEnumerator()
End Function
End Class
End Namespace
|
xieguigang/spectrum
|
src/metadb/Massbank/MetaLib/Match/SynonymIndex.vb
|
Visual Basic
|
mit
| 4,018
|
'------------------------------------------------------------------------------
' <auto-generated>
' This code was generated by a tool.
' Runtime Version:4.0.30319.34014
'
' Changes to this file may cause incorrect behavior and will be lost if
' the code is regenerated.
' </auto-generated>
'------------------------------------------------------------------------------
Option Strict On
Option Explicit On
Namespace My
<Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0"), _
Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Partial Friend NotInheritable Class MySettings
Inherits Global.System.Configuration.ApplicationSettingsBase
Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings), MySettings)
#Region "My.Settings Auto-Save Functionality"
#If _MyType = "WindowsForms" Then
Private Shared addedHandler As Boolean
Private Shared addedHandlerLockObject As New Object
<Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs)
If My.Application.SaveMySettingsOnExit Then
My.Settings.Save()
End If
End Sub
#End If
#End Region
Public Shared ReadOnly Property [Default]() As MySettings
Get
#If _MyType = "WindowsForms" Then
If Not addedHandler Then
SyncLock addedHandlerLockObject
If Not addedHandler Then
AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings
addedHandler = True
End If
End SyncLock
End If
#End If
Return defaultInstance
End Get
End Property
End Class
End Namespace
Namespace My
<Global.Microsoft.VisualBasic.HideModuleNameAttribute(), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute()> _
Friend Module MySettingsProperty
<Global.System.ComponentModel.Design.HelpKeywordAttribute("My.Settings")> _
Friend ReadOnly Property Settings() As Global.GetMarketInfo.My.MySettings
Get
Return Global.GetMarketInfo.My.MySettings.Default
End Get
End Property
End Module
End Namespace
|
shoutatani/GetMarketInfoByVB.net
|
GetMarketInfo/My Project/Settings.Designer.vb
|
Visual Basic
|
mit
| 2,932
|
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System.Collections.Immutable
Imports System.Collections.ObjectModel
Imports System.IO
Imports System.Reflection
Imports System.Reflection.Metadata
Imports System.Reflection.Metadata.Ecma335
Imports System.Runtime.InteropServices
Imports Microsoft.CodeAnalysis.CodeGen
Imports Microsoft.CodeAnalysis.Collections
Imports Microsoft.CodeAnalysis.Debugging
Imports Microsoft.CodeAnalysis.Emit
Imports Microsoft.CodeAnalysis.ExpressionEvaluator
Imports Microsoft.CodeAnalysis.VisualBasic.Symbols
Imports Microsoft.CodeAnalysis.VisualBasic.Symbols.Metadata.PE
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Imports Microsoft.DiaSymReader
Imports Microsoft.VisualStudio.Debugger.Clr
Imports Microsoft.VisualStudio.Debugger.Evaluation
Imports Microsoft.VisualStudio.Debugger.Evaluation.ClrCompilation
Imports Roslyn.Utilities
Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator
Friend NotInheritable Class EvaluationContext
Inherits EvaluationContextBase
' These names are arbitrary, so we'll just use the same names as
' the C# expression compiler.
Private Const s_typeName = "<>x"
Private Const s_methodName = "<>m0"
Friend ReadOnly MethodContextReuseConstraints As MethodContextReuseConstraints?
Friend ReadOnly Compilation As VisualBasicCompilation
Private ReadOnly _currentFrame As MethodSymbol
Private ReadOnly _locals As ImmutableArray(Of LocalSymbol)
Private ReadOnly _inScopeHoistedLocalSlots As ImmutableSortedSet(Of Integer)
Private ReadOnly _methodDebugInfo As MethodDebugInfo(Of TypeSymbol, LocalSymbol)
Private Sub New(
methodContextReuseConstraints As MethodContextReuseConstraints?,
compilation As VisualBasicCompilation,
currentFrame As MethodSymbol,
locals As ImmutableArray(Of LocalSymbol),
inScopeHoistedLocalSlots As ImmutableSortedSet(Of Integer),
methodDebugInfo As MethodDebugInfo(Of TypeSymbol, LocalSymbol))
Me.MethodContextReuseConstraints = methodContextReuseConstraints
Me.Compilation = compilation
_currentFrame = currentFrame
_locals = locals
_inScopeHoistedLocalSlots = inScopeHoistedLocalSlots
_methodDebugInfo = methodDebugInfo
End Sub
''' <summary>
''' Create a context for evaluating expressions at a type scope.
''' </summary>
''' <param name="previous">Previous context, if any, for possible re-use.</param>
''' <param name="metadataBlocks">Module metadata.</param>
''' <param name="moduleVersionId">Module containing type.</param>
''' <param name="typeToken">Type metadata token.</param>
''' <returns>Evaluation context.</returns>
''' <remarks>
''' No locals since locals are associated with methods, not types.
''' </remarks>
Friend Shared Function CreateTypeContext(
previous As VisualBasicMetadataContext,
metadataBlocks As ImmutableArray(Of MetadataBlock),
moduleVersionId As Guid,
typeToken As Integer) As EvaluationContext
' Re-use the previous compilation if possible.
Dim compilation = If(previous.Matches(metadataBlocks),
previous.Compilation,
metadataBlocks.ToCompilation())
Return CreateTypeContext(compilation, moduleVersionId, typeToken)
End Function
Friend Shared Function CreateTypeContext(
compilation As VisualBasicCompilation,
moduleVersionId As Guid,
typeToken As Integer) As EvaluationContext
Debug.Assert(MetadataTokens.Handle(typeToken).Kind = HandleKind.TypeDefinition)
Dim currentType = compilation.GetType(moduleVersionId, typeToken)
Debug.Assert(currentType IsNot Nothing)
Dim currentFrame = New SynthesizedContextMethodSymbol(currentType)
Return New EvaluationContext(
Nothing,
compilation,
currentFrame,
locals:=Nothing,
inScopeHoistedLocalSlots:=Nothing,
methodDebugInfo:=MethodDebugInfo(Of TypeSymbol, LocalSymbol).None)
End Function
''' <summary>
''' Create a context for evaluating expressions within a method scope.
''' </summary>
''' <param name="previous">Previous context, if any, for possible re-use.</param>
''' <param name="metadataBlocks">Module metadata.</param>
''' <param name="symReader"><see cref="ISymUnmanagedReader"/> for PDB associated with <paramref name="moduleVersionId"/>.</param>
''' <param name="moduleVersionId">Module containing method.</param>
''' <param name="methodToken">Method metadata token.</param>
''' <param name="methodVersion">Method version.</param>
''' <param name="ilOffset">IL offset of instruction pointer in method.</param>
''' <param name="localSignatureToken">Method local signature token.</param>
''' <returns>Evaluation context.</returns>
Friend Shared Function CreateMethodContext(
previous As VisualBasicMetadataContext,
metadataBlocks As ImmutableArray(Of MetadataBlock),
lazyAssemblyReaders As Lazy(Of ImmutableArray(Of AssemblyReaders)),
symReader As Object,
moduleVersionId As Guid,
methodToken As Integer,
methodVersion As Integer,
ilOffset As UInteger,
localSignatureToken As Integer) As EvaluationContext
Dim offset = NormalizeILOffset(ilOffset)
' Re-use the previous compilation if possible.
Dim compilation As VisualBasicCompilation
If previous.Matches(metadataBlocks) Then
' Re-use entire context if method scope has not changed.
Dim previousContext = previous.EvaluationContext
If previousContext IsNot Nothing AndAlso
previousContext.MethodContextReuseConstraints.HasValue AndAlso
previousContext.MethodContextReuseConstraints.GetValueOrDefault().AreSatisfied(moduleVersionId, methodToken, methodVersion, offset) Then
Return previousContext
End If
compilation = previous.Compilation
Else
compilation = metadataBlocks.ToCompilation()
End If
Return CreateMethodContext(
compilation,
lazyAssemblyReaders,
symReader,
moduleVersionId,
methodToken,
methodVersion,
offset,
localSignatureToken)
End Function
Friend Shared Function CreateMethodContext(
compilation As VisualBasicCompilation,
lazyAssemblyReaders As Lazy(Of ImmutableArray(Of AssemblyReaders)),
symReader As Object,
moduleVersionId As Guid,
methodToken As Integer,
methodVersion As Integer,
ilOffset As UInteger,
localSignatureToken As Integer) As EvaluationContext
Return CreateMethodContext(
compilation,
lazyAssemblyReaders,
symReader,
moduleVersionId,
methodToken,
methodVersion,
NormalizeILOffset(ilOffset),
localSignatureToken)
End Function
Private Shared Function CreateMethodContext(
compilation As VisualBasicCompilation,
lazyAssemblyReaders As Lazy(Of ImmutableArray(Of AssemblyReaders)),
symReader As Object,
moduleVersionId As Guid,
methodToken As Integer,
methodVersion As Integer,
ilOffset As Integer,
localSignatureToken As Integer) As EvaluationContext
Dim methodHandle = CType(MetadataTokens.Handle(methodToken), MethodDefinitionHandle)
Dim localSignatureHandle = If(localSignatureToken <> 0, CType(MetadataTokens.Handle(localSignatureToken), StandaloneSignatureHandle), Nothing)
Dim currentFrame = compilation.GetMethod(moduleVersionId, methodHandle)
Debug.Assert(currentFrame IsNot Nothing)
Dim symbolProvider = New VisualBasicEESymbolProvider(DirectCast(currentFrame.ContainingModule, PEModuleSymbol), currentFrame)
Dim metadataDecoder = New MetadataDecoder(DirectCast(currentFrame.ContainingModule, PEModuleSymbol), currentFrame)
Dim localInfo = metadataDecoder.GetLocalInfo(localSignatureHandle)
Dim debugInfo As MethodDebugInfo(Of TypeSymbol, LocalSymbol)
If IsDteeEntryPoint(currentFrame) Then
debugInfo = SynthesizeMethodDebugInfoForDtee(lazyAssemblyReaders.Value)
Else
Dim typedSymReader = DirectCast(symReader, ISymUnmanagedReader3)
debugInfo = MethodDebugInfo(Of TypeSymbol, LocalSymbol).ReadMethodDebugInfo(typedSymReader, symbolProvider, methodToken, methodVersion, ilOffset, isVisualBasicMethod:=True)
End If
Dim reuseSpan = debugInfo.ReuseSpan
Dim inScopeHoistedLocalSlots As ImmutableSortedSet(Of Integer)
If debugInfo.HoistedLocalScopeRecords.IsDefault Then
inScopeHoistedLocalSlots = GetInScopeHoistedLocalSlots(debugInfo.LocalVariableNames)
Else
inScopeHoistedLocalSlots = debugInfo.GetInScopeHoistedLocalIndices(ilOffset, reuseSpan)
End If
Dim localNames = debugInfo.LocalVariableNames.WhereAsArray(
Function(name) name Is Nothing OrElse Not name.StartsWith(StringConstants.StateMachineHoistedUserVariablePrefix, StringComparison.Ordinal))
Dim localsBuilder = ArrayBuilder(Of LocalSymbol).GetInstance()
MethodDebugInfo(Of TypeSymbol, LocalSymbol).GetLocals(localsBuilder, symbolProvider, localNames, localInfo, Nothing, debugInfo.TupleLocalMap)
GetStaticLocals(localsBuilder, currentFrame, methodHandle, metadataDecoder)
localsBuilder.AddRange(debugInfo.LocalConstants)
Return New EvaluationContext(
New MethodContextReuseConstraints(moduleVersionId, methodToken, methodVersion, reuseSpan),
compilation,
currentFrame,
localsBuilder.ToImmutableAndFree(),
inScopeHoistedLocalSlots,
debugInfo)
End Function
Private Shared Function GetInScopeHoistedLocalSlots(allLocalNames As ImmutableArray(Of String)) As ImmutableSortedSet(Of Integer)
Dim builder = ArrayBuilder(Of Integer).GetInstance()
For Each localName In allLocalNames
Dim hoistedLocalName As String = Nothing
Dim hoistedLocalSlot As Integer = 0
If localName IsNot Nothing AndAlso GeneratedNames.TryParseStateMachineHoistedUserVariableName(localName, hoistedLocalName, hoistedLocalSlot) Then
builder.Add(hoistedLocalSlot)
End If
Next
Dim result = builder.ToImmutableSortedSet()
builder.Free()
Return result
End Function
''' <summary>
''' When using DTEE with the hosting process enabled, if the assembly being debugged doesn't have
''' a Main method, the debugger will actually stop in a driver method in the hosting process.
''' As in the native EE, we detect such methods by name (respecting case).
''' </summary>
''' <remarks>
''' Logic copied from ProcedureContext::IsDteeEntryPoint.
''' Friend for testing.
''' </remarks>
''' <seealso cref="SynthesizeMethodDebugInfoForDtee"/>
Friend Shared Function IsDteeEntryPoint(currentFrame As MethodSymbol) As Boolean
Dim typeName = currentFrame.ContainingType.Name
Dim methodName = currentFrame.Name
Return _
(String.Equals(typeName, "HostProc", StringComparison.Ordinal) AndAlso ' DLL
String.Equals(methodName, "BreakForDebugger", StringComparison.Ordinal)) OrElse
(String.Equals(typeName, "AppDomain", StringComparison.Ordinal) AndAlso ' WPF app
String.Equals(methodName, "ExecuteAssembly", StringComparison.Ordinal))
End Function
''' <summary>
''' When using DTEE with the hosting process enabled, if the assembly being debugged doesn't have
''' a Main method, the debugger will actually stop in a driver method in the hosting process.
''' (This condition is detected by <see cref="IsDteeEntryPoint"/>.)
'''
''' Since such driver methods have no knowledge of the assembly being debugged, we synthesize
''' imports to bring symbols from the target assembly into scope (for convenience). In particular,
''' we import the root namespace of any assembly that isn't obviously a framework assembly and
''' any namespace containing a module type.
''' </summary>
''' <remarks>
''' Logic copied from ProcedureContext::LoadImportsAndDefaultNamespaceForDteeEntryPoint.
''' Friend for testing.
''' </remarks>
''' <seealso cref="IsDteeEntryPoint"/>
''' <seealso cref="PENamedTypeSymbol.TypeKind"/>
Friend Shared Function SynthesizeMethodDebugInfoForDtee(assemblyReaders As ImmutableArray(Of AssemblyReaders)) As MethodDebugInfo(Of TypeSymbol, LocalSymbol)
Dim [imports] = PooledHashSet(Of String).GetInstance()
For Each readers In assemblyReaders
Dim metadataReader = readers.MetadataReader
Dim symReader = DirectCast(readers.SymReader, ISymUnmanagedReader3)
' Ignore assemblies for which we don't have PDBs.
If symReader Is Nothing Then Continue For
Try
For Each typeDefHandle In metadataReader.TypeDefinitions
Dim typeDef = metadataReader.GetTypeDefinition(typeDefHandle)
' VB does ignores the StandardModuleAttribute on interfaces and nested
' or generic types (see PENamedTypeSymbol.TypeKind).
If Not PEModule.IsNested(typeDef.Attributes) AndAlso
typeDef.GetGenericParameters().Count = 0 AndAlso
(typeDef.Attributes And TypeAttributes.[Interface]) = 0 AndAlso
PEModule.FindTargetAttribute(metadataReader, typeDefHandle, AttributeDescription.StandardModuleAttribute).HasValue Then
Dim namespaceName = metadataReader.GetString(typeDef.Namespace)
[imports].Add(namespaceName)
End If
Next
For Each methodDefHandle In metadataReader.MethodDefinitions
' TODO: this can be done better
' EnC can't change the default namespace of the assembly, so version 1 will suffice.
Dim debugInfo = MethodDebugInfo(Of TypeSymbol, LocalSymbol).ReadMethodDebugInfo(symReader,
Nothing,
metadataReader.GetToken(methodDefHandle),
methodVersion:=1,
ilOffset:=0,
isVisualBasicMethod:=True)
' Some methods aren't decorated with import custom debug info.
If Not String.IsNullOrEmpty(debugInfo.DefaultNamespaceName) Then
' NOTE: We're adding it as a project-level import, not as the default namespace
' (because there's one for each assembly and they can't all be the default).
[imports].Add(debugInfo.DefaultNamespaceName)
' The default namespace should be the same for all methods, so we only need to check one.
Exit For
End If
Next
Catch ex As BadImageFormatException
' This will only prevent us from synthesizing imports for the module types in
' one assembly - it is decidedly recoverable.
End Try
Next
Dim projectLevelImportRecords = ImmutableArray.CreateRange([imports].Select(
Function(namespaceName) New ImportRecord(ImportTargetKind.Namespace,
alias:=Nothing,
targetType:=Nothing,
targetString:=namespaceName,
targetAssembly:=Nothing,
targetAssemblyAlias:=Nothing)))
[imports].Free()
Dim fileLevelImportRecords = ImmutableArray(Of ImportRecord).Empty
Dim importRecordGroups = ImmutableArray.Create(fileLevelImportRecords, projectLevelImportRecords)
Return New MethodDebugInfo(Of TypeSymbol, LocalSymbol)(
hoistedLocalScopeRecords:=ImmutableArray(Of HoistedLocalScopeRecord).Empty,
importRecordGroups:=importRecordGroups,
defaultNamespaceName:="",
externAliasRecords:=ImmutableArray(Of ExternAliasRecord).Empty,
dynamicLocalMap:=Nothing,
tupleLocalMap:=Nothing,
localVariableNames:=ImmutableArray(Of String).Empty,
localConstants:=ImmutableArray(Of LocalSymbol).Empty,
reuseSpan:=Nothing)
End Function
Friend Function CreateCompilationContext(withSyntax As Boolean) As CompilationContext
Return New CompilationContext(
Compilation,
_currentFrame,
_locals,
_inScopeHoistedLocalSlots,
_methodDebugInfo,
withSyntax)
End Function
Friend Overrides Function CompileExpression(
expr As String,
compilationFlags As DkmEvaluationFlags,
aliases As ImmutableArray(Of [Alias]),
diagnostics As DiagnosticBag,
<Out> ByRef resultProperties As ResultProperties,
testData As Microsoft.CodeAnalysis.CodeGen.CompilationTestData) As CompileResult
resultProperties = Nothing
Dim formatSpecifiers As ReadOnlyCollection(Of String) = Nothing
Dim syntax = If((compilationFlags And DkmEvaluationFlags.TreatAsExpression) <> 0,
expr.ParseExpression(diagnostics, allowFormatSpecifiers:=True, formatSpecifiers:=formatSpecifiers),
expr.ParseStatement(diagnostics))
If syntax Is Nothing Then
Return Nothing
End If
If Not IsSupportedDebuggerStatement(syntax) Then
diagnostics.Add(New SimpleMessageDiagnostic(String.Format(Resources.InvalidDebuggerStatement, syntax.Kind)))
Return Nothing
End If
Dim context = Me.CreateCompilationContext(withSyntax:=True)
Dim synthesizedMethod As EEMethodSymbol = Nothing
Dim moduleBuilder = context.Compile(DirectCast(syntax, ExecutableStatementSyntax), s_typeName, s_methodName, aliases, testData, diagnostics, synthesizedMethod)
If moduleBuilder Is Nothing Then
Return Nothing
End If
Using stream As New MemoryStream()
Cci.PeWriter.WritePeToStream(
New EmitContext(moduleBuilder, Nothing, diagnostics),
context.MessageProvider,
Function() stream,
getPortablePdbStreamOpt:=Nothing,
nativePdbWriterOpt:=Nothing,
pdbPathOpt:=Nothing,
allowMissingMethodBodies:=False,
isDeterministic:=False,
cancellationToken:=Nothing)
If diagnostics.HasAnyErrors() Then
Return Nothing
End If
Debug.Assert(synthesizedMethod.ContainingType.MetadataName = s_typeName)
Debug.Assert(synthesizedMethod.MetadataName = s_methodName)
resultProperties = synthesizedMethod.ResultProperties
Return New VisualBasicCompileResult(
stream.ToArray(),
synthesizedMethod,
formatSpecifiers)
End Using
End Function
Friend Overrides Function CompileAssignment(
target As String,
expr As String,
aliases As ImmutableArray(Of [Alias]),
diagnostics As DiagnosticBag,
<Out> ByRef resultProperties As ResultProperties,
testData As Microsoft.CodeAnalysis.CodeGen.CompilationTestData) As CompileResult
Dim assignment = target.ParseAssignment(expr, diagnostics)
If assignment Is Nothing Then
Return Nothing
End If
Dim context = Me.CreateCompilationContext(withSyntax:=True)
Dim synthesizedMethod As EEMethodSymbol = Nothing
Dim modulebuilder = context.Compile(assignment, s_typeName, s_methodName, aliases, testData, diagnostics, synthesizedMethod)
If modulebuilder Is Nothing Then
Return Nothing
End If
Using stream As New MemoryStream()
Cci.PeWriter.WritePeToStream(
New EmitContext(modulebuilder, Nothing, diagnostics),
context.MessageProvider,
Function() stream,
getPortablePdbStreamOpt:=Nothing,
nativePdbWriterOpt:=Nothing,
pdbPathOpt:=Nothing,
allowMissingMethodBodies:=False,
isDeterministic:=False,
cancellationToken:=Nothing)
If diagnostics.HasAnyErrors() Then
Return Nothing
End If
Debug.Assert(synthesizedMethod.ContainingType.MetadataName = s_typeName)
Debug.Assert(synthesizedMethod.MetadataName = s_methodName)
Dim properties = synthesizedMethod.ResultProperties
resultProperties = New ResultProperties(
properties.Flags Or DkmClrCompilationResultFlags.PotentialSideEffect,
properties.Category,
properties.AccessType,
properties.StorageType,
properties.ModifierFlags)
Return New VisualBasicCompileResult(
stream.ToArray(),
synthesizedMethod,
formatSpecifiers:=Nothing)
End Using
End Function
Private Shared ReadOnly s_emptyBytes As New ReadOnlyCollection(Of Byte)(Array.Empty(Of Byte))
Friend Overrides Function CompileGetLocals(
locals As ArrayBuilder(Of LocalAndMethod),
argumentsOnly As Boolean,
aliases As ImmutableArray(Of [Alias]),
diagnostics As DiagnosticBag,
<Out> ByRef typeName As String,
testData As CompilationTestData) As ReadOnlyCollection(Of Byte)
Dim context = Me.CreateCompilationContext(withSyntax:=False)
Dim modulebuilder = context.CompileGetLocals(s_typeName, locals, argumentsOnly, aliases, testData, diagnostics)
Dim assembly As ReadOnlyCollection(Of Byte) = Nothing
If modulebuilder IsNot Nothing AndAlso locals.Count > 0 Then
Using stream As New MemoryStream()
Cci.PeWriter.WritePeToStream(
New EmitContext(modulebuilder, Nothing, diagnostics),
context.MessageProvider,
Function() stream,
getPortablePdbStreamOpt:=Nothing,
nativePdbWriterOpt:=Nothing,
pdbPathOpt:=Nothing,
allowMissingMethodBodies:=False,
isDeterministic:=False,
cancellationToken:=Nothing)
If Not diagnostics.HasAnyErrors() Then
assembly = New ReadOnlyCollection(Of Byte)(stream.ToArray())
End If
End Using
End If
If assembly Is Nothing Then
locals.Clear()
assembly = s_emptyBytes
End If
typeName = EvaluationContext.s_typeName
Return assembly
End Function
''' <summary>
''' Include static locals for the given method. Static locals
''' are represented as fields on the containing class named
''' "$STATIC$[methodname]$[methodsignature]$[localname]".
''' </summary>
Private Shared Sub GetStaticLocals(
builder As ArrayBuilder(Of LocalSymbol),
method As MethodSymbol,
methodHandle As MethodDefinitionHandle,
metadataDecoder As MetadataDecoder)
Dim type = method.ContainingType
If type.TypeKind <> TypeKind.Class Then
Return
End If
For Each member In type.GetMembers()
If member.Kind <> SymbolKind.Field Then
Continue For
End If
Dim methodName As String = Nothing
Dim methodSignature As String = Nothing
Dim localName As String = Nothing
If GeneratedNames.TryParseStaticLocalFieldName(member.Name, methodName, methodSignature, localName) AndAlso
String.Equals(methodName, method.Name, StringComparison.Ordinal) AndAlso
String.Equals(methodSignature, GetMethodSignatureString(metadataDecoder, methodHandle), StringComparison.Ordinal) Then
builder.Add(New EEStaticLocalSymbol(method, DirectCast(member, FieldSymbol), localName))
End If
Next
End Sub
Private Shared Function GetMethodSignatureString(metadataDecoder As MetadataDecoder, methodHandle As MethodDefinitionHandle) As String
Dim [module] = metadataDecoder.Module
Dim signatureHandle = [module].GetMethodSignatureOrThrow(methodHandle)
Dim signatureReader = [module].GetMemoryReaderOrThrow(signatureHandle)
Dim signature = signatureReader.ReadBytes(signatureReader.Length)
Return GeneratedNames.MakeSignatureString(signature)
End Function
Friend Overrides Function HasDuplicateTypesOrAssemblies(diagnostic As Diagnostic) As Boolean
Select Case CType(diagnostic.Code, ERRID)
Case ERRID.ERR_DuplicateReference2,
ERRID.ERR_DuplicateReferenceStrong,
ERRID.ERR_AmbiguousInUnnamedNamespace1,
ERRID.ERR_AmbiguousInNamespace2,
ERRID.ERR_NoMostSpecificOverload2,
ERRID.ERR_AmbiguousInModules2
Return True
Case Else
Return False
End Select
End Function
Friend Overrides Function GetMissingAssemblyIdentities(diagnostic As Diagnostic, linqLibrary As AssemblyIdentity) As ImmutableArray(Of AssemblyIdentity)
Return GetMissingAssemblyIdentitiesHelper(CType(diagnostic.Code, ERRID), diagnostic.Arguments, Me.Compilation.GlobalNamespace, linqLibrary)
End Function
''' <remarks>
''' Friend for testing.
''' </remarks>
Friend Shared Function GetMissingAssemblyIdentitiesHelper(code As ERRID, arguments As IReadOnlyList(Of Object), globalNamespace As NamespaceSymbol, linqLibrary As AssemblyIdentity) As ImmutableArray(Of AssemblyIdentity)
Debug.Assert(linqLibrary IsNot Nothing)
Select Case code
Case ERRID.ERR_UnreferencedAssemblyEvent3, ERRID.ERR_UnreferencedAssembly3
For Each argument As Object In arguments
Dim identity = If(TryCast(argument, AssemblyIdentity), TryCast(argument, AssemblySymbol)?.Identity)
If IsValidMissingAssemblyIdentity(identity) Then
Return ImmutableArray.Create(identity)
End If
Next
Case ERRID.ERR_ForwardedTypeUnavailable3
If arguments.Count = 3 Then
Dim identity As AssemblyIdentity = TryCast(arguments(2), AssemblySymbol)?.Identity
If IsValidMissingAssemblyIdentity(identity) Then
Return ImmutableArray.Create(identity)
End If
End If
Case ERRID.ERR_NameNotMember2
If arguments.Count = 2 Then
Dim namespaceName = TryCast(arguments(0), String)
Dim containingNamespace = TryCast(arguments(1), NamespaceSymbol)
If namespaceName IsNot Nothing AndAlso containingNamespace IsNot Nothing AndAlso HasConstituentFromWindowsAssembly(containingNamespace) Then
' This is just a heuristic, but it has the advantage of being portable, particularly
' across different versions of (desktop) windows.
Dim identity = New AssemblyIdentity($"{containingNamespace.ToDisplayString}.{namespaceName}", contentType:=AssemblyContentType.WindowsRuntime)
Return ImmutableArray.Create(identity)
Else
' Maybe it's a missing LINQ extension method. Let's try adding the "LINQ library" to see if that helps.
Return ImmutableArray.Create(linqLibrary)
End If
End If
Case ERRID.ERR_UndefinedType1
If arguments.Count = 1 Then
Dim qualifiedName = TryCast(arguments(0), String)
If Not String.IsNullOrEmpty(qualifiedName) Then
Dim nameParts = qualifiedName.Split("."c)
Dim numParts = nameParts.Length
Dim pos = 0
If CaseInsensitiveComparison.Comparer.Equals(nameParts(0), "global") Then
pos = 1
Debug.Assert(pos < numParts)
End If
Dim currNamespace = globalNamespace
While pos < numParts
Dim nextNamespace = currNamespace.GetMembers(nameParts(pos)).OfType(Of NamespaceSymbol).SingleOrDefault()
If nextNamespace Is Nothing Then
Exit While
End If
pos += 1
currNamespace = nextNamespace
End While
If currNamespace IsNot globalNamespace AndAlso HasConstituentFromWindowsAssembly(currNamespace) AndAlso pos < numParts Then
Dim nextNamePart = nameParts(pos)
If nextNamePart.All(AddressOf SyntaxFacts.IsIdentifierPartCharacter) Then
' This is just a heuristic, but it has the advantage of being portable, particularly
' across different versions of (desktop) windows.
Dim identity = New AssemblyIdentity($"{currNamespace.ToDisplayString}.{nameParts(pos)}", contentType:=AssemblyContentType.WindowsRuntime)
Return ImmutableArray.Create(identity)
End If
End If
End If
End If
Case ERRID.ERR_XmlFeaturesNotAvailable
Return ImmutableArray.Create(SystemIdentity, linqLibrary, SystemXmlIdentity, SystemXmlLinqIdentity)
Case ERRID.ERR_MissingRuntimeHelper
Return ImmutableArray.Create(MicrosoftVisualBasicIdentity)
End Select
Return Nothing
End Function
Private Shared Function HasConstituentFromWindowsAssembly(namespaceSymbol As NamespaceSymbol) As Boolean
Return namespaceSymbol.ConstituentNamespaces.Any(Function(n) n.ContainingAssembly.Identity.IsWindowsAssemblyIdentity)
End Function
Private Shared Function IsValidMissingAssemblyIdentity(identity As AssemblyIdentity) As Boolean
Return identity IsNot Nothing AndAlso Not identity.Equals(MissingCorLibrarySymbol.Instance.Identity)
End Function
Private Shared Function GetSynthesizedMethod(moduleBuilder As CommonPEModuleBuilder) As MethodSymbol
Dim method = DirectCast(moduleBuilder, EEAssemblyBuilder).Methods.Single(Function(m) m.MetadataName = s_methodName)
Debug.Assert(method.ContainingType.MetadataName = s_typeName)
Return method
End Function
End Class
End Namespace
|
akrisiun/roslyn
|
src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/EvaluationContext.vb
|
Visual Basic
|
apache-2.0
| 34,515
|
'------------------------------------------------------------------------------
' <auto-generated>
' This code was generated by a tool.
' Runtime Version:4.0.30319.18034
'
' Changes to this file may cause incorrect behavior and will be lost if
' the code is regenerated.
' </auto-generated>
'------------------------------------------------------------------------------
Option Strict On
Option Explicit On
Imports System
Namespace My.Resources
'This class was auto-generated by the StronglyTypedResourceBuilder
'class via a tool like ResGen or Visual Studio.
'To add or remove a member, edit your .ResX file then rerun ResGen
'with the /str option, or rebuild your VS project.
'''<summary>
''' A strongly-typed resource class, for looking up localized strings, etc.
'''</summary>
<Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0"), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
Global.Microsoft.VisualBasic.HideModuleNameAttribute()> _
Friend Module Resources
Private resourceMan As Global.System.Resources.ResourceManager
Private resourceCulture As Global.System.Globalization.CultureInfo
'''<summary>
''' Returns the cached ResourceManager instance used by this class.
'''</summary>
<Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager
Get
If Object.ReferenceEquals(resourceMan, Nothing) Then
Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("SvgCanvasSampleVB.Resources", GetType(Resources).Assembly)
resourceMan = temp
End If
Return resourceMan
End Get
End Property
'''<summary>
''' Overrides the current thread's CurrentUICulture property for all
''' resource lookups using this strongly typed resource class.
'''</summary>
<Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Friend Property Culture() As Global.System.Globalization.CultureInfo
Get
Return resourceCulture
End Get
Set
resourceCulture = value
End Set
End Property
End Module
End Namespace
|
jogibear9988/SharpVectors
|
Samples/SharpVectorsControlSamples/SvgCanvasSampleVB/My Project/Resources.Designer.vb
|
Visual Basic
|
bsd-3-clause
| 2,786
|
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports Microsoft.CodeAnalysis.Diagnostics
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Imports Microsoft.CodeAnalysis.BannedApiAnalyzers
Namespace Microsoft.CodeAnalysis.VisualBasic.BannedApiAnalyzers
<DiagnosticAnalyzer(LanguageNames.VisualBasic)>
Public Class BasicSymbolIsBannedAnalyzer
Inherits SymbolIsBannedAnalyzer(Of SyntaxKind)
Protected Overrides ReadOnly Property XmlCrefSyntaxKind As SyntaxKind
Get
Return SyntaxKind.XmlCrefAttribute
End Get
End Property
Protected Overrides ReadOnly Property SymbolDisplayFormat As SymbolDisplayFormat
Get
Return SymbolDisplayFormat.VisualBasicShortErrorMessageFormat
End Get
End Property
Protected Overrides Function GetReferenceSyntaxNodeFromXmlCref(syntaxNode As SyntaxNode) As SyntaxNode
Return CType(syntaxNode, XmlCrefAttributeSyntax).Reference
End Function
End Class
End Namespace
|
mavasani/roslyn-analyzers
|
src/Microsoft.CodeAnalysis.BannedApiAnalyzers/VisualBasic/BasicSymbolIsBannedAnalyzer.vb
|
Visual Basic
|
apache-2.0
| 1,168
|
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System.Composition
Imports Microsoft.CodeAnalysis.CodeRefactorings
Imports Microsoft.CodeAnalysis.SplitOrMergeIfStatements
Namespace Microsoft.CodeAnalysis.VisualBasic.SplitOrMergeIfStatements
<ExportCodeRefactoringProvider(LanguageNames.VisualBasic, Name:=PredefinedCodeRefactoringProviderNames.SplitIntoConsecutiveIfStatements), [Shared]>
<ExtensionOrder(After:=PredefinedCodeRefactoringProviderNames.InvertLogical, Before:=PredefinedCodeRefactoringProviderNames.IntroduceVariable)>
Friend NotInheritable Class VisualBasicSplitIntoConsecutiveIfStatementsCodeRefactoringProvider
Inherits AbstractSplitIntoConsecutiveIfStatementsCodeRefactoringProvider
<ImportingConstructor>
Public Sub New()
End Sub
End Class
End Namespace
|
nguerrera/roslyn
|
src/Features/VisualBasic/Portable/SplitOrMergeIfStatements/VisualBasicSplitIntoConsecutiveIfStatementsCodeRefactoringProvider.vb
|
Visual Basic
|
apache-2.0
| 947
|
' Copyright (c) 2015 ZZZ Projects. All rights reserved
' Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods)
' Website: http://www.zzzprojects.com/
' Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927
' All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library
Imports System.Reflection
Public Module Extensions_843
''' <summary>
''' Determines whether any custom attributes are applied to a member of a type. Parameters specify the member,
''' and the type of the custom attribute to search for.
''' </summary>
''' <param name="element">
''' An object derived from the class that describes a constructor, event, field, method, type,
''' or property member of a class.
''' </param>
''' <param name="attributeType">The type, or a base type, of the custom attribute to search for.</param>
''' <returns>true if a custom attribute of type is applied to ; otherwise, false.</returns>
<System.Runtime.CompilerServices.Extension> _
Public Function IsDefined(element As MemberInfo, attributeType As Type) As [Boolean]
Return Attribute.IsDefined(element, attributeType)
End Function
''' <summary>
''' Determines whether any custom attributes are applied to a member of a type. Parameters specify the member,
''' the type of the custom attribute to search for, and whether to search ancestors of the member.
''' </summary>
''' <param name="element">
''' An object derived from the class that describes a constructor, event, field, method, type,
''' or property member of a class.
''' </param>
''' <param name="attributeType">The type, or a base type, of the custom attribute to search for.</param>
''' <param name="inherit">If true, specifies to also search the ancestors of for custom attributes.</param>
''' <returns>true if a custom attribute of type is applied to ; otherwise, false.</returns>
<System.Runtime.CompilerServices.Extension> _
Public Function IsDefined(element As MemberInfo, attributeType As Type, inherit As [Boolean]) As [Boolean]
Return Attribute.IsDefined(element, attributeType, inherit)
End Function
End Module
|
mario-loza/Z.ExtensionMethods
|
src (VB.NET)/Z.ExtensionMethods.VB/Z.Reflection/System.Reflection.MemberInfo/System.Attribute/MemberInfo.IsDefined.vb
|
Visual Basic
|
mit
| 2,217
|
'------------------------------------------------------------------------------
' <auto-generated>
' This code was generated by a tool.
' Runtime Version:2.0.50727.1434
'
' Changes to this file may cause incorrect behavior and will be lost if
' the code is regenerated.
' </auto-generated>
'------------------------------------------------------------------------------
Option Strict On
Option Explicit On
Namespace My
<Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0"), _
Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Partial Friend NotInheritable Class MySettings
Inherits Global.System.Configuration.ApplicationSettingsBase
Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings), MySettings)
#Region "My.Settings Auto-Save Functionality"
#If _MyType = "WindowsForms" Then
Private Shared addedHandler As Boolean
Private Shared addedHandlerLockObject As New Object
<Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs)
If My.Application.SaveMySettingsOnExit Then
My.Settings.Save()
End If
End Sub
#End If
#End Region
Public Shared ReadOnly Property [Default]() As MySettings
Get
#If _MyType = "WindowsForms" Then
If Not addedHandler Then
SyncLock addedHandlerLockObject
If Not addedHandler Then
AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings
addedHandler = True
End If
End SyncLock
End If
#End If
Return defaultInstance
End Get
End Property
End Class
End Namespace
Namespace My
<Global.Microsoft.VisualBasic.HideModuleNameAttribute(), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute()> _
Friend Module MySettingsProperty
<Global.System.ComponentModel.Design.HelpKeywordAttribute("My.Settings")> _
Friend ReadOnly Property Settings() As Global.BASS_SFXTestVB.My.MySettings
Get
Return Global.BASS_SFXTestVB.My.MySettings.Default
End Get
End Property
End Module
End Namespace
|
J2TeaM/au3-boilerplate
|
abp/Sound/BASSlib/BASS_SFX/ORIGINAL/VS 2005/VB .NET/BASS_SFXTestVB/My Project/Settings.Designer.vb
|
Visual Basic
|
bsd-3-clause
| 2,975
|
Namespace Microsoft.CodeAnalysis.VisualBasic.ExpressionEvaluator
#Disable Warning RS0010
''' <summary>
''' Causes all diagnostics related to <see cref="ObsoleteAttribute"/>
''' and <see cref="T:Windows.Foundation.MetadataDeprecatedAttribute"/>
''' to be suppressed.
''' </summary>
Friend NotInheritable Class SuppressObsoleteDiagnosticsBinder
#Enable Warning RS0010
Inherits Binder
Public Sub New(containingBinder As Binder)
MyBase.New(containingBinder)
End Sub
Friend Overrides ReadOnly Property SuppressObsoleteDiagnostics As Boolean
Get
Return True
End Get
End Property
End Class
End Namespace
|
DavidKarlas/roslyn
|
src/ExpressionEvaluator/VisualBasic/Source/ExpressionCompiler/Binders/SuppressObsoleteDiagnosticsBinder.vb
|
Visual Basic
|
apache-2.0
| 724
|
' Licensed to the .NET Foundation under one or more agreements.
' The .NET Foundation licenses this file to you under the MIT license.
' See the LICENSE file in the project root for more information.
Imports System.Collections.Immutable
Imports System.IO
Imports System.Linq
Imports System.Reflection.PortableExecutable
Imports System.Runtime.InteropServices
Imports System.Security.Cryptography
Imports System.Text
Imports System.Threading
Imports System.Xml.Linq
Imports Microsoft.CodeAnalysis
Imports Microsoft.CodeAnalysis.Emit
Imports Microsoft.CodeAnalysis.Test.Extensions
Imports Microsoft.CodeAnalysis.Test.Utilities
Imports Microsoft.CodeAnalysis.Text
Imports Microsoft.CodeAnalysis.VisualBasic
Imports Microsoft.CodeAnalysis.VisualBasic.Symbols
Imports Microsoft.CodeAnalysis.VisualBasic.UnitTests
Imports Roslyn.Test.Utilities
Imports CS = Microsoft.CodeAnalysis.CSharp
Imports Roslyn.Test.Utilities.TestHelpers
Imports Roslyn.Test.Utilities.TestMetadata
Namespace Microsoft.CodeAnalysis.VisualBasic.UnitTests
Public Class CompilationAPITests
Inherits BasicTestBase
Private Function WithDiagnosticOptions(
tree As SyntaxTree,
ParamArray options As (string, ReportDiagnostic)()) As VisualBasicCompilationOptions
Return TestOptions.DebugDll.
WithSyntaxTreeOptionsProvider(new TestSyntaxTreeOptionsProvider(tree, options))
End Function
<Fact>
Public Sub PerTreeVsGlobalSuppress()
Dim tree = SyntaxFactory.ParseSyntaxTree("
Class C
Sub M()
Dim x As Integer
End Sub
End Class")
Dim options = New VisualBasicCompilationOptions(OutputKind.DynamicallyLinkedLibrary).
WithGeneralDiagnosticOption(ReportDiagnostic.Suppress)
Dim comp = CreateCompilationWithMscorlib45({tree}, options:=options)
comp.AssertNoDiagnostics()
options = options.WithSyntaxTreeOptionsProvider(
new TestSyntaxTreeOptionsProvider(tree, ("BC42024", ReportDiagnostic.Warn)))
comp = CreateCompilationWithMscorlib45({tree}, options:=options)
' Global options override syntax tree options. This is the opposite of C# behavior
comp.AssertNoDiagnostics()
End Sub
<Fact>
Public Sub PerTreeDiagnosticOptionsParseWarnings()
Dim tree = SyntaxFactory.ParseSyntaxTree("
Class C
Sub M()
Dim x As Integer
End Sub
End Class")
Dim comp = CreateCompilation({tree}, options:=TestOptions.DebugDll)
comp.AssertTheseDiagnostics(
<errors>
BC42024: Unused local variable: 'x'.
Dim x As Integer
~
</errors>)
Dim options = WithDiagnosticOptions(tree, ("BC42024", ReportDiagnostic.Suppress))
Dim comp2 = CreateCompilation({tree}, options:=options)
comp2.AssertNoDiagnostics()
End Sub
<Fact>
Public Sub PerTreeDiagnosticOptionsVsPragma()
Dim tree = SyntaxFactory.ParseSyntaxTree("
Class C
Sub M()
#Disable Warning BC42024
Dim x As Integer
#Enable Warning BC42024
End Sub
End Class")
Dim comp = CreateCompilation({tree}, options:=TestOptions.DebugDll)
comp.AssertNoDiagnostics()
Dim options = WithDiagnosticOptions(tree, ("BC42024", ReportDiagnostic.Warn))
Dim comp2 = CreateCompilation({tree}, options:=options)
' Pragma should have precedence over per-tree options
comp2.AssertNoDiagnostics()
End Sub
<Fact>
Public Sub PerTreeDiagnosticOptionsVsSpecificOptions()
Dim tree = SyntaxFactory.ParseSyntaxTree("
Class C
Sub M()
Dim x As Integer
End Sub
End Class")
Dim options = TestOptions.DebugDll.WithSpecificDiagnosticOptions(
CreateImmutableDictionary(("BC42024", ReportDiagnostic.Suppress)))
Dim comp = CreateCompilationWithMscorlib45({tree}, options:=options)
comp.AssertNoDiagnostics()
options = options.WithSyntaxTreeOptionsProvider(
new TestSyntaxTreeOptionsProvider(tree, ("BC42024", ReportDiagnostic.Error)))
Dim comp2 = CreateCompilationWithMscorlib45({tree}, options:=options)
' Specific diagnostic options should have precedence over tree options
comp2.AssertNoDiagnostics()
End Sub
<Fact>
Public Sub DifferentDiagnosticOptionsForTrees()
Dim tree = SyntaxFactory.ParseSyntaxTree("
Class C
Sub M()
Dim x As Integer
End Sub
End Class")
Dim newTree = SyntaxFactory.ParseSyntaxTree("
Class D
Sub M()
Dim y As Integer
End Sub
End Class")
Dim options = TestOptions.DebugDll.WithSyntaxTreeOptionsProvider(
New TestSyntaxTreeOptionsProvider(
(tree, {("BC42024", ReportDiagnostic.Suppress)}),
(newTree, {("BC4024", ReportDiagnostic.Error)})))
Dim comp = CreateCompilationWithMscorlib45({tree, newTree}, options:=options)
comp.AssertTheseDiagnostics(
<errors>
BC42024: Unused local variable: 'y'.
Dim y As Integer
~
</errors>)
End Sub
<Fact>
Public Sub TreeOptionsComparerRespected()
Dim tree = SyntaxFactory.ParseSyntaxTree("
Class C
Sub M()
Dim x As Integer
End Sub
End Class")
' Default provider is case insensitive
Dim options = WithDiagnosticOptions(tree, ("bc42024", ReportDiagnostic.Suppress))
Dim comp = CreateCompilation(tree, options:=options)
comp.AssertNoDiagnostics()
options = options.WithSyntaxTreeOptionsProvider(
New TestSyntaxTreeOptionsProvider(
StringComparer.Ordinal,
Nothing,
(tree, {("bc42024", ReportDiagnostic.Suppress)}))
)
comp = CreateCompilation(tree, options:=options)
comp.AssertTheseDiagnostics(
<errors>
BC42024: Unused local variable: 'x'.
Dim x As Integer
~
</errors>)
End Sub
<WorkItem(8360, "https://github.com/dotnet/roslyn/issues/8360")>
<WorkItem(9153, "https://github.com/dotnet/roslyn/issues/9153")>
<Fact>
Public Sub PublicSignWithRelativeKeyPath()
Dim options = New VisualBasicCompilationOptions(OutputKind.DynamicallyLinkedLibrary).
WithPublicSign(True).WithCryptoKeyFile("test.snk")
AssertTheseDiagnostics(VisualBasicCompilation.Create("test", options:=options),
<errors>
BC37254: Public sign was specified and requires a public key, but no public key was specified
BC37257: Option 'CryptoKeyFile' must be an absolute path.
</errors>)
End Sub
<WorkItem(11497, "https://github.com/dotnet/roslyn/issues/11497")>
<Fact>
Public Sub PublicSignWithEmptyKeyPath()
Dim options = New VisualBasicCompilationOptions(OutputKind.DynamicallyLinkedLibrary).
WithPublicSign(True).WithCryptoKeyFile("")
AssertTheseDiagnostics(VisualBasicCompilation.Create("test", options:=options),
<errors>
BC37254: Public sign was specified and requires a public key, but no public key was specified
</errors>)
End Sub
<WorkItem(11497, "https://github.com/dotnet/roslyn/issues/11497")>
<Fact>
Public Sub PublicSignWithEmptyKeyPath2()
Dim options = New VisualBasicCompilationOptions(OutputKind.DynamicallyLinkedLibrary).
WithPublicSign(True).WithCryptoKeyFile("""""")
AssertTheseDiagnostics(VisualBasicCompilation.Create("test", options:=options),
<errors>
BC37254: Public sign was specified and requires a public key, but no public key was specified
BC37257: Option 'CryptoKeyFile' must be an absolute path.
</errors>)
End Sub
<Fact>
Public Sub LocalizableErrorArgumentToStringDoesntStackOverflow()
' Error ID is arbitrary
Dim arg = New LocalizableErrorArgument(ERRID.IDS_ProjectSettingsLocationName)
Assert.NotNull(arg.ToString())
End Sub
<WorkItem(538778, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/538778")>
<WorkItem(537623, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/537623")>
<WorkItem(233669, "https://devdiv.visualstudio.com/DevDiv/_workitems?id=233669")>
<Fact>
Public Sub CompilationName()
' report an error, rather then silently ignoring the directory
' (see cli partition II 22.30)
VisualBasicCompilation.Create("C:/goo/Test.exe").AssertTheseEmitDiagnostics(
<expected>
BC30420: 'Sub Main' was not found in 'C:/goo/Test.exe'.
BC37283: Invalid assembly name: Name contains invalid characters.
</expected>)
VisualBasicCompilation.Create("C:\goo\Test.exe", options:=TestOptions.ReleaseDll).AssertTheseDeclarationDiagnostics(
<expected>
BC37283: Invalid assembly name: Name contains invalid characters.
</expected>)
VisualBasicCompilation.Create("\goo/Test.exe", options:=TestOptions.ReleaseDll).AssertTheseEmitDiagnostics(
<expected>
BC37283: Invalid assembly name: Name contains invalid characters.
</expected>)
VisualBasicCompilation.Create("C:Test.exe", options:=TestOptions.ReleaseDll).AssertTheseEmitDiagnostics(
<expected>
BC37283: Invalid assembly name: Name contains invalid characters.
</expected>)
VisualBasicCompilation.Create("Te" & ChrW(0) & "st.exe", options:=TestOptions.ReleaseDll).AssertTheseEmitDiagnostics(
<expected>
BC37283: Invalid assembly name: Name contains invalid characters.
</expected>)
VisualBasicCompilation.Create(" " & vbTab & " ", options:=TestOptions.ReleaseDll).AssertTheseEmitDiagnostics(
<expected>
BC37283: Invalid assembly name: Name cannot start with whitespace.
</expected>)
VisualBasicCompilation.Create(ChrW(&HD800), options:=TestOptions.ReleaseDll).AssertTheseEmitDiagnostics(
<expected>
BC37283: Invalid assembly name: Name contains invalid characters.
</expected>)
VisualBasicCompilation.Create("", options:=TestOptions.ReleaseDll).AssertTheseEmitDiagnostics(
<expected>
BC37283: Invalid assembly name: Name cannot be empty.
</expected>)
VisualBasicCompilation.Create(" a", options:=TestOptions.ReleaseDll).AssertTheseEmitDiagnostics(
<expected>
BC37283: Invalid assembly name: Name cannot start with whitespace.
</expected>)
VisualBasicCompilation.Create("\u2000a", options:=TestOptions.ReleaseDll).AssertTheseEmitDiagnostics( ' // U+2000 is whitespace
<expected>
BC37283: Invalid assembly name: Name contains invalid characters.
</expected>)
' other characters than directory separators are ok:
VisualBasicCompilation.Create(";,*?<>#!@&", options:=TestOptions.ReleaseDll).AssertTheseEmitDiagnostics()
VisualBasicCompilation.Create("goo", options:=TestOptions.ReleaseDll).AssertTheseEmitDiagnostics()
VisualBasicCompilation.Create(".goo", options:=TestOptions.ReleaseDll).AssertTheseEmitDiagnostics()
VisualBasicCompilation.Create("goo ", options:=TestOptions.ReleaseDll).AssertTheseEmitDiagnostics() ' can end with whitespace
VisualBasicCompilation.Create("....", options:=TestOptions.ReleaseDll).AssertTheseEmitDiagnostics()
VisualBasicCompilation.Create(Nothing, options:=TestOptions.ReleaseDll).AssertTheseEmitDiagnostics()
End Sub
<Fact>
Public Sub CreateAPITest()
Dim listSyntaxTree = New List(Of SyntaxTree)
Dim listRef = New List(Of MetadataReference)
Dim s1 = "using Goo"
Dim t1 As SyntaxTree = VisualBasicSyntaxTree.ParseText(s1)
listSyntaxTree.Add(t1)
' System.dll
listRef.Add(Net451.System)
Dim ops = TestOptions.ReleaseExe
' Create Compilation with Option is not Nothing
Dim comp = VisualBasicCompilation.Create("Compilation", listSyntaxTree, listRef, ops)
Assert.Equal(ops, comp.Options)
Assert.NotNull(comp.SyntaxTrees)
Assert.NotNull(comp.References)
Assert.Equal(1, comp.SyntaxTrees.Count)
Assert.Equal(1, comp.References.Count)
' Create Compilation with PreProcessorSymbols of Option is empty
Dim ops1 = TestOptions.ReleaseExe.WithGlobalImports(GlobalImport.Parse({"System", "Microsoft.VisualBasic"})).WithRootNamespace("")
' Create Compilation with Assembly name contains invalid char
Dim asmname = "楽聖いち にÅÅ€"
comp = VisualBasicCompilation.Create(asmname, listSyntaxTree, listRef, ops1)
Assert.Equal(asmname, comp.Assembly.Name)
Assert.Equal(asmname + ".exe", comp.SourceModule.Name)
Dim compOpt = VisualBasicCompilation.Create("Compilation", Nothing, Nothing, Nothing)
Assert.NotNull(compOpt.Options)
' Not Implemented code
' comp = comp.ChangeOptions(options:=null)
' Assert.Equal(CompilationOptions.Default, comp.Options)
' comp = comp.ChangeOptions(ops1)
' Assert.Equal(ops1, comp.Options)
' comp = comp.ChangeOptions(comp1.Options)
' ssert.Equal(comp1.Options, comp.Options)
' comp = comp.ChangeOptions(CompilationOptions.Default)
' Assert.Equal(CompilationOptions.Default, comp.Options)
End Sub
<Fact>
Public Sub GetSpecialType()
Dim comp = VisualBasicCompilation.Create("compilation", Nothing, Nothing, Nothing)
' Get Special Type by enum
Dim ntSmb = comp.GetSpecialType(typeId:=SpecialType.Count)
Assert.Equal(SpecialType.Count, ntSmb.SpecialType)
' Get Special Type by integer
ntSmb = comp.GetSpecialType(CType(31, SpecialType))
Assert.Equal(31, CType(ntSmb.SpecialType, Integer))
End Sub
<Fact>
Public Sub GetTypeByMetadataName()
Dim comp = VisualBasicCompilation.Create("compilation", Nothing, Nothing, Nothing)
' Get Type Name And Arity
Assert.Null(comp.GetTypeByMetadataName("`1"))
Assert.Null(comp.GetTypeByMetadataName("中文`1"))
' Throw exception when the parameter of GetTypeByNameAndArity is NULL
'Assert.Throws(Of Exception)(
' Sub()
' comp.GetTypeByNameAndArity(fullName:=Nothing, arity:=1)
' End Sub)
' Throw exception when the parameter of GetTypeByNameAndArity is less than 0
'Assert.Throws(Of Exception)(
' Sub()
' comp.GetTypeByNameAndArity(String.Empty, -4)
' End Sub)
Dim compilationDef =
<compilation name="compilation">
<file name="a.vb">
Namespace A.B
Class C
Class D
Class E
End Class
End Class
End Class
Class G(Of T)
Class Q(Of S1,S2)
ENd Class
End Class
Class G(Of T1,T2)
End Class
End Namespace
Class C
Class D
Class E
End Class
End Class
End Class
</file>
</compilation>
comp = CompilationUtils.CreateCompilationWithMscorlib40AndVBRuntime(compilationDef)
'IsCaseSensitive
Assert.Equal(Of Boolean)(False, comp.IsCaseSensitive)
Assert.Equal("D", comp.GetTypeByMetadataName("C+D").Name)
Assert.Equal("E", comp.GetTypeByMetadataName("C+D+E").Name)
Assert.Null(comp.GetTypeByMetadataName(""))
Assert.Null(comp.GetTypeByMetadataName("+"))
Assert.Null(comp.GetTypeByMetadataName("++"))
Assert.Equal("C", comp.GetTypeByMetadataName("A.B.C").Name)
Assert.Equal("D", comp.GetTypeByMetadataName("A.B.C+D").Name)
Assert.Null(comp.GetTypeByMetadataName("A.B.C+F"))
Assert.Equal("E", comp.GetTypeByMetadataName("A.B.C+D+E").Name)
Assert.Null(comp.GetTypeByMetadataName("A.B.C+D+E+F"))
Assert.Equal(1, comp.GetTypeByMetadataName("A.B.G`1").Arity)
Assert.Equal(2, comp.GetTypeByMetadataName("A.B.G`1+Q`2").Arity)
Assert.Equal(2, comp.GetTypeByMetadataName("A.B.G`2").Arity)
Assert.Null(comp.GetTypeByMetadataName("c"))
Assert.Null(comp.GetTypeByMetadataName("A.b.C"))
Assert.Null(comp.GetTypeByMetadataName("C+d"))
Assert.Equal(SpecialType.System_Array, comp.GetTypeByMetadataName("System.Array").SpecialType)
Assert.Null(comp.Assembly.GetTypeByMetadataName("System.Array"))
Assert.Equal("E", comp.Assembly.GetTypeByMetadataName("A.B.C+D+E").Name)
End Sub
<Fact>
Public Sub EmitToMemoryStreams()
Dim comp = VisualBasicCompilation.Create("Compilation", options:=TestOptions.ReleaseDll)
Using output = New MemoryStream()
Using outputPdb = New MemoryStream()
Using outputxml = New MemoryStream()
Dim result = comp.Emit(output, outputPdb, Nothing)
Assert.True(result.Success)
result = comp.Emit(output, outputPdb)
Assert.True(result.Success)
result = comp.Emit(peStream:=output, pdbStream:=outputPdb, xmlDocumentationStream:=Nothing, cancellationToken:=Nothing)
Assert.True(result.Success)
result = comp.Emit(peStream:=output, pdbStream:=outputPdb, cancellationToken:=Nothing)
Assert.True(result.Success)
result = comp.Emit(output, outputPdb)
Assert.True(result.Success)
result = comp.Emit(output, outputPdb)
Assert.True(result.Success)
result = comp.Emit(output, outputPdb, outputxml)
Assert.True(result.Success)
result = comp.Emit(output, Nothing, Nothing, Nothing)
Assert.True(result.Success)
result = comp.Emit(output)
Assert.True(result.Success)
result = comp.Emit(output, Nothing, outputxml)
Assert.True(result.Success)
result = comp.Emit(output, xmlDocumentationStream:=outputxml)
Assert.True(result.Success)
result = comp.Emit(output, Nothing, outputxml)
Assert.True(result.Success)
result = comp.Emit(output, xmlDocumentationStream:=outputxml)
Assert.True(result.Success)
End Using
End Using
End Using
End Sub
<Fact>
Public Sub Emit_BadArgs()
Dim comp = VisualBasicCompilation.Create("Compilation", options:=TestOptions.ReleaseDll)
Assert.Throws(Of ArgumentNullException)("peStream", Sub() comp.Emit(peStream:=Nothing))
Assert.Throws(Of ArgumentException)("peStream", Sub() comp.Emit(peStream:=New TestStream(canRead:=True, canWrite:=False, canSeek:=True)))
Assert.Throws(Of ArgumentException)("pdbStream", Sub() comp.Emit(peStream:=New MemoryStream(), pdbStream:=New TestStream(canRead:=True, canWrite:=False, canSeek:=True)))
Assert.Throws(Of ArgumentException)("pdbStream", Sub() comp.Emit(peStream:=New MemoryStream(), pdbStream:=New MemoryStream(), options:=EmitOptions.Default.WithDebugInformationFormat(DebugInformationFormat.Embedded)))
Assert.Throws(Of ArgumentException)("sourceLinkStream", Sub() comp.Emit(
peStream:=New MemoryStream(),
pdbStream:=New MemoryStream(),
options:=EmitOptions.Default.WithDebugInformationFormat(DebugInformationFormat.PortablePdb),
sourceLinkStream:=New TestStream(canRead:=False, canWrite:=True, canSeek:=True)))
Assert.Throws(Of ArgumentException)("embeddedTexts", Sub() comp.Emit(
peStream:=New MemoryStream(),
pdbStream:=Nothing,
options:=Nothing,
embeddedTexts:={EmbeddedText.FromStream("_", New MemoryStream())}))
Assert.Throws(Of ArgumentException)("embeddedTexts", Sub() comp.Emit(
peStream:=New MemoryStream(),
pdbStream:=Nothing,
options:=EmitOptions.Default.WithDebugInformationFormat(DebugInformationFormat.PortablePdb),
embeddedTexts:={EmbeddedText.FromStream("_", New MemoryStream())}))
Assert.Throws(Of ArgumentException)("win32Resources", Sub() comp.Emit(
peStream:=New MemoryStream(),
win32Resources:=New TestStream(canRead:=True, canWrite:=False, canSeek:=False)))
Assert.Throws(Of ArgumentException)("win32Resources", Sub() comp.Emit(
peStream:=New MemoryStream(),
win32Resources:=New TestStream(canRead:=False, canWrite:=False, canSeek:=True)))
' we don't report an error when we can't write to the XML doc stream:
Assert.True(comp.Emit(
peStream:=New MemoryStream(),
pdbStream:=New MemoryStream(),
xmlDocumentationStream:=New TestStream(canRead:=True, canWrite:=False, canSeek:=True)).Success)
End Sub
<Fact>
Public Sub EmitOptionsDiagnostics()
Dim c = CreateCompilationWithMscorlib40({"class C {}"})
Dim stream = New MemoryStream()
Dim options = New EmitOptions(
debugInformationFormat:=CType(-1, DebugInformationFormat),
outputNameOverride:=" ",
fileAlignment:=513,
subsystemVersion:=SubsystemVersion.Create(1000000, -1000000),
pdbChecksumAlgorithm:=New HashAlgorithmName("invalid hash algorithm name"))
Dim result = c.Emit(stream, options:=options)
result.Diagnostics.Verify(
Diagnostic(ERRID.ERR_InvalidDebugInformationFormat).WithArguments("-1"),
Diagnostic(ERRID.ERR_InvalidOutputName).WithArguments("Name cannot start with whitespace."),
Diagnostic(ERRID.ERR_InvalidFileAlignment).WithArguments("513"),
Diagnostic(ERRID.ERR_InvalidSubsystemVersion).WithArguments("1000000.-1000000"),
Diagnostic(ERRID.ERR_InvalidHashAlgorithmName).WithArguments("invalid hash algorithm name"))
Assert.False(result.Success)
End Sub
<Fact>
Sub EmitOptions_PdbChecksumAndDeterminism()
Dim options = New EmitOptions(pdbChecksumAlgorithm:=New HashAlgorithmName())
Dim diagnosticBag = New DiagnosticBag()
options.ValidateOptions(diagnosticBag, MessageProvider.Instance, isDeterministic:=True)
diagnosticBag.Verify(
Diagnostic(ERRID.ERR_InvalidHashAlgorithmName).WithArguments(""))
diagnosticBag.Clear()
options.ValidateOptions(diagnosticBag, MessageProvider.Instance, isDeterministic:=False)
diagnosticBag.Verify()
End Sub
<Fact>
Public Sub ReferenceAPITest()
' Create Compilation takes two args
Dim comp = VisualBasicCompilation.Create("Compilation")
Dim ref1 = Net451.mscorlib
Dim ref2 = Net451.System
Dim ref3 = New TestMetadataReference(fullPath:="c:\xml.bms")
Dim ref4 = New TestMetadataReference(fullPath:="c:\aaa.dll")
' Add a new empty item
comp = comp.AddReferences(Enumerable.Empty(Of MetadataReference)())
Assert.Equal(0, comp.References.Count)
' Add a new valid item
comp = comp.AddReferences(ref1)
Dim assemblySmb = comp.GetReferencedAssemblySymbol(ref1)
Assert.NotNull(assemblySmb)
Assert.Equal("mscorlib", assemblySmb.Name, StringComparer.OrdinalIgnoreCase)
Assert.Equal(1, comp.References.Count)
Assert.Equal(MetadataImageKind.Assembly, comp.References(0).Properties.Kind)
Assert.Same(ref1, comp.References(0))
' Replace an existing item with another valid item
comp = comp.ReplaceReference(ref1, ref2)
Assert.Equal(1, comp.References.Count)
Assert.Equal(MetadataImageKind.Assembly, comp.References(0).Properties.Kind)
Assert.Equal(ref2, comp.References(0))
' Remove an existing item
comp = comp.RemoveReferences(ref2)
Assert.Equal(0, comp.References.Count)
'WithReferences
Dim hs1 As New HashSet(Of MetadataReference) From {ref1, ref2, ref3}
Dim compCollection1 = VisualBasicCompilation.Create("Compilation")
Assert.Equal(Of Integer)(0, Enumerable.Count(Of MetadataReference)(compCollection1.References))
Dim c2 As Compilation = compCollection1.WithReferences(hs1)
Assert.Equal(Of Integer)(3, Enumerable.Count(Of MetadataReference)(c2.References))
'WithReferences
Dim compCollection2 = VisualBasicCompilation.Create("Compilation")
Assert.Equal(Of Integer)(0, Enumerable.Count(Of MetadataReference)(compCollection2.References))
Dim c3 As Compilation = compCollection1.WithReferences(ref1, ref2, ref3)
Assert.Equal(Of Integer)(3, Enumerable.Count(Of MetadataReference)(c3.References))
'ReferencedAssemblyNames
Dim RefAsm_Names As IEnumerable(Of AssemblyIdentity) = c2.ReferencedAssemblyNames
Assert.Equal(Of Integer)(2, Enumerable.Count(Of AssemblyIdentity)(RefAsm_Names))
Dim ListNames As New List(Of String)
Dim I As AssemblyIdentity
For Each I In RefAsm_Names
ListNames.Add(I.Name)
Next
Assert.Contains(Of String)("mscorlib", ListNames)
Assert.Contains(Of String)("System", ListNames)
'RemoveAllReferences
c2 = c2.RemoveAllReferences
Assert.Equal(Of Integer)(0, Enumerable.Count(Of MetadataReference)(c2.References))
' Overload with Hashset
Dim hs = New HashSet(Of MetadataReference)() From {ref1, ref2, ref3}
Dim compCollection = VisualBasicCompilation.Create("Compilation", references:=hs)
compCollection = compCollection.AddReferences(ref1, ref2, ref3, ref4).RemoveReferences(hs)
Assert.Equal(1, compCollection.References.Count)
compCollection = compCollection.AddReferences(hs).RemoveReferences(ref1, ref2, ref3, ref4)
Assert.Equal(0, compCollection.References.Count)
' Overload with Collection
Dim col = New ObjectModel.Collection(Of MetadataReference)() From {ref1, ref2, ref3}
compCollection = VisualBasicCompilation.Create("Compilation", references:=col)
compCollection = compCollection.AddReferences(col).RemoveReferences(ref1, ref2, ref3)
Assert.Equal(0, compCollection.References.Count)
compCollection = compCollection.AddReferences(ref1, ref2, ref3).RemoveReferences(col)
Assert.Equal(0, comp.References.Count)
' Overload with ConcurrentStack
Dim stack = New Concurrent.ConcurrentStack(Of MetadataReference)
stack.Push(ref1)
stack.Push(ref2)
stack.Push(ref3)
compCollection = VisualBasicCompilation.Create("Compilation", references:=stack)
compCollection = compCollection.AddReferences(stack).RemoveReferences(ref1, ref3, ref2)
Assert.Equal(0, compCollection.References.Count)
compCollection = compCollection.AddReferences(ref2, ref1, ref3).RemoveReferences(stack)
Assert.Equal(0, compCollection.References.Count)
' Overload with ConcurrentQueue
Dim queue = New Concurrent.ConcurrentQueue(Of MetadataReference)
queue.Enqueue(ref1)
queue.Enqueue(ref2)
queue.Enqueue(ref3)
compCollection = VisualBasicCompilation.Create("Compilation", references:=queue)
compCollection = compCollection.AddReferences(queue).RemoveReferences(ref3, ref2, ref1)
Assert.Equal(0, compCollection.References.Count)
compCollection = compCollection.AddReferences(ref2, ref1, ref3).RemoveReferences(queue)
Assert.Equal(0, compCollection.References.Count)
End Sub
<WorkItem(537826, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/537826")>
<Fact>
Public Sub SyntreeAPITest()
Dim s1 = "using System.Linq;"
Dim s2 = <![CDATA[Class goo
sub main
Public Operator
End Operator
End Class
]]>.Value
Dim s3 = "Imports s$ = System.Text"
Dim s4 = <text>
Module Module1
Sub Goo()
for i = 0 to 100
next
end sub
End Module
</text>.Value
Dim t1 = VisualBasicSyntaxTree.ParseText(s4)
Dim withErrorTree = VisualBasicSyntaxTree.ParseText(s2)
Dim withErrorTree1 = VisualBasicSyntaxTree.ParseText(s3)
Dim withErrorTreeCS = VisualBasicSyntaxTree.ParseText(s1)
Dim withExpressionRootTree = SyntaxFactory.ParseExpression("0").SyntaxTree
' Create compilation takes three args
Dim comp = VisualBasicCompilation.Create("Compilation",
{t1},
{MscorlibRef, MsvbRef},
TestOptions.ReleaseDll)
Dim tree = comp.SyntaxTrees.AsEnumerable()
comp.VerifyDiagnostics()
' Add syntaxtree with error
comp = comp.AddSyntaxTrees(withErrorTreeCS)
Assert.Equal(2, comp.GetDiagnostics().Length())
' Remove syntaxtree without error
comp = comp.RemoveSyntaxTrees(tree)
Assert.Equal(2, comp.GetDiagnostics(cancellationToken:=CancellationToken.None).Length())
' Remove syntaxtree with error
comp = comp.RemoveSyntaxTrees(withErrorTreeCS)
Assert.Equal(0, comp.GetDiagnostics().Length())
Assert.Equal(0, comp.GetDeclarationDiagnostics().Length())
' Get valid binding
Dim bind = comp.GetSemanticModel(syntaxTree:=t1)
Assert.NotNull(bind)
' Get Binding with tree is not exist
bind = comp.GetSemanticModel(withErrorTree)
Assert.NotNull(bind)
' Add syntaxtree which is CS language
comp = comp.AddSyntaxTrees(withErrorTreeCS)
Assert.Equal(2, comp.GetDiagnostics().Length())
comp = comp.RemoveSyntaxTrees(withErrorTreeCS)
Assert.Equal(0, comp.GetDiagnostics().Length())
comp = comp.AddSyntaxTrees(t1, withErrorTree, withErrorTree1, withErrorTreeCS)
comp = comp.RemoveSyntaxTrees(t1, withErrorTree, withErrorTree1, withErrorTreeCS)
' Add a new empty item
comp = comp.AddSyntaxTrees(Enumerable.Empty(Of SyntaxTree))
Assert.Equal(0, comp.SyntaxTrees.Length)
' Add a new valid item
comp = comp.AddSyntaxTrees(t1)
Assert.Equal(1, comp.SyntaxTrees.Length)
comp = comp.AddSyntaxTrees(VisualBasicSyntaxTree.ParseText(s4))
Assert.Equal(2, comp.SyntaxTrees.Length)
' Replace an existing item with another valid item
comp = comp.ReplaceSyntaxTree(t1, VisualBasicSyntaxTree.ParseText(s4))
Assert.Equal(2, comp.SyntaxTrees.Length)
' Replace an existing item with same item
comp = comp.AddSyntaxTrees(t1).ReplaceSyntaxTree(t1, t1)
Assert.Equal(3, comp.SyntaxTrees.Length)
' Replace with existing and verify that it throws
Assert.Throws(Of ArgumentException)(Sub() comp.ReplaceSyntaxTree(t1, comp.SyntaxTrees(0)))
Assert.Throws(Of ArgumentException)(Sub() comp.AddSyntaxTrees(t1))
' SyntaxTrees have reference equality. This removal should fail.
Assert.Throws(Of ArgumentException)(Sub() comp = comp.RemoveSyntaxTrees(VisualBasicSyntaxTree.ParseText(s4)))
Assert.Equal(3, comp.SyntaxTrees.Length)
' Remove non-existing item
Assert.Throws(Of ArgumentException)(Sub() comp = comp.RemoveSyntaxTrees(withErrorTree))
Assert.Equal(3, comp.SyntaxTrees.Length)
Dim t4 = VisualBasicSyntaxTree.ParseText("Using System;")
Dim t5 = VisualBasicSyntaxTree.ParseText("Usingsssssssssssss System;")
Dim t6 = VisualBasicSyntaxTree.ParseText("Import System")
' Overload with Hashset
Dim hs = New HashSet(Of SyntaxTree) From {t4, t5, t6}
Dim compCollection = VisualBasicCompilation.Create("Compilation", syntaxTrees:=hs)
compCollection = compCollection.RemoveSyntaxTrees(hs)
Assert.Equal(0, compCollection.SyntaxTrees.Length)
compCollection = compCollection.AddSyntaxTrees(hs).RemoveSyntaxTrees(t4, t5, t6)
Assert.Equal(0, compCollection.SyntaxTrees.Length)
' Overload with Collection
Dim col = New ObjectModel.Collection(Of SyntaxTree) From {t4, t5, t6}
compCollection = VisualBasicCompilation.Create("Compilation", syntaxTrees:=col)
compCollection = compCollection.RemoveSyntaxTrees(t4, t5, t6)
Assert.Equal(0, compCollection.SyntaxTrees.Length)
Assert.Throws(Of ArgumentException)(Sub() compCollection = compCollection.AddSyntaxTrees(t4, t5).RemoveSyntaxTrees(col))
Assert.Equal(0, compCollection.SyntaxTrees.Length)
' Overload with ConcurrentStack
Dim stack = New Concurrent.ConcurrentStack(Of SyntaxTree)
stack.Push(t4)
stack.Push(t5)
stack.Push(t6)
compCollection = VisualBasicCompilation.Create("Compilation", syntaxTrees:=stack)
compCollection = compCollection.RemoveSyntaxTrees(t4, t6, t5)
Assert.Equal(0, compCollection.SyntaxTrees.Length)
Assert.Throws(Of ArgumentException)(Sub() compCollection = compCollection.AddSyntaxTrees(t4, t6).RemoveSyntaxTrees(stack))
Assert.Equal(0, compCollection.SyntaxTrees.Length)
' Overload with ConcurrentQueue
Dim queue = New Concurrent.ConcurrentQueue(Of SyntaxTree)
queue.Enqueue(t4)
queue.Enqueue(t5)
queue.Enqueue(t6)
compCollection = VisualBasicCompilation.Create("Compilation", syntaxTrees:=queue)
compCollection = compCollection.RemoveSyntaxTrees(t4, t6, t5)
Assert.Equal(0, compCollection.SyntaxTrees.Length)
Assert.Throws(Of ArgumentException)(Sub() compCollection = compCollection.AddSyntaxTrees(t4, t6).RemoveSyntaxTrees(queue))
Assert.Equal(0, compCollection.SyntaxTrees.Length)
' VisualBasicCompilation.Create with syntaxtree with a non-CompilationUnit root node: should throw an ArgumentException.
Assert.False(withExpressionRootTree.HasCompilationUnitRoot, "how did we get a CompilationUnit root?")
Assert.Throws(Of ArgumentException)(Sub() VisualBasicCompilation.Create("Compilation", syntaxTrees:={withExpressionRootTree}))
' AddSyntaxTrees with a non-CompilationUnit root node: should throw an ArgumentException.
Assert.Throws(Of ArgumentException)(Sub() comp.AddSyntaxTrees(withExpressionRootTree))
' ReplaceSyntaxTrees syntaxtree with a non-CompilationUnit root node: should throw an ArgumentException.
Assert.Throws(Of ArgumentException)(Sub() comp.ReplaceSyntaxTree(comp.SyntaxTrees(0), withExpressionRootTree))
End Sub
<Fact>
Public Sub ChainedOperations()
Dim s1 = "using System.Linq;"
Dim s2 = ""
Dim s3 = "Import System"
Dim t1 = VisualBasicSyntaxTree.ParseText(s1)
Dim t2 = VisualBasicSyntaxTree.ParseText(s2)
Dim t3 = VisualBasicSyntaxTree.ParseText(s3)
Dim listSyntaxTree = New List(Of SyntaxTree)
listSyntaxTree.Add(t1)
listSyntaxTree.Add(t2)
' Remove second SyntaxTree
Dim comp = VisualBasicCompilation.Create("Compilation")
comp = comp.AddSyntaxTrees(listSyntaxTree).RemoveSyntaxTrees(t2)
Assert.Equal(1, comp.SyntaxTrees.Length)
'ContainsSyntaxTree
Dim b1 As Boolean = comp.ContainsSyntaxTree(t2)
Assert.Equal(Of Boolean)(False, b1)
comp = comp.AddSyntaxTrees({t2})
b1 = comp.ContainsSyntaxTree(t2)
Assert.Equal(Of Boolean)(True, b1)
Dim xt As SyntaxTree = Nothing
Assert.Throws(Of ArgumentNullException)(Sub()
b1 = comp.ContainsSyntaxTree(xt)
End Sub)
comp = comp.RemoveSyntaxTrees({t2})
Assert.Equal(1, comp.SyntaxTrees.Length)
comp = comp.AddSyntaxTrees({t2})
Assert.Equal(2, comp.SyntaxTrees.Length)
'RemoveAllSyntaxTrees
comp = comp.RemoveAllSyntaxTrees
Assert.Equal(0, comp.SyntaxTrees.Length)
comp = VisualBasicCompilation.Create("Compilation").AddSyntaxTrees(listSyntaxTree).RemoveSyntaxTrees({t2})
Assert.Equal(Of Integer)(1, comp.SyntaxTrees.Length)
Assert.Equal(Of String)("Object", comp.ObjectType.Name)
' Remove mid SyntaxTree
listSyntaxTree.Add(t3)
comp = comp.RemoveSyntaxTrees(t1).AddSyntaxTrees(listSyntaxTree).RemoveSyntaxTrees(t2)
Assert.Equal(2, comp.SyntaxTrees.Length)
' remove list
listSyntaxTree.Remove(t2)
comp = comp.AddSyntaxTrees().RemoveSyntaxTrees(listSyntaxTree)
comp = comp.AddSyntaxTrees(listSyntaxTree).RemoveSyntaxTrees(listSyntaxTree)
Assert.Equal(0, comp.SyntaxTrees.Length)
listSyntaxTree.Clear()
listSyntaxTree.Add(t1)
' Chained operation count > 2
comp = comp.AddSyntaxTrees(listSyntaxTree).AddReferences().ReplaceSyntaxTree(t1, t2)
Assert.Equal(1, comp.SyntaxTrees.Length)
Assert.Equal(0, comp.References.Count)
' Create compilation with args is disordered
Dim comp1 = VisualBasicCompilation.Create("Compilation")
Dim Err = "c:\file_that_does_not_exist"
Dim ref1 = Net451.mscorlib
Dim listRef = New List(Of MetadataReference)
' this is NOT testing Roslyn
listRef.Add(ref1)
listRef.Add(ref1)
' Remove with no args
comp1 = comp1.AddReferences(listRef).AddSyntaxTrees(listSyntaxTree).RemoveReferences().RemoveSyntaxTrees()
'should have only added one reference since ref1.Equals(ref1) and Equal references are added only once.
Assert.Equal(1, comp1.References.Count)
Assert.Equal(1, comp1.SyntaxTrees.Length)
End Sub
<WorkItem(713356, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/713356")>
<Fact()>
Public Sub MissedModuleA()
Dim netModule1 = CreateCompilationWithMscorlib40AndVBRuntime(
<compilation name="missing1">
<file name="a.vb">
Class C1
End Class
</file>
</compilation>, options:=TestOptions.ReleaseModule)
netModule1.VerifyDiagnostics()
Dim netModule2 = CreateCompilationWithMscorlib40AndVBRuntimeAndReferences(
<compilation name="missing2">
<file name="a.vb">
Class C2
Public Shared Sub M()
Dim a As New C1()
End Sub
End Class
</file>
</compilation>, references:={netModule1.EmitToImageReference()}, options:=TestOptions.ReleaseModule)
netModule2.VerifyDiagnostics()
Dim assembly = CreateCompilationWithMscorlib40AndVBRuntimeAndReferences(
<compilation name="missing">
<file name="a.vb">
Class C3
Public Shared Sub Main(args() As String)
Dim a As New C2()
End Sub
End Class
</file>
</compilation>, references:={netModule2.EmitToImageReference()})
assembly.VerifyDiagnostics(Diagnostic(ERRID.ERR_MissingNetModuleReference).WithArguments("missing1.netmodule"))
assembly = CreateCompilationWithMscorlib40AndVBRuntimeAndReferences(
<compilation name="MissedModuleA">
<file name="a.vb">
Class C3
Public Shared Sub Main(args() As String)
Dim a As New C2()
End Sub
End Class
</file>
</compilation>, references:={netModule1.EmitToImageReference(), netModule2.EmitToImageReference()})
assembly.VerifyDiagnostics()
CompileAndVerify(assembly)
End Sub
<WorkItem(713356, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/713356")>
<Fact()>
Public Sub MissedModuleB_OneError()
Dim netModule1 = CreateCompilationWithMscorlib40AndVBRuntime(
<compilation name="a1">
<file name="a.vb">
Class C1
End Class
</file>
</compilation>, options:=TestOptions.ReleaseModule)
CompilationUtils.AssertNoDiagnostics(netModule1)
Dim netModule2 = CreateCompilationWithMscorlib40AndVBRuntimeAndReferences(
<compilation name="a2">
<file name="a.vb">
Class C2
Public Shared Sub M()
Dim a As New C1()
End Sub
End Class
</file>
</compilation>, references:={netModule1.EmitToImageReference()}, options:=TestOptions.ReleaseModule)
CompilationUtils.AssertNoDiagnostics(netModule2)
Dim netModule3 = CreateCompilationWithMscorlib40AndVBRuntimeAndReferences(
<compilation name="a3">
<file name="a.vb">
Class C22
Public Shared Sub M()
Dim a As New C1()
End Sub
End Class
</file>
</compilation>, references:={netModule1.EmitToImageReference()}, options:=TestOptions.ReleaseModule)
CompilationUtils.AssertNoDiagnostics(netModule3)
Dim assembly = CreateCompilationWithMscorlib40AndVBRuntimeAndReferences(
<compilation name="a">
<file name="a.vb">
Class C3
Public Shared Sub Main(args() As String)
Dim a As New C2()
Dim b As New C22()
End Sub
End Class
</file>
</compilation>, references:={netModule2.EmitToImageReference(), netModule3.EmitToImageReference()})
CompilationUtils.AssertTheseDiagnostics(assembly,
<errors>
BC37221: Reference to 'a1.netmodule' netmodule missing.
</errors>)
End Sub
<WorkItem(718500, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/718500")>
<WorkItem(716762, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/716762")>
<Fact()>
Public Sub MissedModuleB_NoErrorForUnmanagedModules()
Dim netModule1 = CreateCompilationWithMscorlib40AndVBRuntime(
<compilation name="a1">
<file name="a.vb">
Imports System.Runtime.InteropServices
Public Class ClassDLLImports
Declare Function getUserName Lib "advapi32.dll" Alias "GetUserNameA" (
ByVal lpBuffer As String, ByRef nSize As Integer) As Integer
End Class
</file>
</compilation>, options:=TestOptions.ReleaseModule)
CompilationUtils.AssertNoDiagnostics(netModule1)
Dim assembly = CreateCompilationWithMscorlib40AndVBRuntimeAndReferences(
<compilation name="a">
<file name="a.vb">
Class C3
Public Shared Sub Main(args() As String)
End Sub
End Class
</file>
</compilation>, references:={netModule1.EmitToImageReference(expectedWarnings:={
Diagnostic(ERRID.HDN_UnusedImportStatement, "Imports System.Runtime.InteropServices")})})
assembly.AssertNoDiagnostics()
End Sub
<WorkItem(715872, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/715872")>
<Fact()>
Public Sub MissedModuleC()
Dim netModule1 = CreateCompilationWithMscorlib40AndVBRuntime(
<compilation name="a1">
<file name="a.vb">
Class C1
End Class
</file>
</compilation>, options:=TestOptions.ReleaseModule)
CompilationUtils.AssertNoDiagnostics(netModule1)
Dim netModule2 = CreateCompilationWithMscorlib40AndVBRuntimeAndReferences(
<compilation name="a1">
<file name="a.vb">
Class C2
Public Shared Sub M()
End Sub
End Class
</file>
</compilation>, references:={netModule1.EmitToImageReference()}, options:=TestOptions.ReleaseModule)
CompilationUtils.AssertNoDiagnostics(netModule2)
Dim assembly = CreateCompilationWithMscorlib40AndVBRuntimeAndReferences(
<compilation name="a">
<file name="a.vb">
Class C3
Public Shared Sub Main(args() As String)
Dim a As New C2()
End Sub
End Class
</file>
</compilation>, references:={netModule1.EmitToImageReference(), netModule2.EmitToImageReference()})
CompilationUtils.AssertTheseDiagnostics(assembly,
<errors>
BC37224: Module 'a1.netmodule' is already defined in this assembly. Each module must have a unique filename.
</errors>)
End Sub
<Fact>
Public Sub MixedRefType()
' Create compilation takes three args
Dim csComp = CS.CSharpCompilation.Create("CompilationVB")
Dim comp = VisualBasicCompilation.Create("Compilation")
' this is NOT right path,
' please don't use VB dll (there is a change to the location in Dev11; you test will fail then)
csComp = csComp.AddReferences(SystemRef)
' Add VB reference to C# compilation
For Each item In csComp.References
comp = comp.AddReferences(item)
comp = comp.ReplaceReference(item, item)
Next
Assert.Equal(1, comp.References.Count)
Dim text1 = "Imports System"
Dim comp1 = VisualBasicCompilation.Create("Test1", {VisualBasicSyntaxTree.ParseText(text1)})
Dim comp2 = VisualBasicCompilation.Create("Test2", {VisualBasicSyntaxTree.ParseText(text1)})
Dim compRef1 = comp1.ToMetadataReference()
Dim compRef2 = comp2.ToMetadataReference()
Dim csCompRef = csComp.ToMetadataReference(embedInteropTypes:=True)
Dim ref1 = Net451.mscorlib
Dim ref2 = Net451.System
' Add VisualBasicCompilationReference
comp = VisualBasicCompilation.Create("Test1",
{VisualBasicSyntaxTree.ParseText(text1)},
{compRef1, compRef2})
Assert.Equal(2, comp.References.Count)
Assert.Equal(MetadataImageKind.Assembly, comp.References(0).Properties.Kind)
Assert.Contains(compRef1, comp.References)
Assert.Contains(compRef2, comp.References)
Dim smb = comp.GetReferencedAssemblySymbol(compRef1)
Assert.Equal(smb.Kind, SymbolKind.Assembly)
Assert.Equal("Test1", smb.Identity.Name, StringComparer.OrdinalIgnoreCase)
' Mixed reference type
comp = comp.AddReferences(ref1)
Assert.Equal(3, comp.References.Count)
Assert.Contains(ref1, comp.References)
' Replace Compilation reference with Assembly file reference
comp = comp.ReplaceReference(compRef2, ref2)
Assert.Equal(3, comp.References.Count)
Assert.Contains(ref2, comp.References)
' Replace Assembly file reference with Compilation reference
comp = comp.ReplaceReference(ref1, compRef2)
Assert.Equal(3, comp.References.Count)
Assert.Contains(compRef2, comp.References)
Dim modRef1 = ModuleMetadata.CreateFromImage(TestResources.MetadataTests.NetModule01.ModuleCS00).GetReference()
' Add Module file reference
comp = comp.AddReferences(modRef1)
' Not Implemented
'Dim modSmb = comp.GetReferencedModuleSymbol(modRef1)
'Assert.Equal("ModuleCS00.mod", modSmb.Name)
'Assert.Equal(4, comp.References.Count)
'Assert.True(comp.References.Contains(modRef1))
' Get Referenced Assembly Symbol
'smb = comp.GetReferencedAssemblySymbol(reference:=modRef1)
'Assert.Equal(smb.Kind, SymbolKind.Assembly)
'Assert.True(String.Equals(smb.AssemblyName.Name, "Test1", StringComparison.OrdinalIgnoreCase))
' Get Referenced Module Symbol
'Dim moduleSmb = comp.GetReferencedModuleSymbol(reference:=modRef1)
'Assert.Equal(moduleSmb.Kind, SymbolKind.NetModule)
'Assert.True(String.Equals(moduleSmb.Name, "ModuleCS00.mod", StringComparison.OrdinalIgnoreCase))
' Not implemented
' Get Compilation Namespace
'Dim nsSmb = comp.GlobalNamespace
'Dim ns = comp.GetCompilationNamespace(ns:=nsSmb)
'Assert.Equal(ns.Kind, SymbolKind.Namespace)
'Assert.True(String.Equals(ns.Name, "Compilation", StringComparison.OrdinalIgnoreCase))
' Not implemented
' GetCompilationNamespace (Derived Class MergedNamespaceSymbol)
'Dim merged As NamespaceSymbol = MergedNamespaceSymbol.Create(New NamespaceExtent(New MockAssemblySymbol("Merged")), Nothing, Nothing)
'ns = comp.GetCompilationNamespace(ns:=merged)
'Assert.Equal(ns.Kind, SymbolKind.Namespace)
'Assert.True(String.Equals(ns.Name, "Compilation", StringComparison.OrdinalIgnoreCase))
' Not implemented
' GetCompilationNamespace (Derived Class PENamespaceSymbol)
'Dim pensSmb As Metadata.PE.PENamespaceSymbol = CType(nsSmb, Metadata.PE.PENamespaceSymbol)
'ns = comp.GetCompilationNamespace(ns:=pensSmb)
'Assert.Equal(ns.Kind, SymbolKind.Namespace)
'Assert.True(String.Equals(ns.Name, "Compilation", StringComparison.OrdinalIgnoreCase))
' Replace Module file reference with compilation reference
comp = comp.RemoveReferences(compRef1).ReplaceReference(modRef1, compRef1)
Assert.Equal(3, comp.References.Count)
' Check the reference order after replace
Assert.Equal(MetadataImageKind.Assembly, comp.References(2).Properties.Kind)
Assert.Equal(compRef1, comp.References(2))
' Replace compilation Module file reference with Module file reference
comp = comp.ReplaceReference(compRef1, modRef1)
' Check the reference order after replace
Assert.Equal(3, comp.References.Count)
Assert.Equal(MetadataImageKind.Module, comp.References(2).Properties.Kind)
Assert.Equal(modRef1, comp.References(2))
' Add CS compilation ref
Assert.Throws(Of ArgumentException)(Function() comp.AddReferences(csCompRef))
For Each item In comp.References
comp = comp.RemoveReferences(item)
Next
Assert.Equal(0, comp.References.Count)
' Not Implemented
' Dim asmByteRef = MetadataReference.CreateFromImage(New Byte(4) {}, "AssemblyBytesRef1", embedInteropTypes:=True)
'Dim asmObjectRef = New AssemblyObjectReference(assembly:=System.Reflection.Assembly.GetAssembly(GetType(Object)), embedInteropTypes:=True)
'comp = comp.AddReferences(asmByteRef, asmObjectRef)
'Assert.Equal(2, comp.References.Count)
'Assert.Equal(ReferenceKind.AssemblyBytes, comp.References(0).Kind)
'Assert.Equal(ReferenceKind.AssemblyObject, comp.References(1).Kind)
'Assert.Equal(asmByteRef, comp.References(0))
'Assert.Equal(asmObjectRef, comp.References(1))
'Assert.True(comp.References(0).EmbedInteropTypes)
'Assert.True(comp.References(1).EmbedInteropTypes)
End Sub
<Fact>
Public Sub ModuleSuppliedAsAssembly()
Dim comp = VisualBasicCompilation.Create("Compilation", references:={AssemblyMetadata.CreateFromImage(TestResources.MetadataTests.NetModule01.ModuleVB01).GetReference()})
Assert.Equal(comp.GetDiagnostics().First().Code, ERRID.ERR_MetaDataIsNotAssembly)
End Sub
<Fact>
Public Sub AssemblySuppliedAsModule()
Dim comp = VisualBasicCompilation.Create("Compilation", references:={ModuleMetadata.CreateFromImage(ResourcesNet451.System).GetReference()})
Assert.Equal(comp.GetDiagnostics().First().Code, ERRID.ERR_MetaDataIsNotModule)
End Sub
'' Get nonexistent Referenced Assembly Symbol
<WorkItem(537637, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/537637")>
<Fact>
Public Sub NegReference1()
Dim comp = VisualBasicCompilation.Create("Compilation")
Assert.Null(comp.GetReferencedAssemblySymbol(Net451.System))
Dim modRef1 = ModuleMetadata.CreateFromImage(TestResources.MetadataTests.NetModule01.ModuleVB01).GetReference()
Assert.Null(comp.GetReferencedModuleSymbol(modRef1))
End Sub
'' Add already existing item
<WorkItem(537617, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/537617")>
<Fact>
Public Sub NegReference2()
Dim comp = VisualBasicCompilation.Create("Compilation")
Dim ref1 = Net451.System
Dim ref2 = New TestMetadataReference(fullPath:="c:\a\xml.bms")
Dim ref3 = ref2
Dim ref4 = New TestMetadataReference(fullPath:="c:\aaa.dll")
comp = comp.AddReferences(ref1, ref1)
Assert.Equal(1, comp.References.Count)
Assert.Equal(ref1, comp.References(0))
' Remove non-existing item
Assert.Throws(Of ArgumentException)(Function() comp.RemoveReferences(ref2))
Dim listRef = New List(Of MetadataReference) From {ref1, ref2, ref3, ref4}
comp = comp.AddReferences(listRef).AddReferences(ref2).ReplaceReference(ref2, ref2)
Assert.Equal(3, comp.References.Count)
comp = comp.RemoveReferences(listRef).AddReferences(ref1)
Assert.Equal(1, comp.References.Count)
Assert.Equal(ref1, comp.References(0))
End Sub
'' Add a new invalid item
<WorkItem(537575, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/537575")>
<Fact>
Public Sub NegReference3()
Dim comp = VisualBasicCompilation.Create("Compilation")
Dim ref1 = New TestMetadataReference(fullPath:="c:\xml.bms")
Dim ref2 = Net451.System
comp = comp.AddReferences(ref1)
Assert.Equal(1, comp.References.Count)
' Replace a non-existing item with another invalid item
Assert.Throws(Of ArgumentException)(Sub()
comp = comp.ReplaceReference(ref2, ref1)
End Sub)
Assert.Equal(1, comp.References.Count)
End Sub
'' Replace a non-existing item with null
<WorkItem(537567, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/537567")>
<Fact>
Public Sub NegReference4()
Dim opt = TestOptions.ReleaseExe
Dim comp = VisualBasicCompilation.Create("Compilation")
Dim ref1 = New TestMetadataReference(fullPath:="c:\xml.bms")
Assert.Throws(Of ArgumentException)(
Sub()
comp.ReplaceReference(ref1, Nothing)
End Sub)
' Replace null and the arg order of replace is vise
Assert.Throws(Of ArgumentNullException)(
Sub()
comp.ReplaceReference(newReference:=ref1, oldReference:=Nothing)
End Sub)
End Sub
'' Replace a non-existing item with another valid item
<WorkItem(537566, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/537566")>
<Fact>
Public Sub NegReference5()
Dim comp = VisualBasicCompilation.Create("Compilation")
Dim ref1 = Net451.mscorlib
Dim ref2 = Net451.System
Assert.Throws(Of ArgumentException)(
Sub()
comp = comp.ReplaceReference(ref1, ref2)
End Sub)
Dim s1 = "Imports System.Text"
Dim t1 = Parse(s1)
' Replace a non-existing item with another valid item and disorder the args
Assert.Throws(Of ArgumentException)(Sub()
comp.ReplaceSyntaxTree(newTree:=VisualBasicSyntaxTree.ParseText("Imports System"), oldTree:=t1)
End Sub)
Assert.Equal(0, comp.References.Count)
End Sub
'' Throw exception when add Nothing references
<WorkItem(537618, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/537618")>
<Fact>
Public Sub NegReference6()
Dim opt = TestOptions.ReleaseExe
Dim comp = VisualBasicCompilation.Create("Compilation")
Assert.Throws(Of ArgumentNullException)(Sub() comp = comp.AddReferences(Nothing))
End Sub
'' Throw exception when remove Nothing references
<WorkItem(537621, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/537621")>
<Fact>
Public Sub NegReference7()
Dim opt = TestOptions.ReleaseExe
Dim comp = VisualBasicCompilation.Create("Compilation")
Dim RemoveNothingRefEx = Assert.Throws(Of ArgumentNullException)(Sub() comp = comp.RemoveReferences(Nothing))
End Sub
'' Add already existing item
<WorkItem(537576, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/537576")>
<Fact>
Public Sub NegSyntaxTree1()
Dim opt = TestOptions.ReleaseExe
Dim comp = VisualBasicCompilation.Create("Compilation")
Dim t1 = VisualBasicSyntaxTree.ParseText("Using System;")
Assert.Throws(Of ArgumentException)(Sub() comp.AddSyntaxTrees(t1, t1))
Assert.Equal(0, comp.SyntaxTrees.Length)
End Sub
' Throw exception when the parameter of ContainsSyntaxTrees is null
<WorkItem(527256, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/527256")>
<Fact>
Public Sub NegContainsSyntaxTrees()
Dim opt = TestOptions.ReleaseExe
Dim comp = VisualBasicCompilation.Create("Compilation")
Assert.False(comp.SyntaxTrees.Contains(Nothing))
End Sub
' Throw exception when the parameter of AddReferences is CSharpCompilationReference
<WorkItem(537778, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/537778")>
<Fact>
Public Sub NegGetSymbol()
Dim opt = TestOptions.ReleaseExe
Dim comp = VisualBasicCompilation.Create("Compilation")
Dim csComp = CS.CSharpCompilation.Create("CompilationCS")
Dim compRef = csComp.ToMetadataReference()
Assert.Throws(Of ArgumentException)(Function() comp.AddReferences(compRef))
'' Throw exception when the parameter of GetReferencedAssemblySymbol is null
'Assert.Throws(Of ArgumentNullException)(Sub() comp.GetReferencedAssemblySymbol(Nothing))
'' Throw exception when the parameter of GetReferencedModuleSymbol is null
'Assert.Throws(Of ArgumentNullException)(
' Sub()
' comp.GetReferencedModuleSymbol(Nothing)
' End Sub)
End Sub
'' Throw exception when the parameter of GetSpecialType is 'SpecialType.None'
<WorkItem(537784, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/537784")>
<Fact>
Public Sub NegGetSpecialType()
Dim comp = VisualBasicCompilation.Create("Compilation")
Assert.Throws(Of ArgumentOutOfRangeException)(
Sub()
comp.GetSpecialType((SpecialType.None))
End Sub)
' Throw exception when the parameter of GetSpecialType is '0'
Assert.Throws(Of ArgumentOutOfRangeException)(
Sub()
comp.GetSpecialType(CType(0, SpecialType))
End Sub)
' Throw exception when the parameter of GetBinding is out of range
Assert.Throws(Of ArgumentOutOfRangeException)(
Sub()
comp.GetSpecialType(CType(100, SpecialType))
End Sub)
' Throw exception when the parameter of GetCompilationNamespace is null
Assert.Throws(Of ArgumentNullException)(
Sub()
comp.GetCompilationNamespace(namespaceSymbol:=Nothing)
End Sub)
Dim bind = comp.GetSemanticModel(Nothing)
Assert.NotNull(bind)
End Sub
<Fact>
Public Sub NegSynTree()
Dim comp = VisualBasicCompilation.Create("Compilation")
Dim s1 = "Imports System.Text"
Dim tree = VisualBasicSyntaxTree.ParseText(s1)
' Throw exception when add Nothing SyntaxTree
Assert.Throws(Of ArgumentNullException)(Sub() comp.AddSyntaxTrees(Nothing))
' Throw exception when Remove Nothing SyntaxTree
Assert.Throws(Of ArgumentNullException)(Sub() comp.RemoveSyntaxTrees(Nothing))
' Replace a tree with nothing (aka removing it)
comp = comp.AddSyntaxTrees(tree).ReplaceSyntaxTree(tree, Nothing)
Assert.Equal(0, comp.SyntaxTrees.Count)
' Throw exception when remove Nothing SyntaxTree
Assert.Throws(Of ArgumentNullException)(Sub() comp = comp.ReplaceSyntaxTree(Nothing, tree))
Dim t1 = CS.SyntaxFactory.ParseSyntaxTree(s1)
Dim t2 As SyntaxTree = t1
Dim t3 = t2
Dim csComp = CS.CSharpCompilation.Create("CompilationVB")
csComp = csComp.AddSyntaxTrees(t1, CS.SyntaxFactory.ParseSyntaxTree("Imports Goo"))
' Throw exception when cast SyntaxTree
For Each item In csComp.SyntaxTrees
t3 = item
Dim invalidCastSynTreeEx = Assert.Throws(Of InvalidCastException)(Sub() comp = comp.AddSyntaxTrees(CType(t3, VisualBasicSyntaxTree)))
invalidCastSynTreeEx = Assert.Throws(Of InvalidCastException)(Sub() comp = comp.RemoveSyntaxTrees(CType(t3, VisualBasicSyntaxTree)))
invalidCastSynTreeEx = Assert.Throws(Of InvalidCastException)(Sub() comp = comp.ReplaceSyntaxTree(CType(t3, VisualBasicSyntaxTree), CType(t3, VisualBasicSyntaxTree)))
Next
End Sub
<Fact>
Public Sub RootNSIllegalIdentifiers()
AssertTheseDiagnostics(TestOptions.ReleaseExe.WithRootNamespace("[[Global]]").Errors,
<expected>
BC2014: the value '[[Global]]' is invalid for option 'RootNamespace'
</expected>)
AssertTheseDiagnostics(TestOptions.ReleaseExe.WithRootNamespace("From()").Errors,
<expected>
BC2014: the value 'From()' is invalid for option 'RootNamespace'
</expected>)
AssertTheseDiagnostics(TestOptions.ReleaseExe.WithRootNamespace("x$").Errors,
<expected>
BC2014: the value 'x$' is invalid for option 'RootNamespace'
</expected>)
AssertTheseDiagnostics(TestOptions.ReleaseExe.WithRootNamespace("Goo.").Errors,
<expected>
BC2014: the value 'Goo.' is invalid for option 'RootNamespace'
</expected>)
AssertTheseDiagnostics(TestOptions.ReleaseExe.WithRootNamespace("_").Errors,
<expected>
BC2014: the value '_' is invalid for option 'RootNamespace'
</expected>)
End Sub
<Fact>
Public Sub AmbiguousNestedTypeSymbolFromMetadata()
Dim code = "Class A : Class B : End Class : End Class"
Dim c1 = VisualBasicCompilation.Create("Asm1", syntaxTrees:={VisualBasicSyntaxTree.ParseText(code)})
Dim c2 = VisualBasicCompilation.Create("Asm2", syntaxTrees:={VisualBasicSyntaxTree.ParseText(code)})
Dim c3 = VisualBasicCompilation.Create("Asm3", references:={c1.ToMetadataReference(), c2.ToMetadataReference()})
Assert.Null(c3.GetTypeByMetadataName("A+B"))
End Sub
<Fact>
Public Sub DuplicateNestedTypeSymbol()
Dim code = "Class A : Class B : End Class : Class B : End Class : End Class"
Dim c1 = VisualBasicCompilation.Create("Asm1",
syntaxTrees:={VisualBasicSyntaxTree.ParseText(code)})
Assert.Equal("A.B", c1.GetTypeByMetadataName("A+B").ToDisplayString())
End Sub
<Fact()>
<WorkItem(543211, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543211")>
Public Sub TreeDiagnosticsShouldNotIncludeEntryPointDiagnostics()
Dim code1 = "Module M : Sub Main : End Sub : End Module"
Dim code2 = " "
Dim tree1 = VisualBasicSyntaxTree.ParseText(code1)
Dim tree2 = VisualBasicSyntaxTree.ParseText(code2)
Dim comp = VisualBasicCompilation.Create(
"Test",
syntaxTrees:={tree1, tree2})
Dim semanticModel2 = comp.GetSemanticModel(tree2)
Dim diagnostics2 = semanticModel2.GetDiagnostics()
Assert.Equal(0, diagnostics2.Length())
End Sub
<Fact()>
<WorkItem(543292, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543292")>
Public Sub CompilationNotSupported()
Dim compilation = VisualBasicCompilation.Create("HelloWorld")
Assert.Throws(Of NotSupportedException)(Function() compilation.DynamicType)
Assert.Throws(Of NotSupportedException)(Function() compilation.CreatePointerTypeSymbol(Nothing))
Assert.Throws(Of NotSupportedException)(Function() compilation.CreateFunctionPointerTypeSymbol(Nothing, Nothing, Nothing, Nothing, Nothing, Nothing))
End Sub
<Fact>
Public Sub CreateTupleTypeSymbol_NoNames()
Dim comp = VisualBasicCompilation.Create("test", references:={MscorlibRef}) ' no ValueTuple
Dim intType As TypeSymbol = comp.GetSpecialType(SpecialType.System_Int32)
Dim stringType As TypeSymbol = comp.GetSpecialType(SpecialType.System_String)
Dim vt2 = comp.GetWellKnownType(WellKnownType.System_ValueTuple_T2).Construct(intType, stringType)
Dim tupleWithoutNames = comp.CreateTupleTypeSymbol(vt2, Nothing)
Assert.True(tupleWithoutNames.IsTupleType)
Assert.Equal("(System.Int32, System.String)", tupleWithoutNames.ToTestDisplayString())
Assert.True(tupleWithoutNames.TupleElements.All(Function(e) e.IsImplicitlyDeclared))
Assert.Equal({"System.Int32", "System.String"}, tupleWithoutNames.TupleElements.Select(Function(t) t.Type.ToTestDisplayString()))
Assert.Equal(CInt(SymbolKind.NamedType), CInt(tupleWithoutNames.Kind))
End Sub
<Fact>
Public Sub CreateTupleTypeSymbol_WithNames()
Dim comp = VisualBasicCompilation.Create("test", references:={MscorlibRef}) ' no ValueTuple
Dim intType As TypeSymbol = comp.GetSpecialType(SpecialType.System_Int32)
Dim stringType As TypeSymbol = comp.GetSpecialType(SpecialType.System_String)
Dim vt2 = comp.GetWellKnownType(WellKnownType.System_ValueTuple_T2).Construct(intType, stringType)
Dim tupleWithNames = comp.CreateTupleTypeSymbol(vt2, ImmutableArray.Create("Alice", "Bob"))
Assert.True(tupleWithNames.IsTupleType)
Assert.Equal("(Alice As System.Int32, Bob As System.String)", tupleWithNames.ToTestDisplayString())
Assert.Equal({"Alice", "Bob"}, tupleWithNames.TupleElements.SelectAsArray(Function(e) e.Name))
Assert.Equal({"System.Int32", "System.String"}, tupleWithNames.TupleElements.Select(Function(t) t.Type.ToTestDisplayString()))
Assert.Equal(SymbolKind.NamedType, tupleWithNames.Kind)
End Sub
<Fact()>
<WorkItem(36047, "https://github.com/dotnet/roslyn/issues/36047")>
Public Sub CreateArrayType_DefaultArgs()
Dim comp = DirectCast(VisualBasicCompilation.Create(""), Compilation)
Dim elementType = comp.GetSpecialType(SpecialType.System_Object)
Dim arrayType = comp.CreateArrayTypeSymbol(elementType)
Assert.Equal(1, arrayType.Rank)
Assert.Equal(CodeAnalysis.NullableAnnotation.None, arrayType.ElementNullableAnnotation)
Assert.Throws(Of ArgumentException)(Function() comp.CreateArrayTypeSymbol(elementType, Nothing))
Assert.Throws(Of ArgumentException)(Function() comp.CreateArrayTypeSymbol(elementType, 0))
arrayType = comp.CreateArrayTypeSymbol(elementType, 1, Nothing)
Assert.Equal(1, arrayType.Rank)
Assert.Equal(CodeAnalysis.NullableAnnotation.None, arrayType.ElementNullableAnnotation)
Assert.Throws(Of ArgumentException)(Function() comp.CreateArrayTypeSymbol(elementType, rank:=Nothing))
Assert.Throws(Of ArgumentException)(Function() comp.CreateArrayTypeSymbol(elementType, rank:=0))
arrayType = comp.CreateArrayTypeSymbol(elementType, elementNullableAnnotation:=Nothing)
Assert.Equal(1, arrayType.Rank)
Assert.Equal(CodeAnalysis.NullableAnnotation.None, arrayType.ElementNullableAnnotation)
End Sub
<Fact()>
<WorkItem(36047, "https://github.com/dotnet/roslyn/issues/36047")>
Public Sub CreateArrayType_ElementNullableAnnotation()
Dim comp = DirectCast(VisualBasicCompilation.Create(""), Compilation)
Dim elementType = comp.GetSpecialType(SpecialType.System_Object)
Assert.Equal(CodeAnalysis.NullableAnnotation.None, comp.CreateArrayTypeSymbol(elementType).ElementNullableAnnotation)
Assert.Equal(CodeAnalysis.NullableAnnotation.None, comp.CreateArrayTypeSymbol(elementType, elementNullableAnnotation:=Nothing).ElementNullableAnnotation)
Assert.Equal(CodeAnalysis.NullableAnnotation.None, comp.CreateArrayTypeSymbol(elementType, elementNullableAnnotation:=CodeAnalysis.NullableAnnotation.None).ElementNullableAnnotation)
Assert.Equal(CodeAnalysis.NullableAnnotation.None, comp.CreateArrayTypeSymbol(elementType, elementNullableAnnotation:=CodeAnalysis.NullableAnnotation.NotAnnotated).ElementNullableAnnotation)
Assert.Equal(CodeAnalysis.NullableAnnotation.None, comp.CreateArrayTypeSymbol(elementType, elementNullableAnnotation:=CodeAnalysis.NullableAnnotation.Annotated).ElementNullableAnnotation)
End Sub
<Fact()>
Public Sub CreateAnonymousType_IncorrectLengths()
Dim compilation = VisualBasicCompilation.Create("HelloWorld")
Assert.Throws(Of ArgumentException)(
Function()
Return compilation.CreateAnonymousTypeSymbol(
ImmutableArray.Create(DirectCast(Nothing, ITypeSymbol)),
ImmutableArray.Create("m1", "m2"))
End Function)
End Sub
<Fact>
Public Sub CreateAnonymousType_IncorrectLengths_IsReadOnly()
Dim compilation = VisualBasicCompilation.Create("HelloWorld")
Assert.Throws(Of ArgumentException)(
Sub()
compilation.CreateAnonymousTypeSymbol(
ImmutableArray.Create(DirectCast(compilation.GetSpecialType(SpecialType.System_Int32), ITypeSymbol),
DirectCast(compilation.GetSpecialType(SpecialType.System_Int32), ITypeSymbol)),
ImmutableArray.Create("m1", "m2"),
ImmutableArray.Create(True))
End Sub)
End Sub
<Fact>
Public Sub CreateAnonymousType_IncorrectLengths_Locations()
Dim Compilation = VisualBasicCompilation.Create("HelloWorld")
Assert.Throws(Of ArgumentException)(
Sub()
Compilation.CreateAnonymousTypeSymbol(
ImmutableArray.Create(DirectCast(Compilation.GetSpecialType(SpecialType.System_Int32), ITypeSymbol),
DirectCast(Compilation.GetSpecialType(SpecialType.System_Int32), ITypeSymbol)),
ImmutableArray.Create("m1", "m2"),
memberLocations:=ImmutableArray.Create(Location.None))
End Sub)
End Sub
<Fact>
Public Sub CreateAnonymousType_WritableProperty()
Dim compilation = VisualBasicCompilation.Create("HelloWorld")
Dim type = compilation.CreateAnonymousTypeSymbol(
ImmutableArray.Create(DirectCast(compilation.GetSpecialType(SpecialType.System_Int32), ITypeSymbol),
DirectCast(compilation.GetSpecialType(SpecialType.System_Int32), ITypeSymbol)),
ImmutableArray.Create("m1", "m2"),
ImmutableArray.Create(False, False))
Assert.True(type.IsAnonymousType)
Assert.Equal(2, type.GetMembers().OfType(Of IPropertySymbol).Count())
Assert.Equal("<anonymous type: m1 As Integer, m2 As Integer>", type.ToDisplayString())
Assert.All(type.GetMembers().OfType(Of IPropertySymbol)().Select(Function(p) p.Locations.FirstOrDefault()),
Sub(loc) Assert.Equal(loc, Location.None))
End Sub
<Fact>
Public Sub CreateAnonymousType_Locations()
Dim compilation = VisualBasicCompilation.Create("HelloWorld")
Dim tree = VisualBasicSyntaxTree.ParseText("Class X")
compilation = compilation.AddSyntaxTrees(tree)
Dim loc1 = Location.Create(tree, New TextSpan(0, 1))
Dim loc2 = Location.Create(tree, New TextSpan(1, 1))
Dim type = compilation.CreateAnonymousTypeSymbol(
ImmutableArray.Create(DirectCast(compilation.GetSpecialType(SpecialType.System_Int32), ITypeSymbol),
DirectCast(compilation.GetSpecialType(SpecialType.System_Int32), ITypeSymbol)),
ImmutableArray.Create("m1", "m2"),
ImmutableArray.Create(False, False),
ImmutableArray.Create(loc1, loc2))
Assert.True(type.IsAnonymousType)
Assert.Equal(2, type.GetMembers().OfType(Of IPropertySymbol).Count())
Assert.Equal(loc1, type.GetMembers("m1").Single().Locations.Single())
Assert.Equal(loc2, type.GetMembers("m2").Single().Locations.Single())
Assert.Equal("<anonymous type: m1 As Integer, m2 As Integer>", type.ToDisplayString())
End Sub
<Fact()>
Public Sub CreateAnonymousType_NothingArgument()
Dim compilation = VisualBasicCompilation.Create("HelloWorld")
Assert.Throws(Of ArgumentNullException)(
Function()
Return compilation.CreateAnonymousTypeSymbol(
ImmutableArray.Create(DirectCast(Nothing, ITypeSymbol)),
ImmutableArray.Create("m1"))
End Function)
End Sub
<Fact()>
Public Sub CreateAnonymousType1()
Dim compilation = VisualBasicCompilation.Create("HelloWorld")
Dim type = compilation.CreateAnonymousTypeSymbol(
ImmutableArray.Create(Of ITypeSymbol)(compilation.GetSpecialType(SpecialType.System_Int32)),
ImmutableArray.Create("m1"))
Assert.True(type.IsAnonymousType)
Assert.Equal(1, type.GetMembers().OfType(Of IPropertySymbol).Count())
Assert.Equal("<anonymous type: Key m1 As Integer>", type.ToDisplayString())
Assert.All(type.GetMembers().OfType(Of IPropertySymbol)().Select(Function(p) p.Locations.FirstOrDefault()),
Sub(loc) Assert.Equal(loc, Location.None))
End Sub
<Fact()>
Public Sub CreateMutableAnonymousType1()
Dim compilation = VisualBasicCompilation.Create("HelloWorld")
Dim type = compilation.CreateAnonymousTypeSymbol(
ImmutableArray.Create(Of ITypeSymbol)(compilation.GetSpecialType(SpecialType.System_Int32)),
ImmutableArray.Create("m1"),
ImmutableArray.Create(False))
Assert.True(type.IsAnonymousType)
Assert.Equal(1, type.GetMembers().OfType(Of IPropertySymbol).Count())
Assert.Equal("<anonymous type: m1 As Integer>", type.ToDisplayString())
Assert.All(type.GetMembers().OfType(Of IPropertySymbol)().Select(Function(p) p.Locations.FirstOrDefault()),
Sub(loc) Assert.Equal(loc, Location.None))
End Sub
<Fact()>
Public Sub CreateAnonymousType2()
Dim compilation = VisualBasicCompilation.Create("HelloWorld")
Dim type = compilation.CreateAnonymousTypeSymbol(
ImmutableArray.Create(Of ITypeSymbol)(compilation.GetSpecialType(SpecialType.System_Int32), compilation.GetSpecialType(SpecialType.System_Boolean)),
ImmutableArray.Create("m1", "m2"))
Assert.True(type.IsAnonymousType)
Assert.Equal(2, type.GetMembers().OfType(Of IPropertySymbol).Count())
Assert.Equal("<anonymous type: Key m1 As Integer, Key m2 As Boolean>", type.ToDisplayString())
Assert.All(type.GetMembers().OfType(Of IPropertySymbol)().Select(Function(p) p.Locations.FirstOrDefault()),
Sub(loc) Assert.Equal(loc, Location.None))
End Sub
<Fact()>
<WorkItem(36047, "https://github.com/dotnet/roslyn/issues/36047")>
Public Sub CreateAnonymousType_DefaultArgs()
Dim comp = DirectCast(CreateCompilation(""), Compilation)
Dim memberTypes = ImmutableArray.Create(Of ITypeSymbol)(comp.GetSpecialType(SpecialType.System_Object), comp.GetSpecialType(SpecialType.System_String))
Dim memberNames = ImmutableArray.Create("P", "Q")
Dim type = comp.CreateAnonymousTypeSymbol(memberTypes, memberNames)
Assert.Equal("<anonymous type: Key P As System.Object, Key Q As System.String>", type.ToTestDisplayString())
type = comp.CreateAnonymousTypeSymbol(memberTypes, memberNames, Nothing)
Assert.Equal("<anonymous type: Key P As System.Object, Key Q As System.String>", type.ToTestDisplayString())
type = comp.CreateAnonymousTypeSymbol(memberTypes, memberNames, Nothing, Nothing)
Assert.Equal("<anonymous type: Key P As System.Object, Key Q As System.String>", type.ToTestDisplayString())
type = comp.CreateAnonymousTypeSymbol(memberTypes, memberNames, Nothing, Nothing, Nothing)
Assert.Equal("<anonymous type: Key P As System.Object, Key Q As System.String>", type.ToTestDisplayString())
type = comp.CreateAnonymousTypeSymbol(memberTypes, memberNames, memberIsReadOnly:=Nothing)
Assert.Equal("<anonymous type: Key P As System.Object, Key Q As System.String>", type.ToTestDisplayString())
type = comp.CreateAnonymousTypeSymbol(memberTypes, memberNames, memberLocations:=Nothing)
Assert.Equal("<anonymous type: Key P As System.Object, Key Q As System.String>", type.ToTestDisplayString())
type = comp.CreateAnonymousTypeSymbol(memberTypes, memberNames, memberNullableAnnotations:=Nothing)
Assert.Equal("<anonymous type: Key P As System.Object, Key Q As System.String>", type.ToTestDisplayString())
End Sub
<Fact()>
<WorkItem(36047, "https://github.com/dotnet/roslyn/issues/36047")>
Public Sub CreateAnonymousType_MemberNullableAnnotations_Empty()
Dim comp = DirectCast(VisualBasicCompilation.Create(""), Compilation)
Dim type = comp.CreateAnonymousTypeSymbol(ImmutableArray(Of ITypeSymbol).Empty, ImmutableArray(Of String).Empty, memberNullableAnnotations:=ImmutableArray(Of CodeAnalysis.NullableAnnotation).Empty)
Assert.Equal("<empty anonymous type>", type.ToTestDisplayString())
AssertEx.Equal(Array.Empty(Of CodeAnalysis.NullableAnnotation)(), GetAnonymousTypeNullableAnnotations(type))
End Sub
<Fact()>
<WorkItem(36047, "https://github.com/dotnet/roslyn/issues/36047")>
Public Sub CreateAnonymousType_MemberNullableAnnotations()
Dim comp = DirectCast(CreateCompilation(""), Compilation)
Dim memberTypes = ImmutableArray.Create(Of ITypeSymbol)(comp.GetSpecialType(SpecialType.System_Object), comp.GetSpecialType(SpecialType.System_String))
Dim memberNames = ImmutableArray.Create("P", "Q")
Dim type = comp.CreateAnonymousTypeSymbol(memberTypes, memberNames)
Assert.Equal("<anonymous type: Key P As System.Object, Key Q As System.String>", type.ToTestDisplayString())
AssertEx.Equal({CodeAnalysis.NullableAnnotation.None, CodeAnalysis.NullableAnnotation.None}, GetAnonymousTypeNullableAnnotations(type))
Assert.Throws(Of ArgumentException)(Function() comp.CreateAnonymousTypeSymbol(memberTypes, memberNames, memberNullableAnnotations:=ImmutableArray.Create(CodeAnalysis.NullableAnnotation.NotAnnotated)))
type = comp.CreateAnonymousTypeSymbol(memberTypes, memberNames, memberNullableAnnotations:=ImmutableArray.Create(CodeAnalysis.NullableAnnotation.NotAnnotated, CodeAnalysis.NullableAnnotation.Annotated))
Assert.Equal("<anonymous type: Key P As System.Object, Key Q As System.String>", type.ToTestDisplayString())
AssertEx.Equal({CodeAnalysis.NullableAnnotation.None, CodeAnalysis.NullableAnnotation.None}, GetAnonymousTypeNullableAnnotations(type))
End Sub
Private Shared Function GetAnonymousTypeNullableAnnotations(type As ITypeSymbol) As ImmutableArray(Of CodeAnalysis.NullableAnnotation)
Return type.GetMembers().OfType(Of IPropertySymbol)().SelectAsArray(Function(p) p.NullableAnnotation)
End Function
<Fact()>
<WorkItem(36046, "https://github.com/dotnet/roslyn/issues/36046")>
Public Sub ConstructTypeWithNullability()
Dim source =
"Class Pair(Of T, U)
End Class"
Dim comp = DirectCast(CreateCompilation(source), Compilation)
Dim genericType = DirectCast(comp.GetMember("Pair"), INamedTypeSymbol)
Dim typeArguments = ImmutableArray.Create(Of ITypeSymbol)(comp.GetSpecialType(SpecialType.System_Object), comp.GetSpecialType(SpecialType.System_String))
Assert.Throws(Of ArgumentException)(Function() genericType.Construct(New ImmutableArray(Of ITypeSymbol), New ImmutableArray(Of CodeAnalysis.NullableAnnotation)))
Assert.Throws(Of ArgumentException)(Function() genericType.Construct(typeArguments:=Nothing, typeArgumentNullableAnnotations:=Nothing))
Dim type = genericType.Construct(typeArguments, Nothing)
Assert.Equal("Pair(Of System.Object, System.String)", type.ToTestDisplayString())
AssertEx.Equal({CodeAnalysis.NullableAnnotation.None, CodeAnalysis.NullableAnnotation.None}, type.TypeArgumentNullableAnnotations)
Assert.Throws(Of ArgumentException)(Function() genericType.Construct(typeArguments, ImmutableArray(Of CodeAnalysis.NullableAnnotation).Empty))
Assert.Throws(Of ArgumentException)(Function() genericType.Construct(ImmutableArray.Create(Of ITypeSymbol)(Nothing, Nothing), Nothing))
type = genericType.Construct(typeArguments, ImmutableArray.Create(CodeAnalysis.NullableAnnotation.Annotated, CodeAnalysis.NullableAnnotation.NotAnnotated))
Assert.Equal("Pair(Of System.Object, System.String)", type.ToTestDisplayString())
AssertEx.Equal({CodeAnalysis.NullableAnnotation.None, CodeAnalysis.NullableAnnotation.None}, type.TypeArgumentNullableAnnotations)
' Type arguments from C#.
comp = CreateCSharpCompilation("")
typeArguments = ImmutableArray.Create(Of ITypeSymbol)(comp.GetSpecialType(SpecialType.System_Object), comp.GetSpecialType(SpecialType.System_String))
Assert.Throws(Of ArgumentException)(Function() genericType.Construct(typeArguments, Nothing))
End Sub
<Fact()>
<WorkItem(37310, "https://github.com/dotnet/roslyn/issues/37310")>
Public Sub ConstructMethodWithNullability()
Dim source =
"Class Program
Shared Sub M(Of T, U)
End Sub
End Class"
Dim comp = DirectCast(CreateCompilation(source), Compilation)
Dim genericMethod = DirectCast(comp.GetMember("Program.M"), IMethodSymbol)
Dim typeArguments = ImmutableArray.Create(Of ITypeSymbol)(comp.GetSpecialType(SpecialType.System_Object), comp.GetSpecialType(SpecialType.System_String))
Assert.Throws(Of ArgumentException)(Function() genericMethod.Construct(New ImmutableArray(Of ITypeSymbol), New ImmutableArray(Of CodeAnalysis.NullableAnnotation)))
Assert.Throws(Of ArgumentException)(Function() genericMethod.Construct(typeArguments:=Nothing, typeArgumentNullableAnnotations:=Nothing))
Dim type = genericMethod.Construct(typeArguments, Nothing)
Assert.Equal("Sub Program.M(Of System.Object, System.String)()", type.ToTestDisplayString())
AssertEx.Equal({CodeAnalysis.NullableAnnotation.None, CodeAnalysis.NullableAnnotation.None}, type.TypeArgumentNullableAnnotations)
Assert.Throws(Of ArgumentException)(Function() genericMethod.Construct(typeArguments, ImmutableArray(Of CodeAnalysis.NullableAnnotation).Empty))
Assert.Throws(Of ArgumentException)(Function() genericMethod.Construct(ImmutableArray.Create(Of ITypeSymbol)(Nothing, Nothing), Nothing))
type = genericMethod.Construct(typeArguments, ImmutableArray.Create(CodeAnalysis.NullableAnnotation.Annotated, CodeAnalysis.NullableAnnotation.NotAnnotated))
Assert.Equal("Sub Program.M(Of System.Object, System.String)()", type.ToTestDisplayString())
AssertEx.Equal({CodeAnalysis.NullableAnnotation.None, CodeAnalysis.NullableAnnotation.None}, type.TypeArgumentNullableAnnotations)
' Type arguments from C#.
comp = CreateCSharpCompilation("")
typeArguments = ImmutableArray.Create(Of ITypeSymbol)(comp.GetSpecialType(SpecialType.System_Object), comp.GetSpecialType(SpecialType.System_String))
Assert.Throws(Of ArgumentException)(Function() genericMethod.Construct(typeArguments, Nothing))
End Sub
<Fact()>
Public Sub GetEntryPoint_Exe()
Dim source = <compilation name="Name1">
<file name="a.vb"><![CDATA[
Class A
Shared Sub Main()
End Sub
End Class
]]>
</file>
</compilation>
Dim compilation = CreateCompilationWithMscorlib40(source, OutputKind.ConsoleApplication)
compilation.VerifyDiagnostics()
Dim mainMethod = compilation.GlobalNamespace.GetMember(Of NamedTypeSymbol)("A").GetMember(Of MethodSymbol)("Main")
Assert.Equal(mainMethod, compilation.GetEntryPoint(Nothing))
Dim entryPointAndDiagnostics = compilation.GetEntryPointAndDiagnostics(Nothing)
Assert.Equal(mainMethod, entryPointAndDiagnostics.MethodSymbol)
entryPointAndDiagnostics.Diagnostics.Verify()
End Sub
<Fact()>
Public Sub GetEntryPoint_Dll()
Dim source = <compilation name="Name1">
<file name="a.vb"><![CDATA[
Class A
Shared Sub Main()
End Sub
End Class
]]>
</file>
</compilation>
Dim compilation = CreateCompilationWithMscorlib40(source, OutputKind.DynamicallyLinkedLibrary)
compilation.VerifyDiagnostics()
Assert.Null(compilation.GetEntryPoint(Nothing))
Assert.Null(compilation.GetEntryPointAndDiagnostics(Nothing))
End Sub
<Fact()>
Public Sub GetEntryPoint_Module()
Dim source = <compilation name="Name1">
<file name="a.vb"><![CDATA[
Class A
Shared Sub Main()
End Sub
End Class
]]>
</file>
</compilation>
Dim compilation = CreateCompilationWithMscorlib40(source, OutputKind.NetModule)
compilation.VerifyDiagnostics()
Assert.Null(compilation.GetEntryPoint(Nothing))
Assert.Null(compilation.GetEntryPointAndDiagnostics(Nothing))
End Sub
<Fact>
Public Sub CreateCompilationForModule()
Dim source =
<text>
Class A
Shared Sub Main()
End Sub
End Class
</text>.Value
' equivalent of vbc with no /moduleassemblyname specified:
Dim c = VisualBasicCompilation.Create(assemblyName:=Nothing, options:=TestOptions.ReleaseModule, syntaxTrees:={Parse(source)}, references:={MscorlibRef})
c.VerifyEmitDiagnostics()
Assert.Null(c.AssemblyName)
Assert.Equal("?", c.Assembly.Name)
Assert.Equal("?", c.Assembly.Identity.Name)
' no name is allowed for assembly as well, although it isn't useful:
c = VisualBasicCompilation.Create(assemblyName:=Nothing, options:=TestOptions.ReleaseModule, syntaxTrees:={Parse(source)}, references:={MscorlibRef})
c.VerifyEmitDiagnostics()
Assert.Null(c.AssemblyName)
Assert.Equal("?", c.Assembly.Name)
Assert.Equal("?", c.Assembly.Identity.Name)
' equivalent of vbc with /moduleassemblyname specified:
c = VisualBasicCompilation.Create(assemblyName:="ModuleAssemblyName", options:=TestOptions.ReleaseModule, syntaxTrees:={Parse(source)}, references:={MscorlibRef})
c.VerifyDiagnostics()
Assert.Equal("ModuleAssemblyName", c.AssemblyName)
Assert.Equal("ModuleAssemblyName", c.Assembly.Name)
Assert.Equal("ModuleAssemblyName", c.Assembly.Identity.Name)
End Sub
<WorkItem(8506, "https://github.com/dotnet/roslyn/issues/8506")>
<WorkItem(17403, "https://github.com/dotnet/roslyn/issues/17403")>
<Fact()>
Public Sub CrossCorlibSystemObjectReturnType_Script()
' MinAsyncCorlibRef corlib Is used since it provides just enough corlib type definitions
' And Task APIs necessary for script hosting are provided by MinAsyncRef. This ensures that
' `System.Object, mscorlib, Version=4.0.0.0` will Not be provided (since it's unversioned).
'
' In the original bug, Xamarin iOS, Android, And Mac Mobile profile corlibs were
' realistic cross-compilation targets.
Dim AssertCompilationCorlib As Action(Of VisualBasicCompilation) =
Sub(compilation As VisualBasicCompilation)
Assert.True(compilation.IsSubmission)
Dim taskOfT = compilation.GetWellKnownType(WellKnownType.System_Threading_Tasks_Task_T)
Dim taskOfObject = taskOfT.Construct(compilation.ObjectType)
Dim entryPoint = compilation.GetEntryPoint(Nothing)
Assert.Same(compilation.ObjectType.ContainingAssembly, taskOfT.ContainingAssembly)
Assert.Same(compilation.ObjectType.ContainingAssembly, taskOfObject.ContainingAssembly)
Assert.Equal(taskOfObject, entryPoint.ReturnType)
End Sub
Dim firstCompilation = VisualBasicCompilation.CreateScriptCompilation(
"submission-assembly-1",
references:={MinAsyncCorlibRef},
syntaxTree:=Parse("? True", options:=TestOptions.Script)
).VerifyDiagnostics()
AssertCompilationCorlib(firstCompilation)
Dim secondCompilation = VisualBasicCompilation.CreateScriptCompilation(
"submission-assembly-2",
previousScriptCompilation:=firstCompilation,
syntaxTree:=Parse("? False", options:=TestOptions.Script)
).WithScriptCompilationInfo(New VisualBasicScriptCompilationInfo(firstCompilation, Nothing, Nothing)
).VerifyDiagnostics()
AssertCompilationCorlib(secondCompilation)
Assert.Same(firstCompilation.ObjectType, secondCompilation.ObjectType)
Assert.Null(New VisualBasicScriptCompilationInfo(Nothing, Nothing, Nothing).WithPreviousScriptCompilation(firstCompilation).ReturnTypeOpt)
End Sub
<WorkItem(3719, "https://github.com/dotnet/roslyn/issues/3719")>
<Fact()>
Public Sub GetEntryPoint_Script()
Dim source = <![CDATA[System.Console.WriteLine(1)]]>
Dim compilation = CreateCompilationWithMscorlib45({VisualBasicSyntaxTree.ParseText(source.Value, options:=TestOptions.Script)}, options:=TestOptions.ReleaseDll)
compilation.VerifyDiagnostics()
Dim scriptMethod = compilation.GetMember("Script.<Main>")
Assert.NotNull(scriptMethod)
Dim method = compilation.GetEntryPoint(Nothing)
Assert.Equal(method, scriptMethod)
Dim entryPoint = compilation.GetEntryPointAndDiagnostics(Nothing)
Assert.Equal(entryPoint.MethodSymbol, scriptMethod)
End Sub
<Fact()>
Public Sub GetEntryPoint_Script_MainIgnored()
Dim source = <![CDATA[
Class A
Shared Sub Main()
End Sub
End Class
]]>
Dim compilation = CreateCompilationWithMscorlib45({VisualBasicSyntaxTree.ParseText(source.Value, options:=TestOptions.Script)}, options:=TestOptions.ReleaseDll)
compilation.VerifyDiagnostics(Diagnostic(ERRID.WRN_MainIgnored, "Main").WithArguments("Public Shared Sub Main()").WithLocation(3, 20))
Dim scriptMethod = compilation.GetMember("Script.<Main>")
Assert.NotNull(scriptMethod)
Dim entryPoint = compilation.GetEntryPointAndDiagnostics(Nothing)
Assert.Equal(entryPoint.MethodSymbol, scriptMethod)
entryPoint.Diagnostics.Verify(Diagnostic(ERRID.WRN_MainIgnored, "Main").WithArguments("Public Shared Sub Main()").WithLocation(3, 20))
End Sub
<Fact()>
Public Sub GetEntryPoint_Submission()
Dim source = "? 1 + 1"
Dim compilation = VisualBasicCompilation.CreateScriptCompilation(
"sub",
references:={MscorlibRef},
syntaxTree:=Parse(source, options:=TestOptions.Script))
compilation.VerifyDiagnostics()
Dim scriptMethod = compilation.GetMember("Script.<Factory>")
Assert.NotNull(scriptMethod)
Dim method = compilation.GetEntryPoint(Nothing)
Assert.Equal(method, scriptMethod)
Dim entryPoint = compilation.GetEntryPointAndDiagnostics(Nothing)
Assert.Equal(entryPoint.MethodSymbol, scriptMethod)
entryPoint.Diagnostics.Verify()
End Sub
<Fact()>
Public Sub GetEntryPoint_Submission_MainIgnored()
Dim source = "
Class A
Shared Sub Main()
End Sub
End Class
"
Dim compilation = VisualBasicCompilation.CreateScriptCompilation(
"Sub",
references:={MscorlibRef},
syntaxTree:=Parse(source, options:=TestOptions.Script))
compilation.VerifyDiagnostics(Diagnostic(ERRID.WRN_MainIgnored, "Main").WithArguments("Public Shared Sub Main()").WithLocation(3, 20))
Dim scriptMethod = compilation.GetMember("Script.<Factory>")
Assert.NotNull(scriptMethod)
Dim entryPoint = compilation.GetEntryPointAndDiagnostics(Nothing)
Assert.Equal(entryPoint.MethodSymbol, scriptMethod)
entryPoint.Diagnostics.Verify(Diagnostic(ERRID.WRN_MainIgnored, "Main").WithArguments("Public Shared Sub Main()").WithLocation(3, 20))
End Sub
<Fact()>
Public Sub GetEntryPoint_MainType()
Dim source = <compilation name="Name1">
<file name="a.vb"><![CDATA[
Class A
Shared Sub Main()
End Sub
End Class
Class B
Shared Sub Main()
End Sub
End Class
]]>
</file>
</compilation>
Dim compilation = CreateCompilationWithMscorlib40(source, options:=TestOptions.ReleaseExe.WithMainTypeName("B"))
compilation.VerifyDiagnostics()
Dim mainMethod = compilation.GlobalNamespace.GetMember(Of NamedTypeSymbol)("B").GetMember(Of MethodSymbol)("Main")
Assert.Equal(mainMethod, compilation.GetEntryPoint(Nothing))
Dim entryPointAndDiagnostics = compilation.GetEntryPointAndDiagnostics(Nothing)
Assert.Equal(mainMethod, entryPointAndDiagnostics.MethodSymbol)
entryPointAndDiagnostics.Diagnostics.Verify()
End Sub
<Fact>
Public Sub ReferenceManagerReuse_WithOptions()
Dim c1 = VisualBasicCompilation.Create("c", options:=TestOptions.ReleaseDll)
Dim c2 = c1.WithOptions(TestOptions.ReleaseExe)
Assert.True(c1.ReferenceManagerEquals(c2))
c2 = c1.WithOptions(New VisualBasicCompilationOptions(OutputKind.WindowsApplication))
Assert.True(c1.ReferenceManagerEquals(c2))
c2 = c1.WithOptions(TestOptions.ReleaseModule)
Assert.False(c1.ReferenceManagerEquals(c2))
c1 = VisualBasicCompilation.Create("c", options:=TestOptions.ReleaseModule)
c2 = c1.WithOptions(TestOptions.ReleaseExe)
Assert.False(c1.ReferenceManagerEquals(c2))
c2 = c1.WithOptions(TestOptions.ReleaseDll)
Assert.False(c1.ReferenceManagerEquals(c2))
c2 = c1.WithOptions(New VisualBasicCompilationOptions(OutputKind.WindowsApplication))
Assert.False(c1.ReferenceManagerEquals(c2))
End Sub
<Fact>
Public Sub ReferenceManagerReuse_WithXmlFileResolver()
Dim c1 = VisualBasicCompilation.Create("c", options:=TestOptions.ReleaseDll)
Dim c2 = c1.WithOptions(TestOptions.ReleaseDll.WithXmlReferenceResolver(New XmlFileResolver(Nothing)))
Assert.False(c1.ReferenceManagerEquals(c2))
Dim c3 = c1.WithOptions(TestOptions.ReleaseDll.WithXmlReferenceResolver(c1.Options.XmlReferenceResolver))
Assert.True(c1.ReferenceManagerEquals(c3))
End Sub
<Fact>
Public Sub ReferenceManagerReuse_WithMetadataReferenceResolver()
Dim c1 = VisualBasicCompilation.Create("c", options:=TestOptions.ReleaseDll)
Dim c2 = c1.WithOptions(TestOptions.ReleaseDll.WithMetadataReferenceResolver(New TestMetadataReferenceResolver()))
Assert.False(c1.ReferenceManagerEquals(c2))
Dim c3 = c1.WithOptions(TestOptions.ReleaseDll.WithMetadataReferenceResolver(c1.Options.MetadataReferenceResolver))
Assert.True(c1.ReferenceManagerEquals(c3))
End Sub
<Fact>
Public Sub ReferenceManagerReuse_WithName()
Dim c1 = VisualBasicCompilation.Create("c1")
Dim c2 = c1.WithAssemblyName("c2")
Assert.False(c1.ReferenceManagerEquals(c2))
Dim c3 = c1.WithAssemblyName("c1")
Assert.True(c1.ReferenceManagerEquals(c3))
Dim c4 = c1.WithAssemblyName(Nothing)
Assert.False(c1.ReferenceManagerEquals(c4))
Dim c5 = c4.WithAssemblyName(Nothing)
Assert.True(c4.ReferenceManagerEquals(c5))
End Sub
<Fact>
Public Sub ReferenceManagerReuse_WithReferences()
Dim c1 = VisualBasicCompilation.Create("c1")
Dim c2 = c1.WithReferences({MscorlibRef})
Assert.False(c1.ReferenceManagerEquals(c2))
Dim c3 = c2.WithReferences({MscorlibRef, SystemCoreRef})
Assert.False(c3.ReferenceManagerEquals(c2))
c3 = c2.AddReferences(SystemCoreRef)
Assert.False(c3.ReferenceManagerEquals(c2))
c3 = c2.RemoveAllReferences()
Assert.False(c3.ReferenceManagerEquals(c2))
c3 = c2.ReplaceReference(MscorlibRef, SystemCoreRef)
Assert.False(c3.ReferenceManagerEquals(c2))
c3 = c2.RemoveReferences(MscorlibRef)
Assert.False(c3.ReferenceManagerEquals(c2))
End Sub
<Fact>
Public Sub ReferenceManagerReuse_WithSyntaxTrees()
Dim ta = Parse("Imports System")
Dim tb = Parse("Imports System", options:=TestOptions.Script)
Dim tc = Parse("#r ""bar"" ' error: #r in regular code")
Dim tr = Parse("#r ""goo""", options:=TestOptions.Script)
Dim ts = Parse("#r ""bar""", options:=TestOptions.Script)
Dim a = VisualBasicCompilation.Create("c", syntaxTrees:={ta})
' add:
Dim ab = a.AddSyntaxTrees(tb)
Assert.True(a.ReferenceManagerEquals(ab))
Dim ac = a.AddSyntaxTrees(tc)
Assert.True(a.ReferenceManagerEquals(ac))
Dim ar = a.AddSyntaxTrees(tr)
Assert.False(a.ReferenceManagerEquals(ar))
Dim arc = ar.AddSyntaxTrees(tc)
Assert.True(ar.ReferenceManagerEquals(arc))
' remove:
Dim ar2 = arc.RemoveSyntaxTrees(tc)
Assert.True(arc.ReferenceManagerEquals(ar2))
Dim c = arc.RemoveSyntaxTrees(ta, tr)
Assert.False(arc.ReferenceManagerEquals(c))
Dim none1 = c.RemoveSyntaxTrees(tc)
Assert.True(c.ReferenceManagerEquals(none1))
Dim none2 = arc.RemoveAllSyntaxTrees()
Assert.False(arc.ReferenceManagerEquals(none2))
Dim none3 = ac.RemoveAllSyntaxTrees()
Assert.True(ac.ReferenceManagerEquals(none3))
' replace:
Dim asc = arc.ReplaceSyntaxTree(tr, ts)
Assert.False(arc.ReferenceManagerEquals(asc))
Dim brc = arc.ReplaceSyntaxTree(ta, tb)
Assert.True(arc.ReferenceManagerEquals(brc))
Dim abc = arc.ReplaceSyntaxTree(tr, tb)
Assert.False(arc.ReferenceManagerEquals(abc))
Dim ars = arc.ReplaceSyntaxTree(tc, ts)
Assert.False(arc.ReferenceManagerEquals(ars))
End Sub
<Fact>
Public Sub ReferenceManagerReuse_WithScriptCompilationInfo()
' Note The following results would change if we optimized sharing more: https://github.com/dotnet/roslyn/issues/43397
Dim c1 = VisualBasicCompilation.CreateScriptCompilation("c1")
Assert.NotNull(c1.ScriptCompilationInfo)
Assert.Null(c1.ScriptCompilationInfo.PreviousScriptCompilation)
Dim c2 = c1.WithScriptCompilationInfo(Nothing)
Assert.Null(c2.ScriptCompilationInfo)
Assert.True(c2.ReferenceManagerEquals(c1))
Dim c3 = c2.WithScriptCompilationInfo(New VisualBasicScriptCompilationInfo(previousCompilationOpt:=Nothing, returnType:=GetType(Integer), globalsType:=Nothing))
Assert.NotNull(c3.ScriptCompilationInfo)
Assert.Null(c3.ScriptCompilationInfo.PreviousScriptCompilation)
Assert.True(c3.ReferenceManagerEquals(c2))
Dim c4 = c3.WithScriptCompilationInfo(Nothing)
Assert.Null(c4.ScriptCompilationInfo)
Assert.True(c4.ReferenceManagerEquals(c3))
Dim c5 = c4.WithScriptCompilationInfo(New VisualBasicScriptCompilationInfo(previousCompilationOpt:=c1, returnType:=GetType(Integer), globalsType:=Nothing))
Assert.False(c5.ReferenceManagerEquals(c4))
Dim c6 = c5.WithScriptCompilationInfo(New VisualBasicScriptCompilationInfo(previousCompilationOpt:=c1, returnType:=GetType(Boolean), globalsType:=Nothing))
Assert.True(c6.ReferenceManagerEquals(c5))
Dim c7 = c6.WithScriptCompilationInfo(New VisualBasicScriptCompilationInfo(previousCompilationOpt:=c2, returnType:=GetType(Boolean), globalsType:=Nothing))
Assert.False(c7.ReferenceManagerEquals(c6))
Dim c8 = c7.WithScriptCompilationInfo(New VisualBasicScriptCompilationInfo(previousCompilationOpt:=Nothing, returnType:=GetType(Boolean), globalsType:=Nothing))
Assert.False(c8.ReferenceManagerEquals(c7))
Dim c9 = c8.WithScriptCompilationInfo(Nothing)
Assert.True(c9.ReferenceManagerEquals(c8))
End Sub
Private Class EvolvingTestReference
Inherits PortableExecutableReference
Private ReadOnly _metadataSequence As IEnumerator(Of Metadata)
Public QueryCount As Integer
Public Sub New(metadataSequence As IEnumerable(Of Metadata))
MyBase.New(MetadataReferenceProperties.Assembly)
Me._metadataSequence = metadataSequence.GetEnumerator()
End Sub
Protected Overrides Function CreateDocumentationProvider() As DocumentationProvider
Return DocumentationProvider.Default
End Function
Protected Overrides Function GetMetadataImpl() As Metadata
QueryCount = QueryCount + 1
_metadataSequence.MoveNext()
Return _metadataSequence.Current
End Function
Protected Overrides Function WithPropertiesImpl(properties As MetadataReferenceProperties) As PortableExecutableReference
Throw New NotImplementedException()
End Function
End Class
<ConditionalFact(GetType(NoIOperationValidation))>
Public Sub MetadataConsistencyWhileEvolvingCompilation()
Dim md1 = AssemblyMetadata.CreateFromImage(CreateCompilationWithMscorlib40({"Public Class C : End Class"}, options:=TestOptions.ReleaseDll).EmitToArray())
Dim md2 = AssemblyMetadata.CreateFromImage(CreateCompilationWithMscorlib40({"Public Class D : End Class"}, options:=TestOptions.ReleaseDll).EmitToArray())
Dim reference = New EvolvingTestReference({md1, md2})
Dim references = TargetFrameworkUtil.Mscorlib40References.AddRange({reference, reference})
Dim c1 = CreateEmptyCompilation({"Public Class Main : Public Shared C As C : End Class"}, references:=references, options:=TestOptions.ReleaseDll)
Dim c2 = c1.WithAssemblyName("c2")
Dim c3 = c2.AddSyntaxTrees(Parse("Public Class Main2 : Public Shared A As Integer : End Class"))
Dim c4 = c3.WithOptions(New VisualBasicCompilationOptions(OutputKind.NetModule))
Dim c5 = c4.WithReferences({MscorlibRef, reference})
c3.VerifyDiagnostics()
c1.VerifyDiagnostics()
c4.VerifyDiagnostics()
c2.VerifyDiagnostics()
Assert.Equal(1, reference.QueryCount)
c5.VerifyDiagnostics(Diagnostic(ERRID.ERR_UndefinedType1, "C").WithArguments("C").WithLocation(1, 40))
Assert.Equal(2, reference.QueryCount)
End Sub
<Fact>
Public Sub LinkedNetmoduleMetadataMustProvideFullPEImage()
Dim moduleBytes = TestResources.MetadataTests.NetModule01.ModuleCS00
Dim headers = New PEHeaders(New MemoryStream(moduleBytes))
Dim pinnedPEImage = GCHandle.Alloc(moduleBytes.ToArray(), GCHandleType.Pinned)
Try
Using mdModule = ModuleMetadata.CreateFromMetadata(pinnedPEImage.AddrOfPinnedObject() + headers.MetadataStartOffset, headers.MetadataSize)
Dim c = VisualBasicCompilation.Create("Goo", references:={MscorlibRef, mdModule.GetReference(display:="ModuleCS00")}, options:=TestOptions.ReleaseDll)
c.VerifyDiagnostics(Diagnostic(ERRID.ERR_LinkedNetmoduleMetadataMustProvideFullPEImage).WithArguments("ModuleCS00").WithLocation(1, 1))
End Using
Finally
pinnedPEImage.Free()
End Try
End Sub
<Fact>
<WorkItem(797640, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/797640")>
Public Sub GetMetadataReferenceAPITest()
Dim comp = VisualBasicCompilation.Create("Compilation")
Dim metadata = Net451.mscorlib
comp = comp.AddReferences(metadata)
Dim assemblySmb = comp.GetReferencedAssemblySymbol(metadata)
Dim reference = comp.GetMetadataReference(assemblySmb)
Assert.NotNull(reference)
Dim comp2 = VisualBasicCompilation.Create("Compilation")
comp2 = comp.AddReferences(metadata)
Dim reference2 = comp2.GetMetadataReference(assemblySmb)
Assert.NotNull(reference2)
End Sub
<WorkItem(40466, "https://github.com/dotnet/roslyn/issues/40466")>
<Fact>
Public Sub GetMetadataReference_CSharpSymbols()
Dim comp As Compilation = CreateCompilation("")
Dim csComp = CreateCSharpCompilation("", referencedAssemblies:=TargetFrameworkUtil.GetReferences(TargetFramework.Standard))
Dim assembly = csComp.GetBoundReferenceManager().GetReferencedAssemblies().First().Value
Assert.Null(comp.GetMetadataReference(DirectCast(assembly.GetISymbol(), IAssemblySymbol)))
Assert.Null(comp.GetMetadataReference(csComp.Assembly))
Assert.Null(comp.GetMetadataReference(Nothing))
End Sub
<Fact()>
Public Sub EqualityOfMergedNamespaces()
Dim moduleComp = CompilationUtils.CreateEmptyCompilation(
<compilation>
<file name="a.vb">
Namespace NS1
Namespace NS3
Interface T1
End Interface
End Namespace
End Namespace
Namespace NS2
Namespace NS3
Interface T2
End Interface
End Namespace
End Namespace
</file>
</compilation>, options:=TestOptions.ReleaseModule)
Dim compilation = CompilationUtils.CreateEmptyCompilationWithReferences(
<compilation>
<file name="a.vb">
Namespace NS1
Namespace NS3
Interface T3
End Interface
End Namespace
End Namespace
Namespace NS2
Namespace NS3
Interface T4
End Interface
End Namespace
End Namespace
</file>
</compilation>, {moduleComp.EmitToImageReference()})
TestEqualityRecursive(compilation.GlobalNamespace,
compilation.GlobalNamespace,
NamespaceKind.Compilation,
Function(ns) compilation.GetCompilationNamespace(ns))
TestEqualityRecursive(compilation.Assembly.GlobalNamespace,
compilation.Assembly.GlobalNamespace,
NamespaceKind.Assembly,
Function(ns) compilation.Assembly.GetAssemblyNamespace(ns))
End Sub
Private Shared Sub TestEqualityRecursive(testNs1 As NamespaceSymbol,
testNs2 As NamespaceSymbol,
kind As NamespaceKind,
factory As Func(Of NamespaceSymbol, NamespaceSymbol))
Assert.Equal(kind, testNs1.NamespaceKind)
Assert.Same(testNs1, testNs2)
Dim children1 = testNs1.GetMembers().OrderBy(Function(m) m.Name).ToArray()
Dim children2 = testNs2.GetMembers().OrderBy(Function(m) m.Name).ToArray()
For i = 0 To children1.Count - 1
Assert.Same(children1(i), children2(i))
If children1(i).Kind = SymbolKind.Namespace Then
TestEqualityRecursive(DirectCast(testNs1.GetMembers(children1(i).Name).Single(), NamespaceSymbol),
DirectCast(testNs1.GetMembers(children1(i).Name).Single(), NamespaceSymbol),
kind,
factory)
End If
Next
Assert.Same(testNs1, factory(testNs1))
For Each constituent In testNs1.ConstituentNamespaces
Assert.Same(testNs1, factory(constituent))
Next
End Sub
<Fact>
Public Sub ConsistentParseOptions()
Dim tree1 = SyntaxFactory.ParseSyntaxTree("", VisualBasicParseOptions.Default.WithLanguageVersion(LanguageVersion.VisualBasic12))
Dim tree2 = SyntaxFactory.ParseSyntaxTree("", VisualBasicParseOptions.Default.WithLanguageVersion(LanguageVersion.VisualBasic12))
Dim tree3 = SyntaxFactory.ParseSyntaxTree("", VisualBasicParseOptions.Default.WithLanguageVersion(LanguageVersion.VisualBasic11))
Dim assemblyName = GetUniqueName()
Dim CompilationOptions = New VisualBasicCompilationOptions(OutputKind.DynamicallyLinkedLibrary)
VisualBasicCompilation.Create(assemblyName, {tree1, tree2}, {MscorlibRef}, CompilationOptions)
Assert.Throws(Of ArgumentException)(Function() VisualBasicCompilation.Create(assemblyName, {tree1, tree3}, {MscorlibRef}, CompilationOptions))
End Sub
<Fact>
Public Sub SubmissionCompilation_Errors()
Dim genericParameter = GetType(List(Of)).GetGenericArguments()(0)
Dim open = GetType(Dictionary(Of,)).MakeGenericType(GetType(Integer), genericParameter)
Dim ptr = GetType(Integer).MakePointerType()
Dim byRefType = GetType(Integer).MakeByRefType()
Assert.Throws(Of ArgumentException)(Function() VisualBasicCompilation.CreateScriptCompilation("a", returnType:=genericParameter))
Assert.Throws(Of ArgumentException)(Function() VisualBasicCompilation.CreateScriptCompilation("a", returnType:=open))
Assert.Throws(Of ArgumentException)(Function() VisualBasicCompilation.CreateScriptCompilation("a", returnType:=GetType(Void)))
Assert.Throws(Of ArgumentException)(Function() VisualBasicCompilation.CreateScriptCompilation("a", returnType:=byRefType))
Assert.Throws(Of ArgumentException)(Function() VisualBasicCompilation.CreateScriptCompilation("a", globalsType:=genericParameter))
Assert.Throws(Of ArgumentException)(Function() VisualBasicCompilation.CreateScriptCompilation("a", globalsType:=open))
Assert.Throws(Of ArgumentException)(Function() VisualBasicCompilation.CreateScriptCompilation("a", globalsType:=GetType(Void)))
Assert.Throws(Of ArgumentException)(Function() VisualBasicCompilation.CreateScriptCompilation("a", globalsType:=GetType(Integer)))
Assert.Throws(Of ArgumentException)(Function() VisualBasicCompilation.CreateScriptCompilation("a", globalsType:=ptr))
Assert.Throws(Of ArgumentException)(Function() VisualBasicCompilation.CreateScriptCompilation("a", globalsType:=byRefType))
Dim s0 = VisualBasicCompilation.CreateScriptCompilation("a0", globalsType:=GetType(List(Of Integer)))
Assert.Throws(Of ArgumentException)(Function() VisualBasicCompilation.CreateScriptCompilation("a1", previousScriptCompilation:=s0, globalsType:=GetType(List(Of Boolean))))
' invalid options
Assert.Throws(Of ArgumentException)(Function() VisualBasicCompilation.CreateScriptCompilation("a", options:=TestOptions.ReleaseExe))
Assert.Throws(Of ArgumentException)(Function() VisualBasicCompilation.CreateScriptCompilation("a", options:=TestOptions.ReleaseDll.WithOutputKind(OutputKind.NetModule)))
Assert.Throws(Of ArgumentException)(Function() VisualBasicCompilation.CreateScriptCompilation("a", options:=TestOptions.ReleaseDll.WithOutputKind(OutputKind.WindowsRuntimeMetadata)))
Assert.Throws(Of ArgumentException)(Function() VisualBasicCompilation.CreateScriptCompilation("a", options:=TestOptions.ReleaseDll.WithOutputKind(OutputKind.WindowsRuntimeApplication)))
Assert.Throws(Of ArgumentException)(Function() VisualBasicCompilation.CreateScriptCompilation("a", options:=TestOptions.ReleaseDll.WithOutputKind(OutputKind.WindowsApplication)))
Assert.Throws(Of ArgumentException)(Function() VisualBasicCompilation.CreateScriptCompilation("a", options:=TestOptions.ReleaseDll.WithCryptoKeyContainer("goo")))
Assert.Throws(Of ArgumentException)(Function() VisualBasicCompilation.CreateScriptCompilation("a", options:=TestOptions.ReleaseDll.WithCryptoKeyFile("goo.snk")))
Assert.Throws(Of ArgumentException)(Function() VisualBasicCompilation.CreateScriptCompilation("a", options:=TestOptions.ReleaseDll.WithDelaySign(True)))
Assert.Throws(Of ArgumentException)(Function() VisualBasicCompilation.CreateScriptCompilation("a", options:=TestOptions.ReleaseDll.WithDelaySign(False)))
End Sub
<Fact>
Public Sub HasSubmissionResult()
Assert.False(VisualBasicCompilation.CreateScriptCompilation("sub").HasSubmissionResult())
Assert.True(CreateSubmission("?1", parseOptions:=TestOptions.Script).HasSubmissionResult())
Assert.False(CreateSubmission("1", parseOptions:=TestOptions.Script).HasSubmissionResult())
' TODO (https://github.com/dotnet/roslyn/issues/4763): '?' should be optional
' TestSubmissionResult(CreateSubmission("1", parseOptions:=TestOptions.Interactive), expectedType:=SpecialType.System_Int32, expectedHasValue:=True)
' TODO (https://github.com/dotnet/roslyn/issues/4766): ReturnType should not be ignored
' TestSubmissionResult(CreateSubmission("?1", parseOptions:=TestOptions.Interactive, returnType:=GetType(Double)), expectedType:=SpecialType.System_Double, expectedHasValue:=True)
Assert.False(CreateSubmission("
Sub Goo()
End Sub
").HasSubmissionResult())
Assert.False(CreateSubmission("Imports System", parseOptions:=TestOptions.Script).HasSubmissionResult())
Assert.False(CreateSubmission("Dim i As Integer", parseOptions:=TestOptions.Script).HasSubmissionResult())
Assert.False(CreateSubmission("System.Console.WriteLine()", parseOptions:=TestOptions.Script).HasSubmissionResult())
Assert.True(CreateSubmission("?System.Console.WriteLine()", parseOptions:=TestOptions.Script).HasSubmissionResult())
Assert.True(CreateSubmission("System.Console.ReadLine()", parseOptions:=TestOptions.Script).HasSubmissionResult())
Assert.True(CreateSubmission("?System.Console.ReadLine()", parseOptions:=TestOptions.Script).HasSubmissionResult())
Assert.True(CreateSubmission("?Nothing", parseOptions:=TestOptions.Script).HasSubmissionResult())
Assert.True(CreateSubmission("?AddressOf System.Console.WriteLine", parseOptions:=TestOptions.Script).HasSubmissionResult())
Assert.True(CreateSubmission("?Function(x) x", parseOptions:=TestOptions.Script).HasSubmissionResult())
End Sub
''' <summary>
''' Previous submission has to have no errors.
''' </summary>
<Fact>
Public Sub PreviousSubmissionWithError()
Dim s0 = CreateSubmission("Dim a As X = 1")
s0.VerifyDiagnostics(
Diagnostic(ERRID.ERR_UndefinedType1, "X").WithArguments("X"))
Assert.Throws(Of InvalidOperationException)(Function() CreateSubmission("?a + 1", previous:=s0))
End Sub
<Fact>
<WorkItem(13925, "https://github.com/dotnet/roslyn/issues/13925")>
Public Sub RemoveAllSyntaxTreesAndEmbeddedTrees_01()
Dim compilation1 = CreateCompilationWithMscorlib40(
<compilation>
<file name="a.vb">
Public Module C
Sub Main()
System.Console.WriteLine(1)
End Sub
End Module
</file>
</compilation>, options:=TestOptions.ReleaseExe.WithEmbedVbCoreRuntime(True), references:={SystemRef})
compilation1.VerifyDiagnostics()
Dim compilation2 = compilation1.RemoveAllSyntaxTrees()
compilation2 = compilation2.AddSyntaxTrees(compilation1.SyntaxTrees)
compilation2.VerifyDiagnostics()
CompileAndVerify(compilation2, expectedOutput:="1")
End Sub
<Fact>
<WorkItem(13925, "https://github.com/dotnet/roslyn/issues/13925")>
Public Sub RemoveAllSyntaxTreesAndEmbeddedTrees_02()
Dim compilation1 = CreateCompilationWithMscorlib40AndVBRuntime(
<compilation>
<file name="a.vb">
Public Module C
Sub Main()
System.Console.WriteLine(1)
End Sub
End Module
</file>
</compilation>, options:=TestOptions.ReleaseExe.WithEmbedVbCoreRuntime(True))
compilation1.VerifyDiagnostics()
Dim compilation2 = compilation1.RemoveAllSyntaxTrees()
compilation2 = compilation2.AddSyntaxTrees(compilation1.SyntaxTrees)
compilation2.VerifyDiagnostics()
CompileAndVerify(compilation2, expectedOutput:="1")
End Sub
End Class
End Namespace
|
brettfo/roslyn
|
src/Compilers/VisualBasic/Test/Semantic/Compilation/CompilationAPITests.vb
|
Visual Basic
|
apache-2.0
| 122,748
|
Option Strict On
Option Explicit On
Namespace Manhattan
Public Class manhattanCustomData
Public polygons As List(Of manhattanPolygon)
''' <summary>
''' area is number of cells, since grid considered to be unit squares
''' </summary>
Public area As Integer
Public Sub New(ByVal polygons As List(Of manhattanPolygon), ByVal area As Integer)
Me.polygons = polygons
Me.area = area
End Sub
End Class
End NameSpace
|
swsglobal/DotSpatial
|
Source/DotSpatial.Plugins.Taudem.Port/Manhattan/manhattanCustomData.vb
|
Visual Basic
|
mit
| 515
|
' Copyright (c) Microsoft. 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.Composition
Imports System.Threading
Imports Microsoft.CodeAnalysis
Imports Microsoft.CodeAnalysis.CodeGeneration
Imports Microsoft.CodeAnalysis.GenerateMember.GenerateParameterizedMember
Imports Microsoft.CodeAnalysis.Host
Imports Microsoft.CodeAnalysis.Host.Mef
Imports Microsoft.CodeAnalysis.LanguageServices
Imports Microsoft.CodeAnalysis.VisualBasic.Extensions.ContextQuery
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Namespace Microsoft.CodeAnalysis.VisualBasic.GenerateMember.GenerateMethod
<ExportLanguageService(GetType(IGenerateParameterizedMemberService), LanguageNames.VisualBasic), [Shared]>
Partial Friend Class VisualBasicGenerateMethodService
Inherits AbstractGenerateMethodService(Of VisualBasicGenerateMethodService, SimpleNameSyntax, ExpressionSyntax, InvocationExpressionSyntax)
Protected Overrides Function IsExplicitInterfaceGeneration(node As SyntaxNode) As Boolean
Return TypeOf node Is QualifiedNameSyntax
End Function
Protected Overrides Function IsSimpleNameGeneration(node As SyntaxNode) As Boolean
Return TypeOf node Is SimpleNameSyntax
End Function
Protected Overrides Function AreSpecialOptionsActive(semanticModel As SemanticModel) As Boolean
Return VisualBasicCommonGenerationServiceMethods.AreSpecialOptionsActive(semanticModel)
End Function
Protected Overrides Function IsValidSymbol(symbol As ISymbol, semanticModel As SemanticModel) As Boolean
Return VisualBasicCommonGenerationServiceMethods.IsValidSymbol(symbol, semanticModel)
End Function
Protected Overrides Function TryInitializeExplicitInterfaceState(
document As SemanticDocument,
node As SyntaxNode,
cancellationToken As CancellationToken,
ByRef identifierToken As SyntaxToken,
ByRef methodSymbol As IMethodSymbol,
ByRef typeToGenerateIn As INamedTypeSymbol) As Boolean
Dim qualifiedName = DirectCast(node, QualifiedNameSyntax)
identifierToken = qualifiedName.Right.Identifier
If qualifiedName.IsParentKind(SyntaxKind.ImplementsClause) Then
Dim implementsClause = DirectCast(qualifiedName.Parent, ImplementsClauseSyntax)
If implementsClause.IsParentKind(SyntaxKind.SubStatement) OrElse
implementsClause.IsParentKind(SyntaxKind.FunctionStatement) Then
Dim methodStatement = DirectCast(implementsClause.Parent, MethodStatementSyntax)
Dim semanticModel = document.SemanticModel
methodSymbol = DirectCast(semanticModel.GetDeclaredSymbol(methodStatement, cancellationToken), IMethodSymbol)
If methodSymbol IsNot Nothing AndAlso Not methodSymbol.ExplicitInterfaceImplementations.Any() Then
Dim semanticInfo = semanticModel.GetTypeInfo(qualifiedName.Left, cancellationToken)
typeToGenerateIn = TryCast(semanticInfo.Type, INamedTypeSymbol)
Return typeToGenerateIn IsNot Nothing
End If
End If
End If
identifierToken = Nothing
methodSymbol = Nothing
typeToGenerateIn = Nothing
Return False
End Function
Protected Overrides Function TryInitializeSimpleNameState(
document As SemanticDocument,
simpleName As SimpleNameSyntax,
cancellationToken As CancellationToken,
ByRef identifierToken As SyntaxToken,
ByRef simpleNameOrMemberAccessExpression As ExpressionSyntax,
ByRef invocationExpressionOpt As InvocationExpressionSyntax,
ByRef isInConditionalAccessExpression As Boolean) As Boolean
identifierToken = simpleName.Identifier
Dim memberAccess = TryCast(simpleName?.Parent, MemberAccessExpressionSyntax)
Dim conditionalMemberAccessInvocationExpression = TryCast(simpleName?.Parent?.Parent?.Parent, ConditionalAccessExpressionSyntax)
Dim conditionalMemberAccessSimpleMemberAccess = TryCast(simpleName?.Parent?.Parent, ConditionalAccessExpressionSyntax)
If memberAccess?.Name Is simpleName Then
simpleNameOrMemberAccessExpression = DirectCast(memberAccess, ExpressionSyntax)
ElseIf TryCast(TryCast(conditionalMemberAccessInvocationExpression?.WhenNotNull, InvocationExpressionSyntax)?.Expression, MemberAccessExpressionSyntax)?.Name Is simpleName Then
simpleNameOrMemberAccessExpression = conditionalMemberAccessInvocationExpression
ElseIf TryCast(conditionalMemberAccessSimpleMemberAccess?.WhenNotNull, MemberAccessExpressionSyntax)?.Name Is simpleName Then
simpleNameOrMemberAccessExpression = conditionalMemberAccessSimpleMemberAccess
Else
simpleNameOrMemberAccessExpression = simpleName
End If
If memberAccess Is Nothing OrElse memberAccess.Name Is simpleName Then
' VB is ambiguous. Something that looks like a method call might
' actually just be an array access. Check for that here.
Dim semanticModel = document.SemanticModel
Dim nameSemanticInfo = semanticModel.GetTypeInfo(simpleNameOrMemberAccessExpression, cancellationToken)
If TypeOf nameSemanticInfo.Type IsNot IArrayTypeSymbol Then
' Don't offer generate method if it's a call to another constructor inside a
' constructor.
If Not memberAccess.IsConstructorInitializer() Then
If cancellationToken.IsCancellationRequested Then
isInConditionalAccessExpression = False
Return False
End If
isInConditionalAccessExpression = conditionalMemberAccessInvocationExpression IsNot Nothing Or conditionalMemberAccessSimpleMemberAccess IsNot Nothing
If simpleNameOrMemberAccessExpression.IsParentKind(SyntaxKind.InvocationExpression) Then
invocationExpressionOpt = DirectCast(simpleNameOrMemberAccessExpression.Parent, InvocationExpressionSyntax)
Return invocationExpressionOpt.ArgumentList Is Nothing OrElse
Not invocationExpressionOpt.ArgumentList.CloseParenToken.IsMissing
ElseIf TryCast(TryCast(TryCast(simpleNameOrMemberAccessExpression, ConditionalAccessExpressionSyntax)?.WhenNotNull, InvocationExpressionSyntax)?.Expression, MemberAccessExpressionSyntax)?.Name Is simpleName
invocationExpressionOpt = DirectCast(DirectCast(simpleNameOrMemberAccessExpression, ConditionalAccessExpressionSyntax).WhenNotNull, InvocationExpressionSyntax)
Return invocationExpressionOpt.ArgumentList Is Nothing OrElse
Not invocationExpressionOpt.ArgumentList.CloseParenToken.IsMissing
ElseIf TryCast(conditionalMemberAccessSimpleMemberAccess?.WhenNotNull, MemberAccessExpressionSyntax)?.Name Is simpleName AndAlso
IsLegal(semanticModel, simpleNameOrMemberAccessExpression, cancellationToken) Then
Return True
ElseIf simpleNameOrMemberAccessExpression?.Parent?.IsKind(SyntaxKind.AddressOfExpression, SyntaxKind.NameOfExpression) Then
Return True
ElseIf IsLegal(semanticModel, simpleNameOrMemberAccessExpression, cancellationToken) Then
simpleNameOrMemberAccessExpression =
If(memberAccess IsNot Nothing AndAlso memberAccess.Name Is simpleName,
DirectCast(memberAccess, ExpressionSyntax),
simpleName)
Return True
End If
End If
End If
End If
identifierToken = Nothing
simpleNameOrMemberAccessExpression = Nothing
invocationExpressionOpt = Nothing
isInConditionalAccessExpression = False
Return False
End Function
Private Function IsLegal(semanticModel As SemanticModel, expression As ExpressionSyntax, cancellationToken As CancellationToken) As Boolean
Dim tree = semanticModel.SyntaxTree
Dim position = expression.SpanStart
If Not tree.IsExpressionContext(position, cancellationToken) AndAlso
Not tree.IsSingleLineStatementContext(position, cancellationToken) Then
Return False
End If
Return expression.CanReplaceWithLValue(semanticModel, cancellationToken)
End Function
Protected Overrides Function CreateInvocationMethodInfo(document As SemanticDocument, state As AbstractGenerateParameterizedMemberService(Of VisualBasicGenerateMethodService, SimpleNameSyntax, ExpressionSyntax, InvocationExpressionSyntax).State) As AbstractInvocationInfo
Return New VisualBasicGenerateParameterizedMemberService(Of VisualBasicGenerateMethodService).InvocationExpressionInfo(document, state)
End Function
Protected Overrides Function CanGenerateMethodForSimpleNameOrMemberAccessExpression(typeInferenceService As ITypeInferenceService, semanticModel As SemanticModel, expresion As ExpressionSyntax, cancellationToken As CancellationToken) As ITypeSymbol
Return typeInferenceService.InferType(semanticModel, expresion, True, cancellationToken)
End Function
End Class
End Namespace
|
paladique/roslyn
|
src/Features/VisualBasic/GenerateMember/GenerateParameterizedMember/VisualBasicGenerateMethodService.vb
|
Visual Basic
|
apache-2.0
| 10,125
|
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System.Collections.Immutable
Imports Microsoft.CodeAnalysis.Text
Imports Microsoft.CodeAnalysis.VisualBasic.Symbols
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Namespace Microsoft.CodeAnalysis.VisualBasic
''' <summary>
''' This binder keeps track of the set of constant fields that are currently being evaluated
''' so that the set can be passed into the next call to SourceFieldSymbol.ConstantValue (and
''' its callers).
''' </summary>
Friend NotInheritable Class ConstantFieldsInProgressBinder
Inherits Binder
Private ReadOnly _inProgress As SymbolsInProgress(Of FieldSymbol)
Private ReadOnly _field As FieldSymbol
Friend Sub New(inProgress As SymbolsInProgress(Of FieldSymbol), [next] As Binder, field As FieldSymbol)
MyBase.New([next])
Me._inProgress = inProgress
Me._field = field
End Sub
Friend Overrides ReadOnly Property ConstantFieldsInProgress As SymbolsInProgress(Of FieldSymbol)
Get
Return _inProgress
End Get
End Property
Public Overrides ReadOnly Property ContainingMember As Symbol
Get
Return _field
End Get
End Property
Public Overrides ReadOnly Property AdditionalContainingMembers As ImmutableArray(Of Symbol)
Get
Return ImmutableArray(Of Symbol).Empty
End Get
End Property
End Class
End Namespace
|
mmitche/roslyn
|
src/Compilers/VisualBasic/Portable/Binding/ConstantFieldsInProgressBinder.vb
|
Visual Basic
|
apache-2.0
| 1,675
|
' Licensed to the .NET Foundation under one or more agreements.
' The .NET Foundation licenses this file to you under the MIT license.
' See the LICENSE file in the project root for more information.
Imports System.Collections.Generic
Imports System.Collections.Immutable
Imports System.Globalization
Imports System.Threading
Imports Microsoft.CodeAnalysis
Imports Microsoft.CodeAnalysis.Text
Imports Microsoft.CodeAnalysis.VisualBasic.Symbols
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
Friend NotInheritable Class SubstitutedEventSymbol
Inherits EventSymbol
Private ReadOnly _originalDefinition As EventSymbol
Private ReadOnly _containingType As SubstitutedNamedType
Private ReadOnly _addMethod As SubstitutedMethodSymbol
Private ReadOnly _removeMethod As SubstitutedMethodSymbol
Private ReadOnly _raiseMethod As SubstitutedMethodSymbol
Private ReadOnly _associatedField As SubstitutedFieldSymbol
Private _lazyType As TypeSymbol
'we want to compute this lazily since it may be expensive for the underlying symbol
Private _lazyExplicitInterfaceImplementations As ImmutableArray(Of EventSymbol)
Private _lazyOverriddenOrHiddenMembers As OverriddenMembersResult(Of EventSymbol)
Friend Sub New(containingType As SubstitutedNamedType,
originalDefinition As EventSymbol,
addMethod As SubstitutedMethodSymbol,
removeMethod As SubstitutedMethodSymbol,
raiseMethod As SubstitutedMethodSymbol,
associatedField As SubstitutedFieldSymbol)
Me._containingType = containingType
Me._originalDefinition = originalDefinition
Me._associatedField = associatedField
If addMethod IsNot Nothing Then
addMethod.SetAssociatedPropertyOrEvent(Me)
_addMethod = addMethod
End If
If removeMethod IsNot Nothing Then
removeMethod.SetAssociatedPropertyOrEvent(Me)
_removeMethod = removeMethod
End If
If raiseMethod IsNot Nothing Then
raiseMethod.SetAssociatedPropertyOrEvent(Me)
_raiseMethod = raiseMethod
End If
End Sub
Friend ReadOnly Property TypeSubstitution As TypeSubstitution
Get
Return _containingType.TypeSubstitution
End Get
End Property
Public Overrides ReadOnly Property Type As TypeSymbol
Get
If Me._lazyType Is Nothing Then
Interlocked.CompareExchange(Me._lazyType,
_originalDefinition.Type.InternalSubstituteTypeParameters(TypeSubstitution).AsTypeSymbolOnly(),
Nothing)
End If
Return Me._lazyType
End Get
End Property
Public Overrides ReadOnly Property Name As String
Get
Return Me.OriginalDefinition.Name
End Get
End Property
Friend Overrides ReadOnly Property HasSpecialName As Boolean
Get
Return Me._originalDefinition.HasSpecialName
End Get
End Property
Public Overrides ReadOnly Property ContainingSymbol As Symbol
Get
Return Me._containingType
End Get
End Property
Public Overrides ReadOnly Property ContainingType As NamedTypeSymbol
Get
Return Me._containingType
End Get
End Property
Public Overrides ReadOnly Property OriginalDefinition As EventSymbol
Get
Return Me._originalDefinition
End Get
End Property
Public Overrides ReadOnly Property Locations As ImmutableArray(Of Location)
Get
Return Me._originalDefinition.Locations
End Get
End Property
Public Overrides ReadOnly Property DeclaringSyntaxReferences As ImmutableArray(Of SyntaxReference)
Get
Return Me._originalDefinition.DeclaringSyntaxReferences
End Get
End Property
Public Overrides Function GetAttributes() As ImmutableArray(Of VisualBasicAttributeData)
Return Me._originalDefinition.GetAttributes()
End Function
Public Overrides ReadOnly Property IsShared As Boolean
Get
Return Me._originalDefinition.IsShared
End Get
End Property
Public Overrides ReadOnly Property IsNotOverridable As Boolean
Get
Return Me._originalDefinition.IsNotOverridable
End Get
End Property
Public Overrides ReadOnly Property IsMustOverride As Boolean
Get
Return Me._originalDefinition.IsMustOverride
End Get
End Property
Public Overrides ReadOnly Property IsOverridable As Boolean
Get
Return Me._originalDefinition.IsOverridable
End Get
End Property
Public Overrides ReadOnly Property IsOverrides As Boolean
Get
Return Me.OriginalDefinition.IsOverrides
End Get
End Property
Public Overrides ReadOnly Property IsImplicitlyDeclared As Boolean
Get
Return Me.OriginalDefinition.IsImplicitlyDeclared
End Get
End Property
Public Overrides ReadOnly Property AddMethod As MethodSymbol
Get
Return _addMethod
End Get
End Property
Public Overrides ReadOnly Property RemoveMethod As MethodSymbol
Get
Return _removeMethod
End Get
End Property
Public Overrides ReadOnly Property RaiseMethod As MethodSymbol
Get
Return _raiseMethod
End Get
End Property
Friend Overrides ReadOnly Property AssociatedField As FieldSymbol
Get
Return _associatedField
End Get
End Property
Friend Overrides ReadOnly Property IsExplicitInterfaceImplementation As Boolean
Get
Return Me._originalDefinition.IsExplicitInterfaceImplementation
End Get
End Property
Public Overrides ReadOnly Property ExplicitInterfaceImplementations As ImmutableArray(Of EventSymbol)
Get
If _lazyExplicitInterfaceImplementations.IsDefault Then
ImmutableInterlocked.InterlockedCompareExchange(_lazyExplicitInterfaceImplementations,
ImplementsHelper.SubstituteExplicitInterfaceImplementations(
_originalDefinition.ExplicitInterfaceImplementations,
TypeSubstitution),
Nothing)
End If
Return _lazyExplicitInterfaceImplementations
End Get
End Property
Public Overrides ReadOnly Property DeclaredAccessibility As Accessibility
Get
Return Me.OriginalDefinition.DeclaredAccessibility
End Get
End Property
Friend Overrides ReadOnly Property OverriddenOrHiddenMembers As OverriddenMembersResult(Of EventSymbol)
Get
If Me._lazyOverriddenOrHiddenMembers Is Nothing Then
Interlocked.CompareExchange(Me._lazyOverriddenOrHiddenMembers,
OverrideHidingHelper(Of EventSymbol).MakeOverriddenMembers(Me),
Nothing)
End If
Return Me._lazyOverriddenOrHiddenMembers
End Get
End Property
Friend Overrides ReadOnly Property ObsoleteAttributeData As ObsoleteAttributeData
Get
Return Me.OriginalDefinition.ObsoleteAttributeData
End Get
End Property
Public Overrides ReadOnly Property IsWindowsRuntimeEvent As Boolean
Get
Return _originalDefinition.IsWindowsRuntimeEvent
End Get
End Property
Public Overrides Function GetDocumentationCommentXml(Optional preferredCulture As CultureInfo = Nothing, Optional expandIncludes As Boolean = False, Optional cancellationToken As CancellationToken = Nothing) As String
Return _originalDefinition.GetDocumentationCommentXml(preferredCulture, expandIncludes, cancellationToken)
End Function
End Class
End Namespace
|
physhi/roslyn
|
src/Compilers/VisualBasic/Portable/Symbols/SubstitutedEventSymbol.vb
|
Visual Basic
|
apache-2.0
| 9,012
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.