提交 3fe345e9 编写于 作者: W Wonseok Chae

Support EnC for query expressions in VB compiler

上级 efc05f3b
' 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.Immutable
Imports Microsoft.CodeAnalysis.CodeGen
Imports Microsoft.CodeAnalysis.VisualBasic.Symbols
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Namespace Microsoft.CodeAnalysis.VisualBasic
Friend NotInheritable Class SynthesizedLambdaCacheFieldSymbol
Inherits SynthesizedFieldSymbol
Implements ISynthesizedMethodBodyImplementationSymbol
Private ReadOnly m_topLevelMethod As MethodSymbol
Public Sub New(containingType As NamedTypeSymbol,
implicitlyDefinedBy As Symbol,
type As TypeSymbol,
name As String,
topLevelMethod As MethodSymbol,
Optional accessibility As Accessibility = Accessibility.Private,
Optional isReadOnly As Boolean = False,
Optional isShared As Boolean = False,
Optional isSpecialNameAndRuntimeSpecial As Boolean = False)
MyBase.New(containingType, implicitlyDefinedBy, type, name, accessibility, isReadOnly, isShared, isSpecialNameAndRuntimeSpecial)
Debug.Assert(topLevelMethod IsNot Nothing)
m_topLevelMethod = topLevelMethod
End Sub
' When the containing top-level method body is updated we don't need to attempt to update the cache field
' since a field update is a no-op.
Public ReadOnly Property HasMethodBodyDependency As Boolean Implements ISynthesizedMethodBodyImplementationSymbol.HasMethodBodyDependency
Get
Return False
End Get
End Property
Public ReadOnly Property Method As IMethodSymbol Implements ISynthesizedMethodBodyImplementationSymbol.Method
Get
Return m_topLevelMethod
End Get
End Property
End Class
End Namespace
......@@ -951,22 +951,23 @@ internal bool TryCalculateSyntaxOffsetOfPositionInInitializer(int position, Synt
return true;
}
internal static ImmutableArray<FieldOrPropertyInitializer> GetInitializersInSourceTree(SyntaxTree tree, ImmutableArray<ImmutableArray<FieldOrPropertyInitializer>> initializers)
private static ImmutableArray<FieldOrPropertyInitializer> GetInitializersInSourceTree(SyntaxTree tree, ImmutableArray<ImmutableArray<FieldOrPropertyInitializer>> initializers)
{
var builder = ArrayBuilder<FieldOrPropertyInitializer>.GetInstance();
foreach (var siblingInitializers in initializers)
{
Debug.Assert(!siblingInitializers.IsEmpty);
if (siblingInitializers[0].Syntax.SyntaxTree == tree)
{
return siblingInitializers;
builder.AddRange(siblingInitializers);
}
}
return ImmutableArray<FieldOrPropertyInitializer>.Empty;
return builder.ToImmutable();
}
internal static int IndexOfInitializerContainingPosition(ImmutableArray<FieldOrPropertyInitializer> initializers, int position)
private static int IndexOfInitializerContainingPosition(ImmutableArray<FieldOrPropertyInitializer> initializers, int position)
{
// Search for the start of the span (the spans are non-overlapping and sorted)
int index = initializers.BinarySearch(position, (initializer, pos) => initializer.Syntax.Span.Start.CompareTo(pos));
......
......@@ -369,6 +369,65 @@ class C : D
Row(11, TableIndex.MethodDef, EditAndContinueOperation.Default));
}
[Fact]
public void PartialClass()
{
var source0 = MarkedSource(@"
using System;
partial class C
{
Func<int> m1 = <N:0>() => 1</N:0>;
}
partial class C
{
Func<int> m2 = <N:1>() => 1</N:1>;
}
");
var source1 = MarkedSource(@"
using System;
partial class C
{
Func<int> m1 = <N:0>() => 10</N:0>;
}
partial class C
{
Func<int> m2 = <N:1>() => 10</N:1>;
}");
var compilation0 = CreateCompilationWithMscorlib(source0.Tree, options: ComSafeDebugDll.WithMetadataImportOptions(MetadataImportOptions.All));
var compilation1 = compilation0.WithSource(source1.Tree);
var v0 = CompileAndVerify(compilation0);
var md0 = ModuleMetadata.CreateFromImage(v0.EmittedAssemblyData);
var ctor0 = compilation0.GetMember<NamedTypeSymbol>("C").InstanceConstructors.Single();
var ctor1 = compilation1.GetMember<NamedTypeSymbol>("C").InstanceConstructors.Single();
var generation0 = EmitBaseline.CreateInitialBaseline(md0, v0.CreatePdbInfoProvider().GetEncMethodDebugInfo);
var diff1 = compilation1.EmitDifference(
generation0,
ImmutableArray.Create(new SemanticEdit(SemanticEditKind.Update, ctor0, ctor1, GetSyntaxMapFromMarkers(source0, source1), preserveLocalVariables: true)));
// no new synthesized members generated (with #1 in names):
diff1.VerifySynthesizedMembers(
"C: {<>c}",
"C.<>c: {<>9__2_0, <>9__2_1, <.ctor>b__2_0, <.ctor>b__2_1}");
var md1 = diff1.GetMetadata();
var reader1 = md1.Reader;
// Method updates
CheckEncLogDefinitions(reader1,
Row(2, TableIndex.StandAloneSig, EditAndContinueOperation.Default),
Row(1, TableIndex.MethodDef, EditAndContinueOperation.Default),
Row(4, TableIndex.MethodDef, EditAndContinueOperation.Default),
Row(5, TableIndex.MethodDef, EditAndContinueOperation.Default));
}
[Fact]
public void JoinAndGroupByClauses()
{
......
......@@ -464,6 +464,7 @@
<Compile Include="Lowering\LambdaRewriter\LambdaRewriter.Analysis.vb" />
<Compile Include="Lowering\LambdaRewriter\LambdaRewriter.vb" />
<Compile Include="Lowering\LambdaRewriter\SynthesizedLambdaMethod.vb" />
<Compile Include="Lowering\LambdaRewriter\SynthesizedLambdaCacheFieldSymbol.vb" />
<Compile Include="Lowering\LocalRewriter\LocalRewriter.vb" />
<Compile Include="Lowering\LocalRewriter\LocalRewriter_AddRemoveHandler.vb" />
<Compile Include="Lowering\LocalRewriter\LocalRewriter_AnonymousTypeCreationExpression.vb" />
......
......@@ -1468,7 +1468,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
lambdaBinders = ImmutableArray.Create(Of Binder)(outerKeyBinder, innerKeyBinder)
End If
Dim joinSelectorLambda As New BoundQueryLambda(joinSelectorSyntax,
joinSelectorLambdaSymbol,
joinSelectorRangeVariables,
......@@ -1897,7 +1896,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Dim keysSelector = keysLambdaBinder.BindExpressionRangeVariables(keys, True, groupBy,
keysRangeVariables, diagnostics)
Dim keysLambda As New BoundQueryLambda(groupBy,
Dim keysLambda As New BoundQueryLambda(keysSelector.Syntax,
keysLambdaSymbol,
source.RangeVariables,
keysSelector,
......@@ -2117,7 +2116,8 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
intoRangeVariables,
diagnostics)
Dim intoLambda As New BoundQueryLambda(syntaxNode,
Dim syntax As VisualBasicSyntaxNode = aggregationVariables.FirstOrDefault()
Dim intoLambda As New BoundQueryLambda(If(syntax, syntaxNode),
intoLambdaSymbol,
keysRangeVariables,
intoSelector,
......@@ -3358,7 +3358,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
suppressDiagnostics.Free()
End If
outerKeyLambda = New BoundQueryLambda(join,
outerKeyLambda = New BoundQueryLambda(outerKey.Syntax,
outerKeyLambdaSymbol,
outer.RangeVariables,
outerKey,
......@@ -3366,7 +3366,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
outerKeyLambda.SetWasCompilerGenerated()
innerKeyLambda = New BoundQueryLambda(join,
innerKeyLambda = New BoundQueryLambda(innerKey.Syntax,
innerKeyLambdaSymbol,
inner.RangeVariables,
innerKey,
......
......@@ -1262,9 +1262,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Debug.Assert(_moduleBeingBuiltOpt Is Nothing OrElse _moduleBeingBuiltOpt.AllowOmissionOfConditionalCalls)
Dim lambdaDebugInfoBuilder = ArrayBuilder(Of LambdaDebugInfo).GetInstance()
Dim closureDebugInfoBuilder = ArrayBuilder(Of ClosureDebugInfo).GetInstance()
For Each handledEvent In handledEvents
If handledEvent.HandlesKind <> HandledEventKind.WithEvents Then
Continue For
......@@ -1294,8 +1291,8 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
' setter needs to rewritten as it may require lambda conversions
Dim setterBody = setter.GetBoundMethodBody(diagnostics, containingTypeBinder)
Dim lambdaOrdinalDispenser = 0
Dim scopeOrdinalDispenser = 0
Dim lambdaDebugInfoBuilder = ArrayBuilder(Of LambdaDebugInfo).GetInstance()
Dim closureDebugInfoBuilder = ArrayBuilder(Of ClosureDebugInfo).GetInstance()
setterBody = Rewriter.LowerBodyOrInitializer(setter,
withEventPropertyIdDispenser,
......@@ -1315,6 +1312,9 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Debug.Assert(Not lambdaDebugInfoBuilder.Any())
Debug.Assert(Not closureDebugInfoBuilder.Any())
lambdaDebugInfoBuilder.Free()
closureDebugInfoBuilder.Free()
compilationState.AddMethodWrapper(setter, setter, setterBody)
_moduleBeingBuiltOpt.AddSynthesizedDefinition(containingType, setter)
......@@ -1322,9 +1322,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
_moduleBeingBuiltOpt.AddSynthesizedDefinition(containingType, prop)
withEventPropertyIdDispenser += 1
Next
lambdaDebugInfoBuilder.Free()
closureDebugInfoBuilder.Free()
End Sub
''' <summary>
......
......@@ -22,8 +22,8 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Friend ReadOnly ClosureOrdinal As Integer
'NOTE: this does not include captured parent frame references
Friend ReadOnly m_captured_locals As New ArrayBuilder(Of LambdaCapturedVariable)
Friend ReadOnly m_constructor As SynthesizedLambdaConstructor
Friend ReadOnly CapturedLocals As New ArrayBuilder(Of LambdaCapturedVariable)
Private ReadOnly m_constructor As SynthesizedLambdaConstructor
Friend ReadOnly TypeMap As TypeSubstitution
Private ReadOnly m_scopeSyntaxOpt As VisualBasicSyntaxNode
......@@ -60,7 +60,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
If isStatic Then
Me.m_sharedConstructor = New SynthesizedConstructorSymbol(Nothing, Me, isShared:=True, isDebuggable:=False, binder:=Nothing, diagnostics:=Nothing)
Dim cacheVariableName = GeneratedNames.MakeCachedFrameInstanceName()
Me.m_singletonCache = New SynthesizedFieldSymbol(Me, Me, Me, cacheVariableName, Accessibility.Public, isReadOnly:=True, isShared:=True)
Me.m_singletonCache = New SynthesizedLambdaCacheFieldSymbol(Me, Me, Me, cacheVariableName, topLevelMethod, Accessibility.Public, isReadOnly:=True, isShared:=True)
m_scopeSyntaxOpt = Nothing
Else
m_scopeSyntaxOpt = scopeSyntaxOpt
......@@ -128,7 +128,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
End Function
Public Overloads Overrides Function GetMembers() As ImmutableArray(Of Symbol)
Dim members = StaticCast(Of Symbol).From(m_captured_locals.AsImmutable())
Dim members = StaticCast(Of Symbol).From(CapturedLocals.AsImmutable())
If m_sharedConstructor IsNot Nothing Then
members = members.AddRange(ImmutableArray.Create(Of Symbol)(m_constructor, m_sharedConstructor, m_singletonCache))
Else
......@@ -165,9 +165,9 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Friend Overrides Function GetFieldsToEmit() As IEnumerable(Of FieldSymbol)
If m_singletonCache Is Nothing Then
Return m_captured_locals
Return CapturedLocals
Else
Return DirectCast(m_captured_locals, IEnumerable(Of FieldSymbol)).Concat(Me.m_singletonCache)
Return DirectCast(CapturedLocals, IEnumerable(Of FieldSymbol)).Concat(Me.m_singletonCache)
End If
End Function
......
......@@ -258,7 +258,11 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
Dim nameAndIndex = template.NameAndIndex
Dim key = template.GetAnonymousTypeKey()
Dim value = New Microsoft.CodeAnalysis.Emit.AnonymousTypeValue(nameAndIndex.Name, nameAndIndex.Index, template)
result.Add(key, value)
If Not result.ContainsKey(key) Then
' Between generations, "key" properties are dropped, the same type could be already in the map.
' Consider revisit here to support anonymous types for EnC.
result.Add(key, value)
End If
Next
builder.Free()
Return result
......
......@@ -27,7 +27,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
''' A sum of widths of spans of all preceding initializers
''' (instance and static initializers are summed separately, and trivias are not counted).
''' </summary>
Friend PrecedingInitializersLength As Integer
Friend ReadOnly PrecedingInitializersLength As Integer
Friend ReadOnly IsMetadataConstant As Boolean
......@@ -35,10 +35,11 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
''' Initializer for an executable statement in script code.
''' </summary>
''' <param name="syntax">The initializer syntax for the statement.</param>
Public Sub New(syntax As SyntaxReference)
Public Sub New(syntax As SyntaxReference, precedingInitializersLength As Integer)
Debug.Assert(TypeOf syntax.GetSyntax() Is StatementSyntax)
Me.Syntax = syntax
Me.IsMetadataConstant = False
Me.PrecedingInitializersLength = precedingInitializersLength
End Sub
''' <summary>
......@@ -46,7 +47,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
''' </summary>
''' <param name="field">The field.</param>
''' <param name="syntax">The initializer syntax for the field.</param>
Public Sub New(field As FieldSymbol, syntax As SyntaxReference)
Public Sub New(field As FieldSymbol, syntax As SyntaxReference, precedingInitializersLength As Integer)
Debug.Assert(field IsNot Nothing)
Debug.Assert(syntax.GetSyntax().IsKind(SyntaxKind.AsNewClause) OrElse
syntax.GetSyntax().IsKind(SyntaxKind.EqualsValue) OrElse
......@@ -55,17 +56,19 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
Me.FieldsOrProperty = ImmutableArray.Create(Of Symbol)(field)
Me.Syntax = syntax
Me.IsMetadataConstant = field.IsMetadataConstant
Me.PrecedingInitializersLength = precedingInitializersLength
End Sub
''' <summary>
''' Initializes a new instance of the <see cref="FieldOrPropertyInitializer" /> structure.
''' </summary>
Public Sub New(fieldsOrProperties As ImmutableArray(Of Symbol), syntax As SyntaxReference)
Public Sub New(fieldsOrProperties As ImmutableArray(Of Symbol), syntax As SyntaxReference, precedingInitializersLength As Integer)
Debug.Assert(Not fieldsOrProperties.IsEmpty)
Debug.Assert(syntax.GetSyntax().IsKind(SyntaxKind.AsNewClause) OrElse syntax.GetSyntax().IsKind(SyntaxKind.EqualsValue))
Me.FieldsOrProperty = fieldsOrProperties
Me.Syntax = syntax
Me.IsMetadataConstant = False
Me.PrecedingInitializersLength = precedingInitializersLength
End Sub
''' <summary>
......@@ -73,7 +76,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
''' </summary>
''' <param name="property">The property.</param>
''' <param name="syntax">The initializer syntax for the property.</param>
Public Sub New([property] As PropertySymbol, syntax As SyntaxReference)
Public Sub New([property] As PropertySymbol, syntax As SyntaxReference, precedingInitializersLength As Integer)
Debug.Assert([property] IsNot Nothing)
Debug.Assert(syntax IsNot Nothing)
Debug.Assert(syntax.GetSyntax().IsKind(SyntaxKind.AsNewClause) OrElse syntax.GetSyntax().IsKind(SyntaxKind.EqualsValue))
......@@ -81,6 +84,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
Me.FieldsOrProperty = ImmutableArray.Create(Of Symbol)([property])
Me.Syntax = syntax
Me.IsMetadataConstant = False
Me.PrecedingInitializersLength = precedingInitializersLength
End Sub
End Structure
End Namespace
......@@ -1546,8 +1546,8 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
Friend ReadOnly DeferredMemberDiagnostic As ArrayBuilder(Of ValueTuple(Of Symbol, Binder)) = ArrayBuilder(Of ValueTuple(Of Symbol, Binder)).GetInstance()
Public StaticSyntaxLength As Integer = 0
Public InstanceSyntaxLength As Integer = 0
Friend StaticSyntaxLength As Integer = 0
Friend InstanceSyntaxLength As Integer = 0
Friend Function ToReadOnlyAndFree() As MembersAndInitializers
DeferredMemberDiagnostic.Free()
......@@ -1570,8 +1570,10 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
''' Adds a field initializer for the field to list of field initializers
''' </summary>
''' <param name="initializers">All initializers.</param>
''' <param name="initializer">The field initializer to add to the list of initializers.</param>
Friend Shared Sub AddInitializer(ByRef initializers As ArrayBuilder(Of FieldOrPropertyInitializer), initializer As FieldOrPropertyInitializer, ByRef aggregateSyntaxLength As Integer)
''' <param name="computeInitializer">Compute the field initializer to add to the list of initializers.</param>
Friend Shared Sub AddInitializer(ByRef initializers As ArrayBuilder(Of FieldOrPropertyInitializer), computeInitializer As Func(Of Integer, FieldOrPropertyInitializer), ByRef aggregateSyntaxLength As Integer)
Dim initializer = computeInitializer(aggregateSyntaxLength)
If initializers Is Nothing Then
initializers = ArrayBuilder(Of FieldOrPropertyInitializer).GetInstance()
Else
......@@ -1580,7 +1582,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
Debug.Assert(initializer.Syntax.Span.Start > initializers.Last().Syntax.Span.Start)
End If
initializer.PrecedingInitializersLength = aggregateSyntaxLength
'initializer.PrecedingInitializersLength = aggregateSyntaxLength
initializers.Add(initializer)
' A constant field of type decimal needs a field initializer, so
......@@ -2620,7 +2622,9 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
diagBag.Add(ERRID.ERR_InvalidInNamespace, memberSyntax.GetLocation())
End If
Dim initializer = New FieldOrPropertyInitializer(binder.GetSyntaxReference(memberSyntax))
Dim initializer = Function(precedingInitializersLength As Integer)
Return New FieldOrPropertyInitializer(binder.GetSyntaxReference(memberSyntax), precedingInitializersLength)
End Function
SourceNamedTypeSymbol.AddInitializer(instanceInitializers, initializer, members.InstanceSyntaxLength)
End If
End If
......@@ -2651,7 +2655,9 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
If equalsValueOrAsNewSyntax IsNot Nothing Then
Dim initializerOptRef = binder.GetSyntaxReference(equalsValueOrAsNewSyntax)
Dim initializer = New FieldOrPropertyInitializer(propertySymbol, initializerOptRef)
Dim initializer = Function(precedingInitializersLength As Integer)
Return New FieldOrPropertyInitializer(propertySymbol, initializerOptRef, precedingInitializersLength)
End Function
If propertySymbol.IsShared Then
AddInitializer(staticInitializers, initializer, members.StaticSyntaxLength)
......@@ -3241,7 +3247,9 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
aggregateLength += syntaxRef.Span.Length
Next
Throw ExceptionUtilities.Unreachable
' This point should not be reachable.
Debug.Assert(False)
Return -1
End If
Dim syntaxOffset As Integer
......@@ -3249,8 +3257,10 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
Return syntaxOffset
End If
' An implicit constructor has no body and no initializer, so the variable has to be declared in a member initializer
Throw ExceptionUtilities.Unreachable
' This point should not be reachable. An implicit constructor has no body and no initializer,
' so the variable has to be declared in a member initializer.
Debug.Assert(False)
Return -1
End Function
' Calculates a syntax offset of a syntax position that is contained in a property or field initializer (if it is in fact contained in one).
......@@ -3280,17 +3290,18 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
Return True
End Function
Friend Shared Function GetInitializersInSourceTree(tree As SyntaxTree, initializers As ImmutableArray(Of ImmutableArray(Of FieldOrPropertyInitializer))) As ImmutableArray(Of FieldOrPropertyInitializer)
Private Shared Function GetInitializersInSourceTree(tree As SyntaxTree, initializers As ImmutableArray(Of ImmutableArray(Of FieldOrPropertyInitializer))) As ImmutableArray(Of FieldOrPropertyInitializer)
Dim builder = ArrayBuilder(Of FieldOrPropertyInitializer).GetInstance()
For Each siblingInitializers In initializers
If (siblingInitializers.First().Syntax.SyntaxTree Is tree) Then
Return siblingInitializers
builder.AddRange(siblingInitializers)
End If
Next
Return ImmutableArray(Of FieldOrPropertyInitializer).Empty
Return builder.ToImmutable()
End Function
Friend Shared Function IndexOfInitializerContainingPosition(initializers As ImmutableArray(Of FieldOrPropertyInitializer), position As Integer) As Integer
Private Shared Function IndexOfInitializerContainingPosition(initializers As ImmutableArray(Of FieldOrPropertyInitializer), position As Integer) As Integer
' Search for the start of the span (the spans are non-overlapping and sorted)
Dim index = initializers.BinarySearch(position, Function(initializer, pos) initializer.Syntax.Span.Start.CompareTo(pos))
......@@ -3299,7 +3310,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
Return index
End If
' Otherwise, ~index is the closest span whose start is greater than the position.
' Otherwise, "Not index" is the closest span whose start is greater than the position.
' Make sure that this closest span contains the position.
index = (Not index) - 1
If index >= 0 AndAlso initializers(index).Syntax.Span.Contains(position) Then
......
......@@ -577,7 +577,9 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
Else
If initializerOpt Is Nothing Then
' Array declaration with implicit initializer.
Dim initializer = New FieldOrPropertyInitializer(fieldSymbol, modifiedIdentifierRef)
Dim initializer = Function(precedingInitializersLength As Integer)
Return New FieldOrPropertyInitializer(fieldSymbol, modifiedIdentifierRef, precedingInitializersLength)
End Function
If fieldSymbol.IsShared Then
SourceNamedTypeSymbol.AddInitializer(staticInitializers, initializer, members.StaticSyntaxLength)
Else
......@@ -611,7 +613,9 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
Next
If initializerOptRef IsNot Nothing Then
Dim initializer = New FieldOrPropertyInitializer(fieldOrWithEventSymbols.AsImmutableOrNull, initializerOptRef)
Dim initializer = Function(precedingInitializersLength As Integer)
Return New FieldOrPropertyInitializer(fieldOrWithEventSymbols.AsImmutableOrNull, initializerOptRef, precedingInitializersLength)
End Function
' all symbols are the same regarding the sharedness
Dim symbolsAreShared = nameCount > 0 AndAlso fieldOrWithEventSymbols(0).IsShared
......
......@@ -51,7 +51,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols
End Get
End Property
Friend Overrides Sub AddSynthesizedAttributes(compilationState as ModuleCompilationState, ByRef attributes As ArrayBuilder(Of SynthesizedAttributeData))
Friend Overrides Sub AddSynthesizedAttributes(compilationState As ModuleCompilationState, ByRef attributes As ArrayBuilder(Of SynthesizedAttributeData))
MyBase.AddSynthesizedAttributes(compilationState, attributes)
' enum fields do not need to be marked as generated
......
......@@ -1169,12 +1169,5 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Return False
End Function
' "Pair lambda" is a synthesized lambda that creates an instance of an anonymous type representing a pair of values.
' TODO: Avoid generating lambdas. Instead generate a method on the anonymous type, or use KeyValuePair instead.
Friend Shared Function IsQueryPairLambda(syntax As SyntaxNode) As Boolean
Return syntax.IsKind(SyntaxKind.GroupByClause) OrElse syntax.IsKind(SyntaxKind.GroupJoinClause) OrElse syntax.IsKind(SyntaxKind.FromClause) OrElse syntax.IsKind(SyntaxKind.SimpleJoinClause)
End Function
End Class
End Namespace
......@@ -9,6 +9,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
''' SyntaxNode.GetCorrespondingLambdaBody(SyntaxNode)
''' </summary>
Friend Shared Function GetCorrespondingLambdaBody(oldBody As SyntaxNode, newLambda As SyntaxNode) As SyntaxNode
Dim oldLambda = oldBody.Parent
Select Case oldLambda.Kind
......@@ -43,12 +44,43 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
SyntaxKind.DescendingOrdering
Return DirectCast(newLambda, OrderingSyntax).Expression
Case SyntaxKind.SelectClause
Dim oldSelect = DirectCast(oldLambda, SelectClauseSyntax)
Return DirectCast(newLambda, SelectClauseSyntax).Variables.First
Case SyntaxKind.JoinCondition
Dim oldJoin = DirectCast(oldLambda, JoinConditionSyntax)
Dim newJoin = DirectCast(newLambda, JoinConditionSyntax)
Debug.Assert(oldJoin.Left Is oldBody OrElse oldJoin.Right Is oldBody)
Return If(oldJoin.Left Is oldBody, newJoin.Left, newJoin.Right)
Case SyntaxKind.GroupByClause
Dim oldGroup = DirectCast(oldLambda, GroupByClauseSyntax)
Dim newGroup = DirectCast(newLambda, GroupByClauseSyntax)
If oldBody.IsKind(SyntaxKind.ExpressionRangeVariable) Then
Debug.Assert(oldGroup.Keys.Contains(DirectCast(oldBody, ExpressionRangeVariableSyntax)))
Dim location = oldGroup.Keys.IndexOf(DirectCast(oldBody, ExpressionRangeVariableSyntax))
Return newGroup.Keys(location)
Else
Debug.Assert(oldBody.IsKind(SyntaxKind.AggregationRangeVariable))
Dim syntax = newGroup.AggregationVariables.First
Return If(syntax, newLambda)
End If
Case SyntaxKind.FromClause
Dim oldFrom = DirectCast(oldLambda, FromClauseSyntax)
Dim newFrom = DirectCast(newLambda, FromClauseSyntax)
Debug.Assert(oldFrom.Variables.Contains(DirectCast(oldBody, CollectionRangeVariableSyntax)))
Dim location = oldFrom.Variables.IndexOf(DirectCast(oldBody, CollectionRangeVariableSyntax))
Return newFrom.Variables(location)
Case SyntaxKind.GroupJoinClause
Dim oldGroup = DirectCast(oldLambda, GroupJoinClauseSyntax)
Dim newGroup = DirectCast(newLambda, GroupJoinClauseSyntax)
Debug.Assert(oldBody.IsKind(SyntaxKind.AggregationRangeVariable))
Dim syntax = newGroup.AggregationVariables.First
Return If(syntax, newLambda)
Case Else
Throw ExceptionUtilities.Unreachable
End Select
......
......@@ -225,7 +225,7 @@ End Module
End Sub
<Fact(), WorkItem(827337, "DevDiv"), WorkItem(836491, "DevDiv")>
Public Sub LocalCapturedAndHoisted()
Public Sub LocalCapturedInBetweenSuspensionPoints_Debug()
Dim source =
<compilation>
<file>
......@@ -233,7 +233,7 @@ Imports System
Imports System.Threading.Tasks
Public Class C
Private Async Function Async_Lambda_Hoisted() As Task
Private Async Function Async_Lambda() As Task
Dim x As Integer = 1
Dim y As Integer = 2
......@@ -252,16 +252,11 @@ End Class
{MscorlibRef_v4_0_30316_17626, MsvbRef},
TestOptions.DebugDll)
compilation.VerifyPdb("C.Async_Lambda_Hoisted",
<symbols>
<methods/>
</symbols>)
' Goal: We're looking for the double-mangled name "$VB$ResumableLocal_$VB$Closure_2$1".
compilation.VerifyPdb("C+VB$StateMachine_1_Async_Lambda_Hoisted.MoveNext",
' Goal: We're looking for "$VB$ResumableLocal_$VB$Closure_$0" and "$VB$ResumableLocal_a$1".
compilation.VerifyPdb("C+VB$StateMachine_1_Async_Lambda.MoveNext",
<symbols>
<methods>
<method containingType="C+VB$StateMachine_1_Async_Lambda_Hoisted" name="MoveNext">
<method containingType="C+VB$StateMachine_1_Async_Lambda" name="MoveNext">
<customDebugInfo>
<encLocalSlotMap>
<slot kind="27" offset="-1"/>
......@@ -275,7 +270,7 @@ End Class
<sequencePoints>
<entry offset="0x0" hidden="true" document="0"/>
<entry offset="0x7" hidden="true" document="0"/>
<entry offset="0x12" startLine="5" startColumn="5" endLine="5" endColumn="58" document="0"/>
<entry offset="0x12" startLine="5" startColumn="5" endLine="5" endColumn="50" document="0"/>
<entry offset="0x13" hidden="true" document="0"/>
<entry offset="0x1e" startLine="6" startColumn="13" endLine="6" endColumn="29" document="0"/>
<entry offset="0x2a" startLine="7" startColumn="13" endLine="7" endColumn="29" document="0"/>
......@@ -301,16 +296,16 @@ End Class
</scope>
</scope>
<asyncInfo>
<kickoffMethod declaringType="C" methodName="Async_Lambda_Hoisted"/>
<await yield="0x91" resume="0xb0" declaringType="C+VB$StateMachine_1_Async_Lambda_Hoisted" methodName="MoveNext"/>
<kickoffMethod declaringType="C" methodName="Async_Lambda"/>
<await yield="0x91" resume="0xb0" declaringType="C+VB$StateMachine_1_Async_Lambda" methodName="MoveNext"/>
</asyncInfo>
</method>
</methods>
</symbols>)
End Sub
<Fact(), WorkItem(827337, "DevDiv"), WorkItem(836491, "DevDiv")>
Public Sub LocalCapturedAndNotHoisted()
<Fact()>
Public Sub LocalCapturedInBetweenSuspensionPoints_Release()
Dim source =
<compilation>
<file>
......@@ -318,13 +313,15 @@ Imports System
Imports System.Threading.Tasks
Public Class C
Private Async Function Async_Lambda_NotHoisted() As Task
Private Async Function Async_Lambda() As Task
Dim x As Integer = 1
Dim y As Integer = 2
Dim a As Func(Of Integer) = Function() x + y
Await Console.Out.WriteAsync((x + y).ToString)
x.ToString()
y.ToString()
End Function
End Class
</file>
......@@ -333,52 +330,40 @@ End Class
Dim compilation = CompilationUtils.CreateCompilationWithReferences(
source,
{MscorlibRef_v4_0_30316_17626, MsvbRef},
TestOptions.DebugDll)
TestOptions.ReleaseDll)
' Goal: We're looking for the single-mangled name "$VB$Closure_1".
compilation.VerifyPdb("C+VB$StateMachine_1_Async_Lambda_NotHoisted.MoveNext",
' Goal: We're looking for "$VB$ResumableLocal_$VB$Closure_$0" but not "$VB$ResumableLocal_a$1".
compilation.VerifyPdb("C+VB$StateMachine_1_Async_Lambda.MoveNext",
<symbols>
<methods>
<method containingType="C+VB$StateMachine_1_Async_Lambda_NotHoisted" name="MoveNext">
<customDebugInfo>
<encLocalSlotMap>
<slot kind="27" offset="-1"/>
<slot kind="temp"/>
<slot kind="temp"/>
<slot kind="temp"/>
<slot kind="temp"/>
<slot kind="temp"/>
</encLocalSlotMap>
</customDebugInfo>
<method containingType="C+VB$StateMachine_1_Async_Lambda" name="MoveNext">
<sequencePoints>
<entry offset="0x0" hidden="true" document="0"/>
<entry offset="0x7" hidden="true" document="0"/>
<entry offset="0x12" startLine="5" startColumn="5" endLine="5" endColumn="61" document="0"/>
<entry offset="0x13" hidden="true" document="0"/>
<entry offset="0x1e" startLine="6" startColumn="13" endLine="6" endColumn="29" document="0"/>
<entry offset="0x2a" startLine="7" startColumn="13" endLine="7" endColumn="29" document="0"/>
<entry offset="0x36" startLine="9" startColumn="13" endLine="9" endColumn="53" document="0"/>
<entry offset="0x4d" startLine="11" startColumn="9" endLine="11" endColumn="55" document="0"/>
<entry offset="0xda" startLine="12" startColumn="5" endLine="12" endColumn="17" document="0"/>
<entry offset="0xdc" hidden="true" document="0"/>
<entry offset="0xe4" hidden="true" document="0"/>
<entry offset="0x101" startLine="12" startColumn="5" endLine="12" endColumn="17" document="0"/>
<entry offset="0x10b" hidden="true" document="0"/>
<entry offset="0xa" hidden="true" document="0"/>
<entry offset="0x15" startLine="6" startColumn="13" endLine="6" endColumn="29" document="0"/>
<entry offset="0x21" startLine="7" startColumn="13" endLine="7" endColumn="29" document="0"/>
<entry offset="0x2d" startLine="11" startColumn="9" endLine="11" endColumn="55" document="0"/>
<entry offset="0xb3" startLine="12" startColumn="9" endLine="12" endColumn="21" document="0"/>
<entry offset="0xc4" startLine="13" startColumn="9" endLine="13" endColumn="21" document="0"/>
<entry offset="0xd5" startLine="14" startColumn="5" endLine="14" endColumn="17" document="0"/>
<entry offset="0xd7" hidden="true" document="0"/>
<entry offset="0xde" hidden="true" document="0"/>
<entry offset="0xf9" startLine="14" startColumn="5" endLine="14" endColumn="17" document="0"/>
<entry offset="0x103" hidden="true" document="0"/>
</sequencePoints>
<locals>
<local name="$VB$ResumableLocal_$VB$Closure_$0" il_index="0" il_start="0x12" il_end="0xdb" attributes="0"/>
<local name="$VB$ResumableLocal_a$1" il_index="1" il_start="0x12" il_end="0xdb" attributes="0"/>
<local name="$VB$ResumableLocal_$VB$Closure_$0" il_index="0" il_start="0xa" il_end="0xd6" attributes="0"/>
</locals>
<scope startOffset="0x0" endOffset="0x118">
<scope startOffset="0x0" endOffset="0x10f">
<importsforward declaringType="C+_Closure$__1-0" methodName="_Lambda$__0"/>
<scope startOffset="0x12" endOffset="0xdb">
<local name="$VB$ResumableLocal_$VB$Closure_$0" il_index="0" il_start="0x12" il_end="0xdb" attributes="0"/>
<local name="$VB$ResumableLocal_a$1" il_index="1" il_start="0x12" il_end="0xdb" attributes="0"/>
<scope startOffset="0xa" endOffset="0xd6">
<local name="$VB$ResumableLocal_$VB$Closure_$0" il_index="0" il_start="0xa" il_end="0xd6" attributes="0"/>
</scope>
</scope>
<asyncInfo>
<kickoffMethod declaringType="C" methodName="Async_Lambda_NotHoisted"/>
<await yield="0x91" resume="0xad" declaringType="C+VB$StateMachine_1_Async_Lambda_NotHoisted" methodName="MoveNext"/>
<kickoffMethod declaringType="C" methodName="Async_Lambda"/>
<await yield="0x6e" resume="0x88" declaringType="C+VB$StateMachine_1_Async_Lambda" methodName="MoveNext"/>
</asyncInfo>
</method>
</methods>
......@@ -386,7 +371,7 @@ End Class
End Sub
<Fact(), WorkItem(827337, "DevDiv"), WorkItem(836491, "DevDiv")>
Public Sub LocalHoistedAndNotCapture()
Public Sub LocalNotCapturedInBetweenSuspensionPoints_Debug()
Dim source =
<compilation>
<file>
......@@ -394,7 +379,7 @@ Imports System
Imports System.Threading.Tasks
Public Class C
Private Async Function Async_NoLambda_Hoisted() As Task
Private Async Function Async_NoLambda() As Task
Dim x As Integer = 1
Dim y As Integer = 2
......@@ -412,10 +397,10 @@ End Class
TestOptions.DebugDll)
' Goal: We're looking for the single-mangled names "$VB$ResumableLocal_x$1" and "$VB$ResumableLocal_y$2".
compilation.VerifyPdb("C+VB$StateMachine_1_Async_NoLambda_Hoisted.MoveNext",
compilation.VerifyPdb("C+VB$StateMachine_1_Async_NoLambda.MoveNext",
<symbols>
<methods>
<method containingType="C+VB$StateMachine_1_Async_NoLambda_Hoisted" name="MoveNext">
<method containingType="C+VB$StateMachine_1_Async_NoLambda" name="MoveNext">
<customDebugInfo>
<encLocalSlotMap>
<slot kind="27" offset="-1"/>
......@@ -429,7 +414,7 @@ End Class
<sequencePoints>
<entry offset="0x0" hidden="true" document="0"/>
<entry offset="0x7" hidden="true" document="0"/>
<entry offset="0xf" startLine="5" startColumn="5" endLine="5" endColumn="60" document="0"/>
<entry offset="0xf" startLine="5" startColumn="5" endLine="5" endColumn="52" document="0"/>
<entry offset="0x10" startLine="6" startColumn="13" endLine="6" endColumn="29" document="0"/>
<entry offset="0x17" startLine="7" startColumn="13" endLine="7" endColumn="29" document="0"/>
<entry offset="0x1e" startLine="9" startColumn="9" endLine="9" endColumn="55" document="0"/>
......@@ -455,17 +440,16 @@ End Class
</scope>
</scope>
<asyncInfo>
<kickoffMethod declaringType="C" methodName="Async_NoLambda_Hoisted"/>
<await yield="0x58" resume="0x77" declaringType="C+VB$StateMachine_1_Async_NoLambda_Hoisted" methodName="MoveNext"/>
<kickoffMethod declaringType="C" methodName="Async_NoLambda"/>
<await yield="0x58" resume="0x77" declaringType="C+VB$StateMachine_1_Async_NoLambda" methodName="MoveNext"/>
</asyncInfo>
</method>
</methods>
</symbols>)
End Sub
' Invalid method token '0x06000001' or version '1' (hresult = 0x80004005)
<Fact(), WorkItem(827337, "DevDiv"), WorkItem(836491, "DevDiv")>
Public Sub LocalNotHoistedAndNotCaptured()
<Fact()>
Public Sub LocalNotCapturedInBetweenSuspensionPoints_Release()
Dim source =
<compilation>
<file>
......@@ -473,11 +457,13 @@ Imports System
Imports System.Threading.Tasks
Public Class C
Private Async Function Async_NoLambda_NotHoisted() As Task
Private Async Function Async_NoLambda() As Task
Dim x As Integer = 1
Dim y As Integer = 2
Await Console.Out.WriteAsync((x + y).ToString)
x.ToString()
y.ToString()
End Function
End Class
</file>
......@@ -486,52 +472,43 @@ End Class
Dim compilation = CompilationUtils.CreateCompilationWithReferences(
source,
{MscorlibRef_v4_0_30316_17626, MsvbRef},
TestOptions.DebugDll)
TestOptions.ReleaseDll)
' Goal: We're looking for the unmangled names "x" and "y".
compilation.VerifyPdb(
' Goal: We're looking for the single-mangled names "$VB$ResumableLocal_x$1" and "$VB$ResumableLocal_y$2".
compilation.VerifyPdb("C+VB$StateMachine_1_Async_NoLambda.MoveNext",
<symbols>
<methods>
<method containingType="C+VB$StateMachine_1_Async_NoLambda_NotHoisted" name="MoveNext">
<customDebugInfo>
<encLocalSlotMap>
<slot kind="27" offset="-1"/>
<slot kind="temp"/>
<slot kind="temp"/>
<slot kind="temp"/>
<slot kind="temp"/>
<slot kind="temp"/>
</encLocalSlotMap>
</customDebugInfo>
<method containingType="C+VB$StateMachine_1_Async_NoLambda" name="MoveNext">
<sequencePoints>
<entry offset="0x0" hidden="true" document="0"/>
<entry offset="0x7" hidden="true" document="0"/>
<entry offset="0xf" startLine="5" startColumn="5" endLine="5" endColumn="63" document="0"/>
<entry offset="0x10" startLine="6" startColumn="13" endLine="6" endColumn="29" document="0"/>
<entry offset="0x17" startLine="7" startColumn="13" endLine="7" endColumn="29" document="0"/>
<entry offset="0x1e" startLine="9" startColumn="9" endLine="9" endColumn="55" document="0"/>
<entry offset="0xa1" startLine="10" startColumn="5" endLine="10" endColumn="17" document="0"/>
<entry offset="0xa3" hidden="true" document="0"/>
<entry offset="0xa" startLine="6" startColumn="13" endLine="6" endColumn="29" document="0"/>
<entry offset="0x11" startLine="7" startColumn="13" endLine="7" endColumn="29" document="0"/>
<entry offset="0x18" startLine="9" startColumn="9" endLine="9" endColumn="55" document="0"/>
<entry offset="0x91" startLine="10" startColumn="9" endLine="10" endColumn="21" document="0"/>
<entry offset="0x9d" startLine="11" startColumn="9" endLine="11" endColumn="21" document="0"/>
<entry offset="0xa9" startLine="12" startColumn="5" endLine="12" endColumn="17" document="0"/>
<entry offset="0xab" hidden="true" document="0"/>
<entry offset="0xc8" startLine="10" startColumn="5" endLine="10" endColumn="17" document="0"/>
<entry offset="0xd2" hidden="true" document="0"/>
<entry offset="0xb2" hidden="true" document="0"/>
<entry offset="0xcd" startLine="12" startColumn="5" endLine="12" endColumn="17" document="0"/>
<entry offset="0xd7" hidden="true" document="0"/>
</sequencePoints>
<locals>
<local name="$VB$ResumableLocal_x$0" il_index="0" il_start="0xf" il_end="0xa2" attributes="0"/>
<local name="$VB$ResumableLocal_y$1" il_index="1" il_start="0xf" il_end="0xa2" attributes="0"/>
<local name="$VB$ResumableLocal_x$0" il_index="0" il_start="0xa" il_end="0xaa" attributes="0"/>
<local name="$VB$ResumableLocal_y$1" il_index="1" il_start="0xa" il_end="0xaa" attributes="0"/>
</locals>
<scope startOffset="0x0" endOffset="0xdf">
<scope startOffset="0x0" endOffset="0xe3">
<namespace name="System" importlevel="file"/>
<namespace name="System.Threading.Tasks" importlevel="file"/>
<currentnamespace name=""/>
<scope startOffset="0xf" endOffset="0xa2">
<local name="$VB$ResumableLocal_x$0" il_index="0" il_start="0xf" il_end="0xa2" attributes="0"/>
<local name="$VB$ResumableLocal_y$1" il_index="1" il_start="0xf" il_end="0xa2" attributes="0"/>
<scope startOffset="0xa" endOffset="0xaa">
<local name="$VB$ResumableLocal_x$0" il_index="0" il_start="0xa" il_end="0xaa" attributes="0"/>
<local name="$VB$ResumableLocal_y$1" il_index="1" il_start="0xa" il_end="0xaa" attributes="0"/>
</scope>
</scope>
<asyncInfo>
<kickoffMethod declaringType="C" methodName="Async_NoLambda_NotHoisted"/>
<await yield="0x58" resume="0x74" declaringType="C+VB$StateMachine_1_Async_NoLambda_NotHoisted" methodName="MoveNext"/>
<kickoffMethod declaringType="C" methodName="Async_NoLambda"/>
<await yield="0x4f" resume="0x66" declaringType="C+VB$StateMachine_1_Async_NoLambda" methodName="MoveNext"/>
</asyncInfo>
</method>
</methods>
......
......@@ -77,8 +77,6 @@ End Class
</symbols>)
End Sub
<Fact()>
Public Sub LambdaMethod()
Dim source =
......@@ -164,7 +162,6 @@ End Module
</symbols>)
End Sub
' TODO: Invalid method token
<Fact>
<WorkItem(544000, "DevDiv")>
Public Sub TestLambdaNameStability()
......@@ -240,5 +237,193 @@ End Module
</symbols>)
End Sub
<Fact>
Public Sub PartiallydefinedClass_1()
Dim source =
<compilation>
<file name="a.vb">
Imports System
Partial Class C
Public m1 As Func(Of Integer) = Function() 1
Sub Main()
End Sub
End Class
</file>
<file name="b.vb">
Imports System
Partial Class C
Public m2 As Func(Of Integer) = Function() 2
End Class
</file>
</compilation>
Dim compilation = CompilationUtils.CreateCompilationWithMscorlibAndVBRuntime(
source,
TestOptions.DebugDll)
' Check two distinct lambda offets for m1 and m2
compilation.VerifyPdb(
<symbols>
<files>
<file id="1" name="a.vb" language="3a12d0b8-c26c-11d0-b442-00a0244a1dd2" languageVendor="994b45c4-e6e9-11d2-903f-00c04fa302a1" documentType="5a869d0b-6611-11d3-bd2a-0000f80849bd" checkSumAlgorithmId="ff1816ec-aa5e-4d10-87f7-6f4963833460" checkSum="E9, 8A, 62, CA, DC, E3, 2B, C4, 4B, 6, D5, 97, 3C, 77, 18, 2E, 6F, 67, EE, 15, "/>
<file id="2" name="b.vb" language="3a12d0b8-c26c-11d0-b442-00a0244a1dd2" languageVendor="994b45c4-e6e9-11d2-903f-00c04fa302a1" documentType="5a869d0b-6611-11d3-bd2a-0000f80849bd" checkSumAlgorithmId="ff1816ec-aa5e-4d10-87f7-6f4963833460" checkSum="A1, 36, 22, 63, B1, FC, DD, 52, E1, 86, 92, E9, 1A, 7D, 68, 5A, C5, 74, 27, 69, "/>
</files>
<methods>
<method containingType="C" name=".ctor">
<customDebugInfo>
<encLambdaMap>
<methodOrdinal>0</methodOrdinal>
<lambda offset="-26"/>
<lambda offset="-12"/>
</encLambdaMap>
</customDebugInfo>
<sequencePoints>
<entry offset="0x0" hidden="true" document="1"/>
<entry offset="0x6" startLine="3" startColumn="12" endLine="3" endColumn="49" document="1"/>
<entry offset="0x30" startLine="3" startColumn="12" endLine="3" endColumn="49" document="2"/>
</sequencePoints>
<locals/>
<scope startOffset="0x0" endOffset="0x5b">
<namespace name="System" importlevel="file"/>
<currentnamespace name=""/>
</scope>
</method>
<method containingType="C" name="Main">
<sequencePoints>
<entry offset="0x0" startLine="5" startColumn="5" endLine="5" endColumn="15" document="1"/>
<entry offset="0x1" startLine="6" startColumn="5" endLine="6" endColumn="12" document="1"/>
</sequencePoints>
<locals/>
<scope startOffset="0x0" endOffset="0x2">
<importsforward declaringType="C" methodName=".ctor"/>
</scope>
</method>
<method containingType="C+_Closure$__" name="_Lambda$__0-0">
<customDebugInfo>
<encLocalSlotMap>
<slot kind="21" offset="-1"/>
</encLocalSlotMap>
</customDebugInfo>
<sequencePoints>
<entry offset="0x0" startLine="3" startColumn="37" endLine="3" endColumn="47" document="1"/>
<entry offset="0x1" startLine="3" startColumn="48" endLine="3" endColumn="49" document="1"/>
</sequencePoints>
<locals/>
<scope startOffset="0x0" endOffset="0x7">
<importsforward declaringType="C" methodName=".ctor"/>
</scope>
</method>
<method containingType="C+_Closure$__" name="_Lambda$__0-1">
<customDebugInfo>
<encLocalSlotMap>
<slot kind="21" offset="-1"/>
</encLocalSlotMap>
</customDebugInfo>
<sequencePoints>
<entry offset="0x0" startLine="3" startColumn="37" endLine="3" endColumn="47" document="2"/>
<entry offset="0x1" startLine="3" startColumn="48" endLine="3" endColumn="49" document="2"/>
</sequencePoints>
<locals/>
<scope startOffset="0x0" endOffset="0x7">
<importsforward declaringType="C" methodName=".ctor"/>
</scope>
</method>
</methods>
</symbols>)
End Sub
<Fact>
Public Sub PartiallydefinedClass_2()
Dim source =
<compilation>
<file name="a.vb">
Imports System
Partial Class C
Public m1 As Func(Of Integer) = Function() 1
Sub Main()
End Sub
End Class
Partial Class C
Public m2 As Func(Of Integer) = Function() 2
End Class
</file>
</compilation>
Dim compilation = CompilationUtils.CreateCompilationWithMscorlibAndVBRuntime(
source,
TestOptions.DebugDll)
' Check two distinct lambda offets for m1 and m2
compilation.VerifyPdb(
<symbols>
<files>
<file id="1" name="a.vb" language="3a12d0b8-c26c-11d0-b442-00a0244a1dd2" languageVendor="994b45c4-e6e9-11d2-903f-00c04fa302a1" documentType="5a869d0b-6611-11d3-bd2a-0000f80849bd" checkSumAlgorithmId="ff1816ec-aa5e-4d10-87f7-6f4963833460" checkSum="CC, 4, 2E, 86, CE, 51, 76, 57, 53, 27, C4, A0, 42, 3C, DA, FC, 6A, 91, 4A, 39, "/>
</files>
<methods>
<method containingType="C" name=".ctor">
<customDebugInfo>
<encLambdaMap>
<methodOrdinal>0</methodOrdinal>
<lambda offset="-26"/>
<lambda offset="-12"/>
</encLambdaMap>
</customDebugInfo>
<sequencePoints>
<entry offset="0x0" hidden="true" document="1"/>
<entry offset="0x6" startLine="3" startColumn="12" endLine="3" endColumn="49" document="1"/>
<entry offset="0x30" startLine="10" startColumn="12" endLine="10" endColumn="49" document="1"/>
</sequencePoints>
<locals/>
<scope startOffset="0x0" endOffset="0x5b">
<namespace name="System" importlevel="file"/>
<currentnamespace name=""/>
</scope>
</method>
<method containingType="C" name="Main">
<sequencePoints>
<entry offset="0x0" startLine="5" startColumn="5" endLine="5" endColumn="15" document="1"/>
<entry offset="0x1" startLine="6" startColumn="5" endLine="6" endColumn="12" document="1"/>
</sequencePoints>
<locals/>
<scope startOffset="0x0" endOffset="0x2">
<importsforward declaringType="C" methodName=".ctor"/>
</scope>
</method>
<method containingType="C+_Closure$__" name="_Lambda$__0-0">
<customDebugInfo>
<encLocalSlotMap>
<slot kind="21" offset="-1"/>
</encLocalSlotMap>
</customDebugInfo>
<sequencePoints>
<entry offset="0x0" startLine="3" startColumn="37" endLine="3" endColumn="47" document="1"/>
<entry offset="0x1" startLine="3" startColumn="48" endLine="3" endColumn="49" document="1"/>
</sequencePoints>
<locals/>
<scope startOffset="0x0" endOffset="0x7">
<importsforward declaringType="C" methodName=".ctor"/>
</scope>
</method>
<method containingType="C+_Closure$__" name="_Lambda$__0-1">
<customDebugInfo>
<encLocalSlotMap>
<slot kind="21" offset="-1"/>
</encLocalSlotMap>
</customDebugInfo>
<sequencePoints>
<entry offset="0x0" startLine="10" startColumn="37" endLine="10" endColumn="47" document="1"/>
<entry offset="0x1" startLine="10" startColumn="48" endLine="10" endColumn="49" document="1"/>
</sequencePoints>
<locals/>
<scope startOffset="0x0" endOffset="0x7">
<importsforward declaringType="C" methodName=".ctor"/>
</scope>
</method>
</methods>
</symbols>)
End Sub
End Class
End Namespace
\ No newline at end of file
......@@ -2949,9 +2949,9 @@ End Module
<encLambdaMap>
<methodOrdinal>1</methodOrdinal>
<lambda offset="101"/>
<lambda offset="164"/>
<lambda offset="131"/>
<lambda offset="131"/>
<lambda offset="131"/>
<lambda offset="208"/>
<lambda offset="216"/>
<lambda offset="236"/>
<lambda offset="298"/>
......@@ -3808,8 +3808,8 @@ End Module
<encLambdaMap>
<methodOrdinal>1</methodOrdinal>
<lambda offset="101"/>
<lambda offset="86"/>
<lambda offset="86"/>
<lambda offset="160"/>
<lambda offset="177"/>
<lambda offset="86"/>
</encLambdaMap>
</customDebugInfo>
......@@ -3925,8 +3925,8 @@ End Module
</encLocalSlotMap>
<encLambdaMap>
<methodOrdinal>1</methodOrdinal>
<lambda offset="154"/>
<lambda offset="154"/>
<lambda offset="242"/>
<lambda offset="225"/>
<lambda offset="154"/>
<lambda offset="86"/>
<lambda offset="86"/>
......@@ -4056,9 +4056,9 @@ End Module
<encLambdaMap>
<methodOrdinal>1</methodOrdinal>
<lambda offset="107"/>
<lambda offset="86"/>
<lambda offset="86"/>
<lambda offset="86"/>
<lambda offset="166"/>
<lambda offset="183"/>
<lambda offset="236"/>
</encLambdaMap>
</customDebugInfo>
<sequencePoints>
......@@ -4177,13 +4177,13 @@ End Module
<methodOrdinal>1</methodOrdinal>
<lambda offset="107"/>
<lambda offset="188"/>
<lambda offset="167"/>
<lambda offset="167"/>
<lambda offset="167"/>
<lambda offset="275"/>
<lambda offset="258"/>
<lambda offset="332"/>
<lambda offset="336"/>
<lambda offset="86"/>
<lambda offset="86"/>
<lambda offset="86"/>
<lambda offset="388"/>
<lambda offset="405"/>
<lambda offset="458"/>
<lambda offset="462"/>
</encLambdaMap>
</customDebugInfo>
......@@ -4365,7 +4365,7 @@ End Module
<methodOrdinal>1</methodOrdinal>
<lambda offset="86"/>
<lambda offset="86"/>
<lambda offset="86"/>
<lambda offset="267"/>
<lambda offset="284"/>
</encLambdaMap>
</customDebugInfo>
......@@ -4977,8 +4977,8 @@ End Module
<methodOrdinal>1</methodOrdinal>
<lambda offset="87"/>
<lambda offset="87"/>
<lambda offset="120"/>
<lambda offset="120"/>
<lambda offset="129"/>
<lambda offset="157"/>
</encLambdaMap>
</customDebugInfo>
<sequencePoints>
......@@ -5085,8 +5085,8 @@ End Module
<methodOrdinal>1</methodOrdinal>
<lambda offset="87"/>
<lambda offset="87"/>
<lambda offset="120"/>
<lambda offset="120"/>
<lambda offset="129"/>
<lambda offset="173"/>
<lambda offset="177"/>
</encLambdaMap>
</customDebugInfo>
......@@ -5214,7 +5214,7 @@ End Module
<lambda offset="87"/>
<lambda offset="87"/>
<lambda offset="120"/>
<lambda offset="120"/>
<lambda offset="200"/>
<lambda offset="217"/>
</encLambdaMap>
</customDebugInfo>
......@@ -5970,8 +5970,8 @@ End Module
<methodOrdinal>1</methodOrdinal>
<lambda offset="99"/>
<lambda offset="119"/>
<lambda offset="137"/>
<lambda offset="137"/>
<lambda offset="165"/>
<lambda offset="182"/>
<lambda offset="137"/>
<lambda offset="99"/>
<lambda offset="220"/>
......@@ -6398,8 +6398,8 @@ End Module
<lambda offset="99"/>
<lambda offset="121"/>
<lambda offset="141"/>
<lambda offset="159"/>
<lambda offset="159"/>
<lambda offset="187"/>
<lambda offset="204"/>
<lambda offset="159"/>
<lambda offset="121"/>
<lambda offset="242"/>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册