diff --git a/build/Targets/Packages.props b/build/Targets/Packages.props index f357a2f8a05ad..078b18b4a32dd 100644 --- a/build/Targets/Packages.props +++ b/build/Targets/Packages.props @@ -34,10 +34,10 @@ 4.3.0 0.8.31-beta 1.0.35 - 1.1.0 - 1.0.0-beta1-61708-01 - 1.6.0-beta2-25304 - 1.3.0 + 1.2.0-beta1-62008-01 + 1.1.0-beta1-62008-01 + 1.7.0-private-25604 + 1.3.0-beta1-62008-01 4.7.2-alpha-00001 1.0.27-prerelease-01811-02 3.13.8 @@ -194,6 +194,7 @@ 4.3.0 4.3.0 4.3.0 + 4.3.0 4.3.0 4.3.0 4.3.0 diff --git a/src/Compilers/CSharp/Portable/CSharpResources.Designer.cs b/src/Compilers/CSharp/Portable/CSharpResources.Designer.cs index 3da604946ed62..5e52a17ebc936 100644 --- a/src/Compilers/CSharp/Portable/CSharpResources.Designer.cs +++ b/src/Compilers/CSharp/Portable/CSharpResources.Designer.cs @@ -2375,7 +2375,7 @@ internal class CSharpResources { } /// - /// Looks up a localized string similar to /embed switch is only supported when emitting Portable PDB (/debug:portable or /debug:embedded).. + /// Looks up a localized string similar to /embed switch is only supported when emitting a PDB.. /// internal static string ERR_CannotEmbedWithoutPdb { get { diff --git a/src/Compilers/CSharp/Portable/CSharpResources.resx b/src/Compilers/CSharp/Portable/CSharpResources.resx index a371834092cbf..96ca274ec8e9f 100644 --- a/src/Compilers/CSharp/Portable/CSharpResources.resx +++ b/src/Compilers/CSharp/Portable/CSharpResources.resx @@ -4986,7 +4986,7 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ /sourcelink switch is only supported when emitting PDB. - /embed switch is only supported when emitting Portable PDB (/debug:portable or /debug:embedded). + /embed switch is only supported when emitting a PDB. Invalid instrumentation kind: {0} diff --git a/src/Compilers/CSharp/Portable/CommandLine/CSharpCommandLineParser.cs b/src/Compilers/CSharp/Portable/CommandLine/CSharpCommandLineParser.cs index 256dd9ebf02c4..134d914809622 100644 --- a/src/Compilers/CSharp/Portable/CommandLine/CSharpCommandLineParser.cs +++ b/src/Compilers/CSharp/Portable/CommandLine/CSharpCommandLineParser.cs @@ -1243,14 +1243,9 @@ public new CSharpCommandLineArguments Parse(IEnumerable args, string bas embeddedFiles.AddRange(sourceFiles); } - if (embeddedFiles.Count > 0) + if (embeddedFiles.Count > 0 && !emitPdb) { - // Restricted to portable PDBs for now, but the IsPortable condition should be removed - // and the error message adjusted accordingly when native PDB support is added. - if (!emitPdb || !debugInformationFormat.IsPortable()) - { - AddDiagnostic(diagnostics, ErrorCode.ERR_CannotEmbedWithoutPdb); - } + AddDiagnostic(diagnostics, ErrorCode.ERR_CannotEmbedWithoutPdb); } var parsedFeatures = ParseFeatures(features); diff --git a/src/Compilers/CSharp/Portable/Compiler/TypeCompilationState.cs b/src/Compilers/CSharp/Portable/Compiler/TypeCompilationState.cs index 2898d62ca6289..785b20d1f24d7 100644 --- a/src/Compilers/CSharp/Portable/Compiler/TypeCompilationState.cs +++ b/src/Compilers/CSharp/Portable/Compiler/TypeCompilationState.cs @@ -66,7 +66,7 @@ internal MethodWithBody(MethodSymbol method, BoundStatement body, ImportChain im public readonly CSharpCompilation Compilation; - public ClosureEnvironment StaticLambdaFrame; + public SynthesizedClosureEnvironment StaticLambdaFrame; /// /// A graph of method->method references for this(...) constructor initializers. diff --git a/src/Compilers/CSharp/Portable/Lowering/LambdaRewriter/LambdaCapturedVariable.cs b/src/Compilers/CSharp/Portable/Lowering/LambdaRewriter/LambdaCapturedVariable.cs index a67f98a89bffe..6ac017446b934 100644 --- a/src/Compilers/CSharp/Portable/Lowering/LambdaRewriter/LambdaCapturedVariable.cs +++ b/src/Compilers/CSharp/Portable/Lowering/LambdaRewriter/LambdaCapturedVariable.cs @@ -31,7 +31,7 @@ private LambdaCapturedVariable(SynthesizedContainer frame, TypeSymbol type, stri _isThis = isThisParameter; } - public static LambdaCapturedVariable Create(ClosureEnvironment frame, Symbol captured, ref int uniqueId) + public static LambdaCapturedVariable Create(SynthesizedClosureEnvironment frame, Symbol captured, ref int uniqueId) { Debug.Assert(captured is LocalSymbol || captured is ParameterSymbol); @@ -87,7 +87,7 @@ private static TypeSymbol GetCapturedVariableFieldType(SynthesizedContainer fram if ((object)local != null) { // if we're capturing a generic frame pointer, construct it with the new frame's type parameters - var lambdaFrame = local.Type.OriginalDefinition as ClosureEnvironment; + var lambdaFrame = local.Type.OriginalDefinition as SynthesizedClosureEnvironment; if ((object)lambdaFrame != null) { // lambdaFrame may have less generic type parameters than frame, so trim them down (the first N will always match) diff --git a/src/Compilers/CSharp/Portable/Lowering/LambdaRewriter/LambdaRewriter.Analysis.Tree.cs b/src/Compilers/CSharp/Portable/Lowering/LambdaRewriter/LambdaRewriter.Analysis.Tree.cs index f776ab258519f..3995278c7913a 100644 --- a/src/Compilers/CSharp/Portable/Lowering/LambdaRewriter/LambdaRewriter.Analysis.Tree.cs +++ b/src/Compilers/CSharp/Portable/Lowering/LambdaRewriter/LambdaRewriter.Analysis.Tree.cs @@ -119,6 +119,23 @@ public sealed class Closure public ClosureEnvironment ContainingEnvironmentOpt; + private bool _capturesThis; + + /// + /// True if this closure directly or transitively captures 'this' (captures + /// a local function which directly or indirectly captures 'this'). + /// Calculated in . + /// + public bool CapturesThis + { + get => _capturesThis; + set + { + Debug.Assert(value); + _capturesThis = value; + } + } + public Closure(MethodSymbol symbol) { Debug.Assert(symbol != null); @@ -132,81 +149,29 @@ public void Free() } } - /// - /// Optimizes local functions such that if a local function only references other local functions - /// that capture no variables, we don't need to create capture environments for any of them. - /// - private void RemoveUnneededReferences(ParameterSymbol thisParam) + public sealed class ClosureEnvironment { - var methodGraph = new MultiDictionary(); - var capturesThis = new HashSet(); - var capturesVariable = new HashSet(); - var visitStack = new Stack(); - VisitClosures(ScopeTree, (scope, closure) => - { - foreach (var capture in closure.CapturedVariables) - { - if (capture is MethodSymbol localFunc) - { - methodGraph.Add(localFunc, closure.OriginalMethodSymbol); - } - else if (capture == thisParam) - { - if (capturesThis.Add(closure.OriginalMethodSymbol)) - { - visitStack.Push(closure.OriginalMethodSymbol); - } - } - else if (capturesVariable.Add(closure.OriginalMethodSymbol) && - !capturesThis.Contains(closure.OriginalMethodSymbol)) - { - visitStack.Push(closure.OriginalMethodSymbol); - } - } - }); - - while (visitStack.Count > 0) - { - var current = visitStack.Pop(); - var setToAddTo = capturesVariable.Contains(current) ? capturesVariable : capturesThis; - foreach (var capturesCurrent in methodGraph[current]) - { - if (setToAddTo.Add(capturesCurrent)) - { - visitStack.Push(capturesCurrent); - } - } - } + public readonly SetWithInsertionOrder CapturedVariables; + + /// + /// Represents a that had its environment + /// pointer (a local pointing to the environment) captured like a captured + /// variable. Assigned in + /// + /// + public bool CapturesParent; - // True if there are any closures in the tree which - // capture 'this' and another variable - bool captureMoreThanThis = false; + public readonly bool IsStruct; + internal SynthesizedClosureEnvironment SynthesizedEnvironment; - VisitClosures(ScopeTree, (scope, closure) => + public ClosureEnvironment(IEnumerable capturedVariables, bool isStruct) { - if (!capturesVariable.Contains(closure.OriginalMethodSymbol)) - { - closure.CapturedVariables.Clear(); - } - - if (capturesThis.Contains(closure.OriginalMethodSymbol)) + CapturedVariables = new SetWithInsertionOrder(); + foreach (var item in capturedVariables) { - closure.CapturedVariables.Add(thisParam); - if (closure.CapturedVariables.Count > 1) - { - captureMoreThanThis |= true; - } + CapturedVariables.Add(item); } - }); - - if (!captureMoreThanThis && capturesThis.Count > 0) - { - // If we have closures which capture 'this', and nothing else, we can - // remove 'this' from the declared variables list, since we don't need - // to create an environment to hold 'this' (since we can emit the - // lowered methods directly onto the containing class) - bool removed = ScopeTree.DeclaredVariables.Remove(thisParam); - Debug.Assert(removed); + IsStruct = isStruct; } } @@ -226,6 +191,31 @@ public static void VisitClosures(Scope scope, Action action) } } + /// + /// Visit all the closures and return true when the returns + /// true. Otherwise, returns false. + /// + public static bool CheckClosures(Scope scope, Func func) + { + foreach (var closure in scope.Closures) + { + if (func(scope, closure)) + { + return true; + } + } + + foreach (var nested in scope.NestedScopes) + { + if (CheckClosures(nested, func)) + { + return true; + } + } + + return false; + } + /// /// Visit the tree with the given root and run the /// @@ -491,6 +481,13 @@ private void AddIfCaptured(Symbol symbol, SyntaxNode syntax) return; } + if (symbol is MethodSymbol method && + _currentClosure.OriginalMethodSymbol == method) + { + // Is this recursion? If so there's no capturing + return; + } + if (symbol.ContainingSymbol != _currentClosure.OriginalMethodSymbol) { // Restricted types can't be hoisted, so they are not permitted to be captured diff --git a/src/Compilers/CSharp/Portable/Lowering/LambdaRewriter/LambdaRewriter.Analysis.cs b/src/Compilers/CSharp/Portable/Lowering/LambdaRewriter/LambdaRewriter.Analysis.cs index 4c77933cd3c64..98a3179932f70 100644 --- a/src/Compilers/CSharp/Portable/Lowering/LambdaRewriter/LambdaRewriter.Analysis.cs +++ b/src/Compilers/CSharp/Portable/Lowering/LambdaRewriter/LambdaRewriter.Analysis.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Collections.Generic; +using System.Collections.Immutable; using System.Diagnostics; using System.Linq; using Microsoft.CodeAnalysis.CodeGen; @@ -32,15 +33,6 @@ internal sealed partial class Analysis // We can't rewrite delegate signatures || MethodsConvertedToDelegates.Contains(closure)); - /// - /// Blocks that are positioned between a block declaring some lifted variables - /// and a block that contains the lambda that lifts said variables. - /// If such block itself requires a closure, then it must lift parent frame pointer into the closure - /// in addition to whatever else needs to be lifted. - /// needs to be called to compute this. - /// - public readonly PooledHashSet NeedsParentFrame = PooledHashSet.GetInstance(); - /// /// The root of the scope tree for this method. /// @@ -97,9 +89,9 @@ internal sealed partial class Analysis slotAllocatorOpt, compilationState); - analysis.RemoveUnneededReferences(method.ThisParameter); - analysis.MakeAndAssignEnvironments(closureDebugInfo); + analysis.MakeAndAssignEnvironments(); analysis.ComputeLambdaScopesAndFrameCaptures(method.ThisParameter); + analysis.InlineThisOnlyEnvironments(); return analysis; } @@ -146,167 +138,233 @@ private void ComputeLambdaScopesAndFrameCaptures(ParameterSymbol thisParam) { VisitClosures(ScopeTree, (scope, closure) => { - if (closure.CapturedVariables.Count > 0) + if (closure.CapturedEnvironments.Count > 0) { - (Scope innermost, Scope outermost) = FindLambdaScopeRange(closure, scope); - RecordClosureScope(innermost, outermost, closure); + var capturedEnvs = PooledHashSet.GetInstance(); + capturedEnvs.AddAll(closure.CapturedEnvironments); + + // Find the nearest captured class environment, if one exists + var curScope = scope; + while (curScope != null) + { + if (capturedEnvs.RemoveAll(curScope.DeclaredEnvironments)) + { + // Right now we only create one environment per scope + Debug.Assert(curScope.DeclaredEnvironments.Count == 1); + var env = curScope.DeclaredEnvironments[0]; + if (!env.IsStruct) + { + closure.ContainingEnvironmentOpt = env; + break; + } + } + curScope = curScope.Parent; + } + + // Now we need to walk up the scopes to find environment captures + var oldEnv = curScope?.DeclaredEnvironments[0]; + while (curScope != null) + { + if (capturedEnvs.Count == 0) + { + break; + } + + var envs = curScope.DeclaredEnvironments.Where(e => !e.IsStruct); + if (!envs.IsEmpty()) + { + // Right now we only create one environment per scope + Debug.Assert(envs.IsSingle()); + var env = envs.First(); + Debug.Assert(!oldEnv.IsStruct); + oldEnv.CapturesParent = true; + oldEnv = env; + } + capturedEnvs.RemoveAll(curScope.DeclaredEnvironments); + curScope = curScope.Parent; + } + + if (capturedEnvs.Count > 0) + { + throw ExceptionUtilities.Unreachable; + } + + capturedEnvs.Free(); + } }); + } - (Scope innermost, Scope outermost) FindLambdaScopeRange(Closure closure, Scope closureScope) + /// + /// We may have ended up with a closure environment containing only + /// 'this'. This is basically equivalent to the containing type itself, + /// so we can inline the 'this' parameter into environments that + /// reference this one or lower closures directly onto the containing + /// type. + /// + private void InlineThisOnlyEnvironments() + { + // First make sure 'this' even exists + if (!_topLevelMethod.TryGetThisParameter(out var thisParam) || + thisParam == null) { - // If the closure only captures this, put the method directly in the - // top-level method's containing type - if (closure.CapturedVariables.Count == 1 && - closure.CapturedVariables.Single() is ParameterSymbol param && - param.IsThis) - { - return (null, null); - } + return; + } - Scope innermost = null; - Scope outermost = null; + var topLevelEnvs = ScopeTree.DeclaredEnvironments; - var capturedVars = PooledHashSet.GetInstance(); - capturedVars.AddAll(closure.CapturedVariables); + // If it does exist, 'this' is always in the top-level environment + if (topLevelEnvs.Count == 0) + { + return; + } + + Debug.Assert(topLevelEnvs.Count == 1); + var env = topLevelEnvs[0]; - // If any of the captured variables are local functions we'll need - // to add the captured variables of that local function to the current - // set. This has the effect of ensuring that if the local function - // captures anything "above" the current scope then parent frame - // is itself captured (so that the current lambda can call that - // local function). - foreach (var captured in closure.CapturedVariables) + // The environment must contain only 'this' to be inlined + if (env.CapturedVariables.Count > 1 || + !env.CapturedVariables.Contains(thisParam)) + { + return; + } + + if (env.IsStruct) + { + // If everything that captures the 'this' environment + // lives in the containing type, we can remove the env + bool cantRemove = CheckClosures(ScopeTree, (scope, closure) => + { + return closure.CapturedEnvironments.Contains(env) && + closure.ContainingEnvironmentOpt != null; + }); + + if (!cantRemove) + { + RemoveEnv(); + } + } + else + { + // Class-based 'this' closures can move member functions + // to the top-level type and environments which capture + // the 'this' environment can capture 'this' directly + RemoveEnv(); + VisitClosures(ScopeTree, (scope, closure) => { - if (captured is LocalFunctionSymbol localFunc) + if (closure.ContainingEnvironmentOpt == env) { - var (found, _) = GetVisibleClosure(closureScope, localFunc); - capturedVars.AddAll(found.CapturedVariables); + closure.ContainingEnvironmentOpt = null; } - } - - for (var curScope = closureScope; - curScope != null && capturedVars.Count > 0; - curScope = curScope.Parent) + }); + + // Find all environments in the scope below that could + // capture the parent. If there are any, add 'this' to + // the list of captured variables and remove the parent + // link + VisitFirstLevelScopes(ScopeTree); + void VisitFirstLevelScopes(Scope scope) { - if (!(capturedVars.RemoveAll(curScope.DeclaredVariables) || - capturedVars.RemoveAll(curScope.Closures.Select(c => c.OriginalMethodSymbol)))) + var classEnvs = scope.DeclaredEnvironments.Where(e => !e.IsStruct); + if (classEnvs.IsEmpty()) { - continue; + // Keep looking for nested environments + foreach (var nested in scope.NestedScopes) + { + VisitFirstLevelScopes(nested); + } } - - outermost = curScope; - if (innermost == null) + else { - innermost = curScope; + foreach (var declEnv in classEnvs) + { + if (declEnv.CapturesParent) + { + declEnv.CapturedVariables.Insert(0, thisParam); + declEnv.CapturesParent = false; + } + } } } - - // If any captured variables are left, they're captured above method scope - if (capturedVars.Count > 0) - { - outermost = null; - } - - capturedVars.Free(); - - return (innermost, outermost); } - void RecordClosureScope(Scope innermost, Scope outermost, Closure closure) + void RemoveEnv() { - // 1) if there is innermost scope, lambda goes there as we cannot go any higher. - // 2) scopes in [innermostScope, outermostScope) chain need to have access to the parent scope. - // - // Example: - // if a lambda captures a method's parameter and `this`, - // its innermost scope is the root Scope (method locals and parameters) - // and outermost Scope is null - // Such lambda will be placed in a closure frame that corresponds to the method's outer block - // and this frame will also lift original `this` as a field when created by its parent. - // Note that it is completely irrelevant how deeply the lexical scope of the lambda was originally nested. - if (innermost != null) + topLevelEnvs.RemoveAt(topLevelEnvs.IndexOf(env)); + VisitClosures(ScopeTree, (scope, closure) => { - closure.ContainingEnvironmentOpt = innermost.DeclaredEnvironments[0]; - - while (innermost != outermost) + var index = closure.CapturedEnvironments.IndexOf(env); + if (index >= 0) { - NeedsParentFrame.Add(innermost.BoundNode); - innermost = innermost.Parent; + closure.CapturedEnvironments.RemoveAt(index); } - } + }); } } - private void MakeAndAssignEnvironments(ArrayBuilder closureDebugInfo) + private void MakeAndAssignEnvironments() { VisitScopeTree(ScopeTree, scope => { - if (scope.DeclaredVariables.Count > 0) + // Currently all variables declared in the same scope are added + // to the same closure environment + var variablesInEnvironment = scope.DeclaredVariables; + + // Don't create empty environments + if (variablesInEnvironment.Count == 0) + { + return; + } + + // First walk the nested scopes to find all closures which + // capture variables from this scope. They all need to capture + // this environment. This includes closures which captured local + // functions that capture those variables, so multiple passes may + // be needed. This will also decide if the environment is a struct + // or a class. + bool isStruct = true; + var closures = new SetWithInsertionOrder(); + bool addedItem; + + // This loop is O(n), where n is the length of the chain + // L_1 <- L_2 <- L_3 ... + // where L_1 represents a local function that directly captures the current + // environment, L_2 represents a local function that directly captures L_1, + // L_3 represents a local function that captures L_2, and so on. + // + // Each iteration of the loop runs a visitor that is proportional to the + // number of closures in nested scopes, so we hope that the total number + // of nested functions and function chains is small in any real-world code. + do { - // First walk the nested scopes to find all closures which - // capture variables from this scope. They all need to capture - // this environment. This includes closures which captured local - // functions that capture those variables, so multiple passes may - // be needed. This will also decide if the environment is a struct - // or a class. - bool isStruct = true; - var closures = new SetWithInsertionOrder(); - bool addedItem; - do + addedItem = false; + VisitClosures(scope, (closureScope, closure) => { - addedItem = false; - VisitClosures(scope, (closureScope, closure) => + if (!closures.Contains(closure) && + (closure.CapturedVariables.Overlaps(scope.DeclaredVariables) || + closure.CapturedVariables.Overlaps(closures.Select(c => c.OriginalMethodSymbol)))) { - if (!closures.Contains(closure) && - (closure.CapturedVariables.Overlaps(scope.DeclaredVariables) || - closure.CapturedVariables.Overlaps(closures.Select(c => c.OriginalMethodSymbol)))) - { - closures.Add(closure); - addedItem = true; - isStruct &= CanTakeRefParameters(closure.OriginalMethodSymbol); - } - }); - } while (addedItem == true); + closures.Add(closure); + addedItem = true; + isStruct &= CanTakeRefParameters(closure.OriginalMethodSymbol); + } + }); + } while (addedItem == true); - // Next create the environment and add it to the declaration scope - // Currently all variables declared in the same scope are added - // to the same closure environment - var env = MakeEnvironment(scope, scope.DeclaredVariables, isStruct); - scope.DeclaredEnvironments.Add(env); + // Next create the environment and add it to the declaration scope + var env = new ClosureEnvironment(variablesInEnvironment, isStruct); + scope.DeclaredEnvironments.Add(env); - foreach (var closure in closures) + _topLevelMethod.TryGetThisParameter(out var thisParam); + foreach (var closure in closures) + { + closure.CapturedEnvironments.Add(env); + if (thisParam != null && env.CapturedVariables.Contains(thisParam)) { - closure.CapturedEnvironments.Add(env); + closure.CapturesThis = true; } } }); - - ClosureEnvironment MakeEnvironment(Scope scope, IEnumerable capturedVariables, bool isStruct) - { - var scopeBoundNode = scope.BoundNode; - - var syntax = scopeBoundNode.Syntax; - Debug.Assert(syntax != null); - - DebugId methodId = GetTopLevelMethodId(); - DebugId closureId = GetClosureId(syntax, closureDebugInfo); - - var containingMethod = scope.ContainingClosureOpt?.OriginalMethodSymbol ?? _topLevelMethod; - if ((object)_substitutedSourceMethod != null && containingMethod == _topLevelMethod) - { - containingMethod = _substitutedSourceMethod; - } - - return new ClosureEnvironment( - capturedVariables, - _topLevelMethod, - containingMethod, - isStruct, - syntax, - methodId, - closureId); - } } internal DebugId GetTopLevelMethodId() @@ -314,7 +372,7 @@ internal DebugId GetTopLevelMethodId() return _slotAllocatorOpt?.MethodId ?? new DebugId(_topLevelMethodOrdinal, _compilationState.ModuleBuilderOpt.CurrentGenerationOrdinal); } - private DebugId GetClosureId(SyntaxNode syntax, ArrayBuilder closureDebugInfo) + internal DebugId GetClosureId(SyntaxNode syntax, ArrayBuilder closureDebugInfo) { Debug.Assert(syntax != null); @@ -470,7 +528,6 @@ Closure Helper(Scope scope) public void Free() { MethodsConvertedToDelegates.Free(); - NeedsParentFrame.Free(); ScopeTree.Free(); } } diff --git a/src/Compilers/CSharp/Portable/Lowering/LambdaRewriter/LambdaRewriter.LocalFunctionReferenceRewriter.cs b/src/Compilers/CSharp/Portable/Lowering/LambdaRewriter/LambdaRewriter.LocalFunctionReferenceRewriter.cs index ffc7842e98836..95bb6cd7400f1 100644 --- a/src/Compilers/CSharp/Portable/Lowering/LambdaRewriter/LambdaRewriter.LocalFunctionReferenceRewriter.cs +++ b/src/Compilers/CSharp/Portable/Lowering/LambdaRewriter/LambdaRewriter.LocalFunctionReferenceRewriter.cs @@ -140,7 +140,7 @@ public BoundStatement RewriteLocalFunctionReferences(BoundStatement loweredBody) _framePointers.TryGetValue(synthesizedLambda.ContainingType, out _innermostFramePointer); } - var containerAsFrame = synthesizedLambda.ContainingType as ClosureEnvironment; + var containerAsFrame = synthesizedLambda.ContainingType as SynthesizedClosureEnvironment; // Includes type parameters from the containing type iff // the containing type is a frame. If it is a frame then @@ -201,11 +201,11 @@ public BoundStatement RewriteLocalFunctionReferences(BoundStatement loweredBody) // will always be a LambdaFrame, it's always a capture frame var frameType = (NamedTypeSymbol)loweredSymbol.Parameters[i].Type.OriginalDefinition; - Debug.Assert(frameType is ClosureEnvironment); + Debug.Assert(frameType is SynthesizedClosureEnvironment); if (frameType.Arity > 0) { - var typeParameters = ((ClosureEnvironment)frameType).ConstructedFromTypeParameters; + var typeParameters = ((SynthesizedClosureEnvironment)frameType).ConstructedFromTypeParameters; Debug.Assert(typeParameters.Length == frameType.Arity); var subst = this.TypeMap.SubstituteTypeParameters(typeParameters); frameType = frameType.Construct(subst); diff --git a/src/Compilers/CSharp/Portable/Lowering/LambdaRewriter/LambdaRewriter.cs b/src/Compilers/CSharp/Portable/Lowering/LambdaRewriter/LambdaRewriter.cs index 0b00ee2c34454..1e4c9b4c98d11 100644 --- a/src/Compilers/CSharp/Portable/Lowering/LambdaRewriter/LambdaRewriter.cs +++ b/src/Compilers/CSharp/Portable/Lowering/LambdaRewriter/LambdaRewriter.cs @@ -30,7 +30,7 @@ namespace Microsoft.CodeAnalysis.CSharp /// have captured variables. The result of this analysis is left in . /// /// Then we make a frame, or compiler-generated class, represented by an instance of - /// for each scope with captured variables. The generated frames are kept + /// for each scope with captured variables. The generated frames are kept /// in . Each frame is given a single field for each captured /// variable in the corresponding scope. These are maintained in . /// @@ -73,7 +73,7 @@ internal sealed partial class LambdaRewriter : MethodToClassRewriter // lambda frame for static lambdas. // initialized lazily and could be null if there are no static lambdas - private ClosureEnvironment _lazyStaticLambdaFrame; + private SynthesizedClosureEnvironment _lazyStaticLambdaFrame; // A mapping from every lambda parameter to its corresponding method's parameter. private readonly Dictionary _parameterMap = new Dictionary(); @@ -93,7 +93,7 @@ public MappedLocalFunction(SynthesizedLambdaMethod symbol, ClosureKind closureKi private readonly Dictionary _localFunctionMap = new Dictionary(); // for each block with lifted (captured) variables, the corresponding frame type - private readonly Dictionary _frames = new Dictionary(); + private readonly Dictionary _frames = new Dictionary(); // the current set of frame pointers in scope. Each is either a local variable (where introduced), // or the "this" parameter when at the top level. Keys in this map are never constructed types. @@ -268,7 +268,7 @@ protected override bool NeedsProxy(Symbol localOrParameter) diagnostics, assignLocals); - rewriter.SynthesizeClosureEnvironments(); + rewriter.SynthesizeClosureEnvironments(closureDebugInfoBuilder); // First, lower everything but references (calls, delegate conversions) // to local functions @@ -341,10 +341,10 @@ protected override NamedTypeSymbol ContainingType static partial void CheckLocalsDefined(BoundNode node); /// - /// Adds synthesized types to the compilation state + /// Adds synthesized types to the compilation state /// and creates hoisted fields for all locals captured by the environments. /// - private void SynthesizeClosureEnvironments() + private void SynthesizeClosureEnvironments(ArrayBuilder closureDebugInfo) { Analysis.VisitScopeTree(_analysis.ScopeTree, scope => { @@ -356,32 +356,59 @@ private void SynthesizeClosureEnvironments() Debug.Assert(scope.DeclaredEnvironments.Count == 1); var env = scope.DeclaredEnvironments[0]; + var frame = MakeFrame(scope, env.IsStruct); + env.SynthesizedEnvironment = frame; - CompilationState.ModuleBuilderOpt.AddSynthesizedDefinition(ContainingType, env); - if (env.Constructor != null) + CompilationState.ModuleBuilderOpt.AddSynthesizedDefinition(ContainingType, frame); + if (frame.Constructor != null) { AddSynthesizedMethod( - env.Constructor, + frame.Constructor, FlowAnalysisPass.AppendImplicitReturn( - MethodCompiler.BindMethodBody(env.Constructor, CompilationState, null), - env.Constructor)); + MethodCompiler.BindMethodBody(frame.Constructor, CompilationState, null), + frame.Constructor)); } foreach (var captured in env.CapturedVariables) { Debug.Assert(!proxies.ContainsKey(captured)); - var hoistedField = LambdaCapturedVariable.Create(env, captured, ref _synthesizedFieldNameIdDispenser); + var hoistedField = LambdaCapturedVariable.Create(frame, captured, ref _synthesizedFieldNameIdDispenser); proxies.Add(captured, new CapturedToFrameSymbolReplacement(hoistedField, isReusable: false)); - CompilationState.ModuleBuilderOpt.AddSynthesizedDefinition(env, hoistedField); + CompilationState.ModuleBuilderOpt.AddSynthesizedDefinition(frame, hoistedField); } _frames.Add(scope.BoundNode, env); } }); + + SynthesizedClosureEnvironment MakeFrame(Analysis.Scope scope, bool isStruct) + { + var scopeBoundNode = scope.BoundNode; + + var syntax = scopeBoundNode.Syntax; + Debug.Assert(syntax != null); + + DebugId methodId = _analysis.GetTopLevelMethodId(); + DebugId closureId = _analysis.GetClosureId(syntax, closureDebugInfo); + + var containingMethod = scope.ContainingClosureOpt?.OriginalMethodSymbol ?? _topLevelMethod; + if ((object)_substitutedSourceMethod != null && containingMethod == _topLevelMethod) + { + containingMethod = _substitutedSourceMethod; + } + + return new SynthesizedClosureEnvironment( + _topLevelMethod, + containingMethod, + isStruct, + syntax, + methodId, + closureId); } + } - private ClosureEnvironment GetStaticFrame(DiagnosticBag diagnostics, IBoundLambdaOrFunction lambda) + private SynthesizedClosureEnvironment GetStaticFrame(DiagnosticBag diagnostics, IBoundLambdaOrFunction lambda) { if (_lazyStaticLambdaFrame == null) { @@ -406,8 +433,7 @@ private ClosureEnvironment GetStaticFrame(DiagnosticBag diagnostics, IBoundLambd DebugId closureId = default(DebugId); // using _topLevelMethod as containing member because the static frame does not have generic parameters, except for the top level method's var containingMethod = isNonGeneric ? null : (_substitutedSourceMethod ?? _topLevelMethod); - _lazyStaticLambdaFrame = new ClosureEnvironment( - SpecializedCollections.EmptyEnumerable(), + _lazyStaticLambdaFrame = new SynthesizedClosureEnvironment( _topLevelMethod, containingMethod, isStruct: false, @@ -530,11 +556,12 @@ private static void InsertAndFreePrologue(ArrayBuilder result, A /// Introduce a frame around the translation of the given node. /// /// The node whose translation should be translated to contain a frame - /// The frame for the translated node + /// The environment for the translated node /// A function that computes the translation of the node. It receives lists of added statements and added symbols /// The translated statement, as returned from F - private BoundNode IntroduceFrame(BoundNode node, ClosureEnvironment frame, Func, ArrayBuilder, BoundNode> F) + private BoundNode IntroduceFrame(BoundNode node, Analysis.ClosureEnvironment env, Func, ArrayBuilder, BoundNode> F) { + var frame = env.SynthesizedEnvironment; var frameTypeParameters = ImmutableArray.Create(StaticCast.From(_currentTypeParameters).SelectAsArray(TypeMap.TypeSymbolAsTypeWithModifiers), 0, frame.Arity); NamedTypeSymbol frameType = frame.ConstructIfGeneric(frameTypeParameters); @@ -562,14 +589,7 @@ private BoundNode IntroduceFrame(BoundNode node, ClosureEnvironment frame, Func< if ((object)_innermostFramePointer != null) { proxies.TryGetValue(_innermostFramePointer, out oldInnermostFrameProxy); - if (_analysis.NeedsParentFrame.Contains(node) && - // If the frame pointer is a struct type that means the frame is a struct - // passed by-ref to a local function. Capturing parent frames for local - // functions is performed in RemapLambdaOrLocalFunction, rather than here - // (since struct frame pointers should never be captured, but instead be - // passed in a list to the needed local functions). - !(_innermostFramePointer.Kind == SymbolKind.Local && - ((LocalSymbol)_innermostFramePointer).Type.IsValueType)) + if (env.CapturesParent) { var capturedFrame = LambdaCapturedVariable.Create(frame, _innermostFramePointer, ref _synthesizedFieldNameIdDispenser); FieldSymbol frameParent = capturedFrame.AsMember(frameType); @@ -590,7 +610,7 @@ private BoundNode IntroduceFrame(BoundNode node, ClosureEnvironment frame, Func< // Capture any parameters of this block. This would typically occur // at the top level of a method or lambda with captured parameters. - foreach (var variable in frame.CapturedVariables) + foreach (var variable in env.CapturedVariables) { InitVariableProxy(syntax, variable, framePointer, prologue); } @@ -728,7 +748,7 @@ public override BoundNode VisitBaseReference(BoundBaseReference node) out NamedTypeSymbol constructedFrame) { var translatedLambdaContainer = synthesizedMethod.ContainingType; - var containerAsFrame = translatedLambdaContainer as ClosureEnvironment; + var containerAsFrame = translatedLambdaContainer as SynthesizedClosureEnvironment; // All of _currentTypeParameters might not be preserved here due to recursively calling upwards in the chain of local functions/lambdas Debug.Assert((typeArgumentsOpt.IsDefault && !originalMethod.IsGenericMethod) || (typeArgumentsOpt.Length == originalMethod.Arity)); @@ -866,9 +886,8 @@ private BoundSequence RewriteSequence(BoundSequence node, ArrayBuilder prologue, ArrayBuilder newLocals) => RewriteBlock(node, prologue, newLocals)); @@ -924,8 +943,7 @@ public override BoundNode VisitScope(BoundScope node) public override BoundNode VisitCatchBlock(BoundCatchBlock node) { // Test if this frame has captured variables and requires the introduction of a closure class. - ClosureEnvironment frame; - if (_frames.TryGetValue(node, out frame)) + if (_frames.TryGetValue(node, out var frame)) { return IntroduceFrame(node, frame, (ArrayBuilder prologue, ArrayBuilder newLocals) => { @@ -991,9 +1009,8 @@ private BoundNode RewriteCatch(BoundCatchBlock node, ArrayBuilder prologue, ArrayBuilder newLocals) => { @@ -1008,10 +1025,9 @@ public override BoundNode VisitSequence(BoundSequence node) public override BoundNode VisitStatementList(BoundStatementList node) { - ClosureEnvironment frame; // Test if this frame has captured variables and requires the introduction of a closure class. // That can occur for a BoundStatementList if it is the body of a method with captured parameters. - if (_frames.TryGetValue(node, out frame)) + if (_frames.TryGetValue(node, out var frame)) { return IntroduceFrame(node, frame, (ArrayBuilder prologue, ArrayBuilder newLocals) => { @@ -1034,9 +1050,8 @@ public override BoundNode VisitStatementList(BoundStatementList node) public override BoundNode VisitSwitchStatement(BoundSwitchStatement node) { - ClosureEnvironment frame; // Test if this frame has captured variables and requires the introduction of a closure class. - if (_frames.TryGetValue(node, out frame)) + if (_frames.TryGetValue(node, out var frame)) { return IntroduceFrame(node, frame, (ArrayBuilder prologue, ArrayBuilder newLocals) => { @@ -1105,7 +1120,7 @@ public override BoundNode VisitLocalFunctionStatement(BoundLocalFunctionStatemen { ClosureKind closureKind; NamedTypeSymbol translatedLambdaContainer; - ClosureEnvironment containerAsFrame; + SynthesizedClosureEnvironment containerAsFrame; BoundNode lambdaScope; DebugId topLevelMethodId; DebugId lambdaId; @@ -1178,7 +1193,7 @@ private DebugId GetLambdaId(SyntaxNode syntax, ClosureKind closureKind, int clos IBoundLambdaOrFunction node, out ClosureKind closureKind, out NamedTypeSymbol translatedLambdaContainer, - out ClosureEnvironment containerAsFrame, + out SynthesizedClosureEnvironment containerAsFrame, out BoundNode lambdaScope, out DebugId topLevelMethodId, out DebugId lambdaId) @@ -1186,40 +1201,37 @@ private DebugId GetLambdaId(SyntaxNode syntax, ClosureKind closureKind, int clos Analysis.Closure closure = Analysis.GetClosureInTree(_analysis.ScopeTree, node.Symbol); var structClosures = closure.CapturedEnvironments - .Where(env => env.IsStructType()).AsImmutable(); + .Where(env => env.IsStruct).Select(env => env.SynthesizedEnvironment).AsImmutable(); + int closureOrdinal; if (closure.ContainingEnvironmentOpt != null) { - containerAsFrame = closure.ContainingEnvironmentOpt; + containerAsFrame = closure.ContainingEnvironmentOpt?.SynthesizedEnvironment; - if (containerAsFrame?.IsValueType == true) - { - // Lower directly onto the containing type - containerAsFrame = null; - lambdaScope = null; - closureKind = ClosureKind.Static; // not exactly... but we've rewritten the receiver to be a by-ref parameter - translatedLambdaContainer = _topLevelMethod.ContainingType; - closureOrdinal = LambdaDebugInfo.StaticClosureOrdinal; - } - else + closureKind = ClosureKind.General; + translatedLambdaContainer = containerAsFrame; + closureOrdinal = containerAsFrame.ClosureOrdinal; + // Find the scope of the containing environment + BoundNode tmpScope = null; + Analysis.VisitScopeTree(_analysis.ScopeTree, scope => { - closureKind = ClosureKind.General; - translatedLambdaContainer = containerAsFrame; - closureOrdinal = containerAsFrame.ClosureOrdinal; - // Find the scope of the containing environment - BoundNode tmpScope = null; - Analysis.VisitScopeTree(_analysis.ScopeTree, scope => + if (scope.DeclaredEnvironments.Contains(closure.ContainingEnvironmentOpt)) { - if (scope.DeclaredEnvironments.Contains(closure.ContainingEnvironmentOpt)) - { - tmpScope = scope.BoundNode; - } - }); - Debug.Assert(tmpScope != null); - lambdaScope = tmpScope; - } + tmpScope = scope.BoundNode; + } + }); + Debug.Assert(tmpScope != null); + lambdaScope = tmpScope; + } + else if (closure.CapturesThis) + { + lambdaScope = null; + containerAsFrame = null; + translatedLambdaContainer = _topLevelMethod.ContainingType; + closureKind = ClosureKind.ThisOnly; + closureOrdinal = LambdaDebugInfo.ThisOnlyClosureOrdinal; } - else if (closure.CapturedVariables.Count == 0) + else if (closure.CapturedEnvironments.Count == 0) { if (_analysis.MethodsConvertedToDelegates.Contains(node.Symbol)) { @@ -1238,11 +1250,12 @@ private DebugId GetLambdaId(SyntaxNode syntax, ClosureKind closureKind, int clos } else { - lambdaScope = null; + // Lower directly onto the containing type containerAsFrame = null; + lambdaScope = null; + closureKind = ClosureKind.Static; // not exactly... but we've rewritten the receiver to be a by-ref parameter translatedLambdaContainer = _topLevelMethod.ContainingType; - closureKind = ClosureKind.ThisOnly; - closureOrdinal = LambdaDebugInfo.ThisOnlyClosureOrdinal; + closureOrdinal = LambdaDebugInfo.StaticClosureOrdinal; } // Move the body of the lambda to a freshly generated synthetic method on its frame. @@ -1338,7 +1351,7 @@ private BoundNode RewriteLambdaConversion(BoundLambda node) ClosureKind closureKind; NamedTypeSymbol translatedLambdaContainer; - ClosureEnvironment containerAsFrame; + SynthesizedClosureEnvironment containerAsFrame; BoundNode lambdaScope; DebugId topLevelMethodId; DebugId lambdaId; diff --git a/src/Compilers/CSharp/Portable/Lowering/LambdaRewriter/LambdaFrame.cs b/src/Compilers/CSharp/Portable/Lowering/LambdaRewriter/SynthesizedClosureEnvironment.cs similarity index 89% rename from src/Compilers/CSharp/Portable/Lowering/LambdaRewriter/LambdaFrame.cs rename to src/Compilers/CSharp/Portable/Lowering/LambdaRewriter/SynthesizedClosureEnvironment.cs index 5ef934ebdc892..67b4377b6d42d 100644 --- a/src/Compilers/CSharp/Portable/Lowering/LambdaRewriter/LambdaFrame.cs +++ b/src/Compilers/CSharp/Portable/Lowering/LambdaRewriter/SynthesizedClosureEnvironment.cs @@ -10,10 +10,9 @@ namespace Microsoft.CodeAnalysis.CSharp { /// - /// A class that represents the set of variables in a scope that have been - /// captured by nested functions within that scope. + /// The synthesized type added to a compilation to hold captured variables for closures. /// - internal sealed class ClosureEnvironment : SynthesizedContainer, ISynthesizedMethodBodyImplementationSymbol + internal sealed class SynthesizedClosureEnvironment : SynthesizedContainer, ISynthesizedMethodBodyImplementationSymbol { private readonly MethodSymbol _topLevelMethod; internal readonly SyntaxNode ScopeSyntaxOpt; @@ -25,13 +24,11 @@ internal sealed class ClosureEnvironment : SynthesizedContainer, ISynthesizedMet internal readonly MethodSymbol OriginalContainingMethodOpt; internal readonly FieldSymbol SingletonCache; internal readonly MethodSymbol StaticConstructor; - public readonly IEnumerable CapturedVariables; public override TypeKind TypeKind { get; } internal override MethodSymbol Constructor { get; } - internal ClosureEnvironment( - IEnumerable capturedVariables, + internal SynthesizedClosureEnvironment( MethodSymbol topLevelMethod, MethodSymbol containingMethod, bool isStruct, @@ -40,11 +37,10 @@ internal sealed class ClosureEnvironment : SynthesizedContainer, ISynthesizedMet DebugId closureId) : base(MakeName(scopeSyntaxOpt, methodId, closureId), containingMethod) { - CapturedVariables = capturedVariables; TypeKind = isStruct ? TypeKind.Struct : TypeKind.Class; _topLevelMethod = topLevelMethod; OriginalContainingMethodOpt = containingMethod; - Constructor = isStruct ? null : new LambdaFrameConstructor(this); + Constructor = isStruct ? null : new SynthesizedClosureEnvironmentConstructor(this); this.ClosureOrdinal = closureId.Ordinal; // static lambdas technically have the class scope so the scope syntax is null diff --git a/src/Compilers/CSharp/Portable/Lowering/LambdaRewriter/LambdaFrameConstructor.cs b/src/Compilers/CSharp/Portable/Lowering/LambdaRewriter/SynthesizedClosureEnvironmentConstructor.cs similarity index 72% rename from src/Compilers/CSharp/Portable/Lowering/LambdaRewriter/LambdaFrameConstructor.cs rename to src/Compilers/CSharp/Portable/Lowering/LambdaRewriter/SynthesizedClosureEnvironmentConstructor.cs index b64c048f75971..76dd6c2642099 100644 --- a/src/Compilers/CSharp/Portable/Lowering/LambdaRewriter/LambdaFrameConstructor.cs +++ b/src/Compilers/CSharp/Portable/Lowering/LambdaRewriter/SynthesizedClosureEnvironmentConstructor.cs @@ -4,9 +4,9 @@ namespace Microsoft.CodeAnalysis.CSharp { - internal sealed class LambdaFrameConstructor : SynthesizedInstanceConstructor, ISynthesizedMethodBodyImplementationSymbol + internal sealed class SynthesizedClosureEnvironmentConstructor : SynthesizedInstanceConstructor, ISynthesizedMethodBodyImplementationSymbol { - internal LambdaFrameConstructor(ClosureEnvironment frame) + internal SynthesizedClosureEnvironmentConstructor(SynthesizedClosureEnvironment frame) : base(frame) { } diff --git a/src/Compilers/CSharp/Portable/Lowering/LambdaRewriter/SynthesizedLambdaMethod.cs b/src/Compilers/CSharp/Portable/Lowering/LambdaRewriter/SynthesizedLambdaMethod.cs index 1eee93f9df38b..9bb6e7418db6d 100644 --- a/src/Compilers/CSharp/Portable/Lowering/LambdaRewriter/SynthesizedLambdaMethod.cs +++ b/src/Compilers/CSharp/Portable/Lowering/LambdaRewriter/SynthesizedLambdaMethod.cs @@ -19,7 +19,7 @@ internal sealed class SynthesizedLambdaMethod : SynthesizedMethodBaseSymbol, ISy internal SynthesizedLambdaMethod( NamedTypeSymbol containingType, - ImmutableArray structEnvironments, + ImmutableArray structEnvironments, ClosureKind closureKind, MethodSymbol topLevelMethod, DebugId topLevelMethodId, @@ -43,9 +43,9 @@ internal sealed class SynthesizedLambdaMethod : SynthesizedMethodBaseSymbol, ISy TypeMap typeMap; ImmutableArray typeParameters; ImmutableArray constructedFromTypeParameters; - ClosureEnvironment lambdaFrame; + SynthesizedClosureEnvironment lambdaFrame; - lambdaFrame = this.ContainingType as ClosureEnvironment; + lambdaFrame = this.ContainingType as SynthesizedClosureEnvironment; switch (closureKind) { case ClosureKind.Singleton: // all type parameters on method (except the top level method's) diff --git a/src/Compilers/CSharp/Portable/Operations/CSharpConversionExpression.cs b/src/Compilers/CSharp/Portable/Operations/CSharpConversionExpression.cs index e73841ddd389c..27fbede93d0bb 100644 --- a/src/Compilers/CSharp/Portable/Operations/CSharpConversionExpression.cs +++ b/src/Compilers/CSharp/Portable/Operations/CSharpConversionExpression.cs @@ -7,8 +7,8 @@ namespace Microsoft.CodeAnalysis.CSharp { internal abstract class BaseCSharpConversionExpression : BaseConversionExpression { - protected BaseCSharpConversionExpression(Conversion conversion, bool isExplicitInCode, bool isTryCast, bool isChecked, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(isExplicitInCode, isTryCast, isChecked, semanticModel, syntax, type, constantValue) + protected BaseCSharpConversionExpression(Conversion conversion, bool isExplicitInCode, bool isTryCast, bool isChecked, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(isExplicitInCode, isTryCast, isChecked, semanticModel, syntax, type, constantValue, isImplicit) { ConversionInternal = conversion; } @@ -20,8 +20,8 @@ internal abstract class BaseCSharpConversionExpression : BaseConversionExpressio internal sealed partial class CSharpConversionExpression : BaseCSharpConversionExpression { - public CSharpConversionExpression(IOperation operand, Conversion conversion, bool isExplicit, bool isTryCast, bool isChecked, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(conversion, isExplicit, isTryCast, isChecked, semanticModel, syntax, type, constantValue) + public CSharpConversionExpression(IOperation operand, Conversion conversion, bool isExplicit, bool isTryCast, bool isChecked, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(conversion, isExplicit, isTryCast, isChecked, semanticModel, syntax, type, constantValue, isImplicit) { OperandImpl = operand; } @@ -32,8 +32,8 @@ internal sealed partial class CSharpConversionExpression : BaseCSharpConversionE internal sealed partial class LazyCSharpConversionExpression : BaseCSharpConversionExpression { private readonly Lazy _operand; - public LazyCSharpConversionExpression(Lazy operand, Conversion conversion, bool isExplicit, bool isTryCast, bool isChecked, SemanticModel semanticModel,SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(conversion, isExplicit, isTryCast, isChecked, semanticModel, syntax, type, constantValue) + public LazyCSharpConversionExpression(Lazy operand, Conversion conversion, bool isExplicit, bool isTryCast, bool isChecked, SemanticModel semanticModel,SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(conversion, isExplicit, isTryCast, isChecked, semanticModel, syntax, type, constantValue, isImplicit) { _operand = operand; } diff --git a/src/Compilers/CSharp/Portable/Operations/CSharpOperationCloner.cs b/src/Compilers/CSharp/Portable/Operations/CSharpOperationCloner.cs index 72551d490a080..bb27fab2eba42 100644 --- a/src/Compilers/CSharp/Portable/Operations/CSharpOperationCloner.cs +++ b/src/Compilers/CSharp/Portable/Operations/CSharpOperationCloner.cs @@ -10,7 +10,7 @@ internal class CSharpOperationCloner : OperationCloner public override IOperation VisitConversionExpression(IConversionExpression operation, object argument) { - return new CSharpConversionExpression(Visit(operation.Operand), operation.GetConversion(), operation.IsExplicitInCode, operation.IsTryCast, operation.IsChecked, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new CSharpConversionExpression(Visit(operation.Operand), operation.GetConversion(), operation.IsExplicitInCode, operation.IsTryCast, operation.IsChecked, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } } } diff --git a/src/Compilers/CSharp/Portable/Operations/CSharpOperationFactory.cs b/src/Compilers/CSharp/Portable/Operations/CSharpOperationFactory.cs index 46f423026549d..5310867a48741 100644 --- a/src/Compilers/CSharp/Portable/Operations/CSharpOperationFactory.cs +++ b/src/Compilers/CSharp/Portable/Operations/CSharpOperationFactory.cs @@ -256,7 +256,9 @@ private IOperation CreateInternal(BoundNode boundNode) return CreateBoundIsPatternExpressionOperation((BoundIsPatternExpression)boundNode); default: var constantValue = ConvertToOptional((boundNode as BoundExpression)?.ConstantValue); - return Operation.CreateOperationNone(_semanticModel, boundNode.Syntax, constantValue, getChildren: () => GetIOperationChildren(boundNode)); + bool isImplicit = boundNode.WasCompilerGenerated; + + return Operation.CreateOperationNone(_semanticModel, boundNode.Syntax, constantValue, getChildren: () => GetIOperationChildren(boundNode), isImplicit: isImplicit); } } @@ -283,7 +285,8 @@ private IPlaceholderExpression CreateBoundDeconstructValuePlaceholderOperation(B SyntaxNode syntax = boundDeconstructValuePlaceholder.Syntax; ITypeSymbol type = boundDeconstructValuePlaceholder.Type; Optional constantValue = ConvertToOptional(boundDeconstructValuePlaceholder.ConstantValue); - return new PlaceholderExpression(_semanticModel, syntax, type, constantValue); + bool isImplicit = boundDeconstructValuePlaceholder.WasCompilerGenerated; + return new PlaceholderExpression(_semanticModel, syntax, type, constantValue, isImplicit); } private IInvocationExpression CreateBoundCallOperation(BoundCall boundCall) @@ -313,7 +316,8 @@ private IInvocationExpression CreateBoundCallOperation(BoundCall boundCall) SyntaxNode syntax = boundCall.Syntax; ITypeSymbol type = boundCall.Type; Optional constantValue = ConvertToOptional(boundCall.ConstantValue); - return new LazyInvocationExpression(targetMethod, instance, isVirtual, argumentsInEvaluationOrder, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundCall.WasCompilerGenerated; + return new LazyInvocationExpression(targetMethod, instance, isVirtual, argumentsInEvaluationOrder, _semanticModel, syntax, type, constantValue, isImplicit); } private ILocalReferenceExpression CreateBoundLocalOperation(BoundLocal boundLocal) @@ -322,7 +326,8 @@ private ILocalReferenceExpression CreateBoundLocalOperation(BoundLocal boundLoca SyntaxNode syntax = boundLocal.Syntax; ITypeSymbol type = boundLocal.Type; Optional constantValue = ConvertToOptional(boundLocal.ConstantValue); - return new LocalReferenceExpression(local, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundLocal.WasCompilerGenerated; + return new LocalReferenceExpression(local, _semanticModel, syntax, type, constantValue, isImplicit); } private IFieldReferenceExpression CreateBoundFieldAccessOperation(BoundFieldAccess boundFieldAccess) @@ -333,7 +338,8 @@ private IFieldReferenceExpression CreateBoundFieldAccessOperation(BoundFieldAcce SyntaxNode syntax = boundFieldAccess.Syntax; ITypeSymbol type = boundFieldAccess.Type; Optional constantValue = ConvertToOptional(boundFieldAccess.ConstantValue); - return new LazyFieldReferenceExpression(field, instance, member, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundFieldAccess.WasCompilerGenerated; + return new LazyFieldReferenceExpression(field, instance, member, _semanticModel, syntax, type, constantValue, isImplicit); } private IPropertyReferenceExpression CreateBoundPropertyAccessOperation(BoundPropertyAccess boundPropertyAccess) @@ -345,7 +351,8 @@ private IPropertyReferenceExpression CreateBoundPropertyAccessOperation(BoundPro SyntaxNode syntax = boundPropertyAccess.Syntax; ITypeSymbol type = boundPropertyAccess.Type; Optional constantValue = ConvertToOptional(boundPropertyAccess.ConstantValue); - return new LazyPropertyReferenceExpression(property, instance, member, argumentsInEvaluationOrder, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundPropertyAccess.WasCompilerGenerated; + return new LazyPropertyReferenceExpression(property, instance, member, argumentsInEvaluationOrder, _semanticModel, syntax, type, constantValue, isImplicit); } private IPropertyReferenceExpression CreateBoundIndexerAccessOperation(BoundIndexerAccess boundIndexerAccess) @@ -375,7 +382,8 @@ private IPropertyReferenceExpression CreateBoundIndexerAccessOperation(BoundInde SyntaxNode syntax = boundIndexerAccess.Syntax; ITypeSymbol type = boundIndexerAccess.Type; Optional constantValue = ConvertToOptional(boundIndexerAccess.ConstantValue); - return new LazyPropertyReferenceExpression(property, instance, member, argumentsInEvaluationOrder, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundIndexerAccess.WasCompilerGenerated; + return new LazyPropertyReferenceExpression(property, instance, member, argumentsInEvaluationOrder, _semanticModel, syntax, type, constantValue, isImplicit); } private IEventReferenceExpression CreateBoundEventAccessOperation(BoundEventAccess boundEventAccess) @@ -386,7 +394,8 @@ private IEventReferenceExpression CreateBoundEventAccessOperation(BoundEventAcce SyntaxNode syntax = boundEventAccess.Syntax; ITypeSymbol type = boundEventAccess.Type; Optional constantValue = ConvertToOptional(boundEventAccess.ConstantValue); - return new LazyEventReferenceExpression(@event, instance, member, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundEventAccess.WasCompilerGenerated; + return new LazyEventReferenceExpression(@event, instance, member, _semanticModel, syntax, type, constantValue, isImplicit); } private IEventReferenceExpression CreateBoundEventAccessOperation(BoundEventAssignmentOperator boundEventAssignmentOperator) @@ -400,28 +409,31 @@ private IEventReferenceExpression CreateBoundEventAccessOperation(BoundEventAssi IEventSymbol @event = boundEventAssignmentOperator.Event; Lazy instance = new Lazy(() => Create(boundEventAssignmentOperator.Event.IsStatic ? null : boundEventAssignmentOperator.ReceiverOpt)); SyntaxNode eventAccessSyntax = ((AssignmentExpressionSyntax)syntax).Left; + bool isImplicit = boundEventAssignmentOperator.WasCompilerGenerated; - return new LazyEventReferenceExpression(@event, instance, @event, _semanticModel, eventAccessSyntax, @event.Type, ConvertToOptional(null)); + return new LazyEventReferenceExpression(@event, instance, @event, _semanticModel, eventAccessSyntax, @event.Type, ConvertToOptional(null), isImplicit); } private IEventAssignmentExpression CreateBoundEventAssignmentOperatorOperation(BoundEventAssignmentOperator boundEventAssignmentOperator) { - Lazy eventReference = new Lazy(() => CreateBoundEventAccessOperation(boundEventAssignmentOperator)); + Lazy eventReference = new Lazy(() => CreateBoundEventAccessOperation(boundEventAssignmentOperator)); Lazy handlerValue = new Lazy(() => Create(boundEventAssignmentOperator.Argument)); SyntaxNode syntax = boundEventAssignmentOperator.Syntax; bool adds = boundEventAssignmentOperator.IsAddition; ITypeSymbol type = boundEventAssignmentOperator.Type; Optional constantValue = ConvertToOptional(boundEventAssignmentOperator.ConstantValue); - return new LazyEventAssignmentExpression(eventReference, handlerValue, adds, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundEventAssignmentOperator.WasCompilerGenerated; + return new LazyEventAssignmentExpression(eventReference, handlerValue, adds, _semanticModel, syntax, type, constantValue, isImplicit); } - private IParameterReferenceExpression CreateBoundParameterOperation(BoundParameter boundParameter) + private IParameterReferenceExpression CreateBoundParameterOperation(BoundParameter boundParameter) { IParameterSymbol parameter = boundParameter.ParameterSymbol; SyntaxNode syntax = boundParameter.Syntax; ITypeSymbol type = boundParameter.Type; Optional constantValue = ConvertToOptional(boundParameter.ConstantValue); - return new ParameterReferenceExpression(parameter, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundParameter.WasCompilerGenerated; + return new ParameterReferenceExpression(parameter, _semanticModel, syntax, type, constantValue, isImplicit); } private ILiteralExpression CreateBoundLiteralOperation(BoundLiteral boundLiteral) @@ -429,7 +441,8 @@ private ILiteralExpression CreateBoundLiteralOperation(BoundLiteral boundLiteral SyntaxNode syntax = boundLiteral.Syntax; ITypeSymbol type = boundLiteral.Type; Optional constantValue = ConvertToOptional(boundLiteral.ConstantValue); - return new LiteralExpression(_semanticModel, syntax, type, constantValue); + bool isImplicit = boundLiteral.WasCompilerGenerated; + return new LiteralExpression(_semanticModel, syntax, type, constantValue, isImplicit); } private IAnonymousObjectCreationExpression CreateBoundAnonymousObjectCreationExpressionOperation(BoundAnonymousObjectCreationExpression boundAnonymousObjectCreationExpression) @@ -438,7 +451,8 @@ private IAnonymousObjectCreationExpression CreateBoundAnonymousObjectCreationExp SyntaxNode syntax = boundAnonymousObjectCreationExpression.Syntax; ITypeSymbol type = boundAnonymousObjectCreationExpression.Type; Optional constantValue = ConvertToOptional(boundAnonymousObjectCreationExpression.ConstantValue); - return new LazyAnonymousObjectCreationExpression(memberInitializers, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundAnonymousObjectCreationExpression.WasCompilerGenerated; + return new LazyAnonymousObjectCreationExpression(memberInitializers, _semanticModel, syntax, type, constantValue, isImplicit); } private IPropertyReferenceExpression CreateBoundAnonymousPropertyDeclarationOperation(BoundAnonymousPropertyDeclaration boundAnonymousPropertyDeclaration) @@ -450,7 +464,8 @@ private IPropertyReferenceExpression CreateBoundAnonymousPropertyDeclarationOper SyntaxNode syntax = boundAnonymousPropertyDeclaration.Syntax; ITypeSymbol type = boundAnonymousPropertyDeclaration.Type; Optional constantValue = ConvertToOptional(boundAnonymousPropertyDeclaration.ConstantValue); - return new LazyPropertyReferenceExpression(property, instance, member, argumentsInEvaluationOrder, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundAnonymousPropertyDeclaration.WasCompilerGenerated; + return new LazyPropertyReferenceExpression(property, instance, member, argumentsInEvaluationOrder, _semanticModel, syntax, type, constantValue, isImplicit); } private IObjectCreationExpression CreateBoundObjectCreationExpressionOperation(BoundObjectCreationExpression boundObjectCreationExpression) @@ -475,7 +490,8 @@ private IObjectCreationExpression CreateBoundObjectCreationExpressionOperation(B SyntaxNode syntax = boundObjectCreationExpression.Syntax; ITypeSymbol type = boundObjectCreationExpression.Type; Optional constantValue = ConvertToOptional(boundObjectCreationExpression.ConstantValue); - return new LazyObjectCreationExpression(constructor, initializer, argumentsInEvaluationOrder, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundObjectCreationExpression.WasCompilerGenerated; + return new LazyObjectCreationExpression(constructor, initializer, argumentsInEvaluationOrder, _semanticModel, syntax, type, constantValue, isImplicit); } private IDynamicObjectCreationExpression CreateBoundDynamicObjectCreationExpressionOperation(BoundDynamicObjectCreationExpression boundDynamicObjectCreationExpression) @@ -489,7 +505,8 @@ private IDynamicObjectCreationExpression CreateBoundDynamicObjectCreationExpress SyntaxNode syntax = boundDynamicObjectCreationExpression.Syntax; ITypeSymbol type = boundDynamicObjectCreationExpression.Type; Optional constantValue = ConvertToOptional(boundDynamicObjectCreationExpression.ConstantValue); - return new LazyDynamicObjectCreationExpression(name, applicableSymbols, arguments, argumentNames, argumentRefKinds, initializer, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundDynamicObjectCreationExpression.WasCompilerGenerated; + return new LazyDynamicObjectCreationExpression(name, applicableSymbols, arguments, argumentNames, argumentRefKinds, initializer, _semanticModel, syntax, type, constantValue, isImplicit); } private IObjectOrCollectionInitializerExpression CreateBoundObjectInitializerExpressionOperation(BoundObjectInitializerExpression boundObjectInitializerExpression) @@ -498,7 +515,8 @@ private IObjectOrCollectionInitializerExpression CreateBoundObjectInitializerExp SyntaxNode syntax = boundObjectInitializerExpression.Syntax; ITypeSymbol type = boundObjectInitializerExpression.Type; Optional constantValue = ConvertToOptional(boundObjectInitializerExpression.ConstantValue); - return new LazyObjectOrCollectionInitializerExpression(initializers, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundObjectInitializerExpression.WasCompilerGenerated; + return new LazyObjectOrCollectionInitializerExpression(initializers, _semanticModel, syntax, type, constantValue, isImplicit); } private IObjectOrCollectionInitializerExpression CreateBoundCollectionInitializerExpressionOperation(BoundCollectionInitializerExpression boundCollectionInitializerExpression) @@ -507,7 +525,8 @@ private IObjectOrCollectionInitializerExpression CreateBoundCollectionInitialize SyntaxNode syntax = boundCollectionInitializerExpression.Syntax; ITypeSymbol type = boundCollectionInitializerExpression.Type; Optional constantValue = ConvertToOptional(boundCollectionInitializerExpression.ConstantValue); - return new LazyObjectOrCollectionInitializerExpression(initializers, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundCollectionInitializerExpression.WasCompilerGenerated; + return new LazyObjectOrCollectionInitializerExpression(initializers, _semanticModel, syntax, type, constantValue, isImplicit); } private IMemberReferenceExpression CreateBoundObjectInitializerMemberOperation(BoundObjectInitializerMember boundObjectInitializerMember) @@ -517,20 +536,22 @@ private IMemberReferenceExpression CreateBoundObjectInitializerMemberOperation(B _semanticModel, syntax: boundObjectInitializerMember.Syntax, type: boundObjectInitializerMember.MemberSymbol.ContainingType, - constantValue: default(Optional))); + constantValue: default(Optional), + isImplicit: boundObjectInitializerMember.WasCompilerGenerated)); SyntaxNode syntax = boundObjectInitializerMember.Syntax; ITypeSymbol type = boundObjectInitializerMember.Type; Optional constantValue = ConvertToOptional(boundObjectInitializerMember.ConstantValue); + bool isImplicit = boundObjectInitializerMember.WasCompilerGenerated; switch (boundObjectInitializerMember.MemberSymbol.Kind) { case SymbolKind.Field: var field = (FieldSymbol)boundObjectInitializerMember.MemberSymbol; - return new LazyFieldReferenceExpression(field, instance, field, _semanticModel, syntax, type, constantValue); + return new LazyFieldReferenceExpression(field, instance, field, _semanticModel, syntax, type, constantValue, isImplicit); case SymbolKind.Event: var eventSymbol = (EventSymbol)boundObjectInitializerMember.MemberSymbol; - return new LazyEventReferenceExpression(eventSymbol, instance, eventSymbol, _semanticModel, syntax, type, constantValue); + return new LazyEventReferenceExpression(eventSymbol, instance, eventSymbol, _semanticModel, syntax, type, constantValue, isImplicit); case SymbolKind.Property: var property = (PropertySymbol)boundObjectInitializerMember.MemberSymbol; Lazy> argumentsInEvaluationOrder; @@ -559,7 +580,7 @@ private IMemberReferenceExpression CreateBoundObjectInitializerMemberOperation(B }); } - return new LazyPropertyReferenceExpression(property, instance, property, argumentsInEvaluationOrder, _semanticModel, syntax, type, constantValue); + return new LazyPropertyReferenceExpression(property, instance, property, argumentsInEvaluationOrder, _semanticModel, syntax, type, constantValue, isImplicit); default: throw ExceptionUtilities.Unreachable; } @@ -573,7 +594,8 @@ private ICollectionElementInitializerExpression CreateBoundCollectionElementInit SyntaxNode syntax = boundCollectionElementInitializer.Syntax; ITypeSymbol type = boundCollectionElementInitializer.Type; Optional constantValue = ConvertToOptional(boundCollectionElementInitializer.ConstantValue); - return new LazyCollectionElementInitializerExpression(addMethod, arguments, isDynamic, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundCollectionElementInitializer.WasCompilerGenerated; + return new LazyCollectionElementInitializerExpression(addMethod, arguments, isDynamic, _semanticModel, syntax, type, constantValue, isImplicit); } private IDynamicMemberReferenceExpression CreateBoundDynamicMemberAccessOperation(BoundDynamicMemberAccess boundDynamicMemberAccess) @@ -589,7 +611,8 @@ private IDynamicMemberReferenceExpression CreateBoundDynamicMemberAccessOperatio SyntaxNode syntaxNode = boundDynamicMemberAccess.Syntax; ITypeSymbol type = boundDynamicMemberAccess.Type; Optional constantValue = ConvertToOptional(boundDynamicMemberAccess.ConstantValue); - return new LazyDynamicMemberReferenceExpression(instance, memberName, typeArguments, containingType, _semanticModel, syntaxNode, type, constantValue); + bool isImplicit = boundDynamicMemberAccess.WasCompilerGenerated; + return new LazyDynamicMemberReferenceExpression(instance, memberName, typeArguments, containingType, _semanticModel, syntaxNode, type, constantValue, isImplicit); } private ICollectionElementInitializerExpression CreateBoundDynamicCollectionElementInitializerOperation(BoundDynamicCollectionElementInitializer boundCollectionElementInitializer) @@ -600,7 +623,8 @@ private ICollectionElementInitializerExpression CreateBoundDynamicCollectionElem SyntaxNode syntax = boundCollectionElementInitializer.Syntax; ITypeSymbol type = boundCollectionElementInitializer.Type; Optional constantValue = ConvertToOptional(boundCollectionElementInitializer.ConstantValue); - return new LazyCollectionElementInitializerExpression(addMethod, arguments, isDynamic, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundCollectionElementInitializer.WasCompilerGenerated; + return new LazyCollectionElementInitializerExpression(addMethod, arguments, isDynamic, _semanticModel, syntax, type, constantValue, isImplicit); } private IOperation CreateUnboundLambdaOperation(UnboundLambda unboundLambda) @@ -625,7 +649,8 @@ private ILambdaExpression CreateBoundLambdaOperation(BoundLambda boundLambda) // an ILambdaExpression, you need to look at the parent IConversionExpression. ITypeSymbol type = null; Optional constantValue = ConvertToOptional(boundLambda.ConstantValue); - return new LazyLambdaExpression(signature, body, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundLambda.WasCompilerGenerated; + return new LazyLambdaExpression(signature, body, _semanticModel, syntax, type, constantValue, isImplicit); } private ILocalFunctionStatement CreateBoundLocalFunctionStatementOperation(BoundLocalFunctionStatement boundLocalFunctionStatement) @@ -635,12 +660,14 @@ private ILocalFunctionStatement CreateBoundLocalFunctionStatementOperation(Bound SyntaxNode syntax = boundLocalFunctionStatement.Syntax; ITypeSymbol type = null; Optional constantValue = default(Optional); - return new LazyLocalFunctionStatement(localFunctionSymbol, body, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundLocalFunctionStatement.WasCompilerGenerated; + return new LazyLocalFunctionStatement(localFunctionSymbol, body, _semanticModel, syntax, type, constantValue, isImplicit); } private IOperation CreateBoundConversionOperation(BoundConversion boundConversion) { ConversionKind conversionKind = GetConversionKind(boundConversion.ConversionKind); + bool isImplicit = boundConversion.WasCompilerGenerated; if (boundConversion.ConversionKind == CSharp.ConversionKind.MethodGroup) { IMethodSymbol method = boundConversion.SymbolOpt; @@ -649,7 +676,7 @@ private IOperation CreateBoundConversionOperation(BoundConversion boundConversio SyntaxNode syntax = boundConversion.Syntax; ITypeSymbol type = boundConversion.Type; Optional constantValue = ConvertToOptional(boundConversion.ConstantValue); - return new LazyMethodBindingExpression(method, isVirtual, instance, method, _semanticModel, syntax, type, constantValue); + return new LazyMethodBindingExpression(method, isVirtual, instance, method, _semanticModel, syntax, type, constantValue, isImplicit); } else { @@ -662,7 +689,7 @@ private IOperation CreateBoundConversionOperation(BoundConversion boundConversio bool isChecked = conversion.IsNumeric && boundConversion.Checked; ITypeSymbol type = boundConversion.Type; Optional constantValue = ConvertToOptional(boundConversion.ConstantValue); - return new LazyCSharpConversionExpression(operand, conversion, isExplicit, isTryCast, isChecked, _semanticModel, syntax, type, constantValue); + return new LazyCSharpConversionExpression(operand, conversion, isExplicit, isTryCast, isChecked, _semanticModel, syntax, type, constantValue, isImplicit); } } @@ -676,7 +703,8 @@ private IConversionExpression CreateBoundAsOperatorOperation(BoundAsOperator bou bool isChecked = false; ITypeSymbol type = boundAsOperator.Type; Optional constantValue = ConvertToOptional(boundAsOperator.ConstantValue); - return new LazyCSharpConversionExpression(operand, conversion, isExplicit, isTryCast, isChecked, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundAsOperator.WasCompilerGenerated; + return new LazyCSharpConversionExpression(operand, conversion, isExplicit, isTryCast, isChecked, _semanticModel, syntax, type, constantValue, isImplicit); } private IIsTypeExpression CreateBoundIsOperatorOperation(BoundIsOperator boundIsOperator) @@ -686,7 +714,8 @@ private IIsTypeExpression CreateBoundIsOperatorOperation(BoundIsOperator boundIs SyntaxNode syntax = boundIsOperator.Syntax; ITypeSymbol type = boundIsOperator.Type; Optional constantValue = ConvertToOptional(boundIsOperator.ConstantValue); - return new LazyIsTypeExpression(operand, isType, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundIsOperator.WasCompilerGenerated; + return new LazyIsTypeExpression(operand, isType, _semanticModel, syntax, type, constantValue, isImplicit); } private ISizeOfExpression CreateBoundSizeOfOperatorOperation(BoundSizeOfOperator boundSizeOfOperator) @@ -695,7 +724,8 @@ private ISizeOfExpression CreateBoundSizeOfOperatorOperation(BoundSizeOfOperator SyntaxNode syntax = boundSizeOfOperator.Syntax; ITypeSymbol type = boundSizeOfOperator.Type; Optional constantValue = ConvertToOptional(boundSizeOfOperator.ConstantValue); - return new SizeOfExpression(typeOperand, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundSizeOfOperator.WasCompilerGenerated; + return new SizeOfExpression(typeOperand, _semanticModel, syntax, type, constantValue, isImplicit); } private ITypeOfExpression CreateBoundTypeOfOperatorOperation(BoundTypeOfOperator boundTypeOfOperator) @@ -704,7 +734,8 @@ private ITypeOfExpression CreateBoundTypeOfOperatorOperation(BoundTypeOfOperator SyntaxNode syntax = boundTypeOfOperator.Syntax; ITypeSymbol type = boundTypeOfOperator.Type; Optional constantValue = ConvertToOptional(boundTypeOfOperator.ConstantValue); - return new TypeOfExpression(typeOperand, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundTypeOfOperator.WasCompilerGenerated; + return new TypeOfExpression(typeOperand, _semanticModel, syntax, type, constantValue, isImplicit); } private IArrayCreationExpression CreateBoundArrayCreationOperation(BoundArrayCreation boundArrayCreation) @@ -715,7 +746,8 @@ private IArrayCreationExpression CreateBoundArrayCreationOperation(BoundArrayCre SyntaxNode syntax = boundArrayCreation.Syntax; ITypeSymbol type = boundArrayCreation.Type; Optional constantValue = ConvertToOptional(boundArrayCreation.ConstantValue); - return new LazyArrayCreationExpression(elementType, dimensionSizes, initializer, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundArrayCreation.WasCompilerGenerated; + return new LazyArrayCreationExpression(elementType, dimensionSizes, initializer, _semanticModel, syntax, type, constantValue, isImplicit); } private IArrayInitializer CreateBoundArrayInitializationOperation(BoundArrayInitialization boundArrayInitialization) @@ -724,7 +756,8 @@ private IArrayInitializer CreateBoundArrayInitializationOperation(BoundArrayInit SyntaxNode syntax = boundArrayInitialization.Syntax; ITypeSymbol type = boundArrayInitialization.Type; Optional constantValue = ConvertToOptional(boundArrayInitialization.ConstantValue); - return new LazyArrayInitializer(elementValues, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundArrayInitialization.WasCompilerGenerated; + return new LazyArrayInitializer(elementValues, _semanticModel, syntax, type, constantValue, isImplicit); } private IDefaultValueExpression CreateBoundDefaultExpressionOperation(BoundDefaultExpression boundDefaultExpression) @@ -732,7 +765,8 @@ private IDefaultValueExpression CreateBoundDefaultExpressionOperation(BoundDefau SyntaxNode syntax = boundDefaultExpression.Syntax; ITypeSymbol type = boundDefaultExpression.Type; Optional constantValue = ConvertToOptional(boundDefaultExpression.ConstantValue); - return new DefaultValueExpression(_semanticModel, syntax, type, constantValue); + bool isImplicit = boundDefaultExpression.WasCompilerGenerated; + return new DefaultValueExpression(_semanticModel, syntax, type, constantValue, isImplicit); } private IInstanceReferenceExpression CreateBoundBaseReferenceOperation(BoundBaseReference boundBaseReference) @@ -741,7 +775,8 @@ private IInstanceReferenceExpression CreateBoundBaseReferenceOperation(BoundBase SyntaxNode syntax = boundBaseReference.Syntax; ITypeSymbol type = boundBaseReference.Type; Optional constantValue = ConvertToOptional(boundBaseReference.ConstantValue); - return new InstanceReferenceExpression(instanceReferenceKind, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundBaseReference.WasCompilerGenerated; + return new InstanceReferenceExpression(instanceReferenceKind, _semanticModel, syntax, type, constantValue, isImplicit); } private IInstanceReferenceExpression CreateBoundThisReferenceOperation(BoundThisReference boundThisReference) @@ -750,7 +785,8 @@ private IInstanceReferenceExpression CreateBoundThisReferenceOperation(BoundThis SyntaxNode syntax = boundThisReference.Syntax; ITypeSymbol type = boundThisReference.Type; Optional constantValue = ConvertToOptional(boundThisReference.ConstantValue); - return new InstanceReferenceExpression(instanceReferenceKind, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundThisReference.WasCompilerGenerated; + return new InstanceReferenceExpression(instanceReferenceKind, _semanticModel, syntax, type, constantValue, isImplicit); } private IOperation CreateBoundAssignmentOperatorOrMemberInitializerOperation(BoundAssignmentOperator boundAssignmentOperator) @@ -772,7 +808,8 @@ private ISimpleAssignmentExpression CreateBoundAssignmentOperatorOperation(Bound SyntaxNode syntax = boundAssignmentOperator.Syntax; ITypeSymbol type = boundAssignmentOperator.Type; Optional constantValue = ConvertToOptional(boundAssignmentOperator.ConstantValue); - return new LazySimpleAssignmentExpression(target, value, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundAssignmentOperator.WasCompilerGenerated; + return new LazySimpleAssignmentExpression(target, value, _semanticModel, syntax, type, constantValue, isImplicit); } private IMemberInitializerExpression CreateBoundMemberInitializerOperation(BoundAssignmentOperator boundAssignmentOperator) @@ -784,7 +821,8 @@ private IMemberInitializerExpression CreateBoundMemberInitializerOperation(Bound SyntaxNode syntax = boundAssignmentOperator.Syntax; ITypeSymbol type = boundAssignmentOperator.Type; Optional constantValue = ConvertToOptional(boundAssignmentOperator.ConstantValue); - return new LazyMemberInitializerExpression(target, value, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundAssignmentOperator.WasCompilerGenerated; + return new LazyMemberInitializerExpression(target, value, _semanticModel, syntax, type, constantValue, isImplicit); } private ICompoundAssignmentExpression CreateBoundCompoundAssignmentOperatorOperation(BoundCompoundAssignmentOperator boundCompoundAssignmentOperator) @@ -797,7 +835,8 @@ private ICompoundAssignmentExpression CreateBoundCompoundAssignmentOperatorOpera SyntaxNode syntax = boundCompoundAssignmentOperator.Syntax; ITypeSymbol type = boundCompoundAssignmentOperator.Type; Optional constantValue = ConvertToOptional(boundCompoundAssignmentOperator.ConstantValue); - return new LazyCompoundAssignmentExpression(binaryOperationKind, boundCompoundAssignmentOperator.Type.IsNullableType(), target, value, usesOperatorMethod, operatorMethod, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundCompoundAssignmentOperator.WasCompilerGenerated; + return new LazyCompoundAssignmentExpression(binaryOperationKind, boundCompoundAssignmentOperator.Type.IsNullableType(), target, value, usesOperatorMethod, operatorMethod, _semanticModel, syntax, type, constantValue, isImplicit); } private IIncrementExpression CreateBoundIncrementOperatorOperation(BoundIncrementOperator boundIncrementOperator) @@ -809,7 +848,8 @@ private IIncrementExpression CreateBoundIncrementOperatorOperation(BoundIncremen SyntaxNode syntax = boundIncrementOperator.Syntax; ITypeSymbol type = boundIncrementOperator.Type; Optional constantValue = ConvertToOptional(boundIncrementOperator.ConstantValue); - return new LazyIncrementExpression(incrementOperationKind, target, usesOperatorMethod, operatorMethod, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundIncrementOperator.WasCompilerGenerated; + return new LazyIncrementExpression(incrementOperationKind, target, usesOperatorMethod, operatorMethod, _semanticModel, syntax, type, constantValue, isImplicit); } private IInvalidExpression CreateBoundBadExpressionOperation(BoundBadExpression boundBadExpression) @@ -818,7 +858,8 @@ private IInvalidExpression CreateBoundBadExpressionOperation(BoundBadExpression SyntaxNode syntax = boundBadExpression.Syntax; ITypeSymbol type = boundBadExpression.Type; Optional constantValue = ConvertToOptional(boundBadExpression.ConstantValue); - return new LazyInvalidExpression(children, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundBadExpression.WasCompilerGenerated; + return new LazyInvalidExpression(children, _semanticModel, syntax, type, constantValue, isImplicit); } private ITypeParameterObjectCreationExpression CreateBoundNewTOperation(BoundNewT boundNewT) @@ -827,7 +868,8 @@ private ITypeParameterObjectCreationExpression CreateBoundNewTOperation(BoundNew SyntaxNode syntax = boundNewT.Syntax; ITypeSymbol type = boundNewT.Type; Optional constantValue = ConvertToOptional(boundNewT.ConstantValue); - return new LazyTypeParameterObjectCreationExpression(initializer, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundNewT.WasCompilerGenerated; + return new LazyTypeParameterObjectCreationExpression(initializer, _semanticModel, syntax, type, constantValue, isImplicit); } private IUnaryOperatorExpression CreateBoundUnaryOperatorOperation(BoundUnaryOperator boundUnaryOperator) @@ -840,7 +882,8 @@ private IUnaryOperatorExpression CreateBoundUnaryOperatorOperation(BoundUnaryOpe ITypeSymbol type = boundUnaryOperator.Type; Optional constantValue = ConvertToOptional(boundUnaryOperator.ConstantValue); bool isLifted = boundUnaryOperator.OperatorKind.IsLifted(); - return new LazyUnaryOperatorExpression(unaryOperationKind, operand, isLifted, usesOperatorMethod, operatorMethod, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundUnaryOperator.WasCompilerGenerated; + return new LazyUnaryOperatorExpression(unaryOperationKind, operand, isLifted, usesOperatorMethod, operatorMethod, _semanticModel, syntax, type, constantValue, isImplicit); } private IBinaryOperatorExpression CreateBoundBinaryOperatorOperation(BoundBinaryOperator boundBinaryOperator) @@ -854,7 +897,8 @@ private IBinaryOperatorExpression CreateBoundBinaryOperatorOperation(BoundBinary ITypeSymbol type = boundBinaryOperator.Type; Optional constantValue = ConvertToOptional(boundBinaryOperator.ConstantValue); bool isLifted = boundBinaryOperator.OperatorKind.IsLifted(); - return new LazyBinaryOperatorExpression(binaryOperationKind, leftOperand, rightOperand, isLifted, usesOperatorMethod, operatorMethod, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundBinaryOperator.WasCompilerGenerated; + return new LazyBinaryOperatorExpression(binaryOperationKind, leftOperand, rightOperand, isLifted, usesOperatorMethod, operatorMethod, _semanticModel, syntax, type, constantValue, isImplicit); } private IConditionalChoiceExpression CreateBoundConditionalOperatorOperation(BoundConditionalOperator boundConditionalOperator) @@ -865,7 +909,8 @@ private IConditionalChoiceExpression CreateBoundConditionalOperatorOperation(Bou SyntaxNode syntax = boundConditionalOperator.Syntax; ITypeSymbol type = boundConditionalOperator.Type; Optional constantValue = ConvertToOptional(boundConditionalOperator.ConstantValue); - return new LazyConditionalChoiceExpression(condition, ifTrueValue, ifFalseValue, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundConditionalOperator.WasCompilerGenerated; + return new LazyConditionalChoiceExpression(condition, ifTrueValue, ifFalseValue, _semanticModel, syntax, type, constantValue, isImplicit); } private INullCoalescingExpression CreateBoundNullCoalescingOperatorOperation(BoundNullCoalescingOperator boundNullCoalescingOperator) @@ -875,7 +920,8 @@ private INullCoalescingExpression CreateBoundNullCoalescingOperatorOperation(Bou SyntaxNode syntax = boundNullCoalescingOperator.Syntax; ITypeSymbol type = boundNullCoalescingOperator.Type; Optional constantValue = ConvertToOptional(boundNullCoalescingOperator.ConstantValue); - return new LazyNullCoalescingExpression(primaryOperand, secondaryOperand, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundNullCoalescingOperator.WasCompilerGenerated; + return new LazyNullCoalescingExpression(primaryOperand, secondaryOperand, _semanticModel, syntax, type, constantValue, isImplicit); } private IAwaitExpression CreateBoundAwaitExpressionOperation(BoundAwaitExpression boundAwaitExpression) @@ -884,7 +930,8 @@ private IAwaitExpression CreateBoundAwaitExpressionOperation(BoundAwaitExpressio SyntaxNode syntax = boundAwaitExpression.Syntax; ITypeSymbol type = boundAwaitExpression.Type; Optional constantValue = ConvertToOptional(boundAwaitExpression.ConstantValue); - return new LazyAwaitExpression(awaitedValue, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundAwaitExpression.WasCompilerGenerated; + return new LazyAwaitExpression(awaitedValue, _semanticModel, syntax, type, constantValue, isImplicit); } private IArrayElementReferenceExpression CreateBoundArrayAccessOperation(BoundArrayAccess boundArrayAccess) @@ -894,7 +941,9 @@ private IArrayElementReferenceExpression CreateBoundArrayAccessOperation(BoundAr SyntaxNode syntax = boundArrayAccess.Syntax; ITypeSymbol type = boundArrayAccess.Type; Optional constantValue = ConvertToOptional(boundArrayAccess.ConstantValue); - return new LazyArrayElementReferenceExpression(arrayReference, indices, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundArrayAccess.WasCompilerGenerated; + + return new LazyArrayElementReferenceExpression(arrayReference, indices, _semanticModel, syntax, type, constantValue, isImplicit); } private IPointerIndirectionReferenceExpression CreateBoundPointerIndirectionOperatorOperation(BoundPointerIndirectionOperator boundPointerIndirectionOperator) @@ -903,7 +952,8 @@ private IPointerIndirectionReferenceExpression CreateBoundPointerIndirectionOper SyntaxNode syntax = boundPointerIndirectionOperator.Syntax; ITypeSymbol type = boundPointerIndirectionOperator.Type; Optional constantValue = ConvertToOptional(boundPointerIndirectionOperator.ConstantValue); - return new LazyPointerIndirectionReferenceExpression(pointer, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundPointerIndirectionOperator.WasCompilerGenerated; + return new LazyPointerIndirectionReferenceExpression(pointer, _semanticModel, syntax, type, constantValue, isImplicit); } private INameOfExpression CreateBoundNameOfOperatorOperation(BoundNameOfOperator boundNameOfOperator) @@ -912,7 +962,8 @@ private INameOfExpression CreateBoundNameOfOperatorOperation(BoundNameOfOperator SyntaxNode syntax = boundNameOfOperator.Syntax; ITypeSymbol type = boundNameOfOperator.Type; Optional constantValue = ConvertToOptional(boundNameOfOperator.ConstantValue); - return new LazyNameOfExpression(argument, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundNameOfOperator.WasCompilerGenerated; + return new LazyNameOfExpression(argument, _semanticModel, syntax, type, constantValue, isImplicit); } private IThrowExpression CreateBoundThrowExpressionOperation(BoundThrowExpression boundThrowExpression) @@ -921,7 +972,8 @@ private IThrowExpression CreateBoundThrowExpressionOperation(BoundThrowExpressio SyntaxNode syntax = boundThrowExpression.Syntax; ITypeSymbol type = boundThrowExpression.Type; Optional constantValue = ConvertToOptional(boundThrowExpression.ConstantValue); - return new LazyThrowExpression(expression, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundThrowExpression.WasCompilerGenerated; + return new LazyThrowExpression(expression, _semanticModel, syntax, type, constantValue, isImplicit); } private IAddressOfExpression CreateBoundAddressOfOperatorOperation(BoundAddressOfOperator boundAddressOfOperator) @@ -930,7 +982,8 @@ private IAddressOfExpression CreateBoundAddressOfOperatorOperation(BoundAddressO SyntaxNode syntax = boundAddressOfOperator.Syntax; ITypeSymbol type = boundAddressOfOperator.Type; Optional constantValue = ConvertToOptional(boundAddressOfOperator.ConstantValue); - return new LazyAddressOfExpression(reference, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundAddressOfOperator.WasCompilerGenerated; + return new LazyAddressOfExpression(reference, _semanticModel, syntax, type, constantValue, isImplicit); } private IInstanceReferenceExpression CreateBoundImplicitReceiverOperation(BoundImplicitReceiver boundImplicitReceiver) @@ -939,7 +992,8 @@ private IInstanceReferenceExpression CreateBoundImplicitReceiverOperation(BoundI SyntaxNode syntax = boundImplicitReceiver.Syntax; ITypeSymbol type = boundImplicitReceiver.Type; Optional constantValue = ConvertToOptional(boundImplicitReceiver.ConstantValue); - return new InstanceReferenceExpression(instanceReferenceKind, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundImplicitReceiver.WasCompilerGenerated; + return new InstanceReferenceExpression(instanceReferenceKind, _semanticModel, syntax, type, constantValue, isImplicit); } private IConditionalAccessExpression CreateBoundConditionalAccessOperation(BoundConditionalAccess boundConditionalAccess) @@ -949,7 +1003,9 @@ private IConditionalAccessExpression CreateBoundConditionalAccessOperation(Bound SyntaxNode syntax = boundConditionalAccess.Syntax; ITypeSymbol type = boundConditionalAccess.Type; Optional constantValue = ConvertToOptional(boundConditionalAccess.ConstantValue); - return new LazyConditionalAccessExpression(conditionalValue, conditionalInstance, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundConditionalAccess.WasCompilerGenerated; + + return new LazyConditionalAccessExpression(conditionalValue, conditionalInstance, _semanticModel, syntax, type, constantValue, isImplicit); } private IConditionalAccessInstanceExpression CreateBoundConditionalReceiverOperation(BoundConditionalReceiver boundConditionalReceiver) @@ -957,7 +1013,8 @@ private IConditionalAccessInstanceExpression CreateBoundConditionalReceiverOpera SyntaxNode syntax = boundConditionalReceiver.Syntax; ITypeSymbol type = boundConditionalReceiver.Type; Optional constantValue = ConvertToOptional(boundConditionalReceiver.ConstantValue); - return new ConditionalAccessInstanceExpression(_semanticModel, syntax, type, constantValue); + bool isImplicit = boundConditionalReceiver.WasCompilerGenerated; + return new ConditionalAccessInstanceExpression(_semanticModel, syntax, type, constantValue, isImplicit); } private IFieldInitializer CreateBoundFieldEqualsValueOperation(BoundFieldEqualsValue boundFieldEqualsValue) @@ -968,7 +1025,8 @@ private IFieldInitializer CreateBoundFieldEqualsValueOperation(BoundFieldEqualsV SyntaxNode syntax = boundFieldEqualsValue.Syntax; ITypeSymbol type = null; Optional constantValue = default(Optional); - return new LazyFieldInitializer(initializedFields, value, kind, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundFieldEqualsValue.WasCompilerGenerated; + return new LazyFieldInitializer(initializedFields, value, kind, _semanticModel, syntax, type, constantValue, isImplicit); } private IPropertyInitializer CreateBoundPropertyEqualsValueOperation(BoundPropertyEqualsValue boundPropertyEqualsValue) @@ -979,7 +1037,8 @@ private IPropertyInitializer CreateBoundPropertyEqualsValueOperation(BoundProper SyntaxNode syntax = boundPropertyEqualsValue.Syntax; ITypeSymbol type = null; Optional constantValue = default(Optional); - return new LazyPropertyInitializer(initializedProperty, value, kind, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundPropertyEqualsValue.WasCompilerGenerated; + return new LazyPropertyInitializer(initializedProperty, value, kind, _semanticModel, syntax, type, constantValue, isImplicit); } private IParameterInitializer CreateBoundParameterEqualsValueOperation(BoundParameterEqualsValue boundParameterEqualsValue) @@ -990,7 +1049,8 @@ private IParameterInitializer CreateBoundParameterEqualsValueOperation(BoundPara SyntaxNode syntax = boundParameterEqualsValue.Syntax; ITypeSymbol type = null; Optional constantValue = default(Optional); - return new LazyParameterInitializer(parameter, value, kind, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundParameterEqualsValue.WasCompilerGenerated; + return new LazyParameterInitializer(parameter, value, kind, _semanticModel, syntax, type, constantValue, isImplicit); } private IBlockStatement CreateBoundBlockOperation(BoundBlock boundBlock) @@ -1002,7 +1062,8 @@ private IBlockStatement CreateBoundBlockOperation(BoundBlock boundBlock) SyntaxNode syntax = boundBlock.Syntax; ITypeSymbol type = null; Optional constantValue = default(Optional); - return new LazyBlockStatement(statements, locals, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundBlock.WasCompilerGenerated; + return new LazyBlockStatement(statements, locals, _semanticModel, syntax, type, constantValue, isImplicit); } private IBranchStatement CreateBoundContinueStatementOperation(BoundContinueStatement boundContinueStatement) @@ -1012,7 +1073,8 @@ private IBranchStatement CreateBoundContinueStatementOperation(BoundContinueStat SyntaxNode syntax = boundContinueStatement.Syntax; ITypeSymbol type = null; Optional constantValue = default(Optional); - return new BranchStatement(target, branchKind, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundContinueStatement.WasCompilerGenerated; + return new BranchStatement(target, branchKind, _semanticModel, syntax, type, constantValue, isImplicit); } private IBranchStatement CreateBoundBreakStatementOperation(BoundBreakStatement boundBreakStatement) @@ -1022,7 +1084,8 @@ private IBranchStatement CreateBoundBreakStatementOperation(BoundBreakStatement SyntaxNode syntax = boundBreakStatement.Syntax; ITypeSymbol type = null; Optional constantValue = default(Optional); - return new BranchStatement(target, branchKind, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundBreakStatement.WasCompilerGenerated; + return new BranchStatement(target, branchKind, _semanticModel, syntax, type, constantValue, isImplicit); } private IReturnStatement CreateBoundYieldBreakStatementOperation(BoundYieldBreakStatement boundYieldBreakStatement) @@ -1031,7 +1094,8 @@ private IReturnStatement CreateBoundYieldBreakStatementOperation(BoundYieldBreak SyntaxNode syntax = boundYieldBreakStatement.Syntax; ITypeSymbol type = null; Optional constantValue = default(Optional); - return new LazyReturnStatement(OperationKind.YieldBreakStatement, returnedValue, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundYieldBreakStatement.WasCompilerGenerated; + return new LazyReturnStatement(OperationKind.YieldBreakStatement, returnedValue, _semanticModel, syntax, type, constantValue, isImplicit); } private IBranchStatement CreateBoundGotoStatementOperation(BoundGotoStatement boundGotoStatement) @@ -1041,7 +1105,8 @@ private IBranchStatement CreateBoundGotoStatementOperation(BoundGotoStatement bo SyntaxNode syntax = boundGotoStatement.Syntax; ITypeSymbol type = null; Optional constantValue = default(Optional); - return new BranchStatement(target, branchKind, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundGotoStatement.WasCompilerGenerated; + return new BranchStatement(target, branchKind, _semanticModel, syntax, type, constantValue, isImplicit); } private IEmptyStatement CreateBoundNoOpStatementOperation(BoundNoOpStatement boundNoOpStatement) @@ -1049,7 +1114,8 @@ private IEmptyStatement CreateBoundNoOpStatementOperation(BoundNoOpStatement bou SyntaxNode syntax = boundNoOpStatement.Syntax; ITypeSymbol type = null; Optional constantValue = default(Optional); - return new EmptyStatement(_semanticModel, syntax, type, constantValue); + bool isImplicit = boundNoOpStatement.WasCompilerGenerated; + return new EmptyStatement(_semanticModel, syntax, type, constantValue, isImplicit); } private IIfStatement CreateBoundIfStatementOperation(BoundIfStatement boundIfStatement) @@ -1060,7 +1126,8 @@ private IIfStatement CreateBoundIfStatementOperation(BoundIfStatement boundIfSta SyntaxNode syntax = boundIfStatement.Syntax; ITypeSymbol type = null; Optional constantValue = default(Optional); - return new LazyIfStatement(condition, ifTrueStatement, ifFalseStatement, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundIfStatement.WasCompilerGenerated; + return new LazyIfStatement(condition, ifTrueStatement, ifFalseStatement, _semanticModel, syntax, type, constantValue, isImplicit); } private IWhileUntilLoopStatement CreateBoundWhileStatementOperation(BoundWhileStatement boundWhileStatement) @@ -1073,7 +1140,8 @@ private IWhileUntilLoopStatement CreateBoundWhileStatementOperation(BoundWhileSt SyntaxNode syntax = boundWhileStatement.Syntax; ITypeSymbol type = null; Optional constantValue = default(Optional); - return new LazyWhileUntilLoopStatement(isTopTest, isWhile, condition, loopKind, body, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundWhileStatement.WasCompilerGenerated; + return new LazyWhileUntilLoopStatement(isTopTest, isWhile, condition, loopKind, body, _semanticModel, syntax, type, constantValue, isImplicit); } private IWhileUntilLoopStatement CreateBoundDoStatementOperation(BoundDoStatement boundDoStatement) @@ -1086,7 +1154,8 @@ private IWhileUntilLoopStatement CreateBoundDoStatementOperation(BoundDoStatemen SyntaxNode syntax = boundDoStatement.Syntax; ITypeSymbol type = null; Optional constantValue = default(Optional); - return new LazyWhileUntilLoopStatement(isTopTest, isWhile, condition, loopKind, body, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundDoStatement.WasCompilerGenerated; + return new LazyWhileUntilLoopStatement(isTopTest, isWhile, condition, loopKind, body, _semanticModel, syntax, type, constantValue, isImplicit); } private IForLoopStatement CreateBoundForStatementOperation(BoundForStatement boundForStatement) @@ -1100,7 +1169,8 @@ private IForLoopStatement CreateBoundForStatementOperation(BoundForStatement bou SyntaxNode syntax = boundForStatement.Syntax; ITypeSymbol type = null; Optional constantValue = default(Optional); - return new LazyForLoopStatement(before, atLoopBottom, locals, condition, loopKind, body, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundForStatement.WasCompilerGenerated; + return new LazyForLoopStatement(before, atLoopBottom, locals, condition, loopKind, body, _semanticModel, syntax, type, constantValue, isImplicit); } private IForEachLoopStatement CreateBoundForEachStatementOperation(BoundForEachStatement boundForEachStatement) @@ -1114,7 +1184,8 @@ private IForEachLoopStatement CreateBoundForEachStatementOperation(BoundForEachS SyntaxNode syntax = boundForEachStatement.Syntax; ITypeSymbol type = null; Optional constantValue = default(Optional); - return new LazyForEachLoopStatement(iterationVariable, collection, loopKind, body, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundForEachStatement.WasCompilerGenerated; + return new LazyForEachLoopStatement(iterationVariable, collection, loopKind, body, _semanticModel, syntax, type, constantValue, isImplicit); } private ISwitchStatement CreateBoundSwitchStatementOperation(BoundSwitchStatement boundSwitchStatement) @@ -1124,7 +1195,8 @@ private ISwitchStatement CreateBoundSwitchStatementOperation(BoundSwitchStatemen SyntaxNode syntax = boundSwitchStatement.Syntax; ITypeSymbol type = null; Optional constantValue = default(Optional); - return new LazySwitchStatement(value, cases, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundSwitchStatement.WasCompilerGenerated; + return new LazySwitchStatement(value, cases, _semanticModel, syntax, type, constantValue, isImplicit); } private ICaseClause CreateBoundSwitchLabelOperation(BoundSwitchLabel boundSwitchLabel) @@ -1132,16 +1204,17 @@ private ICaseClause CreateBoundSwitchLabelOperation(BoundSwitchLabel boundSwitch SyntaxNode syntax = boundSwitchLabel.Syntax; ITypeSymbol type = null; Optional constantValue = default(Optional); + bool isImplicit = boundSwitchLabel.WasCompilerGenerated; if (boundSwitchLabel.ExpressionOpt != null) { Lazy value = new Lazy(() => Create(boundSwitchLabel.ExpressionOpt)); BinaryOperationKind equality = GetLabelEqualityKind(boundSwitchLabel); - return new LazySingleValueCaseClause(value, equality, CaseKind.SingleValue, _semanticModel, syntax, type, constantValue); + return new LazySingleValueCaseClause(value, equality, CaseKind.SingleValue, _semanticModel, syntax, type, constantValue, isImplicit); } else { - return new DefaultCaseClause(_semanticModel, syntax, type, constantValue); + return new DefaultCaseClause(_semanticModel, syntax, type, constantValue, isImplicit); } } @@ -1153,7 +1226,8 @@ private ITryStatement CreateBoundTryStatementOperation(BoundTryStatement boundTr SyntaxNode syntax = boundTryStatement.Syntax; ITypeSymbol type = null; Optional constantValue = default(Optional); - return new LazyTryStatement(body, catches, finallyHandler, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundTryStatement.WasCompilerGenerated; + return new LazyTryStatement(body, catches, finallyHandler, _semanticModel, syntax, type, constantValue, isImplicit); } private ICatchClause CreateBoundCatchBlockOperation(BoundCatchBlock boundCatchBlock) @@ -1165,7 +1239,8 @@ private ICatchClause CreateBoundCatchBlockOperation(BoundCatchBlock boundCatchBl SyntaxNode syntax = boundCatchBlock.Syntax; ITypeSymbol type = null; Optional constantValue = default(Optional); - return new LazyCatchClause(handler, caughtType, filter, exceptionLocal, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundCatchBlock.WasCompilerGenerated; + return new LazyCatchClause(handler, caughtType, filter, exceptionLocal, _semanticModel, syntax, type, constantValue, isImplicit); } private IFixedStatement CreateBoundFixedStatementOperation(BoundFixedStatement boundFixedStatement) @@ -1175,7 +1250,8 @@ private IFixedStatement CreateBoundFixedStatementOperation(BoundFixedStatement b SyntaxNode syntax = boundFixedStatement.Syntax; ITypeSymbol type = null; Optional constantValue = default(Optional); - return new LazyFixedStatement(variables, body, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundFixedStatement.WasCompilerGenerated; + return new LazyFixedStatement(variables, body, _semanticModel, syntax, type, constantValue, isImplicit); } private IUsingStatement CreateBoundUsingStatementOperation(BoundUsingStatement boundUsingStatement) @@ -1186,7 +1262,8 @@ private IUsingStatement CreateBoundUsingStatementOperation(BoundUsingStatement b SyntaxNode syntax = boundUsingStatement.Syntax; ITypeSymbol type = null; Optional constantValue = default(Optional); - return new LazyUsingStatement(body, declaration, value, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundUsingStatement.WasCompilerGenerated; + return new LazyUsingStatement(body, declaration, value, _semanticModel, syntax, type, constantValue, isImplicit); } private IThrowStatement CreateBoundThrowStatementOperation(BoundThrowStatement boundThrowStatement) @@ -1195,7 +1272,8 @@ private IThrowStatement CreateBoundThrowStatementOperation(BoundThrowStatement b SyntaxNode syntax = boundThrowStatement.Syntax; ITypeSymbol type = null; Optional constantValue = default(Optional); - return new LazyThrowStatement(thrownObject, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundThrowStatement.WasCompilerGenerated; + return new LazyThrowStatement(thrownObject, _semanticModel, syntax, type, constantValue, isImplicit); } private IReturnStatement CreateBoundReturnStatementOperation(BoundReturnStatement boundReturnStatement) @@ -1204,7 +1282,8 @@ private IReturnStatement CreateBoundReturnStatementOperation(BoundReturnStatemen SyntaxNode syntax = boundReturnStatement.Syntax; ITypeSymbol type = null; Optional constantValue = default(Optional); - return new LazyReturnStatement(OperationKind.ReturnStatement, returnedValue, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundReturnStatement.WasCompilerGenerated; + return new LazyReturnStatement(OperationKind.ReturnStatement, returnedValue, _semanticModel, syntax, type, constantValue, isImplicit); } private IReturnStatement CreateBoundYieldReturnStatementOperation(BoundYieldReturnStatement boundYieldReturnStatement) @@ -1213,7 +1292,8 @@ private IReturnStatement CreateBoundYieldReturnStatementOperation(BoundYieldRetu SyntaxNode syntax = boundYieldReturnStatement.Syntax; ITypeSymbol type = null; Optional constantValue = default(Optional); - return new LazyReturnStatement(OperationKind.YieldReturnStatement, returnedValue, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundYieldReturnStatement.WasCompilerGenerated; + return new LazyReturnStatement(OperationKind.YieldReturnStatement, returnedValue, _semanticModel, syntax, type, constantValue, isImplicit); } private ILockStatement CreateBoundLockStatementOperation(BoundLockStatement boundLockStatement) @@ -1223,7 +1303,9 @@ private ILockStatement CreateBoundLockStatementOperation(BoundLockStatement boun SyntaxNode syntax = boundLockStatement.Syntax; ITypeSymbol type = null; Optional constantValue = default(Optional); - return new LazyLockStatement(lockedObject, body, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundLockStatement.WasCompilerGenerated; + + return new LazyLockStatement(lockedObject, body, _semanticModel, syntax, type, constantValue, isImplicit); } private IInvalidStatement CreateBoundBadStatementOperation(BoundBadStatement boundBadStatement) @@ -1232,7 +1314,8 @@ private IInvalidStatement CreateBoundBadStatementOperation(BoundBadStatement bou SyntaxNode syntax = boundBadStatement.Syntax; ITypeSymbol type = null; Optional constantValue = default(Optional); - return new LazyInvalidStatement(children, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundBadStatement.WasCompilerGenerated; + return new LazyInvalidStatement(children, _semanticModel, syntax, type, constantValue, isImplicit); } private IVariableDeclaration CreateVariableDeclaration(BoundLocalDeclaration boundLocalDeclaration) @@ -1250,7 +1333,8 @@ private IVariableDeclarationStatement CreateBoundLocalDeclarationOperation(Bound SyntaxNode syntax = boundLocalDeclaration.Syntax; ITypeSymbol type = null; Optional constantValue = default(Optional); - return new LazyVariableDeclarationStatement(declarations, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundLocalDeclaration.WasCompilerGenerated; + return new LazyVariableDeclarationStatement(declarations, _semanticModel, syntax, type, constantValue, isImplicit); } private IVariableDeclarationStatement CreateBoundMultipleLocalDeclarationsOperation(BoundMultipleLocalDeclarations boundMultipleLocalDeclarations) @@ -1260,7 +1344,8 @@ private IVariableDeclarationStatement CreateBoundMultipleLocalDeclarationsOperat SyntaxNode syntax = boundMultipleLocalDeclarations.Syntax; ITypeSymbol type = null; Optional constantValue = default(Optional); - return new LazyVariableDeclarationStatement(declarations, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundMultipleLocalDeclarations.WasCompilerGenerated; + return new LazyVariableDeclarationStatement(declarations, _semanticModel, syntax, type, constantValue, isImplicit); } private ILabelStatement CreateBoundLabelStatementOperation(BoundLabelStatement boundLabelStatement) @@ -1270,7 +1355,8 @@ private ILabelStatement CreateBoundLabelStatementOperation(BoundLabelStatement b SyntaxNode syntax = boundLabelStatement.Syntax; ITypeSymbol type = null; Optional constantValue = default(Optional); - return new LazyLabelStatement(label, labeledStatement, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundLabelStatement.WasCompilerGenerated; + return new LazyLabelStatement(label, labeledStatement, _semanticModel, syntax, type, constantValue, isImplicit); } private ILabelStatement CreateBoundLabeledStatementOperation(BoundLabeledStatement boundLabeledStatement) @@ -1280,7 +1366,8 @@ private ILabelStatement CreateBoundLabeledStatementOperation(BoundLabeledStateme SyntaxNode syntax = boundLabeledStatement.Syntax; ITypeSymbol type = null; Optional constantValue = default(Optional); - return new LazyLabelStatement(label, labeledStatement, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundLabeledStatement.WasCompilerGenerated; + return new LazyLabelStatement(label, labeledStatement, _semanticModel, syntax, type, constantValue, isImplicit); } private IExpressionStatement CreateBoundExpressionStatementOperation(BoundExpressionStatement boundExpressionStatement) @@ -1289,7 +1376,8 @@ private IExpressionStatement CreateBoundExpressionStatementOperation(BoundExpres SyntaxNode syntax = boundExpressionStatement.Syntax; ITypeSymbol type = null; Optional constantValue = default(Optional); - return new LazyExpressionStatement(expression, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundExpressionStatement.WasCompilerGenerated; + return new LazyExpressionStatement(expression, _semanticModel, syntax, type, constantValue, isImplicit); } private ITupleExpression CreateBoundTupleExpressionOperation(BoundTupleExpression boundTupleExpression) @@ -1298,7 +1386,8 @@ private ITupleExpression CreateBoundTupleExpressionOperation(BoundTupleExpressio SyntaxNode syntax = boundTupleExpression.Syntax; ITypeSymbol type = boundTupleExpression.Type; Optional constantValue = default(Optional); - return new LazyTupleExpression(elements, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundTupleExpression.WasCompilerGenerated; + return new LazyTupleExpression(elements, _semanticModel, syntax, type, constantValue, isImplicit); } private IInterpolatedStringExpression CreateBoundInterpolatedStringExpressionOperation(BoundInterpolatedString boundInterpolatedString) @@ -1308,7 +1397,8 @@ private IInterpolatedStringExpression CreateBoundInterpolatedStringExpressionOpe SyntaxNode syntax = boundInterpolatedString.Syntax; ITypeSymbol type = boundInterpolatedString.Type; Optional constantValue = ConvertToOptional(boundInterpolatedString.ConstantValue); - return new LazyInterpolatedStringExpression(parts, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundInterpolatedString.WasCompilerGenerated; + return new LazyInterpolatedStringExpression(parts, _semanticModel, syntax, type, constantValue, isImplicit); } private IInterpolatedStringContent CreateBoundInterpolatedStringContentOperation(BoundNode boundNode) @@ -1331,7 +1421,8 @@ private IInterpolation CreateBoundInterpolationOperation(BoundStringInsert bound SyntaxNode syntax = boundStringInsert.Syntax; ITypeSymbol type = null; Optional constantValue = default(Optional); - return new LazyInterpolation(expression, alignment, format, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundStringInsert.WasCompilerGenerated; + return new LazyInterpolation(expression, alignment, format, _semanticModel, syntax, type, constantValue, isImplicit); } private IInterpolatedStringText CreateBoundInterpolatedStringTextOperation(BoundNode boundNode) @@ -1340,7 +1431,8 @@ private IInterpolatedStringText CreateBoundInterpolatedStringTextOperation(Bound SyntaxNode syntax = boundNode.Syntax; ITypeSymbol type = null; Optional constantValue = default(Optional); - return new LazyInterpolatedStringText(text, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundNode.WasCompilerGenerated; + return new LazyInterpolatedStringText(text, _semanticModel, syntax, type, constantValue, isImplicit); } private IConstantPattern CreateBoundConstantPatternOperation(BoundConstantPattern boundConstantPattern) @@ -1349,7 +1441,8 @@ private IConstantPattern CreateBoundConstantPatternOperation(BoundConstantPatter SyntaxNode syntax = boundConstantPattern.Syntax; ITypeSymbol type = null; Optional constantValue = default(Optional); - return new LazyConstantPattern(value, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundConstantPattern.WasCompilerGenerated; + return new LazyConstantPattern(value, _semanticModel, syntax, type, constantValue, isImplicit); } private IDeclarationPattern CreateBoundDeclarationPatternOperation(BoundDeclarationPattern boundDeclarationPattern) @@ -1358,7 +1451,8 @@ private IDeclarationPattern CreateBoundDeclarationPatternOperation(BoundDeclarat SyntaxNode syntax = boundDeclarationPattern.Syntax; ITypeSymbol type = null; Optional constantValue = default(Optional); - return new DeclarationPattern(variable, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundDeclarationPattern.WasCompilerGenerated; + return new DeclarationPattern(variable, _semanticModel, syntax, type, constantValue, isImplicit); } private ISwitchStatement CreateBoundPatternSwitchStatementOperation(BoundPatternSwitchStatement boundPatternSwitchStatement) @@ -1368,7 +1462,8 @@ private ISwitchStatement CreateBoundPatternSwitchStatementOperation(BoundPattern SyntaxNode syntax = boundPatternSwitchStatement.Syntax; ITypeSymbol type = null; Optional constantValue = default(Optional); - return new LazySwitchStatement(value, cases, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundPatternSwitchStatement.WasCompilerGenerated; + return new LazySwitchStatement(value, cases, _semanticModel, syntax, type, constantValue, isImplicit); } private ICaseClause CreateBoundPatternSwitchLabelOperation(BoundPatternSwitchLabel boundPatternSwitchLabel) @@ -1376,18 +1471,19 @@ private ICaseClause CreateBoundPatternSwitchLabelOperation(BoundPatternSwitchLab SyntaxNode syntax = boundPatternSwitchLabel.Syntax; ITypeSymbol type = null; Optional constantValue = default(Optional); + bool isImplicit = boundPatternSwitchLabel.WasCompilerGenerated; if (boundPatternSwitchLabel.Pattern.Kind == BoundKind.WildcardPattern) { // Default switch label in pattern switch statement is represented as a default case clause. - return new DefaultCaseClause(_semanticModel, syntax, type, constantValue); + return new DefaultCaseClause(_semanticModel, syntax, type, constantValue, isImplicit); } else { LabelSymbol label = boundPatternSwitchLabel.Label; Lazy pattern = new Lazy(() => (IPattern)Create(boundPatternSwitchLabel.Pattern)); Lazy guardExpression = new Lazy(() => Create(boundPatternSwitchLabel.Guard)); - return new LazyPatternCaseClause(label, pattern, guardExpression, _semanticModel, syntax, type, constantValue); + return new LazyPatternCaseClause(label, pattern, guardExpression, _semanticModel, syntax, type, constantValue, isImplicit); } } @@ -1398,7 +1494,8 @@ private IIsPatternExpression CreateBoundIsPatternExpressionOperation(BoundIsPatt SyntaxNode syntax = boundIsPatternExpression.Syntax; ITypeSymbol type = boundIsPatternExpression.Type; Optional constantValue = ConvertToOptional(boundIsPatternExpression.ConstantValue); - return new LazyIsPatternExpression(expression, pattern, _semanticModel, syntax, type, constantValue); + bool isImplicit = boundIsPatternExpression.WasCompilerGenerated; + return new LazyIsPatternExpression(expression, pattern, _semanticModel, syntax, type, constantValue, isImplicit); } } } diff --git a/src/Compilers/CSharp/Portable/Operations/CSharpOperationFactory_Methods.cs b/src/Compilers/CSharp/Portable/Operations/CSharpOperationFactory_Methods.cs index b4d36118c6d79..3b5140ee35a49 100644 --- a/src/Compilers/CSharp/Portable/Operations/CSharpOperationFactory_Methods.cs +++ b/src/Compilers/CSharp/Portable/Operations/CSharpOperationFactory_Methods.cs @@ -44,7 +44,8 @@ internal IArgument CreateArgumentOperation(ArgumentKind kind, IParameterSymbol p semanticModel: _semanticModel, syntax: value.Syntax, type: value.Type, - constantValue: default); + constantValue: default, + isImplicit: expression.WasCompilerGenerated); } private ImmutableArray DeriveArguments( @@ -116,7 +117,7 @@ private ImmutableArray GetAnonymousObjectCreationInitializers(BoundA SyntaxNode syntax = value.Syntax?.Parent ?? expression.Syntax; ITypeSymbol type = target.Type; Optional constantValue = value.ConstantValue; - var assignment = new SimpleAssignmentExpression(target, value, _semanticModel, syntax, type, constantValue); + var assignment = new SimpleAssignmentExpression(target, value, _semanticModel, syntax, type, constantValue, isImplicit: value.IsImplicit); builder.Add(assignment); } @@ -188,7 +189,7 @@ private ImmutableArray GetSwitchStatementCases(BoundSwitchStatement var clauses = switchSection.SwitchLabels.SelectAsArray(s => (ICaseClause)Create(s)); var body = switchSection.Statements.SelectAsArray(s => Create(s)); - return (ISwitchCase)new SwitchCase(clauses, body, _semanticModel, switchSection.Syntax, type: null, constantValue: default(Optional)); + return (ISwitchCase)new SwitchCase(clauses, body, _semanticModel, switchSection.Syntax, type: null, constantValue: default(Optional), isImplicit: switchSection.WasCompilerGenerated); }); } @@ -199,7 +200,7 @@ private ImmutableArray GetPatternSwitchStatementCases(BoundPatternS var clauses = switchSection.SwitchLabels.SelectAsArray(s => (ICaseClause)Create(s)); var body = switchSection.Statements.SelectAsArray(s => Create(s)); - return (ISwitchCase)new SwitchCase(clauses, body, _semanticModel, switchSection.Syntax, type: null, constantValue: default(Optional)); + return (ISwitchCase)new SwitchCase(clauses, body, _semanticModel, switchSection.Syntax, type: null, constantValue: default(Optional), isImplicit: switchSection.WasCompilerGenerated); }); } diff --git a/src/Compilers/CSharp/Test/CommandLine/CommandLineTests.cs b/src/Compilers/CSharp/Test/CommandLine/CommandLineTests.cs index 5edbb6940f8c7..adafe9cc93ef6 100644 --- a/src/Compilers/CSharp/Test/CommandLine/CommandLineTests.cs +++ b/src/Compilers/CSharp/Test/CommandLine/CommandLineTests.cs @@ -22,6 +22,8 @@ using Microsoft.CodeAnalysis.Emit; using Microsoft.CodeAnalysis.Test.Utilities; using Microsoft.CodeAnalysis.Text; +using Microsoft.DiaSymReader; +using Roslyn.Test.PdbUtilities; using Roslyn.Test.Utilities; using Roslyn.Utilities; using Xunit; @@ -1898,18 +1900,14 @@ public void Embed() parsedArgs = DefaultParse(new[] { "/embed:a.txt", "/debug-", "a.cs" }, _baseDirectory); parsedArgs.Errors.Verify(Diagnostic(ErrorCode.ERR_CannotEmbedWithoutPdb)); - // These should fail when native PDB support is added. parsedArgs = DefaultParse(new[] { "/embed", "/debug:full", "a.cs" }, _baseDirectory); - parsedArgs.Errors.Verify(Diagnostic(ErrorCode.ERR_CannotEmbedWithoutPdb)); - - parsedArgs = DefaultParse(new[] { "/embed", "/debug:full", "a.cs" }, _baseDirectory); - parsedArgs.Errors.Verify(Diagnostic(ErrorCode.ERR_CannotEmbedWithoutPdb)); + parsedArgs.Errors.Verify(); parsedArgs = DefaultParse(new[] { "/embed", "/debug:pdbonly", "a.cs" }, _baseDirectory); - parsedArgs.Errors.Verify(Diagnostic(ErrorCode.ERR_CannotEmbedWithoutPdb)); + parsedArgs.Errors.Verify(); parsedArgs = DefaultParse(new[] { "/embed", "/debug+", "a.cs" }, _baseDirectory); - parsedArgs.Errors.Verify(Diagnostic(ErrorCode.ERR_CannotEmbedWithoutPdb)); + parsedArgs.Errors.Verify(); } [Theory] @@ -1921,7 +1919,7 @@ public void Embed() [InlineData("/debug:embedded", "/embed:embed.cs", new[] { "embed.cs", "embed.xyz" })] [InlineData("/debug:embedded", "/embed:embed2.cs", new[] { "embed2.cs" })] [InlineData("/debug:embedded", "/embed:embed.xyz", new[] {"embed.xyz" })] - public void Embed_EndToEnd(string debugSwitch, string embedSwitch, string[] expectedEmbedded) + public void Embed_EndToEnd_Portable(string debugSwitch, string embedSwitch, string[] expectedEmbedded) { // embed.cs: large enough to compress, has #line directives const string embed_cs = @@ -1981,14 +1979,32 @@ class Program { int exitCode = csc.Run(output); Assert.Equal("", output.ToString().Trim()); Assert.Equal(0, exitCode); - - bool embedded = debugSwitch == "/debug:embedded"; + + switch (debugSwitch) + { + case "/debug:embedded": + ValidateEmbeddedSources_Portable(expectedEmbeddedMap, dir, isEmbeddedPdb: true); + break; + case "/debug:portable": + ValidateEmbeddedSources_Portable(expectedEmbeddedMap, dir, isEmbeddedPdb: false); + break; + case "/debug:full": + ValidateEmbeddedSources_Windows(expectedEmbeddedMap, dir); + break; + } + + Assert.Empty(expectedEmbeddedMap); + CleanupAllGeneratedFiles(src.Path); + } + + private static void ValidateEmbeddedSources_Portable(Dictionary expectedEmbeddedMap, TempDirectory dir, bool isEmbeddedPdb) + { using (var peReader = new PEReader(File.OpenRead(Path.Combine(dir.Path, "embed.exe")))) { var entry = peReader.ReadDebugDirectory().SingleOrDefault(e => e.Type == DebugDirectoryEntryType.EmbeddedPortablePdb); - Assert.Equal(embedded, entry.DataSize > 0); + Assert.Equal(isEmbeddedPdb, entry.DataSize > 0); - using (var mdProvider = embedded ? + using (var mdProvider = isEmbeddedPdb ? peReader.ReadEmbeddedPortablePdbDebugDirectoryData(entry) : MetadataReaderProvider.FromPortablePdbStream(File.OpenRead(Path.Combine(dir.Path, "embed.pdb")))) { @@ -2011,9 +2027,36 @@ class Program { } } } + } - Assert.Empty(expectedEmbeddedMap); - CleanupAllGeneratedFiles(src.Path); + private static void ValidateEmbeddedSources_Windows(Dictionary expectedEmbeddedMap, TempDirectory dir) + { + ISymUnmanagedReader5 symReader = null; + + try + { + symReader = SymReaderFactory.CreateReader(File.OpenRead(Path.Combine(dir.Path, "embed.pdb"))); + + foreach (var doc in symReader.GetDocuments()) + { + var docPath = doc.GetName(); + + var sourceBlob = doc.GetEmbeddedSource(); + if (sourceBlob.Array == null) + { + continue; + } + + var sourceStr = Encoding.UTF8.GetString(sourceBlob.Array, sourceBlob.Offset, sourceBlob.Count); + + Assert.Equal(expectedEmbeddedMap[docPath], sourceStr); + Assert.True(expectedEmbeddedMap.Remove(docPath)); + } + } + catch + { + symReader?.Dispose(); + } } [Fact] diff --git a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenClosureLambdaTests.cs b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenClosureLambdaTests.cs index 434f863cea41a..3a544712af69d 100644 --- a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenClosureLambdaTests.cs +++ b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenClosureLambdaTests.cs @@ -11,6 +11,53 @@ namespace Microsoft.CodeAnalysis.CSharp.UnitTests.CodeGen { public class CodeGenClosureLambdaTests : CSharpTestBase { + [Fact] + public void EnvironmentChainContainsUnusedEnvironment() + { + CompileAndVerify(@" +using System; +class C +{ + void M(int x) + { + { + int y = 10; + Action f1 = () => Console.WriteLine(y); + + { + int z = 5; + Action f2 = () => Console.WriteLine(z + x); + f2(); + } + f1(); + } + } + public static void Main() => new C().M(3); +}", expectedOutput: @"8 +10"); + } + + [Fact] + public void CaptureThisAsFramePointer() + { + var comp = @" +using System; +using System.Collections.Generic; + +class C +{ + int _z = 0; + void M(IEnumerable xs) + { + foreach (var x in xs) + { + Func captureFunc = k => x + _z; + } + } +}"; + CompileAndVerify(comp); + } + [Fact] public void StaticClosure01() { @@ -3655,8 +3702,8 @@ .maxstack 2 IL_000d: ldarg.0 IL_000e: call ""bool Program.c1.T()"" IL_0013: brfalse.s IL_002e - IL_0015: ldarg.0 - IL_0016: ldftn ""bool Program.c1.b__1_0(int)"" + IL_0015: ldloc.0 + IL_0016: ldftn ""bool Program.c1.<>c__DisplayClass1_0.b__0(int)"" IL_001c: newobj ""System.Func..ctor(object, System.IntPtr)"" IL_0021: ldc.i4.s 42 IL_0023: callvirt ""bool System.Func.Invoke(int)"" diff --git a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenLocalFunctionTests.cs b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenLocalFunctionTests.cs index 39818e6069820..95631d9d75a73 100644 --- a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenLocalFunctionTests.cs +++ b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenLocalFunctionTests.cs @@ -30,6 +30,98 @@ public static IMethodSymbol FindLocalFunction(this CompilationVerifier verifier, [CompilerTrait(CompilerFeature.LocalFunctions)] public class CodeGenLocalFunctionTests : CSharpTestBase { + [Fact] + public void EnvironmentChainContainsStructEnvironment() + { + CompileAndVerify(@" +using System; +class C +{ + void M(int x) + { + { + int y = 10; + void L() => Console.WriteLine(y); + + { + int z = 5; + Action f2 = () => Console.WriteLine(z + x); + f2(); + } + L(); + } + } + public static void Main() => new C().M(3); +}", expectedOutput: @"8 +10"); + } + + [Fact] + public void Repro20577() + { + var comp = CreateStandardCompilation(@" +using System.Linq; + +public class Program { + public static void Main(string[] args) { + object v; + + void AAA() { + object BBB(object v2) { + var a = v; + ((object[])v2).Select(i => BBB(i)); + return null; + } + } + } +}", references: new[] { LinqAssemblyRef }); + CompileAndVerify(comp); + } + + [Fact] + public void Repro19033() + { + CompileAndVerify(@" +using System; + +class Program +{ + void Q(int n = 0) + { + { + object mc; + + string B(object map) + { + Action a = _ => B(new object()); + return n.ToString(); + } + } + } +}"); + } + + [Fact] + public void Repro19033_2() + { + CompileAndVerify(@" +using System; +class C +{ + static void F(Action a) + { + object x = null; + { + object y = null; + void G(object z) + { + F(() => G(x)); + } + } + } +}"); + } + [Fact] [WorkItem(18814, "https://github.com/dotnet/roslyn/issues/18814")] [WorkItem(18918, "https://github.com/dotnet/roslyn/issues/18918")] @@ -78,7 +170,7 @@ void L5() 1"); verifier.VerifyIL("C.M()", @" { - // Code size 46 (0x2e) + // Code size 47 (0x2f) .maxstack 2 .locals init (C.<>c__DisplayClass2_0 V_0) //CS$<>8__locals0 IL_0000: ldloca.s V_0 @@ -90,24 +182,24 @@ .maxstack 2 IL_0010: ldarg.0 IL_0011: ldfld ""int C._x"" IL_0016: call ""void System.Console.WriteLine(int)"" - IL_001b: ldloca.s V_0 - IL_001d: call ""void C.g__L12_0(ref C.<>c__DisplayClass2_0)"" - IL_0022: ldarg.0 - IL_0023: ldfld ""int C._x"" - IL_0028: call ""void System.Console.WriteLine(int)"" - IL_002d: ret + IL_001b: ldarg.0 + IL_001c: ldloca.s V_0 + IL_001e: call ""void C.g__L12_0(ref C.<>c__DisplayClass2_0)"" + IL_0023: ldarg.0 + IL_0024: ldfld ""int C._x"" + IL_0029: call ""void System.Console.WriteLine(int)"" + IL_002e: ret }"); // L1 verifier.VerifyIL("C.g__L12_0(ref C.<>c__DisplayClass2_0)", @" { - // Code size 13 (0xd) + // Code size 8 (0x8) .maxstack 2 IL_0000: ldarg.0 - IL_0001: ldfld ""C C.<>c__DisplayClass2_0.<>4__this"" - IL_0006: ldarg.0 - IL_0007: call ""void C.g__L22_1(ref C.<>c__DisplayClass2_0)"" - IL_000c: ret + IL_0001: ldarg.1 + IL_0002: call ""void C.g__L22_1(ref C.<>c__DisplayClass2_0)"" + IL_0007: ret }"); // L2 verifier.VerifyIL("C.g__L22_1(ref C.<>c__DisplayClass2_0)", @" @@ -122,35 +214,34 @@ .maxstack 2 // Skip some... L5 verifier.VerifyIL("C.g__L52_4(ref C.<>c__DisplayClass2_0, ref C.<>c__DisplayClass2_1)", @" { - // Code size 9 (0x9) - .maxstack 2 + // Code size 10 (0xa) + .maxstack 3 IL_0000: ldarg.0 IL_0001: ldarg.1 - IL_0002: call ""int C.g__L62_5(ref C.<>c__DisplayClass2_0, ref C.<>c__DisplayClass2_1)"" - IL_0007: pop - IL_0008: ret + IL_0002: ldarg.2 + IL_0003: call ""int C.g__L62_5(ref C.<>c__DisplayClass2_0, ref C.<>c__DisplayClass2_1)"" + IL_0008: pop + IL_0009: ret }"); // L6 verifier.VerifyIL("C.g__L62_5(ref C.<>c__DisplayClass2_0, ref C.<>c__DisplayClass2_1)", @" { - // Code size 35 (0x23) + // Code size 25 (0x19) .maxstack 4 .locals init (int V_0) - IL_0000: ldarg.1 + IL_0000: ldarg.2 IL_0001: ldfld ""int C.<>c__DisplayClass2_1.var2"" - IL_0006: ldarg.1 - IL_0007: ldfld ""C C.<>c__DisplayClass2_1.<>4__this"" - IL_000c: ldarg.1 - IL_000d: ldfld ""C C.<>c__DisplayClass2_1.<>4__this"" - IL_0012: ldfld ""int C._x"" - IL_0017: stloc.0 - IL_0018: ldloc.0 - IL_0019: ldc.i4.1 - IL_001a: add - IL_001b: stfld ""int C._x"" - IL_0020: ldloc.0 - IL_0021: add - IL_0022: ret + IL_0006: ldarg.0 + IL_0007: ldarg.0 + IL_0008: ldfld ""int C._x"" + IL_000d: stloc.0 + IL_000e: ldloc.0 + IL_000f: ldc.i4.1 + IL_0010: add + IL_0011: stfld ""int C._x"" + IL_0016: ldloc.0 + IL_0017: add + IL_0018: ret }"); } diff --git a/src/Compilers/CSharp/Test/Emit/Emit/EditAndContinue/EditAndContinueClosureTests.cs b/src/Compilers/CSharp/Test/Emit/Emit/EditAndContinue/EditAndContinueClosureTests.cs index bea69b33f55b3..748e6c12d1ca5 100644 --- a/src/Compilers/CSharp/Test/Emit/Emit/EditAndContinue/EditAndContinueClosureTests.cs +++ b/src/Compilers/CSharp/Test/Emit/Emit/EditAndContinue/EditAndContinueClosureTests.cs @@ -1408,8 +1408,8 @@ public int F() var reader0 = md0.MetadataReader; CheckNames(reader0, reader0.GetTypeDefNames(), "", "C", "<>c__DisplayClass0_0", "<>c"); - CheckNames(reader0, reader0.GetMethodDefNames(), "F", ".ctor", "b__0_1", ".ctor", "b__2", ".cctor", ".ctor", "b__0_0"); - CheckNames(reader0, reader0.GetFieldDefNames(), "a", "<>9", "<>9__0_0"); + CheckNames(reader0, reader0.GetMethodDefNames(), "F", ".ctor", ".ctor", "b__1", "b__2", ".cctor", ".ctor", "b__0_0"); + CheckNames(reader0, reader0.GetFieldDefNames(), "<>4__this", "a", "<>9", "<>9__0_0"); var generation0 = EmitBaseline.CreateInitialBaseline(md0, v0.CreateSymReader().GetEncMethodDebugInfo); var diff1 = compilation1.EmitDifference( @@ -1420,13 +1420,13 @@ public int F() var reader1 = diff1.GetMetadata().Reader; CheckNames(new[] { reader0, reader1 }, reader1.GetTypeDefNames(), "<>c__DisplayClass0#1_0#1"); - CheckNames(new[] { reader0, reader1 }, reader1.GetMethodDefNames(), ".ctor", "F", "b__0#1_1#1", ".ctor", "b__2#1", "b__0#1_0#1"); - CheckNames(new[] { reader0, reader1 }, reader1.GetFieldDefNames(), "a", "<>9__0#1_0#1"); + CheckNames(new[] { reader0, reader1 }, reader1.GetMethodDefNames(), ".ctor", "F", ".ctor", "b__1#1", "b__2#1", "b__0#1_0#1"); + CheckNames(new[] { reader0, reader1 }, reader1.GetFieldDefNames(), "<>4__this", "a", "<>9__0#1_0#1"); diff1.VerifySynthesizedMembers( - "C: {b__0#1_1#1, <>c__DisplayClass0#1_0#1, <>c}", - "C.<>c: {<>9__0#1_0#1, b__0#1_0#1}", - "C.<>c__DisplayClass0#1_0#1: {a, b__2#1}"); + "C: {<>c__DisplayClass0#1_0#1, <>c}", + "C.<>c__DisplayClass0#1_0#1: {<>4__this, a, b__1#1, b__2#1}", + "C.<>c: {<>9__0#1_0#1, b__0#1_0#1}"); var diff2 = compilation2.EmitDifference( diff1.NextGeneration, @@ -1436,8 +1436,8 @@ public int F() var reader2 = diff2.GetMetadata().Reader; CheckNames(new[] { reader0, reader1, reader2 }, reader2.GetTypeDefNames(), "<>c__DisplayClass1#2_0#2"); - CheckNames(new[] { reader0, reader1, reader2 }, reader2.GetMethodDefNames(), ".ctor", "F", "b__1#2_1#2", ".ctor", "b__2#2", "b__1#2_0#2"); - CheckNames(new[] { reader0, reader1, reader2 }, reader2.GetFieldDefNames(), "a", "<>9__1#2_0#2"); + CheckNames(new[] { reader0, reader1, reader2 }, reader2.GetMethodDefNames(), ".ctor", "F", ".ctor", "b__1#2", "b__2#2", "b__1#2_0#2"); + CheckNames(new[] { reader0, reader1, reader2 }, reader2.GetFieldDefNames(), "<>4__this", "a", "<>9__1#2_0#2"); } [Fact] @@ -1525,8 +1525,8 @@ public int F() var reader0 = md0.MetadataReader; CheckNames(reader0, reader0.GetTypeDefNames(), "", "C", "<>c__DisplayClass0_0`1", "<>c__0`1"); - CheckNames(reader0, reader0.GetMethodDefNames(), "F", ".ctor", "b__0_1", ".ctor", "b__2", ".cctor", ".ctor", "b__0_0"); - CheckNames(reader0, reader0.GetFieldDefNames(), "a", "<>9", "<>9__0_0"); + CheckNames(reader0, reader0.GetMethodDefNames(), "F", ".ctor", ".ctor", "b__1", "b__2", ".cctor", ".ctor", "b__0_0"); + CheckNames(reader0, reader0.GetFieldDefNames(), "<>4__this", "a", "<>9", "<>9__0_0"); var generation0 = EmitBaseline.CreateInitialBaseline(md0, v0.CreateSymReader().GetEncMethodDebugInfo); var diff1 = compilation1.EmitDifference( @@ -1537,13 +1537,13 @@ public int F() var reader1 = diff1.GetMetadata().Reader; CheckNames(new[] { reader0, reader1 }, reader1.GetTypeDefNames(), "<>c__DisplayClass0#1_0#1`1", "<>c__0#1`1"); - CheckNames(new[] { reader0, reader1 }, reader1.GetMethodDefNames(), "F", "b__0#1_1#1", ".ctor", "b__2#1", ".cctor", ".ctor", "b__0#1_0#1"); - CheckNames(new[] { reader0, reader1 }, reader1.GetFieldDefNames(), "a", "<>9", "<>9__0#1_0#1"); + CheckNames(new[] { reader0, reader1 }, reader1.GetMethodDefNames(), "F", ".ctor", "b__1#1", "b__2#1", ".cctor", ".ctor", "b__0#1_0#1"); + CheckNames(new[] { reader0, reader1 }, reader1.GetFieldDefNames(), "<>4__this", "a", "<>9", "<>9__0#1_0#1"); diff1.VerifySynthesizedMembers( - "C: {b__0#1_1#1, <>c__DisplayClass0#1_0#1, <>c__0#1}", "C.<>c__0#1: {<>9__0#1_0#1, b__0#1_0#1}", - "C.<>c__DisplayClass0#1_0#1: {a, b__2#1}"); + "C: {<>c__DisplayClass0#1_0#1, <>c__0#1}", + "C.<>c__DisplayClass0#1_0#1: {<>4__this, a, b__1#1, b__2#1}"); var diff2 = compilation2.EmitDifference( diff1.NextGeneration, @@ -1553,8 +1553,8 @@ public int F() var reader2 = diff2.GetMetadata().Reader; CheckNames(new[] { reader0, reader1, reader2 }, reader2.GetTypeDefNames(), "<>c__DisplayClass1#2_0#2`1", "<>c__1#2`1"); - CheckNames(new[] { reader0, reader1, reader2 }, reader2.GetMethodDefNames(), "F", "b__1#2_1#2", ".ctor", "b__2#2", ".cctor", ".ctor", "b__1#2_0#2"); - CheckNames(new[] { reader0, reader1, reader2 }, reader2.GetFieldDefNames(), "a", "<>9", "<>9__1#2_0#2"); + CheckNames(new[] { reader0, reader1, reader2 }, reader2.GetMethodDefNames(), "F", ".ctor", "b__1#2", "b__2#2", ".cctor", ".ctor", "b__1#2_0#2"); + CheckNames(new[] { reader0, reader1, reader2 }, reader2.GetFieldDefNames(), "<>4__this", "a", "<>9", "<>9__1#2_0#2"); } [Fact] @@ -1669,9 +1669,9 @@ public int F() new SemanticEdit(SemanticEditKind.Update, main0, main1, preserveLocalVariables: true))); diff1.VerifySynthesizedMembers( - "C: {b__1#1_1#1, <>c__DisplayClass1#1_0#1, <>c}", "C.<>c: {<>9__1#1_0#1, b__1#1_0#1}", - "C.<>c__DisplayClass1#1_0#1: {a, b__2#1}"); + "C.<>c__DisplayClass1#1_0#1: {<>4__this, a, b__1#1, b__2#1}", + "C: {<>c__DisplayClass1#1_0#1, <>c}"); var diff2 = compilation2.EmitDifference( diff1.NextGeneration, @@ -1680,10 +1680,10 @@ public int F() new SemanticEdit(SemanticEditKind.Update, main1, main2, preserveLocalVariables: true))); diff2.VerifySynthesizedMembers( - "C: {b__1#2_1#2, <>c__DisplayClass1#2_0#2, <>c, b__1#1_1#1, <>c__DisplayClass1#1_0#1}", + "C.<>c__DisplayClass1#2_0#2: {<>4__this, a, b__1#2, b__2#2}", + "C: {<>c__DisplayClass1#2_0#2, <>c, <>c__DisplayClass1#1_0#1}", "C.<>c: {<>9__1#2_0#2, b__1#2_0#2, <>9__1#1_0#1, b__1#1_0#1}", - "C.<>c__DisplayClass1#1_0#1: {a, b__2#1}", - "C.<>c__DisplayClass1#2_0#2: {a, b__2#2}"); + "C.<>c__DisplayClass1#1_0#1: {<>4__this, a, b__1#1, b__2#1}"); var diff3 = compilation3.EmitDifference( diff2.NextGeneration, @@ -1691,10 +1691,10 @@ public int F() new SemanticEdit(SemanticEditKind.Update, main2, main3, preserveLocalVariables: true))); diff3.VerifySynthesizedMembers( - "C: {b__1#2_1#2, <>c__DisplayClass1#2_0#2, <>c, b__1#1_1#1, <>c__DisplayClass1#1_0#1}", + "C.<>c__DisplayClass1#1_0#1: {<>4__this, a, b__1#1, b__2#1}", "C.<>c: {<>9__1#2_0#2, b__1#2_0#2, <>9__1#1_0#1, b__1#1_0#1}", - "C.<>c__DisplayClass1#1_0#1: {a, b__2#1}", - "C.<>c__DisplayClass1#2_0#2: {a, b__2#2}"); + "C.<>c__DisplayClass1#2_0#2: {<>4__this, a, b__1#2, b__2#2}", + "C: {<>c__DisplayClass1#2_0#2, <>c, <>c__DisplayClass1#1_0#1}"); } [Fact] diff --git a/src/Compilers/CSharp/Test/Emit/PDB/PDBEmbeddedSourceTests.cs b/src/Compilers/CSharp/Test/Emit/PDB/PDBEmbeddedSourceTests.cs new file mode 100644 index 0000000000000..3344313a01df9 --- /dev/null +++ b/src/Compilers/CSharp/Test/Emit/PDB/PDBEmbeddedSourceTests.cs @@ -0,0 +1,128 @@ +// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.IO; +using System.Linq; +using System.Reflection.PortableExecutable; +using Microsoft.CodeAnalysis.CSharp.Test.Utilities; +using Microsoft.CodeAnalysis.Emit; +using Microsoft.CodeAnalysis.Test.Utilities; +using Microsoft.DiaSymReader; +using Roslyn.Test.Utilities; +using Xunit; + +namespace Microsoft.CodeAnalysis.CSharp.UnitTests.PDB +{ + public class PDBEmbeddedSourceTests : CSharpTestBase + { + [Fact] + public void StandalonePdb() + { + string source1 = @" +using System; + +class C +{ + public static void Main() + { + Console.WriteLine(); + } +} +"; + string source2 = @" +// no code +"; + + var tree1 = Parse(source1, "f:/build/goo.cs"); + var tree2 = Parse(source2, "f:/build/nocode.cs"); + var c = CreateStandardCompilation(new[] { tree1, tree2 }, options: TestOptions.DebugDll); + var embeddedTexts = new[] + { + EmbeddedText.FromSource(tree1.FilePath, tree1.GetText()), + EmbeddedText.FromSource(tree2.FilePath, tree2.GetText()) + }; + + c.VerifyPdb(@" + + + + + + + + + + + + + + + + + + + + + + + +", embeddedTexts); + } + + [Fact] + public void EmbeddedPdb() + { + string source = @" +using System; + +class C +{ + public static void Main() + { + Console.WriteLine(); + } +} +"; + var tree = Parse(source, "f:/build/goo.cs"); + var c = CreateStandardCompilation(tree, options: TestOptions.DebugDll); + + var pdbStream = new MemoryStream(); + var peBlob = c.EmitToArray( + EmitOptions.Default.WithDebugInformationFormat(DebugInformationFormat.Embedded), + embeddedTexts: new[] { EmbeddedText.FromSource(tree.FilePath, tree.GetText()) }); + pdbStream.Position = 0; + + using (var peReader = new PEReader(peBlob)) + { + var embeddedEntry = peReader.ReadDebugDirectory().Single(e => e.Type == DebugDirectoryEntryType.EmbeddedPortablePdb); + + using (var embeddedMetadataProvider = peReader.ReadEmbeddedPortablePdbDebugDirectoryData(embeddedEntry)) + { + var pdbReader = embeddedMetadataProvider.GetMetadataReader(); + + var embeddedSource = + (from documentHandle in pdbReader.Documents + let document = pdbReader.GetDocument(documentHandle) + select new + { + FilePath = pdbReader.GetString(document.Name), + Text = pdbReader.GetEmbeddedSource(documentHandle) + }).Single(); + + Assert.Equal(embeddedSource.FilePath, "f:/build/goo.cs"); + Assert.Equal(source, embeddedSource.Text.ToString()); + } + } + } + } +} diff --git a/src/Compilers/CSharp/Test/Emit/PDB/PDBLambdaTests.cs b/src/Compilers/CSharp/Test/Emit/PDB/PDBLambdaTests.cs index a63ab728ce7e1..f233175099fe0 100644 --- a/src/Compilers/CSharp/Test/Emit/PDB/PDBLambdaTests.cs +++ b/src/Compilers/CSharp/Test/Emit/PDB/PDBLambdaTests.cs @@ -537,50 +537,50 @@ public C(int a, int b) : base(() => a) - + - - - - + + + + - + - + - + - + - + - + diff --git a/src/Compilers/CSharp/Test/Emit/PDB/PDBUsingTests.cs b/src/Compilers/CSharp/Test/Emit/PDB/PDBUsingTests.cs index 3cdcf6f520e70..079bbd48c8b76 100644 --- a/src/Compilers/CSharp/Test/Emit/PDB/PDBUsingTests.cs +++ b/src/Compilers/CSharp/Test/Emit/PDB/PDBUsingTests.cs @@ -56,21 +56,17 @@ class C { void M() { } } CompileAndVerify(text, options: TestOptions.DebugDll).VerifyPdb(@" - + - - - - + + - - @@ -90,17 +86,21 @@ class C { void M() { } } - + + + - - + + + + @@ -133,21 +133,17 @@ class C { void M() { } } CompileAndVerify(text, options: TestOptions.DebugDll).VerifyPdb(@" - + - - - - + + - - @@ -167,17 +163,21 @@ class C { void M() { } } - + + + - - + + + + @@ -210,21 +210,17 @@ class C { void M() { } } CompileAndVerify(text, options: TestOptions.DebugDll).VerifyPdb(@" - + - - - - + + - - @@ -244,17 +240,21 @@ class C { void M() { } } - + + + - - + + + + @@ -287,21 +287,17 @@ class C { void M() { } } CompileAndVerify(text, options: TestOptions.DebugDll).VerifyPdb(@" - + - - - - + + - - @@ -321,17 +317,21 @@ class C { void M() { } } - + + + - - + + + + @@ -805,8 +805,8 @@ class C { void M() { } } - + @@ -827,12 +827,12 @@ class C { void M() { } } - + - + @@ -855,12 +855,12 @@ class C { void M() { } } - + - + @@ -1101,12 +1101,12 @@ partial class C - + - + @@ -1127,12 +1127,12 @@ partial class C - + - + @@ -1150,12 +1150,12 @@ partial class C - + - + @@ -1289,12 +1289,12 @@ partial class C - + - + @@ -1316,12 +1316,12 @@ partial class C - + - + @@ -1339,12 +1339,12 @@ partial class C - + - + @@ -1542,44 +1542,44 @@ class C - + + + + - - + + + - + - - + + - + - - - - - - + + - + - - + + diff --git a/src/Compilers/CSharp/Test/Emit/PDB/PortablePdbTests.cs b/src/Compilers/CSharp/Test/Emit/PDB/PortablePdbTests.cs index 76f84dd575f84..4943eda0e1805 100644 --- a/src/Compilers/CSharp/Test/Emit/PDB/PortablePdbTests.cs +++ b/src/Compilers/CSharp/Test/Emit/PDB/PortablePdbTests.cs @@ -362,93 +362,5 @@ public static void Main() // error CS0041: Unexpected error writing debug information -- 'Error!' Diagnostic(ErrorCode.FTL_DebugEmitFailure).WithArguments("Error!").WithLocation(1, 1)); } - - [Fact] - public void EmbeddedSource() - { - string source = @" -using System; - -class C -{ - public static void Main() - { - Console.WriteLine(); - } -} -"; - var tree = Parse(source, "f:/build/goo.cs"); - var c = CreateStandardCompilation(tree, options: TestOptions.DebugDll); - - var pdbStream = new MemoryStream(); - c.EmitToArray( - EmitOptions.Default.WithDebugInformationFormat(DebugInformationFormat.PortablePdb), - pdbStream: pdbStream, - embeddedTexts: new[] { EmbeddedText.FromSource(tree.FilePath, tree.GetText()) }); - pdbStream.Position = 0; - - using (var provider = MetadataReaderProvider.FromPortablePdbStream(pdbStream)) - { - var pdbReader = provider.GetMetadataReader(); - - var embeddedSource = - (from documentHandle in pdbReader.Documents - let document = pdbReader.GetDocument(documentHandle) - select new - { - FilePath = pdbReader.GetString(document.Name), - Text = pdbReader.GetEmbeddedSource(documentHandle) - }).Single(); - - Assert.Equal(embeddedSource.FilePath, "f:/build/goo.cs"); - Assert.Equal(source, embeddedSource.Text.ToString()); - } - } - - [Fact] - public void EmbeddedSource_InEmbeddedPdb() - { - string source = @" -using System; - -class C -{ - public static void Main() - { - Console.WriteLine(); - } -} -"; - var tree = Parse(source, "f:/build/goo.cs"); - var c = CreateStandardCompilation(tree, options: TestOptions.DebugDll); - - var pdbStream = new MemoryStream(); - var peBlob = c.EmitToArray( - EmitOptions.Default.WithDebugInformationFormat(DebugInformationFormat.Embedded), - embeddedTexts: new[] { EmbeddedText.FromSource(tree.FilePath, tree.GetText()) }); - pdbStream.Position = 0; - - using (var peReader = new PEReader(peBlob)) - { - var embeddedEntry = peReader.ReadDebugDirectory().Single(e => e.Type == DebugDirectoryEntryType.EmbeddedPortablePdb); - - using (var embeddedMetadataProvider = peReader.ReadEmbeddedPortablePdbDebugDirectoryData(embeddedEntry)) - { - var pdbReader = embeddedMetadataProvider.GetMetadataReader(); - - var embeddedSource = - (from documentHandle in pdbReader.Documents - let document = pdbReader.GetDocument(documentHandle) - select new - { - FilePath = pdbReader.GetString(document.Name), - Text = pdbReader.GetEmbeddedSource(documentHandle) - }).Single(); - - Assert.Equal(embeddedSource.FilePath, "f:/build/goo.cs"); - Assert.Equal(source, embeddedSource.Text.ToString()); - } - } - } } } diff --git a/src/Compilers/CSharp/Test/Symbol/Compilation/CompilationAPITests.cs b/src/Compilers/CSharp/Test/Symbol/Compilation/CompilationAPITests.cs index a6f4a051937e3..6860a2e96b989 100644 --- a/src/Compilers/CSharp/Test/Symbol/Compilation/CompilationAPITests.cs +++ b/src/Compilers/CSharp/Test/Symbol/Compilation/CompilationAPITests.cs @@ -212,8 +212,8 @@ public void Emit_BadArgs() Assert.Throws("embeddedTexts", () => comp.Emit( peStream: new MemoryStream(), - pdbStream: new MemoryStream(), - options: EmitOptions.Default.WithDebugInformationFormat(DebugInformationFormat.Pdb), + pdbStream: null, + options: null, embeddedTexts: new[] { EmbeddedText.FromStream("_", new MemoryStream()) })); Assert.Throws("embeddedTexts", () => comp.Emit( diff --git a/src/Compilers/Core/Portable/CodeAnalysisResources.Designer.cs b/src/Compilers/Core/Portable/CodeAnalysisResources.Designer.cs index 924294ba735ca..a269db33fafcb 100644 --- a/src/Compilers/Core/Portable/CodeAnalysisResources.Designer.cs +++ b/src/Compilers/Core/Portable/CodeAnalysisResources.Designer.cs @@ -460,11 +460,11 @@ internal class CodeAnalysisResources { } /// - /// Looks up a localized string similar to Embedded texts are only supported when emitting Portable PDB.. + /// Looks up a localized string similar to Embedded texts are only supported when emitting a PDB.. /// - internal static string EmbeddedTextsRequirePortablePdb { + internal static string EmbeddedTextsRequirePdb { get { - return ResourceManager.GetString("EmbeddedTextsRequirePortablePdb", resourceCulture); + return ResourceManager.GetString("EmbeddedTextsRequirePdb", resourceCulture); } } diff --git a/src/Compilers/Core/Portable/CodeAnalysisResources.resx b/src/Compilers/Core/Portable/CodeAnalysisResources.resx index 102db4f2b47ed..d53562649f721 100644 --- a/src/Compilers/Core/Portable/CodeAnalysisResources.resx +++ b/src/Compilers/Core/Portable/CodeAnalysisResources.resx @@ -591,8 +591,8 @@ Stream is too long. - - Embedded texts are only supported when emitting Portable PDB. + + Embedded texts are only supported when emitting a PDB. The stream cannot be written to. diff --git a/src/Compilers/Core/Portable/Compilation/Compilation.cs b/src/Compilers/Core/Portable/Compilation/Compilation.cs index 50b214a779f12..5343697480f5b 100644 --- a/src/Compilers/Core/Portable/Compilation/Compilation.cs +++ b/src/Compilers/Core/Portable/Compilation/Compilation.cs @@ -2123,14 +2123,12 @@ internal void EnsureAnonymousTypeTemplates(CancellationToken cancellationToken) throw new ArgumentException(CodeAnalysisResources.StreamMustSupportRead, nameof(sourceLinkStream)); } - if (embeddedTexts != null && !embeddedTexts.IsEmpty()) + if (embeddedTexts != null && + !embeddedTexts.IsEmpty() && + pdbStream == null && + options?.DebugInformationFormat != DebugInformationFormat.Embedded) { - if (options == null || - options.DebugInformationFormat == DebugInformationFormat.Pdb || - options.DebugInformationFormat == DebugInformationFormat.PortablePdb && pdbStream == null) - { - throw new ArgumentException(CodeAnalysisResources.EmbeddedTextsRequirePortablePdb, nameof(embeddedTexts)); - } + throw new ArgumentException(CodeAnalysisResources.EmbeddedTextsRequirePdb, nameof(embeddedTexts)); } return Emit( diff --git a/src/Compilers/Core/Portable/Generated/Operations.xml.Generated.cs b/src/Compilers/Core/Portable/Generated/Operations.xml.Generated.cs index df76c3c6ea5d3..47aeb6b9fb9ca 100644 --- a/src/Compilers/Core/Portable/Generated/Operations.xml.Generated.cs +++ b/src/Compilers/Core/Portable/Generated/Operations.xml.Generated.cs @@ -12,8 +12,8 @@ namespace Microsoft.CodeAnalysis.Semantics /// internal abstract partial class BaseAddressOfExpression : Operation, IAddressOfExpression { - protected BaseAddressOfExpression(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.AddressOfExpression, semanticModel, syntax, type, constantValue) + protected BaseAddressOfExpression(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.AddressOfExpression, semanticModel, syntax, type, constantValue, isImplicit) { } @@ -43,8 +43,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class AddressOfExpression : BaseAddressOfExpression, IAddressOfExpression { - public AddressOfExpression(IOperation reference, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(semanticModel, syntax, type, constantValue) + public AddressOfExpression(IOperation reference, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(semanticModel, syntax, type, constantValue, isImplicit) { ReferenceImpl = reference; } @@ -58,7 +58,7 @@ internal sealed partial class LazyAddressOfExpression : BaseAddressOfExpression, { private readonly Lazy _lazyReference; - public LazyAddressOfExpression(Lazy reference, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(semanticModel, syntax, type, constantValue) + public LazyAddressOfExpression(Lazy reference, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : base(semanticModel, syntax, type, constantValue, isImplicit) { _lazyReference = reference ?? throw new System.ArgumentNullException(nameof(reference)); } @@ -71,8 +71,8 @@ public LazyAddressOfExpression(Lazy reference, SemanticModel semanti /// internal abstract partial class BaseNameOfExpression : Operation, INameOfExpression { - protected BaseNameOfExpression(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.NameOfExpression, semanticModel, syntax, type, constantValue) + protected BaseNameOfExpression(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.NameOfExpression, semanticModel, syntax, type, constantValue, isImplicit) { } @@ -102,8 +102,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class NameOfExpression : BaseNameOfExpression, INameOfExpression { - public NameOfExpression(IOperation argument, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(semanticModel, syntax, type, constantValue) + public NameOfExpression(IOperation argument, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(semanticModel, syntax, type, constantValue, isImplicit) { ArgumentImpl = argument; } @@ -117,8 +117,8 @@ internal sealed partial class LazyNameOfExpression : BaseNameOfExpression, IName { private readonly Lazy _lazyArgument; - public LazyNameOfExpression(Lazy argument, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(semanticModel, syntax, type, constantValue) + public LazyNameOfExpression(Lazy argument, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(semanticModel, syntax, type, constantValue, isImplicit) { _lazyArgument = argument ?? throw new System.ArgumentNullException(nameof(argument)); } @@ -131,8 +131,8 @@ internal sealed partial class LazyNameOfExpression : BaseNameOfExpression, IName /// internal abstract partial class BaseThrowExpression : Operation, IThrowExpression { - protected BaseThrowExpression(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.ThrowExpression, semanticModel, syntax, type, constantValue) + protected BaseThrowExpression(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.ThrowExpression, semanticModel, syntax, type, constantValue, isImplicit) { } @@ -162,8 +162,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class ThrowExpression : BaseThrowExpression, IThrowExpression { - public ThrowExpression(IOperation expression, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(semanticModel, syntax, type, constantValue) + public ThrowExpression(IOperation expression, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(semanticModel, syntax, type, constantValue, isImplicit) { ExpressionImpl = expression; } @@ -177,8 +177,8 @@ internal sealed partial class LazyThrowExpression : BaseThrowExpression, IThrowE { private readonly Lazy _lazyExpression; - public LazyThrowExpression(Lazy expression, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(semanticModel, syntax, type, constantValue) + public LazyThrowExpression(Lazy expression, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(semanticModel, syntax, type, constantValue, isImplicit) { _lazyExpression = expression ?? throw new System.ArgumentNullException(nameof(expression)); } @@ -191,8 +191,8 @@ internal sealed partial class LazyThrowExpression : BaseThrowExpression, IThrowE /// internal abstract partial class BaseArgument : Operation, IArgument { - protected BaseArgument(ArgumentKind argumentKind, IParameterSymbol parameter, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.Argument, semanticModel, syntax, type, constantValue) + protected BaseArgument(ArgumentKind argumentKind, IParameterSymbol parameter, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.Argument, semanticModel, syntax, type, constantValue, isImplicit) { ArgumentKind = argumentKind; Parameter = parameter; @@ -244,8 +244,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class Argument : BaseArgument, IArgument { - public Argument(ArgumentKind argumentKind, IParameterSymbol parameter, IOperation value, IOperation inConversion, IOperation outConversion, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(argumentKind, parameter, semanticModel, syntax, type, constantValue) + public Argument(ArgumentKind argumentKind, IParameterSymbol parameter, IOperation value, IOperation inConversion, IOperation outConversion, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(argumentKind, parameter, semanticModel, syntax, type, constantValue, isImplicit) { ValueImpl = value; InConversionImpl = inConversion; @@ -266,7 +266,7 @@ internal sealed partial class LazyArgument : BaseArgument, IArgument private readonly Lazy _lazyInConversion; private readonly Lazy _lazyOutConversion; - public LazyArgument(ArgumentKind argumentKind, IParameterSymbol parameter, Lazy value, Lazy inConversion, Lazy outConversion, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(argumentKind, parameter, semanticModel, syntax, type, constantValue) + public LazyArgument(ArgumentKind argumentKind, IParameterSymbol parameter, Lazy value, Lazy inConversion, Lazy outConversion, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : base(argumentKind, parameter, semanticModel, syntax, type, constantValue, isImplicit) { _lazyValue = value ?? throw new System.ArgumentNullException(nameof(value)); _lazyInConversion = inConversion ?? throw new System.ArgumentNullException(nameof(inConversion)); @@ -285,8 +285,8 @@ public LazyArgument(ArgumentKind argumentKind, IParameterSymbol parameter, Lazy< /// internal abstract partial class BaseArrayCreationExpression : Operation, IArrayCreationExpression { - protected BaseArrayCreationExpression(ITypeSymbol elementType, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.ArrayCreationExpression, semanticModel, syntax, type, constantValue) + protected BaseArrayCreationExpression(ITypeSymbol elementType, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.ArrayCreationExpression, semanticModel, syntax, type, constantValue, isImplicit) { ElementType = elementType; } @@ -330,8 +330,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class ArrayCreationExpression : BaseArrayCreationExpression, IArrayCreationExpression { - public ArrayCreationExpression(ITypeSymbol elementType, ImmutableArray dimensionSizes, IArrayInitializer initializer, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(elementType, semanticModel, syntax, type, constantValue) + public ArrayCreationExpression(ITypeSymbol elementType, ImmutableArray dimensionSizes, IArrayInitializer initializer, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(elementType, semanticModel, syntax, type, constantValue, isImplicit) { DimensionSizesImpl = dimensionSizes; InitializerImpl = initializer; @@ -349,7 +349,7 @@ internal sealed partial class LazyArrayCreationExpression : BaseArrayCreationExp private readonly Lazy> _lazyDimensionSizes; private readonly Lazy _lazyInitializer; - public LazyArrayCreationExpression(ITypeSymbol elementType, Lazy> dimensionSizes, Lazy initializer, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(elementType, semanticModel, syntax, type, constantValue) + public LazyArrayCreationExpression(ITypeSymbol elementType, Lazy> dimensionSizes, Lazy initializer, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : base(elementType, semanticModel, syntax, type, constantValue, isImplicit) { _lazyDimensionSizes = dimensionSizes; _lazyInitializer = initializer ?? throw new System.ArgumentNullException(nameof(initializer)); @@ -365,8 +365,8 @@ public LazyArrayCreationExpression(ITypeSymbol elementType, Lazy internal abstract partial class BaseArrayElementReferenceExpression : Operation, IArrayElementReferenceExpression { - protected BaseArrayElementReferenceExpression(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.ArrayElementReferenceExpression, semanticModel, syntax, type, constantValue) + protected BaseArrayElementReferenceExpression(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.ArrayElementReferenceExpression, semanticModel, syntax, type, constantValue, isImplicit) { } @@ -406,8 +406,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class ArrayElementReferenceExpression : BaseArrayElementReferenceExpression, IArrayElementReferenceExpression { - public ArrayElementReferenceExpression(IOperation arrayReference, ImmutableArray indices, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(semanticModel, syntax, type, constantValue) + public ArrayElementReferenceExpression(IOperation arrayReference, ImmutableArray indices, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(semanticModel, syntax, type, constantValue, isImplicit) { ArrayReferenceImpl = arrayReference; IndicesImpl = indices; @@ -425,7 +425,7 @@ internal sealed partial class LazyArrayElementReferenceExpression : BaseArrayEle private readonly Lazy _lazyArrayReference; private readonly Lazy> _lazyIndices; - public LazyArrayElementReferenceExpression(Lazy arrayReference, Lazy> indices, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(semanticModel, syntax, type, constantValue) + public LazyArrayElementReferenceExpression(Lazy arrayReference, Lazy> indices, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : base(semanticModel, syntax, type, constantValue, isImplicit) { _lazyArrayReference = arrayReference ?? throw new System.ArgumentNullException(nameof(arrayReference)); _lazyIndices = indices; @@ -441,8 +441,8 @@ public LazyArrayElementReferenceExpression(Lazy arrayReference, Lazy /// internal abstract partial class BaseArrayInitializer : Operation, IArrayInitializer { - protected BaseArrayInitializer(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.ArrayInitializer, semanticModel, syntax, type, constantValue) + protected BaseArrayInitializer(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.ArrayInitializer, semanticModel, syntax, type, constantValue, isImplicit) { } @@ -476,8 +476,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class ArrayInitializer : BaseArrayInitializer, IArrayInitializer { - public ArrayInitializer(ImmutableArray elementValues, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(semanticModel, syntax, type, constantValue) + public ArrayInitializer(ImmutableArray elementValues, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(semanticModel, syntax, type, constantValue, isImplicit) { ElementValuesImpl = elementValues; } @@ -492,7 +492,7 @@ internal sealed partial class LazyArrayInitializer : BaseArrayInitializer, IArra { private readonly Lazy> _lazyElementValues; - public LazyArrayInitializer(Lazy> elementValues, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(semanticModel, syntax, type, constantValue) + public LazyArrayInitializer(Lazy> elementValues, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : base(semanticModel, syntax, type, constantValue, isImplicit) { _lazyElementValues = elementValues; } @@ -505,8 +505,8 @@ public LazyArrayInitializer(Lazy> elementValues, Sema /// internal abstract partial class AssignmentExpression : Operation, IAssignmentExpression { - protected AssignmentExpression(OperationKind kind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(kind, semanticModel, syntax, type, constantValue) + protected AssignmentExpression(OperationKind kind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(kind, semanticModel, syntax, type, constantValue, isImplicit) { } protected abstract IOperation TargetImpl { get; } @@ -526,8 +526,8 @@ internal abstract partial class AssignmentExpression : Operation, IAssignmentExp /// internal abstract partial class BaseSimpleAssignmentExpression : AssignmentExpression, ISimpleAssignmentExpression { - public BaseSimpleAssignmentExpression(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.SimpleAssignmentExpression, semanticModel, syntax, type, constantValue) + public BaseSimpleAssignmentExpression(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.SimpleAssignmentExpression, semanticModel, syntax, type, constantValue, isImplicit) { } public override IEnumerable Children @@ -553,8 +553,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class SimpleAssignmentExpression : BaseSimpleAssignmentExpression, ISimpleAssignmentExpression { - public SimpleAssignmentExpression(IOperation target, IOperation value, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(semanticModel, syntax, type, constantValue) + public SimpleAssignmentExpression(IOperation target, IOperation value, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(semanticModel, syntax, type, constantValue, isImplicit) { TargetImpl = target; ValueImpl = value; @@ -571,8 +571,8 @@ internal sealed partial class LazySimpleAssignmentExpression : BaseSimpleAssignm private readonly Lazy _lazyTarget; private readonly Lazy _lazyValue; - public LazySimpleAssignmentExpression(Lazy target, Lazy value, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(semanticModel, syntax, type, constantValue) + public LazySimpleAssignmentExpression(Lazy target, Lazy value, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(semanticModel, syntax, type, constantValue, isImplicit) { _lazyTarget = target ?? throw new System.ArgumentNullException(nameof(target)); _lazyValue = value ?? throw new System.ArgumentNullException(nameof(value)); @@ -586,8 +586,8 @@ internal sealed partial class LazySimpleAssignmentExpression : BaseSimpleAssignm /// internal abstract partial class BaseAwaitExpression : Operation, IAwaitExpression { - protected BaseAwaitExpression(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.AwaitExpression, semanticModel, syntax, type, constantValue) + protected BaseAwaitExpression(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.AwaitExpression, semanticModel, syntax, type, constantValue, isImplicit) { } @@ -618,8 +618,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class AwaitExpression : BaseAwaitExpression, IAwaitExpression { - public AwaitExpression(IOperation awaitedValue, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(semanticModel, syntax, type, constantValue) + public AwaitExpression(IOperation awaitedValue, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(semanticModel, syntax, type, constantValue, isImplicit) { AwaitedValueImpl = awaitedValue; } @@ -634,7 +634,7 @@ internal sealed partial class LazyAwaitExpression : BaseAwaitExpression, IAwaitE { private readonly Lazy _lazyAwaitedValue; - public LazyAwaitExpression(Lazy awaitedValue, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(semanticModel, syntax, type, constantValue) + public LazyAwaitExpression(Lazy awaitedValue, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : base(semanticModel, syntax, type, constantValue, isImplicit) { _lazyAwaitedValue = awaitedValue ?? throw new System.ArgumentNullException(nameof(awaitedValue)); } @@ -647,8 +647,8 @@ public LazyAwaitExpression(Lazy awaitedValue, SemanticModel semantic /// internal abstract partial class BaseBinaryOperatorExpression : Operation, IHasOperatorMethodExpression, IBinaryOperatorExpression { - protected BaseBinaryOperatorExpression(BinaryOperationKind binaryOperationKind, bool isLifted, bool usesOperatorMethod, IMethodSymbol operatorMethod, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.BinaryOperatorExpression, semanticModel, syntax, type, constantValue) + protected BaseBinaryOperatorExpression(BinaryOperationKind binaryOperationKind, bool isLifted, bool usesOperatorMethod, IMethodSymbol operatorMethod, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.BinaryOperatorExpression, semanticModel, syntax, type, constantValue, isImplicit) { BinaryOperationKind = binaryOperationKind; UsesOperatorMethod = usesOperatorMethod; @@ -703,8 +703,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class BinaryOperatorExpression : BaseBinaryOperatorExpression, IHasOperatorMethodExpression, IBinaryOperatorExpression { - public BinaryOperatorExpression(BinaryOperationKind binaryOperationKind, IOperation leftOperand, IOperation rightOperand, bool isLifted, bool usesOperatorMethod, IMethodSymbol operatorMethod, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(binaryOperationKind, isLifted, usesOperatorMethod, operatorMethod, semanticModel, syntax, type, constantValue) + public BinaryOperatorExpression(BinaryOperationKind binaryOperationKind, IOperation leftOperand, IOperation rightOperand, bool isLifted, bool usesOperatorMethod, IMethodSymbol operatorMethod, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(binaryOperationKind, isLifted, usesOperatorMethod, operatorMethod, semanticModel, syntax, type, constantValue, isImplicit) { LeftOperandImpl = leftOperand; RightOperandImpl = rightOperand; @@ -722,8 +722,8 @@ internal sealed partial class LazyBinaryOperatorExpression : BaseBinaryOperatorE private readonly Lazy _lazyLeftOperand; private readonly Lazy _lazyRightOperand; - public LazyBinaryOperatorExpression(BinaryOperationKind binaryOperationKind, Lazy leftOperand, Lazy rightOperand, bool isLifted, bool usesOperatorMethod, IMethodSymbol operatorMethod, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(binaryOperationKind, isLifted, usesOperatorMethod, operatorMethod, semanticModel, syntax, type, constantValue) + public LazyBinaryOperatorExpression(BinaryOperationKind binaryOperationKind, Lazy leftOperand, Lazy rightOperand, bool isLifted, bool usesOperatorMethod, IMethodSymbol operatorMethod, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(binaryOperationKind, isLifted, usesOperatorMethod, operatorMethod, semanticModel, syntax, type, constantValue, isImplicit) { _lazyLeftOperand = leftOperand ?? throw new System.ArgumentNullException(nameof(leftOperand)); _lazyRightOperand = rightOperand ?? throw new System.ArgumentNullException(nameof(rightOperand)); @@ -739,8 +739,8 @@ internal sealed partial class LazyBinaryOperatorExpression : BaseBinaryOperatorE /// internal abstract partial class BaseBlockStatement : Operation, IBlockStatement { - protected BaseBlockStatement(ImmutableArray locals, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.BlockStatement, semanticModel, syntax, type, constantValue) + protected BaseBlockStatement(ImmutableArray locals, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.BlockStatement, semanticModel, syntax, type, constantValue, isImplicit) { Locals = locals; } @@ -779,8 +779,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class BlockStatement : BaseBlockStatement, IBlockStatement { - public BlockStatement(ImmutableArray statements, ImmutableArray locals, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(locals, semanticModel, syntax, type, constantValue) + public BlockStatement(ImmutableArray statements, ImmutableArray locals, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(locals, semanticModel, syntax, type, constantValue, isImplicit) { StatementsImpl = statements; } @@ -795,7 +795,7 @@ internal sealed partial class LazyBlockStatement : BaseBlockStatement, IBlockSta { private readonly Lazy> _lazyStatements; - public LazyBlockStatement(Lazy> statements, ImmutableArray locals, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(locals, semanticModel, syntax, type, constantValue) + public LazyBlockStatement(Lazy> statements, ImmutableArray locals, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : base(locals, semanticModel, syntax, type, constantValue, isImplicit) { _lazyStatements = statements; } @@ -808,8 +808,8 @@ public LazyBlockStatement(Lazy> statements, Immutable /// internal sealed partial class BranchStatement : Operation, IBranchStatement { - public BranchStatement(ILabelSymbol target, BranchKind branchKind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.BranchStatement, semanticModel, syntax, type, constantValue) + public BranchStatement(ILabelSymbol target, BranchKind branchKind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.BranchStatement, semanticModel, syntax, type, constantValue, isImplicit) { Target = target; BranchKind = branchKind; @@ -844,8 +844,8 @@ public override void Accept(OperationVisitor visitor) /// internal abstract partial class CaseClause : Operation, ICaseClause { - protected CaseClause(CaseKind caseKind, OperationKind kind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(kind, semanticModel, syntax, type, constantValue) + protected CaseClause(CaseKind caseKind, OperationKind kind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(kind, semanticModel, syntax, type, constantValue, isImplicit) { CaseKind = caseKind; } @@ -860,8 +860,8 @@ internal abstract partial class CaseClause : Operation, ICaseClause /// internal abstract partial class BaseCatchClause : Operation, ICatchClause { - protected BaseCatchClause(ITypeSymbol caughtType, ILocalSymbol exceptionLocal, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.CatchClause, semanticModel, syntax, type, constantValue) + protected BaseCatchClause(ITypeSymbol caughtType, ILocalSymbol exceptionLocal, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.CatchClause, semanticModel, syntax, type, constantValue, isImplicit) { CaughtType = caughtType; ExceptionLocal = exceptionLocal; @@ -908,8 +908,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class CatchClause : BaseCatchClause, ICatchClause { - public CatchClause(IBlockStatement handler, ITypeSymbol caughtType, IOperation filter, ILocalSymbol exceptionLocal, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(caughtType, exceptionLocal, semanticModel, syntax, type, constantValue) + public CatchClause(IBlockStatement handler, ITypeSymbol caughtType, IOperation filter, ILocalSymbol exceptionLocal, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(caughtType, exceptionLocal, semanticModel, syntax, type, constantValue, isImplicit) { HandlerImpl = handler; FilterImpl = filter; @@ -927,7 +927,7 @@ internal sealed partial class LazyCatchClause : BaseCatchClause, ICatchClause private readonly Lazy _lazyHandler; private readonly Lazy _lazyFilter; - public LazyCatchClause(Lazy handler, ITypeSymbol caughtType, Lazy filter, ILocalSymbol exceptionLocal, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(caughtType, exceptionLocal, semanticModel, syntax, type, constantValue) + public LazyCatchClause(Lazy handler, ITypeSymbol caughtType, Lazy filter, ILocalSymbol exceptionLocal, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : base(caughtType, exceptionLocal, semanticModel, syntax, type, constantValue, isImplicit) { _lazyHandler = handler ?? throw new System.ArgumentNullException(nameof(handler)); _lazyFilter = filter ?? throw new System.ArgumentNullException(nameof(filter)); @@ -943,8 +943,8 @@ public LazyCatchClause(Lazy handler, ITypeSymbol caughtType, La /// internal abstract partial class BaseCompoundAssignmentExpression : AssignmentExpression, IHasOperatorMethodExpression, ICompoundAssignmentExpression { - protected BaseCompoundAssignmentExpression(BinaryOperationKind binaryOperationKind, bool isLifted, bool usesOperatorMethod, IMethodSymbol operatorMethod, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.CompoundAssignmentExpression, semanticModel, syntax, type, constantValue) + protected BaseCompoundAssignmentExpression(BinaryOperationKind binaryOperationKind, bool isLifted, bool usesOperatorMethod, IMethodSymbol operatorMethod, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.CompoundAssignmentExpression, semanticModel, syntax, type, constantValue, isImplicit) { BinaryOperationKind = binaryOperationKind; IsLifted = isLifted; @@ -991,8 +991,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class CompoundAssignmentExpression : BaseCompoundAssignmentExpression, IHasOperatorMethodExpression, ICompoundAssignmentExpression { - public CompoundAssignmentExpression(BinaryOperationKind binaryOperationKind, bool isLifted, IOperation target, IOperation value, bool usesOperatorMethod, IMethodSymbol operatorMethod, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(binaryOperationKind, isLifted, usesOperatorMethod, operatorMethod, semanticModel, syntax, type, constantValue) + public CompoundAssignmentExpression(BinaryOperationKind binaryOperationKind, bool isLifted, IOperation target, IOperation value, bool usesOperatorMethod, IMethodSymbol operatorMethod, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(binaryOperationKind, isLifted, usesOperatorMethod, operatorMethod, semanticModel, syntax, type, constantValue, isImplicit) { TargetImpl = target; ValueImpl = value; @@ -1009,8 +1009,8 @@ internal sealed partial class LazyCompoundAssignmentExpression : BaseCompoundAss private readonly Lazy _lazyTarget; private readonly Lazy _lazyValue; - public LazyCompoundAssignmentExpression(BinaryOperationKind binaryOperationKind, bool isLifted, Lazy target, Lazy value, bool usesOperatorMethod, IMethodSymbol operatorMethod, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(binaryOperationKind, isLifted, usesOperatorMethod, operatorMethod, semanticModel, syntax, type, constantValue) + public LazyCompoundAssignmentExpression(BinaryOperationKind binaryOperationKind, bool isLifted, Lazy target, Lazy value, bool usesOperatorMethod, IMethodSymbol operatorMethod, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(binaryOperationKind, isLifted, usesOperatorMethod, operatorMethod, semanticModel, syntax, type, constantValue, isImplicit) { _lazyTarget = target ?? throw new System.ArgumentNullException(nameof(target)); _lazyValue = value ?? throw new System.ArgumentNullException(nameof(value)); @@ -1024,8 +1024,8 @@ internal sealed partial class LazyCompoundAssignmentExpression : BaseCompoundAss /// internal abstract partial class BaseConditionalAccessExpression : Operation, IConditionalAccessExpression { - protected BaseConditionalAccessExpression(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.ConditionalAccessExpression, semanticModel, syntax, type, constantValue) + protected BaseConditionalAccessExpression(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.ConditionalAccessExpression, semanticModel, syntax, type, constantValue, isImplicit) { } @@ -1062,8 +1062,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class ConditionalAccessExpression : BaseConditionalAccessExpression, IConditionalAccessExpression { - public ConditionalAccessExpression(IOperation conditionalValue, IOperation conditionalInstance, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(semanticModel, syntax, type, constantValue) + public ConditionalAccessExpression(IOperation conditionalValue, IOperation conditionalInstance, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(semanticModel, syntax, type, constantValue, isImplicit) { ConditionalValueImpl = conditionalValue; ConditionalInstanceImpl = conditionalInstance; @@ -1081,7 +1081,7 @@ internal sealed partial class LazyConditionalAccessExpression : BaseConditionalA private readonly Lazy _lazyConditionalValue; private readonly Lazy _lazyConditionalInstance; - public LazyConditionalAccessExpression(Lazy conditionalValue, Lazy conditionalInstance, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(semanticModel, syntax, type, constantValue) + public LazyConditionalAccessExpression(Lazy conditionalValue, Lazy conditionalInstance, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : base(semanticModel, syntax, type, constantValue, isImplicit) { _lazyConditionalValue = conditionalValue ?? throw new System.ArgumentNullException(nameof(conditionalValue)); _lazyConditionalInstance = conditionalInstance ?? throw new System.ArgumentNullException(nameof(conditionalInstance)); @@ -1097,8 +1097,8 @@ public LazyConditionalAccessExpression(Lazy conditionalValue, Lazy internal sealed partial class ConditionalAccessInstanceExpression : Operation, IConditionalAccessInstanceExpression { - public ConditionalAccessInstanceExpression(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.ConditionalAccessInstanceExpression, semanticModel, syntax, type, constantValue) + public ConditionalAccessInstanceExpression(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.ConditionalAccessInstanceExpression, semanticModel, syntax, type, constantValue, isImplicit) { } public override IEnumerable Children @@ -1123,8 +1123,8 @@ public override void Accept(OperationVisitor visitor) /// internal abstract partial class BaseConditionalChoiceExpression : Operation, IConditionalChoiceExpression { - protected BaseConditionalChoiceExpression(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.ConditionalChoiceExpression, semanticModel, syntax, type, constantValue) + protected BaseConditionalChoiceExpression(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.ConditionalChoiceExpression, semanticModel, syntax, type, constantValue, isImplicit) { } @@ -1167,8 +1167,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class ConditionalChoiceExpression : BaseConditionalChoiceExpression, IConditionalChoiceExpression { - public ConditionalChoiceExpression(IOperation condition, IOperation ifTrueValue, IOperation ifFalseValue, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(semanticModel, syntax, type, constantValue) + public ConditionalChoiceExpression(IOperation condition, IOperation ifTrueValue, IOperation ifFalseValue, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(semanticModel, syntax, type, constantValue, isImplicit) { ConditionImpl = condition; IfTrueValueImpl = ifTrueValue; @@ -1189,7 +1189,7 @@ internal sealed partial class LazyConditionalChoiceExpression : BaseConditionalC private readonly Lazy _lazyIfTrueValue; private readonly Lazy _lazyIfFalseValue; - public LazyConditionalChoiceExpression(Lazy condition, Lazy ifTrueValue, Lazy ifFalseValue, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(semanticModel, syntax, type, constantValue) + public LazyConditionalChoiceExpression(Lazy condition, Lazy ifTrueValue, Lazy ifFalseValue, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : base(semanticModel, syntax, type, constantValue, isImplicit) { _lazyCondition = condition ?? throw new System.ArgumentNullException(nameof(condition)); _lazyIfTrueValue = ifTrueValue ?? throw new System.ArgumentNullException(nameof(ifTrueValue)); @@ -1208,8 +1208,8 @@ public LazyConditionalChoiceExpression(Lazy condition, Lazy internal abstract partial class BaseConversionExpression : Operation, IHasOperatorMethodExpression, IConversionExpression { - protected BaseConversionExpression(bool isExplicitInCode, bool isTryCast, bool isChecked, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.ConversionExpression, semanticModel, syntax, type, constantValue) + protected BaseConversionExpression(bool isExplicitInCode, bool isTryCast, bool isChecked, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.ConversionExpression, semanticModel, syntax, type, constantValue, isImplicit) { IsExplicitInCode = isExplicitInCode; IsTryCast = isTryCast; @@ -1250,8 +1250,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class DefaultValueExpression : Operation, IDefaultValueExpression { - public DefaultValueExpression(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.DefaultValueExpression, semanticModel, syntax, type, constantValue) + public DefaultValueExpression(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.DefaultValueExpression, semanticModel, syntax, type, constantValue, isImplicit) { } public override IEnumerable Children @@ -1276,8 +1276,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class EmptyStatement : Operation, IEmptyStatement { - public EmptyStatement(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.EmptyStatement, semanticModel, syntax, type, constantValue) + public EmptyStatement(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.EmptyStatement, semanticModel, syntax, type, constantValue, isImplicit) { } public override IEnumerable Children @@ -1302,8 +1302,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class EndStatement : Operation, IEndStatement { - public EndStatement(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.EndStatement, semanticModel, syntax, type, constantValue) + public EndStatement(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.EndStatement, semanticModel, syntax, type, constantValue, isImplicit) { } public override IEnumerable Children @@ -1328,8 +1328,8 @@ public override void Accept(OperationVisitor visitor) /// internal abstract partial class BaseEventAssignmentExpression : Operation, IEventAssignmentExpression { - protected BaseEventAssignmentExpression(bool adds, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.EventAssignmentExpression, semanticModel, syntax, type, constantValue) + protected BaseEventAssignmentExpression(bool adds, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.EventAssignmentExpression, semanticModel, syntax, type, constantValue, isImplicit) { Adds = adds; } @@ -1381,8 +1381,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class EventAssignmentExpression : BaseEventAssignmentExpression, IEventAssignmentExpression { - public EventAssignmentExpression(IEventReferenceExpression eventReference, IOperation handlerValue, bool adds, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(adds, semanticModel, syntax, type, constantValue) + public EventAssignmentExpression(IEventReferenceExpression eventReference, IOperation handlerValue, bool adds, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(adds, semanticModel, syntax, type, constantValue, isImplicit) { EventReferenceImpl = eventReference; HandlerValueImpl = handlerValue; @@ -1400,7 +1400,7 @@ internal sealed partial class LazyEventAssignmentExpression : BaseEventAssignmen private readonly Lazy _lazyEventReference; private readonly Lazy _lazyHandlerValue; - public LazyEventAssignmentExpression(Lazy eventReference, Lazy handlerValue, bool adds, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(adds, semanticModel, syntax, type, constantValue) + public LazyEventAssignmentExpression(Lazy eventReference, Lazy handlerValue, bool adds, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : base(adds, semanticModel, syntax, type, constantValue, isImplicit) { _lazyEventReference = eventReference ?? throw new System.ArgumentNullException(nameof(eventReference)); @@ -1417,8 +1417,8 @@ public LazyEventAssignmentExpression(Lazy eventRefere /// internal abstract partial class BaseEventReferenceExpression : MemberReferenceExpression, IEventReferenceExpression { - public BaseEventReferenceExpression(IEventSymbol @event, ISymbol member, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(member, OperationKind.EventReferenceExpression, semanticModel, syntax, type, constantValue) + public BaseEventReferenceExpression(IEventSymbol @event, ISymbol member, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(member, OperationKind.EventReferenceExpression, semanticModel, syntax, type, constantValue, isImplicit) { Event = @event; } @@ -1449,8 +1449,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class EventReferenceExpression : BaseEventReferenceExpression, IEventReferenceExpression { - public EventReferenceExpression(IEventSymbol @event, IOperation instance, ISymbol member, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(@event, member, semanticModel, syntax, type, constantValue) + public EventReferenceExpression(IEventSymbol @event, IOperation instance, ISymbol member, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(@event, member, semanticModel, syntax, type, constantValue, isImplicit) { InstanceImpl = instance; } @@ -1464,8 +1464,8 @@ internal sealed partial class LazyEventReferenceExpression : BaseEventReferenceE { private readonly Lazy _lazyInstance; - public LazyEventReferenceExpression(IEventSymbol @event, Lazy instance, ISymbol member, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(@event, member, semanticModel, syntax, type, constantValue) + public LazyEventReferenceExpression(IEventSymbol @event, Lazy instance, ISymbol member, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(@event, member, semanticModel, syntax, type, constantValue, isImplicit) { _lazyInstance = instance ?? throw new System.ArgumentNullException(nameof(instance)); } @@ -1477,8 +1477,8 @@ internal sealed partial class LazyEventReferenceExpression : BaseEventReferenceE /// internal abstract partial class BaseExpressionStatement : Operation, IExpressionStatement { - protected BaseExpressionStatement(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.ExpressionStatement, semanticModel, syntax, type, constantValue) + protected BaseExpressionStatement(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.ExpressionStatement, semanticModel, syntax, type, constantValue, isImplicit) { } @@ -1509,8 +1509,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class ExpressionStatement : BaseExpressionStatement, IExpressionStatement { - public ExpressionStatement(IOperation expression, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(semanticModel, syntax, type, constantValue) + public ExpressionStatement(IOperation expression, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(semanticModel, syntax, type, constantValue, isImplicit) { ExpressionImpl = expression; } @@ -1525,7 +1525,7 @@ internal sealed partial class LazyExpressionStatement : BaseExpressionStatement, { private readonly Lazy _lazyExpression; - public LazyExpressionStatement(Lazy expression, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(semanticModel, syntax, type, constantValue) + public LazyExpressionStatement(Lazy expression, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : base(semanticModel, syntax, type, constantValue, isImplicit) { _lazyExpression = expression ?? throw new System.ArgumentNullException(nameof(expression)); } @@ -1538,8 +1538,8 @@ public LazyExpressionStatement(Lazy expression, SemanticModel semant /// internal abstract partial class BaseFieldInitializer : SymbolInitializer, IFieldInitializer { - public BaseFieldInitializer(ImmutableArray initializedFields, OperationKind kind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(kind, semanticModel, syntax, type, constantValue) + public BaseFieldInitializer(ImmutableArray initializedFields, OperationKind kind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(kind, semanticModel, syntax, type, constantValue, isImplicit) { InitializedFields = initializedFields; } @@ -1570,8 +1570,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class FieldInitializer : BaseFieldInitializer, IFieldInitializer { - public FieldInitializer(ImmutableArray initializedFields, IOperation value, OperationKind kind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(initializedFields, kind, semanticModel, syntax, type, constantValue) + public FieldInitializer(ImmutableArray initializedFields, IOperation value, OperationKind kind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(initializedFields, kind, semanticModel, syntax, type, constantValue, isImplicit) { ValueImpl = value; } @@ -1585,8 +1585,8 @@ internal sealed partial class LazyFieldInitializer : BaseFieldInitializer, IFiel { private readonly Lazy _lazyValue; - public LazyFieldInitializer(ImmutableArray initializedFields, Lazy value, OperationKind kind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(initializedFields, kind, semanticModel, syntax, type, constantValue) + public LazyFieldInitializer(ImmutableArray initializedFields, Lazy value, OperationKind kind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(initializedFields, kind, semanticModel, syntax, type, constantValue, isImplicit) { _lazyValue = value ?? throw new System.ArgumentNullException(nameof(value)); } @@ -1598,8 +1598,8 @@ internal sealed partial class LazyFieldInitializer : BaseFieldInitializer, IFiel /// internal abstract partial class BaseFieldReferenceExpression : MemberReferenceExpression, IFieldReferenceExpression { - public BaseFieldReferenceExpression(IFieldSymbol field, ISymbol member, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(member, OperationKind.FieldReferenceExpression, semanticModel, syntax, type, constantValue) + public BaseFieldReferenceExpression(IFieldSymbol field, ISymbol member, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(member, OperationKind.FieldReferenceExpression, semanticModel, syntax, type, constantValue, isImplicit) { Field = field; } @@ -1630,8 +1630,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class FieldReferenceExpression : BaseFieldReferenceExpression, IFieldReferenceExpression { - public FieldReferenceExpression(IFieldSymbol field, IOperation instance, ISymbol member, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(field, member, semanticModel, syntax, type, constantValue) + public FieldReferenceExpression(IFieldSymbol field, IOperation instance, ISymbol member, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(field, member, semanticModel, syntax, type, constantValue, isImplicit) { InstanceImpl = instance; } @@ -1645,8 +1645,8 @@ internal sealed partial class LazyFieldReferenceExpression : BaseFieldReferenceE { private readonly Lazy _lazyInstance; - public LazyFieldReferenceExpression(IFieldSymbol field, Lazy instance, ISymbol member, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(field, member, semanticModel, syntax, type, constantValue) + public LazyFieldReferenceExpression(IFieldSymbol field, Lazy instance, ISymbol member, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(field, member, semanticModel, syntax, type, constantValue, isImplicit) { _lazyInstance = instance ?? throw new System.ArgumentNullException(nameof(instance)); } @@ -1658,8 +1658,8 @@ internal sealed partial class LazyFieldReferenceExpression : BaseFieldReferenceE /// internal abstract partial class BaseFixedStatement : Operation, IFixedStatement { - protected BaseFixedStatement(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.FixedStatement, semanticModel, syntax, type, constantValue) + protected BaseFixedStatement(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.FixedStatement, semanticModel, syntax, type, constantValue, isImplicit) { } @@ -1696,8 +1696,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class FixedStatement : BaseFixedStatement, IFixedStatement { - public FixedStatement(IVariableDeclarationStatement variables, IOperation body, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(semanticModel, syntax, type, constantValue) + public FixedStatement(IVariableDeclarationStatement variables, IOperation body, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(semanticModel, syntax, type, constantValue, isImplicit) { VariablesImpl = variables; BodyImpl = body; @@ -1715,7 +1715,7 @@ internal sealed partial class LazyFixedStatement : BaseFixedStatement, IFixedSta private readonly Lazy _lazyVariables; private readonly Lazy _lazyBody; - public LazyFixedStatement(Lazy variables, Lazy body, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(semanticModel, syntax, type, constantValue) + public LazyFixedStatement(Lazy variables, Lazy body, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : base(semanticModel, syntax, type, constantValue, isImplicit) { _lazyVariables = variables ?? throw new System.ArgumentNullException(nameof(variables)); _lazyBody = body ?? throw new System.ArgumentNullException(nameof(body)); @@ -1731,8 +1731,8 @@ public LazyFixedStatement(Lazy variables, Lazy internal abstract partial class BaseForEachLoopStatement : LoopStatement, IForEachLoopStatement { - public BaseForEachLoopStatement(ILocalSymbol iterationVariable, LoopKind loopKind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(loopKind, OperationKind.LoopStatement, semanticModel, syntax, type, constantValue) + public BaseForEachLoopStatement(ILocalSymbol iterationVariable, LoopKind loopKind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(loopKind, OperationKind.LoopStatement, semanticModel, syntax, type, constantValue, isImplicit) { IterationVariable = iterationVariable; } @@ -1769,8 +1769,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class ForEachLoopStatement : BaseForEachLoopStatement, IForEachLoopStatement { - public ForEachLoopStatement(ILocalSymbol iterationVariable, IOperation collection, LoopKind loopKind, IOperation body, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(iterationVariable, loopKind, semanticModel, syntax, type, constantValue) + public ForEachLoopStatement(ILocalSymbol iterationVariable, IOperation collection, LoopKind loopKind, IOperation body, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(iterationVariable, loopKind, semanticModel, syntax, type, constantValue, isImplicit) { CollectionImpl = collection; BodyImpl = body; @@ -1788,8 +1788,8 @@ internal sealed partial class LazyForEachLoopStatement : BaseForEachLoopStatemen private readonly Lazy _lazyCollection; private readonly Lazy _lazyBody; - public LazyForEachLoopStatement(ILocalSymbol iterationVariable, Lazy collection, LoopKind loopKind, Lazy body, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(iterationVariable, loopKind, semanticModel, syntax, type, constantValue) + public LazyForEachLoopStatement(ILocalSymbol iterationVariable, Lazy collection, LoopKind loopKind, Lazy body, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(iterationVariable, loopKind, semanticModel, syntax, type, constantValue, isImplicit) { _lazyCollection = collection ?? throw new System.ArgumentNullException(nameof(collection)); _lazyBody = body ?? throw new System.ArgumentNullException(nameof(body)); @@ -1804,8 +1804,8 @@ internal sealed partial class LazyForEachLoopStatement : BaseForEachLoopStatemen /// internal abstract partial class BaseForLoopStatement : ForWhileUntilLoopStatement, IForLoopStatement { - public BaseForLoopStatement(ImmutableArray locals, LoopKind loopKind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(loopKind, OperationKind.LoopStatement, semanticModel, syntax, type, constantValue) + public BaseForLoopStatement(ImmutableArray locals, LoopKind loopKind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(loopKind, OperationKind.LoopStatement, semanticModel, syntax, type, constantValue, isImplicit) { Locals = locals; } @@ -1856,8 +1856,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class ForLoopStatement : BaseForLoopStatement, IForLoopStatement { - public ForLoopStatement(ImmutableArray before, ImmutableArray atLoopBottom, ImmutableArray locals, IOperation condition, LoopKind loopKind, IOperation body, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(locals, loopKind, semanticModel, syntax, type, constantValue) + public ForLoopStatement(ImmutableArray before, ImmutableArray atLoopBottom, ImmutableArray locals, IOperation condition, LoopKind loopKind, IOperation body, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(locals, loopKind, semanticModel, syntax, type, constantValue, isImplicit) { BeforeImpl = before; AtLoopBottomImpl = atLoopBottom; @@ -1881,8 +1881,8 @@ internal sealed partial class LazyForLoopStatement : BaseForLoopStatement, IForL private readonly Lazy _lazyCondition; private readonly Lazy _lazyBody; - public LazyForLoopStatement(Lazy> before, Lazy> atLoopBottom, ImmutableArray locals, Lazy condition, LoopKind loopKind, Lazy body, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(locals, loopKind, semanticModel, syntax, type, constantValue) + public LazyForLoopStatement(Lazy> before, Lazy> atLoopBottom, ImmutableArray locals, Lazy condition, LoopKind loopKind, Lazy body, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(locals, loopKind, semanticModel, syntax, type, constantValue, isImplicit) { _lazyBefore = before; _lazyAtLoopBottom = atLoopBottom; @@ -1904,8 +1904,8 @@ internal sealed partial class LazyForLoopStatement : BaseForLoopStatement, IForL /// internal abstract partial class ForWhileUntilLoopStatement : LoopStatement, IForWhileUntilLoopStatement { - protected ForWhileUntilLoopStatement(LoopKind loopKind, OperationKind kind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(loopKind, kind, semanticModel, syntax, type, constantValue) + protected ForWhileUntilLoopStatement(LoopKind loopKind, OperationKind kind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(loopKind, kind, semanticModel, syntax, type, constantValue, isImplicit) { } protected abstract IOperation ConditionImpl { get; } @@ -1920,8 +1920,8 @@ internal abstract partial class ForWhileUntilLoopStatement : LoopStatement, IFor /// internal abstract partial class BaseIfStatement : Operation, IIfStatement { - protected BaseIfStatement(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.IfStatement, semanticModel, syntax, type, constantValue) + protected BaseIfStatement(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.IfStatement, semanticModel, syntax, type, constantValue, isImplicit) { } @@ -1964,8 +1964,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class IfStatement : BaseIfStatement, IIfStatement { - public IfStatement(IOperation condition, IOperation ifTrueStatement, IOperation ifFalseStatement, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(semanticModel, syntax, type, constantValue) + public IfStatement(IOperation condition, IOperation ifTrueStatement, IOperation ifFalseStatement, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(semanticModel, syntax, type, constantValue, isImplicit) { ConditionImpl = condition; IfTrueStatementImpl = ifTrueStatement; @@ -1986,7 +1986,7 @@ internal sealed partial class LazyIfStatement : BaseIfStatement, IIfStatement private readonly Lazy _lazyIfTrueStatement; private readonly Lazy _lazyIfFalseStatement; - public LazyIfStatement(Lazy condition, Lazy ifTrueStatement, Lazy ifFalseStatement, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(semanticModel, syntax, type, constantValue) + public LazyIfStatement(Lazy condition, Lazy ifTrueStatement, Lazy ifFalseStatement, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : base(semanticModel, syntax, type, constantValue, isImplicit) { _lazyCondition = condition ?? throw new System.ArgumentNullException(nameof(condition)); _lazyIfTrueStatement = ifTrueStatement ?? throw new System.ArgumentNullException(nameof(ifTrueStatement)); @@ -2005,8 +2005,8 @@ public LazyIfStatement(Lazy condition, Lazy ifTrueStatem /// internal abstract partial class BaseIncrementExpression : Operation, IIncrementExpression { - public BaseIncrementExpression(UnaryOperationKind incrementOperationKind, bool usesOperatorMethod, IMethodSymbol operatorMethod, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.IncrementExpression, semanticModel, syntax, type, constantValue) + public BaseIncrementExpression(UnaryOperationKind incrementOperationKind, bool usesOperatorMethod, IMethodSymbol operatorMethod, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.IncrementExpression, semanticModel, syntax, type, constantValue, isImplicit) { IncrementOperationKind = incrementOperationKind; UsesOperatorMethod = usesOperatorMethod; @@ -2052,8 +2052,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class IncrementExpression : BaseIncrementExpression, IIncrementExpression { - public IncrementExpression(UnaryOperationKind incrementOperationKind, IOperation target, bool usesOperatorMethod, IMethodSymbol operatorMethod, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(incrementOperationKind, usesOperatorMethod, operatorMethod, semanticModel, syntax, type, constantValue) + public IncrementExpression(UnaryOperationKind incrementOperationKind, IOperation target, bool usesOperatorMethod, IMethodSymbol operatorMethod, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(incrementOperationKind, usesOperatorMethod, operatorMethod, semanticModel, syntax, type, constantValue, isImplicit) { TargetImpl = target; } @@ -2068,8 +2068,8 @@ internal sealed partial class LazyIncrementExpression : BaseIncrementExpression, { private readonly Lazy _lazyTarget; - public LazyIncrementExpression(UnaryOperationKind incrementOperationKind, Lazy target, bool usesOperatorMethod, IMethodSymbol operatorMethod, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(incrementOperationKind, usesOperatorMethod, operatorMethod, semanticModel, syntax, type, constantValue) + public LazyIncrementExpression(UnaryOperationKind incrementOperationKind, Lazy target, bool usesOperatorMethod, IMethodSymbol operatorMethod, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(incrementOperationKind, usesOperatorMethod, operatorMethod, semanticModel, syntax, type, constantValue, isImplicit) { _lazyTarget = target ?? throw new System.ArgumentNullException(nameof(target)); } @@ -2082,8 +2082,8 @@ internal sealed partial class LazyIncrementExpression : BaseIncrementExpression, /// internal sealed partial class InstanceReferenceExpression : Operation, IInstanceReferenceExpression { - public InstanceReferenceExpression(InstanceReferenceKind instanceReferenceKind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.InstanceReferenceExpression, semanticModel, syntax, type, constantValue) + public InstanceReferenceExpression(InstanceReferenceKind instanceReferenceKind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.InstanceReferenceExpression, semanticModel, syntax, type, constantValue, isImplicit) { InstanceReferenceKind = instanceReferenceKind; } @@ -2114,8 +2114,8 @@ public override void Accept(OperationVisitor visitor) /// internal abstract partial class BaseInterpolatedStringExpression : Operation, IInterpolatedStringExpression { - protected BaseInterpolatedStringExpression(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.InterpolatedStringExpression, semanticModel, syntax, type, constantValue) + protected BaseInterpolatedStringExpression(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.InterpolatedStringExpression, semanticModel, syntax, type, constantValue, isImplicit) { } @@ -2149,8 +2149,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class InterpolatedStringExpression : BaseInterpolatedStringExpression, IInterpolatedStringExpression { - public InterpolatedStringExpression(ImmutableArray parts, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(semanticModel, syntax, type, constantValue) + public InterpolatedStringExpression(ImmutableArray parts, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(semanticModel, syntax, type, constantValue, isImplicit) { PartsImpl = parts; } @@ -2165,7 +2165,7 @@ internal sealed partial class LazyInterpolatedStringExpression : BaseInterpolate { private readonly Lazy> _lazyParts; - public LazyInterpolatedStringExpression(Lazy> parts, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(semanticModel, syntax, type, constantValue) + public LazyInterpolatedStringExpression(Lazy> parts, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : base(semanticModel, syntax, type, constantValue, isImplicit) { _lazyParts = parts; } @@ -2178,8 +2178,8 @@ public LazyInterpolatedStringExpression(Lazy internal abstract partial class BaseInterpolatedStringText : Operation, IInterpolatedStringText { - protected BaseInterpolatedStringText(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.InterpolatedStringText, semanticModel, syntax, type, constantValue) + protected BaseInterpolatedStringText(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.InterpolatedStringText, semanticModel, syntax, type, constantValue, isImplicit) { } @@ -2210,8 +2210,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class InterpolatedStringText : BaseInterpolatedStringText, IInterpolatedStringText { - public InterpolatedStringText(IOperation text, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(semanticModel, syntax, type, constantValue) + public InterpolatedStringText(IOperation text, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(semanticModel, syntax, type, constantValue, isImplicit) { TextImpl = text; } @@ -2226,7 +2226,7 @@ internal sealed partial class LazyInterpolatedStringText : BaseInterpolatedStrin { private readonly Lazy _lazyText; - public LazyInterpolatedStringText(Lazy text, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(semanticModel, syntax, type, constantValue) + public LazyInterpolatedStringText(Lazy text, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : base(semanticModel, syntax, type, constantValue, isImplicit) { _lazyText = text; } @@ -2239,8 +2239,8 @@ public LazyInterpolatedStringText(Lazy text, SemanticModel semanticM /// internal abstract partial class BaseInterpolation : Operation, IInterpolation { - protected BaseInterpolation(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.Interpolation, semanticModel, syntax, type, constantValue) + protected BaseInterpolation(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.Interpolation, semanticModel, syntax, type, constantValue, isImplicit) { } @@ -2283,8 +2283,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class Interpolation : BaseInterpolation, IInterpolation { - public Interpolation(IOperation expression, IOperation alignment, IOperation formatString, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(semanticModel, syntax, type, constantValue) + public Interpolation(IOperation expression, IOperation alignment, IOperation formatString, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(semanticModel, syntax, type, constantValue, isImplicit) { ExpressionImpl = expression; AlignmentImpl = alignment; @@ -2305,8 +2305,8 @@ internal sealed partial class LazyInterpolation : BaseInterpolation, IInterpolat private readonly Lazy _lazyAlignment; private readonly Lazy _lazyFormatString; - public LazyInterpolation(Lazy expression, Lazy alignment, Lazy formatString, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(semanticModel, syntax, type, constantValue) + public LazyInterpolation(Lazy expression, Lazy alignment, Lazy formatString, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(semanticModel, syntax, type, constantValue, isImplicit) { _lazyExpression = expression; _lazyAlignment = alignment; @@ -2326,8 +2326,8 @@ internal sealed partial class LazyInterpolation : BaseInterpolation, IInterpolat /// internal abstract partial class BaseInvalidExpression : Operation, IInvalidExpression { - protected BaseInvalidExpression(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.InvalidExpression, semanticModel, syntax, type, constantValue) + protected BaseInvalidExpression(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.InvalidExpression, semanticModel, syntax, type, constantValue, isImplicit) { } protected abstract ImmutableArray ChildrenImpl { get; } @@ -2351,8 +2351,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class InvalidExpression : BaseInvalidExpression, IInvalidExpression { - public InvalidExpression(ImmutableArray children, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(semanticModel, syntax, type, constantValue) + public InvalidExpression(ImmutableArray children, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(semanticModel, syntax, type, constantValue, isImplicit) { ChildrenImpl = children; } @@ -2367,7 +2367,7 @@ internal sealed partial class LazyInvalidExpression : BaseInvalidExpression, IIn { private readonly Lazy> _lazyChildren; - public LazyInvalidExpression(Lazy> children, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(semanticModel, syntax, type, constantValue) + public LazyInvalidExpression(Lazy> children, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : base(semanticModel, syntax, type, constantValue, isImplicit) { _lazyChildren = children; } @@ -2379,8 +2379,8 @@ public LazyInvalidExpression(Lazy> children, Semantic /// internal abstract partial class BaseInvalidStatement : Operation, IInvalidStatement { - protected BaseInvalidStatement(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.InvalidStatement, semanticModel, syntax, type, constantValue) + protected BaseInvalidStatement(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.InvalidStatement, semanticModel, syntax, type, constantValue, isImplicit) { } protected abstract ImmutableArray ChildrenImpl { get; } @@ -2403,8 +2403,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class InvalidStatement : BaseInvalidStatement, IInvalidStatement { - public InvalidStatement(ImmutableArray children, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(semanticModel, syntax, type, constantValue) + public InvalidStatement(ImmutableArray children, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(semanticModel, syntax, type, constantValue, isImplicit) { ChildrenImpl = children; } @@ -2418,7 +2418,7 @@ internal sealed partial class LazyInvalidStatement : BaseInvalidStatement, IInva { private readonly Lazy> _lazyChildren; - public LazyInvalidStatement(Lazy> children, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(semanticModel, syntax, type, constantValue) + public LazyInvalidStatement(Lazy> children, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : base(semanticModel, syntax, type, constantValue, isImplicit) { _lazyChildren = children; } @@ -2430,8 +2430,8 @@ public LazyInvalidStatement(Lazy> children, SemanticM /// internal abstract partial class BaseInvocationExpression : Operation, IHasArgumentsExpression, IInvocationExpression { - protected BaseInvocationExpression(IMethodSymbol targetMethod, bool isVirtual, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.InvocationExpression, semanticModel, syntax, type, constantValue) + protected BaseInvocationExpression(IMethodSymbol targetMethod, bool isVirtual, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.InvocationExpression, semanticModel, syntax, type, constantValue, isImplicit) { TargetMethod = targetMethod; IsVirtual = isVirtual; @@ -2484,8 +2484,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class InvocationExpression : BaseInvocationExpression, IHasArgumentsExpression, IInvocationExpression { - public InvocationExpression(IMethodSymbol targetMethod, IOperation instance, bool isVirtual, ImmutableArray argumentsInEvaluationOrder, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(targetMethod, isVirtual, semanticModel, syntax, type, constantValue) + public InvocationExpression(IMethodSymbol targetMethod, IOperation instance, bool isVirtual, ImmutableArray argumentsInEvaluationOrder, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(targetMethod, isVirtual, semanticModel, syntax, type, constantValue, isImplicit) { InstanceImpl = instance; ArgumentsInEvaluationOrderImpl = argumentsInEvaluationOrder; @@ -2503,7 +2503,7 @@ internal sealed partial class LazyInvocationExpression : BaseInvocationExpressio private readonly Lazy _lazyInstance; private readonly Lazy> _lazyArgumentsInEvaluationOrder; - public LazyInvocationExpression(IMethodSymbol targetMethod, Lazy instance, bool isVirtual, Lazy> argumentsInEvaluationOrder, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(targetMethod, isVirtual, semanticModel, syntax, type, constantValue) + public LazyInvocationExpression(IMethodSymbol targetMethod, Lazy instance, bool isVirtual, Lazy> argumentsInEvaluationOrder, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : base(targetMethod, isVirtual, semanticModel, syntax, type, constantValue, isImplicit) { _lazyInstance = instance ?? throw new System.ArgumentNullException(nameof(instance)); _lazyArgumentsInEvaluationOrder = argumentsInEvaluationOrder; @@ -2519,8 +2519,8 @@ public LazyInvocationExpression(IMethodSymbol targetMethod, Lazy ins /// internal abstract partial class BaseIsTypeExpression : Operation, IIsTypeExpression { - protected BaseIsTypeExpression(ITypeSymbol isType, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.IsTypeExpression, semanticModel, syntax, type, constantValue) + protected BaseIsTypeExpression(ITypeSymbol isType, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.IsTypeExpression, semanticModel, syntax, type, constantValue, isImplicit) { IsType = isType; } @@ -2556,8 +2556,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class IsTypeExpression : BaseIsTypeExpression, IIsTypeExpression { - public IsTypeExpression(IOperation operand, ITypeSymbol isType, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(isType, semanticModel, syntax, type, constantValue) + public IsTypeExpression(IOperation operand, ITypeSymbol isType, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(isType, semanticModel, syntax, type, constantValue, isImplicit) { OperandImpl = operand; } @@ -2572,7 +2572,7 @@ internal sealed partial class LazyIsTypeExpression : BaseIsTypeExpression, IIsTy { private readonly Lazy _lazyOperand; - public LazyIsTypeExpression(Lazy operand, ITypeSymbol isType, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(isType, semanticModel, syntax, type, constantValue) + public LazyIsTypeExpression(Lazy operand, ITypeSymbol isType, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : base(isType, semanticModel, syntax, type, constantValue, isImplicit) { _lazyOperand = operand ?? throw new System.ArgumentNullException(nameof(operand)); } @@ -2585,8 +2585,8 @@ public LazyIsTypeExpression(Lazy operand, ITypeSymbol isType, Semant /// internal abstract partial class BaseLabelStatement : Operation, ILabelStatement { - protected BaseLabelStatement(ILabelSymbol label, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.LabelStatement, semanticModel, syntax, type, constantValue) + protected BaseLabelStatement(ILabelSymbol label, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.LabelStatement, semanticModel, syntax, type, constantValue, isImplicit) { Label = label; } @@ -2621,8 +2621,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class LabelStatement : BaseLabelStatement, ILabelStatement { - public LabelStatement(ILabelSymbol label, IOperation labeledStatement, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(label, semanticModel, syntax, type, constantValue) + public LabelStatement(ILabelSymbol label, IOperation labeledStatement, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(label, semanticModel, syntax, type, constantValue, isImplicit) { LabeledStatementImpl = labeledStatement; } @@ -2637,7 +2637,7 @@ internal sealed partial class LazyLabelStatement : BaseLabelStatement, ILabelSta { private readonly Lazy _lazyLabeledStatement; - public LazyLabelStatement(ILabelSymbol label, Lazy labeledStatement, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(label, semanticModel, syntax, type, constantValue) + public LazyLabelStatement(ILabelSymbol label, Lazy labeledStatement, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : base(label, semanticModel, syntax, type, constantValue, isImplicit) { _lazyLabeledStatement = labeledStatement ?? throw new System.ArgumentNullException(nameof(labeledStatement)); } @@ -2650,8 +2650,8 @@ public LazyLabelStatement(ILabelSymbol label, Lazy labeledStatement, /// internal abstract partial class BaseLambdaExpression : Operation, ILambdaExpression { - protected BaseLambdaExpression(IMethodSymbol signature, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.LambdaExpression, semanticModel, syntax, type, constantValue) + protected BaseLambdaExpression(IMethodSymbol signature, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.LambdaExpression, semanticModel, syntax, type, constantValue, isImplicit) { Signature = signature; } @@ -2686,8 +2686,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class LambdaExpression : BaseLambdaExpression, ILambdaExpression { - public LambdaExpression(IMethodSymbol signature, IBlockStatement body, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(signature, semanticModel, syntax, type, constantValue) + public LambdaExpression(IMethodSymbol signature, IBlockStatement body, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(signature, semanticModel, syntax, type, constantValue, isImplicit) { BodyImpl = body; } @@ -2702,7 +2702,7 @@ internal sealed partial class LazyLambdaExpression : BaseLambdaExpression, ILamb { private readonly Lazy _lazyBody; - public LazyLambdaExpression(IMethodSymbol signature, Lazy body, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(signature, semanticModel, syntax, type, constantValue) + public LazyLambdaExpression(IMethodSymbol signature, Lazy body, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : base(signature, semanticModel, syntax, type, constantValue, isImplicit) { _lazyBody = body ?? throw new System.ArgumentNullException(nameof(body)); } @@ -2715,8 +2715,8 @@ public LazyLambdaExpression(IMethodSymbol signature, Lazy body, /// internal abstract partial class BaseDynamicMemberReferenceExpression : Operation, IDynamicMemberReferenceExpression { - protected BaseDynamicMemberReferenceExpression(string memberName, ImmutableArray typeArguments, ITypeSymbol containingType, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.DynamicMemberReferenceExpression, semanticModel, syntax, type, constantValue) + protected BaseDynamicMemberReferenceExpression(string memberName, ImmutableArray typeArguments, ITypeSymbol containingType, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.DynamicMemberReferenceExpression, semanticModel, syntax, type, constantValue, isImplicit) { MemberName = memberName; TypeArguments = typeArguments; @@ -2764,8 +2764,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class DynamicMemberReferenceExpression : BaseDynamicMemberReferenceExpression, IDynamicMemberReferenceExpression { - public DynamicMemberReferenceExpression(IOperation instance, string memberName, ImmutableArray typeArguments, ITypeSymbol containingType, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(memberName, typeArguments, containingType, semanticModel, syntax, type, constantValue) + public DynamicMemberReferenceExpression(IOperation instance, string memberName, ImmutableArray typeArguments, ITypeSymbol containingType, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(memberName, typeArguments, containingType, semanticModel, syntax, type, constantValue, isImplicit) { InstanceImpl = instance; } @@ -2780,8 +2780,8 @@ internal sealed partial class LazyDynamicMemberReferenceExpression : BaseDynamic { private readonly Lazy _lazyInstance; - public LazyDynamicMemberReferenceExpression(Lazy lazyInstance, string memberName, ImmutableArray typeArguments, ITypeSymbol containingType, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(memberName, typeArguments, containingType, semanticModel, syntax, type, constantValue) + public LazyDynamicMemberReferenceExpression(Lazy lazyInstance, string memberName, ImmutableArray typeArguments, ITypeSymbol containingType, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(memberName, typeArguments, containingType, semanticModel, syntax, type, constantValue, isImplicit) { _lazyInstance = lazyInstance; } @@ -2794,8 +2794,8 @@ internal sealed partial class LazyDynamicMemberReferenceExpression : BaseDynamic /// internal sealed partial class LiteralExpression : Operation, ILiteralExpression { - public LiteralExpression(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.LiteralExpression, semanticModel, syntax, type, constantValue) + public LiteralExpression(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.LiteralExpression, semanticModel, syntax, type, constantValue, isImplicit) { } public override IEnumerable Children @@ -2820,8 +2820,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class LocalReferenceExpression : Operation, ILocalReferenceExpression { - public LocalReferenceExpression(ILocalSymbol local, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.LocalReferenceExpression, semanticModel, syntax, type, constantValue) + public LocalReferenceExpression(ILocalSymbol local, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.LocalReferenceExpression, semanticModel, syntax, type, constantValue, isImplicit) { Local = local; } @@ -2851,8 +2851,8 @@ public override void Accept(OperationVisitor visitor) /// internal abstract partial class BaseLockStatement : Operation, ILockStatement { - protected BaseLockStatement(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.LockStatement, semanticModel, syntax, type, constantValue) + protected BaseLockStatement(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.LockStatement, semanticModel, syntax, type, constantValue, isImplicit) { } @@ -2889,8 +2889,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class LockStatement : BaseLockStatement, ILockStatement { - public LockStatement(IOperation lockedObject, IOperation body, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(semanticModel, syntax, type, constantValue) + public LockStatement(IOperation lockedObject, IOperation body, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(semanticModel, syntax, type, constantValue, isImplicit) { LockedObjectImpl = lockedObject; BodyImpl = body; @@ -2908,7 +2908,7 @@ internal sealed partial class LazyLockStatement : BaseLockStatement, ILockStatem private readonly Lazy _lazyLockedObject; private readonly Lazy _lazyBody; - public LazyLockStatement(Lazy lockedObject, Lazy body, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(semanticModel, syntax, type, constantValue) + public LazyLockStatement(Lazy lockedObject, Lazy body, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : base(semanticModel, syntax, type, constantValue, isImplicit) { _lazyLockedObject = lockedObject ?? throw new System.ArgumentNullException(nameof(lockedObject)); _lazyBody = body ?? throw new System.ArgumentNullException(nameof(body)); @@ -2924,8 +2924,8 @@ public LazyLockStatement(Lazy lockedObject, Lazy body, S /// internal abstract partial class LoopStatement : Operation, ILoopStatement { - protected LoopStatement(LoopKind loopKind, OperationKind kind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(kind, semanticModel, syntax, type, constantValue) + protected LoopStatement(LoopKind loopKind, OperationKind kind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(kind, semanticModel, syntax, type, constantValue, isImplicit) { LoopKind = loopKind; } @@ -2945,8 +2945,8 @@ internal abstract partial class LoopStatement : Operation, ILoopStatement /// internal abstract partial class MemberReferenceExpression : Operation, IMemberReferenceExpression { - protected MemberReferenceExpression(ISymbol member, OperationKind kind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(kind, semanticModel, syntax, type, constantValue) + protected MemberReferenceExpression(ISymbol member, OperationKind kind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(kind, semanticModel, syntax, type, constantValue, isImplicit) { Member = member; } @@ -2967,8 +2967,8 @@ internal abstract partial class MemberReferenceExpression : Operation, IMemberRe /// internal abstract partial class BaseMethodBindingExpression : MemberReferenceExpression, IMethodBindingExpression { - public BaseMethodBindingExpression(IMethodSymbol method, bool isVirtual, ISymbol member, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(member, OperationKind.MethodBindingExpression, semanticModel, syntax, type, constantValue) + public BaseMethodBindingExpression(IMethodSymbol method, bool isVirtual, ISymbol member, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(member, OperationKind.MethodBindingExpression, semanticModel, syntax, type, constantValue, isImplicit) { Method = method; IsVirtual = isVirtual; @@ -3005,8 +3005,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class MethodBindingExpression : BaseMethodBindingExpression, IMethodBindingExpression { - public MethodBindingExpression(IMethodSymbol method, bool isVirtual, IOperation instance, ISymbol member, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(method, isVirtual, member, semanticModel, syntax, type, constantValue) + public MethodBindingExpression(IMethodSymbol method, bool isVirtual, IOperation instance, ISymbol member, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(method, isVirtual, member, semanticModel, syntax, type, constantValue, isImplicit) { InstanceImpl = instance; } @@ -3023,8 +3023,8 @@ internal sealed partial class LazyMethodBindingExpression : BaseMethodBindingExp { private readonly Lazy _lazyInstance; - public LazyMethodBindingExpression(IMethodSymbol method, bool isVirtual, Lazy instance, ISymbol member, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(method, isVirtual, member, semanticModel, syntax, type, constantValue) + public LazyMethodBindingExpression(IMethodSymbol method, bool isVirtual, Lazy instance, ISymbol member, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(method, isVirtual, member, semanticModel, syntax, type, constantValue, isImplicit) { _lazyInstance = instance ?? throw new System.ArgumentNullException(nameof(instance)); } @@ -3036,8 +3036,8 @@ internal sealed partial class LazyMethodBindingExpression : BaseMethodBindingExp /// internal abstract partial class BaseNullCoalescingExpression : Operation, INullCoalescingExpression { - protected BaseNullCoalescingExpression(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.NullCoalescingExpression, semanticModel, syntax, type, constantValue) + protected BaseNullCoalescingExpression(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.NullCoalescingExpression, semanticModel, syntax, type, constantValue, isImplicit) { } @@ -3074,8 +3074,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class NullCoalescingExpression : BaseNullCoalescingExpression, INullCoalescingExpression { - public NullCoalescingExpression(IOperation primaryOperand, IOperation secondaryOperand, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(semanticModel, syntax, type, constantValue) + public NullCoalescingExpression(IOperation primaryOperand, IOperation secondaryOperand, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(semanticModel, syntax, type, constantValue, isImplicit) { PrimaryOperandImpl = primaryOperand; SecondaryOperandImpl = secondaryOperand; @@ -3093,7 +3093,7 @@ internal sealed partial class LazyNullCoalescingExpression : BaseNullCoalescingE private readonly Lazy _lazyPrimaryOperand; private readonly Lazy _lazySecondaryOperand; - public LazyNullCoalescingExpression(Lazy primaryOperand, Lazy secondaryOperand, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(semanticModel, syntax, type, constantValue) + public LazyNullCoalescingExpression(Lazy primaryOperand, Lazy secondaryOperand, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : base(semanticModel, syntax, type, constantValue, isImplicit) { _lazyPrimaryOperand = primaryOperand ?? throw new System.ArgumentNullException(nameof(primaryOperand)); _lazySecondaryOperand = secondaryOperand ?? throw new System.ArgumentNullException(nameof(secondaryOperand)); @@ -3109,8 +3109,8 @@ public LazyNullCoalescingExpression(Lazy primaryOperand, Lazy internal abstract partial class BaseObjectCreationExpression : Operation, IHasArgumentsExpression, IObjectCreationExpression { - protected BaseObjectCreationExpression(IMethodSymbol constructor, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.ObjectCreationExpression, semanticModel, syntax, type, constantValue) + protected BaseObjectCreationExpression(IMethodSymbol constructor, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.ObjectCreationExpression, semanticModel, syntax, type, constantValue, isImplicit) { Constructor = constructor; } @@ -3158,8 +3158,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class ObjectCreationExpression : BaseObjectCreationExpression, IHasArgumentsExpression, IObjectCreationExpression { - public ObjectCreationExpression(IMethodSymbol constructor, IObjectOrCollectionInitializerExpression initializer, ImmutableArray argumentsInEvaluationOrder, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(constructor, semanticModel, syntax, type, constantValue) + public ObjectCreationExpression(IMethodSymbol constructor, IObjectOrCollectionInitializerExpression initializer, ImmutableArray argumentsInEvaluationOrder, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(constructor, semanticModel, syntax, type, constantValue, isImplicit) { InitializerImpl = initializer; ArgumentsInEvaluationOrderImpl = argumentsInEvaluationOrder; @@ -3177,7 +3177,7 @@ internal sealed partial class LazyObjectCreationExpression : BaseObjectCreationE private readonly Lazy _lazyInitializer; private readonly Lazy> _lazyArgumentsInEvaluationOrder; - public LazyObjectCreationExpression(IMethodSymbol constructor, Lazy initializer, Lazy> argumentsInEvaluationOrder, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(constructor, semanticModel, syntax, type, constantValue) + public LazyObjectCreationExpression(IMethodSymbol constructor, Lazy initializer, Lazy> argumentsInEvaluationOrder, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : base(constructor, semanticModel, syntax, type, constantValue, isImplicit) { _lazyInitializer = initializer; _lazyArgumentsInEvaluationOrder = argumentsInEvaluationOrder; @@ -3194,8 +3194,8 @@ public LazyObjectCreationExpression(IMethodSymbol constructor, Lazy internal abstract partial class BaseAnonymousObjectCreationExpression : Operation, IAnonymousObjectCreationExpression { - protected BaseAnonymousObjectCreationExpression(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.AnonymousObjectCreationExpression, semanticModel, syntax, type, constantValue) + protected BaseAnonymousObjectCreationExpression(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.AnonymousObjectCreationExpression, semanticModel, syntax, type, constantValue, isImplicit) { } @@ -3229,8 +3229,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class AnonymousObjectCreationExpression : BaseAnonymousObjectCreationExpression, IAnonymousObjectCreationExpression { - public AnonymousObjectCreationExpression(ImmutableArray initializers, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(semanticModel, syntax, type, constantValue) + public AnonymousObjectCreationExpression(ImmutableArray initializers, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(semanticModel, syntax, type, constantValue, isImplicit) { InitializersImpl = initializers; } @@ -3245,8 +3245,8 @@ internal sealed partial class LazyAnonymousObjectCreationExpression : BaseAnonym { private readonly Lazy> _lazyInitializers; - public LazyAnonymousObjectCreationExpression(Lazy> initializers, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(semanticModel, syntax, type, constantValue) + public LazyAnonymousObjectCreationExpression(Lazy> initializers, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(semanticModel, syntax, type, constantValue, isImplicit) { _lazyInitializers = initializers; } @@ -3259,8 +3259,8 @@ internal sealed partial class LazyAnonymousObjectCreationExpression : BaseAnonym /// internal sealed partial class OmittedArgumentExpression : Operation, IOmittedArgumentExpression { - public OmittedArgumentExpression(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.OmittedArgumentExpression, semanticModel, syntax, type, constantValue) + public OmittedArgumentExpression(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.OmittedArgumentExpression, semanticModel, syntax, type, constantValue, isImplicit) { } public override IEnumerable Children @@ -3285,8 +3285,8 @@ public override void Accept(OperationVisitor visitor) /// internal abstract partial class BaseParameterInitializer : SymbolInitializer, IParameterInitializer { - public BaseParameterInitializer(IParameterSymbol parameter, OperationKind kind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(kind, semanticModel, syntax, type, constantValue) + public BaseParameterInitializer(IParameterSymbol parameter, OperationKind kind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(kind, semanticModel, syntax, type, constantValue, isImplicit) { Parameter = parameter; } @@ -3317,8 +3317,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class ParameterInitializer : BaseParameterInitializer, IParameterInitializer { - public ParameterInitializer(IParameterSymbol parameter, IOperation value, OperationKind kind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(parameter, kind, semanticModel, syntax, type, constantValue) + public ParameterInitializer(IParameterSymbol parameter, IOperation value, OperationKind kind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(parameter, kind, semanticModel, syntax, type, constantValue, isImplicit) { ValueImpl = value; } @@ -3332,8 +3332,8 @@ internal sealed partial class LazyParameterInitializer : BaseParameterInitialize { private readonly Lazy _lazyValue; - public LazyParameterInitializer(IParameterSymbol parameter, Lazy value, OperationKind kind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(parameter, kind, semanticModel, syntax, type, constantValue) + public LazyParameterInitializer(IParameterSymbol parameter, Lazy value, OperationKind kind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(parameter, kind, semanticModel, syntax, type, constantValue, isImplicit) { _lazyValue = value ?? throw new System.ArgumentNullException(nameof(value)); } @@ -3345,8 +3345,8 @@ internal sealed partial class LazyParameterInitializer : BaseParameterInitialize /// internal sealed partial class ParameterReferenceExpression : Operation, IParameterReferenceExpression { - public ParameterReferenceExpression(IParameterSymbol parameter, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.ParameterReferenceExpression, semanticModel, syntax, type, constantValue) + public ParameterReferenceExpression(IParameterSymbol parameter, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.ParameterReferenceExpression, semanticModel, syntax, type, constantValue, isImplicit) { Parameter = parameter; } @@ -3376,8 +3376,8 @@ public override void Accept(OperationVisitor visitor) /// internal abstract partial class BaseParenthesizedExpression : Operation, IParenthesizedExpression { - protected BaseParenthesizedExpression(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.ParenthesizedExpression, semanticModel, syntax, type, constantValue) + protected BaseParenthesizedExpression(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.ParenthesizedExpression, semanticModel, syntax, type, constantValue, isImplicit) { } @@ -3408,8 +3408,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class ParenthesizedExpression : BaseParenthesizedExpression, IParenthesizedExpression { - public ParenthesizedExpression(IOperation operand, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(semanticModel, syntax, type, constantValue) + public ParenthesizedExpression(IOperation operand, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(semanticModel, syntax, type, constantValue, isImplicit) { OperandImpl = operand; } @@ -3424,7 +3424,7 @@ internal sealed partial class LazyParenthesizedExpression : BaseParenthesizedExp { private readonly Lazy _lazyOperand; - public LazyParenthesizedExpression(Lazy operand, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(semanticModel, syntax, type, constantValue) + public LazyParenthesizedExpression(Lazy operand, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : base(semanticModel, syntax, type, constantValue, isImplicit) { _lazyOperand = operand ?? throw new System.ArgumentNullException(nameof(operand)); } @@ -3438,8 +3438,8 @@ public LazyParenthesizedExpression(Lazy operand, SemanticModel seman /// internal sealed partial class PlaceholderExpression : Operation, IPlaceholderExpression { - public PlaceholderExpression(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.PlaceholderExpression, semanticModel, syntax, type, constantValue) + public PlaceholderExpression(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.PlaceholderExpression, semanticModel, syntax, type, constantValue, isImplicit) { } public override IEnumerable Children @@ -3464,8 +3464,8 @@ public override void Accept(OperationVisitor visitor) /// internal abstract partial class BasePointerIndirectionReferenceExpression : Operation, IPointerIndirectionReferenceExpression { - protected BasePointerIndirectionReferenceExpression(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.PointerIndirectionReferenceExpression, semanticModel, syntax, type, constantValue) + protected BasePointerIndirectionReferenceExpression(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.PointerIndirectionReferenceExpression, semanticModel, syntax, type, constantValue, isImplicit) { } @@ -3496,8 +3496,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class PointerIndirectionReferenceExpression : BasePointerIndirectionReferenceExpression, IPointerIndirectionReferenceExpression { - public PointerIndirectionReferenceExpression(IOperation pointer, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(semanticModel, syntax, type, constantValue) + public PointerIndirectionReferenceExpression(IOperation pointer, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(semanticModel, syntax, type, constantValue, isImplicit) { PointerImpl = pointer; } @@ -3512,7 +3512,7 @@ internal sealed partial class LazyPointerIndirectionReferenceExpression : BasePo { private readonly Lazy _lazyPointer; - public LazyPointerIndirectionReferenceExpression(Lazy pointer, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(semanticModel, syntax, type, constantValue) + public LazyPointerIndirectionReferenceExpression(Lazy pointer, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : base(semanticModel, syntax, type, constantValue, isImplicit) { _lazyPointer = pointer ?? throw new System.ArgumentNullException(nameof(pointer)); } @@ -3525,8 +3525,8 @@ public LazyPointerIndirectionReferenceExpression(Lazy pointer, Seman /// internal abstract partial class BasePropertyInitializer : SymbolInitializer, IPropertyInitializer { - public BasePropertyInitializer(IPropertySymbol initializedProperty, OperationKind kind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(kind, semanticModel, syntax, type, constantValue) + public BasePropertyInitializer(IPropertySymbol initializedProperty, OperationKind kind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(kind, semanticModel, syntax, type, constantValue, isImplicit) { InitializedProperty = initializedProperty; } @@ -3557,8 +3557,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class PropertyInitializer : BasePropertyInitializer, IPropertyInitializer { - public PropertyInitializer(IPropertySymbol initializedProperty, IOperation value, OperationKind kind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(initializedProperty, kind, semanticModel, syntax, type, constantValue) + public PropertyInitializer(IPropertySymbol initializedProperty, IOperation value, OperationKind kind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(initializedProperty, kind, semanticModel, syntax, type, constantValue, isImplicit) { ValueImpl = value; } @@ -3572,8 +3572,8 @@ internal sealed partial class LazyPropertyInitializer : BasePropertyInitializer, { private readonly Lazy _lazyValue; - public LazyPropertyInitializer(IPropertySymbol initializedProperty, Lazy value, OperationKind kind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(initializedProperty, kind, semanticModel, syntax, type, constantValue) + public LazyPropertyInitializer(IPropertySymbol initializedProperty, Lazy value, OperationKind kind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(initializedProperty, kind, semanticModel, syntax, type, constantValue, isImplicit) { _lazyValue = value ?? throw new System.ArgumentNullException(nameof(value)); } @@ -3585,8 +3585,8 @@ internal sealed partial class LazyPropertyInitializer : BasePropertyInitializer, /// internal abstract partial class BasePropertyReferenceExpression : MemberReferenceExpression, IPropertyReferenceExpression, IHasArgumentsExpression { - protected BasePropertyReferenceExpression(IPropertySymbol property, ISymbol member, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(member, OperationKind.PropertyReferenceExpression, semanticModel, syntax, type, constantValue) + protected BasePropertyReferenceExpression(IPropertySymbol property, ISymbol member, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(member, OperationKind.PropertyReferenceExpression, semanticModel, syntax, type, constantValue, isImplicit) { Property = property; } @@ -3630,8 +3630,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class PropertyReferenceExpression : BasePropertyReferenceExpression, IPropertyReferenceExpression, IHasArgumentsExpression { - public PropertyReferenceExpression(IPropertySymbol property, IOperation instance, ISymbol member, ImmutableArray argumentsInEvaluationOrder, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(property, member, semanticModel, syntax, type, constantValue) + public PropertyReferenceExpression(IPropertySymbol property, IOperation instance, ISymbol member, ImmutableArray argumentsInEvaluationOrder, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(property, member, semanticModel, syntax, type, constantValue, isImplicit) { InstanceImpl = instance; ArgumentsInEvaluationOrderImpl = argumentsInEvaluationOrder; @@ -3657,8 +3657,8 @@ internal sealed partial class LazyPropertyReferenceExpression : BasePropertyRefe private readonly Lazy _lazyInstance; private readonly Lazy> _lazyArgumentsInEvaluationOrder; - public LazyPropertyReferenceExpression(IPropertySymbol property, Lazy instance, ISymbol member, Lazy> argumentsInEvaluationOrder, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(property, member, semanticModel, syntax, type, constantValue) + public LazyPropertyReferenceExpression(IPropertySymbol property, Lazy instance, ISymbol member, Lazy> argumentsInEvaluationOrder, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(property, member, semanticModel, syntax, type, constantValue, isImplicit) { _lazyInstance = instance ?? throw new System.ArgumentNullException(nameof(instance)); _lazyArgumentsInEvaluationOrder = argumentsInEvaluationOrder ?? throw new System.ArgumentNullException(nameof(argumentsInEvaluationOrder)); @@ -3682,8 +3682,8 @@ public override void Accept(OperationVisitor visitor) /// internal abstract partial class BaseRangeCaseClause : CaseClause, IRangeCaseClause { - public BaseRangeCaseClause(CaseKind caseKind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(caseKind, OperationKind.RangeCaseClause, semanticModel, syntax, type, constantValue) + public BaseRangeCaseClause(CaseKind caseKind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(caseKind, OperationKind.RangeCaseClause, semanticModel, syntax, type, constantValue, isImplicit) { } @@ -3721,8 +3721,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class RangeCaseClause : BaseRangeCaseClause, IRangeCaseClause { - public RangeCaseClause(IOperation minimumValue, IOperation maximumValue, CaseKind caseKind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(caseKind, semanticModel, syntax, type, constantValue) + public RangeCaseClause(IOperation minimumValue, IOperation maximumValue, CaseKind caseKind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(caseKind, semanticModel, syntax, type, constantValue, isImplicit) { MinimumValueImpl = minimumValue; MaximumValueImpl = maximumValue; @@ -3740,8 +3740,8 @@ internal sealed partial class LazyRangeCaseClause : BaseRangeCaseClause, IRangeC private readonly Lazy _lazyMinimumValue; private readonly Lazy _lazyMaximumValue; - public LazyRangeCaseClause(Lazy minimumValue, Lazy maximumValue, CaseKind caseKind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(caseKind, semanticModel, syntax, type, constantValue) + public LazyRangeCaseClause(Lazy minimumValue, Lazy maximumValue, CaseKind caseKind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(caseKind, semanticModel, syntax, type, constantValue, isImplicit) { _lazyMinimumValue = minimumValue ?? throw new System.ArgumentNullException(nameof(minimumValue)); _lazyMaximumValue = maximumValue ?? throw new System.ArgumentNullException(nameof(maximumValue)); @@ -3757,8 +3757,8 @@ internal sealed partial class LazyRangeCaseClause : BaseRangeCaseClause, IRangeC /// internal abstract partial class BaseRelationalCaseClause : CaseClause, IRelationalCaseClause { - public BaseRelationalCaseClause(BinaryOperationKind relation, CaseKind caseKind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(caseKind, OperationKind.RelationalCaseClause, semanticModel, syntax, type, constantValue) + public BaseRelationalCaseClause(BinaryOperationKind relation, CaseKind caseKind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(caseKind, OperationKind.RelationalCaseClause, semanticModel, syntax, type, constantValue, isImplicit) { Relation = relation; } @@ -3795,8 +3795,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class RelationalCaseClause : BaseRelationalCaseClause, IRelationalCaseClause { - public RelationalCaseClause(IOperation value, BinaryOperationKind relation, CaseKind caseKind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(relation, caseKind, semanticModel, syntax, type, constantValue) + public RelationalCaseClause(IOperation value, BinaryOperationKind relation, CaseKind caseKind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(relation, caseKind, semanticModel, syntax, type, constantValue, isImplicit) { ValueImpl = value; } @@ -3811,8 +3811,8 @@ internal sealed partial class LazyRelationalCaseClause : BaseRelationalCaseClaus { private readonly Lazy _lazyValue; - public LazyRelationalCaseClause(Lazy value, BinaryOperationKind relation, CaseKind caseKind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(relation, caseKind, semanticModel, syntax, type, constantValue) + public LazyRelationalCaseClause(Lazy value, BinaryOperationKind relation, CaseKind caseKind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(relation, caseKind, semanticModel, syntax, type, constantValue, isImplicit) { _lazyValue = value ?? throw new System.ArgumentNullException(nameof(value)); } @@ -3825,8 +3825,8 @@ internal sealed partial class LazyRelationalCaseClause : BaseRelationalCaseClaus /// internal abstract partial class BaseReturnStatement : Operation, IReturnStatement { - protected BaseReturnStatement(OperationKind kind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(kind, semanticModel, syntax, type, constantValue) + protected BaseReturnStatement(OperationKind kind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(kind, semanticModel, syntax, type, constantValue, isImplicit) { Debug.Assert(kind == OperationKind.ReturnStatement || kind == OperationKind.YieldReturnStatement @@ -3874,8 +3874,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class ReturnStatement : BaseReturnStatement, IReturnStatement { - public ReturnStatement(OperationKind kind, IOperation returnedValue, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(kind, semanticModel, syntax, type, constantValue) + public ReturnStatement(OperationKind kind, IOperation returnedValue, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(kind, semanticModel, syntax, type, constantValue, isImplicit) { ReturnedValueImpl = returnedValue; } @@ -3890,7 +3890,7 @@ internal sealed partial class LazyReturnStatement : BaseReturnStatement, IReturn { private readonly Lazy _lazyReturnedValue; - public LazyReturnStatement(OperationKind kind, Lazy returnedValue, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(kind, semanticModel, syntax, type, constantValue) + public LazyReturnStatement(OperationKind kind, Lazy returnedValue, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : base(kind, semanticModel, syntax, type, constantValue, isImplicit) { _lazyReturnedValue = returnedValue ?? throw new System.ArgumentNullException(nameof(returnedValue)); } @@ -3903,8 +3903,8 @@ public LazyReturnStatement(OperationKind kind, Lazy returnedValue, S /// internal abstract partial class BaseSingleValueCaseClause : CaseClause, ISingleValueCaseClause { - public BaseSingleValueCaseClause(BinaryOperationKind equality, CaseKind caseKind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(caseKind, OperationKind.SingleValueCaseClause, semanticModel, syntax, type, constantValue) + public BaseSingleValueCaseClause(BinaryOperationKind equality, CaseKind caseKind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(caseKind, OperationKind.SingleValueCaseClause, semanticModel, syntax, type, constantValue, isImplicit) { Equality = equality; } @@ -3941,8 +3941,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class SingleValueCaseClause : BaseSingleValueCaseClause, ISingleValueCaseClause { - public SingleValueCaseClause(IOperation value, BinaryOperationKind equality, CaseKind caseKind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(equality, caseKind, semanticModel, syntax, type, constantValue) + public SingleValueCaseClause(IOperation value, BinaryOperationKind equality, CaseKind caseKind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(equality, caseKind, semanticModel, syntax, type, constantValue, isImplicit) { ValueImpl = value; } @@ -3957,8 +3957,8 @@ internal sealed partial class LazySingleValueCaseClause : BaseSingleValueCaseCla { private readonly Lazy _lazyValue; - public LazySingleValueCaseClause(Lazy value, BinaryOperationKind equality, CaseKind caseKind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(equality, caseKind, semanticModel, syntax, type, constantValue) + public LazySingleValueCaseClause(Lazy value, BinaryOperationKind equality, CaseKind caseKind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(equality, caseKind, semanticModel, syntax, type, constantValue, isImplicit) { _lazyValue = value ?? throw new System.ArgumentNullException(nameof(value)); } @@ -3971,8 +3971,8 @@ internal sealed partial class LazySingleValueCaseClause : BaseSingleValueCaseCla /// internal sealed partial class DefaultCaseClause : CaseClause, IDefaultCaseClause { - public DefaultCaseClause(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(CaseKind.Default, OperationKind.DefaultCaseClause, semanticModel, syntax, type, constantValue) + public DefaultCaseClause(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(CaseKind.Default, OperationKind.DefaultCaseClause, semanticModel, syntax, type, constantValue, isImplicit) { } public override IEnumerable Children @@ -3997,8 +3997,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class SizeOfExpression : TypeOperationExpression, ISizeOfExpression { - public SizeOfExpression(ITypeSymbol typeOperand, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(typeOperand, OperationKind.SizeOfExpression, semanticModel, syntax, type, constantValue) + public SizeOfExpression(ITypeSymbol typeOperand, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(typeOperand, OperationKind.SizeOfExpression, semanticModel, syntax, type, constantValue, isImplicit) { } public override IEnumerable Children @@ -4023,8 +4023,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class StopStatement : Operation, IStopStatement { - public StopStatement(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.StopStatement, semanticModel, syntax, type, constantValue) + public StopStatement(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.StopStatement, semanticModel, syntax, type, constantValue, isImplicit) { } public override IEnumerable Children @@ -4049,8 +4049,8 @@ public override void Accept(OperationVisitor visitor) /// internal abstract partial class BaseSwitchCase : Operation, ISwitchCase { - protected BaseSwitchCase(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.SwitchCase, semanticModel, syntax, type, constantValue) + protected BaseSwitchCase(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.SwitchCase, semanticModel, syntax, type, constantValue, isImplicit) { } @@ -4093,8 +4093,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class SwitchCase : BaseSwitchCase, ISwitchCase { - public SwitchCase(ImmutableArray clauses, ImmutableArray body, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(semanticModel, syntax, type, constantValue) + public SwitchCase(ImmutableArray clauses, ImmutableArray body, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(semanticModel, syntax, type, constantValue, isImplicit) { ClausesImpl = clauses; BodyImpl = body; @@ -4112,7 +4112,7 @@ internal sealed partial class LazySwitchCase : BaseSwitchCase, ISwitchCase private readonly Lazy> _lazyClauses; private readonly Lazy> _lazyBody; - public LazySwitchCase(Lazy> clauses, Lazy> body, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(semanticModel, syntax, type, constantValue) + public LazySwitchCase(Lazy> clauses, Lazy> body, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : base(semanticModel, syntax, type, constantValue, isImplicit) { _lazyClauses = clauses; _lazyBody = body; @@ -4128,8 +4128,8 @@ public LazySwitchCase(Lazy> clauses, Lazy internal abstract partial class BaseSwitchStatement : Operation, ISwitchStatement { - protected BaseSwitchStatement(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.SwitchStatement, semanticModel, syntax, type, constantValue) + protected BaseSwitchStatement(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.SwitchStatement, semanticModel, syntax, type, constantValue, isImplicit) { } @@ -4169,8 +4169,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class SwitchStatement : BaseSwitchStatement, ISwitchStatement { - public SwitchStatement(IOperation value, ImmutableArray cases, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(semanticModel, syntax, type, constantValue) + public SwitchStatement(IOperation value, ImmutableArray cases, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(semanticModel, syntax, type, constantValue, isImplicit) { ValueImpl = value; CasesImpl = cases; @@ -4188,7 +4188,7 @@ internal sealed partial class LazySwitchStatement : BaseSwitchStatement, ISwitch private readonly Lazy _lazyValue; private readonly Lazy> _lazyCases; - public LazySwitchStatement(Lazy value, Lazy> cases, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(semanticModel, syntax, type, constantValue) + public LazySwitchStatement(Lazy value, Lazy> cases, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : base(semanticModel, syntax, type, constantValue, isImplicit) { _lazyValue = value ?? throw new System.ArgumentNullException(nameof(value)); _lazyCases = cases; @@ -4204,8 +4204,8 @@ public LazySwitchStatement(Lazy value, Lazy internal abstract partial class SymbolInitializer : Operation, ISymbolInitializer { - protected SymbolInitializer(OperationKind kind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(kind, semanticModel, syntax, type, constantValue) + protected SymbolInitializer(OperationKind kind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(kind, semanticModel, syntax, type, constantValue, isImplicit) { } protected abstract IOperation ValueImpl { get; } @@ -4217,8 +4217,8 @@ internal abstract partial class SymbolInitializer : Operation, ISymbolInitialize /// internal abstract partial class BaseSyntheticLocalReferenceExpression : Operation, ISyntheticLocalReferenceExpression { - protected BaseSyntheticLocalReferenceExpression(SyntheticLocalKind syntheticLocalKind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.SyntheticLocalReferenceExpression, semanticModel, syntax, type, constantValue) + protected BaseSyntheticLocalReferenceExpression(SyntheticLocalKind syntheticLocalKind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.SyntheticLocalReferenceExpression, semanticModel, syntax, type, constantValue, isImplicit) { SyntheticLocalKind = syntheticLocalKind; } @@ -4249,8 +4249,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class SyntheticLocalReferenceExpression : BaseSyntheticLocalReferenceExpression, ISyntheticLocalReferenceExpression { - public SyntheticLocalReferenceExpression(SyntheticLocalKind syntheticLocalKind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(syntheticLocalKind, semanticModel, syntax, type, constantValue) + public SyntheticLocalReferenceExpression(SyntheticLocalKind syntheticLocalKind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(syntheticLocalKind, semanticModel, syntax, type, constantValue, isImplicit) { } } @@ -4260,8 +4260,8 @@ internal sealed partial class SyntheticLocalReferenceExpression : BaseSyntheticL /// internal sealed partial class LazySyntheticLocalReferenceExpression : BaseSyntheticLocalReferenceExpression, ISyntheticLocalReferenceExpression { - public LazySyntheticLocalReferenceExpression(SyntheticLocalKind syntheticLocalKind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(syntheticLocalKind, semanticModel, syntax, type, constantValue) + public LazySyntheticLocalReferenceExpression(SyntheticLocalKind syntheticLocalKind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(syntheticLocalKind, semanticModel, syntax, type, constantValue, isImplicit) { } } @@ -4271,8 +4271,8 @@ internal sealed partial class LazySyntheticLocalReferenceExpression : BaseSynthe /// internal abstract partial class BaseThrowStatement : Operation, IThrowStatement { - protected BaseThrowStatement(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.ThrowStatement, semanticModel, syntax, type, constantValue) + protected BaseThrowStatement(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.ThrowStatement, semanticModel, syntax, type, constantValue, isImplicit) { } @@ -4303,8 +4303,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class ThrowStatement : BaseThrowStatement, IThrowStatement { - public ThrowStatement(IOperation thrownObject, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(semanticModel, syntax, type, constantValue) + public ThrowStatement(IOperation thrownObject, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(semanticModel, syntax, type, constantValue, isImplicit) { ThrownObjectImpl = thrownObject; } @@ -4319,7 +4319,7 @@ internal sealed partial class LazyThrowStatement : BaseThrowStatement, IThrowSta { private readonly Lazy _lazyThrownObject; - public LazyThrowStatement(Lazy thrownObject, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(semanticModel, syntax, type, constantValue) + public LazyThrowStatement(Lazy thrownObject, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : base(semanticModel, syntax, type, constantValue, isImplicit) { _lazyThrownObject = thrownObject ?? throw new System.ArgumentNullException(nameof(thrownObject)); } @@ -4332,8 +4332,8 @@ public LazyThrowStatement(Lazy thrownObject, SemanticModel semanticM /// internal abstract partial class BaseTryStatement : Operation, ITryStatement { - protected BaseTryStatement(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.TryStatement, semanticModel, syntax, type, constantValue) + protected BaseTryStatement(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.TryStatement, semanticModel, syntax, type, constantValue, isImplicit) { } @@ -4379,8 +4379,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class TryStatement : BaseTryStatement, ITryStatement { - public TryStatement(IBlockStatement body, ImmutableArray catches, IBlockStatement finallyHandler, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(semanticModel, syntax, type, constantValue) + public TryStatement(IBlockStatement body, ImmutableArray catches, IBlockStatement finallyHandler, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(semanticModel, syntax, type, constantValue, isImplicit) { BodyImpl = body; CatchesImpl = catches; @@ -4401,7 +4401,7 @@ internal sealed partial class LazyTryStatement : BaseTryStatement, ITryStatement private readonly Lazy> _lazyCatches; private readonly Lazy _lazyFinallyHandler; - public LazyTryStatement(Lazy body, Lazy> catches, Lazy finallyHandler, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(semanticModel, syntax, type, constantValue) + public LazyTryStatement(Lazy body, Lazy> catches, Lazy finallyHandler, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : base(semanticModel, syntax, type, constantValue, isImplicit) { _lazyBody = body ?? throw new System.ArgumentNullException(nameof(body)); _lazyCatches = catches; @@ -4420,8 +4420,8 @@ public LazyTryStatement(Lazy body, Lazy internal abstract partial class BaseTupleExpression : Operation, ITupleExpression { - protected BaseTupleExpression(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.TupleExpression, semanticModel, syntax, type, constantValue) + protected BaseTupleExpression(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.TupleExpression, semanticModel, syntax, type, constantValue, isImplicit) { } @@ -4455,8 +4455,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class TupleExpression : BaseTupleExpression, ITupleExpression { - public TupleExpression(ImmutableArray elements, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(semanticModel, syntax, type, constantValue) + public TupleExpression(ImmutableArray elements, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(semanticModel, syntax, type, constantValue, isImplicit) { ElementsImpl = elements; } @@ -4471,8 +4471,8 @@ internal sealed partial class LazyTupleExpression : BaseTupleExpression, ITupleE { private readonly Lazy> _lazyElements; - public LazyTupleExpression(Lazy> elements, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(semanticModel, syntax, type, constantValue) + public LazyTupleExpression(Lazy> elements, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(semanticModel, syntax, type, constantValue, isImplicit) { _lazyElements = elements; } @@ -4485,8 +4485,8 @@ internal sealed partial class LazyTupleExpression : BaseTupleExpression, ITupleE /// internal sealed partial class TypeOfExpression : TypeOperationExpression, ITypeOfExpression { - public TypeOfExpression(ITypeSymbol typeOperand, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(typeOperand, OperationKind.TypeOfExpression, semanticModel, syntax, type, constantValue) + public TypeOfExpression(ITypeSymbol typeOperand, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(typeOperand, OperationKind.TypeOfExpression, semanticModel, syntax, type, constantValue, isImplicit) { } public override IEnumerable Children @@ -4511,8 +4511,8 @@ public override void Accept(OperationVisitor visitor) /// internal abstract partial class TypeOperationExpression : Operation, ITypeOperationExpression { - protected TypeOperationExpression(ITypeSymbol typeOperand, OperationKind kind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(kind, semanticModel, syntax, type, constantValue) + protected TypeOperationExpression(ITypeSymbol typeOperand, OperationKind kind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(kind, semanticModel, syntax, type, constantValue, isImplicit) { TypeOperand = typeOperand; } @@ -4527,8 +4527,8 @@ internal abstract partial class TypeOperationExpression : Operation, ITypeOperat /// internal abstract partial class BaseTypeParameterObjectCreationExpression : Operation, ITypeParameterObjectCreationExpression { - public BaseTypeParameterObjectCreationExpression(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.TypeParameterObjectCreationExpression, semanticModel, syntax, type, constantValue) + public BaseTypeParameterObjectCreationExpression(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.TypeParameterObjectCreationExpression, semanticModel, syntax, type, constantValue, isImplicit) { } protected abstract IObjectOrCollectionInitializerExpression InitializerImpl { get; } @@ -4558,8 +4558,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class TypeParameterObjectCreationExpression : BaseTypeParameterObjectCreationExpression, ITypeParameterObjectCreationExpression { - public TypeParameterObjectCreationExpression(IObjectOrCollectionInitializerExpression initializer, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(semanticModel, syntax, type, constantValue) + public TypeParameterObjectCreationExpression(IObjectOrCollectionInitializerExpression initializer, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(semanticModel, syntax, type, constantValue, isImplicit) { InitializerImpl = initializer; } @@ -4572,8 +4572,8 @@ internal sealed partial class TypeParameterObjectCreationExpression : BaseTypePa internal sealed partial class LazyTypeParameterObjectCreationExpression : BaseTypeParameterObjectCreationExpression, ITypeParameterObjectCreationExpression { private readonly Lazy _lazyInitializer; - public LazyTypeParameterObjectCreationExpression(Lazy initializer, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(semanticModel, syntax, type, constantValue) + public LazyTypeParameterObjectCreationExpression(Lazy initializer, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(semanticModel, syntax, type, constantValue, isImplicit) { _lazyInitializer = initializer ?? throw new System.ArgumentNullException(nameof(initializer)); } @@ -4585,8 +4585,8 @@ internal sealed partial class LazyTypeParameterObjectCreationExpression : BaseTy /// internal abstract partial class BaseDynamicObjectCreationExpression : Operation, IHasDynamicArgumentsExpression, IDynamicObjectCreationExpression { - public BaseDynamicObjectCreationExpression(string name, ImmutableArray applicableSymbols, ImmutableArray argumentNames, ImmutableArray argumentRefKinds, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.TypeParameterObjectCreationExpression, semanticModel, syntax, type, constantValue) + public BaseDynamicObjectCreationExpression(string name, ImmutableArray applicableSymbols, ImmutableArray argumentNames, ImmutableArray argumentRefKinds, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.TypeParameterObjectCreationExpression, semanticModel, syntax, type, constantValue, isImplicit) { Name = name; ApplicableSymbols = applicableSymbols; @@ -4646,8 +4646,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class DynamicObjectCreationExpression : BaseDynamicObjectCreationExpression, IHasDynamicArgumentsExpression, IDynamicObjectCreationExpression { - public DynamicObjectCreationExpression(string name, ImmutableArray applicableSymbols, ImmutableArray arguments, ImmutableArray argumentNames, ImmutableArray argumentRefKinds, IObjectOrCollectionInitializerExpression initializer, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(name, applicableSymbols, argumentNames, argumentRefKinds, semanticModel, syntax, type, constantValue) + public DynamicObjectCreationExpression(string name, ImmutableArray applicableSymbols, ImmutableArray arguments, ImmutableArray argumentNames, ImmutableArray argumentRefKinds, IObjectOrCollectionInitializerExpression initializer, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(name, applicableSymbols, argumentNames, argumentRefKinds, semanticModel, syntax, type, constantValue, isImplicit) { ArgumentsImpl = arguments; InitializerImpl = initializer; @@ -4663,8 +4663,8 @@ internal sealed partial class LazyDynamicObjectCreationExpression : BaseDynamicO { private readonly Lazy _lazyInitializer; private readonly Lazy> _lazyArguments; - public LazyDynamicObjectCreationExpression(string name, ImmutableArray applicableSymbols, Lazy> arguments, ImmutableArray argumentNames, ImmutableArray argumentRefKinds, Lazy initializer, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(name, applicableSymbols, argumentNames, argumentRefKinds, semanticModel, syntax, type, constantValue) + public LazyDynamicObjectCreationExpression(string name, ImmutableArray applicableSymbols, Lazy> arguments, ImmutableArray argumentNames, ImmutableArray argumentRefKinds, Lazy initializer, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(name, applicableSymbols, argumentNames, argumentRefKinds, semanticModel, syntax, type, constantValue, isImplicit) { _lazyArguments = arguments ?? throw new System.ArgumentNullException(nameof(arguments)); _lazyInitializer = initializer ?? throw new System.ArgumentNullException(nameof(initializer)); @@ -4678,8 +4678,8 @@ internal sealed partial class LazyDynamicObjectCreationExpression : BaseDynamicO /// internal abstract partial class BaseUnaryOperatorExpression : Operation, IHasOperatorMethodExpression, IUnaryOperatorExpression { - protected BaseUnaryOperatorExpression(UnaryOperationKind unaryOperationKind, bool isLifted, bool usesOperatorMethod, IMethodSymbol operatorMethod, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.UnaryOperatorExpression, semanticModel, syntax, type, constantValue) + protected BaseUnaryOperatorExpression(UnaryOperationKind unaryOperationKind, bool isLifted, bool usesOperatorMethod, IMethodSymbol operatorMethod, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.UnaryOperatorExpression, semanticModel, syntax, type, constantValue, isImplicit) { UnaryOperationKind = unaryOperationKind; UsesOperatorMethod = usesOperatorMethod; @@ -4728,8 +4728,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class UnaryOperatorExpression : BaseUnaryOperatorExpression, IHasOperatorMethodExpression, IUnaryOperatorExpression { - public UnaryOperatorExpression(UnaryOperationKind unaryOperationKind, IOperation operand, bool isLifted, bool usesOperatorMethod, IMethodSymbol operatorMethod, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(unaryOperationKind, isLifted, usesOperatorMethod, operatorMethod, semanticModel, syntax, type, constantValue) + public UnaryOperatorExpression(UnaryOperationKind unaryOperationKind, IOperation operand, bool isLifted, bool usesOperatorMethod, IMethodSymbol operatorMethod, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(unaryOperationKind, isLifted, usesOperatorMethod, operatorMethod, semanticModel, syntax, type, constantValue, isImplicit) { OperandImpl = operand; } @@ -4744,8 +4744,8 @@ internal sealed partial class LazyUnaryOperatorExpression : BaseUnaryOperatorExp { private readonly Lazy _lazyOperand; - public LazyUnaryOperatorExpression(UnaryOperationKind unaryOperationKind, Lazy operand, bool isLifted, bool usesOperatorMethod, IMethodSymbol operatorMethod, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(unaryOperationKind, isLifted, usesOperatorMethod, operatorMethod, semanticModel, syntax, type, constantValue) + public LazyUnaryOperatorExpression(UnaryOperationKind unaryOperationKind, Lazy operand, bool isLifted, bool usesOperatorMethod, IMethodSymbol operatorMethod, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(unaryOperationKind, isLifted, usesOperatorMethod, operatorMethod, semanticModel, syntax, type, constantValue, isImplicit) { _lazyOperand = operand ?? throw new System.ArgumentNullException(nameof(operand)); } @@ -4758,8 +4758,8 @@ internal sealed partial class LazyUnaryOperatorExpression : BaseUnaryOperatorExp /// internal abstract partial class BaseUsingStatement : Operation, IUsingStatement { - protected BaseUsingStatement(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.UsingStatement, semanticModel, syntax, type, constantValue) + protected BaseUsingStatement(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.UsingStatement, semanticModel, syntax, type, constantValue, isImplicit) { } @@ -4804,8 +4804,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class UsingStatement : BaseUsingStatement, IUsingStatement { - public UsingStatement(IOperation body, IVariableDeclarationStatement declaration, IOperation value, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(semanticModel, syntax, type, constantValue) + public UsingStatement(IOperation body, IVariableDeclarationStatement declaration, IOperation value, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(semanticModel, syntax, type, constantValue, isImplicit) { BodyImpl = body; DeclarationImpl = declaration; @@ -4826,7 +4826,7 @@ internal sealed partial class LazyUsingStatement : BaseUsingStatement, IUsingSta private readonly Lazy _lazyDeclaration; private readonly Lazy _lazyValue; - public LazyUsingStatement(Lazy body, Lazy declaration, Lazy value, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(semanticModel, syntax, type, constantValue) + public LazyUsingStatement(Lazy body, Lazy declaration, Lazy value, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : base(semanticModel, syntax, type, constantValue, isImplicit) { _lazyBody = body ?? throw new System.ArgumentNullException(nameof(body)); _lazyDeclaration = declaration ?? throw new System.ArgumentNullException(nameof(declaration)); @@ -4845,8 +4845,8 @@ public LazyUsingStatement(Lazy body, Lazy internal abstract partial class BaseVariableDeclaration : Operation, IVariableDeclaration { - protected BaseVariableDeclaration(ImmutableArray variables, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.VariableDeclaration, semanticModel, syntax, type, constantValue) + protected BaseVariableDeclaration(ImmutableArray variables, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.VariableDeclaration, semanticModel, syntax, type, constantValue, isImplicit) { Variables = variables; } @@ -4883,8 +4883,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class VariableDeclaration : BaseVariableDeclaration, IVariableDeclaration { - public VariableDeclaration(ImmutableArray variables, IOperation initializer, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(variables, semanticModel, syntax, type, constantValue) + public VariableDeclaration(ImmutableArray variables, IOperation initializer, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(variables, semanticModel, syntax, type, constantValue, isImplicit) { InitializerImpl = initializer; } @@ -4899,7 +4899,7 @@ internal sealed partial class LazyVariableDeclaration : BaseVariableDeclaration, { private readonly Lazy _lazyInitializer; - public LazyVariableDeclaration(ImmutableArray variables, Lazy initializer, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(variables, semanticModel, syntax, type, constantValue) + public LazyVariableDeclaration(ImmutableArray variables, Lazy initializer, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : base(variables, semanticModel, syntax, type, constantValue, isImplicit) { _lazyInitializer = initializer ?? throw new System.ArgumentNullException(nameof(initializer)); } @@ -4912,8 +4912,8 @@ public LazyVariableDeclaration(ImmutableArray variables, Lazy internal abstract partial class BaseVariableDeclarationStatement : Operation, IVariableDeclarationStatement { - protected BaseVariableDeclarationStatement(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.VariableDeclarationStatement, semanticModel, syntax, type, constantValue) + protected BaseVariableDeclarationStatement(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.VariableDeclarationStatement, semanticModel, syntax, type, constantValue, isImplicit) { } @@ -4947,8 +4947,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class VariableDeclarationStatement : BaseVariableDeclarationStatement, IVariableDeclarationStatement { - public VariableDeclarationStatement(ImmutableArray declarations, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(semanticModel, syntax, type, constantValue) + public VariableDeclarationStatement(ImmutableArray declarations, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(semanticModel, syntax, type, constantValue, isImplicit) { DeclarationsImpl = declarations; } @@ -4963,7 +4963,7 @@ internal sealed partial class LazyVariableDeclarationStatement : BaseVariableDec { private readonly Lazy> _lazyDeclarations; - public LazyVariableDeclarationStatement(Lazy> declarations, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(semanticModel, syntax, type, constantValue) + public LazyVariableDeclarationStatement(Lazy> declarations, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : base(semanticModel, syntax, type, constantValue, isImplicit) { _lazyDeclarations = declarations; } @@ -4976,8 +4976,8 @@ public LazyVariableDeclarationStatement(Lazy internal abstract partial class BaseWhileUntilLoopStatement : ForWhileUntilLoopStatement, IWhileUntilLoopStatement { - public BaseWhileUntilLoopStatement(bool isTopTest, bool isWhile, LoopKind loopKind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(loopKind, OperationKind.LoopStatement, semanticModel, syntax, type, constantValue) + public BaseWhileUntilLoopStatement(bool isTopTest, bool isWhile, LoopKind loopKind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(loopKind, OperationKind.LoopStatement, semanticModel, syntax, type, constantValue, isImplicit) { IsTopTest = isTopTest; IsWhile = isWhile; @@ -5014,8 +5014,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class WhileUntilLoopStatement : BaseWhileUntilLoopStatement, IWhileUntilLoopStatement { - public WhileUntilLoopStatement(bool isTopTest, bool isWhile, IOperation condition, LoopKind loopKind, IOperation body, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(isTopTest, isWhile, loopKind, semanticModel, syntax, type, constantValue) + public WhileUntilLoopStatement(bool isTopTest, bool isWhile, IOperation condition, LoopKind loopKind, IOperation body, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(isTopTest, isWhile, loopKind, semanticModel, syntax, type, constantValue, isImplicit) { ConditionImpl = condition; BodyImpl = body; @@ -5032,8 +5032,8 @@ internal sealed partial class LazyWhileUntilLoopStatement : BaseWhileUntilLoopSt private readonly Lazy _lazyCondition; private readonly Lazy _lazyBody; - public LazyWhileUntilLoopStatement(bool isTopTest, bool isWhile, Lazy condition, LoopKind loopKind, Lazy body, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(isTopTest, isWhile, loopKind, semanticModel, syntax, type, constantValue) + public LazyWhileUntilLoopStatement(bool isTopTest, bool isWhile, Lazy condition, LoopKind loopKind, Lazy body, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(isTopTest, isWhile, loopKind, semanticModel, syntax, type, constantValue, isImplicit) { _lazyCondition = condition ?? throw new System.ArgumentNullException(nameof(condition)); _lazyBody = body ?? throw new System.ArgumentNullException(nameof(body)); @@ -5047,8 +5047,8 @@ internal sealed partial class LazyWhileUntilLoopStatement : BaseWhileUntilLoopSt /// internal abstract partial class BaseWithStatement : Operation, IWithStatement { - protected BaseWithStatement(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.WithStatement, semanticModel, syntax, type, constantValue) + protected BaseWithStatement(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.WithStatement, semanticModel, syntax, type, constantValue, isImplicit) { } @@ -5085,8 +5085,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class WithStatement : BaseWithStatement, IWithStatement { - public WithStatement(IOperation body, IOperation value, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(semanticModel, syntax, type, constantValue) + public WithStatement(IOperation body, IOperation value, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(semanticModel, syntax, type, constantValue, isImplicit) { BodyImpl = body; ValueImpl = value; @@ -5104,7 +5104,7 @@ internal sealed partial class LazyWithStatement : BaseWithStatement, IWithStatem private readonly Lazy _lazyBody; private readonly Lazy _lazyValue; - public LazyWithStatement(Lazy body, Lazy value, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : base(semanticModel, syntax, type, constantValue) + public LazyWithStatement(Lazy body, Lazy value, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : base(semanticModel, syntax, type, constantValue, isImplicit) { _lazyBody = body ?? throw new System.ArgumentNullException(nameof(body)); _lazyValue = value ?? throw new System.ArgumentNullException(nameof(value)); @@ -5120,8 +5120,8 @@ public LazyWithStatement(Lazy body, Lazy value, Semantic /// internal abstract partial class BaseLocalFunctionStatement : Operation, ILocalFunctionStatement { - protected BaseLocalFunctionStatement(IMethodSymbol localFunctionSymbol, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.LocalFunctionStatement, semanticModel, syntax, type, constantValue) + protected BaseLocalFunctionStatement(IMethodSymbol localFunctionSymbol, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.LocalFunctionStatement, semanticModel, syntax, type, constantValue, isImplicit) { LocalFunctionSymbol = localFunctionSymbol; } @@ -5156,8 +5156,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class LocalFunctionStatement : BaseLocalFunctionStatement, ILocalFunctionStatement { - public LocalFunctionStatement(IMethodSymbol localFunctionSymbol, IBlockStatement body, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(localFunctionSymbol, semanticModel, syntax, type, constantValue) + public LocalFunctionStatement(IMethodSymbol localFunctionSymbol, IBlockStatement body, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(localFunctionSymbol, semanticModel, syntax, type, constantValue, isImplicit) { BodyImpl = body; } @@ -5172,8 +5172,8 @@ internal sealed partial class LazyLocalFunctionStatement : BaseLocalFunctionStat { private readonly Lazy _lazyBody; - public LazyLocalFunctionStatement(IMethodSymbol localFunctionSymbol, Lazy body, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) - : base(localFunctionSymbol, semanticModel, syntax, type, constantValue) + public LazyLocalFunctionStatement(IMethodSymbol localFunctionSymbol, Lazy body, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue,bool isImplicit) + : base(localFunctionSymbol, semanticModel, syntax, type, constantValue, isImplicit) { _lazyBody = body ?? throw new System.ArgumentNullException(nameof(body)); } @@ -5186,8 +5186,8 @@ public LazyLocalFunctionStatement(IMethodSymbol localFunctionSymbol, Lazy internal abstract partial class BaseConstantPattern : Operation, IConstantPattern { - protected BaseConstantPattern(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.ConstantPattern, semanticModel, syntax, type, constantValue) + protected BaseConstantPattern(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.ConstantPattern, semanticModel, syntax, type, constantValue, isImplicit) { } @@ -5218,8 +5218,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class ConstantPattern : BaseConstantPattern, IConstantPattern { - public ConstantPattern(IOperation value, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(semanticModel, syntax, type, constantValue) + public ConstantPattern(IOperation value, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(semanticModel, syntax, type, constantValue, isImplicit) { ValueImpl = value; } @@ -5234,8 +5234,8 @@ internal sealed partial class LazyConstantPattern : BaseConstantPattern, IConsta { private readonly Lazy _lazyValue; - public LazyConstantPattern(Lazy value, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) - : base(semanticModel, syntax, type, constantValue) + public LazyConstantPattern(Lazy value, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) + : base(semanticModel, syntax, type, constantValue, isImplicit) { _lazyValue = value ?? throw new System.ArgumentNullException(nameof(value)); } @@ -5248,8 +5248,8 @@ public LazyConstantPattern(Lazy value, SemanticModel semanticModel, /// internal sealed partial class DeclarationPattern : Operation, IDeclarationPattern { - public DeclarationPattern(ISymbol declaredSymbol, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.DeclarationPattern, semanticModel, syntax, type, constantValue) + public DeclarationPattern(ISymbol declaredSymbol, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.DeclarationPattern, semanticModel, syntax, type, constantValue, isImplicit) { DeclaredSymbol = declaredSymbol; } @@ -5279,8 +5279,8 @@ public override void Accept(OperationVisitor visitor) /// internal abstract partial class BasePatternCaseClause : CaseClause, IPatternCaseClause { - protected BasePatternCaseClause(ILabelSymbol label, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(CaseKind.Pattern, OperationKind.PatternCaseClause, semanticModel, syntax, type, constantValue) + protected BasePatternCaseClause(ILabelSymbol label, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(CaseKind.Pattern, OperationKind.PatternCaseClause, semanticModel, syntax, type, constantValue, isImplicit) { Label = label; } @@ -5321,8 +5321,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class PatternCaseClause : BasePatternCaseClause, IPatternCaseClause { - public PatternCaseClause(ILabelSymbol label, IPattern pattern, IOperation guardExpression, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(label, semanticModel, syntax, type, constantValue) + public PatternCaseClause(ILabelSymbol label, IPattern pattern, IOperation guardExpression, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(label, semanticModel, syntax, type, constantValue, isImplicit) { PatternImpl = pattern; GuardExpressionImpl = guardExpression; @@ -5340,8 +5340,8 @@ internal sealed partial class LazyPatternCaseClause : BasePatternCaseClause, IPa private readonly Lazy _lazyPattern; private readonly Lazy _lazyGuardExpression; - public LazyPatternCaseClause(ILabelSymbol label, Lazy lazyPattern, Lazy lazyGuardExpression, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) - : base(label, semanticModel, syntax, type, constantValue) + public LazyPatternCaseClause(ILabelSymbol label, Lazy lazyPattern, Lazy lazyGuardExpression, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) + : base(label, semanticModel, syntax, type, constantValue, isImplicit) { _lazyPattern = lazyPattern ?? throw new System.ArgumentNullException(nameof(lazyPattern)); _lazyGuardExpression = lazyGuardExpression ?? throw new System.ArgumentNullException(nameof(lazyGuardExpression)); @@ -5357,8 +5357,8 @@ public LazyPatternCaseClause(ILabelSymbol label, Lazy lazyPattern, Laz /// internal abstract partial class BaseIsPatternExpression : Operation, IIsPatternExpression { - protected BaseIsPatternExpression(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.IsPatternExpression, semanticModel, syntax, type, constantValue) + protected BaseIsPatternExpression(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.IsPatternExpression, semanticModel, syntax, type, constantValue, isImplicit) { } @@ -5395,8 +5395,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class IsPatternExpression : BaseIsPatternExpression, IIsPatternExpression { - public IsPatternExpression(IOperation expression, IPattern pattern, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(semanticModel, syntax, type, constantValue) + public IsPatternExpression(IOperation expression, IPattern pattern, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(semanticModel, syntax, type, constantValue, isImplicit) { ExpressionImpl = expression; PatternImpl = pattern; @@ -5414,8 +5414,8 @@ internal sealed partial class LazyIsPatternExpression : BaseIsPatternExpression, private readonly Lazy _lazyExpression; private readonly Lazy _lazyPattern; - public LazyIsPatternExpression(Lazy lazyExpression, Lazy lazyPattern, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) - : base(semanticModel, syntax, type, constantValue) + public LazyIsPatternExpression(Lazy lazyExpression, Lazy lazyPattern, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) + : base(semanticModel, syntax, type, constantValue, isImplicit) { _lazyExpression = lazyExpression ?? throw new System.ArgumentNullException(nameof(lazyExpression)); _lazyPattern = lazyPattern ?? throw new System.ArgumentNullException(nameof(lazyPattern)); @@ -5431,8 +5431,8 @@ public LazyIsPatternExpression(Lazy lazyExpression, Lazy l /// internal abstract partial class BaseObjectOrCollectionInitializerExpression : Operation, IObjectOrCollectionInitializerExpression { - protected BaseObjectOrCollectionInitializerExpression(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.ObjectOrCollectionInitializerExpression, semanticModel, syntax, type, constantValue) + protected BaseObjectOrCollectionInitializerExpression(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.ObjectOrCollectionInitializerExpression, semanticModel, syntax, type, constantValue, isImplicit) { } @@ -5466,8 +5466,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class ObjectOrCollectionInitializerExpression : BaseObjectOrCollectionInitializerExpression, IObjectOrCollectionInitializerExpression { - public ObjectOrCollectionInitializerExpression(ImmutableArray initializers, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(semanticModel, syntax, type, constantValue) + public ObjectOrCollectionInitializerExpression(ImmutableArray initializers, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(semanticModel, syntax, type, constantValue, isImplicit) { InitializersImpl = initializers; } @@ -5482,8 +5482,8 @@ internal sealed partial class LazyObjectOrCollectionInitializerExpression : Base { private readonly Lazy> _lazyInitializers; - public LazyObjectOrCollectionInitializerExpression(Lazy> initializers, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(semanticModel, syntax, type, constantValue) + public LazyObjectOrCollectionInitializerExpression(Lazy> initializers, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(semanticModel, syntax, type, constantValue, isImplicit) { _lazyInitializers = initializers ?? throw new System.ArgumentNullException(nameof(initializers)); } @@ -5496,8 +5496,8 @@ internal sealed partial class LazyObjectOrCollectionInitializerExpression : Base /// internal abstract partial class BaseMemberInitializerExpression : Operation, IMemberInitializerExpression { - protected BaseMemberInitializerExpression(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.MemberInitializerExpression, semanticModel, syntax, type, constantValue) + protected BaseMemberInitializerExpression(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.MemberInitializerExpression, semanticModel, syntax, type, constantValue, isImplicit) { } @@ -5535,8 +5535,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class MemberInitializerExpression : BaseMemberInitializerExpression, IMemberInitializerExpression { - public MemberInitializerExpression(IMemberReferenceExpression initializedMember, IObjectOrCollectionInitializerExpression initializer, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(semanticModel, syntax, type, constantValue) + public MemberInitializerExpression(IMemberReferenceExpression initializedMember, IObjectOrCollectionInitializerExpression initializer, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(semanticModel, syntax, type, constantValue, isImplicit) { InitializedMemberImpl = initializedMember; InitializerImpl = initializer; @@ -5554,8 +5554,8 @@ internal sealed partial class LazyMemberInitializerExpression : BaseMemberInitia private readonly Lazy _lazyInitializedMember; private readonly Lazy _lazyInitializer; - public LazyMemberInitializerExpression(Lazy initializedMember, Lazy initializer, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(semanticModel, syntax, type, constantValue) + public LazyMemberInitializerExpression(Lazy initializedMember, Lazy initializer, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(semanticModel, syntax, type, constantValue, isImplicit) { _lazyInitializedMember = initializedMember ?? throw new System.ArgumentNullException(nameof(initializedMember)); _lazyInitializer = initializer ?? throw new System.ArgumentNullException(nameof(initializer)); @@ -5571,8 +5571,8 @@ internal sealed partial class LazyMemberInitializerExpression : BaseMemberInitia /// internal abstract partial class BaseCollectionElementInitializerExpression : Operation, ICollectionElementInitializerExpression { - protected BaseCollectionElementInitializerExpression(IMethodSymbol addMethod, bool isDynamic, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(OperationKind.CollectionElementInitializerExpression, semanticModel, syntax, type, constantValue) + protected BaseCollectionElementInitializerExpression(IMethodSymbol addMethod, bool isDynamic, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(OperationKind.CollectionElementInitializerExpression, semanticModel, syntax, type, constantValue, isImplicit) { AddMethod = addMethod; IsDynamic = isDynamic; @@ -5615,8 +5615,8 @@ public override void Accept(OperationVisitor visitor) /// internal sealed partial class CollectionElementInitializerExpression : BaseCollectionElementInitializerExpression, ICollectionElementInitializerExpression { - public CollectionElementInitializerExpression(IMethodSymbol addMethod, ImmutableArray arguments, bool isDynamic, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(addMethod, isDynamic, semanticModel, syntax, type, constantValue) + public CollectionElementInitializerExpression(IMethodSymbol addMethod, ImmutableArray arguments, bool isDynamic, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(addMethod, isDynamic, semanticModel, syntax, type, constantValue, isImplicit) { ArgumentsImpl = arguments; } @@ -5631,8 +5631,8 @@ internal sealed partial class LazyCollectionElementInitializerExpression : BaseC { private readonly Lazy> _lazyArguments; - public LazyCollectionElementInitializerExpression(IMethodSymbol addMethod, Lazy> arguments, bool isDynamic, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) : - base(addMethod, isDynamic, semanticModel, syntax, type, constantValue) + public LazyCollectionElementInitializerExpression(IMethodSymbol addMethod, Lazy> arguments, bool isDynamic, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) : + base(addMethod, isDynamic, semanticModel, syntax, type, constantValue, isImplicit) { _lazyArguments = arguments ?? throw new System.ArgumentNullException(nameof(arguments)); } diff --git a/src/Compilers/Core/Portable/InternalUtilities/SetWithInsertionOrder.cs b/src/Compilers/Core/Portable/InternalUtilities/SetWithInsertionOrder.cs index 97145d508a68e..e76d4519db1db 100644 --- a/src/Compilers/Core/Portable/InternalUtilities/SetWithInsertionOrder.cs +++ b/src/Compilers/Core/Portable/InternalUtilities/SetWithInsertionOrder.cs @@ -37,6 +37,36 @@ public bool Add(T value) return true; } + public bool Insert(int index, T value) + { + if (_set == null) + { + if (index > 0) + { + throw new IndexOutOfRangeException(); + } + Add(value); + } + else + { + if (!_set.Add(value)) + { + return false; + } + + try + { + _elements.Insert(index, value); + } + catch + { + _set.Remove(value); + throw; + } + } + return true; + } + public bool Remove(T value) { if (!_set.Remove(value)) @@ -57,5 +87,7 @@ public IEnumerator GetEnumerator() IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); public ImmutableArray AsImmutable() => _elements.ToImmutableArrayOrEmpty(); + + public T this[int i] => _elements[i]; } } diff --git a/src/Compilers/Core/Portable/NativePdbWriter/PdbWriter.cs b/src/Compilers/Core/Portable/NativePdbWriter/PdbWriter.cs index 03e2310d8ac9a..a4fbf6eb63a76 100644 --- a/src/Compilers/Core/Portable/NativePdbWriter/PdbWriter.cs +++ b/src/Compilers/Core/Portable/NativePdbWriter/PdbWriter.cs @@ -974,7 +974,7 @@ private ISymUnmanagedDocumentWriter GetDocumentWriter(DebugSourceDocument docume try { var algorithmId = info.ChecksumAlgorithmId; - var checksum = info.Checksum.ToArray(); + var checksum = ImmutableByteArrayInterop.DangerousGetUnderlyingArray(info.Checksum); var checksumSize = (uint)checksum.Length; writer.SetCheckSum(algorithmId, checksumSize, checksum); if (_callLogger.LogOperation(OP.SetCheckSum)) @@ -990,8 +990,38 @@ private ISymUnmanagedDocumentWriter GetDocumentWriter(DebugSourceDocument docume } } - // embedded text not currently supported for native PDB and we should have validated that - Debug.Assert(info.EmbeddedTextBlob.IsDefault); + if (!info.EmbeddedTextBlob.IsDefault) + { + try + { + uint blobSize = (uint)info.EmbeddedTextBlob.Length; + + writer.SetSource(blobSize, ImmutableByteArrayInterop.DangerousGetUnderlyingArray(info.EmbeddedTextBlob)); + + if (_callLogger.LogOperation(OP.SetSource)) + { + _callLogger.LogArgument(blobSize); + + // Since we only have embedded text for documents that have a computed checksum, + // (otherwise we'd have raised ERR_EncodinglessSyntaxTree), we can rely on + // having already logged the checksum (cryptographic hash) and skip writing the + // entire embedded text to the log (which can be large). + Debug.Assert(document.IsComputedChecksum); + Debug.Assert(!info.Checksum.IsDefault); + + // We do, however, log the first 4 bytes which encode formatting that is not + // included in the checksum. + _callLogger.LogArgument(info.EmbeddedTextBlob[0]); + _callLogger.LogArgument(info.EmbeddedTextBlob[1]); + _callLogger.LogArgument(info.EmbeddedTextBlob[2]); + _callLogger.LogArgument(info.EmbeddedTextBlob[3]); + } + } + catch (Exception ex) + { + throw new PdbWritingException(ex); + } + } } return writer; @@ -1535,6 +1565,22 @@ public unsafe void EmbedSourceLink(Stream stream) } } + /// + /// Write document entries for any embedded text document that does not yet have an entry. + /// + /// + /// This is done after serializing method debug info to ensure that we embed all requested + /// text even if there are no correspodning sequence points. + /// + public void WriteRemainingEmbeddedDocuments(IEnumerable embeddedDocuments) + { + foreach (var document in embeddedDocuments) + { + Debug.Assert(!document.GetSourceInfo().EmbeddedTextBlob.IsDefault); + GetDocumentWriter(document); + } + } + #endregion } } diff --git a/src/Compilers/Core/Portable/Operations/IOperation.cs b/src/Compilers/Core/Portable/Operations/IOperation.cs index 494ba5cf69fbe..b979b2749c9d7 100644 --- a/src/Compilers/Core/Portable/Operations/IOperation.cs +++ b/src/Compilers/Core/Portable/Operations/IOperation.cs @@ -54,5 +54,10 @@ public interface IOperation void Accept(OperationVisitor visitor); TResult Accept(OperationVisitor visitor, TArgument argument); + + /// + /// Set to True if compiler generated /implicitly computed by compiler code + /// + bool IsImplicit { get; } } } diff --git a/src/Compilers/Core/Portable/Operations/Operation.cs b/src/Compilers/Core/Portable/Operations/Operation.cs index ef00c9d67a7f7..93a4af4a88282 100644 --- a/src/Compilers/Core/Portable/Operations/Operation.cs +++ b/src/Compilers/Core/Portable/Operations/Operation.cs @@ -24,7 +24,7 @@ internal abstract class Operation : IOperation // but once initialized, will never change private IOperation _parentDoNotAccessDirectly; - public Operation(OperationKind kind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue) + public Operation(OperationKind kind, SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol type, Optional constantValue, bool isImplicit) { SemanticModel = semanticModel; @@ -32,6 +32,7 @@ public Operation(OperationKind kind, SemanticModel semanticModel, SyntaxNode syn Syntax = syntax; Type = type; ConstantValue = constantValue; + IsImplicit = isImplicit; } /// @@ -50,6 +51,11 @@ public IOperation Parent } } + /// + /// Set to True if compiler generated /implicitly computed by compiler code + /// + public bool IsImplicit { get; } + /// /// Identifies the kind of the operation. /// @@ -104,9 +110,9 @@ protected void SetParentOperation(IOperation parent) /// /// Use this to create IOperation when we don't have proper specific IOperation yet for given language construct /// - public static IOperation CreateOperationNone(SemanticModel semanticModel, SyntaxNode node, Optional constantValue, Func> getChildren) + public static IOperation CreateOperationNone(SemanticModel semanticModel, SyntaxNode node, Optional constantValue, Func> getChildren, bool isImplicit) { - return new NoneOperation(semanticModel, node, constantValue, getChildren); + return new NoneOperation(semanticModel, node, constantValue, getChildren, isImplicit); } public static T SetParentOperation(T operation, IOperation parent) where T : IOperation @@ -160,8 +166,8 @@ private class NoneOperation : Operation { private readonly Func> _getChildren; - public NoneOperation(SemanticModel semanticModel, SyntaxNode node, Optional constantValue, Func> getChildren) : - base(OperationKind.None, semanticModel, node, type: null, constantValue: constantValue) + public NoneOperation(SemanticModel semanticModel, SyntaxNode node, Optional constantValue, Func> getChildren, bool isImplicit) : + base(OperationKind.None, semanticModel, node, type: null, constantValue: constantValue, isImplicit: isImplicit) { _getChildren = getChildren; } diff --git a/src/Compilers/Core/Portable/Operations/OperationCloner.cs b/src/Compilers/Core/Portable/Operations/OperationCloner.cs index e0a0775b5d463..e889bc7ca15fd 100644 --- a/src/Compilers/Core/Portable/Operations/OperationCloner.cs +++ b/src/Compilers/Core/Portable/Operations/OperationCloner.cs @@ -25,7 +25,7 @@ public override IOperation DefaultVisit(IOperation operation, object argument) internal override IOperation VisitNoneOperation(IOperation operation, object argument) { - return Operation.CreateOperationNone(((Operation)operation).SemanticModel, operation.Syntax, operation.ConstantValue, () => VisitArray(operation.Children.ToImmutableArray())); + return Operation.CreateOperationNone(((Operation)operation).SemanticModel, operation.Syntax, operation.ConstantValue, () => VisitArray(operation.Children.ToImmutableArray()), operation.IsImplicit); } private ImmutableArray VisitArray(ImmutableArray nodes) where T : IOperation @@ -36,437 +36,437 @@ internal override IOperation VisitNoneOperation(IOperation operation, object arg public override IOperation VisitBlockStatement(IBlockStatement operation, object argument) { - return new BlockStatement(VisitArray(operation.Statements), operation.Locals, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new BlockStatement(VisitArray(operation.Statements), operation.Locals, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitVariableDeclarationStatement(IVariableDeclarationStatement operation, object argument) { - return new VariableDeclarationStatement(VisitArray(operation.Declarations), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new VariableDeclarationStatement(VisitArray(operation.Declarations), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitVariableDeclaration(IVariableDeclaration operation, object argument) { - return new VariableDeclaration(operation.Variables, Visit(operation.Initializer), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new VariableDeclaration(operation.Variables, Visit(operation.Initializer), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitSwitchStatement(ISwitchStatement operation, object argument) { - return new SwitchStatement(Visit(operation.Value), VisitArray(operation.Cases), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new SwitchStatement(Visit(operation.Value), VisitArray(operation.Cases), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitSwitchCase(ISwitchCase operation, object argument) { - return new SwitchCase(VisitArray(operation.Clauses), VisitArray(operation.Body), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new SwitchCase(VisitArray(operation.Clauses), VisitArray(operation.Body), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitSingleValueCaseClause(ISingleValueCaseClause operation, object argument) { - return new SingleValueCaseClause(Visit(operation.Value), operation.Equality, operation.CaseKind, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new SingleValueCaseClause(Visit(operation.Value), operation.Equality, operation.CaseKind, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitRelationalCaseClause(IRelationalCaseClause operation, object argument) { - return new RelationalCaseClause(Visit(operation.Value), operation.Relation, operation.CaseKind, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new RelationalCaseClause(Visit(operation.Value), operation.Relation, operation.CaseKind, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitRangeCaseClause(IRangeCaseClause operation, object argument) { - return new RangeCaseClause(Visit(operation.MinimumValue), Visit(operation.MaximumValue), operation.CaseKind, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new RangeCaseClause(Visit(operation.MinimumValue), Visit(operation.MaximumValue), operation.CaseKind, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitDefaultCaseClause(IDefaultCaseClause operation, object argument) { - return new DefaultCaseClause(((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new DefaultCaseClause(((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitIfStatement(IIfStatement operation, object argument) { - return new IfStatement(Visit(operation.Condition), Visit(operation.IfTrueStatement), Visit(operation.IfFalseStatement), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new IfStatement(Visit(operation.Condition), Visit(operation.IfTrueStatement), Visit(operation.IfFalseStatement), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitWhileUntilLoopStatement(IWhileUntilLoopStatement operation, object argument) { - return new WhileUntilLoopStatement(operation.IsTopTest, operation.IsWhile, Visit(operation.Condition), operation.LoopKind, Visit(operation.Body), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new WhileUntilLoopStatement(operation.IsTopTest, operation.IsWhile, Visit(operation.Condition), operation.LoopKind, Visit(operation.Body), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitForLoopStatement(IForLoopStatement operation, object argument) { - return new ForLoopStatement(VisitArray(operation.Before), VisitArray(operation.AtLoopBottom), operation.Locals, Visit(operation.Condition), operation.LoopKind, Visit(operation.Body), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new ForLoopStatement(VisitArray(operation.Before), VisitArray(operation.AtLoopBottom), operation.Locals, Visit(operation.Condition), operation.LoopKind, Visit(operation.Body), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitForEachLoopStatement(IForEachLoopStatement operation, object argument) { - return new ForEachLoopStatement(operation.IterationVariable, Visit(operation.Collection), operation.LoopKind, Visit(operation.Body), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new ForEachLoopStatement(operation.IterationVariable, Visit(operation.Collection), operation.LoopKind, Visit(operation.Body), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitLabelStatement(ILabelStatement operation, object argument) { - return new LabelStatement(operation.Label, Visit(operation.LabeledStatement), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new LabelStatement(operation.Label, Visit(operation.LabeledStatement), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitBranchStatement(IBranchStatement operation, object argument) { - return new BranchStatement(operation.Target, operation.BranchKind, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new BranchStatement(operation.Target, operation.BranchKind, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitYieldBreakStatement(IReturnStatement operation, object argument) { - return new ReturnStatement(operation.Kind, Visit(operation.ReturnedValue), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new ReturnStatement(operation.Kind, Visit(operation.ReturnedValue), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitEmptyStatement(IEmptyStatement operation, object argument) { - return new EmptyStatement(((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new EmptyStatement(((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitThrowStatement(IThrowStatement operation, object argument) { - return new ThrowStatement(Visit(operation.ThrownObject), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new ThrowStatement(Visit(operation.ThrownObject), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitReturnStatement(IReturnStatement operation, object argument) { - return new ReturnStatement(operation.Kind, Visit(operation.ReturnedValue), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new ReturnStatement(operation.Kind, Visit(operation.ReturnedValue), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitLockStatement(ILockStatement operation, object argument) { - return new LockStatement(Visit(operation.LockedObject), Visit(operation.Body), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new LockStatement(Visit(operation.LockedObject), Visit(operation.Body), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitTryStatement(ITryStatement operation, object argument) { - return new TryStatement(Visit(operation.Body), VisitArray(operation.Catches), Visit(operation.FinallyHandler), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new TryStatement(Visit(operation.Body), VisitArray(operation.Catches), Visit(operation.FinallyHandler), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitCatchClause(ICatchClause operation, object argument) { - return new CatchClause(Visit(operation.Handler), operation.CaughtType, Visit(operation.Filter), operation.ExceptionLocal, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new CatchClause(Visit(operation.Handler), operation.CaughtType, Visit(operation.Filter), operation.ExceptionLocal, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitUsingStatement(IUsingStatement operation, object argument) { - return new UsingStatement(Visit(operation.Body), Visit(operation.Declaration), Visit(operation.Value), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new UsingStatement(Visit(operation.Body), Visit(operation.Declaration), Visit(operation.Value), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitFixedStatement(IFixedStatement operation, object argument) { - return new FixedStatement(Visit(operation.Variables), Visit(operation.Body), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new FixedStatement(Visit(operation.Variables), Visit(operation.Body), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitExpressionStatement(IExpressionStatement operation, object argument) { - return new ExpressionStatement(Visit(operation.Expression), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new ExpressionStatement(Visit(operation.Expression), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitWithStatement(IWithStatement operation, object argument) { - return new WithStatement(Visit(operation.Body), Visit(operation.Value), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new WithStatement(Visit(operation.Body), Visit(operation.Value), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitStopStatement(IStopStatement operation, object argument) { - return new StopStatement(((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new StopStatement(((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitEndStatement(IEndStatement operation, object argument) { - return new EndStatement(((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new EndStatement(((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitInvocationExpression(IInvocationExpression operation, object argument) { - return new InvocationExpression(operation.TargetMethod, Visit(operation.Instance), operation.IsVirtual, VisitArray(operation.ArgumentsInEvaluationOrder), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new InvocationExpression(operation.TargetMethod, Visit(operation.Instance), operation.IsVirtual, VisitArray(operation.ArgumentsInEvaluationOrder), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitArgument(IArgument operation, object argument) { - return new Argument(operation.ArgumentKind, operation.Parameter, Visit(operation.Value), Visit(operation.InConversion), Visit(operation.OutConversion), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new Argument(operation.ArgumentKind, operation.Parameter, Visit(operation.Value), Visit(operation.InConversion), Visit(operation.OutConversion), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitOmittedArgumentExpression(IOmittedArgumentExpression operation, object argument) { - return new OmittedArgumentExpression(((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new OmittedArgumentExpression(((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitArrayElementReferenceExpression(IArrayElementReferenceExpression operation, object argument) { - return new ArrayElementReferenceExpression(Visit(operation.ArrayReference), VisitArray(operation.Indices), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new ArrayElementReferenceExpression(Visit(operation.ArrayReference), VisitArray(operation.Indices), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitPointerIndirectionReferenceExpression(IPointerIndirectionReferenceExpression operation, object argument) { - return new PointerIndirectionReferenceExpression(Visit(operation.Pointer), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new PointerIndirectionReferenceExpression(Visit(operation.Pointer), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitLocalReferenceExpression(ILocalReferenceExpression operation, object argument) { - return new LocalReferenceExpression(operation.Local, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new LocalReferenceExpression(operation.Local, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitParameterReferenceExpression(IParameterReferenceExpression operation, object argument) { - return new ParameterReferenceExpression(operation.Parameter, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new ParameterReferenceExpression(operation.Parameter, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitSyntheticLocalReferenceExpression(ISyntheticLocalReferenceExpression operation, object argument) { - return new SyntheticLocalReferenceExpression(operation.SyntheticLocalKind, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new SyntheticLocalReferenceExpression(operation.SyntheticLocalKind, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitInstanceReferenceExpression(IInstanceReferenceExpression operation, object argument) { - return new InstanceReferenceExpression(operation.InstanceReferenceKind, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new InstanceReferenceExpression(operation.InstanceReferenceKind, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitFieldReferenceExpression(IFieldReferenceExpression operation, object argument) { - return new FieldReferenceExpression(operation.Field, Visit(operation.Instance), operation.Member, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new FieldReferenceExpression(operation.Field, Visit(operation.Instance), operation.Member, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitMethodBindingExpression(IMethodBindingExpression operation, object argument) { - return new MethodBindingExpression(operation.Method, operation.IsVirtual, Visit(operation.Instance), operation.Member, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new MethodBindingExpression(operation.Method, operation.IsVirtual, Visit(operation.Instance), operation.Member, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitPropertyReferenceExpression(IPropertyReferenceExpression operation, object argument) { - return new PropertyReferenceExpression(operation.Property, Visit(operation.Instance), operation.Member, VisitArray(operation.ArgumentsInEvaluationOrder), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new PropertyReferenceExpression(operation.Property, Visit(operation.Instance), operation.Member, VisitArray(operation.ArgumentsInEvaluationOrder), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitEventReferenceExpression(IEventReferenceExpression operation, object argument) { - return new EventReferenceExpression(operation.Event, Visit(operation.Instance), operation.Member, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new EventReferenceExpression(operation.Event, Visit(operation.Instance), operation.Member, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitEventAssignmentExpression(IEventAssignmentExpression operation, object argument) { - return new EventAssignmentExpression(Visit(operation.EventReference), Visit(operation.HandlerValue), operation.Adds, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new EventAssignmentExpression(Visit(operation.EventReference), Visit(operation.HandlerValue), operation.Adds, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitConditionalAccessExpression(IConditionalAccessExpression operation, object argument) { - return new ConditionalAccessExpression(Visit(operation.ConditionalValue), Visit(operation.ConditionalInstance), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new ConditionalAccessExpression(Visit(operation.ConditionalValue), Visit(operation.ConditionalInstance), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitConditionalAccessInstanceExpression(IConditionalAccessInstanceExpression operation, object argument) { - return new ConditionalAccessInstanceExpression(((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new ConditionalAccessInstanceExpression(((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitPlaceholderExpression(IPlaceholderExpression operation, object argument) { - return new PlaceholderExpression(((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new PlaceholderExpression(((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitUnaryOperatorExpression(IUnaryOperatorExpression operation, object argument) { - return new UnaryOperatorExpression(operation.UnaryOperationKind, Visit(operation.Operand), operation.IsLifted, operation.UsesOperatorMethod, operation.OperatorMethod, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new UnaryOperatorExpression(operation.UnaryOperationKind, Visit(operation.Operand), operation.IsLifted, operation.UsesOperatorMethod, operation.OperatorMethod, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitBinaryOperatorExpression(IBinaryOperatorExpression operation, object argument) { - return new BinaryOperatorExpression(operation.BinaryOperationKind, Visit(operation.LeftOperand), Visit(operation.RightOperand), operation.IsLifted, operation.UsesOperatorMethod, operation.OperatorMethod, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new BinaryOperatorExpression(operation.BinaryOperationKind, Visit(operation.LeftOperand), Visit(operation.RightOperand), operation.IsLifted, operation.UsesOperatorMethod, operation.OperatorMethod, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitConditionalChoiceExpression(IConditionalChoiceExpression operation, object argument) { - return new ConditionalChoiceExpression(Visit(operation.Condition), Visit(operation.IfTrueValue), Visit(operation.IfFalseValue), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new ConditionalChoiceExpression(Visit(operation.Condition), Visit(operation.IfTrueValue), Visit(operation.IfFalseValue), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitNullCoalescingExpression(INullCoalescingExpression operation, object argument) { - return new NullCoalescingExpression(Visit(operation.PrimaryOperand), Visit(operation.SecondaryOperand), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new NullCoalescingExpression(Visit(operation.PrimaryOperand), Visit(operation.SecondaryOperand), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitIsTypeExpression(IIsTypeExpression operation, object argument) { - return new IsTypeExpression(Visit(operation.Operand), operation.IsType, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new IsTypeExpression(Visit(operation.Operand), operation.IsType, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitSizeOfExpression(ISizeOfExpression operation, object argument) { - return new SizeOfExpression(operation.TypeOperand, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new SizeOfExpression(operation.TypeOperand, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitTypeOfExpression(ITypeOfExpression operation, object argument) { - return new TypeOfExpression(operation.TypeOperand, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new TypeOfExpression(operation.TypeOperand, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitLambdaExpression(ILambdaExpression operation, object argument) { - return new LambdaExpression(operation.Signature, Visit(operation.Body), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new LambdaExpression(operation.Signature, Visit(operation.Body), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitLiteralExpression(ILiteralExpression operation, object argument) { - return new LiteralExpression(((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new LiteralExpression(((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitAwaitExpression(IAwaitExpression operation, object argument) { - return new AwaitExpression(Visit(operation.AwaitedValue), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new AwaitExpression(Visit(operation.AwaitedValue), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitNameOfExpression(INameOfExpression operation, object argument) { - return new NameOfExpression(Visit(operation.Argument), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new NameOfExpression(Visit(operation.Argument), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitThrowExpression(IThrowExpression operation, object argument) { - return new ThrowExpression(Visit(operation.Expression), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new ThrowExpression(Visit(operation.Expression), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitAddressOfExpression(IAddressOfExpression operation, object argument) { - return new AddressOfExpression(Visit(operation.Reference), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new AddressOfExpression(Visit(operation.Reference), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitObjectCreationExpression(IObjectCreationExpression operation, object argument) { - return new ObjectCreationExpression(operation.Constructor, Visit(operation.Initializer), VisitArray(operation.ArgumentsInEvaluationOrder), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new ObjectCreationExpression(operation.Constructor, Visit(operation.Initializer), VisitArray(operation.ArgumentsInEvaluationOrder), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitAnonymousObjectCreationExpression(IAnonymousObjectCreationExpression operation, object argument) { - return new AnonymousObjectCreationExpression(VisitArray(operation.Initializers), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new AnonymousObjectCreationExpression(VisitArray(operation.Initializers), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitObjectOrCollectionInitializerExpression(IObjectOrCollectionInitializerExpression operation, object argument) { - return new ObjectOrCollectionInitializerExpression(VisitArray(operation.Initializers), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new ObjectOrCollectionInitializerExpression(VisitArray(operation.Initializers), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitMemberInitializerExpression(IMemberInitializerExpression operation, object argument) { - return new MemberInitializerExpression(Visit(operation.InitializedMember), Visit(operation.Initializer), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new MemberInitializerExpression(Visit(operation.InitializedMember), Visit(operation.Initializer), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitCollectionElementInitializerExpression(ICollectionElementInitializerExpression operation, object argument) { - return new CollectionElementInitializerExpression(operation.AddMethod, VisitArray(operation.Arguments), operation.IsDynamic, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new CollectionElementInitializerExpression(operation.AddMethod, VisitArray(operation.Arguments), operation.IsDynamic, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitFieldInitializer(IFieldInitializer operation, object argument) { - return new FieldInitializer(operation.InitializedFields, Visit(operation.Value), operation.Kind, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new FieldInitializer(operation.InitializedFields, Visit(operation.Value), operation.Kind, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitPropertyInitializer(IPropertyInitializer operation, object argument) { - return new PropertyInitializer(operation.InitializedProperty, Visit(operation.Value), operation.Kind, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new PropertyInitializer(operation.InitializedProperty, Visit(operation.Value), operation.Kind, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitParameterInitializer(IParameterInitializer operation, object argument) { - return new ParameterInitializer(operation.Parameter, Visit(operation.Value), operation.Kind, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new ParameterInitializer(operation.Parameter, Visit(operation.Value), operation.Kind, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitArrayCreationExpression(IArrayCreationExpression operation, object argument) { - return new ArrayCreationExpression(operation.ElementType, VisitArray(operation.DimensionSizes), Visit(operation.Initializer), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new ArrayCreationExpression(operation.ElementType, VisitArray(operation.DimensionSizes), Visit(operation.Initializer), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitArrayInitializer(IArrayInitializer operation, object argument) { - return new ArrayInitializer(VisitArray(operation.ElementValues), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new ArrayInitializer(VisitArray(operation.ElementValues), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitSimpleAssignmentExpression(ISimpleAssignmentExpression operation, object argument) { - return new SimpleAssignmentExpression(Visit(operation.Target), Visit(operation.Value), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new SimpleAssignmentExpression(Visit(operation.Target), Visit(operation.Value), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitCompoundAssignmentExpression(ICompoundAssignmentExpression operation, object argument) { - return new CompoundAssignmentExpression(operation.BinaryOperationKind, operation.IsLifted, Visit(operation.Target), Visit(operation.Value), operation.UsesOperatorMethod, operation.OperatorMethod, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new CompoundAssignmentExpression(operation.BinaryOperationKind, operation.IsLifted, Visit(operation.Target), Visit(operation.Value), operation.UsesOperatorMethod, operation.OperatorMethod, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitIncrementExpression(IIncrementExpression operation, object argument) { - return new IncrementExpression(operation.IncrementOperationKind, Visit(operation.Target), operation.UsesOperatorMethod, operation.OperatorMethod, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new IncrementExpression(operation.IncrementOperationKind, Visit(operation.Target), operation.UsesOperatorMethod, operation.OperatorMethod, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitParenthesizedExpression(IParenthesizedExpression operation, object argument) { - return new ParenthesizedExpression(Visit(operation.Operand), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new ParenthesizedExpression(Visit(operation.Operand), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitDynamicMemberReferenceExpression(IDynamicMemberReferenceExpression operation, object argument) { - return new DynamicMemberReferenceExpression(Visit(operation.Instance), operation.MemberName, operation.TypeArguments, operation.ContainingType, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new DynamicMemberReferenceExpression(Visit(operation.Instance), operation.MemberName, operation.TypeArguments, operation.ContainingType, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitDynamicObjectCreationExpression(IDynamicObjectCreationExpression operation, object argument) { - return new DynamicObjectCreationExpression(operation.Name, operation.ApplicableSymbols, VisitArray(operation.Arguments), operation.ArgumentNames, operation.ArgumentRefKinds, Visit(operation.Initializer), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new DynamicObjectCreationExpression(operation.Name, operation.ApplicableSymbols, VisitArray(operation.Arguments), operation.ArgumentNames, operation.ArgumentRefKinds, Visit(operation.Initializer), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitDefaultValueExpression(IDefaultValueExpression operation, object argument) { - return new DefaultValueExpression(((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new DefaultValueExpression(((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitTypeParameterObjectCreationExpression(ITypeParameterObjectCreationExpression operation, object argument) { - return new TypeParameterObjectCreationExpression(Visit(operation.Initializer), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new TypeParameterObjectCreationExpression(Visit(operation.Initializer), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitInvalidStatement(IInvalidStatement operation, object argument) { - return new InvalidStatement(VisitArray(operation.Children.ToImmutableArray()), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new InvalidStatement(VisitArray(operation.Children.ToImmutableArray()), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitInvalidExpression(IInvalidExpression operation, object argument) { - return new InvalidExpression(VisitArray(operation.Children.ToImmutableArray()), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new InvalidExpression(VisitArray(operation.Children.ToImmutableArray()), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitLocalFunctionStatement(ILocalFunctionStatement operation, object argument) { - return new LocalFunctionStatement(operation.LocalFunctionSymbol, Visit(operation.Body), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new LocalFunctionStatement(operation.LocalFunctionSymbol, Visit(operation.Body), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitInterpolatedStringExpression(IInterpolatedStringExpression operation, object argument) { - return new InterpolatedStringExpression(VisitArray(operation.Parts), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new InterpolatedStringExpression(VisitArray(operation.Parts), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitInterpolatedStringText(IInterpolatedStringText operation, object argument) { - return new InterpolatedStringText(Visit(operation.Text), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new InterpolatedStringText(Visit(operation.Text), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitInterpolation(IInterpolation operation, object argument) { - return new Interpolation(Visit(operation.Expression), Visit(operation.Alignment), Visit(operation.FormatString), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new Interpolation(Visit(operation.Expression), Visit(operation.Alignment), Visit(operation.FormatString), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitIsPatternExpression(IIsPatternExpression operation, object argument) { - return new IsPatternExpression(Visit(operation.Expression), Visit(operation.Pattern), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new IsPatternExpression(Visit(operation.Expression), Visit(operation.Pattern), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitConstantPattern(IConstantPattern operation, object argument) { - return new ConstantPattern(Visit(operation.Value), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new ConstantPattern(Visit(operation.Value), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitDeclarationPattern(IDeclarationPattern operation, object argument) { - return new DeclarationPattern(operation.DeclaredSymbol, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new DeclarationPattern(operation.DeclaredSymbol, ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitPatternCaseClause(IPatternCaseClause operation, object argument) { - return new PatternCaseClause(operation.Label, Visit(operation.Pattern), Visit(operation.GuardExpression), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new PatternCaseClause(operation.Label, Visit(operation.Pattern), Visit(operation.GuardExpression), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } public override IOperation VisitTupleExpression(ITupleExpression operation, object argument) { - return new TupleExpression(VisitArray(operation.Elements), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue); + return new TupleExpression(VisitArray(operation.Elements), ((Operation)operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit); } } } diff --git a/src/Compilers/Core/Portable/Operations/OperationFactory.cs b/src/Compilers/Core/Portable/Operations/OperationFactory.cs index d2a137d3d8c7d..6f0ca07996ee4 100644 --- a/src/Compilers/Core/Portable/Operations/OperationFactory.cs +++ b/src/Compilers/Core/Portable/Operations/OperationFactory.cs @@ -20,10 +20,11 @@ public static VariableDeclaration CreateVariableDeclaration(ImmutableArray)); + constantValue: default(Optional), + isImplicit: false); // variable declaration is always explicit } - public static IConditionalChoiceExpression CreateConditionalChoiceExpression(IOperation condition, IOperation ifTrue, IOperation ifFalse, ITypeSymbol resultType, SemanticModel semanticModel, SyntaxNode syntax) + public static IConditionalChoiceExpression CreateConditionalChoiceExpression(IOperation condition, IOperation ifTrue, IOperation ifFalse, ITypeSymbol resultType, SemanticModel semanticModel, SyntaxNode syntax, bool isImplicit) { return new ConditionalChoiceExpression( condition, @@ -32,17 +33,18 @@ public static IConditionalChoiceExpression CreateConditionalChoiceExpression(IOp semanticModel, syntax, resultType, - default(Optional)); + default(Optional), + isImplicit); } - public static IExpressionStatement CreateSimpleAssignmentExpressionStatement(IOperation target, IOperation value, SemanticModel semanticModel, SyntaxNode syntax) + public static IExpressionStatement CreateSimpleAssignmentExpressionStatement(IOperation target, IOperation value, SemanticModel semanticModel, SyntaxNode syntax, bool isImplicit) { - var expression = new SimpleAssignmentExpression(target, value, semanticModel, syntax, target.Type, default(Optional)); - return new ExpressionStatement(expression, semanticModel, syntax, type: null, constantValue: default(Optional)); + var expression = new SimpleAssignmentExpression(target, value, semanticModel, syntax, target.Type, default(Optional), isImplicit); + return new ExpressionStatement(expression, semanticModel, syntax, type: null, constantValue: default(Optional), isImplicit: isImplicit); } public static IExpressionStatement CreateCompoundAssignmentExpressionStatement( - IOperation target, IOperation value, BinaryOperationKind binaryOperationKind, bool isLifted, IMethodSymbol operatorMethod, SemanticModel semanticModel, SyntaxNode syntax) + IOperation target, IOperation value, BinaryOperationKind binaryOperationKind, bool isLifted, IMethodSymbol operatorMethod, SemanticModel semanticModel, SyntaxNode syntax, bool isImplicit) { var expression = new CompoundAssignmentExpression( binaryOperationKind, @@ -54,52 +56,54 @@ public static IExpressionStatement CreateSimpleAssignmentExpressionStatement(IOp semanticModel, syntax, target.Type, - default(Optional)); + default(Optional), + isImplicit); - return new ExpressionStatement(expression, semanticModel, syntax, type: null, constantValue: default(Optional)); + return new ExpressionStatement(expression, semanticModel, syntax, type: null, constantValue: default(Optional), isImplicit: isImplicit); } - public static ILiteralExpression CreateLiteralExpression(long value, ITypeSymbol resultType, SemanticModel semanticModel, SyntaxNode syntax) + public static ILiteralExpression CreateLiteralExpression(long value, ITypeSymbol resultType, SemanticModel semanticModel, SyntaxNode syntax, bool isImplicit) { - return new LiteralExpression(semanticModel, syntax, resultType, constantValue: new Optional(value)); + return new LiteralExpression(semanticModel, syntax, resultType, constantValue: new Optional(value), isImplicit: isImplicit); } - public static ILiteralExpression CreateLiteralExpression(ConstantValue value, ITypeSymbol resultType, SemanticModel semanticModel, SyntaxNode syntax) + public static ILiteralExpression CreateLiteralExpression(ConstantValue value, ITypeSymbol resultType, SemanticModel semanticModel, SyntaxNode syntax, bool isImplicit) { - return new LiteralExpression(semanticModel, syntax, resultType, new Optional(value.Value)); + return new LiteralExpression(semanticModel, syntax, resultType, new Optional(value.Value), isImplicit); } public static IBinaryOperatorExpression CreateBinaryOperatorExpression( - BinaryOperationKind binaryOperationKind, IOperation left, IOperation right, ITypeSymbol resultType, SemanticModel semanticModel, SyntaxNode syntax, bool isLifted) + BinaryOperationKind binaryOperationKind, IOperation left, IOperation right, ITypeSymbol resultType, SemanticModel semanticModel, SyntaxNode syntax, bool isLifted, bool isImplicit) { return new BinaryOperatorExpression( binaryOperationKind, left, right, isLifted: isLifted, usesOperatorMethod: false, operatorMethod: null, - semanticModel: semanticModel, syntax: syntax, type: resultType, constantValue: default); + semanticModel: semanticModel, syntax: syntax, type: resultType, constantValue: default, isImplicit: isImplicit); } public static IArrayCreationExpression CreateArrayCreationExpression( - IArrayTypeSymbol arrayType, ImmutableArray elementValues, SemanticModel semanticModel, SyntaxNode syntax) + IArrayTypeSymbol arrayType, ImmutableArray elementValues, SemanticModel semanticModel, SyntaxNode syntax, bool isImplicit) { - var initializer = new ArrayInitializer(elementValues, semanticModel, syntax, arrayType, default(Optional)); + var initializer = new ArrayInitializer(elementValues, semanticModel, syntax, arrayType, default(Optional), isImplicit); return new ArrayCreationExpression( arrayType.ElementType, - ImmutableArray.Create(CreateLiteralExpression(elementValues.Count(), resultType: null, semanticModel: semanticModel, syntax: syntax)), + ImmutableArray.Create(CreateLiteralExpression(elementValues.Count(), resultType: null, semanticModel: semanticModel, syntax: syntax, isImplicit: isImplicit)), initializer, semanticModel, syntax, arrayType, - default(Optional)); + default(Optional), + isImplicit); } - public static IInvalidExpression CreateInvalidExpression(SemanticModel semanticModel, SyntaxNode syntax) + public static IInvalidExpression CreateInvalidExpression(SemanticModel semanticModel, SyntaxNode syntax, bool isImplicit) { - return CreateInvalidExpression(semanticModel, syntax, ImmutableArray.Empty); + return CreateInvalidExpression(semanticModel, syntax, ImmutableArray.Empty, isImplicit); } - public static IInvalidExpression CreateInvalidExpression(SemanticModel semanticModel, SyntaxNode syntax, ImmutableArray children) + public static IInvalidExpression CreateInvalidExpression(SemanticModel semanticModel, SyntaxNode syntax, ImmutableArray children, bool isImplicit) { - return new InvalidExpression(children, semanticModel, syntax, type: null, constantValue: default(Optional)); + return new InvalidExpression(children, semanticModel, syntax, type: null, constantValue: default(Optional), isImplicit: isImplicit); } } } diff --git a/src/Compilers/Core/Portable/PEWriter/PeWriter.cs b/src/Compilers/Core/Portable/PEWriter/PeWriter.cs index ed75102cb059f..32207ed572678 100644 --- a/src/Compilers/Core/Portable/PEWriter/PeWriter.cs +++ b/src/Compilers/Core/Portable/PEWriter/PeWriter.cs @@ -96,8 +96,7 @@ internal static class PeWriter #endif } - // embedded text not currently supported for native PDB and we should have validated that - Debug.Assert(!mdWriter.Module.DebugDocumentsBuilder.EmbeddedDocuments.Any()); + nativePdbWriterOpt.WriteRemainingEmbeddedDocuments(mdWriter.Module.DebugDocumentsBuilder.EmbeddedDocuments); } Stream peStream = getPeStream(); diff --git a/src/Compilers/Core/Portable/PublicAPI.Unshipped.txt b/src/Compilers/Core/Portable/PublicAPI.Unshipped.txt index efd1574dda03f..0e096aad6bcb9 100644 --- a/src/Compilers/Core/Portable/PublicAPI.Unshipped.txt +++ b/src/Compilers/Core/Portable/PublicAPI.Unshipped.txt @@ -1,7 +1,6 @@ *REMOVED*Microsoft.CodeAnalysis.Compilation.Emit(System.IO.Stream peStream, System.IO.Stream pdbStream = null, System.IO.Stream xmlDocumentationStream = null, System.IO.Stream win32Resources = null, System.Collections.Generic.IEnumerable manifestResources = null, Microsoft.CodeAnalysis.Emit.EmitOptions options = null, Microsoft.CodeAnalysis.IMethodSymbol debugEntryPoint = null, System.IO.Stream sourceLinkStream = null, System.Collections.Generic.IEnumerable embeddedTexts = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> Microsoft.CodeAnalysis.Emit.EmitResult *REMOVED*Microsoft.CodeAnalysis.Emit.EmitOptions.EmitOptions(bool metadataOnly = false, Microsoft.CodeAnalysis.Emit.DebugInformationFormat debugInformationFormat = (Microsoft.CodeAnalysis.Emit.DebugInformationFormat)0, string pdbFilePath = null, string outputNameOverride = null, int fileAlignment = 0, ulong baseAddress = 0, bool highEntropyVirtualAddressSpace = false, Microsoft.CodeAnalysis.SubsystemVersion subsystemVersion = default(Microsoft.CodeAnalysis.SubsystemVersion), string runtimeMetadataVersion = null, bool tolerateErrors = false, bool includePrivateMembers = false, System.Collections.Immutable.ImmutableArray instrumentationKinds = default(System.Collections.Immutable.ImmutableArray)) -> void *REMOVED*Microsoft.CodeAnalysis.IOperation.IsInvalid.get -> bool -abstract Microsoft.CodeAnalysis.SemanticModel.RootCore.get -> Microsoft.CodeAnalysis.SyntaxNode Microsoft.CodeAnalysis.CommandLineArguments.DisplayLangVersions.get -> bool Microsoft.CodeAnalysis.Diagnostics.AnalysisContext.RegisterOperationAction(System.Action action, params Microsoft.CodeAnalysis.OperationKind[] operationKinds) -> void Microsoft.CodeAnalysis.Diagnostics.CompilationStartAnalysisContext.RegisterOperationAction(System.Action action, params Microsoft.CodeAnalysis.OperationKind[] operationKinds) -> void @@ -42,11 +41,12 @@ Microsoft.CodeAnalysis.IOperation.Accept(Microsoft.CodeAnalysis.Semantics.Operat Microsoft.CodeAnalysis.IOperation.Accept(Microsoft.CodeAnalysis.Semantics.OperationVisitor visitor, TArgument argument) -> TResult Microsoft.CodeAnalysis.IOperation.Children.get -> System.Collections.Generic.IEnumerable Microsoft.CodeAnalysis.IOperation.ConstantValue.get -> Microsoft.CodeAnalysis.Optional +Microsoft.CodeAnalysis.IOperation.IsImplicit.get -> bool Microsoft.CodeAnalysis.IOperation.Kind.get -> Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.IOperation.Language.get -> string +Microsoft.CodeAnalysis.IOperation.Parent.get -> Microsoft.CodeAnalysis.IOperation Microsoft.CodeAnalysis.IOperation.Syntax.get -> Microsoft.CodeAnalysis.SyntaxNode Microsoft.CodeAnalysis.IOperation.Type.get -> Microsoft.CodeAnalysis.ITypeSymbol -Microsoft.CodeAnalysis.IOperation.Parent.get -> Microsoft.CodeAnalysis.IOperation Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.AddressOfExpression = 515 -> Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.AnonymousObjectCreationExpression = 287 -> Microsoft.CodeAnalysis.OperationKind @@ -69,8 +69,8 @@ Microsoft.CodeAnalysis.OperationKind.ConversionExpression = 258 -> Microsoft.Cod Microsoft.CodeAnalysis.OperationKind.DeclarationPattern = 1040 -> Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.DefaultCaseClause = 1042 -> Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.DefaultValueExpression = 512 -> Microsoft.CodeAnalysis.OperationKind -Microsoft.CodeAnalysis.OperationKind.DynamicObjectCreationExpression = 293 -> Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.DynamicMemberReferenceExpression = 294 -> Microsoft.CodeAnalysis.OperationKind +Microsoft.CodeAnalysis.OperationKind.DynamicObjectCreationExpression = 293 -> Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.EmptyStatement = 9 -> Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.EndStatement = 81 -> Microsoft.CodeAnalysis.OperationKind Microsoft.CodeAnalysis.OperationKind.EventAssignmentExpression = 283 -> Microsoft.CodeAnalysis.OperationKind @@ -365,9 +365,9 @@ Microsoft.CodeAnalysis.Semantics.IAwaitExpression Microsoft.CodeAnalysis.Semantics.IAwaitExpression.AwaitedValue.get -> Microsoft.CodeAnalysis.IOperation Microsoft.CodeAnalysis.Semantics.IBinaryOperatorExpression Microsoft.CodeAnalysis.Semantics.IBinaryOperatorExpression.BinaryOperationKind.get -> Microsoft.CodeAnalysis.Semantics.BinaryOperationKind +Microsoft.CodeAnalysis.Semantics.IBinaryOperatorExpression.IsLifted.get -> bool Microsoft.CodeAnalysis.Semantics.IBinaryOperatorExpression.LeftOperand.get -> Microsoft.CodeAnalysis.IOperation Microsoft.CodeAnalysis.Semantics.IBinaryOperatorExpression.RightOperand.get -> Microsoft.CodeAnalysis.IOperation -Microsoft.CodeAnalysis.Semantics.IBinaryOperatorExpression.IsLifted.get -> bool Microsoft.CodeAnalysis.Semantics.IBlockStatement Microsoft.CodeAnalysis.Semantics.IBlockStatement.Locals.get -> System.Collections.Immutable.ImmutableArray Microsoft.CodeAnalysis.Semantics.IBlockStatement.Statements.get -> System.Collections.Immutable.ImmutableArray @@ -578,9 +578,9 @@ Microsoft.CodeAnalysis.Semantics.ITypeOperationExpression.TypeOperand.get -> Mic Microsoft.CodeAnalysis.Semantics.ITypeParameterObjectCreationExpression Microsoft.CodeAnalysis.Semantics.ITypeParameterObjectCreationExpression.Initializer.get -> Microsoft.CodeAnalysis.Semantics.IObjectOrCollectionInitializerExpression Microsoft.CodeAnalysis.Semantics.IUnaryOperatorExpression +Microsoft.CodeAnalysis.Semantics.IUnaryOperatorExpression.IsLifted.get -> bool Microsoft.CodeAnalysis.Semantics.IUnaryOperatorExpression.Operand.get -> Microsoft.CodeAnalysis.IOperation Microsoft.CodeAnalysis.Semantics.IUnaryOperatorExpression.UnaryOperationKind.get -> Microsoft.CodeAnalysis.Semantics.UnaryOperationKind -Microsoft.CodeAnalysis.Semantics.IUnaryOperatorExpression.IsLifted.get -> bool Microsoft.CodeAnalysis.Semantics.IUsingStatement Microsoft.CodeAnalysis.Semantics.IUsingStatement.Body.get -> Microsoft.CodeAnalysis.IOperation Microsoft.CodeAnalysis.Semantics.IUsingStatement.Declaration.get -> Microsoft.CodeAnalysis.Semantics.IVariableDeclarationStatement @@ -745,6 +745,7 @@ Microsoft.CodeAnalysis.SyntaxTriviaList.SyntaxTriviaList(params Microsoft.CodeAn abstract Microsoft.CodeAnalysis.Diagnostics.OperationBlockStartAnalysisContext.RegisterOperationAction(System.Action action, System.Collections.Immutable.ImmutableArray operationKinds) -> void abstract Microsoft.CodeAnalysis.Diagnostics.OperationBlockStartAnalysisContext.RegisterOperationBlockEndAction(System.Action action) -> void abstract Microsoft.CodeAnalysis.SemanticModel.GetOperationCore(Microsoft.CodeAnalysis.SyntaxNode node, System.Threading.CancellationToken cancellationToken) -> Microsoft.CodeAnalysis.IOperation +abstract Microsoft.CodeAnalysis.SemanticModel.RootCore.get -> Microsoft.CodeAnalysis.SyntaxNode override Microsoft.CodeAnalysis.Optional.ToString() -> string override Microsoft.CodeAnalysis.Semantics.OperationWalker.DefaultVisit(Microsoft.CodeAnalysis.IOperation operation) -> void override Microsoft.CodeAnalysis.Semantics.OperationWalker.Visit(Microsoft.CodeAnalysis.IOperation operation) -> void diff --git a/src/Compilers/VisualBasic/Portable/Binding/Binder_Expressions.vb b/src/Compilers/VisualBasic/Portable/Binding/Binder_Expressions.vb index 0a1bff73558a3..f70f5967e453d 100644 --- a/src/Compilers/VisualBasic/Portable/Binding/Binder_Expressions.vb +++ b/src/Compilers/VisualBasic/Portable/Binding/Binder_Expressions.vb @@ -251,11 +251,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic ' e.g. SyntaxKind.MidExpression is handled elsewhere ' NOTE: There were too many "else" cases to justify listing them explicitly and throwing on ' anything unexpected. - ' - ' PROTOTYPE(IOperation) - ' re-enable the assert once this issue is fixed - ' https://github.com/dotnet/roslyn/issues/21180 - ' Debug.Assert(node.ContainsDiagnostics, String.Format("Unexpected {0} syntax does not have diagnostics", node.Kind)) + Debug.Assert(IsSemanticModelBinder OrElse node.ContainsDiagnostics, String.Format("Unexpected {0} syntax does not have diagnostics", node.Kind)) Return BadExpression(node, ImmutableArray(Of BoundExpression).Empty, ErrorTypeSymbol.UnknownResultType) End Select diff --git a/src/Compilers/VisualBasic/Portable/Binding/Binder_Statements.vb b/src/Compilers/VisualBasic/Portable/Binding/Binder_Statements.vb index 9cb0b9308e87b..2eca2a02d2a22 100644 --- a/src/Compilers/VisualBasic/Portable/Binding/Binder_Statements.vb +++ b/src/Compilers/VisualBasic/Portable/Binding/Binder_Statements.vb @@ -65,11 +65,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic Case SyntaxKind.ElseIfStatement ' ElseIf without a preceding If. - ' - ' PROTOTYPE(IOperation) - ' re-enable the assert once this issue is fixed - ' https://github.com/dotnet/roslyn/issues/21180 - ' Debug.Assert(node.ContainsDiagnostics) + Debug.Assert(IsSemanticModelBinder OrElse node.ContainsDiagnostics) Dim condition = BindBooleanExpression(DirectCast(node, ElseIfStatementSyntax).Condition, diagnostics) Return New BoundBadStatement(node, ImmutableArray.Create(Of BoundNode)(condition), hasErrors:=True) @@ -200,31 +196,27 @@ Namespace Microsoft.CodeAnalysis.VisualBasic ' where only the ones that can appear in a method body have been selected). ' ' We simply need to ignore this, the error is already created by the parser. - ' - ' PROTOTYPE(IOperation) - ' re-enable the assert once this issue is fixed - ' https://github.com/dotnet/roslyn/issues/21180 - 'Debug.Assert(node.ContainsDiagnostics OrElse - ' (node.IsMissing AndAlso - ' (node.Parent.Kind = SyntaxKind.MultiLineSubLambdaExpression OrElse - ' node.Parent.Kind = SyntaxKind.MultiLineFunctionLambdaExpression OrElse - ' node.Parent.Kind = SyntaxKind.AddHandlerAccessorBlock OrElse - ' node.Parent.Kind = SyntaxKind.RemoveHandlerAccessorBlock OrElse - ' node.Parent.Kind = SyntaxKind.RaiseEventAccessorBlock OrElse - ' node.Parent.Kind = SyntaxKind.MultiLineIfBlock OrElse - ' node.Parent.Kind = SyntaxKind.ElseIfBlock OrElse - ' node.Parent.Kind = SyntaxKind.ElseBlock OrElse - ' node.Parent.Kind = SyntaxKind.SimpleDoLoopBlock OrElse - ' node.Parent.Kind = SyntaxKind.DoWhileLoopBlock OrElse - ' node.Parent.Kind = SyntaxKind.DoUntilLoopBlock OrElse - ' node.Parent.Kind = SyntaxKind.WhileBlock OrElse - ' node.Parent.Kind = SyntaxKind.WithBlock OrElse - ' node.Parent.Kind = SyntaxKind.ForBlock OrElse - ' node.Parent.Kind = SyntaxKind.ForEachBlock OrElse - ' node.Parent.Kind = SyntaxKind.SyncLockBlock OrElse - ' node.Parent.Kind = SyntaxKind.SelectBlock OrElse - ' node.Parent.Kind = SyntaxKind.TryBlock OrElse - ' node.Parent.Kind = SyntaxKind.UsingBlock))) + Debug.Assert(IsSemanticModelBinder OrElse node.ContainsDiagnostics OrElse + (node.IsMissing AndAlso + (node.Parent.Kind = SyntaxKind.MultiLineSubLambdaExpression OrElse + node.Parent.Kind = SyntaxKind.MultiLineFunctionLambdaExpression OrElse + node.Parent.Kind = SyntaxKind.AddHandlerAccessorBlock OrElse + node.Parent.Kind = SyntaxKind.RemoveHandlerAccessorBlock OrElse + node.Parent.Kind = SyntaxKind.RaiseEventAccessorBlock OrElse + node.Parent.Kind = SyntaxKind.MultiLineIfBlock OrElse + node.Parent.Kind = SyntaxKind.ElseIfBlock OrElse + node.Parent.Kind = SyntaxKind.ElseBlock OrElse + node.Parent.Kind = SyntaxKind.SimpleDoLoopBlock OrElse + node.Parent.Kind = SyntaxKind.DoWhileLoopBlock OrElse + node.Parent.Kind = SyntaxKind.DoUntilLoopBlock OrElse + node.Parent.Kind = SyntaxKind.WhileBlock OrElse + node.Parent.Kind = SyntaxKind.WithBlock OrElse + node.Parent.Kind = SyntaxKind.ForBlock OrElse + node.Parent.Kind = SyntaxKind.ForEachBlock OrElse + node.Parent.Kind = SyntaxKind.SyncLockBlock OrElse + node.Parent.Kind = SyntaxKind.SelectBlock OrElse + node.Parent.Kind = SyntaxKind.TryBlock OrElse + node.Parent.Kind = SyntaxKind.UsingBlock))) Return New BoundBadStatement(node, ImmutableArray(Of BoundNode).Empty, hasErrors:=True) @@ -272,11 +264,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic ' not handling here and then throwing ExceptionUtilities.UnexpectedValue in the else case, but ' there are just too many statement SyntaxKinds in VB (e.g. declarations, statements corresponding ' to blocks handled above, etc). - ' - ' PROTOTYPE(IOperation) - ' re-enable the assert once this issue is fixed - ' https://github.com/dotnet/roslyn/issues/21180 - ' Debug.Assert(node.ContainsDiagnostics) + Debug.Assert(IsSemanticModelBinder OrElse node.ContainsDiagnostics) Return New BoundBadStatement(node, ImmutableArray(Of BoundNode).Empty, hasErrors:=True) End Function diff --git a/src/Compilers/VisualBasic/Portable/CommandLine/VisualBasicCommandLineParser.vb b/src/Compilers/VisualBasic/Portable/CommandLine/VisualBasicCommandLineParser.vb index 6fa83114af9b1..6e46f0e111d76 100644 --- a/src/Compilers/VisualBasic/Portable/CommandLine/VisualBasicCommandLineParser.vb +++ b/src/Compilers/VisualBasic/Portable/CommandLine/VisualBasicCommandLineParser.vb @@ -1274,12 +1274,8 @@ lVbRuntimePlus: embeddedFiles.AddRange(sourceFiles) End If - If embeddedFiles.Count > 0 Then - ' Restricted to portable PDBs for now, but the IsPortable condition should be removed - ' And the error message adjusted accordingly when native PDB support Is added. - If Not emitPdb OrElse Not debugInformationFormat.IsPortable() Then - AddDiagnostic(diagnostics, ERRID.ERR_CannotEmbedWithoutPdb) - End If + If embeddedFiles.Count > 0 And Not emitPdb Then + AddDiagnostic(diagnostics, ERRID.ERR_CannotEmbedWithoutPdb) End If ' Validate root namespace if specified diff --git a/src/Compilers/VisualBasic/Portable/Operations/VisualBasicConversionExpression.vb b/src/Compilers/VisualBasic/Portable/Operations/VisualBasicConversionExpression.vb index 78c1e04aa5f25..a779448167850 100644 --- a/src/Compilers/VisualBasic/Portable/Operations/VisualBasicConversionExpression.vb +++ b/src/Compilers/VisualBasic/Portable/Operations/VisualBasicConversionExpression.vb @@ -7,8 +7,8 @@ Namespace Microsoft.CodeAnalysis.VisualBasic Friend MustInherit Class BaseVisualBasicConversionExpression Inherits BaseConversionExpression - Protected Sub New(conversion As Conversion, isExplicitInCode As Boolean, isTryCast As Boolean, isChecked As Boolean, semanticModel As SemanticModel, syntax As SyntaxNode, type As ITypeSymbol, constantValue As [Optional](Of Object)) - MyBase.New(isExplicitInCode, isTryCast, isChecked, semanticModel, syntax, type, constantValue) + Protected Sub New(conversion As Conversion, isExplicitInCode As Boolean, isTryCast As Boolean, isChecked As Boolean, semanticModel As SemanticModel, syntax As SyntaxNode, type As ITypeSymbol, constantValue As [Optional](Of Object), isImplicit As Boolean) + MyBase.New(isExplicitInCode, isTryCast, isChecked, semanticModel, syntax, type, constantValue, isImplicit) ConversionInternal = conversion End Sub @@ -21,8 +21,8 @@ Namespace Microsoft.CodeAnalysis.VisualBasic Friend NotInheritable Class VisualBasicConversionExpression Inherits BaseVisualBasicConversionExpression - Public Sub New(operand As IOperation, conversion As Conversion, isExplicitInCode As Boolean, isTryCast As Boolean, isChecked As Boolean, semanticModel As SemanticModel, syntax As SyntaxNode, type As ITypeSymbol, constantValue As [Optional](Of Object)) - MyBase.New(conversion, isExplicitInCode, isTryCast, isChecked, semanticModel, syntax, type, constantValue) + Public Sub New(operand As IOperation, conversion As Conversion, isExplicitInCode As Boolean, isTryCast As Boolean, isChecked As Boolean, semanticModel As SemanticModel, syntax As SyntaxNode, type As ITypeSymbol, constantValue As [Optional](Of Object), isImplicit As Boolean) + MyBase.New(conversion, isExplicitInCode, isTryCast, isChecked, semanticModel, syntax, type, constantValue, isImplicit) Me.OperandImpl = operand End Sub @@ -35,8 +35,8 @@ Namespace Microsoft.CodeAnalysis.VisualBasic Private ReadOnly _operandLazy As Lazy(Of IOperation) - Public Sub New(operandLazy As Lazy(Of IOperation), conversion As Conversion, isExplicitInCode As Boolean, isTryCast As Boolean, isChecked As Boolean, semanticModel As SemanticModel, syntax As SyntaxNode, type As ITypeSymbol, constantValue As [Optional](Of Object)) - MyBase.New(conversion, isExplicitInCode, isTryCast, isChecked, semanticModel, syntax, type, constantValue) + Public Sub New(operandLazy As Lazy(Of IOperation), conversion As Conversion, isExplicitInCode As Boolean, isTryCast As Boolean, isChecked As Boolean, semanticModel As SemanticModel, syntax As SyntaxNode, type As ITypeSymbol, constantValue As [Optional](Of Object), isImplicit As Boolean) + MyBase.New(conversion, isExplicitInCode, isTryCast, isChecked, semanticModel, syntax, type, constantValue, isImplicit) _operandLazy = operandLazy End Sub diff --git a/src/Compilers/VisualBasic/Portable/Operations/VisualBasicOperationCloner.vb b/src/Compilers/VisualBasic/Portable/Operations/VisualBasicOperationCloner.vb index 9ce41edb731d9..780e137ed8c51 100644 --- a/src/Compilers/VisualBasic/Portable/Operations/VisualBasicOperationCloner.vb +++ b/src/Compilers/VisualBasic/Portable/Operations/VisualBasicOperationCloner.vb @@ -8,7 +8,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic Public Shared ReadOnly Property Instance As OperationCloner = New VisualBasicOperationCloner() Public Overrides Function VisitConversionExpression(operation As IConversionExpression, argument As Object) As IOperation - Return New VisualBasicConversionExpression(Visit(operation.Operand), operation.GetConversion(), operation.IsExplicitInCode, operation.IsTryCast, operation.IsChecked, DirectCast(operation, Operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue) + Return New VisualBasicConversionExpression(Visit(operation.Operand), operation.GetConversion(), operation.IsExplicitInCode, operation.IsTryCast, operation.IsChecked, DirectCast(operation, Operation).SemanticModel, operation.Syntax, operation.Type, operation.ConstantValue, operation.IsImplicit) End Function End Class End Namespace diff --git a/src/Compilers/VisualBasic/Portable/Operations/VisualBasicOperationFactory.vb b/src/Compilers/VisualBasic/Portable/Operations/VisualBasicOperationFactory.vb index 23978c4df7315..df01984d4216e 100644 --- a/src/Compilers/VisualBasic/Portable/Operations/VisualBasicOperationFactory.vb +++ b/src/Compilers/VisualBasic/Portable/Operations/VisualBasicOperationFactory.vb @@ -234,7 +234,8 @@ Namespace Microsoft.CodeAnalysis.Semantics Return CreateBoundAnonymousTypePropertyAccessOperation(DirectCast(boundNode, BoundAnonymousTypePropertyAccess)) Case Else Dim constantValue = ConvertToOptional(TryCast(boundNode, BoundExpression)?.ConstantValueOpt) - Return Operation.CreateOperationNone(_semanticModel, boundNode.Syntax, constantValue, Function() GetIOperationChildren(boundNode)) + Dim isImplicit As Boolean = boundNode.WasCompilerGenerated + Return Operation.CreateOperationNone(_semanticModel, boundNode.Syntax, constantValue, Function() GetIOperationChildren(boundNode), isImplicit) End Select End Function @@ -255,6 +256,7 @@ Namespace Microsoft.CodeAnalysis.Semantics Private Function CreateBoundAssignmentOperatorOperation(boundAssignmentOperator As BoundAssignmentOperator) As IOperation Dim kind = GetAssignmentKind(boundAssignmentOperator) + Dim isImplicit As Boolean = boundAssignmentOperator.WasCompilerGenerated If kind = OperationKind.CompoundAssignmentExpression Then ' convert Right to IOperation temporarily. we do this to get right operand, operator method and etc Dim temporaryRight = DirectCast(Create(boundAssignmentOperator.Right), IBinaryOperatorExpression) @@ -272,23 +274,24 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim syntax As SyntaxNode = boundAssignmentOperator.Syntax Dim type As ITypeSymbol = boundAssignmentOperator.Type Dim constantValue As [Optional](Of Object) = ConvertToOptional(boundAssignmentOperator.ConstantValueOpt) - Return New LazyCompoundAssignmentExpression(binaryOperationKind, boundAssignmentOperator.Type.IsNullableType(), target, value, usesOperatorMethod, operatorMethod, _semanticModel, syntax, type, constantValue) + Return New LazyCompoundAssignmentExpression(binaryOperationKind, boundAssignmentOperator.Type.IsNullableType(), target, value, usesOperatorMethod, operatorMethod, _semanticModel, syntax, type, constantValue, isImplicit) Else Dim target As Lazy(Of IOperation) = New Lazy(Of IOperation)(Function() Create(boundAssignmentOperator.Left)) Dim value As Lazy(Of IOperation) = New Lazy(Of IOperation)(Function() Create(boundAssignmentOperator.Right)) Dim syntax As SyntaxNode = boundAssignmentOperator.Syntax Dim type As ITypeSymbol = boundAssignmentOperator.Type Dim constantValue As [Optional](Of Object) = ConvertToOptional(boundAssignmentOperator.ConstantValueOpt) - Return New LazySimpleAssignmentExpression(target, value, _semanticModel, syntax, type, constantValue) + Return New LazySimpleAssignmentExpression(target, value, _semanticModel, syntax, type, constantValue, isImplicit) End If End Function Private Function CreateBoundMeReferenceOperation(boundMeReference As BoundMeReference) As IInstanceReferenceExpression - Dim instanceReferenceKind As InstanceReferenceKind = If(boundMeReference.WasCompilerGenerated, InstanceReferenceKind.Implicit, InstanceReferenceKind.Explicit) + Dim instanceReferenceKind As InstanceReferenceKind = If(boundMeReference.WasCompilerGenerated, instanceReferenceKind.Implicit, instanceReferenceKind.Explicit) Dim syntax As SyntaxNode = boundMeReference.Syntax Dim type As ITypeSymbol = boundMeReference.Type Dim constantValue As [Optional](Of Object) = ConvertToOptional(boundMeReference.ConstantValueOpt) - Return New InstanceReferenceExpression(instanceReferenceKind, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundMeReference.WasCompilerGenerated + Return New InstanceReferenceExpression(instanceReferenceKind, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundMyBaseReferenceOperation(boundMyBaseReference As BoundMyBaseReference) As IInstanceReferenceExpression @@ -296,7 +299,8 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim syntax As SyntaxNode = boundMyBaseReference.Syntax Dim type As ITypeSymbol = boundMyBaseReference.Type Dim constantValue As [Optional](Of Object) = ConvertToOptional(boundMyBaseReference.ConstantValueOpt) - Return New InstanceReferenceExpression(instanceReferenceKind, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundMyBaseReference.WasCompilerGenerated + Return New InstanceReferenceExpression(instanceReferenceKind, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundMyClassReferenceOperation(boundMyClassReference As BoundMyClassReference) As IInstanceReferenceExpression @@ -304,14 +308,16 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim syntax As SyntaxNode = boundMyClassReference.Syntax Dim type As ITypeSymbol = boundMyClassReference.Type Dim constantValue As [Optional](Of Object) = ConvertToOptional(boundMyClassReference.ConstantValueOpt) - Return New InstanceReferenceExpression(instanceReferenceKind, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundMyClassReference.WasCompilerGenerated + Return New InstanceReferenceExpression(instanceReferenceKind, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundLiteralOperation(boundLiteral As BoundLiteral) As ILiteralExpression Dim syntax As SyntaxNode = boundLiteral.Syntax Dim type As ITypeSymbol = boundLiteral.Type Dim constantValue As [Optional](Of Object) = ConvertToOptional(boundLiteral.ConstantValueOpt) - Return New LiteralExpression(_semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundLiteral.WasCompilerGenerated + Return New LiteralExpression(_semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundAwaitOperatorOperation(boundAwaitOperator As BoundAwaitOperator) As IAwaitExpression @@ -319,7 +325,8 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim syntax As SyntaxNode = boundAwaitOperator.Syntax Dim type As ITypeSymbol = boundAwaitOperator.Type Dim constantValue As [Optional](Of Object) = ConvertToOptional(boundAwaitOperator.ConstantValueOpt) - Return New LazyAwaitExpression(awaitedValue, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundAwaitOperator.WasCompilerGenerated + Return New LazyAwaitExpression(awaitedValue, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundNameOfOperatorOperation(boundNameOfOperator As BoundNameOfOperator) As INameOfExpression @@ -327,7 +334,8 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim syntax As SyntaxNode = boundNameOfOperator.Syntax Dim type As ITypeSymbol = boundNameOfOperator.Type Dim constantValue As [Optional](Of Object) = ConvertToOptional(boundNameOfOperator.ConstantValueOpt) - Return New LazyNameOfExpression(argument, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundNameOfOperator.WasCompilerGenerated + Return New LazyNameOfExpression(argument, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundLambdaOperation(boundLambda As BoundLambda) As ILambdaExpression @@ -336,7 +344,8 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim syntax As SyntaxNode = boundLambda.Syntax Dim type As ITypeSymbol = boundLambda.Type Dim constantValue As [Optional](Of Object) = ConvertToOptional(boundLambda.ConstantValueOpt) - Return New LazyLambdaExpression(signature, body, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundLambda.WasCompilerGenerated + Return New LazyLambdaExpression(signature, body, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundCallOperation(boundCall As BoundCall) As IInvocationExpression @@ -359,14 +368,16 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim syntax As SyntaxNode = boundCall.Syntax Dim type As ITypeSymbol = boundCall.Type Dim constantValue As [Optional](Of Object) = ConvertToOptional(boundCall.ConstantValueOpt) - Return New LazyInvocationExpression(targetMethod, instance, isVirtual, argumentsInEvaluationOrder, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundCall.WasCompilerGenerated + Return New LazyInvocationExpression(targetMethod, instance, isVirtual, argumentsInEvaluationOrder, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundOmittedArgumentOperation(boundOmittedArgument As BoundOmittedArgument) As IOmittedArgumentExpression Dim syntax As SyntaxNode = boundOmittedArgument.Syntax Dim type As ITypeSymbol = boundOmittedArgument.Type Dim constantValue As [Optional](Of Object) = ConvertToOptional(boundOmittedArgument.ConstantValueOpt) - Return New OmittedArgumentExpression(_semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundOmittedArgument.WasCompilerGenerated + Return New OmittedArgumentExpression(_semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundParenthesizedOperation(boundParenthesized As BoundParenthesized) As IParenthesizedExpression @@ -374,7 +385,8 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim syntax As SyntaxNode = boundParenthesized.Syntax Dim type As ITypeSymbol = boundParenthesized.Type Dim constantValue As [Optional](Of Object) = ConvertToOptional(boundParenthesized.ConstantValueOpt) - Return New LazyParenthesizedExpression(operand, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundParenthesized.WasCompilerGenerated + Return New LazyParenthesizedExpression(operand, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundArrayAccessOperation(boundArrayAccess As BoundArrayAccess) As IArrayElementReferenceExpression @@ -383,7 +395,8 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim syntax As SyntaxNode = boundArrayAccess.Syntax Dim type As ITypeSymbol = boundArrayAccess.Type Dim constantValue As [Optional](Of Object) = ConvertToOptional(boundArrayAccess.ConstantValueOpt) - Return New LazyArrayElementReferenceExpression(arrayReference, indices, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundArrayAccess.WasCompilerGenerated + Return New LazyArrayElementReferenceExpression(arrayReference, indices, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundUnaryOperatorOperation(boundUnaryOperator As BoundUnaryOperator) As IUnaryOperatorExpression @@ -395,7 +408,8 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim type As ITypeSymbol = boundUnaryOperator.Type Dim constantValue As [Optional](Of Object) = ConvertToOptional(boundUnaryOperator.ConstantValueOpt) Dim isLifted = (boundUnaryOperator.OperatorKind And UnaryOperatorKind.Lifted) <> 0 - Return New LazyUnaryOperatorExpression(unaryOperationKind, operand, isLifted, usesOperatorMethod, operatorMethod, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundUnaryOperator.WasCompilerGenerated + Return New LazyUnaryOperatorExpression(unaryOperationKind, operand, isLifted, usesOperatorMethod, operatorMethod, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundUserDefinedUnaryOperatorOperation(boundUserDefinedUnaryOperator As BoundUserDefinedUnaryOperator) As IUnaryOperatorExpression @@ -412,8 +426,9 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim syntax As SyntaxNode = boundUserDefinedUnaryOperator.Syntax Dim type As ITypeSymbol = boundUserDefinedUnaryOperator.Type Dim constantValue As [Optional](Of Object) = ConvertToOptional(boundUserDefinedUnaryOperator.ConstantValueOpt) + Dim isImplicit As Boolean = boundUserDefinedUnaryOperator.WasCompilerGenerated Dim isLifted = (boundUserDefinedUnaryOperator.OperatorKind And UnaryOperatorKind.Lifted) <> 0 - Return New LazyUnaryOperatorExpression(unaryOperationKind, operand, isLifted, usesOperatorMethod, operatorMethod, _semanticModel, syntax, type, constantValue) + Return New LazyUnaryOperatorExpression(unaryOperationKind, operand, isLifted, usesOperatorMethod, operatorMethod, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundBinaryOperatorOperation(boundBinaryOperator As BoundBinaryOperator) As IBinaryOperatorExpression @@ -426,7 +441,8 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim type As ITypeSymbol = boundBinaryOperator.Type Dim constantValue As [Optional](Of Object) = ConvertToOptional(boundBinaryOperator.ConstantValueOpt) Dim isLifted = (boundBinaryOperator.OperatorKind And BinaryOperatorKind.Lifted) <> 0 - Return New LazyBinaryOperatorExpression(binaryOperationKind, leftOperand, rightOperand, isLifted, usesOperatorMethod, operatorMethod, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundBinaryOperator.WasCompilerGenerated + Return New LazyBinaryOperatorExpression(binaryOperationKind, leftOperand, rightOperand, isLifted, usesOperatorMethod, operatorMethod, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundUserDefinedBinaryOperatorOperation(boundUserDefinedBinaryOperator As BoundUserDefinedBinaryOperator) As IBinaryOperatorExpression @@ -439,7 +455,8 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim type As ITypeSymbol = boundUserDefinedBinaryOperator.Type Dim constantValue As [Optional](Of Object) = ConvertToOptional(boundUserDefinedBinaryOperator.ConstantValueOpt) Dim isLifted = (boundUserDefinedBinaryOperator.OperatorKind And BinaryOperatorKind.Lifted) <> 0 - Return New LazyBinaryOperatorExpression(binaryOperationKind, leftOperand, rightOperand, isLifted, usesOperatorMethod, operatorMethod, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundUserDefinedBinaryOperator.WasCompilerGenerated + Return New LazyBinaryOperatorExpression(binaryOperationKind, leftOperand, rightOperand, isLifted, usesOperatorMethod, operatorMethod, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundBinaryConditionalExpressionOperation(boundBinaryConditionalExpression As BoundBinaryConditionalExpression) As INullCoalescingExpression @@ -448,7 +465,8 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim syntax As SyntaxNode = boundBinaryConditionalExpression.Syntax Dim type As ITypeSymbol = boundBinaryConditionalExpression.Type Dim constantValue As [Optional](Of Object) = ConvertToOptional(boundBinaryConditionalExpression.ConstantValueOpt) - Return New LazyNullCoalescingExpression(primaryOperand, secondaryOperand, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundBinaryConditionalExpression.WasCompilerGenerated + Return New LazyNullCoalescingExpression(primaryOperand, secondaryOperand, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundUserDefinedShortCircuitingOperatorOperation(boundUserDefinedShortCircuitingOperator As BoundUserDefinedShortCircuitingOperator) As IBinaryOperatorExpression @@ -461,7 +479,8 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim type As ITypeSymbol = boundUserDefinedShortCircuitingOperator.Type Dim constantValue As [Optional](Of Object) = ConvertToOptional(boundUserDefinedShortCircuitingOperator.ConstantValueOpt) Dim isLifted = (boundUserDefinedShortCircuitingOperator.BitwiseOperator.OperatorKind And BinaryOperatorKind.Lifted) <> 0 - Return New LazyBinaryOperatorExpression(binaryOperationKind, leftOperand, rightOperand, isLifted, usesOperatorMethod, operatorMethod, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundUserDefinedShortCircuitingOperator.WasCompilerGenerated + Return New LazyBinaryOperatorExpression(binaryOperationKind, leftOperand, rightOperand, isLifted, usesOperatorMethod, operatorMethod, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundBadExpressionOperation(boundBadExpression As BoundBadExpression) As IInvalidExpression @@ -469,7 +488,8 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim syntax As SyntaxNode = boundBadExpression.Syntax Dim type As ITypeSymbol = boundBadExpression.Type Dim constantValue As [Optional](Of Object) = ConvertToOptional(boundBadExpression.ConstantValueOpt) - Return New LazyInvalidExpression(children, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundBadExpression.WasCompilerGenerated + Return New LazyInvalidExpression(children, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundTryCastOperation(boundTryCast As BoundTryCast) As IConversionExpression @@ -481,7 +501,8 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim isChecked = False Dim type As ITypeSymbol = boundTryCast.Type Dim constantValue As [Optional](Of Object) = ConvertToOptional(boundTryCast.ConstantValueOpt) - Return New LazyVisualBasicConversionExpression(operand, conversion, isExplicitCastInCode, isTryCast, isChecked, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundTryCast.WasCompilerGenerated + Return New LazyVisualBasicConversionExpression(operand, conversion, isExplicitCastInCode, isTryCast, isChecked, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundDirectCastOperation(boundDirectCast As BoundDirectCast) As IConversionExpression @@ -493,7 +514,8 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim isChecked = False Dim type As ITypeSymbol = boundDirectCast.Type Dim constantValue As [Optional](Of Object) = ConvertToOptional(boundDirectCast.ConstantValueOpt) - Return New LazyVisualBasicConversionExpression(operand, conversion, isExplicit, isTryCast, isChecked, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundDirectCast.WasCompilerGenerated + Return New LazyVisualBasicConversionExpression(operand, conversion, isExplicit, isTryCast, isChecked, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundConversionOperation(boundConversion As BoundConversion) As IConversionExpression @@ -505,7 +527,8 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim isChecked = False Dim type As ITypeSymbol = boundConversion.Type Dim constantValue As [Optional](Of Object) = ConvertToOptional(boundConversion.ConstantValueOpt) - Return New LazyVisualBasicConversionExpression(operand, conversion, isExplicit, isTryCast, isChecked, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundConversion.WasCompilerGenerated + Return New LazyVisualBasicConversionExpression(operand, conversion, isExplicit, isTryCast, isChecked, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundUserDefinedConversionOperation(boundUserDefinedConversion As BoundUserDefinedConversion) As IConversionExpression @@ -517,7 +540,8 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim isChecked = False Dim type As ITypeSymbol = boundUserDefinedConversion.Type Dim constantValue As [Optional](Of Object) = ConvertToOptional(boundUserDefinedConversion.ConstantValueOpt) - Return New LazyVisualBasicConversionExpression(operand, conversion, isExplicit, isTryCast, isChecked, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundUserDefinedConversion.WasCompilerGenerated + Return New LazyVisualBasicConversionExpression(operand, conversion, isExplicit, isTryCast, isChecked, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundTernaryConditionalExpressionOperation(boundTernaryConditionalExpression As BoundTernaryConditionalExpression) As IConditionalChoiceExpression @@ -527,7 +551,8 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim syntax As SyntaxNode = boundTernaryConditionalExpression.Syntax Dim type As ITypeSymbol = boundTernaryConditionalExpression.Type Dim constantValue As [Optional](Of Object) = ConvertToOptional(boundTernaryConditionalExpression.ConstantValueOpt) - Return New LazyConditionalChoiceExpression(condition, ifTrueValue, ifFalseValue, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundTernaryConditionalExpression.WasCompilerGenerated + Return New LazyConditionalChoiceExpression(condition, ifTrueValue, ifFalseValue, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundTypeOfOperation(boundTypeOf As BoundTypeOf) As IIsTypeExpression @@ -536,7 +561,8 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim syntax As SyntaxNode = boundTypeOf.Syntax Dim type As ITypeSymbol = boundTypeOf.Type Dim constantValue As [Optional](Of Object) = ConvertToOptional(boundTypeOf.ConstantValueOpt) - Return New LazyIsTypeExpression(operand, isType, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundTypeOf.WasCompilerGenerated + Return New LazyIsTypeExpression(operand, isType, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundObjectCreationExpressionOperation(boundObjectCreationExpression As BoundObjectCreationExpression) As IObjectCreationExpression @@ -557,7 +583,8 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim syntax As SyntaxNode = boundObjectCreationExpression.Syntax Dim type As ITypeSymbol = boundObjectCreationExpression.Type Dim constantValue As [Optional](Of Object) = ConvertToOptional(boundObjectCreationExpression.ConstantValueOpt) - Return New LazyObjectCreationExpression(constructor, memberInitializers, argumentsInEvaluationOrder, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundObjectCreationExpression.WasCompilerGenerated + Return New LazyObjectCreationExpression(constructor, memberInitializers, argumentsInEvaluationOrder, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundObjectInitializerExpressionOperation(boundObjectInitializerExpression As BoundObjectInitializerExpression) As IObjectOrCollectionInitializerExpression @@ -565,7 +592,8 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim syntax As SyntaxNode = boundObjectInitializerExpression.Syntax Dim type As ITypeSymbol = boundObjectInitializerExpression.Type Dim constantValue As [Optional](Of Object) = ConvertToOptional(boundObjectInitializerExpression.ConstantValueOpt) - Return New LazyObjectOrCollectionInitializerExpression(initializers, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundObjectInitializerExpression.WasCompilerGenerated + Return New LazyObjectOrCollectionInitializerExpression(initializers, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundCollectionInitializerExpressionOperation(boundCollectionInitializerExpression As BoundCollectionInitializerExpression) As IObjectOrCollectionInitializerExpression @@ -573,7 +601,8 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim syntax As SyntaxNode = boundCollectionInitializerExpression.Syntax Dim type As ITypeSymbol = boundCollectionInitializerExpression.Type Dim constantValue As [Optional](Of Object) = ConvertToOptional(boundCollectionInitializerExpression.ConstantValueOpt) - Return New LazyObjectOrCollectionInitializerExpression(initializers, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundCollectionInitializerExpression.WasCompilerGenerated + Return New LazyObjectOrCollectionInitializerExpression(initializers, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundCollectionElementInitializerOperation(boundExpression As BoundExpression) As IOperation @@ -588,7 +617,8 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim syntax As SyntaxNode = boundExpression.Syntax Dim type As ITypeSymbol = boundExpression.Type Dim constantValue As [Optional](Of Object) = ConvertToOptional(boundExpression.ConstantValueOpt) - Return New LazyCollectionElementInitializerExpression(addMethod, arguments, isDynamic, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundExpression.WasCompilerGenerated + Return New LazyCollectionElementInitializerExpression(addMethod, arguments, isDynamic, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundNewTOperation(boundNewT As BoundNewT) As ITypeParameterObjectCreationExpression @@ -596,7 +626,8 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim syntax As SyntaxNode = boundNewT.Syntax Dim type As ITypeSymbol = boundNewT.Type Dim constantValue As [Optional](Of Object) = ConvertToOptional(boundNewT.ConstantValueOpt) - Return New LazyTypeParameterObjectCreationExpression(initializer, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundNewT.WasCompilerGenerated + Return New LazyTypeParameterObjectCreationExpression(initializer, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundArrayCreationOperation(boundArrayCreation As BoundArrayCreation) As IArrayCreationExpression @@ -606,7 +637,8 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim syntax As SyntaxNode = boundArrayCreation.Syntax Dim type As ITypeSymbol = boundArrayCreation.Type Dim constantValue As [Optional](Of Object) = ConvertToOptional(boundArrayCreation.ConstantValueOpt) - Return New LazyArrayCreationExpression(elementType, dimensionSizes, initializer, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundArrayCreation.WasCompilerGenerated + Return New LazyArrayCreationExpression(elementType, dimensionSizes, initializer, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundArrayInitializationOperation(boundArrayInitialization As BoundArrayInitialization) As IArrayInitializer @@ -614,7 +646,8 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim syntax As SyntaxNode = boundArrayInitialization.Syntax Dim type As ITypeSymbol = boundArrayInitialization.Type Dim constantValue As [Optional](Of Object) = ConvertToOptional(boundArrayInitialization.ConstantValueOpt) - Return New LazyArrayInitializer(elementValues, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundArrayInitialization.WasCompilerGenerated + Return New LazyArrayInitializer(elementValues, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundPropertyAccessOperation(boundPropertyAccess As BoundPropertyAccess) As IPropertyReferenceExpression @@ -637,7 +670,8 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim syntax As SyntaxNode = boundPropertyAccess.Syntax Dim type As ITypeSymbol = boundPropertyAccess.Type Dim constantValue As [Optional](Of Object) = ConvertToOptional(boundPropertyAccess.ConstantValueOpt) - Return New LazyPropertyReferenceExpression([property], instance, [property], argumentsInEvaluationOrder, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundPropertyAccess.WasCompilerGenerated + Return New LazyPropertyReferenceExpression([property], instance, [property], argumentsInEvaluationOrder, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundEventAccessOperation(boundEventAccess As BoundEventAccess) As IEventReferenceExpression @@ -654,7 +688,8 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim syntax As SyntaxNode = boundEventAccess.Syntax Dim type As ITypeSymbol = boundEventAccess.Type Dim constantValue As [Optional](Of Object) = ConvertToOptional(boundEventAccess.ConstantValueOpt) - Return New LazyEventReferenceExpression([event], instance, [event], _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundEventAccess.WasCompilerGenerated + Return New LazyEventReferenceExpression([event], instance, [event], _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundFieldAccessOperation(boundFieldAccess As BoundFieldAccess) As IFieldReferenceExpression @@ -672,7 +707,8 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim syntax As SyntaxNode = boundFieldAccess.Syntax Dim type As ITypeSymbol = boundFieldAccess.Type Dim constantValue As [Optional](Of Object) = ConvertToOptional(boundFieldAccess.ConstantValueOpt) - Return New LazyFieldReferenceExpression(field, instance, member, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundFieldAccess.WasCompilerGenerated + Return New LazyFieldReferenceExpression(field, instance, member, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundConditionalAccessOperation(boundConditionalAccess As BoundConditionalAccess) As IConditionalAccessExpression @@ -681,14 +717,16 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim syntax As SyntaxNode = boundConditionalAccess.Syntax Dim type As ITypeSymbol = boundConditionalAccess.Type Dim constantValue As [Optional](Of Object) = ConvertToOptional(boundConditionalAccess.ConstantValueOpt) - Return New LazyConditionalAccessExpression(conditionalValue, conditionalInstance, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundConditionalAccess.WasCompilerGenerated + Return New LazyConditionalAccessExpression(conditionalValue, conditionalInstance, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundConditionalAccessReceiverPlaceholderOperation(boundConditionalAccessReceiverPlaceholder As BoundConditionalAccessReceiverPlaceholder) As IConditionalAccessInstanceExpression Dim syntax As SyntaxNode = boundConditionalAccessReceiverPlaceholder.Syntax Dim type As ITypeSymbol = boundConditionalAccessReceiverPlaceholder.Type Dim constantValue As [Optional](Of Object) = ConvertToOptional(boundConditionalAccessReceiverPlaceholder.ConstantValueOpt) - Return New ConditionalAccessInstanceExpression(_semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundConditionalAccessReceiverPlaceholder.WasCompilerGenerated + Return New ConditionalAccessInstanceExpression(_semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundParameterOperation(boundParameter As BoundParameter) As IParameterReferenceExpression @@ -696,7 +734,8 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim syntax As SyntaxNode = boundParameter.Syntax Dim type As ITypeSymbol = boundParameter.Type Dim constantValue As [Optional](Of Object) = ConvertToOptional(boundParameter.ConstantValueOpt) - Return New ParameterReferenceExpression(parameter, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundParameter.WasCompilerGenerated + Return New ParameterReferenceExpression(parameter, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundLocalOperation(boundLocal As BoundLocal) As ILocalReferenceExpression @@ -704,7 +743,8 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim syntax As SyntaxNode = boundLocal.Syntax Dim type As ITypeSymbol = boundLocal.Type Dim constantValue As [Optional](Of Object) = ConvertToOptional(boundLocal.ConstantValueOpt) - Return New LocalReferenceExpression(local, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundLocal.WasCompilerGenerated + Return New LocalReferenceExpression(local, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundLateMemberAccessOperation(boundLateMemberAccess As BoundLateMemberAccess) As IDynamicMemberReferenceExpression @@ -727,7 +767,8 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim syntax As SyntaxNode = boundLateMemberAccess.Syntax Dim type As ITypeSymbol = boundLateMemberAccess.Type Dim constantValue As [Optional](Of Object) = ConvertToOptional(boundLateMemberAccess.ConstantValueOpt) - Return New LazyDynamicMemberReferenceExpression(instance, memberName, typeArguments, containingType, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundLateMemberAccess.WasCompilerGenerated + Return New LazyDynamicMemberReferenceExpression(instance, memberName, typeArguments, containingType, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundFieldInitializerOperation(boundFieldInitializer As BoundFieldInitializer) As IFieldInitializer @@ -737,7 +778,8 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim syntax As SyntaxNode = boundFieldInitializer.Syntax Dim type As ITypeSymbol = Nothing Dim constantValue As [Optional](Of Object) = New [Optional](Of Object)() - Return New LazyFieldInitializer(initializedFields, value, kind, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundFieldInitializer.WasCompilerGenerated + Return New LazyFieldInitializer(initializedFields, value, kind, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundPropertyInitializerOperation(boundPropertyInitializer As BoundPropertyInitializer) As IPropertyInitializer @@ -747,7 +789,8 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim syntax As SyntaxNode = boundPropertyInitializer.Syntax Dim type As ITypeSymbol = Nothing Dim constantValue As [Optional](Of Object) = New [Optional](Of Object)() - Return New LazyPropertyInitializer(initializedProperty, value, kind, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundPropertyInitializer.WasCompilerGenerated + Return New LazyPropertyInitializer(initializedProperty, value, kind, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundParameterEqualsValueOperation(boundParameterEqualsValue As BoundParameterEqualsValue) As IParameterInitializer @@ -757,14 +800,16 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim syntax As SyntaxNode = boundParameterEqualsValue.Syntax Dim type As ITypeSymbol = Nothing Dim constantValue As [Optional](Of Object) = New [Optional](Of Object)() - Return New LazyParameterInitializer(parameter, value, kind, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundParameterEqualsValue.WasCompilerGenerated + Return New LazyParameterInitializer(parameter, value, kind, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundRValuePlaceholderOperation(boundRValuePlaceholder As BoundRValuePlaceholder) As IPlaceholderExpression Dim syntax As SyntaxNode = boundRValuePlaceholder.Syntax Dim type As ITypeSymbol = boundRValuePlaceholder.Type Dim constantValue As [Optional](Of Object) = ConvertToOptional(boundRValuePlaceholder.ConstantValueOpt) - Return New PlaceholderExpression(_semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundRValuePlaceholder.WasCompilerGenerated + Return New PlaceholderExpression(_semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundIfStatementOperation(boundIfStatement As BoundIfStatement) As IIfStatement @@ -774,7 +819,8 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim syntax As SyntaxNode = boundIfStatement.Syntax Dim type As ITypeSymbol = Nothing Dim constantValue As [Optional](Of Object) = New [Optional](Of Object)() - Return New LazyIfStatement(condition, ifTrueStatement, ifFalseStatement, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundIfStatement.WasCompilerGenerated + Return New LazyIfStatement(condition, ifTrueStatement, ifFalseStatement, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundSelectStatementOperation(boundSelectStatement As BoundSelectStatement) As ISwitchStatement @@ -783,7 +829,8 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim syntax As SyntaxNode = boundSelectStatement.Syntax Dim type As ITypeSymbol = Nothing Dim constantValue As [Optional](Of Object) = New [Optional](Of Object)() - Return New LazySwitchStatement(value, cases, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundSelectStatement.WasCompilerGenerated + Return New LazySwitchStatement(value, cases, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundSimpleCaseClauseOperation(boundSimpleCaseClause As BoundSimpleCaseClause) As ISingleValueCaseClause @@ -794,7 +841,8 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim syntax As SyntaxNode = boundSimpleCaseClause.Syntax Dim type As ITypeSymbol = Nothing Dim constantValue As [Optional](Of Object) = New [Optional](Of Object)() - Return New LazySingleValueCaseClause(value, equality, CaseKind, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundSimpleCaseClause.WasCompilerGenerated + Return New LazySingleValueCaseClause(value, equality, CaseKind, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundRangeCaseClauseOperation(boundRangeCaseClause As BoundRangeCaseClause) As IRangeCaseClause @@ -832,7 +880,8 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim syntax As SyntaxNode = boundRangeCaseClause.Syntax Dim type As ITypeSymbol = Nothing Dim constantValue As [Optional](Of Object) = New [Optional](Of Object)() - Return New LazyRangeCaseClause(minimumValue, maximumValue, CaseKind, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundRangeCaseClause.WasCompilerGenerated + Return New LazyRangeCaseClause(minimumValue, maximumValue, CaseKind, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundRelationalCaseClauseOperation(boundRelationalCaseClause As BoundRelationalCaseClause) As IRelationalCaseClause @@ -843,7 +892,8 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim syntax As SyntaxNode = boundRelationalCaseClause.Syntax Dim type As ITypeSymbol = Nothing Dim constantValue As [Optional](Of Object) = New [Optional](Of Object)() - Return New LazyRelationalCaseClause(value, relation, CaseKind, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundRelationalCaseClause.WasCompilerGenerated + Return New LazyRelationalCaseClause(value, relation, CaseKind, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundDoLoopStatementOperation(boundDoLoopStatement As BoundDoLoopStatement) As IWhileUntilLoopStatement @@ -855,7 +905,8 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim syntax As SyntaxNode = boundDoLoopStatement.Syntax Dim type As ITypeSymbol = Nothing Dim constantValue As [Optional](Of Object) = New [Optional](Of Object)() - Return New LazyWhileUntilLoopStatement(isTopTest, isWhile, condition, LoopKind, body, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundDoLoopStatement.WasCompilerGenerated + Return New LazyWhileUntilLoopStatement(isTopTest, isWhile, condition, LoopKind, body, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundForToStatementOperation(boundForToStatement As BoundForToStatement) As IForLoopStatement @@ -888,7 +939,8 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim syntax As SyntaxNode = boundForToStatement.Syntax Dim type As ITypeSymbol = Nothing Dim constantValue As [Optional](Of Object) = New [Optional](Of Object)() - Return New LazyForLoopStatement(before, atLoopBottom, locals, condition, LoopKind, body, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundForToStatement.WasCompilerGenerated + Return New LazyForLoopStatement(before, atLoopBottom, locals, condition, LoopKind, body, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundForEachStatementOperation(boundForEachStatement As BoundForEachStatement) As IForEachLoopStatement @@ -899,7 +951,8 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim syntax As SyntaxNode = boundForEachStatement.Syntax Dim type As ITypeSymbol = Nothing Dim constantValue As [Optional](Of Object) = New [Optional](Of Object)() - Return New LazyForEachLoopStatement(iterationVariable, collection, LoopKind, body, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundForEachStatement.WasCompilerGenerated + Return New LazyForEachLoopStatement(iterationVariable, collection, LoopKind, body, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundTryStatementOperation(boundTryStatement As BoundTryStatement) As ITryStatement @@ -909,7 +962,8 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim syntax As SyntaxNode = boundTryStatement.Syntax Dim type As ITypeSymbol = Nothing Dim constantValue As [Optional](Of Object) = New [Optional](Of Object)() - Return New LazyTryStatement(body, catches, finallyHandler, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundTryStatement.WasCompilerGenerated + Return New LazyTryStatement(body, catches, finallyHandler, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundCatchBlockOperation(boundCatchBlock As BoundCatchBlock) As ICatchClause @@ -920,7 +974,8 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim syntax As SyntaxNode = boundCatchBlock.Syntax Dim type As ITypeSymbol = Nothing Dim constantValue As [Optional](Of Object) = New [Optional](Of Object)() - Return New LazyCatchClause(handler, caughtType, filter, exceptionLocal, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundCatchBlock.WasCompilerGenerated + Return New LazyCatchClause(handler, caughtType, filter, exceptionLocal, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundBlockOperation(boundBlock As BoundBlock) As IBlockStatement @@ -932,7 +987,8 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim syntax As SyntaxNode = boundBlock.Syntax Dim type As ITypeSymbol = Nothing Dim constantValue As [Optional](Of Object) = New [Optional](Of Object)() - Return New LazyBlockStatement(statements, locals, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundBlock.WasCompilerGenerated + Return New LazyBlockStatement(statements, locals, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundBadStatementOperation(boundBadStatement As BoundBadStatement) As IInvalidStatement @@ -951,7 +1007,8 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim syntax As SyntaxNode = boundBadStatement.Syntax Dim type As ITypeSymbol = Nothing Dim constantValue As [Optional](Of Object) = New [Optional](Of Object)() - Return New LazyInvalidStatement(children, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundBadStatement.WasCompilerGenerated + Return New LazyInvalidStatement(children, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundReturnStatementOperation(boundReturnStatement As BoundReturnStatement) As IReturnStatement @@ -959,7 +1016,8 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim syntax As SyntaxNode = boundReturnStatement.Syntax Dim type As ITypeSymbol = Nothing Dim constantValue As [Optional](Of Object) = New [Optional](Of Object)() - Return New LazyReturnStatement(OperationKind.ReturnStatement, returnedValue, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundReturnStatement.WasCompilerGenerated + Return New LazyReturnStatement(OperationKind.ReturnStatement, returnedValue, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundThrowStatementOperation(boundThrowStatement As BoundThrowStatement) As IThrowStatement @@ -967,7 +1025,8 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim syntax As SyntaxNode = boundThrowStatement.Syntax Dim type As ITypeSymbol = Nothing Dim constantValue As [Optional](Of Object) = New [Optional](Of Object)() - Return New LazyThrowStatement(thrownObject, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundThrowStatement.WasCompilerGenerated + Return New LazyThrowStatement(thrownObject, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundWhileStatementOperation(boundWhileStatement As BoundWhileStatement) As IWhileUntilLoopStatement @@ -979,7 +1038,8 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim syntax As SyntaxNode = boundWhileStatement.Syntax Dim type As ITypeSymbol = Nothing Dim constantValue As [Optional](Of Object) = New [Optional](Of Object)() - Return New LazyWhileUntilLoopStatement(isTopTest, isWhile, condition, LoopKind, body, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundWhileStatement.WasCompilerGenerated + Return New LazyWhileUntilLoopStatement(isTopTest, isWhile, condition, LoopKind, body, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundDimStatementOperation(boundDimStatement As BoundDimStatement) As IVariableDeclarationStatement @@ -987,7 +1047,8 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim syntax As SyntaxNode = boundDimStatement.Syntax Dim type As ITypeSymbol = Nothing Dim constantValue As [Optional](Of Object) = New [Optional](Of Object)() - Return New LazyVariableDeclarationStatement(declarations, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundDimStatement.WasCompilerGenerated + Return New LazyVariableDeclarationStatement(declarations, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundYieldStatementOperation(boundYieldStatement As BoundYieldStatement) As IReturnStatement @@ -995,7 +1056,8 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim syntax As SyntaxNode = boundYieldStatement.Syntax Dim type As ITypeSymbol = Nothing Dim constantValue As [Optional](Of Object) = New [Optional](Of Object)() - Return New LazyReturnStatement(OperationKind.YieldReturnStatement, returnedValue, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundYieldStatement.WasCompilerGenerated + Return New LazyReturnStatement(OperationKind.YieldReturnStatement, returnedValue, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundLabelStatementOperation(boundLabelStatement As BoundLabelStatement) As ILabelStatement @@ -1004,7 +1066,8 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim syntax As SyntaxNode = boundLabelStatement.Syntax Dim type As ITypeSymbol = Nothing Dim constantValue As [Optional](Of Object) = New [Optional](Of Object)() - Return New LazyLabelStatement(label, labeledStatement, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundLabelStatement.WasCompilerGenerated + Return New LazyLabelStatement(label, labeledStatement, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundGotoStatementOperation(boundGotoStatement As BoundGotoStatement) As IBranchStatement @@ -1013,7 +1076,8 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim syntax As SyntaxNode = boundGotoStatement.Syntax Dim type As ITypeSymbol = Nothing Dim constantValue As [Optional](Of Object) = New [Optional](Of Object)() - Return New BranchStatement(target, branchKind, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundGotoStatement.WasCompilerGenerated + Return New BranchStatement(target, branchKind, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundContinueStatementOperation(boundContinueStatement As BoundContinueStatement) As IBranchStatement @@ -1022,7 +1086,8 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim syntax As SyntaxNode = boundContinueStatement.Syntax Dim type As ITypeSymbol = Nothing Dim constantValue As [Optional](Of Object) = New [Optional](Of Object)() - Return New BranchStatement(target, branchKind, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundContinueStatement.WasCompilerGenerated + Return New BranchStatement(target, branchKind, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundExitStatementOperation(boundExitStatement As BoundExitStatement) As IBranchStatement @@ -1031,7 +1096,8 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim syntax As SyntaxNode = boundExitStatement.Syntax Dim type As ITypeSymbol = Nothing Dim constantValue As [Optional](Of Object) = New [Optional](Of Object)() - Return New BranchStatement(target, branchKind, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundExitStatement.WasCompilerGenerated + Return New BranchStatement(target, branchKind, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundSyncLockStatementOperation(boundSyncLockStatement As BoundSyncLockStatement) As ILockStatement @@ -1040,28 +1106,32 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim syntax As SyntaxNode = boundSyncLockStatement.Syntax Dim type As ITypeSymbol = Nothing Dim constantValue As [Optional](Of Object) = New [Optional](Of Object)() - Return New LazyLockStatement(lockedObject, body, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundSyncLockStatement.WasCompilerGenerated + Return New LazyLockStatement(lockedObject, body, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundNoOpStatementOperation(boundNoOpStatement As BoundNoOpStatement) As IEmptyStatement Dim syntax As SyntaxNode = boundNoOpStatement.Syntax Dim type As ITypeSymbol = Nothing Dim constantValue As [Optional](Of Object) = New [Optional](Of Object)() - Return New EmptyStatement(_semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundNoOpStatement.WasCompilerGenerated + Return New EmptyStatement(_semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundStopStatementOperation(boundStopStatement As BoundStopStatement) As IStopStatement Dim syntax As SyntaxNode = boundStopStatement.Syntax Dim type As ITypeSymbol = Nothing Dim constantValue As [Optional](Of Object) = New [Optional](Of Object)() - Return New StopStatement(_semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundStopStatement.WasCompilerGenerated + Return New StopStatement(_semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundEndStatementOperation(boundEndStatement As BoundEndStatement) As IEndStatement Dim syntax As SyntaxNode = boundEndStatement.Syntax Dim type As ITypeSymbol = Nothing Dim constantValue As [Optional](Of Object) = New [Optional](Of Object)() - Return New EndStatement(_semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundEndStatement.WasCompilerGenerated + Return New EndStatement(_semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundWithStatementOperation(boundWithStatement As BoundWithStatement) As IWithStatement @@ -1070,7 +1140,8 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim syntax As SyntaxNode = boundWithStatement.Syntax Dim type As ITypeSymbol = Nothing Dim constantValue As [Optional](Of Object) = New [Optional](Of Object)() - Return New LazyWithStatement(body, value, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundWithStatement.WasCompilerGenerated + Return New LazyWithStatement(body, value, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundUsingStatementOperation(boundUsingStatement As BoundUsingStatement) As IUsingStatement @@ -1083,7 +1154,8 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim syntax As SyntaxNode = boundUsingStatement.Syntax Dim type As ITypeSymbol = Nothing Dim constantValue As [Optional](Of Object) = New [Optional](Of Object)() - Return New LazyUsingStatement(body, declaration, value, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundUsingStatement.WasCompilerGenerated + Return New LazyUsingStatement(body, declaration, value, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundExpressionStatementOperation(boundExpressionStatement As BoundExpressionStatement) As IExpressionStatement @@ -1091,7 +1163,8 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim syntax As SyntaxNode = boundExpressionStatement.Syntax Dim type As ITypeSymbol = Nothing Dim constantValue As [Optional](Of Object) = New [Optional](Of Object)() - Return New LazyExpressionStatement(expression, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundExpressionStatement.WasCompilerGenerated + Return New LazyExpressionStatement(expression, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundRaiseEventStatementOperation(boundRaiseEventStatement As BoundRaiseEventStatement) As IExpressionStatement @@ -1099,7 +1172,8 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim syntax As SyntaxNode = boundRaiseEventStatement.Syntax Dim type As ITypeSymbol = Nothing Dim constantValue As [Optional](Of Object) = New [Optional](Of Object)() - Return New LazyExpressionStatement(expression, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundRaiseEventStatement.WasCompilerGenerated + Return New LazyExpressionStatement(expression, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundAddHandlerStatementOperation(boundAddHandlerStatement As BoundAddHandlerStatement) As IExpressionStatement @@ -1107,7 +1181,8 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim syntax As SyntaxNode = boundAddHandlerStatement.Syntax Dim type As ITypeSymbol = Nothing Dim constantValue As [Optional](Of Object) = New [Optional](Of Object)() - Return New LazyExpressionStatement(expression, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundAddHandlerStatement.WasCompilerGenerated + Return New LazyExpressionStatement(expression, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundRemoveHandlerStatementOperation(boundRemoveHandlerStatement As BoundRemoveHandlerStatement) As IExpressionStatement @@ -1115,7 +1190,8 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim syntax As SyntaxNode = boundRemoveHandlerStatement.Syntax Dim type As ITypeSymbol = Nothing Dim constantValue As [Optional](Of Object) = New [Optional](Of Object)() - Return New LazyExpressionStatement(expression, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundRemoveHandlerStatement.WasCompilerGenerated + Return New LazyExpressionStatement(expression, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundTupleExpressionOperation(boundTupleExpression As BoundTupleExpression) As ITupleExpression @@ -1123,7 +1199,8 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim syntax As SyntaxNode = boundTupleExpression.Syntax Dim type As ITypeSymbol = boundTupleExpression.Type Dim constantValue As [Optional](Of Object) = Nothing - Return New LazyTupleExpression(elements, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundTupleExpression.WasCompilerGenerated + Return New LazyTupleExpression(elements, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundInterpolatedStringExpressionOperation(boundInterpolatedString As BoundInterpolatedStringExpression) As IInterpolatedStringExpression @@ -1135,7 +1212,8 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim syntax As SyntaxNode = boundInterpolatedString.Syntax Dim type As ITypeSymbol = boundInterpolatedString.Type Dim constantValue As [Optional](Of Object) = ConvertToOptional(boundInterpolatedString.ConstantValueOpt) - Return New LazyInterpolatedStringExpression(parts, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundInterpolatedString.WasCompilerGenerated + Return New LazyInterpolatedStringExpression(parts, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundInterpolatedStringContentOperation(boundNode As BoundNode) As IInterpolatedStringContent @@ -1153,7 +1231,8 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim syntax As SyntaxNode = boundInterpolation.Syntax Dim type As ITypeSymbol = Nothing Dim constantValue As [Optional](Of Object) = Nothing - Return New LazyInterpolation(expression, alignment, format, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundInterpolation.WasCompilerGenerated + Return New LazyInterpolation(expression, alignment, format, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundInterpolatedStringTextOperation(boundNode As BoundNode) As IInterpolatedStringText @@ -1161,7 +1240,8 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim syntax As SyntaxNode = boundNode.Syntax Dim type As ITypeSymbol = Nothing Dim constantValue As [Optional](Of Object) = Nothing - Return New LazyInterpolatedStringText(text, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundNode.WasCompilerGenerated + Return New LazyInterpolatedStringText(text, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundAnonymousTypeCreationExpressionOperation(boundAnonymousTypeCreationExpression As BoundAnonymousTypeCreationExpression) As IAnonymousObjectCreationExpression @@ -1173,7 +1253,8 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim syntax As SyntaxNode = boundAnonymousTypeCreationExpression.Syntax Dim type As ITypeSymbol = boundAnonymousTypeCreationExpression.Type Dim constantValue As [Optional](Of Object) = ConvertToOptional(boundAnonymousTypeCreationExpression.ConstantValueOpt) - Return New LazyAnonymousObjectCreationExpression(initializers, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundAnonymousTypeCreationExpression.WasCompilerGenerated + Return New LazyAnonymousObjectCreationExpression(initializers, _semanticModel, syntax, type, constantValue, isImplicit) End Function Private Function CreateBoundAnonymousTypePropertyAccessOperation(boundAnonymousTypePropertyAccess As BoundAnonymousTypePropertyAccess) As IPropertyReferenceExpression @@ -1183,7 +1264,8 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim syntax As SyntaxNode = boundAnonymousTypePropertyAccess.Syntax Dim type As ITypeSymbol = boundAnonymousTypePropertyAccess.Type Dim constantValue As [Optional](Of Object) = ConvertToOptional(boundAnonymousTypePropertyAccess.ConstantValueOpt) - Return New LazyPropertyReferenceExpression([property], instance, [property], argumentsInEvaluationOrder, _semanticModel, syntax, type, constantValue) + Dim isImplicit As Boolean = boundAnonymousTypePropertyAccess.WasCompilerGenerated + Return New LazyPropertyReferenceExpression([property], instance, [property], argumentsInEvaluationOrder, _semanticModel, syntax, type, constantValue, isImplicit) End Function End Class End Namespace diff --git a/src/Compilers/VisualBasic/Portable/Operations/VisualBasicOperationFactory_Methods.vb b/src/Compilers/VisualBasic/Portable/Operations/VisualBasicOperationFactory_Methods.vb index 9bcea721014ad..86fd39877098e 100644 --- a/src/Compilers/VisualBasic/Portable/Operations/VisualBasicOperationFactory_Methods.vb +++ b/src/Compilers/VisualBasic/Portable/Operations/VisualBasicOperationFactory_Methods.vb @@ -41,8 +41,8 @@ Namespace Microsoft.CodeAnalysis.Semantics If child IsNot Nothing Then Return child End If - - Return OperationFactory.CreateInvalidExpression(_semanticModel, [operator].UnderlyingExpression.Syntax, ImmutableArray(Of IOperation).Empty) + Dim isImplicit As Boolean = [operator].WasCompilerGenerated + Return OperationFactory.CreateInvalidExpression(_semanticModel, [operator].UnderlyingExpression.Syntax, ImmutableArray(Of IOperation).Empty, isImplicit) End Function Private Shared Function GetUserDefinedBinaryOperatorChildBoundNode([operator] As BoundUserDefinedBinaryOperator, index As Integer) As BoundNode @@ -72,6 +72,7 @@ Namespace Microsoft.CodeAnalysis.Semantics End Function Private Function DeriveArgument(index As Integer, argument As BoundExpression, parameters As ImmutableArray(Of VisualBasic.Symbols.ParameterSymbol)) As IArgument + Dim isImplicit As Boolean = argument.WasCompilerGenerated Select Case argument.Kind Case BoundKind.ByRefArgumentWithCopyBack Dim byRefArgument = DirectCast(argument, BoundByRefArgumentWithCopyBack) @@ -86,7 +87,8 @@ Namespace Microsoft.CodeAnalysis.Semantics _semanticModel, value.Syntax, type:=Nothing, - constantValue:=Nothing) + constantValue:=Nothing, + isImplicit:=isImplicit) Case Else Dim lastParameterIndex = parameters.Length - 1 If index = lastParameterIndex AndAlso ParameterIsParamArray(parameters(lastParameterIndex)) Then @@ -107,7 +109,8 @@ Namespace Microsoft.CodeAnalysis.Semantics semanticModel:=_semanticModel, syntax:=value.Syntax, type:=Nothing, - constantValue:=Nothing) + constantValue:=Nothing, + isImplicit:=isImplicit) Else ' TODO: figure our if this is true: ' a compiler generated argument for an Optional parameter is created iff @@ -126,7 +129,8 @@ Namespace Microsoft.CodeAnalysis.Semantics semanticModel:=_semanticModel, syntax:=value.Syntax, type:=Nothing, - constantValue:=Nothing) + constantValue:=Nothing, + isImplicit:=isImplicit) End If End Select End Function @@ -140,8 +144,8 @@ Namespace Microsoft.CodeAnalysis.Semantics If child IsNot Nothing Then Return child End If - - Return OperationFactory.CreateInvalidExpression(_semanticModel, parent.Syntax, ImmutableArray(Of IOperation).Empty) + Dim isImplicit As Boolean = parent.WasCompilerGenerated + Return OperationFactory.CreateInvalidExpression(_semanticModel, parent.Syntax, ImmutableArray(Of IOperation).Empty, isImplicit) End Function Private Shared Function GetChildOfBadExpressionBoundNode(parent As BoundNode, index As Integer) As BoundNode @@ -175,7 +179,7 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim syntax As SyntaxNode = If(value.Syntax?.Parent, expression.Syntax) Dim type As ITypeSymbol = target.Type Dim constantValue As [Optional](Of Object) = value.ConstantValue - Dim assignment = New SimpleAssignmentExpression(target, value, _semanticModel, syntax, type, constantValue) + Dim assignment = New SimpleAssignmentExpression(target, value, _semanticModel, syntax, type, constantValue, isImplicit:=value.IsImplicit) builder.Add(assignment) Next i @@ -189,20 +193,22 @@ Namespace Microsoft.CodeAnalysis.Semantics ' so we explicitly create an IOperation node for Case-Else clause to differentiate it from Case clause. Dim clauses As ImmutableArray(Of ICaseClause) Dim caseStatement = boundCaseBlock.CaseStatement + Dim isImplicit As Boolean = boundCaseBlock.WasCompilerGenerated If caseStatement.CaseClauses.IsEmpty AndAlso caseStatement.Syntax.Kind() = SyntaxKind.CaseElseStatement Then clauses = ImmutableArray.Create(Of ICaseClause)( New DefaultCaseClause( _semanticModel, caseStatement.Syntax, type:=Nothing, - constantValue:=Nothing)) + constantValue:=Nothing, + isImplicit:=isImplicit)) Else clauses = caseStatement.CaseClauses.SelectAsArray(Function(n) DirectCast(Create(n), ICaseClause)) End If Dim body = ImmutableArray.Create(Create(boundCaseBlock.Body)) Dim syntax = boundCaseBlock.Syntax - Return DirectCast(New SwitchCase(clauses, body, _semanticModel, syntax, type:=Nothing, constantValue:=Nothing), ISwitchCase) + Return DirectCast(New SwitchCase(clauses, body, _semanticModel, syntax, type:=Nothing, constantValue:=Nothing, isImplicit:=isImplicit), ISwitchCase) End Function) End Function @@ -264,7 +270,7 @@ Namespace Microsoft.CodeAnalysis.Semantics ' ControlVariable = InitialValue If controlVariable IsNot Nothing Then - statements.Add(OperationFactory.CreateSimpleAssignmentExpressionStatement(Create(controlVariable), Create(initialValue), _semanticModel, initialValue.Syntax)) + statements.Add(OperationFactory.CreateSimpleAssignmentExpressionStatement(Create(controlVariable), Create(initialValue), _semanticModel, initialValue.Syntax, isImplicit:=controlVariable.WasCompilerGenerated)) End If ' T0 = LimitValue @@ -276,7 +282,8 @@ Namespace Microsoft.CodeAnalysis.Semantics _semanticModel, limitValue.Syntax, limitValue.Type, - constantValue:=Nothing), limitValue, _semanticModel, limitValue.Syntax)) + constantValue:=Nothing, + isImplicit:=limitValue.IsImplicit), limitValue, _semanticModel, limitValue.Syntax, limitValue.IsImplicit)) End If ' T1 = StepValue @@ -288,7 +295,8 @@ Namespace Microsoft.CodeAnalysis.Semantics _semanticModel, stepValue.Syntax, stepValue.Type, - constantValue:=Nothing), stepValue, _semanticModel, stepValue.Syntax)) + constantValue:=Nothing, + isImplicit:=stepValue.IsImplicit), stepValue, _semanticModel, stepValue.Syntax, stepValue.IsImplicit)) End If Return statements.ToImmutableAndFree() @@ -316,11 +324,12 @@ Namespace Microsoft.CodeAnalysis.Semantics _semanticModel, value.Syntax, value.Type, - constantValue:=Nothing)) + constantValue:=Nothing, + isImplicit:=value.IsImplicit)) statements.Add(OperationFactory.CreateCompoundAssignmentExpressionStatement( controlVariable, stepOperand, Expression.DeriveAdditionKind(controlType.GetNullableUnderlyingTypeOrSelf()), controlType.IsNullableType(), - Nothing, _semanticModel, stepValueExpression.Syntax)) + Nothing, _semanticModel, stepValueExpression.Syntax, value.IsImplicit)) End If End If @@ -342,7 +351,8 @@ Namespace Microsoft.CodeAnalysis.Semantics _semanticModel, limitValueOperation.Syntax, limitValueOperation.Type, - constantValue:=Nothing)) + constantValue:=Nothing, + isImplicit:=limitValueOperation.IsImplicit)) ' controlVariable can be a BoundBadExpression in case of error Dim booleanType As ITypeSymbol = controlVariable.ExpressionSymbol?.DeclaringCompilation.GetSpecialType(SpecialType.System_Boolean) @@ -364,7 +374,7 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim relationalCode As BinaryOperationKind = Helper.DeriveBinaryOperationKind( If(stepValue IsNot Nothing AndAlso stepValue.ConstantValueOpt.IsNegativeNumeric, BinaryOperatorKind.GreaterThanOrEqual, BinaryOperatorKind.LessThanOrEqual), controlVariable) Return OperationFactory.CreateBinaryOperatorExpression( - relationalCode, _semanticModel.CloneOperation(Create(controlVariable)), limitValueReference, booleanType, _semanticModel, limitValueReference.Syntax, isLifted) + relationalCode, _semanticModel.CloneOperation(Create(controlVariable)), limitValueReference, booleanType, _semanticModel, limitValueReference.Syntax, isLifted, limitValueReference.IsImplicit) Else ' If(StepValue >= 0, ControlVariable <= LimitValue, ControlVariable >= LimitValue) Dim value = Create(stepValue) @@ -373,25 +383,27 @@ Namespace Microsoft.CodeAnalysis.Semantics _semanticModel, value.Syntax, value.Type, - constantValue:=Nothing) + constantValue:=Nothing, + isImplicit:=value.IsImplicit) Dim stepRelationalCode As BinaryOperationKind = Helper.DeriveBinaryOperationKind(BinaryOperatorKind.GreaterThanOrEqual, stepValue) Dim stepConditionIsLifted = stepValue.Type.IsNullableType() Dim stepCondition As IOperation = OperationFactory.CreateBinaryOperatorExpression(stepRelationalCode, stepValueReference, - OperationFactory.CreateLiteralExpression(Semantics.Expression.SynthesizeNumeric(stepValueReference.Type, 0), stepValue.Type, _semanticModel, stepValue.Syntax), + OperationFactory.CreateLiteralExpression(Semantics.Expression.SynthesizeNumeric(stepValueReference.Type, 0), stepValue.Type, _semanticModel, stepValue.Syntax, stepValueReference.IsImplicit), booleanType, _semanticModel, stepValue.Syntax, - stepConditionIsLifted) + stepConditionIsLifted, + stepValue.WasCompilerGenerated) Dim positiveStepRelationalCode As BinaryOperationKind = Helper.DeriveBinaryOperationKind(BinaryOperatorKind.LessThanOrEqual, controlVariable) - Dim positiveStepCondition As IOperation = OperationFactory.CreateBinaryOperatorExpression(positiveStepRelationalCode, _semanticModel.CloneOperation(Create(controlVariable)), limitValueReference, booleanType, _semanticModel, limitValueReference.Syntax, isLifted) + Dim positiveStepCondition As IOperation = OperationFactory.CreateBinaryOperatorExpression(positiveStepRelationalCode, _semanticModel.CloneOperation(Create(controlVariable)), limitValueReference, booleanType, _semanticModel, limitValueReference.Syntax, isLifted, limitValueReference.IsImplicit) Dim negativeStepRelationalCode As BinaryOperationKind = Helper.DeriveBinaryOperationKind(BinaryOperatorKind.GreaterThanOrEqual, controlVariable) - Dim negativeStepCondition As IOperation = OperationFactory.CreateBinaryOperatorExpression(negativeStepRelationalCode, _semanticModel.CloneOperation(Create(controlVariable)), _semanticModel.CloneOperation(limitValueReference), booleanType, _semanticModel, limitValueReference.Syntax, isLifted) + Dim negativeStepCondition As IOperation = OperationFactory.CreateBinaryOperatorExpression(negativeStepRelationalCode, _semanticModel.CloneOperation(Create(controlVariable)), _semanticModel.CloneOperation(limitValueReference), booleanType, _semanticModel, limitValueReference.Syntax, isLifted, limitValueReference.IsImplicit) - Return OperationFactory.CreateConditionalChoiceExpression(stepCondition, positiveStepCondition, negativeStepCondition, booleanType, _semanticModel, limitValueReference.Syntax) + Return OperationFactory.CreateConditionalChoiceExpression(stepCondition, positiveStepCondition, negativeStepCondition, booleanType, _semanticModel, limitValueReference.Syntax, limitValueReference.IsImplicit) End If End If End Function @@ -422,7 +434,8 @@ Namespace Microsoft.CodeAnalysis.Semantics _semanticModel, syntax, type:=Nothing, - constantValue:=Nothing) + constantValue:=Nothing, + isImplicit:=False) ' Declaration is always explicit End Function Private Function GetAddRemoveHandlerStatementExpression(statement As BoundAddRemoveHandlerStatement) As IOperation @@ -430,7 +443,7 @@ Namespace Microsoft.CodeAnalysis.Semantics Dim eventReference = If(eventAccess Is Nothing, Nothing, CreateBoundEventAccessOperation(eventAccess)) Dim adds = statement.Kind = BoundKind.AddHandlerStatement Return New EventAssignmentExpression( - eventReference, Create(statement.Handler), adds:=adds, semanticModel:=_semanticModel, syntax:=statement.Syntax, type:=Nothing, constantValue:=Nothing) + eventReference, Create(statement.Handler), adds:=adds, semanticModel:=_semanticModel, syntax:=statement.Syntax, type:=Nothing, constantValue:=Nothing, isImplicit:=statement.WasCompilerGenerated) End Function Private Shared Function GetConversionKind(kind As VisualBasic.ConversionKind) As Semantics.ConversionKind diff --git a/src/Compilers/VisualBasic/Portable/VBResources.Designer.vb b/src/Compilers/VisualBasic/Portable/VBResources.Designer.vb index 3ddb09cdbb3ee..269edbc27171b 100644 --- a/src/Compilers/VisualBasic/Portable/VBResources.Designer.vb +++ b/src/Compilers/VisualBasic/Portable/VBResources.Designer.vb @@ -1784,7 +1784,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic End Property ''' - ''' Looks up a localized string similar to /embed switch is only supported when emitting Portable PDB (/debug:portable or /debug:embedded).. + ''' Looks up a localized string similar to /embed switch is only supported when emitting a PDB.. ''' Friend ReadOnly Property ERR_CannotEmbedWithoutPdb() As String Get diff --git a/src/Compilers/VisualBasic/Portable/VBResources.resx b/src/Compilers/VisualBasic/Portable/VBResources.resx index 3871824dfb5ce..6b068433494d0 100644 --- a/src/Compilers/VisualBasic/Portable/VBResources.resx +++ b/src/Compilers/VisualBasic/Portable/VBResources.resx @@ -5456,7 +5456,7 @@ An expression tree may not contain a call to a method or property that returns by reference. - /embed switch is only supported when emitting Portable PDB (/debug:portable or /debug:embedded). + /embed switch is only supported when emitting a PDB. Invalid instrumentation kind: {0} diff --git a/src/Compilers/VisualBasic/Test/CommandLine/CommandLineTests.vb b/src/Compilers/VisualBasic/Test/CommandLine/CommandLineTests.vb index 3bf8031c535e1..a72147814e3f7 100644 --- a/src/Compilers/VisualBasic/Test/CommandLine/CommandLineTests.vb +++ b/src/Compilers/VisualBasic/Test/CommandLine/CommandLineTests.vb @@ -18,6 +18,8 @@ Imports Microsoft.CodeAnalysis.Emit Imports Microsoft.CodeAnalysis.Test.Utilities Imports Microsoft.CodeAnalysis.Text Imports Microsoft.CodeAnalysis.VisualBasic.UnitTests +Imports Microsoft.DiaSymReader +Imports Roslyn.Test.PdbUtilities Imports Roslyn.Test.Utilities Imports Roslyn.Test.Utilities.SharedResourceHelpers Imports Roslyn.Utilities @@ -2778,18 +2780,14 @@ End Class") parsedArgs = DefaultParse({"/embed:a.txt", "/debug-", "a.vb"}, _baseDirectory) parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_CannotEmbedWithoutPdb)) - ' These should fail when native PDB support is added. parsedArgs = DefaultParse({"/embed", "/debug:full", "a.vb"}, _baseDirectory) - parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_CannotEmbedWithoutPdb)) - - parsedArgs = DefaultParse({"/embed", "/debug:full", "a.vb"}, _baseDirectory) - parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_CannotEmbedWithoutPdb)) + parsedArgs.Errors.Verify() parsedArgs = DefaultParse({"/embed", "/debug:pdbonly", "a.vb"}, _baseDirectory) - parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_CannotEmbedWithoutPdb)) + parsedArgs.Errors.Verify() parsedArgs = DefaultParse({"/embed", "/debug+", "a.vb"}, _baseDirectory) - parsedArgs.Errors.Verify(Diagnostic(ERRID.ERR_CannotEmbedWithoutPdb)) + parsedArgs.Errors.Verify() End Sub @@ -2801,6 +2799,10 @@ End Class") + + + + Public Sub Embed_EndToEnd(debugSwitch As String, embedSwitch As String, expectedEmbedded As String()) ' embed.vb: large enough To compress, has #line directives Const embed_vb = @@ -2858,13 +2860,26 @@ print Goodbye, World" Assert.Equal("", output.ToString().Trim()) Assert.Equal(0, exitCode) - Dim embedded = (debugSwitch = "/debug:embedded") + Select Case debugSwitch + Case "/debug:embedded" + ValidateEmbeddedSources_Portable(expectedEmbeddedMap, dir, isEmbeddedPdb:=True) + Case "/debug:portable" + ValidateEmbeddedSources_Portable(expectedEmbeddedMap, dir, isEmbeddedPdb:=False) + Case "/debug:full" + ValidateEmbeddedSources_Windows(expectedEmbeddedMap, dir) + End Select + + Assert.Empty(expectedEmbeddedMap) + CleanupAllGeneratedFiles(src.Path) + End Sub + + Private Shared Sub ValidateEmbeddedSources_Portable(expectedEmbeddedMap As Dictionary(Of String, String), dir As TempDirectory, isEmbeddedPdb As Boolean) Using peReader As New PEReader(File.OpenRead(Path.Combine(dir.Path, "embed.exe"))) Dim entry = peReader.ReadDebugDirectory().SingleOrDefault(Function(e) e.Type = DebugDirectoryEntryType.EmbeddedPortablePdb) - Assert.Equal(embedded, entry.DataSize > 0) + Assert.Equal(isEmbeddedPdb, entry.DataSize > 0) Using mdProvider As MetadataReaderProvider = If( - embedded, + isEmbeddedPdb, peReader.ReadEmbeddedPortablePdbDebugDirectoryData(entry), MetadataReaderProvider.FromPortablePdbStream(File.OpenRead(Path.Combine(dir.Path, "embed.pdb")))) @@ -2884,9 +2899,30 @@ print Goodbye, World" Next End Using End Using + End Sub - Assert.Empty(expectedEmbeddedMap) - CleanupAllGeneratedFiles(src.Path) + Private Shared Sub ValidateEmbeddedSources_Windows(expectedEmbeddedMap As Dictionary(Of String, String), dir As TempDirectory) + Dim symReader As ISymUnmanagedReader5 = Nothing + + Try + symReader = SymReaderFactory.CreateReader(File.OpenRead(Path.Combine(dir.Path, "embed.pdb"))) + + For Each doc In symReader.GetDocuments() + Dim docPath = doc.GetName() + + Dim sourceBlob = doc.GetEmbeddedSource() + If sourceBlob.Array Is Nothing Then + Continue For + End If + + Dim sourceStr = Encoding.UTF8.GetString(sourceBlob.Array, sourceBlob.Offset, sourceBlob.Count) + + Assert.Equal(expectedEmbeddedMap(docPath), sourceStr) + Assert.True(expectedEmbeddedMap.Remove(docPath)) + Next + Finally + symReader?.Dispose() + End Try End Sub diff --git a/src/Compilers/VisualBasic/Test/Emit/PDB/PDBEmbeddedSourceTests.vb b/src/Compilers/VisualBasic/Test/Emit/PDB/PDBEmbeddedSourceTests.vb new file mode 100644 index 0000000000000..8a32b30747f36 --- /dev/null +++ b/src/Compilers/VisualBasic/Test/Emit/PDB/PDBEmbeddedSourceTests.vb @@ -0,0 +1,110 @@ +' 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.IO +Imports System.Reflection.Metadata +Imports System.Reflection.PortableExecutable +Imports Microsoft.CodeAnalysis.Emit +Imports Microsoft.CodeAnalysis.Test.Utilities +Imports Roslyn.Test.Utilities + +Namespace Microsoft.CodeAnalysis.VisualBasic.UnitTests.PDB + Public Class PDBEmbeddedSourceTests + Inherits BasicTestBase + + + Public Sub StandalonePdb() + Dim source1 = " +Imports System + +Class C + Public Shared Sub Main() + Console.WriteLine() + End Sub +End Class +" + Dim source2 = " +' no code +" + + Dim tree1 = Parse(source1, "f:/build/goo.vb") + Dim tree2 = Parse(source2, "f:/build/nocode.vb") + Dim c = CreateCompilationWithMscorlib({tree1, tree2}, options:=TestOptions.DebugDll) + Dim embeddedTexts = { + EmbeddedText.FromSource(tree1.FilePath, tree1.GetText()), + EmbeddedText.FromSource(tree2.FilePath, tree2.GetText()) + } + + c.VerifyPdb( + + + + + + + + + + + + + + + + + + +, + embeddedTexts) + End Sub + + + Public Sub EmbeddedPdb() + Const source = " +Imports System + +Class C + Public Shared Sub Main() + Console.WriteLine() + End Sub +End Class +" + Dim tree = Parse(source, "f:/build/goo.cs") + Dim c = CreateCompilationWithMscorlib(tree, options:=TestOptions.DebugDll) + + Dim pdbStream = New MemoryStream() + Dim peBlob = c.EmitToArray( + EmitOptions.Default.WithDebugInformationFormat(DebugInformationFormat.Embedded), + embeddedTexts:={EmbeddedText.FromSource(tree.FilePath, tree.GetText())}) + pdbStream.Position = 0 + + Using peReader As New PEReader(peBlob) + Dim embeddedEntry = peReader.ReadDebugDirectory().Single(Function(e) e.Type = DebugDirectoryEntryType.EmbeddedPortablePdb) + + Using embeddedMetadataProvider As MetadataReaderProvider = peReader.ReadEmbeddedPortablePdbDebugDirectoryData(embeddedEntry) + Dim pdbReader = embeddedMetadataProvider.GetMetadataReader() + + Dim embeddedSource = + (From documentHandle In pdbReader.Documents + Let document = pdbReader.GetDocument(documentHandle) + Select New With + { + .FilePath = pdbReader.GetString(document.Name), + .Text = pdbReader.GetEmbeddedSource(documentHandle) + }).Single() + + Assert.Equal(embeddedSource.FilePath, "f:/build/goo.cs") + Assert.Equal(source, embeddedSource.Text.ToString()) + End Using + End Using + End Sub + End Class +End Namespace diff --git a/src/Compilers/VisualBasic/Test/Emit/PDB/PortablePdbTests.vb b/src/Compilers/VisualBasic/Test/Emit/PDB/PortablePdbTests.vb index 3579cf8798875..56cd6d2055237 100644 --- a/src/Compilers/VisualBasic/Test/Emit/PDB/PortablePdbTests.vb +++ b/src/Compilers/VisualBasic/Test/Emit/PDB/PortablePdbTests.vb @@ -1,13 +1,13 @@ ' 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 Roslyn.Test.Utilities Imports System.IO Imports System.Reflection.Metadata -Imports Microsoft.CodeAnalysis.Emit -Imports Microsoft.CodeAnalysis.Test.Utilities Imports System.Reflection.PortableExecutable Imports System.Text Imports Microsoft.CodeAnalysis.Debugging +Imports Microsoft.CodeAnalysis.Emit +Imports Microsoft.CodeAnalysis.Test.Utilities +Imports Roslyn.Test.Utilities Namespace Microsoft.CodeAnalysis.VisualBasic.UnitTests.PDB Public Class PortablePdbTests @@ -250,84 +250,5 @@ End Class result.Diagnostics.Verify( Diagnostic(ERRID.ERR_PDBWritingFailed).WithArguments("Error!").WithLocation(1, 1)) End Sub - - - Public Sub EmbeddedSource() - Const source = " -Imports System - -Class C - Public Shared Sub Main() - Console.WriteLine() - End Sub -End Class -" - Dim tree = Parse(source, "f:/build/goo.cs") - Dim c = CreateCompilationWithMscorlib(tree, options:=TestOptions.DebugDll) - - Dim pdbStream = New MemoryStream() - c.EmitToArray( - EmitOptions.Default.WithDebugInformationFormat(DebugInformationFormat.PortablePdb), - pdbStream:=pdbStream, - embeddedTexts:={EmbeddedText.FromSource(tree.FilePath, tree.GetText())}) - pdbStream.Position = 0 - - Using provider As MetadataReaderProvider = MetadataReaderProvider.FromPortablePdbStream(pdbStream) - Dim pdbReader = provider.GetMetadataReader() - - Dim embeddedSource = - (From documentHandle In pdbReader.Documents - Let document = pdbReader.GetDocument(documentHandle) - Select New With - { - .FilePath = pdbReader.GetString(document.Name), - .Text = pdbReader.GetEmbeddedSource(documentHandle) - }).Single() - - Assert.Equal(embeddedSource.FilePath, "f:/build/goo.cs") - Assert.Equal(source, embeddedSource.Text.ToString()) - End Using - End Sub - - - Public Sub EmbeddedSource_InEmbeddedPdb() - Const source = " -Imports System - -Class C - Public Shared Sub Main() - Console.WriteLine() - End Sub -End Class -" - Dim tree = Parse(source, "f:/build/goo.cs") - Dim c = CreateCompilationWithMscorlib(tree, options:=TestOptions.DebugDll) - - Dim pdbStream = New MemoryStream() - Dim peBlob = c.EmitToArray( - EmitOptions.Default.WithDebugInformationFormat(DebugInformationFormat.Embedded), - embeddedTexts:={EmbeddedText.FromSource(tree.FilePath, tree.GetText())}) - pdbStream.Position = 0 - - Using peReader As New PEReader(peBlob) - Dim embeddedEntry = peReader.ReadDebugDirectory().Single(Function(e) e.Type = DebugDirectoryEntryType.EmbeddedPortablePdb) - - Using embeddedMetadataProvider As MetadataReaderProvider = peReader.ReadEmbeddedPortablePdbDebugDirectoryData(embeddedEntry) - Dim pdbReader = embeddedMetadataProvider.GetMetadataReader() - - Dim embeddedSource = - (From documentHandle In pdbReader.Documents - Let document = pdbReader.GetDocument(documentHandle) - Select New With - { - .FilePath = pdbReader.GetString(document.Name), - .Text = pdbReader.GetEmbeddedSource(documentHandle) - }).Single() - - Assert.Equal(embeddedSource.FilePath, "f:/build/goo.cs") - Assert.Equal(source, embeddedSource.Text.ToString()) - End Using - End Using - End Sub End Class End Namespace diff --git a/src/Compilers/VisualBasic/Test/Semantic/Compilation/CompilationAPITests.vb b/src/Compilers/VisualBasic/Test/Semantic/Compilation/CompilationAPITests.vb index 634f297731321..872d19825ca63 100644 --- a/src/Compilers/VisualBasic/Test/Semantic/Compilation/CompilationAPITests.vb +++ b/src/Compilers/VisualBasic/Test/Semantic/Compilation/CompilationAPITests.vb @@ -287,8 +287,8 @@ End Namespace Assert.Throws(Of ArgumentException)("embeddedTexts", Sub() comp.Emit( peStream:=New MemoryStream(), - pdbStream:=New MemoryStream(), - options:=EmitOptions.Default.WithDebugInformationFormat(DebugInformationFormat.Pdb), + pdbStream:=Nothing, + options:=Nothing, embeddedTexts:={EmbeddedText.FromStream("_", New MemoryStream())})) Assert.Throws(Of ArgumentException)("embeddedTexts", Sub() comp.Emit( diff --git a/src/EditorFeatures/CSharpTest/AddAccessibilityModifiers/AddAccessibilityModifiersTests.cs b/src/EditorFeatures/CSharpTest/AddAccessibilityModifiers/AddAccessibilityModifiersTests.cs index efc1addb68903..d9143548fce6a 100644 --- a/src/EditorFeatures/CSharpTest/AddAccessibilityModifiers/AddAccessibilityModifiersTests.cs +++ b/src/EditorFeatures/CSharpTest/AddAccessibilityModifiers/AddAccessibilityModifiersTests.cs @@ -100,6 +100,7 @@ private struct NestedStruct { } event Action I.e6 { add { } remote { } } static C() { } + private C() { } public C(int i) { } diff --git a/src/EditorFeatures/CSharpTest/AddBraces/AddBracesFixAllTests.cs b/src/EditorFeatures/CSharpTest/AddBraces/AddBracesFixAllTests.cs index 812696d0e1b4d..729676428c9e6 100644 --- a/src/EditorFeatures/CSharpTest/AddBraces/AddBracesFixAllTests.cs +++ b/src/EditorFeatures/CSharpTest/AddBraces/AddBracesFixAllTests.cs @@ -26,7 +26,13 @@ class Program1 { static void Main() { - if (true) { if (true) { return; } } + if (true) + { + if (true) + { + return; + } + } } } "; @@ -53,7 +59,13 @@ class Program1 { static void Main() { - if (true) { if (true) { return; } } + if (true) + { + if (true) + { + return; + } + } } } "; diff --git a/src/EditorFeatures/CSharpTest/AddUsing/AddUsingTests.cs b/src/EditorFeatures/CSharpTest/AddUsing/AddUsingTests.cs index d58779f479592..cd2009a7d18a2 100644 --- a/src/EditorFeatures/CSharpTest/AddUsing/AddUsingTests.cs +++ b/src/EditorFeatures/CSharpTest/AddUsing/AddUsingTests.cs @@ -38,7 +38,7 @@ internal override (DiagnosticAnalyzer, CodeFixProvider) CreateDiagnosticProvider string initialMarkup, string expectedMarkup, int index = 0, - bool ignoreTrivia = true, + bool ignoreTrivia = false, CodeActionPriority? priority = null, IDictionary options = null) { @@ -1807,7 +1807,9 @@ public async Task BugFix5688() { await TestAsync( @"class Program { static void Main ( string [ ] args ) { [|Console|] . Out . NewLine = ""\r\n\r\n"" ; } } ", -@"using System ; class Program { static void Main ( string [ ] args ) { Console . Out . NewLine = ""\r\n\r\n"" ; } } "); +@"using System; + +class Program { static void Main ( string [ ] args ) { Console . Out . NewLine = ""\r\n\r\n"" ; } } "); } [WorkItem(539853, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/539853")] @@ -1817,7 +1819,9 @@ public async Task BugFix5950() await TestAsync( @"using System.Console; WriteLine([|Expression|].Constant(123));", @"using System.Console; -using System.Linq.Expressions; WriteLine(Expression.Constant(123));", +using System.Linq.Expressions; + +WriteLine(Expression.Constant(123));", parseOptions: GetScriptOptions()); } @@ -2146,7 +2150,7 @@ public async Task TestAttribute() input, @"using System.Runtime.InteropServices; -[assembly: Guid(""9ed54f84-a89d-4fcd-a854-44251e925f09"")]"); +[ assembly : Guid ( ""9ed54f84-a89d-4fcd-a854-44251e925f09"" ) ] "); } [WorkItem(546833, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/546833")] @@ -2420,6 +2424,7 @@ static void Main(string[] args) const string ExpectedDocumentText = @"extern alias P; using P::ProjectLib; + namespace ExternAliases { class Program @@ -2477,7 +2482,8 @@ static void Main(string[] args) "; - const string ExpectedDocumentText = @"extern alias P; + const string ExpectedDocumentText = @" +extern alias P; using P::AnotherNS; using P::ProjectLib; @@ -2531,6 +2537,7 @@ static void Main(string[] args) "; const string ExpectedDocumentText = @"extern alias P; + using P::AnotherNS; namespace ExternAliases { @@ -2646,7 +2653,7 @@ public class D { } public class MyClass { - public static explicit operator N1.D(MyClass f) + public static explicit operator N1.D (MyClass f) { return default(N1.D); } @@ -3058,14 +3065,17 @@ public static class E "; var expectedText = -@"using Extensions; +@" +using Extensions; + public class C { void Main(C a) { C x = a?.B(); } -}"; +} + "; await TestAsync(initialText, expectedText); } @@ -3104,7 +3114,9 @@ public static class D "; var expectedText = -@"using Extensions; +@" +using Extensions; + public class C { public E B { get; private set; } @@ -3117,7 +3129,8 @@ void Main(C a) public class E { } -}"; +} + "; await TestAsync(initialText, expectedText); } @@ -3844,8 +3857,8 @@ static void Main(string[] args) }", @"namespace Microsoft.MyApp { -#if true using Microsoft.Win32.SafeHandles; +#if true using Win32; #else using System; @@ -4102,7 +4115,7 @@ static void Main(string[] args) static void Main(string[] args) { - Func f = () => { List.} + Func f = () => { List. } }"; await TestAsync(initialText, expectedText); } @@ -4125,7 +4138,7 @@ static void Main(string[] args) static void Main(string[] args) { - Func f = () => { List} + Func f = () => { List } }"; await TestAsync(initialText, expectedText); } @@ -4645,6 +4658,7 @@ class C { void M() { + // Note: IVsStatusBar is cased incorrectly. IVsStatusbar b; } } diff --git a/src/EditorFeatures/CSharpTest/AddUsing/AddUsingTests_ExtensionMethods.cs b/src/EditorFeatures/CSharpTest/AddUsing/AddUsingTests_ExtensionMethods.cs index bfc302fdda5d6..8bfdec2abead3 100644 --- a/src/EditorFeatures/CSharpTest/AddUsing/AddUsingTests_ExtensionMethods.cs +++ b/src/EditorFeatures/CSharpTest/AddUsing/AddUsingTests_ExtensionMethods.cs @@ -967,7 +967,9 @@ public static string StringExtension(this string s) "; var expectedText = -@"using Sample.Extensions; +@" +using Sample.Extensions; + namespace Sample { class Program @@ -978,7 +980,8 @@ static void Main(string[] args) var other = myString?.StringExtension().Substring(0); } } -}"; +} + "; await TestInRegularAndScriptAsync(initialText, expectedText); } @@ -1014,14 +1017,17 @@ public static C Extn(this C obj) "; var expectedText = -@"using Sample.Extensions; +@" +using Sample.Extensions; + public class C { public T F(T x) { return F(new C())?.F(new C())?.Extn(); } -}"; +} + "; await TestInRegularAndScriptAsync(initialText, expectedText); } @@ -1057,14 +1063,17 @@ public static C Extn(this C obj) "; var expectedText = -@"using Sample.Extensions; +@" +using Sample.Extensions; + public class C { public T F(T x) { return F(new C())?.F(new C()).Extn()?.F(newC()); } -}"; +} + "; await TestInRegularAndScriptAsync(initialText, expectedText); } diff --git a/src/EditorFeatures/CSharpTest/CodeActions/ConvertIfToSwitch/ConvertIfToSwitchTests.cs b/src/EditorFeatures/CSharpTest/CodeActions/ConvertIfToSwitch/ConvertIfToSwitchTests.cs index eef44f33a3af9..f011df7d65a68 100644 --- a/src/EditorFeatures/CSharpTest/CodeActions/ConvertIfToSwitch/ConvertIfToSwitchTests.cs +++ b/src/EditorFeatures/CSharpTest/CodeActions/ConvertIfToSwitch/ConvertIfToSwitchTests.cs @@ -897,8 +897,10 @@ void M(int i) { switch (i) { - case 1 when i == 2: return; - case 10: return; + case 1 when i == 2: + return; + case 10: + return; } } }"); @@ -925,8 +927,10 @@ void M(int i) { switch (i) { - case 1 when i == 2 && i == 3: return; - case 10: return; + case 1 when i == 2 && i == 3: + return; + case 10: + return; } } }"); @@ -953,8 +957,10 @@ void M(int i) { switch (i) { - case 1 when i == 2 && (i == 3): return; - case 10: return; + case 1 when i == 2 && (i == 3): + return; + case 10: + return; } } }"); @@ -981,8 +987,10 @@ void M(int i) { switch (i) { - case 1 when (i == 2) && i == 3: return; - case 10: return; + case 1 when (i == 2) && i == 3: + return; + case 10: + return; } } }"); @@ -1009,8 +1017,10 @@ void M(int i) { switch (i) { - case 1 when (i == 2) && (i == 3): return; - case 10: return; + case 1 when (i == 2) && (i == 3): + return; + case 10: + return; } } }"); @@ -1037,8 +1047,10 @@ void M(int i) { switch (i) { - case 1 when i == 2 && i == 3: return; - case 10: return; + case 1 when i == 2 && i == 3: + return; + case 10: + return; } } }"); @@ -1065,8 +1077,10 @@ void M(int i) { switch (i) { - case 1 when i == 2 && (i == 3): return; - case 10: return; + case 1 when i == 2 && (i == 3): + return; + case 10: + return; } } }"); @@ -1093,8 +1107,10 @@ void M(int i) { switch (i) { - case 1 when (i == 2) && i == 3: return; - case 10: return; + case 1 when (i == 2) && i == 3: + return; + case 10: + return; } } }"); @@ -1121,8 +1137,10 @@ void M(int i) { switch (i) { - case 1 when (i == 2) && (i == 3): return; - case 10: return; + case 1 when (i == 2) && (i == 3): + return; + case 10: + return; } } }"); @@ -1149,8 +1167,10 @@ void M(int i) { switch (i) { - case 1 when i == 2 && i == 3: return; - case 10: return; + case 1 when i == 2 && i == 3: + return; + case 10: + return; } } }"); @@ -1177,8 +1197,10 @@ void M(int i) { switch (i) { - case 1 when i == 2 && i == 3: return; - case 10: return; + case 1 when i == 2 && i == 3: + return; + case 10: + return; } } }"); @@ -1205,8 +1227,10 @@ void M(int i) { switch (i) { - case 1 when i == 2 && i == 3: return; - case 10: return; + case 1 when i == 2 && i == 3: + return; + case 10: + return; } } }"); @@ -1233,8 +1257,10 @@ void M(int i) { switch (i) { - case 1 when (i == 2) && i == 3: return; - case 10: return; + case 1 when (i == 2) && i == 3: + return; + case 10: + return; } } }"); @@ -1261,8 +1287,10 @@ void M(int i) { switch (i) { - case 1 when (i == 2) && (i == 3): return; - case 10: return; + case 1 when (i == 2) && (i == 3): + return; + case 10: + return; } } }"); @@ -1289,8 +1317,10 @@ void M(int i) { switch (i) { - case 1 when (i == 2) && i == 3: return; - case 10: return; + case 1 when (i == 2) && i == 3: + return; + case 10: + return; } } }"); @@ -1317,8 +1347,10 @@ void M(int i) { switch (i) { - case 1 when i == 2 && (i == 3): return; - case 10: return; + case 1 when i == 2 && (i == 3): + return; + case 10: + return; } } }"); diff --git a/src/EditorFeatures/CSharpTest/CodeActions/EncapsulateField/EncapsulateFieldTests.cs b/src/EditorFeatures/CSharpTest/CodeActions/EncapsulateField/EncapsulateFieldTests.cs index c54257ffa67a2..bc1c79ec3d8ab 100644 --- a/src/EditorFeatures/CSharpTest/CodeActions/EncapsulateField/EncapsulateFieldTests.cs +++ b/src/EditorFeatures/CSharpTest/CodeActions/EncapsulateField/EncapsulateFieldTests.cs @@ -28,7 +28,7 @@ protected override CodeRefactoringProvider CreateCodeRefactoringProvider(Workspa string initialMarkup, string expectedMarkup, ParseOptions parseOptions = null, CompilationOptions compilationOptions = null, - int index = 0, bool ignoreTrivia = true, + int index = 0, bool ignoreTrivia = false, IDictionary options = null) { options = options ?? new Dictionary(); @@ -190,12 +190,7 @@ class goo { private int bar; - public int Bar - { - get => bar; - - set => bar = value; - } + public int Bar { get => bar; set => bar = value; } void baz() { @@ -999,7 +994,7 @@ partial class Program { partial class Program {} partial class Program { - private int x; + private int x; public int X { @@ -1007,6 +1002,7 @@ public int X { return x; } + set { x = value; @@ -1080,7 +1076,8 @@ public int MyInt } } } -}"; +} +"; await TestAllOptionsOffAsync(text, expected); } diff --git a/src/EditorFeatures/CSharpTest/CodeActions/ExtractMethod/ExtractMethodTests.cs b/src/EditorFeatures/CSharpTest/CodeActions/ExtractMethod/ExtractMethodTests.cs index 8f67ffa03ddb8..a0aef27540897 100644 --- a/src/EditorFeatures/CSharpTest/CodeActions/ExtractMethod/ExtractMethodTests.cs +++ b/src/EditorFeatures/CSharpTest/CodeActions/ExtractMethod/ExtractMethodTests.cs @@ -151,8 +151,8 @@ static void Main(string[] args) private static bool NewMethod(bool b) { - return b != - true; + return b != + true; } }", options: Option(CSharpCodeStyleOptions.PreferExpressionBodiedMethods, CSharpCodeStyleOptions.WhenOnSingleLineWithNoneEnforcement)); @@ -304,7 +304,8 @@ class C { static void Main(string[] args) { - del q = x => { + del q = x => + { goto label2; return {|Rename:NewMethod|}(x); }; @@ -1291,6 +1292,7 @@ static void M() int r; int y; {|Rename:NewMethod|}(out r, out y); + System.Console.WriteLine(r + y); } @@ -1331,6 +1333,7 @@ static void M() int r; int y; {|Rename:NewMethod|}(out r, out y); + System.Console.WriteLine(r + y); } diff --git a/src/EditorFeatures/CSharpTest/CodeActions/InlineTemporary/InlineTemporaryTests.cs b/src/EditorFeatures/CSharpTest/CodeActions/InlineTemporary/InlineTemporaryTests.cs index c401a59ef2696..f22dde270d2d8 100644 --- a/src/EditorFeatures/CSharpTest/CodeActions/InlineTemporary/InlineTemporaryTests.cs +++ b/src/EditorFeatures/CSharpTest/CodeActions/InlineTemporary/InlineTemporaryTests.cs @@ -15,7 +15,7 @@ public class InlineTemporaryTests : AbstractCSharpCodeActionTest protected override CodeRefactoringProvider CreateCodeRefactoringProvider(Workspace workspace, TestParameters parameters) => new InlineTemporaryCodeRefactoringProvider(); - private async Task TestFixOneAsync(string initial, string expected, bool ignoreTrivia = true) + private async Task TestFixOneAsync(string initial, string expected, bool ignoreTrivia = false) { await TestInRegularAndScriptAsync(GetTreeText(initial), GetTreeText(expected)); } @@ -117,7 +117,8 @@ public async Task Escaping1() @"{ int [||]x = 0; Console.WriteLine(x); }", - @"{ Console.WriteLine(0); }"); +@"{ + Console.WriteLine(0); }"); } [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInlineTemporary)] @@ -127,7 +128,8 @@ public async Task Escaping2() @"{ int [||]@x = 0; Console.WriteLine(x); }", - @"{ Console.WriteLine(0); }"); +@"{ + Console.WriteLine(0); }"); } [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInlineTemporary)] @@ -137,7 +139,8 @@ public async Task Escaping3() @"{ int [||]@x = 0; Console.WriteLine(@x); }", - @"{ Console.WriteLine(0); }"); +@"{ + Console.WriteLine(0); }"); } [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInlineTemporary)] @@ -147,7 +150,8 @@ public async Task Escaping4() @"{ int [||]x = 0; Console.WriteLine(@x); }", - @"{ Console.WriteLine(0); }"); +@"{ + Console.WriteLine(0); }"); } [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInlineTemporary)] @@ -361,7 +365,8 @@ public async Task NoCastOnVar() @"{ var [||]x = 0; Console.WriteLine(x); }", - @"{ Console.WriteLine(0); }"); +@"{ + Console.WriteLine(0); }"); } [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInlineTemporary)] @@ -646,7 +651,12 @@ public async Task TestArrayInitializer() 5 }; int a = Array.IndexOf(x, 3); }", - @"{ int a = Array.IndexOf(new int[] { 3, 4, 5 }, 3); }"); +@"{ + int a = Array.IndexOf(new int[] { + 3, + 4, + 5 + }, 3); }"); } [WorkItem(545657, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/545657")] @@ -1341,15 +1351,16 @@ public async Task Preprocessor1() int a = x; }", - @"{ +@" +{ int #if true - y, + y, #endif - z; + z; int a = 1; - }", +}", ignoreTrivia: false); } @@ -1366,15 +1377,14 @@ public async Task Preprocessor2() int a = x; }", - @"{ +@" +{ int y, -#if true - #endif - z; + z; int a = 1; - }", +}", ignoreTrivia: false); } @@ -1391,15 +1401,14 @@ public async Task Preprocessor3() int a = x; }", - @"{ +@" +{ int y, #if true - z -#endif - ; + z; int a = 1; - }", +}", ignoreTrivia: false); } @@ -4095,7 +4104,7 @@ class Program { static void Main() { - var(x1, x2) = KVP.Create(42, ""hello""); + var (x1, x2) = KVP.Create(42, ""hello""); } } public static class KVP diff --git a/src/EditorFeatures/CSharpTest/CodeActions/IntroduceVariable/IntroduceVariableTests.cs b/src/EditorFeatures/CSharpTest/CodeActions/IntroduceVariable/IntroduceVariableTests.cs index c80dd0ccc2a39..7687ea71f6039 100644 --- a/src/EditorFeatures/CSharpTest/CodeActions/IntroduceVariable/IntroduceVariableTests.cs +++ b/src/EditorFeatures/CSharpTest/CodeActions/IntroduceVariable/IntroduceVariableTests.cs @@ -2208,7 +2208,8 @@ class Program { static void Main(string[] args) { - Func f = x => { + Func f = x => + { var {|Rename:v|} = x + 1; return v; }; @@ -2237,7 +2238,8 @@ class Program { static void Main(string[] args) { - Func> f = x => { + Func> f = x => + { var {|Rename:v|} = x + 1; return y => v; }; @@ -2266,7 +2268,8 @@ class Program { static void Main(string[] args) { - Func> f = x => y => { + Func> f = x => y => + { var {|Rename:v|} = y + 1; return v; }; @@ -2321,7 +2324,8 @@ class Program { static void Main(string[] args) { - Func> f = x => { + Func> f = x => + { Func {|Rename:p|} = y => x + 1; return p; }; @@ -2349,7 +2353,8 @@ class Program { void M() { - Action goo = x => { + Action goo = x => + { object {|Rename:goo1|} = x.Goo; }; } @@ -4034,8 +4039,7 @@ void Method(MySpan span) } } }", -@" -class Program +@"class Program { class MySpan { public int Start { get; } public int End { get; } } void Method(MySpan span) diff --git a/src/EditorFeatures/CSharpTest/CodeActions/InvertIf/InvertIfTests.cs b/src/EditorFeatures/CSharpTest/CodeActions/InvertIf/InvertIfTests.cs index c324bc207da6a..ff1a01ba329c8 100644 --- a/src/EditorFeatures/CSharpTest/CodeActions/InvertIf/InvertIfTests.cs +++ b/src/EditorFeatures/CSharpTest/CodeActions/InvertIf/InvertIfTests.cs @@ -25,10 +25,10 @@ private string CreateTreeText(string initial) return @"class A { - void Goo() - { + void Goo() + { " + initial + @" - } + } }"; } @@ -37,7 +37,8 @@ public async Task TestIdentifier() { await TestFixOneAsync( @"[||]if (a) { a(); } else { b(); }", -@"if (!a) { b(); } else { a(); }"); +@" if (!a) { b(); } + else { a(); }"); } [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInvertIf)] @@ -45,7 +46,8 @@ public async Task TestNotIdentifier() { await TestFixOneAsync( @"[||]if (!a) { a(); } else { b(); }", -@"if (a) { b(); } else { a(); }"); +@" if (a) { b(); } + else { a(); }"); } [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInvertIf)] @@ -53,7 +55,8 @@ public async Task TestEqualsEquals() { await TestFixOneAsync( @"[||]if (a == b) { a(); } else { b(); }", -@"if (a != b) { b(); } else { a(); }"); +@" if (a != b) { b(); } + else { a(); }"); } [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInvertIf)] @@ -61,7 +64,8 @@ public async Task TestNotEquals() { await TestFixOneAsync( @"[||]if (a != b) { a(); } else { b(); }", -@"if (a == b) { b(); } else { a(); }"); +@" if (a == b) { b(); } + else { a(); }"); } [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInvertIf)] @@ -69,7 +73,8 @@ public async Task TestGreaterThan() { await TestFixOneAsync( @"[||]if (a > b) { a(); } else { b(); }", -@"if (a <= b) { b(); } else { a(); }"); +@" if (a <= b) { b(); } + else { a(); }"); } [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInvertIf)] @@ -77,7 +82,8 @@ public async Task TestGreaterThanEquals() { await TestFixOneAsync( @"[||]if (a >= b) { a(); } else { b(); }", -@"if (a < b) { b(); } else { a(); }"); +@" if (a < b) { b(); } + else { a(); }"); } [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInvertIf)] @@ -85,7 +91,8 @@ public async Task TestLessThan() { await TestFixOneAsync( @"[||]if (a < b) { a(); } else { b(); }", -@"if (a >= b) { b(); } else { a(); }"); +@" if (a >= b) { b(); } + else { a(); }"); } [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInvertIf)] @@ -93,7 +100,8 @@ public async Task TestLessThanEquals() { await TestFixOneAsync( @"[||]if (a <= b) { a(); } else { b(); }", -@"if (a > b) { b(); } else { a(); }"); +@" if (a > b) { b(); } + else { a(); }"); } [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInvertIf)] @@ -101,7 +109,8 @@ public async Task TestParens() { await TestFixOneAsync( @"[||]if ((a)) { a(); } else { b(); }", -@"if (!a) { b(); } else { a(); }"); +@" if (!a) { b(); } + else { a(); }"); } [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInvertIf)] @@ -109,7 +118,8 @@ public async Task TestIs() { await TestFixOneAsync( @"[||]if (a is Goo) { a(); } else { b(); }", -@"if (!(a is Goo)) { b(); } else { a(); }"); +@" if (!(a is Goo)) { b(); } + else { a(); }"); } [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInvertIf)] @@ -117,7 +127,8 @@ public async Task TestCall() { await TestFixOneAsync( @"[||]if (a.Goo()) { a(); } else { b(); }", -@"if (!a.Goo()) { b(); } else { a(); }"); +@" if (!a.Goo()) { b(); } + else { a(); }"); } [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInvertIf)] @@ -125,7 +136,8 @@ public async Task TestOr() { await TestFixOneAsync( @"[||]if (a || b) { a(); } else { b(); }", -@"if (!a && !b) { b(); } else { a(); }"); +@" if (!a && !b) { b(); } + else { a(); }"); } [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInvertIf)] @@ -133,7 +145,8 @@ public async Task TestOr2() { await TestFixOneAsync( @"[||]if (!a || !b) { a(); } else { b(); }", -@"if (a && b) { b(); } else { a(); }"); +@" if (a && b) { b(); } + else { a(); }"); } [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInvertIf)] @@ -141,7 +154,8 @@ public async Task TestAnd() { await TestFixOneAsync( @"[||]if (a && b) { a(); } else { b(); }", -@"if (!a || !b) { b(); } else { a(); }"); +@" if (!a || !b) { b(); } + else { a(); }"); } [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInvertIf)] @@ -149,7 +163,8 @@ public async Task TestAnd2() { await TestFixOneAsync( @"[||]if (!a && !b) { a(); } else { b(); }", -@"if (a || b) { b(); } else { a(); }"); +@" if (a || b) { b(); } + else { a(); }"); } [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInvertIf)] @@ -157,7 +172,8 @@ public async Task TestParenthesizeAndForPrecedence() { await TestFixOneAsync( @"[||]if (a && b || c) { a(); } else { b(); }", -@"if ((!a || !b) && !c) { b(); } else { a(); }"); +@" if ((!a || !b) && !c) { b(); } + else { a(); }"); } [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInvertIf)] @@ -165,7 +181,8 @@ public async Task TestPlus() { await TestFixOneAsync( @"[||]if (a + b) { a(); } else { b(); }", -@"if (!(a + b)) { b(); } else { a(); }"); +@" if (!(a + b)) { b(); } + else { a(); }"); } [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInvertIf)] @@ -173,7 +190,8 @@ public async Task TestTrue() { await TestFixOneAsync( @"[||]if (true) { a(); } else { b(); }", -@"if (false) { b(); } else { a(); }"); +@" if (false) { b(); } + else { a(); }"); } [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInvertIf)] @@ -181,7 +199,8 @@ public async Task TestFalse() { await TestFixOneAsync( @"[||]if (false) { a(); } else { b(); }", -@"if (true) { b(); } else { a(); }"); +@" if (true) { b(); } + else { a(); }"); } [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInvertIf)] @@ -189,7 +208,8 @@ public async Task TestTrueAndFalse() { await TestFixOneAsync( @"[||]if (true && false) { a(); } else { b(); }", -@"if (false || true) { b(); } else { a(); }"); +@" if (false || true) { b(); } + else { a(); }"); } [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInvertIf)] @@ -197,7 +217,8 @@ public async Task TestCurlies1() { await TestFixOneAsync( @"[||]if (a) a(); else b();", -@"if (!a) b(); else a();"); +@" if (!a) b(); + else a();"); } [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInvertIf)] @@ -205,7 +226,8 @@ public async Task TestCurlies2() { await TestFixOneAsync( @"[||]if (a) { a(); } else b();", -@"if (!a) b(); else { a(); }"); +@" if (!a) b(); + else { a(); }"); } [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInvertIf)] @@ -213,7 +235,8 @@ public async Task TestCurlies3() { await TestFixOneAsync( @"[||]if (a) a(); else { b(); }", -@"if (!a) { b(); } else a();"); +@" if (!a) { b(); } + else a();"); } [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInvertIf)] @@ -221,7 +244,11 @@ public async Task TestIfElseIf() { await TestFixOneAsync( @"[||]if (a) { a(); } else if (b) { b(); }", -@"if (!a) { if (b) { b(); } } else { a(); }"); +@" if (!a) + { + if (b) { b(); } + } + else { a(); }"); } [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInvertIf)] @@ -229,7 +256,11 @@ public async Task TestIfElseIf2() { await TestFixOneAsync( @"[||]if (a) { a(); } else if (b) { b(); } else { c(); }", -@"if (!a) { if (b) { b(); } else { c(); } } else { a(); }"); +@" if (!a) + { + if (b) { b(); } else { c(); } + } + else { a(); }"); } [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInvertIf)] @@ -237,7 +268,8 @@ public async Task TestNested() { await TestFixOneAsync( @"[||]if (((a == b) && (c != d)) || ((e < f) && (!g))) { a(); } else { b(); }", -@"if ((a != b || c == d) && (e >= f || g)) { b(); } else { a(); }"); +@" if ((a != b || c == d) && (e >= f || g)) { b(); } + else { a(); }"); } [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInvertIf)] @@ -255,17 +287,17 @@ public async Task TestKeepTriviaWithinExpression() { b(); }", -@"if (!a && - (!b || - c >= // comment - d)) -{ - b(); -} -else -{ - a(); -}"); +@" if (!a && + (!b || + c >= // comment + d)) + { + b(); + } + else + { + a(); + }"); } [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInvertIf)] @@ -489,7 +521,8 @@ public async Task TestSimplifyToLengthEqualsZero() { await TestFixOneAsync( @"string x; [||]if (x.Length > 0) { GreaterThanZero(); } else { EqualsZero(); } } } ", -@"string x; if (x.Length == 0) { EqualsZero(); } else { GreaterThanZero(); } } } "); +@"string x; if (x.Length == 0) { EqualsZero(); } else { GreaterThanZero(); } + } } "); } [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInvertIf)] @@ -497,7 +530,8 @@ public async Task TestSimplifyToLengthEqualsZero2() { await TestFixOneAsync( @"string[] x; [||]if (x.Length > 0) { GreaterThanZero(); } else { EqualsZero(); } } } ", -@"string[] x; if (x.Length == 0) { EqualsZero(); } else { GreaterThanZero(); } } } "); +@"string[] x; if (x.Length == 0) { EqualsZero(); } else { GreaterThanZero(); } + } } "); } [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInvertIf)] @@ -505,7 +539,8 @@ public async Task TestSimplifyToLengthEqualsZero3() { await TestFixOneAsync( @"string x; [||]if (x.Length > 0x0) { a(); } else { b(); } } } ", -@"string x; if (x.Length == 0x0) { b(); } else { a(); } } } "); +@"string x; if (x.Length == 0x0) { b(); } else { a(); } + } } "); } [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInvertIf)] @@ -513,7 +548,8 @@ public async Task TestSimplifyToLengthEqualsZero4() { await TestFixOneAsync( @"string x; [||]if (0 < x.Length) { a(); } else { b(); } } } ", -@"string x; if (0 == x.Length) { b(); } else { a(); } } } "); +@"string x; if (0 == x.Length) { b(); } else { a(); } + } } "); } [WorkItem(545986, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/545986")] @@ -522,7 +558,8 @@ public async Task TestSimplifyToLengthEqualsZero5() { await TestFixOneAsync( @"byte x = 1; [||]if (0 < x) { a(); } else { b(); } } } ", -@"byte x = 1; if (0 == x) { b(); } else { a(); } } } "); +@"byte x = 1; if (0 == x) { b(); } else { a(); } + } } "); } [WorkItem(545986, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/545986")] @@ -531,7 +568,8 @@ public async Task TestSimplifyToLengthEqualsZero6() { await TestFixOneAsync( @"ushort x = 1; [||]if (0 < x) { a(); } else { b(); } } } ", -@"ushort x = 1; if (0 == x) { b(); } else { a(); } } } "); +@"ushort x = 1; if (0 == x) { b(); } else { a(); } + } } "); } [WorkItem(545986, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/545986")] @@ -540,7 +578,8 @@ public async Task TestSimplifyToLengthEqualsZero7() { await TestFixOneAsync( @"uint x = 1; [||]if (0 < x) { a(); } else { b(); } } } ", -@"uint x = 1; if (0 == x) { b(); } else { a(); } } } "); +@"uint x = 1; if (0 == x) { b(); } else { a(); } + } } "); } [WorkItem(545986, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/545986")] @@ -549,7 +588,8 @@ public async Task TestSimplifyToLengthEqualsZero8() { await TestFixOneAsync( @"ulong x = 1; [||]if (0 < x) { a(); } else { b(); } } } ", -@"ulong x = 1; if (0 == x) { b(); } else { a(); } } } "); +@"ulong x = 1; if (0 == x) { b(); } else { a(); } + } } "); } [WorkItem(545986, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/545986")] @@ -558,7 +598,8 @@ public async Task TestSimplifyToLengthEqualsZero9() { await TestFixOneAsync( @"ulong x = 1; [||]if (0 == x) { a(); } else { b(); } } } ", -@"ulong x = 1; if (0 < x) { b(); } else { a(); } } } "); +@"ulong x = 1; if (0 < x) { b(); } else { a(); } + } } "); } [WorkItem(545986, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/545986")] @@ -567,7 +608,8 @@ public async Task TestSimplifyToLengthEqualsZero10() { await TestFixOneAsync( @"ulong x = 1; [||]if (x == 0) { a(); } else { b(); } } } ", -@"ulong x = 1; if (x > 0) { b(); } else { a(); } } } "); +@"ulong x = 1; if (x > 0) { b(); } else { a(); } + } } "); } [WorkItem(530505, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/530505")] @@ -576,7 +618,8 @@ public async Task TestSimplifyToLengthEqualsZero11() { await TestFixOneAsync( @"string[] x; [||]if (x.LongLength > 0) { GreaterThanZero(); } else { EqualsZero(); } } } ", -@"string[] x; if (x.LongLength == 0) { EqualsZero(); } else { GreaterThanZero(); } } } "); +@"string[] x; if (x.LongLength == 0) { EqualsZero(); } else { GreaterThanZero(); } + } } "); } [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInvertIf)] @@ -584,7 +627,8 @@ public async Task TestDoesNotSimplifyToLengthEqualsZero() { await TestFixOneAsync( @"string x; [||]if (x.Length >= 0) { a(); } else { b(); } } } ", -@"string x; if (x.Length < 0) { b(); } else { a(); } } } "); +@"string x; if (x.Length < 0) { b(); } else { a(); } + } } "); } [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsInvertIf)] @@ -592,7 +636,8 @@ public async Task TestDoesNotSimplifyToLengthEqualsZero2() { await TestFixOneAsync( @"string x; [||]if (x.Length > 0.0f) { GreaterThanZero(); } else { EqualsZero(); } } } ", -@"string x; if (x.Length <= 0.0f) { EqualsZero(); } else { GreaterThanZero(); } } } "); +@"string x; if (x.Length <= 0.0f) { EqualsZero(); } else { GreaterThanZero(); } + } } "); } } } diff --git a/src/EditorFeatures/CSharpTest/CodeActions/MoveType/MoveTypeTests.MoveToNewFile.cs b/src/EditorFeatures/CSharpTest/CodeActions/MoveType/MoveTypeTests.MoveToNewFile.cs index 4e1fde19cc3ad..16c9b9b7722fe 100644 --- a/src/EditorFeatures/CSharpTest/CodeActions/MoveType/MoveTypeTests.MoveToNewFile.cs +++ b/src/EditorFeatures/CSharpTest/CodeActions/MoveType/MoveTypeTests.MoveToNewFile.cs @@ -59,7 +59,8 @@ class Class2 { }"; var codeAfterMove = @"class Class2 { }"; var expectedDocumentName = "Class1.cs"; - var destinationDocumentText = @"class Class1 { }"; + var destinationDocumentText = @"class Class1 { } +"; await TestMoveTypeToNewFileAsync(code, codeAfterMove, expectedDocumentName, destinationDocumentText); } @@ -78,10 +79,12 @@ class Class2 { } "; - var codeAfterMove = @"class Class2 { }"; + var codeAfterMove = @"class Class2 { } + "; var expectedDocumentName = "Class1.cs"; - var destinationDocumentText = @"class Class1 { }"; + var destinationDocumentText = @"class Class1 { } + "; await TestMoveTypeToNewFileAsync( code, codeAfterMove, expectedDocumentName, @@ -107,7 +110,8 @@ class Class2 { }"; var codeAfterMove = @"class Class2 { }"; var expectedDocumentName = "Class1.cs"; - var destinationDocumentText = @"class Class1 { }"; + var destinationDocumentText = @"class Class1 { } +"; await TestMoveTypeToNewFileAsync(code, codeAfterMove, expectedDocumentName, destinationDocumentText); } @@ -121,7 +125,8 @@ class Class2 { }"; var codeAfterMove = @"class Class2 { }"; var expectedDocumentName = "Class1.cs"; - var destinationDocumentText = @"class Class1 { }"; + var destinationDocumentText = @"class Class1 { } +"; await TestMoveTypeToNewFileAsync(code, codeAfterMove, expectedDocumentName, destinationDocumentText); } @@ -139,12 +144,13 @@ class Class2 { }"; var codeAfterMove = @"// Banner Text using System; - class Class2 { }"; var expectedDocumentName = "Class1.cs"; var destinationDocumentText = -@"class Class1 { }"; +@"// Banner Text +class Class1 { } +"; await TestMoveTypeToNewFileAsync(code, codeAfterMove, expectedDocumentName, destinationDocumentText); } @@ -167,12 +173,11 @@ class Class2 { }"; var codeAfterMove = @"// Banner Text - class Class2 { }"; var expectedDocumentName = "Class1.cs"; var destinationDocumentText = -@" +@"// Banner Text using System; class Class1 { @@ -180,7 +185,8 @@ void Print(int x) { Console.WriteLine(x); } -}"; +} +"; await TestMoveTypeToNewFileAsync(code, codeAfterMove, expectedDocumentName, destinationDocumentText); } @@ -222,7 +228,7 @@ void Print(int x) var expectedDocumentName = "Class1.cs"; var destinationDocumentText = -@" +@"// Banner Text using System; class Class1 { @@ -230,7 +236,8 @@ void Print(int x) { Console.WriteLine(x); } -}"; +} +"; await TestMoveTypeToNewFileAsync(code, codeAfterMove, expectedDocumentName, destinationDocumentText); } @@ -244,7 +251,8 @@ class Class2 { }"; var codeAfterMove = @"class Class2 { }"; var expectedDocumentName = "IMoveType.cs"; - var destinationDocumentText = @"interface IMoveType { }"; + var destinationDocumentText = @"interface IMoveType { } +"; await TestMoveTypeToNewFileAsync(code, codeAfterMove, expectedDocumentName, destinationDocumentText); } @@ -258,7 +266,8 @@ class Class2 { }"; var codeAfterMove = @"class Class2 { }"; var expectedDocumentName = "MyStruct.cs"; - var destinationDocumentText = @"struct MyStruct { }"; + var destinationDocumentText = @"struct MyStruct { } +"; await TestMoveTypeToNewFileAsync(code, codeAfterMove, expectedDocumentName, destinationDocumentText); } @@ -272,7 +281,8 @@ class Class2 { }"; var codeAfterMove = @"class Class2 { }"; var expectedDocumentName = "MyEnum.cs"; - var destinationDocumentText = @"enum MyEnum { }"; + var destinationDocumentText = @"enum MyEnum { } +"; await TestMoveTypeToNewFileAsync(code, codeAfterMove, expectedDocumentName, destinationDocumentText); } @@ -290,7 +300,7 @@ class Class2 { } var codeAfterMove = @"namespace N1 { - class Class2 { } + class Class2 { } }"; var expectedDocumentName = "Class1.cs"; @@ -319,10 +329,10 @@ class Class1 var codeAfterMove = @"namespace N1 { - partial class Class1 + partial class Class1 { - } + }"; var expectedDocumentName = "Class2.cs"; @@ -332,10 +342,9 @@ partial class Class1 { partial class Class1 { - class Class2 - { - } + class Class2 { } } + }"; await TestMoveTypeToNewFileAsync(code, codeAfterMove, expectedDocumentName, destinationDocumentText); } @@ -356,10 +365,10 @@ abstract class Class1 var codeAfterMove = @"namespace N1 { - abstract partial class Class1 + abstract partial class Class1 { - } + }"; var expectedDocumentName = "Class2.cs"; @@ -369,10 +378,9 @@ abstract partial class Class1 { abstract partial class Class1 { - class Class2 - { - } + class Class2 { } } + }"; await TestMoveTypeToNewFileAsync(code, codeAfterMove, expectedDocumentName, destinationDocumentText); } @@ -397,10 +405,10 @@ class Class1 @"namespace N1 { [Outer] - partial class Class1 + partial class Class1 { - } + }"; var expectedDocumentName = "Class2.cs"; @@ -411,10 +419,9 @@ partial class Class1 partial class Class1 { [Inner] - class Class2 - { - } + class Class2 { } } + }"; await TestMoveTypeToNewFileAsync(code, codeAfterMove, expectedDocumentName, destinationDocumentText); } @@ -479,10 +486,10 @@ class Class1 var codeAfterMove = @"namespace N1 { - partial class Class1 + partial class Class1 { - } + }"; var expectedDocumentName = "Class1.Class2.cs"; @@ -492,10 +499,9 @@ partial class Class1 { partial class Class1 { - class Class2 - { - } + class Class2 { } } + }"; await TestMoveTypeToNewFileAsync(code, codeAfterMove, expectedDocumentName, destinationDocumentText, index: 1); } @@ -520,12 +526,13 @@ class Class1 var codeAfterMove = @"namespace N1 { - partial class Class1 + partial class Class1 { private int _field1; public void Method1() { } } + }"; var expectedDocumentName = "Class2.cs"; @@ -535,10 +542,9 @@ partial class Class1 { partial class Class1 { - class Class2 - { - } + class Class2 { } } + }"; await TestMoveTypeToNewFileAsync(code, codeAfterMove, expectedDocumentName, destinationDocumentText); } @@ -567,14 +573,14 @@ internal class Class3 var codeAfterMove = @"namespace N1 { - partial class Class1 + partial class Class1 { private int _field1; public void Method1() { } } - internal class Class3 + internal class Class3 { private void Method1() { } } @@ -587,9 +593,7 @@ internal class Class3 { partial class Class1 { - class Class2 - { - } + class Class2 { } } }"; await TestMoveTypeToNewFileAsync(code, codeAfterMove, expectedDocumentName, destinationDocumentText); @@ -618,7 +622,7 @@ class Class1 var codeAfterMove = @"namespace N1 { - partial class Class1 + partial class Class1 { private int _field1; @@ -633,7 +637,7 @@ partial class Class1 { partial class Class1 { - class Class2 + class Class2 { private string _field1; public void InnerMethod() { } @@ -711,6 +715,7 @@ namespace InnerN3.N3 { partial class OuterClass2 { + class InnerClass4 { } @@ -731,14 +736,15 @@ class InnerClass6 { } } } -}"; +} +"; var expectedDocumentName = "InnerClass2.cs"; var destinationDocumentText = -@" -namespace OuterN1.N1 +@"namespace OuterN1.N1 { + namespace InnerN3.N3 { partial class OuterClass2 @@ -751,7 +757,8 @@ class InnerClass3 } } } -}"; +} +"; await TestMoveTypeToNewFileAsync(code, codeAfterMove, expectedDocumentName, destinationDocumentText); } @@ -772,10 +779,12 @@ class Outer { } }"; var codeAfterMove = @" +// Only used by inner type. + // Unused by both types. using System.Collections; -partial class Outer { +partial class Outer { }"; var expectedDocumentName = "Inner.cs"; @@ -784,8 +793,10 @@ partial class Outer { // Only used by inner type. using System; +// Unused by both types. + partial class Outer { - class Inner { + class Inner { DateTime d; } }"; @@ -935,7 +946,8 @@ partial class Outer : IComparable { var expectedDocumentName = "Inner.cs"; var destinationDocumentText = @" -partial class Outer { +partial class Outer +{ class Inner : IWhatever { DateTime d; } diff --git a/src/EditorFeatures/CSharpTest/CodeActions/MoveType/MoveTypeTests.RenameType.cs b/src/EditorFeatures/CSharpTest/CodeActions/MoveType/MoveTypeTests.RenameType.cs index c3f416d375588..f6174633cecb2 100644 --- a/src/EditorFeatures/CSharpTest/CodeActions/MoveType/MoveTypeTests.RenameType.cs +++ b/src/EditorFeatures/CSharpTest/CodeActions/MoveType/MoveTypeTests.RenameType.cs @@ -30,7 +30,7 @@ class Inner { } }"; var codeWithTypeRenamedToMatchFileName = -@"class [|test1|] +@"class [|test1|] { class Inner { } }"; diff --git a/src/EditorFeatures/CSharpTest/CodeActions/ReplaceMethodWithProperty/ReplaceMethodWithPropertyTests.cs b/src/EditorFeatures/CSharpTest/CodeActions/ReplaceMethodWithProperty/ReplaceMethodWithPropertyTests.cs index aeb7de130cd55..44757ff982571 100644 --- a/src/EditorFeatures/CSharpTest/CodeActions/ReplaceMethodWithProperty/ReplaceMethodWithPropertyTests.cs +++ b/src/EditorFeatures/CSharpTest/CodeActions/ReplaceMethodWithProperty/ReplaceMethodWithPropertyTests.cs @@ -70,7 +70,13 @@ public async Task TestMethodWithArrowBody() }", @"class C { - int Goo { get { return 0; } } + int Goo + { + get + { + return 0; + } + } }"); } @@ -190,8 +196,9 @@ int Goo ignoreTrivia: false); } + [WorkItem(21460, "https://github.com/dotnet/roslyn/issues/21460")] [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsReplaceMethodWithProperty)] - public async Task TestIfDefMethod() + public async Task TestIfDefMethod1() { await TestWithAllCodeStyleOff( @"class C @@ -215,6 +222,144 @@ int Goo }"); } + [WorkItem(21460, "https://github.com/dotnet/roslyn/issues/21460")] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsReplaceMethodWithProperty)] + public async Task TestIfDefMethod2() + { + await TestWithAllCodeStyleOff( +@"class C +{ +#if true + int [||]GetGoo() + { + } + + void SetGoo(int val) + { + } +#endif +}", +@"class C +{ +#if true + int Goo + { + get + { + } + } + + void SetGoo(int val) + { + } +#endif +}"); + } + + [WorkItem(21460, "https://github.com/dotnet/roslyn/issues/21460")] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsReplaceMethodWithProperty)] + public async Task TestIfDefMethod3() + { + await TestWithAllCodeStyleOff( +@"class C +{ +#if true + int [||]GetGoo() + { + } + + void SetGoo(int val) + { + } +#endif +}", +@"class C +{ +#if true + int Goo + { + get + { + } + + set + { + } + } +#endif +}", index: 1); + } + + [WorkItem(21460, "https://github.com/dotnet/roslyn/issues/21460")] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsReplaceMethodWithProperty)] + public async Task TestIfDefMethod4() + { + await TestWithAllCodeStyleOff( +@"class C +{ +#if true + void SetGoo(int val) + { + } + + int [||]GetGoo() + { + } +#endif +}", +@"class C +{ +#if true + void SetGoo(int val) + { + } + + int Goo + { + get + { + } + } +#endif +}"); + } + + [WorkItem(21460, "https://github.com/dotnet/roslyn/issues/21460")] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsReplaceMethodWithProperty)] + public async Task TestIfDefMethod5() + { + await TestWithAllCodeStyleOff( +@"class C +{ +#if true + void SetGoo(int val) + { + } + + int [||]GetGoo() + { + } +#endif +}", +@"class C +{ + +#if true + + int Goo + { + get + { + } + + set + { + } + } +#endif +}", index: 1); + } + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsReplaceMethodWithProperty)] public async Task TestMethodWithTrivia_2() { @@ -1488,10 +1633,7 @@ public async Task TestCodeStyle1() }", @"class C { - int Goo - { - get => 1; - } + int Goo { get => 1; } }", options: PreferExpressionBodiedAccessors); } @@ -1550,11 +1692,7 @@ void SetGoo(int i) }", @"class C { - int Goo - { - get => 1; - set => _i = value; - } + int Goo { get => 1; set => _i = value; } }", index: 1, options: PreferExpressionBodiedAccessors); @@ -1581,8 +1719,15 @@ void SetGoo(int i) { int Goo { - get { return 1; } - set { _i = value; } + get + { + return 1; + } + + set + { + _i = value; + } } }", index: 1, @@ -1608,11 +1753,7 @@ void SetGoo(int i) }", @"class C { - int Goo - { - get => 1; - set => _i = value; - } + int Goo { get => 1; set => _i = value; } }", index: 1, options: PreferExpressionBodiedAccessorsAndProperties); @@ -1707,8 +1848,8 @@ int Goo { get { - throw e + - e; + throw e + + e; } } }", options: OptionsSet( @@ -1787,7 +1928,7 @@ public async Task TestMetadataOverride() private async Task TestWithAllCodeStyleOff( string initialMarkup, string expectedMarkup, ParseOptions parseOptions = null, int index = 0, - bool ignoreTrivia = true) + bool ignoreTrivia = false) { await TestAsync( initialMarkup, expectedMarkup, parseOptions, diff --git a/src/EditorFeatures/CSharpTest/CodeActions/ReplacePropertyWithMethods/ReplacePropertyWithMethodsTests.cs b/src/EditorFeatures/CSharpTest/CodeActions/ReplacePropertyWithMethods/ReplacePropertyWithMethodsTests.cs index faf5eeb29997d..86cb4f05beb92 100644 --- a/src/EditorFeatures/CSharpTest/CodeActions/ReplacePropertyWithMethods/ReplacePropertyWithMethodsTests.cs +++ b/src/EditorFeatures/CSharpTest/CodeActions/ReplacePropertyWithMethods/ReplacePropertyWithMethodsTests.cs @@ -324,7 +324,6 @@ private int GetProp() { return 0; } - private void SetProp(int value) { var v = value; @@ -357,7 +356,6 @@ public int GetProp() { return 0; } - private void SetProp(int value) { var v = value; @@ -395,7 +393,6 @@ private int GetProp() { return 0; } - private void SetProp(int value) { var v = value; @@ -438,7 +435,6 @@ private int GetProp() { return 0; } - private void SetProp(int value) { var v = value; @@ -527,7 +523,6 @@ private int GetProp() { return 0; } - private void SetProp(int value) { var v = value; @@ -570,7 +565,6 @@ private int GetProp() { return 0; } - private void SetProp(int value) { var v = value; diff --git a/src/EditorFeatures/CSharpTest/CodeActions/UseNamedArguments/UseNamedArgumentsTests.cs b/src/EditorFeatures/CSharpTest/CodeActions/UseNamedArguments/UseNamedArgumentsTests.cs index 7280c85489ca4..68e74ac4e1c5e 100644 --- a/src/EditorFeatures/CSharpTest/CodeActions/UseNamedArguments/UseNamedArgumentsTests.cs +++ b/src/EditorFeatures/CSharpTest/CodeActions/UseNamedArguments/UseNamedArgumentsTests.cs @@ -212,7 +212,7 @@ void M(int arg1, int arg2) }", @"class C { - void M(int arg1, int arg2) + void M(int arg1, int arg2) => M(arg1: 1 + 2, arg2: 2); }"); } @@ -229,7 +229,7 @@ void M(int arg1, int arg2) }", @"class C { - void M(int arg1, int arg2) + void M(int arg1, int arg2) => M(arg1: 1 + 2, arg2: 2); }"); } @@ -293,7 +293,7 @@ void M(Action arg1, int arg2) class C { void M(Action arg1, int arg2) - => M(arg1: () => { }, arg2: 2); + => M(arg1: () => { }, arg2: 2); }"); } diff --git a/src/EditorFeatures/CSharpTest/Diagnostics/Async/AddAwaitTests.cs b/src/EditorFeatures/CSharpTest/Diagnostics/Async/AddAwaitTests.cs index 2f61b19cfd102..4e15beb4028bf 100644 --- a/src/EditorFeatures/CSharpTest/Diagnostics/Async/AddAwaitTests.cs +++ b/src/EditorFeatures/CSharpTest/Diagnostics/Async/AddAwaitTests.cs @@ -897,7 +897,7 @@ class Program { async Task A() { - return await (null ?? Task.FromResult(1)) } + return await (null ?? Task.FromResult(1))} }"); } @@ -921,7 +921,7 @@ class Program { async Task A() { - return await (null as Task) } + return await (null as Task)} }"); } diff --git a/src/EditorFeatures/CSharpTest/Diagnostics/Async/ChangeToAsyncTests.cs b/src/EditorFeatures/CSharpTest/Diagnostics/Async/ChangeToAsyncTests.cs index f3d0ecba9561f..d36e9cd9b1c88 100644 --- a/src/EditorFeatures/CSharpTest/Diagnostics/Async/ChangeToAsyncTests.cs +++ b/src/EditorFeatures/CSharpTest/Diagnostics/Async/ChangeToAsyncTests.cs @@ -39,7 +39,9 @@ async Task rtrt() await gt(); } - async Task gt() + async + Task +gt() { } }"; diff --git a/src/EditorFeatures/CSharpTest/Diagnostics/GenerateMethod/GenerateMethodTests.cs b/src/EditorFeatures/CSharpTest/Diagnostics/GenerateMethod/GenerateMethodTests.cs index 5ece58362317d..a630938a29c8f 100644 --- a/src/EditorFeatures/CSharpTest/Diagnostics/GenerateMethod/GenerateMethodTests.cs +++ b/src/EditorFeatures/CSharpTest/Diagnostics/GenerateMethod/GenerateMethodTests.cs @@ -7364,7 +7364,8 @@ public void Goo() ref int i = ref [|Bar|](); } }", -@"using System; +@" +using System; class C { diff --git a/src/EditorFeatures/CSharpTest/Diagnostics/GenerateType/GenerateTypeTests.cs b/src/EditorFeatures/CSharpTest/Diagnostics/GenerateType/GenerateTypeTests.cs index aa579a6ac8ddc..3f4de72d8e895 100644 --- a/src/EditorFeatures/CSharpTest/Diagnostics/GenerateType/GenerateTypeTests.cs +++ b/src/EditorFeatures/CSharpTest/Diagnostics/GenerateType/GenerateTypeTests.cs @@ -212,7 +212,9 @@ public async Task TestGenerateClassFromFieldDeclarationIntoGlobalNamespace() { await TestAddDocumentInRegularAndScriptAsync( @"class Program { void Main ( ) { [|Goo|] f ; } } ", -@"internal class Goo { } ", +@"internal class Goo +{ +}", expectedContainers: ImmutableArray.Empty, expectedDocumentName: "Goo.cs"); } @@ -222,7 +224,12 @@ public async Task TestGenerateClassFromFieldDeclarationIntoCustomNamespace() { await TestAddDocumentInRegularAndScriptAsync( @"class Class { [|TestNamespace|].Goo f; }", -@"namespace TestNamespace { internal class Goo { } }", +@"namespace TestNamespace +{ + internal class Goo + { + } +}", expectedContainers: ImmutableArray.Create("TestNamespace"), expectedDocumentName: "Goo.cs"); } @@ -916,7 +923,12 @@ public async Task TestGenerateClassFromIntoNewNamespace() { await TestAddDocumentInRegularAndScriptAsync( @"class Class { static void Main(string[] args) { [|N|].C c; } }", -@"namespace N { internal class C { } }", +@"namespace N +{ + internal class C + { + } +}", expectedContainers: ImmutableArray.Create("N"), expectedDocumentName: "C.cs"); } @@ -2904,7 +2916,15 @@ public async Task TestGenerateIntoNewFile() { await TestAddDocumentInRegularAndScriptAsync( @"class Class { void F() { new [|Goo|].Bar(); } }", -@"namespace Goo { internal class Bar { public Bar() { } } }", +@"namespace Goo +{ + internal class Bar + { + public Bar() + { + } + } +}", expectedContainers: ImmutableArray.Create("Goo"), expectedDocumentName: "Bar.cs"); } @@ -4178,7 +4198,9 @@ public async Task TestAddDocumentForGlobalNamespace() { await TestAddDocumentInRegularAndScriptAsync( @"class C : [|Goo|]", -"internal class Goo { }", +@"internal class Goo +{ +}", ImmutableArray.Empty, "Goo.cs"); } @@ -4230,7 +4252,8 @@ public async Task CompareIncompleteMembersToEqual() x, x)private class x { } -}", +} +", index: 2); } diff --git a/src/EditorFeatures/CSharpTest/Diagnostics/InvokeDelegateWithConditionalAccess/InvokeDelegateWithConditionalAccessTests.cs b/src/EditorFeatures/CSharpTest/Diagnostics/InvokeDelegateWithConditionalAccess/InvokeDelegateWithConditionalAccessTests.cs index 3933580cddf45..ec60f1d9cabaf 100644 --- a/src/EditorFeatures/CSharpTest/Diagnostics/InvokeDelegateWithConditionalAccess/InvokeDelegateWithConditionalAccessTests.cs +++ b/src/EditorFeatures/CSharpTest/Diagnostics/InvokeDelegateWithConditionalAccess/InvokeDelegateWithConditionalAccessTests.cs @@ -334,6 +334,7 @@ void Goo() { var v = a; v?.Invoke(); + v = null; } }"); @@ -471,8 +472,7 @@ void M() if (true != true) { } - else - this.E?.Invoke(this, EventArgs.Empty); + else this.E?.Invoke(this, EventArgs.Empty); } }"); } diff --git a/src/EditorFeatures/CSharpTest/Diagnostics/InvokeDelegateWithConditionalAccess/InvokeDelegateWithConditionalAccessTests_FixAllTests.cs b/src/EditorFeatures/CSharpTest/Diagnostics/InvokeDelegateWithConditionalAccess/InvokeDelegateWithConditionalAccessTests_FixAllTests.cs index ac6bfbf3e143d..53545205ae798 100644 --- a/src/EditorFeatures/CSharpTest/Diagnostics/InvokeDelegateWithConditionalAccess/InvokeDelegateWithConditionalAccessTests_FixAllTests.cs +++ b/src/EditorFeatures/CSharpTest/Diagnostics/InvokeDelegateWithConditionalAccess/InvokeDelegateWithConditionalAccessTests_FixAllTests.cs @@ -43,6 +43,7 @@ void Goo() void Goo() { a?.Invoke(); + a?.Invoke(); } }"); @@ -78,6 +79,7 @@ void Goo() void Goo() { a?.Invoke(); + a?.Invoke(); } }"); @@ -113,6 +115,7 @@ void Goo() void Goo() { a?.Invoke(); + a?.Invoke(); } }"); @@ -148,6 +151,7 @@ void Goo() void Goo() { a?.Invoke(); + a?.Invoke(); } }"); @@ -183,6 +187,7 @@ void Goo() void Goo() { a?.Invoke(); + a?.Invoke(); } }"); @@ -218,6 +223,7 @@ void Goo() void Goo() { a?.Invoke(); + a?.Invoke(); } }"); diff --git a/src/EditorFeatures/CSharpTest/Diagnostics/MakeMethodSynchronous/MakeMethodSynchronousTests.cs b/src/EditorFeatures/CSharpTest/Diagnostics/MakeMethodSynchronous/MakeMethodSynchronousTests.cs index f9c2356bab14c..2b2a9ee502e7a 100644 --- a/src/EditorFeatures/CSharpTest/Diagnostics/MakeMethodSynchronous/MakeMethodSynchronousTests.cs +++ b/src/EditorFeatures/CSharpTest/Diagnostics/MakeMethodSynchronous/MakeMethodSynchronousTests.cs @@ -610,7 +610,8 @@ class C public void M1() {{ // Leading trivia - /*1*/ {expectedReturn} /*2*/ M2/*3*/() /*4*/ + /*1*/ + {expectedReturn} /*2*/ M2/*3*/() /*4*/ {{ throw new NotImplementedException(); }} @@ -619,14 +620,14 @@ public void M1() } [Theory] - [InlineData("", "Task", "C")] - [InlineData("", "Task", "int")] - [InlineData("", "Task", "void")] - [InlineData("", "void", "void")] - [InlineData("public", "Task", "C")] - [InlineData("public", "Task", "int")] - [InlineData("public", "Task", "void")] - [InlineData("public", "void", "void")] + [InlineData("", "Task", "\r\n C")] + [InlineData("", "Task", "\r\n int")] + [InlineData("", "Task", "\r\n void")] + [InlineData("", "void", "\r\n void")] + [InlineData("public", "Task", " C")] + [InlineData("public", "Task", " int")] + [InlineData("public", "Task", " void")] + [InlineData("public", "void", " void")] [Trait(Traits.Feature, Traits.Features.CodeActionsMakeMethodAsynchronous)] [WorkItem(18307, "https://github.com/dotnet/roslyn/issues/18307")] public async Task RemoveAsyncKeepsTrivia(string modifiers, string asyncReturn, string expectedReturn) @@ -649,7 +650,7 @@ class C class C {{ // Leading trivia - {modifiers}/*1*/ {expectedReturn} /*2*/ M2/*3*/() /*4*/ + {modifiers}/*1*/{expectedReturn} /*2*/ M2/*3*/() /*4*/ {{ throw new NotImplementedException(); }} diff --git a/src/EditorFeatures/CSharpTest/Diagnostics/RemoveUnnecessaryCast/RemoveUnnecessaryCastTests.cs b/src/EditorFeatures/CSharpTest/Diagnostics/RemoveUnnecessaryCast/RemoveUnnecessaryCastTests.cs index 8540ade7ab02a..b848884180783 100644 --- a/src/EditorFeatures/CSharpTest/Diagnostics/RemoveUnnecessaryCast/RemoveUnnecessaryCastTests.cs +++ b/src/EditorFeatures/CSharpTest/Diagnostics/RemoveUnnecessaryCast/RemoveUnnecessaryCastTests.cs @@ -4050,7 +4050,7 @@ class T void Goo() { Sign mySign = Sign.Positive; - Sign invertedSign = (Sign) ( ~mySign ); + Sign invertedSign = (Sign) ( ~mySign); } }"); } diff --git a/src/EditorFeatures/CSharpTest/Diagnostics/SimplifyTypeNames/SimplifyTypeNamesTests.cs b/src/EditorFeatures/CSharpTest/Diagnostics/SimplifyTypeNames/SimplifyTypeNamesTests.cs index 6fd733a5f5aad..5383087bc89e2 100644 --- a/src/EditorFeatures/CSharpTest/Diagnostics/SimplifyTypeNames/SimplifyTypeNamesTests.cs +++ b/src/EditorFeatures/CSharpTest/Diagnostics/SimplifyTypeNames/SimplifyTypeNamesTests.cs @@ -2,7 +2,6 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Threading.Tasks; using Microsoft.CodeAnalysis.CodeFixes; using Microsoft.CodeAnalysis.CodeStyle; @@ -10,9 +9,7 @@ using Microsoft.CodeAnalysis.CSharp.CodeFixes.SimplifyTypeNames; using Microsoft.CodeAnalysis.CSharp.Diagnostics.SimplifyTypeNames; using Microsoft.CodeAnalysis.Diagnostics; -using Microsoft.CodeAnalysis.Editor.UnitTests.Extensions; using Microsoft.CodeAnalysis.Options; -using Microsoft.CodeAnalysis.Text; using Roslyn.Test.Utilities; using Xunit; @@ -346,6 +343,114 @@ class A }"); } + [WorkItem(21449, "https://github.com/dotnet/roslyn/issues/21449")] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsSimplifyTypeNames)] + public async Task DoNotChangeToAliasInNameOfIfItChangesNameOfName() + { + await TestInRegularAndScript1Async( +@"using System; +using Foo = SimplifyInsideNameof.Program; + +namespace SimplifyInsideNameof +{ + class Program + { + static void Main(string[] args) + { + Console.WriteLine(nameof([|SimplifyInsideNameof.Program|])); + } + } +}", +@"using System; +using Foo = SimplifyInsideNameof.Program; + +namespace SimplifyInsideNameof +{ + class Program + { + static void Main(string[] args) + { + Console.WriteLine(nameof(Program)); + } + } +}"); + } + + [WorkItem(21449, "https://github.com/dotnet/roslyn/issues/21449")] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsSimplifyTypeNames)] + public async Task DoChangeToAliasInNameOfIfItDoesNotAffectName1() + { + await TestInRegularAndScriptAsync( +@"using System; +using Goo = SimplifyInsideNameof.Program; + +namespace SimplifyInsideNameof +{ + class Program + { + static void Main(string[] args) + { + Console.WriteLine(nameof([|SimplifyInsideNameof.Program|].Main)); + } + } +}", + +@"using System; +using Goo = SimplifyInsideNameof.Program; + +namespace SimplifyInsideNameof +{ + class Program + { + static void Main(string[] args) + { + Console.WriteLine(nameof(Goo.Main)); + } + } +}"); + } + + [WorkItem(21449, "https://github.com/dotnet/roslyn/issues/21449")] + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsSimplifyTypeNames)] + public async Task DoChangeToAliasInNameOfIfItDoesNotAffectName2() + { + await TestInRegularAndScriptAsync( +@"using System; +using Goo = N.Goo; + +namespace N { + class Goo { } +} + +namespace SimplifyInsideNameof +{ + class Program + { + static void Main(string[] args) + { + Console.WriteLine(nameof([|N.Goo|])); + } + } +}", +@"using System; +using Goo = N.Goo; + +namespace N { + class Goo { } +} + +namespace SimplifyInsideNameof +{ + class Program + { + static void Main(string[] args) + { + Console.WriteLine(nameof(Goo)); + } + } +}"); + } + [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsSimplifyTypeNames)] public async Task TwoAliases() { @@ -513,7 +618,7 @@ public async Task Keywords() var content = @"class A { - [|[||]|] i; + [|[||]|] i; } "; @@ -746,9 +851,7 @@ namespace N2 { public class A2 { - public class A1 - { - } + public class A1 { } A1 a; } @@ -2380,7 +2483,7 @@ class A @"using System; using System.Collections.Generic; /// -/// +/// /// class A { @@ -2493,7 +2596,7 @@ static void Main() { static void Main() { - Program a = null; + Program a = null; } }", parseOptions: null); @@ -2548,7 +2651,7 @@ public static void Main() await TestInRegularAndScriptAsync(source, @"class Preserve { - public static int Y; + public static int Y; } class Z : Preserve @@ -2557,10 +2660,10 @@ class Z : Preserve static class M { - public static void Main() - { - int k = Preserve.Y; - } + public static void Main() + { + int k = Preserve.Y; + } }"); } @@ -2591,10 +2694,10 @@ public static void Main() await TestInRegularAndScriptAsync(source, @"class Preserve { - public class X - { - public static int Y; - } + public class X + { + public static int Y; + } } class Z : Preserve @@ -2603,10 +2706,10 @@ class Z : Preserve class M { - public static void Main() - { - int k = Preserve.X.Y; - } + public static void Main() + { + int k = Preserve.X.Y; + } }"); } diff --git a/src/EditorFeatures/CSharpTest/Diagnostics/Suppression/SuppressionTests.cs b/src/EditorFeatures/CSharpTest/Diagnostics/Suppression/SuppressionTests.cs index fcb7f5697a28b..ddd3273427a2f 100644 --- a/src/EditorFeatures/CSharpTest/Diagnostics/Suppression/SuppressionTests.cs +++ b/src/EditorFeatures/CSharpTest/Diagnostics/Suppression/SuppressionTests.cs @@ -378,13 +378,13 @@ class C2 { } /// class C3 { } // comment // comment // comment", - @"class C1 { } -class C2 { } -#pragma warning disable CS1574 -/// -class C3 { } // comment -#pragma warning enable CS1574 -// comment +$@"class C1 {{ }} +#pragma warning disable CS1574 // {CSharpResources.WRN_BadXMLRef_Title} +class C2 {{ }} /// +class +#pragma warning restore CS1574 // {CSharpResources.WRN_BadXMLRef_Title} +C3 {{ }} // comment + // comment // comment", CSharpParseOptions.Default.WithDocumentationMode(DocumentationMode.Diagnose)); } } diff --git a/src/EditorFeatures/CSharpTest/Diagnostics/UseAutoProperty/UseAutoPropertyTests.cs b/src/EditorFeatures/CSharpTest/Diagnostics/UseAutoProperty/UseAutoPropertyTests.cs index fe7211afede68..d244764b33581 100644 --- a/src/EditorFeatures/CSharpTest/Diagnostics/UseAutoProperty/UseAutoPropertyTests.cs +++ b/src/EditorFeatures/CSharpTest/Diagnostics/UseAutoProperty/UseAutoPropertyTests.cs @@ -34,7 +34,10 @@ int P }", @"class Class { - int P { get; } + + int P + { + get; } }"); } @@ -56,7 +59,10 @@ public int P }", @"class Class { - public int P { get; private set; } + + public int P + { + get; private set; } }", CSharpParseOptions.Default.WithLanguageVersion(LanguageVersion.CSharp5)); } @@ -97,7 +103,10 @@ int P }", @"class Class { - int P { get; } = 1; + + int P + { + get; } = 1; }"); } @@ -137,7 +146,10 @@ public async Task TestSingleGetterFromProperty() }", @"class Class { - int P { get; } + + int P + { + get; } }"); } @@ -182,7 +194,10 @@ int P }", @"class Class { - int P { get; set; } + + int P + { + get; set; } }"); } @@ -204,7 +219,10 @@ int P }", @"class Class { - int P { get; } + + int P + { + get; } }"); } @@ -249,7 +267,10 @@ int P }", @"class Class { - int P { get; set; } + + int P + { + get; set; } }"); } @@ -482,7 +503,9 @@ int P { int j, k; - int P { get; } + int P + { + get; } }"); } @@ -506,7 +529,9 @@ int P { int i, k; - int P { get; } + int P + { + get; } }"); } @@ -530,7 +555,9 @@ int P { int i, j; - int P { get; } + int P + { + get; } }"); } @@ -559,7 +586,9 @@ int P partial class Class { - int P { get; } + int P + { + get; } }"); } @@ -605,7 +634,10 @@ public Class() }", @"class Class { - int P { get; } + + int P + { + get; } public Class() { @@ -637,7 +669,10 @@ public Class(int P) }", @"class Class { - int P { get; } + + int P + { + get; } public Class(int P) { @@ -669,7 +704,10 @@ public Class() }", @"class Class { - int P { get; } + + int P + { + get; } public Class() { @@ -701,7 +739,10 @@ public Goo() }", @"class Class { - int P { get; set; } + + int P + { + get; set; } public Goo() { @@ -733,7 +774,10 @@ public Goo() }", @"class Class { - public int P { get; private set; } + + public int P + { + get; private set; } public Goo() { @@ -832,7 +876,10 @@ public async Task Tuple_SingleGetterFromField() }", @"class Class { - (int, string) P { get; } + + (int, string) P + { + get; } }"); } @@ -854,7 +901,10 @@ public async Task TupleWithNames_SingleGetterFromField() }", @"class Class { - (int a, string b) P { get; } + + (int a, string b) P + { + get; } }"); } @@ -894,7 +944,10 @@ public async Task TupleWithOneName_SingleGetterFromField() }", @"class Class { - (int a, string) P { get; } + + (int a, string) P + { + get; } }"); } @@ -916,7 +969,10 @@ public async Task Tuple_Initializer() }", @"class Class { - (int, string) P { get; } = (1, ""hello""); + + (int, string) P + { + get; } = (1, ""hello""); }"); } @@ -943,7 +999,10 @@ public async Task Tuple_GetterAndSetter() }", @"class Class { - (int, string) P { get; set; } + + (int, string) P + { + get; set; } }"); } } diff --git a/src/EditorFeatures/CSharpTest/Diagnostics/UseImplicitOrExplicitType/UseExplicitTypeTests.cs b/src/EditorFeatures/CSharpTest/Diagnostics/UseImplicitOrExplicitType/UseExplicitTypeTests.cs index aebd39b4e0da4..1e139694b707b 100644 --- a/src/EditorFeatures/CSharpTest/Diagnostics/UseImplicitOrExplicitType/UseExplicitTypeTests.cs +++ b/src/EditorFeatures/CSharpTest/Diagnostics/UseImplicitOrExplicitType/UseExplicitTypeTests.cs @@ -741,8 +741,8 @@ static void M() { var customers = new List(); IEnumerable expr = from c in customers - where c.City == ""London"" - select c; + where c.City == ""London"" + select c; } private class Customer diff --git a/src/EditorFeatures/CSharpTest/Diagnostics/UseImplicitOrExplicitType/UseImplicitTypeTests.cs b/src/EditorFeatures/CSharpTest/Diagnostics/UseImplicitOrExplicitType/UseImplicitTypeTests.cs index c351000f451eb..c6697d411e062 100644 --- a/src/EditorFeatures/CSharpTest/Diagnostics/UseImplicitOrExplicitType/UseImplicitTypeTests.cs +++ b/src/EditorFeatures/CSharpTest/Diagnostics/UseImplicitOrExplicitType/UseImplicitTypeTests.cs @@ -817,8 +817,8 @@ static void M() { var customers = new List(); var expr = from c in customers - where c.City == ""London"" - select c; + where c.City == ""London"" + select c; } private class Customer diff --git a/src/EditorFeatures/CSharpTest/FullyQualify/FullyQualifyTests.cs b/src/EditorFeatures/CSharpTest/FullyQualify/FullyQualifyTests.cs index 0bb71af8a533b..9f7c8417b14a0 100644 --- a/src/EditorFeatures/CSharpTest/FullyQualify/FullyQualifyTests.cs +++ b/src/EditorFeatures/CSharpTest/FullyQualify/FullyQualifyTests.cs @@ -1028,7 +1028,7 @@ public async Task TestAttribute() await TestInRegularAndScriptAsync( input, -@"[assembly: System.Runtime.InteropServices.Guid(""9ed54f84-a89d-4fcd-a854-44251e925f09"")]"); +@"[ assembly : System.Runtime.InteropServices.Guid( ""9ed54f84-a89d-4fcd-a854-44251e925f09"" ) ] "); } [WorkItem(546027, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/546027")] diff --git a/src/EditorFeatures/CSharpTest/GenerateConstructor/GenerateConstructorTests.cs b/src/EditorFeatures/CSharpTest/GenerateConstructor/GenerateConstructorTests.cs index 8560218b30a50..8de3b1e2e7b78 100644 --- a/src/EditorFeatures/CSharpTest/GenerateConstructor/GenerateConstructorTests.cs +++ b/src/EditorFeatures/CSharpTest/GenerateConstructor/GenerateConstructorTests.cs @@ -85,7 +85,9 @@ void M() { private int v; - public C(int v) => this.v = v; void M() + public C(int v) => this.v = v; + + void M() { new C(1); } @@ -3260,18 +3262,20 @@ class P { } } ", @"class C { - public C ( int prop ) { - Prop = prop ; - } + public C(int prop) + { + Prop = prop; + } + public int Prop { get ; } } -class P { - static void M ( ) { +class P { + static void M ( ) { var prop = 42 ; var c = new C ( prop ) ; } -}"); +} "); } } } diff --git a/src/EditorFeatures/CSharpTest/GenerateFromMembers/GenerateConstructorFromMembers/GenerateConstructorFromMembersTests.cs b/src/EditorFeatures/CSharpTest/GenerateFromMembers/GenerateConstructorFromMembers/GenerateConstructorFromMembersTests.cs index 66d037adb31d6..f1565385bd016 100644 --- a/src/EditorFeatures/CSharpTest/GenerateFromMembers/GenerateConstructorFromMembers/GenerateConstructorFromMembersTests.cs +++ b/src/EditorFeatures/CSharpTest/GenerateFromMembers/GenerateConstructorFromMembers/GenerateConstructorFromMembersTests.cs @@ -56,7 +56,7 @@ class Z { int a; - public Z(int a{|Navigation:)|} => this . a = a ; + public Z(int a{|Navigation:)|} => this.a = a; }", options: Option(CSharpCodeStyleOptions.PreferExpressionBodiedConstructors, CSharpCodeStyleOptions.WhenPossibleWithNoneEnforcement)); } @@ -77,7 +77,7 @@ class Z { int a; - public Z(int a{|Navigation:)|} => this . a = a ; + public Z(int a{|Navigation:)|} => this.a = a; }", options: Option(CSharpCodeStyleOptions.PreferExpressionBodiedConstructors, CSharpCodeStyleOptions.WhenOnSingleLineWithNoneEnforcement)); } @@ -102,8 +102,8 @@ class Z public Z(int a, int b{|Navigation:)|} { - this . a = a ; - this . b = b ; + this.a = a; + this.b = b; } }", options: Option(CSharpCodeStyleOptions.PreferExpressionBodiedConstructors, CSharpCodeStyleOptions.WhenOnSingleLineWithNoneEnforcement)); @@ -938,7 +938,7 @@ public async Task ProtectedConstructorShouldBeGeneratedForAbstractClass() protected C(int prop{|Navigation:)|} { Prop = prop; - } + } public int Prop { get; set; } }", diff --git a/src/EditorFeatures/CSharpTest/GenerateFromMembers/GenerateEqualsAndGetHashCodeFromMembers/GenerateEqualsAndGetHashCodeFromMembersTests.cs b/src/EditorFeatures/CSharpTest/GenerateFromMembers/GenerateEqualsAndGetHashCodeFromMembers/GenerateEqualsAndGetHashCodeFromMembersTests.cs index 1c5d84bbf0833..70dee64841832 100644 --- a/src/EditorFeatures/CSharpTest/GenerateFromMembers/GenerateEqualsAndGetHashCodeFromMembers/GenerateEqualsAndGetHashCodeFromMembersTests.cs +++ b/src/EditorFeatures/CSharpTest/GenerateFromMembers/GenerateEqualsAndGetHashCodeFromMembers/GenerateEqualsAndGetHashCodeFromMembersTests.cs @@ -40,7 +40,8 @@ class Program public override bool Equals(object obj) { var program = obj as Program; - return program != null && a == program.a; + return program != null && + a == program.a; } }"); } @@ -72,7 +73,8 @@ class Program public override bool Equals(object obj) { var program = obj as Program; - return program != null && EqualityComparer.Default.Equals(a, program.a); + return program != null && + EqualityComparer.Default.Equals(a, program.a); } }"); } @@ -104,7 +106,8 @@ class Program public override bool Equals(object obj) { var program = obj as Program; - return program != null && a.Equals(program.a); + return program != null && + a.Equals(program.a); } }"); } @@ -128,7 +131,8 @@ class ReallyLongName public override bool Equals(object obj) { var name = obj as ReallyLongName; - return name != null && a == name.a; + return name != null && + a == name.a; } }"); } @@ -152,7 +156,8 @@ class ReallyLongLong public override bool Equals(object obj) { var @long = obj as ReallyLongLong; - return @long != null && a == @long.a; + return @long != null && + a == @long.a; } }"); } @@ -180,7 +185,9 @@ class ReallyLongName public override bool Equals(object obj) { var name = obj as ReallyLongName; - return name != null && a == name.a && B == name.B; + return name != null && + a == name.a && + B == name.B; } }"); } @@ -208,7 +215,8 @@ class Program : Base public override bool Equals(object obj) { var program = obj as Program; - return program != null && i == program.i; + return program != null && + i == program.i; } }"); } @@ -304,8 +312,10 @@ class Program : Middle public override bool Equals(object obj) { var program = obj as Program; - return program != null && base.Equals(obj) && - i == program.i && S == program.S; + return program != null && + base.Equals(obj) && + i == program.i && + S == program.S; } }"); } @@ -338,7 +348,8 @@ public override bool Equals(object obj) } var name = (ReallyLongName)obj; - return i == name.i && S == name.S; + return i == name.i && + S == name.S; } }"); } @@ -1033,11 +1044,8 @@ public override bool Equals(object obj) s == program.s; } - public static bool operator ==(Program program1, Program program2) - => EqualityComparer.Default.Equals(program1, program2); - - public static bool operator !=(Program program1, Program program2) - => !(program1 == program2); + public static bool operator ==(Program program1, Program program2) => EqualityComparer.Default.Equals(program1, program2); + public static bool operator !=(Program program1, Program program2) => !(program1 == program2); }", chosenSymbols: null, optionsCallback: options => EnableOption(options, GenerateOperatorsId), @@ -1266,7 +1274,8 @@ public void F() { return 0; } -}", +} + ", chosenSymbols: new string[] { }, index: 1); } diff --git a/src/EditorFeatures/CSharpTest/GenerateOverrides/GenerateOverridesTests.cs b/src/EditorFeatures/CSharpTest/GenerateOverrides/GenerateOverridesTests.cs index 1e927e2111238..e04bd59be3ab3 100644 --- a/src/EditorFeatures/CSharpTest/GenerateOverrides/GenerateOverridesTests.cs +++ b/src/EditorFeatures/CSharpTest/GenerateOverrides/GenerateOverridesTests.cs @@ -46,8 +46,7 @@ public override string ToString() { return base.ToString(); } -} -", new[] { "Equals", "GetHashCode", "ToString" }); +}", new[] { "Equals", "GetHashCode", "ToString" }); } [WorkItem(17698, "https://github.com/dotnet/roslyn/issues/17698")] @@ -93,8 +92,7 @@ class Derived : Base { return ref base.X(); } -} -", new[] { "X", "Y", "this[]" }); +}", new[] { "X", "Y", "this[]" }); } } } diff --git a/src/EditorFeatures/CSharpTest/GenerateVariable/GenerateVariableTests.cs b/src/EditorFeatures/CSharpTest/GenerateVariable/GenerateVariableTests.cs index 154b38b33806e..3d83a88360afd 100644 --- a/src/EditorFeatures/CSharpTest/GenerateVariable/GenerateVariableTests.cs +++ b/src/EditorFeatures/CSharpTest/GenerateVariable/GenerateVariableTests.cs @@ -2508,14 +2508,12 @@ public async Task TestConstantInParameterValue() await TestInRegularAndScriptAsync( Initial, @"class C -{ - const int y = 1; +{ + const int y = 1 ; private const bool undeclared; - public void Goo(bool x = undeclared) - { - } -}"); + public void Goo ( bool x = undeclared ) { } +} "); } [WorkItem(542900, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/542900")] @@ -3815,6 +3813,7 @@ void Main() #if true // Banner Line 1 // Banner Line 2 + int local; int.TryParse(""123"", out [|local|]); #endif @@ -4346,7 +4345,8 @@ void Goo() await TestExactActionSetOfferedAsync(code, new[] { string.Format(FeaturesResources.Generate_local_0, "Bar") }); await TestInRegularAndScriptAsync(code, -@"class C +@" +class C { #line 1 ""goo"" void Goo() @@ -4355,7 +4355,8 @@ void Goo() } #line default #line hidden -}", options: ImplicitTypingEverywhere()); +} +", options: ImplicitTypingEverywhere()); } [WorkItem(546027, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/546027")] @@ -6778,7 +6779,8 @@ class Program { static void Main(string[] args) { - Func goo = () => { + Func goo = () => + { return 0; }; } @@ -7140,7 +7142,8 @@ public Goo(String goo) [|String|] = goo; } }", -@"using System; +@" +using System; public class Goo { @@ -7168,7 +7171,8 @@ public Goo(String goo) [|String|] = goo; } }", -@"using System; +@" +using System; public class Goo { @@ -7436,7 +7440,6 @@ class C { public bool isDisposed; private int y; - public readonly int x; public readonly int m; @@ -7470,7 +7473,6 @@ class C public readonly int x; public readonly int m; private readonly int y; - public bool isDisposed; public C() diff --git a/src/EditorFeatures/CSharpTest/ImplementAbstractClass/ImplementAbstractClassTests.cs b/src/EditorFeatures/CSharpTest/ImplementAbstractClass/ImplementAbstractClassTests.cs index dd6a1158f3608..86bc52090a4ce 100644 --- a/src/EditorFeatures/CSharpTest/ImplementAbstractClass/ImplementAbstractClassTests.cs +++ b/src/EditorFeatures/CSharpTest/ImplementAbstractClass/ImplementAbstractClassTests.cs @@ -31,7 +31,7 @@ internal override (DiagnosticAnalyzer, CodeFixProvider) CreateDiagnosticProvider internal Task TestAllOptionsOffAsync( string initialMarkup, string expectedMarkup, - int index = 0, bool ignoreTrivia = true, + int index = 0, bool ignoreTrivia = false, IDictionary options = null) { options = options ?? new Dictionary(); @@ -1386,11 +1386,8 @@ class [|T|] : A class T : A { - public override int M - { - get => throw new System.NotImplementedException(); - } - }", options: OptionsSet( + public override int M { get => throw new System.NotImplementedException(); } +}", options: OptionsSet( SingleOption(CSharpCodeStyleOptions.PreferExpressionBodiedProperties, ExpressionBodyPreference.Never, NotificationOption.None), SingleOption(CSharpCodeStyleOptions.PreferExpressionBodiedAccessors, ExpressionBodyPreference.WhenPossible, NotificationOption.None))); } @@ -1415,11 +1412,8 @@ class [|T|] : A class T : A { - public override int M - { - set => throw new System.NotImplementedException(); - } - }", options: Option(CSharpCodeStyleOptions.PreferExpressionBodiedAccessors, CSharpCodeStyleOptions.WhenPossibleWithNoneEnforcement)); + public override int M { set => throw new System.NotImplementedException(); } +}", options: Option(CSharpCodeStyleOptions.PreferExpressionBodiedAccessors, CSharpCodeStyleOptions.WhenPossibleWithNoneEnforcement)); } [WorkItem(581500, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/581500")] @@ -1442,12 +1436,8 @@ class [|T|] : A class T : A { - public override int M - { - get => throw new System.NotImplementedException(); - set => throw new System.NotImplementedException(); - } - }", options: Option(CSharpCodeStyleOptions.PreferExpressionBodiedAccessors, CSharpCodeStyleOptions.WhenPossibleWithNoneEnforcement)); + public override int M { get => throw new System.NotImplementedException(); set => throw new System.NotImplementedException(); } +}", options: Option(CSharpCodeStyleOptions.PreferExpressionBodiedAccessors, CSharpCodeStyleOptions.WhenPossibleWithNoneEnforcement)); } [WorkItem(15387, "https://github.com/dotnet/roslyn/issues/15387")] diff --git a/src/EditorFeatures/CSharpTest/ImplementInterface/ImplementInterfaceTests.cs b/src/EditorFeatures/CSharpTest/ImplementInterface/ImplementInterfaceTests.cs index 62ceaa55badf7..8ac8e82bbf65b 100644 --- a/src/EditorFeatures/CSharpTest/ImplementInterface/ImplementInterfaceTests.cs +++ b/src/EditorFeatures/CSharpTest/ImplementInterface/ImplementInterfaceTests.cs @@ -51,7 +51,7 @@ internal override (DiagnosticAnalyzer, CodeFixProvider) CreateDiagnosticProvider internal async Task TestWithAllCodeStyleOptionsOffAsync( string initialMarkup, string expectedMarkup, - int index = 0, bool ignoreTrivia = true, + int index = 0, bool ignoreTrivia = false, ParseOptions parseOptions = null) { await TestAsync(initialMarkup, expectedMarkup, parseOptions, null, @@ -213,7 +213,8 @@ class Class : IInterface { throw new System.NotImplementedException(); } -}" + s_tupleElementNamesAttribute); +} +" + s_tupleElementNamesAttribute); } [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsImplementInterface), Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Tuples)] @@ -241,7 +242,8 @@ class Class : IInterface { throw new System.NotImplementedException(); } -}" + s_tupleElementNamesAttribute, +} +" + s_tupleElementNamesAttribute, index: 1); } @@ -278,7 +280,8 @@ class Class : IInterface throw new System.NotImplementedException(); } } -}" + s_tupleElementNamesAttribute); +} +" + s_tupleElementNamesAttribute); } [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsImplementInterface), Test.Utilities.CompilerTrait(Test.Utilities.CompilerFeature.Tuples)] @@ -303,7 +306,8 @@ class Class : [|IInterface|] class Class : IInterface { public event Func<(int a, int b)> Event1; -}" + s_tupleElementNamesAttribute); +} +" + s_tupleElementNamesAttribute); } [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsImplementInterface)] @@ -355,7 +359,8 @@ public void Method1() { throw new System.NotImplementedException(); } -}"); +} +"); } [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsImplementInterface)] @@ -374,8 +379,7 @@ interface IInterface2 : IInterface1 class Class : [|IInterface2|] { }", -@" -interface IInterface1 +@"interface IInterface1 { void Method1(); } @@ -2484,26 +2488,28 @@ class HasCanGoo : [|IGoo|] using System; interface IGoo -{ - event System.EventHandler E; +{ + event System.EventHandler E; } class CanGoo : IGoo -{ +{ public event EventHandler E; } class HasCanGoo : IGoo -{ +{ CanGoo canGoo; + public event EventHandler E { add { ((IGoo)canGoo).E += value; } + remove - { + { ((IGoo)canGoo).E -= value; } } @@ -2515,7 +2521,23 @@ public async Task TestImplementEventThroughExplicitMember() { await TestInRegularAndScriptAsync( @"interface IGoo { event System . EventHandler E ; } class CanGoo : IGoo { event IGoo.EventHandler E; } class HasCanGoo : [|IGoo|] { CanGoo canGoo; } ", -@"using System ; interface IGoo { event System . EventHandler E ; } class CanGoo : IGoo { event IGoo.EventHandler E; } class HasCanGoo : IGoo { CanGoo canGoo; public event EventHandler E { add { ((IGoo)canGoo).E += value; } remove { ((IGoo)canGoo).E -= value; } } } ", +@"using System; + +interface IGoo { event System . EventHandler E ; } class CanGoo : IGoo { event IGoo.EventHandler E; } class HasCanGoo : IGoo { CanGoo canGoo; + + public event EventHandler E + { + add + { + ((IGoo)canGoo).E += value; + } + + remove + { + ((IGoo)canGoo).E -= value; + } + } +} ", index: 1); } @@ -2532,6 +2554,7 @@ abstract class Goo : [|IGoo|] { }", @"using System; + interface IGoo { event System.EventHandler E; @@ -2817,6 +2840,7 @@ class A : [|I|] { }", @"using System; + interface I { void Goo() where T : System.Attribute; @@ -3978,7 +4002,14 @@ public async Task TestStringLiteral() { await TestWithAllCodeStyleOptionsOffAsync( @"interface IGoo { void Goo ( string s = ""\"""" ) ; } class B : [|IGoo|] { } ", -@"interface IGoo { void Goo ( string s = ""\"""" ) ; } class B : IGoo { public void Goo ( string s = ""\"""" ) { throw new System.NotImplementedException ( ) ; } } "); +@"interface IGoo { void Goo ( string s = ""\"""" ) ; } +class B : IGoo +{ + public void Goo(string s = ""\"""") + { + throw new System.NotImplementedException(); + } +} "); } [WorkItem(916114, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/916114")] @@ -4914,7 +4945,8 @@ public void Goo<@class>() { throw new System.NotImplementedException(); } -}"); +} +"); } [WorkItem(545922, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/545922")] @@ -5409,12 +5441,13 @@ public async Task TestUnterminatedString1() class C : [|IServiceProvider|] @""", @"using System; -class C : IServiceProvider @"""" { +class C : IServiceProvider @""""{ public object GetService(Type serviceType) { throw new NotImplementedException(); } -}"); +} +"); } [WorkItem(545939, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/545939")] @@ -5427,12 +5460,13 @@ public async Task TestUnterminatedString2() class C : [|IServiceProvider|] """, @"using System; -class C : IServiceProvider """" { +class C : IServiceProvider """"{ public object GetService(Type serviceType) { throw new NotImplementedException(); } -}"); +} +"); } [WorkItem(545939, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/545939")] @@ -5445,12 +5479,13 @@ public async Task TestUnterminatedString3() class C : [|IServiceProvider|] @""", @"using System; -class C : IServiceProvider @"""" { +class C : IServiceProvider @""""{ public object GetService(Type serviceType) { throw new NotImplementedException(); } -}"); +} +"); } [WorkItem(545939, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/545939")] @@ -5463,12 +5498,13 @@ public async Task TestUnterminatedString4() class C : [|IServiceProvider|] """, @"using System; -class C : IServiceProvider """" { +class C : IServiceProvider """"{ public object GetService(Type serviceType) { throw new NotImplementedException(); } -}"); +} +"); } [WorkItem(545940, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/545940")] @@ -5943,7 +5979,7 @@ void IGoo.set_IndexProp(int p1, string Value) throw new System.NotImplementedException(); } } -"; + "; await TestWithAllCodeStyleOptionsOffAsync(initial, expected, index: 1); } @@ -5982,13 +6018,13 @@ public object get_P(int x) { throw new NotImplementedException(); } - + public void set_P(int x, object Value) { throw new NotImplementedException(); } } -"; + "; await TestWithAllCodeStyleOptionsOffAsync(initial, expected, index: 0); } @@ -6016,14 +6052,13 @@ public async Task TestImplementInterfaceForImplicitIDisposable() class Program : [|IDisposable|] { }", -$@" -using System; +$@"using System; class Program : IDisposable {{ -{DisposePattern("protected virtual ", "C", "public void ")} -}} -", index: 1); + +{DisposePattern("protected virtual ", "Program", "public void ")} +}}", index: 1); } [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsImplementInterface)] @@ -6036,15 +6071,14 @@ class Program : [|IDisposable|] { private bool DisposedValue; }", -$@" -using System; +$@"using System; class Program : IDisposable {{ private bool DisposedValue; + {DisposePattern("protected virtual ", "Program", "void IDisposable.")} -}} -", index: 3); +}}", index: 3); } [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsImplementInterface)] @@ -6106,14 +6140,13 @@ public async Task TestImplementInterfaceForExplicitIDisposableWithSealedClass() sealed class Program : [|IDisposable|] { }", -$@" -using System; +$@"using System; sealed class Program : IDisposable {{ + {DisposePattern("", "Program", "void IDisposable.")} -}} -", index: 3); +}}", index: 3); } [WorkItem(939123, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/939123")] @@ -6237,6 +6270,8 @@ public void M1() throw new System.NotImplementedException(); } } + + // Comment }"); } @@ -6675,7 +6710,6 @@ class Class : IInterface void M() { } public int Prop => throw new System.NotImplementedException(); - }", options: Option(ImplementTypeOptions.InsertionBehavior, ImplementTypeInsertionBehavior.AtTheEnd)); } @@ -6699,7 +6733,8 @@ interface IComInterface class Class : [|IComInterface|] { }", -@"using System.Runtime.InteropServices; +@" +using System.Runtime.InteropServices; [ComImport] interface IComInterface @@ -6712,9 +6747,21 @@ interface IComInterface class Class : IComInterface { - public void MOverload() { throw new System.NotImplementedException(); } - public void X() { throw new System.NotImplementedException(); } - public void MOverload(int i) { throw new System.NotImplementedException(); } + public void MOverload() + { + throw new System.NotImplementedException(); + } + + public void X() + { + throw new System.NotImplementedException(); + } + + public void MOverload(int i) + { + throw new System.NotImplementedException(); + } + public int Prop => throw new System.NotImplementedException(); }"); } @@ -6783,9 +6830,7 @@ class Class : [|IInterface|] class Class : IInterface { public int ReadOnlyProp { get; } - public int ReadWriteProp { get; set; } - public int WriteOnlyProp { set => throw new System.NotImplementedException(); } }", parameters: new TestParameters(options: Option( ImplementTypeOptions.PropertyGenerationBehavior, diff --git a/src/EditorFeatures/CSharpTest/InitializeParameter/AddParameterCheckTests.cs b/src/EditorFeatures/CSharpTest/InitializeParameter/AddParameterCheckTests.cs index 66d6560fc4ddd..f585b956d0501 100644 --- a/src/EditorFeatures/CSharpTest/InitializeParameter/AddParameterCheckTests.cs +++ b/src/EditorFeatures/CSharpTest/InitializeParameter/AddParameterCheckTests.cs @@ -425,7 +425,7 @@ public C(string s) { throw new ArgumentNullException(nameof(s)); } - + Init(); } }"); @@ -454,7 +454,7 @@ public C(string s) { throw new ArgumentNullException(nameof(s)); } - + Init(); } }", parameters: new TestParameters(options: diff --git a/src/EditorFeatures/CSharpTest/InitializeParameter/InitializeMemberFromParameterTests.cs b/src/EditorFeatures/CSharpTest/InitializeParameter/InitializeMemberFromParameterTests.cs index 9af2df6cd2142..99dc1d6463268 100644 --- a/src/EditorFeatures/CSharpTest/InitializeParameter/InitializeMemberFromParameterTests.cs +++ b/src/EditorFeatures/CSharpTest/InitializeParameter/InitializeMemberFromParameterTests.cs @@ -183,6 +183,7 @@ public C([||]string s) class C { private string S => null; + public string S1 { get; } public C(string s) @@ -384,7 +385,7 @@ class C public C(string s, string t) { this.s = s; - this.t = t; + this.t = t; } }"); } @@ -440,6 +441,7 @@ class C public C(string s) { if (true) { } + this.s = s; } }"); @@ -562,7 +564,7 @@ class C public C(string s, string t) { S = s; - T = t; + T = t; } public string S { get; } diff --git a/src/EditorFeatures/CSharpTest/InlineDeclaration/CSharpInlineDeclarationTests.cs b/src/EditorFeatures/CSharpTest/InlineDeclaration/CSharpInlineDeclarationTests.cs index e92ebfed2296d..86e65a3969d5f 100644 --- a/src/EditorFeatures/CSharpTest/InlineDeclaration/CSharpInlineDeclarationTests.cs +++ b/src/EditorFeatures/CSharpTest/InlineDeclaration/CSharpInlineDeclarationTests.cs @@ -1124,7 +1124,7 @@ void Goo(string x) { if (x != null && TryBaz(out object s)) { - Console.WriteLine(s); + Console.WriteLine(s); } } @@ -1603,7 +1603,7 @@ class C { static void Main(string[] args) { - for ( ; TryExtractTokenFromEmail(out string token); ) + for (; TryExtractTokenFromEmail(out string token);) { } } diff --git a/src/EditorFeatures/CSharpTest/Interactive/CodeActions/InteractiveIntroduceVariableTests.cs b/src/EditorFeatures/CSharpTest/Interactive/CodeActions/InteractiveIntroduceVariableTests.cs index b8a7c209608da..a43ee5fee315d 100644 --- a/src/EditorFeatures/CSharpTest/Interactive/CodeActions/InteractiveIntroduceVariableTests.cs +++ b/src/EditorFeatures/CSharpTest/Interactive/CodeActions/InteractiveIntroduceVariableTests.cs @@ -13,7 +13,7 @@ public class InteractiveIntroduceVariableTests : AbstractCSharpCodeActionTest protected override CodeRefactoringProvider CreateCodeRefactoringProvider(Workspace workspace, TestParameters parameters) => new IntroduceVariableCodeRefactoringProvider(); - protected Task TestAsync(string initial, string expected, int index = 0, bool ignoreTrivia = true) + protected Task TestAsync(string initial, string expected, int index = 0, bool ignoreTrivia = false) { return TestAsync(initial, expected, Options.Script, null, index, ignoreTrivia); } diff --git a/src/EditorFeatures/CSharpTest/MoveDeclarationNearReference/MoveDeclarationNearReferenceTests.cs b/src/EditorFeatures/CSharpTest/MoveDeclarationNearReference/MoveDeclarationNearReferenceTests.cs index 03cfddef0f0fe..7d26cb8fdfb97 100644 --- a/src/EditorFeatures/CSharpTest/MoveDeclarationNearReference/MoveDeclarationNearReferenceTests.cs +++ b/src/EditorFeatures/CSharpTest/MoveDeclarationNearReference/MoveDeclarationNearReferenceTests.cs @@ -415,7 +415,8 @@ class Program { void Main() { - new[] { 1 }.AsParallel().ForAll((i) => { + new[] { 1 }.AsParallel().ForAll((i) => + { {|Warning:var @lock = new object();|} lock (@lock) { diff --git a/src/EditorFeatures/CSharpTest/OrderModifiers/OrderModifiersTests.cs b/src/EditorFeatures/CSharpTest/OrderModifiers/OrderModifiersTests.cs index 88dfc1fa87a83..8aedab4c0e31c 100644 --- a/src/EditorFeatures/CSharpTest/OrderModifiers/OrderModifiersTests.cs +++ b/src/EditorFeatures/CSharpTest/OrderModifiers/OrderModifiersTests.cs @@ -23,8 +23,7 @@ public async Task TestClass() @"[|static|] internal class C { }", -@" -internal static class C +@"internal static class C { }"); } @@ -36,8 +35,7 @@ public async Task TestStruct() @"[|unsafe|] public struct C { }", -@" -public unsafe struct C +@"public unsafe struct C { }"); } @@ -49,8 +47,7 @@ public async Task TestInterface() @"[|unsafe|] public interface C { }", -@" -public unsafe interface C +@"public unsafe interface C { }"); } @@ -62,8 +59,7 @@ public async Task TestEnum() @"[|internal|] protected enum C { }", -@" -protected internal enum C +@"protected internal enum C { }"); } @@ -84,8 +80,7 @@ public async Task TestMethod() { [|unsafe|] public void M() { } }", -@" -class C +@"class C { public unsafe void M() { } }"); @@ -99,8 +94,7 @@ public async Task TestField() { [|unsafe|] public int a; }", -@" -class C +@"class C { public unsafe int a; }"); @@ -114,8 +108,7 @@ public async Task TestConstructor() { [|unsafe|] public C() { } }", -@" -class C +@"class C { public unsafe C() { } }"); @@ -129,8 +122,7 @@ public async Task TestProperty() { [|unsafe|] public int P { get; } }", -@" -class C +@"class C { public unsafe int P { get; } }"); @@ -144,8 +136,7 @@ public async Task TestAccessor() { int P { [|internal|] protected get; } }", -@" -class C +@"class C { int P { protected internal get; } }"); @@ -159,8 +150,7 @@ public async Task TestPropertyEvent() { [|internal|] protected event Action P { add { } remove { } } }", -@" -class C +@"class C { protected internal event Action P { add { } remove { } } }"); @@ -174,8 +164,7 @@ public async Task TestFieldEvent() { [|internal|] protected event Action P; }", -@" -class C +@"class C { protected internal event Action P; }"); @@ -189,8 +178,7 @@ public async Task TestOperator() { [|static|] public C operator +(C c1, C c2) { } }", -@" -class C +@"class C { public static C operator +(C c1, C c2) { } }"); @@ -204,8 +192,7 @@ public async Task TestConversionOperator() { [|static|] public implicit operator bool(C c1) { } }", -@" -class C +@"class C { public static implicit operator bool(C c1) { } }"); @@ -219,8 +206,7 @@ public async Task TestFixAll1() { static internal class Nested { } }", -@" -internal static class C +@"internal static class C { internal static class Nested { } }"); @@ -234,8 +220,7 @@ public async Task TestFixAll2() { {|FixAllInDocument:static|} internal class Nested { } }", -@" -internal static class C +@"internal static class C { internal static class Nested { } }"); diff --git a/src/EditorFeatures/CSharpTest/RemoveUnreachableCode/RemoveUnreachableCodeTests.cs b/src/EditorFeatures/CSharpTest/RemoveUnreachableCode/RemoveUnreachableCodeTests.cs index 768ecba99a03b..225a078b85ff3 100644 --- a/src/EditorFeatures/CSharpTest/RemoveUnreachableCode/RemoveUnreachableCodeTests.cs +++ b/src/EditorFeatures/CSharpTest/RemoveUnreachableCode/RemoveUnreachableCodeTests.cs @@ -151,7 +151,7 @@ class C void M() { throw new System.Exception(); - + void Local() {} } }"); @@ -181,7 +181,7 @@ class C void M() { throw new System.Exception(); - + void Local() {} void Local2() {} } @@ -215,8 +215,9 @@ class C void M() { throw new System.Exception(); - + void Local() {} + void Local2() {} } }"); @@ -250,8 +251,9 @@ class C void M() { throw new System.Exception(); - + void Local() {} + void Local2() {} } }"); @@ -281,7 +283,7 @@ class C void M() { throw new System.Exception(); - + label: Console.WriteLine(); diff --git a/src/EditorFeatures/CSharpTest/UseCoalesceExpression/UseCoalesceExpressionForNullableTests.cs b/src/EditorFeatures/CSharpTest/UseCoalesceExpression/UseCoalesceExpressionForNullableTests.cs index 8694bf28a6d31..1617fb4573945 100644 --- a/src/EditorFeatures/CSharpTest/UseCoalesceExpression/UseCoalesceExpressionForNullableTests.cs +++ b/src/EditorFeatures/CSharpTest/UseCoalesceExpression/UseCoalesceExpressionForNullableTests.cs @@ -36,7 +36,7 @@ class C { void M(int? x, int? y) { - var z = x ?? y; + var z = x ?? y ; } }"); } @@ -84,7 +84,7 @@ class C { void M(int? x, int? y) { - var z = (x + y) ?? y; + var z = (x + y) ?? y ; } }"); } @@ -134,7 +134,7 @@ class C void M(int? x, int? y) { var z1 = x ?? y; - var z2 = x ?? y; + var z2 = x ?? y ; } }"); } @@ -209,7 +209,7 @@ class C { void M(int? x, int? y) { - Expression> e = () => {|Warning:x ?? y|}; + Expression> e = () => {|Warning:x ?? y|} ; } }"); } diff --git a/src/EditorFeatures/CSharpTest/UseCollectionInitializer/UseCollectionInitializerTests.cs b/src/EditorFeatures/CSharpTest/UseCollectionInitializer/UseCollectionInitializerTests.cs index 3a6300800d74d..264e2d29bc437 100644 --- a/src/EditorFeatures/CSharpTest/UseCollectionInitializer/UseCollectionInitializerTests.cs +++ b/src/EditorFeatures/CSharpTest/UseCollectionInitializer/UseCollectionInitializerTests.cs @@ -529,7 +529,8 @@ class C { void M() { - var list1 = new List(() => { + var list1 = new List(() => + { var list2 = new List { 2 @@ -567,7 +568,8 @@ void M() { var list1 = new List { - () => { + () => + { var list2 = new List { 2 @@ -632,14 +634,8 @@ void M() { var c = new Dictionary { - { - 1, - ""x"" - }, - { - 2, - ""y"" - } + { 1, ""x"" }, + { 2, ""y"" } }; } }"); diff --git a/src/EditorFeatures/CSharpTest/UseExpressionBody/Analyzer/UseExpressionBodyForAccessorsAnalyzerTests.cs b/src/EditorFeatures/CSharpTest/UseExpressionBody/Analyzer/UseExpressionBodyForAccessorsAnalyzerTests.cs index 9052e0e027999..8102529dab519 100644 --- a/src/EditorFeatures/CSharpTest/UseExpressionBody/Analyzer/UseExpressionBodyForAccessorsAnalyzerTests.cs +++ b/src/EditorFeatures/CSharpTest/UseExpressionBody/Analyzer/UseExpressionBodyForAccessorsAnalyzerTests.cs @@ -101,8 +101,8 @@ public async Task TestOnIndexer1() int this[int i] { get => Bar(); - } - }", options: UseExpressionBody); + } +}", options: UseExpressionBody); } [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseExpressionBody)] @@ -144,8 +144,8 @@ int Goo int Goo { set => [|Bar|](); - } - }", options: UseExpressionBody); + } +}", options: UseExpressionBody); } [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseExpressionBody)] @@ -180,8 +180,8 @@ int Goo int Goo { get => throw new NotImplementedException(); - } - }", options: UseExpressionBody); + } +}", options: UseExpressionBody); } [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseExpressionBody)] @@ -361,7 +361,7 @@ class C using System; class C { - int Goo + int Goo { get { @@ -387,15 +387,14 @@ class C using System; class C { - int Goo + int Goo { get { throw new NotImplementedException(); } } - - int Bar + int Bar { get { diff --git a/src/EditorFeatures/CSharpTest/UseExpressionBody/Analyzer/UseExpressionBodyForIndexersAnalyzerTests.cs b/src/EditorFeatures/CSharpTest/UseExpressionBody/Analyzer/UseExpressionBodyForIndexersAnalyzerTests.cs index 184efe1e58d1e..802013b406529 100644 --- a/src/EditorFeatures/CSharpTest/UseExpressionBody/Analyzer/UseExpressionBodyForIndexersAnalyzerTests.cs +++ b/src/EditorFeatures/CSharpTest/UseExpressionBody/Analyzer/UseExpressionBodyForIndexersAnalyzerTests.cs @@ -163,7 +163,10 @@ public async Task TestUseBlockBodyForAccessorEventWhenAccessorWantExpression1() { int this[int i] { - get { return Bar(); } + get + { + return Bar(); + } } }", options: UseBlockBodyExceptAccessor); } diff --git a/src/EditorFeatures/CSharpTest/UseExpressionBody/Analyzer/UseExpressionBodyForPropertiesAnalyzerTests.cs b/src/EditorFeatures/CSharpTest/UseExpressionBody/Analyzer/UseExpressionBodyForPropertiesAnalyzerTests.cs index b14fefa642461..fb2de3de1c5ea 100644 --- a/src/EditorFeatures/CSharpTest/UseExpressionBody/Analyzer/UseExpressionBodyForPropertiesAnalyzerTests.cs +++ b/src/EditorFeatures/CSharpTest/UseExpressionBody/Analyzer/UseExpressionBodyForPropertiesAnalyzerTests.cs @@ -180,7 +180,10 @@ public async Task TestUseBlockBodyForAccessorEventWhenAccessorWantExpression1() { int Goo { - get { return Bar(); } + get + { + return Bar(); + } } }", options: UseBlockBodyExceptAccessor); } @@ -381,7 +384,7 @@ class C using System; class C { - int Goo + int Goo { get { @@ -407,7 +410,7 @@ class C using System; class C { - int Goo + int Goo { get { @@ -415,7 +418,7 @@ int Goo } } - int Bar + int Bar { get { diff --git a/src/EditorFeatures/CSharpTest/UseExpressionBody/Refactoring/UseExpressionBodyForAccessorsRefactoringTests.cs b/src/EditorFeatures/CSharpTest/UseExpressionBody/Refactoring/UseExpressionBodyForAccessorsRefactoringTests.cs index 2481fb9c52da2..93de33cd1712e 100644 --- a/src/EditorFeatures/CSharpTest/UseExpressionBody/Refactoring/UseExpressionBodyForAccessorsRefactoringTests.cs +++ b/src/EditorFeatures/CSharpTest/UseExpressionBody/Refactoring/UseExpressionBodyForAccessorsRefactoringTests.cs @@ -89,7 +89,10 @@ int Goo }", @"class C { - int Goo { get => Bar(); } + int Goo + { + get => Bar(); + } }", parameters: new TestParameters(options: UseBlockBodyForAccessors_ExpressionBodyForProperties)); } diff --git a/src/EditorFeatures/CSharpTest/UseExpressionBody/Refactoring/UseExpressionBodyForConstructorsRefactoringTests.cs b/src/EditorFeatures/CSharpTest/UseExpressionBody/Refactoring/UseExpressionBodyForConstructorsRefactoringTests.cs index 381e3f47b916e..a026faf5669d1 100644 --- a/src/EditorFeatures/CSharpTest/UseExpressionBody/Refactoring/UseExpressionBodyForConstructorsRefactoringTests.cs +++ b/src/EditorFeatures/CSharpTest/UseExpressionBody/Refactoring/UseExpressionBodyForConstructorsRefactoringTests.cs @@ -86,7 +86,10 @@ public async Task TestOfferedIfUserPrefersExpressionBodiesAndInExpressionBody() }", @"class C { - public C() { Bar(); } + public C() + { + Bar(); + } }", parameters: new TestParameters(options: UseExpressionBody)); } } diff --git a/src/EditorFeatures/CSharpTest/UseExpressionBody/Refactoring/UseExpressionBodyForConversionOperatorsRefactoringTests.cs b/src/EditorFeatures/CSharpTest/UseExpressionBody/Refactoring/UseExpressionBodyForConversionOperatorsRefactoringTests.cs index f4e43559c6cc7..419b349e4119a 100644 --- a/src/EditorFeatures/CSharpTest/UseExpressionBody/Refactoring/UseExpressionBodyForConversionOperatorsRefactoringTests.cs +++ b/src/EditorFeatures/CSharpTest/UseExpressionBody/Refactoring/UseExpressionBodyForConversionOperatorsRefactoringTests.cs @@ -86,7 +86,10 @@ public async Task TestOfferedIfUserPrefersExpressionBodiesAndInExpressionBody() }", @"class C { - public static implicit operator bool(C c1) { return Bar(); } + public static implicit operator bool(C c1) + { + return Bar(); + } }", parameters: new TestParameters(options: UseExpressionBody)); } } diff --git a/src/EditorFeatures/CSharpTest/UseExpressionBody/Refactoring/UseExpressionBodyForIndexersRefactoringTests.cs b/src/EditorFeatures/CSharpTest/UseExpressionBody/Refactoring/UseExpressionBodyForIndexersRefactoringTests.cs index 53384def1141d..737eeea1a3feb 100644 --- a/src/EditorFeatures/CSharpTest/UseExpressionBody/Refactoring/UseExpressionBodyForIndexersRefactoringTests.cs +++ b/src/EditorFeatures/CSharpTest/UseExpressionBody/Refactoring/UseExpressionBodyForIndexersRefactoringTests.cs @@ -96,7 +96,13 @@ public async Task TestOfferedIfUserPrefersExpressionBodiesAndInExpressionBody() }", @"class C { - int this[int i] { get { return Bar(); } } + int this[int i] + { + get + { + return Bar(); + } + } }", parameters: new TestParameters(options: UseExpressionBody)); } } diff --git a/src/EditorFeatures/CSharpTest/UseExpressionBody/Refactoring/UseExpressionBodyForMethodsRefactoringTests.cs b/src/EditorFeatures/CSharpTest/UseExpressionBody/Refactoring/UseExpressionBodyForMethodsRefactoringTests.cs index 53b56528bcdf5..259513613859b 100644 --- a/src/EditorFeatures/CSharpTest/UseExpressionBody/Refactoring/UseExpressionBodyForMethodsRefactoringTests.cs +++ b/src/EditorFeatures/CSharpTest/UseExpressionBody/Refactoring/UseExpressionBodyForMethodsRefactoringTests.cs @@ -86,7 +86,10 @@ public async Task TestOfferedIfUserPrefersExpressionBodiesAndInExpressionBody() }", @"class C { - void Goo() { Bar(); } + void Goo() + { + Bar(); + } }", parameters: new TestParameters(options: UseExpressionBody)); } } diff --git a/src/EditorFeatures/CSharpTest/UseExpressionBody/Refactoring/UseExpressionBodyForOperatorsRefactoringTests.cs b/src/EditorFeatures/CSharpTest/UseExpressionBody/Refactoring/UseExpressionBodyForOperatorsRefactoringTests.cs index 03bddbce410b5..fd3f8ffff5896 100644 --- a/src/EditorFeatures/CSharpTest/UseExpressionBody/Refactoring/UseExpressionBodyForOperatorsRefactoringTests.cs +++ b/src/EditorFeatures/CSharpTest/UseExpressionBody/Refactoring/UseExpressionBodyForOperatorsRefactoringTests.cs @@ -86,7 +86,10 @@ public async Task TestOfferedIfUserPrefersExpressionBodiesAndInExpressionBody() }", @"class C { - public static bool operator +(C c1, C c2) { return Bar(); } + public static bool operator +(C c1, C c2) + { + return Bar(); + } }", parameters: new TestParameters(options: UseExpressionBody)); } } diff --git a/src/EditorFeatures/CSharpTest/UseExpressionBody/Refactoring/UseExpressionBodyForPropertiesRefactoringTests.cs b/src/EditorFeatures/CSharpTest/UseExpressionBody/Refactoring/UseExpressionBodyForPropertiesRefactoringTests.cs index a64c10a015379..a46c5d081c7c9 100644 --- a/src/EditorFeatures/CSharpTest/UseExpressionBody/Refactoring/UseExpressionBodyForPropertiesRefactoringTests.cs +++ b/src/EditorFeatures/CSharpTest/UseExpressionBody/Refactoring/UseExpressionBodyForPropertiesRefactoringTests.cs @@ -164,7 +164,13 @@ public async Task TestOfferedIfUserPrefersExpressionBodiesAndInExpressionBody() }", @"class C { - int Goo { get { return Bar(); } } + int Goo + { + get + { + return Bar(); + } + } }", parameters: new TestParameters(options: UseExpressionBodyForAccessors_ExpressionBodyForProperties)); } @@ -178,7 +184,13 @@ public async Task TestOfferedIfUserPrefersExpressionBodiesAndInExpressionBody2() }", @"class C { - int Goo { get { return Bar(); } } + int Goo + { + get + { + return Bar(); + } + } }", parameters: new TestParameters(options: UseBlockBodyForAccessors_ExpressionBodyForProperties)); } @@ -193,7 +205,13 @@ public async Task TestOfferedIfUserPrefersExpressionBodiesAndInExpressionBody_CS }", @"class C { - int Goo { get { return Bar(); } } + int Goo + { + get + { + return Bar(); + } + } }", parseOptions: CSharpParseOptions.Default.WithLanguageVersion(LanguageVersion.CSharp6), options: UseExpressionBodyForAccessors_ExpressionBodyForProperties); } diff --git a/src/EditorFeatures/CSharpTest/UseInferredMemberName/UseInferredMemberNameTests.cs b/src/EditorFeatures/CSharpTest/UseInferredMemberName/UseInferredMemberNameTests.cs index f1c247652ef33..5a60e5f7bf473 100644 --- a/src/EditorFeatures/CSharpTest/UseInferredMemberName/UseInferredMemberNameTests.cs +++ b/src/EditorFeatures/CSharpTest/UseInferredMemberName/UseInferredMemberNameTests.cs @@ -39,7 +39,7 @@ class C void M() { int a = 1; - var t = (a, 2); + var t = ( a, 2); } }", parseOptions: s_parseOptions); } diff --git a/src/EditorFeatures/CSharpTest/UseLocalFunction/UseLocalFunctionTests.cs b/src/EditorFeatures/CSharpTest/UseLocalFunction/UseLocalFunctionTests.cs index 92139273ceffb..cbb39a7914e2a 100644 --- a/src/EditorFeatures/CSharpTest/UseLocalFunction/UseLocalFunctionTests.cs +++ b/src/EditorFeatures/CSharpTest/UseLocalFunction/UseLocalFunctionTests.cs @@ -1097,7 +1097,6 @@ void M() int fibonacci(int v) { bool isTrue(bool b) => b; - return fibonacci(v - 1, v - 2); } } diff --git a/src/EditorFeatures/CSharpTest/UseObjectInitializer/UseObjectInitializerTests.cs b/src/EditorFeatures/CSharpTest/UseObjectInitializer/UseObjectInitializerTests.cs index 3ff7dded98c13..46e44f508e305 100644 --- a/src/EditorFeatures/CSharpTest/UseObjectInitializer/UseObjectInitializerTests.cs +++ b/src/EditorFeatures/CSharpTest/UseObjectInitializer/UseObjectInitializerTests.cs @@ -324,7 +324,8 @@ void M() void M() { - var v = new C(() => { + var v = new C(() => + { var v2 = new C { i = 1 @@ -364,7 +365,8 @@ void M() { var v = new C { - j = () => { + j = () => + { var v2 = new C { i = 1 diff --git a/src/EditorFeatures/Core/Extensibility/NavigationBar/AbstractNavigationBarItemService.cs b/src/EditorFeatures/Core/Extensibility/NavigationBar/AbstractNavigationBarItemService.cs index 30594104b5b7d..b1f1fda6198e1 100644 --- a/src/EditorFeatures/Core/Extensibility/NavigationBar/AbstractNavigationBarItemService.cs +++ b/src/EditorFeatures/Core/Extensibility/NavigationBar/AbstractNavigationBarItemService.cs @@ -32,7 +32,7 @@ internal abstract class AbstractNavigationBarItemService : INavigationBarItemSer if (symbol != null && !(symbol is ITypeSymbol) && !symbol.IsConstructor() && - symbolNavigationService.TrySymbolNavigationNotify(symbol, document.Project.Solution, cancellationToken)) + symbolNavigationService.TrySymbolNavigationNotify(symbol, document.Project, cancellationToken)) { return; } diff --git a/src/EditorFeatures/Core/FindUsages/AbstractFindUsagesService.ProgressAdapter.cs b/src/EditorFeatures/Core/FindUsages/AbstractFindUsagesService.ProgressAdapter.cs index 2659f08e17b5f..6a915e477a940 100644 --- a/src/EditorFeatures/Core/FindUsages/AbstractFindUsagesService.ProgressAdapter.cs +++ b/src/EditorFeatures/Core/FindUsages/AbstractFindUsagesService.ProgressAdapter.cs @@ -93,7 +93,7 @@ private async Task GetDefinitionItemAsync(SymbolAndProjectId def if (!_definitionToItem.TryGetValue(definition.Symbol, out var definitionItem)) { definitionItem = await definition.Symbol.ToClassifiedDefinitionItemAsync( - _solution, includeHiddenLocations: false, cancellationToken: _context.CancellationToken).ConfigureAwait(false); + _solution.GetProject(definition.ProjectId), includeHiddenLocations: false, cancellationToken: _context.CancellationToken).ConfigureAwait(false); _definitionToItem[definition.Symbol] = definitionItem; } diff --git a/src/EditorFeatures/Core/FindUsages/AbstractFindUsagesService.cs b/src/EditorFeatures/Core/FindUsages/AbstractFindUsagesService.cs index 456bf8cb3bb69..112e722da4615 100644 --- a/src/EditorFeatures/Core/FindUsages/AbstractFindUsagesService.cs +++ b/src/EditorFeatures/Core/FindUsages/AbstractFindUsagesService.cs @@ -44,7 +44,7 @@ internal abstract partial class AbstractFindUsagesService : IFindUsagesService foreach (var implementation in tuple.Value.implementations) { var definitionItem = await implementation.ToClassifiedDefinitionItemAsync( - project.Solution, includeHiddenLocations: false, cancellationToken: cancellationToken).ConfigureAwait(false); + project, includeHiddenLocations: false, cancellationToken: cancellationToken).ConfigureAwait(false); await context.OnDefinitionFoundAsync(definitionItem).ConfigureAwait(false); } } diff --git a/src/EditorFeatures/Core/FindUsages/IDefinitionsAndReferencesFactory.cs b/src/EditorFeatures/Core/FindUsages/IDefinitionsAndReferencesFactory.cs index a5c8d6ef4a1b7..6e5aab5155e0c 100644 --- a/src/EditorFeatures/Core/FindUsages/IDefinitionsAndReferencesFactory.cs +++ b/src/EditorFeatures/Core/FindUsages/IDefinitionsAndReferencesFactory.cs @@ -41,31 +41,31 @@ internal static class DefinitionItemExtensions { public static DefinitionItem ToNonClassifiedDefinitionItem( this ISymbol definition, - Solution solution, + Project project, bool includeHiddenLocations) { // Because we're passing in 'false' for 'includeClassifiedSpans', this won't ever have // to actually do async work. This is because the only asynchrony is when we are trying // to compute the classified spans for the locations of the definition. So it's totally // fine to pass in CancellationToken.None and block on the result. - return ToDefinitionItemAsync(definition, solution, includeHiddenLocations, + return ToDefinitionItemAsync(definition, project, includeHiddenLocations, includeClassifiedSpans: false, cancellationToken: CancellationToken.None).WaitAndGetResult_CanCallOnBackground(CancellationToken.None); } public static Task ToClassifiedDefinitionItemAsync( this ISymbol definition, - Solution solution, + Project project, bool includeHiddenLocations, CancellationToken cancellationToken) { - return ToDefinitionItemAsync(definition, solution, + return ToDefinitionItemAsync(definition, project, includeHiddenLocations, includeClassifiedSpans: true, cancellationToken: cancellationToken); } private static async Task ToDefinitionItemAsync( this ISymbol definition, - Solution solution, + Project project, bool includeHiddenLocations, bool includeClassifiedSpans, CancellationToken cancellationToken) @@ -99,7 +99,7 @@ internal static class DefinitionItemExtensions if (location.IsInMetadata) { return DefinitionItem.CreateMetadataDefinition( - tags, displayParts, nameDisplayParts, solution, + tags, displayParts, nameDisplayParts, project, definition, properties, displayIfNoReferences); } else if (location.IsInSource) @@ -110,7 +110,7 @@ internal static class DefinitionItemExtensions continue; } - var document = solution.GetDocument(location.SourceTree); + var document = project.Solution.GetDocument(location.SourceTree); if (document != null) { var documentLocation = !includeClassifiedSpans diff --git a/src/EditorFeatures/Core/GoToDefinition/GoToDefinitionHelpers.cs b/src/EditorFeatures/Core/GoToDefinition/GoToDefinitionHelpers.cs index 3cbbf9004d3fd..db07d3584e0ea 100644 --- a/src/EditorFeatures/Core/GoToDefinition/GoToDefinitionHelpers.cs +++ b/src/EditorFeatures/Core/GoToDefinition/GoToDefinitionHelpers.cs @@ -82,7 +82,7 @@ internal static class GoToDefinitionHelpers // So, if we only have a single location to go to, this does no unnecessary work. And, // if we do have multiple locations to show, it will just be done in the BG, unblocking // this command thread so it can return the user faster. - var definitionItem = symbol.ToNonClassifiedDefinitionItem(solution, includeHiddenLocations: true); + var definitionItem = symbol.ToNonClassifiedDefinitionItem(project, includeHiddenLocations: true); if (thirdPartyNavigationAllowed) { diff --git a/src/EditorFeatures/Core/Implementation/Peek/PeekableItemFactory.cs b/src/EditorFeatures/Core/Implementation/Peek/PeekableItemFactory.cs index 9379dadc6a774..03fa2bde7f8e8 100644 --- a/src/EditorFeatures/Core/Implementation/Peek/PeekableItemFactory.cs +++ b/src/EditorFeatures/Core/Implementation/Peek/PeekableItemFactory.cs @@ -60,7 +60,7 @@ private PeekableItemFactory(IMetadataAsSourceFileService metadataAsSourceFileSer } var symbolNavigationService = solution.Workspace.Services.GetService(); - var definitionItem = symbol.ToNonClassifiedDefinitionItem(solution, includeHiddenLocations: true); + var definitionItem = symbol.ToNonClassifiedDefinitionItem(project, includeHiddenLocations: true); if (symbolNavigationService.WouldNavigateToSymbol( definitionItem, solution, cancellationToken, diff --git a/src/EditorFeatures/Test/CodeGeneration/CodeGenerationTests.CSharp.cs b/src/EditorFeatures/Test/CodeGeneration/CodeGenerationTests.CSharp.cs index c71b85d5041ee..942fe65bd8e96 100644 --- a/src/EditorFeatures/Test/CodeGeneration/CodeGenerationTests.CSharp.cs +++ b/src/EditorFeatures/Test/CodeGeneration/CodeGenerationTests.CSharp.cs @@ -26,7 +26,11 @@ public class CSharp public async Task AddNamespace() { var input = "namespace [|N1|] { }"; - var expected = "namespace N1 { namespace N2 { } }"; + var expected = @"namespace N1 { + namespace N2 + { + } +}"; await TestAddNamespaceAsync(input, expected, name: "N2"); } @@ -35,7 +39,10 @@ public async Task AddNamespace() public async Task AddField() { var input = "class [|C|] { }"; - var expected = "class C { public int F; }"; + var expected = @"class C +{ + public int F; +}"; await TestAddFieldAsync(input, expected, type: GetTypeSymbol(typeof(int))); } @@ -44,7 +51,10 @@ public async Task AddField() public async Task AddStaticField() { var input = "class [|C|] { }"; - var expected = "class C { private static string F; }"; + var expected = @"class C +{ + private static string F; +}"; await TestAddFieldAsync(input, expected, type: GetTypeSymbol(typeof(string)), accessibility: Accessibility.Private, @@ -55,7 +65,10 @@ public async Task AddStaticField() public async Task AddArrayField() { var input = "class [|C|] { }"; - var expected = "class C { public int[] F; }"; + var expected = @"class C +{ + public int[] F; +}"; await TestAddFieldAsync(input, expected, type: CreateArrayType(typeof(int))); } @@ -64,7 +77,10 @@ public async Task AddArrayField() public async Task AddUnsafeField() { var input = "class [|C|] { }"; - var expected = "class C { public unsafe int F; }"; + var expected = @"class C +{ + public unsafe int F; +}"; await TestAddFieldAsync(input, expected, modifiers: new Editing.DeclarationModifiers(isUnsafe: true), type: GetTypeSymbol(typeof(int))); @@ -74,7 +90,7 @@ public async Task AddUnsafeField() public async Task AddFieldToCompilationUnit() { var input = ""; - var expected = "public int F;"; + var expected = "public int F;\n"; await TestAddFieldAsync(input, expected, type: GetTypeSymbol(typeof(int)), addToCompilationUnit: true); } @@ -83,7 +99,12 @@ public async Task AddFieldToCompilationUnit() public async Task AddConstructor() { var input = "class [|C|] { }"; - var expected = "class C { public C() { } }"; + var expected = @"class C +{ + public C() + { + } +}"; await TestAddConstructorAsync(input, expected); } @@ -91,7 +112,10 @@ public async Task AddConstructor() public async Task AddConstructorWithoutBody() { var input = "class [|C|] { }"; - var expected = "class C { public C(); }"; + var expected = @"class C +{ + public C(); +}"; await TestAddConstructorAsync(input, expected, codeGenerationOptions: new CodeGenerationOptions(generateMethodBodies: false)); } @@ -100,7 +124,14 @@ public async Task AddConstructorWithoutBody() public async Task AddConstructorResolveNamespaceImport() { var input = "class [|C|] { }"; - var expected = "using System; class C { public C(DateTime dt, int i) { } }"; + var expected = @"using System; + +class C +{ + public C(DateTime dt, int i) + { + } +}"; await TestAddConstructorAsync(input, expected, parameters: Parameters(Parameter(typeof(DateTime), "dt"), Parameter(typeof(int), "i"))); } @@ -118,7 +149,12 @@ public async Task AddChainedConstructor() public async Task AddStaticConstructor() { var input = "class [|C|] { }"; - var expected = "class C { static C() { } }"; + var expected = @"class C +{ + static C() + { + } +}"; await TestAddConstructorAsync(input, expected, modifiers: new Editing.DeclarationModifiers(isStatic: true)); } @@ -141,7 +177,12 @@ public class C public async Task AddClassEscapeName() { var input = "namespace [|N|] { }"; - var expected = "namespace N { public class @class { } }"; + var expected = @"namespace N +{ + public class @class + { + } +}"; await TestAddNamedTypeAsync(input, expected, name: "class"); } @@ -150,16 +191,26 @@ public async Task AddClassEscapeName() public async Task AddClassUnicodeName() { var input = "namespace [|N|] { }"; - var expected = "namespace N { public class class\u00E6\u00F8\u00E5 { } }"; + var expected = @"namespace N +{ + public class classæøå + { + } +}"; await TestAddNamedTypeAsync(input, expected, - name: "cl\u0061ss\u00E6\u00F8\u00E5"); + name: "classæøå"); } [Fact, Trait(Traits.Feature, Traits.Features.CodeGeneration), WorkItem(544405, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544405")] public async Task AddStaticClass() { var input = "namespace [|N|] { }"; - var expected = "namespace N { public static class C { } }"; + var expected = @"namespace N +{ + public static class C + { + } +}"; await TestAddNamedTypeAsync(input, expected, modifiers: new Editing.DeclarationModifiers(isStatic: true)); } @@ -168,7 +219,12 @@ public async Task AddStaticClass() public async Task AddSealedClass() { var input = "namespace [|N|] { }"; - var expected = "namespace N { private sealed class C { } }"; + var expected = @"namespace N +{ + private sealed class C + { + } +}"; await TestAddNamedTypeAsync(input, expected, accessibility: Accessibility.Private, modifiers: new Editing.DeclarationModifiers(isSealed: true)); @@ -178,7 +234,12 @@ public async Task AddSealedClass() public async Task AddAbstractClass() { var input = "namespace [|N|] { }"; - var expected = "namespace N { protected internal abstract class C { } }"; + var expected = @"namespace N +{ + protected internal abstract class C + { + } +}"; await TestAddNamedTypeAsync(input, expected, accessibility: Accessibility.ProtectedOrInternal, modifiers: new Editing.DeclarationModifiers(isAbstract: true)); @@ -188,7 +249,12 @@ public async Task AddAbstractClass() public async Task AddStruct() { var input = "namespace [|N|] { }"; - var expected = "namespace N { internal struct S { } }"; + var expected = @"namespace N +{ + internal struct S + { + } +}"; await TestAddNamedTypeAsync(input, expected, name: "S", accessibility: Accessibility.Internal, @@ -199,7 +265,12 @@ public async Task AddStruct() public async Task AddSealedStruct() { var input = "namespace [|N|] { }"; - var expected = "namespace N { public struct S { } }"; + var expected = @"namespace N +{ + public struct S + { + } +}"; await TestAddNamedTypeAsync(input, expected, name: "S", modifiers: new Editing.DeclarationModifiers(isSealed: true), @@ -211,7 +282,12 @@ public async Task AddSealedStruct() public async Task AddInterface() { var input = "namespace [|N|] { }"; - var expected = "namespace N { public interface I { } }"; + var expected = @"namespace N +{ + public interface I + { + } +}"; await TestAddNamedTypeAsync(input, expected, name: "I", typeKind: TypeKind.Interface); @@ -221,7 +297,12 @@ public async Task AddInterface() public async Task AddEnum() { var input = "namespace [|N|] { }"; - var expected = "namespace N { public enum E { } }"; + var expected = @"namespace N +{ + public enum E + { + } +}"; await TestAddNamedTypeAsync(input, expected, "E", typeKind: TypeKind.Enum); } @@ -230,7 +311,14 @@ public async Task AddEnum() public async Task AddEnumWithValues() { var input = "namespace [|N|] { }"; - var expected = "namespace N { public enum E { F1 = 1, F2 = 2 } }"; + var expected = @"namespace N +{ + public enum E + { + F1 = 1, + F2 = 2 + } +}"; await TestAddNamedTypeAsync(input, expected, "E", typeKind: TypeKind.Enum, members: Members(CreateEnumField("F1", 1), CreateEnumField("F2", 2))); @@ -240,7 +328,10 @@ public async Task AddEnumWithValues() public async Task AddDelegateType() { var input = "class [|C|] { }"; - var expected = "class C { public delegate int D(string s); }"; + var expected = @"class C +{ + public delegate int D(string s); +}"; await TestAddDelegateTypeAsync(input, expected, returnType: typeof(int), parameters: Parameters(Parameter(typeof(string), "s"))); @@ -250,7 +341,10 @@ public async Task AddDelegateType() public async Task AddSealedDelegateType() { var input = "class [|C|] { }"; - var expected = "class C { public delegate int D(string s); }"; + var expected = @"class C +{ + public delegate int D(string s); +}"; await TestAddDelegateTypeAsync(input, expected, returnType: typeof(int), parameters: Parameters(Parameter(typeof(string), "s")), @@ -261,7 +355,10 @@ public async Task AddSealedDelegateType() public async Task AddEvent() { var input = "class [|C|] { }"; - var expected = "class C { public event System.Action E; }"; + var expected = @"class C +{ + public event System.Action E; +}"; await TestAddEventAsync(input, expected, codeGenerationOptions: new CodeGenerationOptions(addImports: false)); } @@ -270,7 +367,10 @@ public async Task AddEvent() public async Task AddUnsafeEvent() { var input = "class [|C|] { }"; - var expected = "class C { public unsafe event System.Action E; }"; + var expected = @"class C +{ + public unsafe event System.Action E; +}"; await TestAddEventAsync(input, expected, modifiers: new Editing.DeclarationModifiers(isUnsafe: true), codeGenerationOptions: new CodeGenerationOptions(addImports: false)); @@ -280,7 +380,19 @@ public async Task AddUnsafeEvent() public async Task AddEventWithAccessors() { var input = "class [|C|] { }"; - var expected = "class C { public event System.Action E { add { } remove { } } }"; + var expected = @"class C +{ + public event System.Action E + { + add + { + } + + remove + { + } + } +}"; await TestAddEventAsync(input, expected, addMethod: CodeGenerationSymbolFactory.CreateAccessorSymbol(ImmutableArray.Empty, Accessibility.NotApplicable, ImmutableArray.Empty), removeMethod: CodeGenerationSymbolFactory.CreateAccessorSymbol(ImmutableArray.Empty, Accessibility.NotApplicable, ImmutableArray.Empty), @@ -291,7 +403,12 @@ public async Task AddEventWithAccessors() public async Task AddMethodToClass() { var input = "class [|C|] { }"; - var expected = "class C { public void M() { } }"; + var expected = @"class C +{ + public void M() + { + } +}"; await TestAddMethodAsync(input, expected, returnType: typeof(void)); } @@ -300,7 +417,14 @@ public async Task AddMethodToClass() public async Task AddMethodToClassEscapedName() { var input = "class [|C|] { }"; - var expected = "using System; class C { public DateTime @static() { } }"; + var expected = @"using System; + +class C +{ + public DateTime @static() + { + } +}"; await TestAddMethodAsync(input, expected, name: "static", returnType: typeof(DateTime)); @@ -310,7 +434,13 @@ public async Task AddMethodToClassEscapedName() public async Task AddStaticMethodToStruct() { var input = "struct [|S|] { }"; - var expected = "struct S { public static int M() { $$ } }"; + var expected = @"struct S +{ + public static int M() + { + $$ + } +}"; await TestAddMethodAsync(input, expected, modifiers: new Editing.DeclarationModifiers(isStatic: true), returnType: typeof(int), @@ -321,7 +451,13 @@ public async Task AddStaticMethodToStruct() public async Task AddSealedOverrideMethod() { var input = "class [|C|] { }"; - var expected = "class C { public sealed override int GetHashCode() { $$ } }"; + var expected = @"class C +{ + public sealed override int GetHashCode() + { + $$ + } +}"; await TestAddMethodAsync(input, expected, name: "GetHashCode", modifiers: new Editing.DeclarationModifiers(isOverride: true, isSealed: true), @@ -333,7 +469,10 @@ public async Task AddSealedOverrideMethod() public async Task AddAbstractMethod() { var input = "abstract class [|C|] { }"; - var expected = "abstract class C { public abstract int M(); }"; + var expected = @"abstract class C +{ + public abstract int M(); +}"; await TestAddMethodAsync(input, expected, modifiers: new Editing.DeclarationModifiers(isAbstract: true), returnType: typeof(int)); @@ -343,7 +482,10 @@ public async Task AddAbstractMethod() public async Task AddMethodWithoutBody() { var input = "class [|C|] { }"; - var expected = "class C { public int M(); }"; + var expected = @"class C +{ + public int M(); +}"; await TestAddMethodAsync(input, expected, returnType: typeof(int), codeGenerationOptions: new CodeGenerationOptions(generateMethodBodies: false)); @@ -353,7 +495,13 @@ public async Task AddMethodWithoutBody() public async Task AddGenericMethod() { var input = "class [|C|] { }"; - var expected = "class C { public int M() { $$ } }"; + var expected = @"class C +{ + public int M() + { + $$ + } +}"; await TestAddMethodAsync(input, expected, returnType: typeof(int), typeParameters: ImmutableArray.Create(CodeGenerationSymbolFactory.CreateTypeParameterSymbol("T")), @@ -364,7 +512,13 @@ public async Task AddGenericMethod() public async Task AddVirtualMethod() { var input = "class [|C|] { }"; - var expected = "class C { protected virtual int M() { $$ } }"; + var expected = @"class C +{ + protected virtual int M() + { + $$ + } +}"; await TestAddMethodAsync(input, expected, accessibility: Accessibility.Protected, modifiers: new Editing.DeclarationModifiers(isVirtual: true), @@ -376,7 +530,13 @@ public async Task AddVirtualMethod() public async Task AddUnsafeNewMethod() { var input = "class [|C|] { }"; - var expected = "class C { public unsafe new string ToString() { $$ } }"; + var expected = @"class C +{ + public unsafe new string ToString() + { + $$ + } +}"; await TestAddMethodAsync(input, expected, name: "ToString", modifiers: new Editing.DeclarationModifiers(isNew: true, isUnsafe: true), @@ -388,7 +548,13 @@ public async Task AddUnsafeNewMethod() public async Task AddExplicitImplementationOfUnsafeMethod() { var input = "interface I { unsafe void M(int i); } class [|C|] : I { }"; - var expected = "interface I { unsafe void M(int i); } class C : I { unsafe void I.M(int i) { } }"; + var expected = @"interface I { unsafe void M(int i); } +class C : I +{ + unsafe void I.M(int i) + { + } +}"; await TestAddMethodAsync(input, expected, name: "M", returnType: typeof(void), @@ -401,7 +567,13 @@ public async Task AddExplicitImplementationOfUnsafeMethod() public async Task AddExplicitImplementation() { var input = "interface I { void M(int i); } class [|C|] : I { }"; - var expected = "interface I { void M(int i); } class C : I { void I.M(int i) { } }"; + var expected = @"interface I { void M(int i); } +class C : I +{ + void I.M(int i) + { + } +}"; await TestAddMethodAsync(input, expected, name: "M", returnType: typeof(void), @@ -419,10 +591,16 @@ class [|C|] var expected = @" class C { - public static bool operator true (C other) { $$ } - public static bool operator false (C other) { $$ } -} -"; + public static bool operator true(C other) + { + $$ + } + + public static bool operator false(C other) + { + $$ + } +}"; await TestAddOperatorsAsync(input, expected, new[] { CodeGenerationOperatorKind.True, CodeGenerationOperatorKind.False }, parameters: Parameters(Parameter("C", "other")), @@ -440,12 +618,35 @@ class [|C|] var expected = @" class C { - public static object operator + (C other) { $$ } - public static object operator - (C other) { $$ } - public static object operator ! (C other) { $$ } - public static object operator ~ (C other) { $$ } - public static object operator ++ (C other) { $$ } - public static object operator -- (C other) { $$ } + public static object operator +(C other) + { + $$ + } + + public static object operator -(C other) + { + $$ + } + + public static object operator !(C other) + { + $$ + } + + public static object operator ~(C other) + { + $$ + } + + public static object operator ++(C other) + { + $$ + } + + public static object operator --(C other) + { + $$ + } }"; await TestAddOperatorsAsync(input, expected, new[] @@ -472,16 +673,55 @@ class [|C|] var expected = @" class C { - public static object operator + (C a, C b) { $$ } - public static object operator - (C a, C b) { $$ } - public static object operator * (C a, C b) { $$ } - public static object operator / (C a, C b) { $$ } - public static object operator % (C a, C b) { $$ } - public static object operator & (C a, C b) { $$ } - public static object operator | (C a, C b) { $$ } - public static object operator ^ (C a, C b) { $$ } - public static object operator << (C a, C b) { $$ } - public static object operator >> (C a, C b) { $$ } + public static object operator +(C a, C b) + { + $$ + } + + public static object operator -(C a, C b) + { + $$ + } + + public static object operator *(C a, C b) + { + $$ + } + + public static object operator /(C a, C b) + { + $$ + } + + public static object operator %(C a, C b) + { + $$ + } + + public static object operator &(C a, C b) + { + $$ + } + + public static object operator |(C a, C b) + { + $$ + } + + public static object operator ^(C a, C b) + { + $$ + } + + public static object operator <<(C a, C b) + { + $$ + } + + public static object operator >>(C a, C b) + { + $$ + } }"; await TestAddOperatorsAsync(input, expected, new[] @@ -512,12 +752,35 @@ class [|C|] var expected = @" class C { - public static bool operator == (C a, C b) { $$ } - public static bool operator != (C a, C b) { $$ } - public static bool operator < (C a, C b) { $$ } - public static bool operator > (C a, C b) { $$ } - public static bool operator <= (C a, C b) { $$ } - public static bool operator >= (C a, C b) { $$ } + public static bool operator ==(C a, C b) + { + $$ + } + + public static bool operator !=(C a, C b) + { + $$ + } + + public static bool operator <(C a, C b) + { + $$ + } + + public static bool operator >(C a, C b) + { + $$ + } + + public static bool operator <=(C a, C b) + { + $$ + } + + public static bool operator >=(C a, C b) + { + $$ + } }"; await TestAddOperatorsAsync(input, expected, new[] @@ -549,7 +812,13 @@ public async Task AddUnsupportedOperator() public async Task AddExplicitConversion() { var input = @"class [|C|] { }"; - var expected = @"class C { public static explicit operator int(C other) { $$ } }"; + var expected = @"class C +{ + public static explicit operator int(C other) + { + $$ + } +}"; await TestAddConversionAsync(input, expected, toType: typeof(int), fromType: Parameter("C", "other"), @@ -560,7 +829,13 @@ public async Task AddExplicitConversion() public async Task AddImplicitConversion() { var input = @"class [|C|] { }"; - var expected = @"class C { public static implicit operator int(C other) { $$ } }"; + var expected = @"class C +{ + public static implicit operator int(C other) + { + $$ + } +}"; await TestAddConversionAsync(input, expected, toType: typeof(int), fromType: Parameter("C", "other"), @@ -572,7 +847,7 @@ public async Task AddImplicitConversion() public async Task AddStatements() { var input = "class C { public void [|M|]() { Console.WriteLine(1); } }"; - var expected = "class C { public void M() { Console.WriteLine(1); $$ } }"; + var expected = "class C { public void M() { Console.WriteLine(1); $$} }"; await TestAddStatementsAsync(input, expected, "Console.WriteLine(2);"); } @@ -581,7 +856,7 @@ public async Task AddStatements() public async Task AddDefaultParameterWithNonDefaultValueToMethod() { var input = "class C { public void [|M|]() { } }"; - var expected = "class C { public void M(string text = \"Hello\") { } }"; + var expected = "class C { public void M(string text =\"Hello\") { } }"; await TestAddParametersAsync(input, expected, Parameters(Parameter(typeof(string), "text", true, "Hello"))); } @@ -590,7 +865,7 @@ public async Task AddDefaultParameterWithNonDefaultValueToMethod() public async Task AddDefaultParameterWithDefaultValueToMethod() { var input = "class C { public void [|M|]() { } }"; - var expected = "class C { public void M(double number = 0) { } }"; + var expected = "class C { public void M(double number =0) { } }"; await TestAddParametersAsync(input, expected, Parameters(Parameter(typeof(double), "number", true))); } @@ -599,7 +874,7 @@ public async Task AddDefaultParameterWithDefaultValueToMethod() public async Task AddParametersToMethod() { var input = "class C { public void [|M|]() { } }"; - var expected = "class C { public void M(int num, string text =\"Hello!\", float floating = 0.5F) { } }"; + var expected = "class C { public void M(int num, string text =\"Hello!\", float floating =0.5F) { } }"; await TestAddParametersAsync(input, expected, Parameters(Parameter(typeof(int), "num"), Parameter(typeof(string), "text", true, "Hello!"), Parameter(typeof(float), "floating", true, .5f))); } @@ -609,7 +884,7 @@ public async Task AddParametersToMethod() public async Task AddParamsParameterToMethod() { var input = "class C { public void [|M|]() { } }"; - var expected = "class C { public void M(params char[] characters) { } }"; + var expected = "class C { public void M(params char[]characters) { } }"; await TestAddParametersAsync(input, expected, Parameters(Parameter(typeof(char[]), "characters", isParams: true))); } @@ -618,7 +893,10 @@ public async Task AddParamsParameterToMethod() public async Task AddAutoProperty() { var input = "class [|C|] { }"; - var expected = "class C { public int P { get; internal set; } }"; + var expected = @"class C +{ + public int P { get; internal set; } +}"; await TestAddPropertyAsync(input, expected, type: typeof(int), setterAccessibility: Accessibility.Internal); @@ -628,7 +906,10 @@ public async Task AddAutoProperty() public async Task AddUnsafeAutoProperty() { var input = "class [|C|] { }"; - var expected = "class C { public unsafe int P { get; internal set; } }"; + var expected = @"class C +{ + public unsafe int P { get; internal set; } +}"; await TestAddPropertyAsync(input, expected, type: typeof(int), modifiers: new Editing.DeclarationModifiers(isUnsafe: true), @@ -652,7 +933,16 @@ public async Task AddIndexer1() public async Task AddIndexer2() { var input = "class [|C|] { }"; - var expected = "class C { public string this[int i] { get { $$ } } }"; + var expected = @"class C +{ + public string this[int i] + { + get + { + $$ + } + } +}"; await TestAddPropertyAsync(input, expected, type: typeof(string), parameters: Parameters(Parameter(typeof(int), "i")), @@ -668,7 +958,17 @@ public async Task AddIndexer2() public async Task AddParameterfulProperty() { var input = "class [|C|] { }"; - var expected = "class C { public string get_P(int i, int j) { $$ } public void set_P(int i, int j, string value) { } }"; + var expected = @"class C +{ + public string get_P(int i, int j) + { + $$ + } + + public void set_P(int i, int j, string value) + { + } +}"; await TestAddPropertyAsync(input, expected, type: typeof(string), getStatements: "return String.Empty;", @@ -680,7 +980,8 @@ public async Task AddParameterfulProperty() public async Task AddAttributeToTypes() { var input = "class [|C|] { }"; - var expected = "[System.Serializable] class C { }"; + var expected = @"[System.Serializable] +class C { }"; await TestAddAttributeAsync(input, expected, typeof(SerializableAttribute)); } @@ -696,7 +997,7 @@ public async Task RemoveAttributeFromTypes() public async Task AddAttributeToMethods() { var input = "class C { public void [|M()|] { } }"; - var expected = "class C { [System.Serializable] public void M() { } }"; + var expected = "class C {[System.Serializable] public void M() { } }"; await TestAddAttributeAsync(input, expected, typeof(SerializableAttribute)); } @@ -712,7 +1013,7 @@ public async Task RemoveAttributeFromMethods() public async Task AddAttributeToFields() { var input = "class C { [|public int F|]; }"; - var expected = "class C { [System.Serializable] public int F; }"; + var expected = "class C {[System.Serializable] public int F; }"; await TestAddAttributeAsync(input, expected, typeof(SerializableAttribute)); } @@ -728,7 +1029,7 @@ public async Task RemoveAttributeFromFields() public async Task AddAttributeToProperties() { var input = "class C { public int [|P|] { get; set; }}"; - var expected = "class C { [System.Serializable] public int P { get; set; } }"; + var expected = "class C {[System.Serializable] public int P { get; set; } }"; await TestAddAttributeAsync(input, expected, typeof(SerializableAttribute)); } @@ -744,7 +1045,7 @@ public async Task RemoveAttributeFromProperties() public async Task AddAttributeToPropertyAccessor() { var input = "class C { public int P { [|get|]; set; }}"; - var expected = "class C { public int P { [System.Serializable] get; set; } }"; + var expected = "class C { public int P { [System.Serializable] get; set; }}"; await TestAddAttributeAsync(input, expected, typeof(SerializableAttribute)); } @@ -760,7 +1061,8 @@ public async Task RemoveAttributeFromPropertyAccessor() public async Task AddAttributeToEnums() { var input = "enum [|C|] { One, Two }"; - var expected = "[System.Serializable] enum C { One, Two }"; + var expected = @"[System.Serializable] +enum C { One, Two }"; await TestAddAttributeAsync(input, expected, typeof(SerializableAttribute)); } @@ -776,7 +1078,7 @@ public async Task RemoveAttributeFromEnums() public async Task AddAttributeToEnumMembers() { var input = "enum C { [|One|], Two }"; - var expected = "enum C { [System.Serializable] One, Two }"; + var expected = "enum C {[System.Serializable] One, Two }"; await TestAddAttributeAsync(input, expected, typeof(SerializableAttribute)); } @@ -792,7 +1094,7 @@ public async Task RemoveAttributeFromEnumMembers() public async Task AddAttributeToIndexer() { var input = "class C { public int [|this[int y]|] { get; set; }}"; - var expected = "class C { [System.Serializable] public int this[int y] { get; set; } }"; + var expected = "class C {[System.Serializable] public int this[int y] { get; set; } }"; await TestAddAttributeAsync(input, expected, typeof(SerializableAttribute)); } @@ -808,7 +1110,7 @@ public async Task RemoveAttributeFromIndexer() public async Task AddAttributeToOperator() { var input = "class C { public static C operator [|+|] (C c1, C c2) { return new C(); }}"; - var expected = "class C { [System.Serializable] public static C operator + (C c1, C c2) { return new C(); } }"; + var expected = "class C {[System.Serializable] public static C operator +(C c1, C c2) { return new C(); } }"; await TestAddAttributeAsync(input, expected, typeof(SerializableAttribute)); } @@ -824,7 +1126,8 @@ public async Task RemoveAttributeFromOperator() public async Task AddAttributeToDelegate() { var input = "delegate int [|D()|];"; - var expected = "[System.Serializable] delegate int D();"; + var expected = @"[System.Serializable] +delegate int D();"; await TestAddAttributeAsync(input, expected, typeof(SerializableAttribute)); } @@ -872,7 +1175,10 @@ public async Task RemoveAttributeFromTypeParam() public async Task AddAttributeToCompilationUnit() { var input = "[|class C { } class D {} |]"; - var expected = "[assembly: System.Serializable] class C{ } class D {}"; + var expected = @"[assembly: System.Serializable] + +class C { } +class D { }"; await TestAddAttributeAsync(input, expected, typeof(SerializableAttribute), SyntaxFactory.Token(SyntaxKind.AssemblyKeyword)); } @@ -1048,12 +1354,23 @@ public async Task SortAroundDestructor() { var generationSource = "public class [|C|] { public C(){} public int this[int index]{get{return 0;}set{value = 0;}} }"; var initial = "public class [|C|] { ~C(){} }"; - var expected = @" -public class C -{ - public C(){} + var expected = @"public class C { + public C() + { + } + ~C(){} - public int this[int index] { get{} set{} } + + public int this[int index] + { + get + { + } + + set + { + } + } }"; await TestGenerateFromSourceSymbolAsync(generationSource, initial, expected, onlyGenerateMembers: true); } @@ -1098,8 +1415,7 @@ public class [|C|] } }"; var initial = "namespace [|N|] { }"; - var expected = @" -namespace N + var expected = @"namespace N { public class C { @@ -1145,12 +1461,10 @@ public static class [|C|] public static void ExtMethod1(this string s, int y, string z) {} }"; var initial = "public static class [|C|] {}"; - var expected = @" -public static class C + var expected = @"public static class C { public static void ExtMethod1(this string s, int y, string z); -} -"; +}"; await TestGenerateFromSourceSymbolAsync(generationSource, initial, expected, codeGenerationOptions: new CodeGenerationOptions(generateMethodBodies: false), onlyGenerateMembers: true); @@ -1175,16 +1489,14 @@ End Namespace "; var initial = "namespace [|N|] {}"; - var expected = @" -namespace N -{ - public class C - { - public virtual string get_IndexProp ( int p1 ) ; - public virtual void set_IndexProp ( int p1 , string value ) ; - } -} -"; + var expected = @"namespace N +{ + public class C + { + public virtual string get_IndexProp(int p1); + public virtual void set_IndexProp(int p1, string value); + } +}"; await TestGenerateFromSourceSymbolAsync(generationSource, initial, expected, codeGenerationOptions: new CodeGenerationOptions(generateMethodBodies: false)); } @@ -1199,12 +1511,10 @@ public async Task TestRefParamsWithDefaultValue() End Sub End Class"; var initial = "public class [|C|] {}"; - var expected = @" -public class C + var expected = @"public class C { public void Goo(int x, ref int y, ref object z); -} -"; +}"; await TestGenerateFromSourceSymbolAsync(generationSource, initial, expected, codeGenerationOptions: new CodeGenerationOptions(generateMethodBodies: false), onlyGenerateMembers: true); @@ -1225,16 +1535,21 @@ public class [|C|] where T : struct where U : class } "; var initial = "namespace [|N|] {}"; - var expected = @" -namespace N + var expected = @"namespace N { - public class C where T : struct where U : class + public class C + where T : struct + where U : class { - public void Goo() where Q : new() where R : IComparable; - public delegate void D(T t, U u) where T : struct where U : class; + public void Goo() + where Q : new() + where R : IComparable; + + public delegate void D(T t, U u) + where T : struct + where U : class; } -} -"; +}"; await TestGenerateFromSourceSymbolAsync(generationSource, initial, expected, codeGenerationOptions: new CodeGenerationOptions(generateMethodBodies: false), onlyGenerateMembers: true); diff --git a/src/EditorFeatures/Test/CodeGeneration/CodeGenerationTests.Shared.cs b/src/EditorFeatures/Test/CodeGeneration/CodeGenerationTests.Shared.cs index f225261e61502..75f15f5334592 100644 --- a/src/EditorFeatures/Test/CodeGeneration/CodeGenerationTests.Shared.cs +++ b/src/EditorFeatures/Test/CodeGeneration/CodeGenerationTests.Shared.cs @@ -129,8 +129,7 @@ public interface IGeneric { } public string FAccessE; } }"; - var expected = @" -namespace N + var expected = @"namespace N { public class C { @@ -343,8 +342,7 @@ private class CAccessA forceLanguage: LanguageNames.CSharp); initial = "Namespace [|N|] \n End Namespace"; - expected = @" -Namespace N + expected = @"Namespace N Public Class C Public Const FConst As String Public Shared FStatic As String @@ -516,9 +514,7 @@ public async Task TestSortingDefaultTypeMemberAccessibility1() { var generationSource = "public class [|C|] { private string B; public string C; }"; var initial = "public class [|C|] { string A; }"; - var expected = @" -public class C -{ + var expected = @"public class C { public string C; string A; private string B; @@ -526,9 +522,7 @@ public class C await TestGenerateFromSourceSymbolAsync(generationSource, initial, expected, onlyGenerateMembers: true); initial = "public struct [|S|] { string A; }"; - expected = @" -public struct S -{ + expected = @"public struct S { public string C; string A; private string B; @@ -536,8 +530,7 @@ public struct S await TestGenerateFromSourceSymbolAsync(generationSource, initial, expected, onlyGenerateMembers: true); initial = "Public Class [|C|] \n Dim A As String \n End Class"; - expected = @" -Public Class C + expected = @"Public Class C Public C As String Dim A As String Private B As String @@ -545,8 +538,7 @@ public struct S await TestGenerateFromSourceSymbolAsync(generationSource, initial, expected, onlyGenerateMembers: true); initial = "Public Module [|M|] \n Dim A As String \n End Module"; - expected = @" -Public Module M + expected = @"Public Module M Public C As String Dim A As String Private B As String @@ -554,9 +546,8 @@ public struct S await TestGenerateFromSourceSymbolAsync(generationSource, initial, expected, onlyGenerateMembers: true); initial = "Public Structure [|S|] \n Dim A As String \n End Structure"; - expected = @" -Public Structure S - Dim A As String + expected = @"Public Structure S + Dim A As String Public C As String Private B As String End Structure"; @@ -568,43 +559,41 @@ public async Task TestDefaultTypeMemberAccessibility2() { var generationSource = "public class [|C|] { private void B(){} public void C(){} }"; var initial = "public interface [|I|] { void A(); }"; - var expected = @" -public interface I -{ - void A(); + var expected = @"public interface I { void A(); void B(); void C(); }"; await TestGenerateFromSourceSymbolAsync(generationSource, initial, expected, onlyGenerateMembers: true); initial = "Public Interface [|I|] \n Sub A() \n End Interface"; - expected = @" -Public Interface I - Sub A() + expected = @"Public Interface I + Sub A() Sub B() Sub C() End Interface"; await TestGenerateFromSourceSymbolAsync(generationSource, initial, expected, onlyGenerateMembers: true); initial = "Public Class [|C|] \n Sub A() \n End Sub \n End Class"; - expected = @" -Public Class C - Sub A() - End Sub + expected = @"Public Class C + Sub A() + End Sub + Public Sub C() End Sub + Private Sub B() End Sub End Class"; await TestGenerateFromSourceSymbolAsync(generationSource, initial, expected, onlyGenerateMembers: true); initial = "Public Module [|M|] \n Sub A() \n End Sub \n End Module"; - expected = @" -Public Module M - Sub A() - End Sub + expected = @"Public Module M + Sub A() + End Sub + Public Sub C() End Sub + Private Sub B() End Sub End Module"; @@ -616,11 +605,22 @@ public async Task TestDefaultNamespaceMemberAccessibility1() { var generationSource = "internal class [|B|]{}"; var initial = "namespace [|N|] { class A{} }"; - var expected = "namespace N { class A{} internal class B{} }"; + var expected = @"namespace N { class A{} + + internal class B + { + } +}"; await TestGenerateFromSourceSymbolAsync(generationSource, initial, expected); initial = "Namespace [|N|] \n Class A \n End Class \n End Namespace"; - expected = "Namespace N \n Class A \n End Class \n Friend Class B \n End Class \n End Namespace"; + expected = @"Namespace N + Class A + End Class + + Friend Class B + End Class +End Namespace"; await TestGenerateFromSourceSymbolAsync(generationSource, initial, expected); } @@ -629,11 +629,17 @@ public async Task TestDefaultNamespaceMemberAccessibility2() { var generationSource = "public class [|C|]{}"; var initial = "namespace [|N|] { class A{} }"; - var expected = "namespace N { public class C{} class A{} }"; + var expected = "namespace N { public class C { } class A{} }"; await TestGenerateFromSourceSymbolAsync(generationSource, initial, expected); initial = "Namespace [|N|] \n Class A \n End Class \n End Namespace"; - expected = "Namespace N \n Public Class C \n End Class \n Class A \n End Class \n End Namespace"; + expected = @"Namespace N + Public Class C + End Class + + Class A + End Class + End Namespace"; await TestGenerateFromSourceSymbolAsync(generationSource, initial, expected); } @@ -647,10 +653,13 @@ public class [|C|] public C() { } }"; var initial = "public class [|C|] { }"; - var expected = @" -public class C + var expected = @"public class C { - /// When in need, a documented method is a friend, indeed. + /// + /// + /// When in need, a documented method is a friend, indeed. + /// + /// public C(); }"; await TestGenerateFromSourceSymbolAsync(generationSource, initial, expected, @@ -681,48 +690,43 @@ public class C }"; var initial = "namespace [|N|] { }"; - var expected = @" -namespace N -{ -namespace N -{ - public class A + var expected = @"namespace N { + namespace N { - public static abstract string Property1 { get; } - public virtual string Property { get; } + public class A + { + public static abstract string Property1 { get; } + public virtual string Property { get; } - public abstract static void Method2(); - public virtual void Method1(); - } + public abstract static void Method2(); + public virtual void Method1(); + } - public class C - { - public sealed override string Property { get; } - public sealed override void Method1(); + public class C + { + public sealed override string Property { get; } + + public sealed override void Method1(); + } } -} -} -"; +}"; await TestGenerateFromSourceSymbolAsync(generationSource, initial, expected, codeGenerationOptions: new CodeGenerationOptions(generateMethodBodies: false)); var initialVB = "Namespace [|N|] End Namespace"; - var expectedVB = @" -Namespace N -Namespace N - Public Class A - Public Shared MustOverride ReadOnly Property Property1 As String - Public Overridable ReadOnly Property [Property] As String - Public MustOverride Shared Sub Method2() - Public Overridable Sub Method1() - End Class + var expectedVB = @"Namespace N End NamespaceNamespace N + Public Class A + Public Shared MustOverride ReadOnly Property Property1 As String + Public Overridable ReadOnly Property [Property] As String + Public MustOverride Shared Sub Method2() + Public Overridable Sub Method1() + End Class - Public Class C - Public Overrides NotOverridable ReadOnly Property [Property] As String - Public NotOverridable Overrides Sub Method1() - End Class -End Namespace -"; + Public Class C + Public Overrides NotOverridable ReadOnly Property [Property] As String + Public NotOverridable Overrides Sub Method1() + End Class + End Namespace"; await TestGenerateFromSourceSymbolAsync(generationSource, initialVB, expectedVB, codeGenerationOptions: new CodeGenerationOptions(generateMethodBodies: false)); } diff --git a/src/EditorFeatures/Test/CodeGeneration/CodeGenerationTests.VisualBasic.cs b/src/EditorFeatures/Test/CodeGeneration/CodeGenerationTests.VisualBasic.cs index c94349ba62f06..f4ecdf55fb08d 100644 --- a/src/EditorFeatures/Test/CodeGeneration/CodeGenerationTests.VisualBasic.cs +++ b/src/EditorFeatures/Test/CodeGeneration/CodeGenerationTests.VisualBasic.cs @@ -25,7 +25,10 @@ public class VisualBasic public async Task AddNamespace() { var input = "Namespace [|N1|]\n End Namespace"; - var expected = "Namespace N1\n Namespace N2\n End Namespace\n End Namespace"; + var expected = @"Namespace N1 + Namespace N2 + End Namespace +End Namespace"; await TestAddNamespaceAsync(input, expected, name: "N2"); } @@ -34,7 +37,9 @@ public async Task AddNamespace() public async Task AddField() { var input = "Class [|C|]\n End Class"; - var expected = "Class C\n Public F As Integer\n End Class"; + var expected = @"Class C + Public F As Integer +End Class"; await TestAddFieldAsync(input, expected, type: GetTypeSymbol(typeof(int))); } @@ -43,7 +48,9 @@ public async Task AddField() public async Task AddSharedField() { var input = "Class [|C|]\n End Class"; - var expected = "Class C\n Private Shared F As String\n End Class"; + var expected = @"Class C + Private Shared F As String +End Class"; await TestAddFieldAsync(input, expected, type: GetTypeSymbol(typeof(string)), accessibility: Accessibility.Private, @@ -54,7 +61,9 @@ public async Task AddSharedField() public async Task AddArrayField() { var input = "Class [|C|]\n End Class"; - var expected = "Class C\n Public F As Integer()\n End Class"; + var expected = @"Class C + Public F As Integer() +End Class"; await TestAddFieldAsync(input, expected, type: CreateArrayType(typeof(int))); } @@ -63,7 +72,10 @@ public async Task AddArrayField() public async Task AddConstructor() { var input = "Class [|C|]\n End Class"; - var expected = "Class C\n Public Sub New()\n End Sub\n End Class"; + var expected = @"Class C + Public Sub New() + End Sub +End Class"; await TestAddConstructorAsync(input, expected); } @@ -96,7 +108,9 @@ End Sub public async Task AddConstructorWithoutBody() { var input = "Class [|C|]\n End Class"; - var expected = "Class C\n Public Sub New()\n End Class"; + var expected = @"Class C + Public Sub New() +End Class"; await TestAddConstructorAsync(input, expected, codeGenerationOptions: new CodeGenerationOptions(generateMethodBodies: false)); } @@ -105,7 +119,12 @@ public async Task AddConstructorWithoutBody() public async Task AddConstructorResolveNamespaceImport() { var input = "Class [|C|]\n End Class"; - var expected = "Imports System.Text\n Class C\n Public Sub New(s As StringBuilder)\n End Sub\n End Class"; + var expected = @"Imports System.Text + +Class C + Public Sub New(s As StringBuilder) + End Sub +End Class"; await TestAddConstructorAsync(input, expected, parameters: Parameters(Parameter(typeof(StringBuilder), "s"))); } @@ -114,7 +133,10 @@ public async Task AddConstructorResolveNamespaceImport() public async Task AddSharedConstructor() { var input = "Class [|C|]\n End Class"; - var expected = "Class C\n Shared Sub New()\n End Sub\n End Class"; + var expected = @"Class C + Shared Sub New() + End Sub +End Class"; await TestAddConstructorAsync(input, expected, modifiers: new DeclarationModifiers(isStatic: true)); } @@ -123,7 +145,14 @@ public async Task AddSharedConstructor() public async Task AddChainedConstructor() { var input = "Class [|C|]\n Public Sub New(i As Integer)\n End Sub\n End Class"; - var expected = "Class C\n Public Sub New()\n Me.New(42)\n End Sub\n Public Sub New(i As Integer)\n End Sub\n End Class"; + var expected = @"Class C + Public Sub New() + Me.New(42) + End Sub + + Public Sub New(i As Integer) + End Sub + End Class"; await TestAddConstructorAsync(input, expected, thisArguments: ImmutableArray.Create(VB.SyntaxFactory.ParseExpression("42"))); } @@ -144,7 +173,10 @@ End Class public async Task AddClassEscapeName() { var input = "Namespace [|N|]\n End Namespace"; - var expected = "Namespace N\n Public Class [Class]\n End Class\n End Namespace"; + var expected = @"Namespace N + Public Class [Class] + End Class +End Namespace"; await TestAddNamedTypeAsync(input, expected, name: "Class"); } @@ -153,16 +185,22 @@ public async Task AddClassEscapeName() public async Task AddClassUnicodeName() { var input = "Namespace [|N|]\n End Namespace"; - var expected = "Namespace N\n Public Class [Class]\n End Class\n End Namespace"; + var expected = @"Namespace N + Public Class [Class] + End Class +End Namespace"; await TestAddNamedTypeAsync(input, expected, - name: "Cl\u0061ss"); + name: "Class"); } [Fact, Trait(Traits.Feature, Traits.Features.CodeGeneration), WorkItem(544477, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544477")] public async Task AddNotInheritableClass() { var input = "Namespace [|N|]\n End Namespace"; - var expected = "Namespace N\n Public NotInheritable Class C\n End Class\n End Namespace"; + var expected = @"Namespace N + Public NotInheritable Class C + End Class +End Namespace"; await TestAddNamedTypeAsync(input, expected, modifiers: new DeclarationModifiers(isSealed: true)); } @@ -171,7 +209,10 @@ public async Task AddNotInheritableClass() public async Task AddMustInheritClass() { var input = "Namespace [|N|]\n End Namespace"; - var expected = "Namespace N\n Friend MustInherit Class C\n End Class\n End Namespace"; + var expected = @"Namespace N + Friend MustInherit Class C + End Class +End Namespace"; await TestAddNamedTypeAsync(input, expected, accessibility: Accessibility.Internal, modifiers: new DeclarationModifiers(isAbstract: true)); @@ -181,7 +222,10 @@ public async Task AddMustInheritClass() public async Task AddStructure() { var input = "Namespace [|N|]\n End Namespace"; - var expected = "Namespace N\n Friend Structure S\n End Structure\n End Namespace"; + var expected = @"Namespace N + Friend Structure S + End Structure +End Namespace"; await TestAddNamedTypeAsync(input, expected, name: "S", accessibility: Accessibility.Internal, @@ -192,7 +236,10 @@ public async Task AddStructure() public async Task AddSealedStructure() { var input = "Namespace [|N|]\n End Namespace"; - var expected = "Namespace N\n Public Structure S\n End Structure\n End Namespace"; + var expected = @"Namespace N + Public Structure S + End Structure +End Namespace"; await TestAddNamedTypeAsync(input, expected, name: "S", accessibility: Accessibility.Public, @@ -204,7 +251,10 @@ public async Task AddSealedStructure() public async Task AddInterface() { var input = "Namespace [|N|]\n End Namespace"; - var expected = "Namespace N\n Public Interface I\n End Interface\n End Namespace"; + var expected = @"Namespace N + Public Interface I + End Interface +End Namespace"; await TestAddNamedTypeAsync(input, expected, name: "I", typeKind: TypeKind.Interface); @@ -214,7 +264,11 @@ public async Task AddInterface() public async Task AddEnum() { var input = "Namespace [|N|]\n End Namespace"; - var expected = "Namespace N\n Public Enum E\n F1\n End Enum\n End Namespace"; + var expected = @"Namespace N + Public Enum E + F1 + End Enum +End Namespace"; await TestAddNamedTypeAsync(input, expected, "E", typeKind: TypeKind.Enum, members: Members(CreateEnumField("F1", null))); @@ -224,7 +278,12 @@ public async Task AddEnum() public async Task AddEnumWithValues() { var input = "Namespace [|N|]\n End Namespace"; - var expected = "Namespace N\n Public Enum E\n F1 = 1\n F2 = 2\n End Enum\n End Namespace"; + var expected = @"Namespace N + Public Enum E + F1 = 1 + F2 = 2 + End Enum +End Namespace"; await TestAddNamedTypeAsync(input, expected, "E", typeKind: TypeKind.Enum, members: Members(CreateEnumField("F1", 1), CreateEnumField("F2", 2))); @@ -234,7 +293,11 @@ public async Task AddEnumWithValues() public async Task AddEnumMember() { var input = "Public Enum [|E|]\n F1 = 1\n F2 = 2\n End Enum"; - var expected = "Public Enum E\n F1 = 1\n F2 = 2\n F3\n End Enum"; + var expected = @"Public Enum E + F1 = 1 + F2 = 2 + F3 +End Enum"; await TestAddFieldAsync(input, expected, name: "F3"); } @@ -243,7 +306,11 @@ public async Task AddEnumMember() public async Task AddEnumMemberWithValue() { var input = "Public Enum [|E|]\n F1 = 1\n F2\n End Enum"; - var expected = "Public Enum E\n F1 = 1\n F2\n F3 = 3\n End Enum"; + var expected = @"Public Enum E + F1 = 1 + F2 + F3 = 3 +End Enum"; await TestAddFieldAsync(input, expected, name: "F3", hasConstantValue: true, constantValue: 3); } @@ -252,7 +319,9 @@ public async Task AddEnumMemberWithValue() public async Task AddDelegateType() { var input = "Class [|C|]\n End Class"; - var expected = "Class C\n Public Delegate Function D(s As String) As Integer\n End Class"; + var expected = @"Class C + Public Delegate Function D(s As String) As Integer +End Class"; await TestAddDelegateTypeAsync(input, expected, returnType: typeof(int), parameters: Parameters(Parameter(typeof(string), "s"))); @@ -262,7 +331,9 @@ public async Task AddDelegateType() public async Task AddSealedDelegateType() { var input = "Class [|C|]\n End Class"; - var expected = "Class C\n Public Delegate Function D(s As String) As Integer\n End Class"; + var expected = @"Class C + Public Delegate Function D(s As String) As Integer +End Class"; await TestAddDelegateTypeAsync(input, expected, returnType: typeof(int), modifiers: new DeclarationModifiers(isSealed: true), @@ -287,19 +358,15 @@ Class C public async Task AddEventWithAccessorAndImplementsClause() { var input = "Class [|C|] \n End Class"; - var expected = @" -Class C - Public Custom Event E As ComponentModel.PropertyChangedEventHandler Implements ComponentModel.INotifyPropertyChanged.PropertyChanged - - AddHandler ( value As ComponentModel . PropertyChangedEventHandler ) - End AddHandler - - RemoveHandler ( value As ComponentModel . PropertyChangedEventHandler ) - End RemoveHandler - - RaiseEvent ( sender As Object , e As ComponentModel . PropertyChangedEventArgs ) - End RaiseEvent - End Event + var expected = @"Class C + Public Custom Event E As ComponentModel.PropertyChangedEventHandler Implements ComponentModel.INotifyPropertyChanged.PropertyChanged + AddHandler(value As ComponentModel.PropertyChangedEventHandler) + End AddHandler + RemoveHandler(value As ComponentModel.PropertyChangedEventHandler) + End RemoveHandler + RaiseEvent(sender As Object, e As ComponentModel.PropertyChangedEventArgs) + End RaiseEvent + End Event End Class"; ImmutableArray GetExplicitInterfaceEvent(SemanticModel semanticModel) { @@ -332,16 +399,12 @@ public async Task AddEventWithAddAccessor() var expected = @" Class C Public Custom Event E As Action - AddHandler(value As Action) End AddHandler - RemoveHandler(value As Action) End RemoveHandler - RaiseEvent() End RaiseEvent - End Event End Class"; await TestAddEventAsync(input, expected, @@ -358,15 +421,12 @@ public async Task AddEventWithAccessors() var expected = @" Class C Public Custom Event E As Action - AddHandler(value As Action) Console.WriteLine(0) End AddHandler - RemoveHandler(value As Action) Console.WriteLine(1) End RemoveHandler - RaiseEvent() Console.WriteLine(2) End RaiseEvent @@ -389,7 +449,10 @@ End Event public async Task AddMethodToClass() { var input = "Class [|C|]\n End Class"; - var expected = "Class C\n Public Sub M()\n End Sub\n End Class"; + var expected = @"Class C + Public Sub M() + End Sub +End Class"; await TestAddMethodAsync(input, expected, returnType: typeof(void)); } @@ -398,7 +461,10 @@ public async Task AddMethodToClass() public async Task AddMethodToClassEscapedName() { var input = "Class [|C|]\n End Class"; - var expected = "Class C\n Protected Friend Sub [Sub]()\n End Sub\n End Class"; + var expected = @"Class C + Protected Friend Sub [Sub]() + End Sub +End Class"; await TestAddMethodAsync(input, expected, accessibility: Accessibility.ProtectedOrInternal, name: "Sub", @@ -409,7 +475,11 @@ public async Task AddMethodToClassEscapedName() public async Task AddSharedMethodToStructure() { var input = "Structure [|S|]\n End Structure"; - var expected = "Structure S\n Public Shared Function M() As Integer\n Return 0\n End Function\n End Structure"; + var expected = @"Structure S + Public Shared Function M() As Integer + Return 0 + End Function +End Structure"; await TestAddMethodAsync(input, expected, modifiers: new DeclarationModifiers(isStatic: true), returnType: typeof(int), @@ -420,7 +490,11 @@ public async Task AddSharedMethodToStructure() public async Task AddNotOverridableOverridesMethod() { var input = "Class [|C|]\n End Class"; - var expected = "Class C\n Public NotOverridable Overrides Function GetHashCode() As Integer\n $$ \nEnd Function\n End Class"; + var expected = @"Class C + Public NotOverridable Overrides Function GetHashCode() As Integer + $$ + End Function +End Class"; await TestAddMethodAsync(input, expected, name: "GetHashCode", modifiers: new DeclarationModifiers(isOverride: true, isSealed: true), @@ -432,7 +506,7 @@ public async Task AddNotOverridableOverridesMethod() public async Task AddMustOverrideMethod() { var input = "MustInherit Class [|C|]\n End Class"; - var expected = "MustInherit Class C\n Public MustOverride Sub M()\n End Class"; + var expected = "MustInherit Class C\n Public MustOverride Sub M()\nEnd Class"; await TestAddMethodAsync(input, expected, modifiers: new DeclarationModifiers(isAbstract: true), returnType: typeof(void)); @@ -442,7 +516,9 @@ public async Task AddMustOverrideMethod() public async Task AddMethodWithoutBody() { var input = "Class [|C|]\n End Class"; - var expected = "Class C\n Public Sub M()\n End Class"; + var expected = @"Class C + Public Sub M() +End Class"; await TestAddMethodAsync(input, expected, returnType: typeof(void), codeGenerationOptions: new CodeGenerationOptions(generateMethodBodies: false)); @@ -452,7 +528,11 @@ public async Task AddMethodWithoutBody() public async Task AddGenericMethod() { var input = "Class [|C|]\n End Class"; - var expected = "Class C\n Public Function M(Of T)() As Integer\n $$ \nEnd Function\n End Class"; + var expected = @"Class C + Public Function M(Of T)() As Integer + $$ + End Function +End Class"; await TestAddMethodAsync(input, expected, returnType: typeof(int), typeParameters: ImmutableArray.Create(CodeGenerationSymbolFactory.CreateTypeParameterSymbol("T")), @@ -463,32 +543,48 @@ public async Task AddGenericMethod() public async Task AddVirtualMethod() { var input = "Class [|C|]\n End Class"; - var expected = "Class C\n Protected Overridable Function M() As Integer\n $$ End Function\n End Class"; + var expected = @"Class C + Protected Overridable Function M() As Integer + $$ + End Function +End Class"; await TestAddMethodAsync(input, expected, accessibility: Accessibility.Protected, modifiers: new DeclarationModifiers(isVirtual: true), returnType: typeof(int), - statements: "Return 0\n"); + statements: "Return 0"); } [Fact, Trait(Traits.Feature, Traits.Features.CodeGeneration)] public async Task AddShadowsMethod() { var input = "Class [|C|]\n End Class"; - var expected = "Class C\n Public Shadows Function ToString() As String\n $$ End Function\n End Class"; + var expected = @"Class C + Public Shadows Function ToString() As String + $$ + End Function +End Class"; await TestAddMethodAsync(input, expected, name: "ToString", accessibility: Accessibility.Public, modifiers: new DeclarationModifiers(isNew: true), returnType: typeof(string), - statements: "Return String.Empty\n"); + statements: "Return String.Empty"); } [Fact, Trait(Traits.Feature, Traits.Features.CodeGeneration)] public async Task AddExplicitImplementation() { var input = "Interface I\n Sub M(i As Integer)\n End Interface\n Class [|C|]\n Implements I\n End Class"; - var expected = "Interface I\n Sub M(i As Integer)\n End Interface\n Class C\n Implements I\n Public Sub M(i As Integer) Implements I.M\n End Sub\n End Class"; + var expected = @"Interface I + Sub M(i As Integer) + End Interface + Class C + Implements I + + Public Sub M(i As Integer) Implements I.M + End Sub +End Class"; await TestAddMethodAsync(input, expected, name: "M", returnType: typeof(void), @@ -508,6 +604,7 @@ Class C Public Shared Operator IsTrue(other As C) As Boolean $$ End Operator + Public Shared Operator IsFalse(other As C) As Boolean $$ End Operator @@ -529,12 +626,14 @@ End Class "; var expected = @" Class C - Public Shared Operator + (other As C) As Object + Public Shared Operator +(other As C) As Object $$ End Operator + Public Shared Operator -(other As C) As Object $$ End Operator + Public Shared Operator Not(other As C) As Object $$ End Operator @@ -562,44 +661,57 @@ End Class var expected = @" Class C Public Shared Operator +(a As C, b As C) As Object - $$ - End Operator + $$ + End Operator + Public Shared Operator -(a As C, b As C) As Object - $$ - End Operator + $$ + End Operator + Public Shared Operator *(a As C, b As C) As Object - $$ - End Operator + $$ + End Operator + Public Shared Operator /(a As C, b As C) As Object - $$ - End Operator + $$ + End Operator + Public Shared Operator \(a As C, b As C) As Object - $$ - End Operator + $$ + End Operator + Public Shared Operator ^(a As C, b As C) As Object - $$ - End Operator + $$ + End Operator + Public Shared Operator &(a As C, b As C) As Object - $$ - End Operator + $$ + End Operator + Public Shared Operator Like(a As C, b As C) As Object - $$ - End Operator + $$ + End Operator + Public Shared Operator Mod(a As C, b As C) As Object - $$ - End Operator + $$ + End Operator + Public Shared Operator And(a As C, b As C) As Object - $$ - End Operator + $$ + End Operator + Public Shared Operator Or(a As C, b As C) As Object - $$ - End Operator + $$ + End Operator + Public Shared Operator Xor(a As C, b As C) As Object - $$ - End Operator + $$ + End Operator + Public Shared Operator <<(a As C, b As C) As Object - $$ - End Operator + $$ + End Operator + Public Shared Operator >>(a As C, b As C) As Object $$ End Operator @@ -638,23 +750,28 @@ End Class var expected = @" Class C Public Shared Operator =(a As C, b As C) As Boolean - $$ - End Operator + $$ + End Operator + Public Shared Operator <>(a As C, b As C) As Boolean - $$ - End Operator + $$ + End Operator + Public Shared Operator >(a As C, b As C) As Boolean - $$ - End Operator + $$ + End Operator + Public Shared Operator <(a As C, b As C) As Boolean - $$ - End Operator + $$ + End Operator + Public Shared Operator >=(a As C, b As C) As Boolean - $$ - End Operator + $$ + End Operator + Public Shared Operator <=(a As C, b As C) As Boolean - $$ - End Operator + $$ + End Operator End Class "; await TestAddOperatorsAsync(input, expected, @@ -687,7 +804,11 @@ public async Task AddUnsupportedOperator() public async Task AddExplicitConversion() { var input = "Class [|C|]\n End Class"; - var expected = "Class C\n Public Shared Narrowing Operator CType(other As C) As Integer\n $$\n End Operator\n End Class"; + var expected = @"Class C + Public Shared Narrowing Operator CType(other As C) As Integer + $$ + End Operator +End Class"; await TestAddConversionAsync(input, expected, toType: typeof(int), fromType: Parameter("C", "other"), @@ -698,7 +819,11 @@ public async Task AddExplicitConversion() public async Task AddImplicitConversion() { var input = "Class [|C|]\n End Class"; - var expected = "Class C\n Public Shared Widening Operator CType(other As C) As Integer\n $$\n End Operator\n End Class"; + var expected = @"Class C + Public Shared Widening Operator CType(other As C) As Integer + $$ + End Operator +End Class"; await TestAddConversionAsync(input, expected, toType: typeof(int), fromType: Parameter("C", "other"), @@ -710,7 +835,11 @@ public async Task AddImplicitConversion() public async Task AddStatementsToSub() { var input = "Class C\n [|Public Sub M\n Console.WriteLine(1)\n End Sub|]\n End Class"; - var expected = "Class C\n Public Sub M\n Console.WriteLine(1)\n $$\n End Sub\n End Class"; + var expected = @"Class C + Public Sub M + Console.WriteLine(1) +$$ End Sub + End Class"; await TestAddStatementsAsync(input, expected, "Console.WriteLine(2)"); } @@ -718,7 +847,11 @@ public async Task AddStatementsToSub() public async Task AddStatementsToOperator() { var input = "Class C\n [|Shared Operator +(arg As C) As C\n Return arg\n End Operator|]\n End Class"; - var expected = "Class C\n Shared Operator +(arg As C) As C\n Return arg\n $$\n End Operator\n End Class"; + var expected = @"Class C + Shared Operator +(arg As C) As C + Return arg +$$ End Operator + End Class"; await TestAddStatementsAsync(input, expected, "Return Nothing"); } @@ -726,7 +859,13 @@ public async Task AddStatementsToOperator() public async Task AddStatementsToPropertySetter() { var input = "Imports System\n Class C\n WriteOnly Property P As String\n [|Set\n End Set|]\n End Property\n End Class"; - var expected = "Imports System\n Class C\n WriteOnly Property P As String\n Set\n $$\n End Set\n End Property\n End Class"; + var expected = @"Imports System + Class C + WriteOnly Property P As String + Set +$$ End Set + End Property + End Class"; await TestAddStatementsAsync(input, expected, "Console.WriteLine(\"Setting the value\""); } @@ -734,7 +873,10 @@ public async Task AddStatementsToPropertySetter() public async Task AddParametersToMethod() { var input = "Class C\n Public [|Sub M()\n End Sub|]\n End Class"; - var expected = "Class C\n Public Sub M(num As Integer, Optional text As String = \"Hello!\", Optional floating As Single = 0.5)\n End Sub\n End Class"; + var expected = @"Class C + Public Sub M(numAs Integer, OptionaltextAs String = ""Hello!"",OptionalfloatingAs Single = 0.5) + End Sub + End Class"; await TestAddParametersAsync(input, expected, Parameters(Parameter(typeof(int), "num"), Parameter(typeof(string), "text", true, "Hello!"), Parameter(typeof(float), "floating", true, .5F))); } @@ -744,7 +886,15 @@ public async Task AddParametersToMethod() public async Task AddParametersToPropertyBlock() { var input = "Class C\n [|Public Property P As String\n Get\n Return String.Empty\n End Get\n Set(value As String)\n End Set\n End Property|]\n End Class"; - var expected = "Class C\n Public Property P(num As Integer) As String\n Get\n Return String.Empty\n End Get\n Set(value As String)\n End Set\n End Property\n End Class"; + var expected = @"Class C + Public Property P (numAs Integer) As String + Get + Return String.Empty + End Get + Set(value As String) + End Set + End Property + End Class"; await TestAddParametersAsync(input, expected, Parameters(Parameter(typeof(int), "num"))); } @@ -754,7 +904,15 @@ public async Task AddParametersToPropertyBlock() public async Task AddParametersToPropertyStatement() { var input = "Class C\n [|Public Property P As String|]\n Get\n Return String.Empty\n End Get\n Set(value As String)\n End Set\n End Property\n End Class"; - var expected = "Class C\n Public Property P(num As Integer) As String\n Get\n Return String.Empty\n End Get\n Set(value As String)\n End Set\n End Property\n End Class"; + var expected = @"Class C + Public Property P (numAs Integer) As String + Get + Return String.Empty + End Get + Set(value As String) + End Set + End Property + End Class"; await TestAddParametersAsync(input, expected, Parameters(Parameter(typeof(int), "num"))); } @@ -783,7 +941,11 @@ public async Task AddParametersToPropertySetter_ShouldNotSucceed() public async Task AddParametersToOperator() { var input = "Class C\n [|Shared Operator +(a As C) As C\n Return a\n End Operator|]\n End Class"; - var expected = "Class C\n Shared Operator +(a As C, b As C) As C\n Return a\n End Operator\n End Class"; + var expected = @"Class C + Shared Operator +(a As C,bAs C) As C + Return a + End Operator + End Class"; await TestAddParametersAsync(input, expected, Parameters(Parameter("C", "b"))); } @@ -792,7 +954,9 @@ public async Task AddParametersToOperator() public async Task AddAutoProperty() { var input = "Class [|C|]\n End Class"; - var expected = "Class C\n Public Property P As Integer\n End Class"; + var expected = @"Class C + Public Property P As Integer +End Class"; await TestAddPropertyAsync(input, expected, type: typeof(int)); } @@ -801,7 +965,9 @@ public async Task AddAutoProperty() public async Task AddPropertyWithoutAccessorBodies() { var input = "Class [|C|]\n End Class"; - var expected = "Class C\n Public Property P As Integer\n End Class"; + var expected = @"Class C + Public Property P As Integer +End Class"; await TestAddPropertyAsync(input, expected, type: typeof(int), getStatements: "Return 0", @@ -813,7 +979,13 @@ public async Task AddPropertyWithoutAccessorBodies() public async Task AddIndexer() { var input = "Class [|C|]\n End Class"; - var expected = "Class C\n Default Public ReadOnly Property Item(i As Integer) As String\n Get\n $$ \nEnd Get\n End Property\n End Class"; + var expected = @"Class C + Default Public ReadOnly Property Item(i As Integer) As String + Get + $$ + End Get + End Property +End Class"; await TestAddPropertyAsync(input, expected, name: "Item", type: typeof(string), @@ -826,7 +998,9 @@ public async Task AddIndexer() public async Task AddAttributeToTypes() { var input = "Class [|C|]\n End Class"; - var expected = " Class C\n End Class"; + var expected = @" +Class C +End Class"; await TestAddAttributeAsync(input, expected, typeof(SerializableAttribute)); } @@ -847,7 +1021,11 @@ Class C public async Task AddAttributeToMethods() { var input = "Class C\n Public Sub [|M()|] \n End Sub \n End Class"; - var expected = "Class C\n Public Sub M() \n End Sub \n End Class"; + var expected = @"Class C + + Public Sub M() + End Sub + End Class"; await TestAddAttributeAsync(input, expected, typeof(SerializableAttribute)); } @@ -872,7 +1050,10 @@ End Sub public async Task AddAttributeToFields() { var input = "Class C\n [|Public F As Integer|]\n End Class"; - var expected = "Class C\n Public F As Integer\n End Class"; + var expected = @"Class C + + Public F As Integer +End Class"; await TestAddAttributeAsync(input, expected, typeof(SerializableAttribute)); } @@ -895,7 +1076,10 @@ Class C public async Task AddAttributeToProperties() { var input = "Class C \n Public Property [|P|] As Integer \n End Class"; - var expected = "Class C \n Public Property P As Integer \n End Class"; + var expected = @"Class C + + Public Property P As Integer +End Class"; await TestAddAttributeAsync(input, expected, typeof(SerializableAttribute)); } @@ -918,7 +1102,14 @@ Class C public async Task AddAttributeToPropertyAccessor() { var input = "Class C \n Public ReadOnly Property P As Integer \n [|Get|] \n Return 10 \n End Get \n End Property \n End Class"; - var expected = "Class C \n Public ReadOnly Property P As Integer \n Get \n Return 10 \n End Get \n End Property \n End Class"; + var expected = @"Class C + Public ReadOnly Property P As Integer + + Get + Return 10 + End Get + End Property + End Class"; await TestAddAttributeAsync(input, expected, typeof(SerializableAttribute)); } @@ -947,7 +1138,13 @@ End Get public async Task AddAttributeToEnums() { var input = "Module M \n [|Enum C|] \n One \n Two \n End Enum\n End Module"; - var expected = "Module M \n Enum C \n One \n Two \n End Enum\n End Module"; + var expected = @"Module M + + Enum C + One + Two + End Enum + End Module"; await TestAddAttributeAsync(input, expected, typeof(SerializableAttribute)); } @@ -976,7 +1173,13 @@ End Enum public async Task AddAttributeToEnumMembers() { var input = "Module M \n Enum C \n [|One|] \n Two \n End Enum\n End Module"; - var expected = "Module M \n Enum C \n One \n Two \n End Enum\n End Module"; + var expected = @"Module M + Enum C + + One + Two + End Enum + End Module"; await TestAddAttributeAsync(input, expected, typeof(SerializableAttribute)); } @@ -1005,7 +1208,9 @@ End Enum public async Task AddAttributeToModule() { var input = "Module [|M|] \n End Module"; - var expected = " Module M \n End Module"; + var expected = @" +Module M +End Module"; await TestAddAttributeAsync(input, expected, typeof(SerializableAttribute)); } @@ -1026,7 +1231,12 @@ Module M public async Task AddAttributeToOperator() { var input = "Class C \n Public Shared Operator [|+|] (x As C, y As C) As C \n Return New C() \n End Operator \n End Class"; - var expected = "Class C \n Public Shared Operator +(x As C, y As C) As C \n Return New C() \n End Operator \n End Class"; + var expected = @"Class C + + Public Shared Operator +(x As C, y As C) As C + Return New C() + End Operator + End Class"; await TestAddAttributeAsync(input, expected, typeof(SerializableAttribute)); } @@ -1057,7 +1267,7 @@ End Class public async Task AddAttributeToDelegate() { var input = "Module M \n Delegate Sub [|D()|]\n End Module"; - var expected = "Module M \n Delegate Sub D()\n End Module"; + var expected = "Module M\n \n Delegate Sub D()\nEnd Module"; await TestAddAttributeAsync(input, expected, typeof(SerializableAttribute)); } @@ -1104,7 +1314,7 @@ End Sub public async Task AddAttributeToCompilationUnit() { var input = "[|Class C \n End Class \n Class D \n End Class|]"; - var expected = " Class C \n End Class \n Class D \n End Class"; + var expected = "\nClass C\nEnd Class\nClass D\nEnd Class"; await TestAddAttributeAsync(input, expected, typeof(SerializableAttribute), VB.SyntaxFactory.Token(VB.SyntaxKind.AssemblyKeyword)); } @@ -1257,7 +1467,13 @@ public async Task SortModules() { var generationSource = "Public Class [|C|] \n End Class"; var initial = "Namespace [|N|] \n Module M \n End Module \n End Namespace"; - var expected = "Namespace N \n Public Class C \n End Class \n Module M \n End Module \n End Namespace"; + var expected = @"Namespace N + Public Class C + End Class + + Module M + End Module + End Namespace"; await TestGenerateFromSourceSymbolAsync(generationSource, initial, expected); } @@ -1351,8 +1567,7 @@ End Operator End Class End Namespace"; var initial = "Namespace [|N|] \n End Namespace"; - var expected = @" -Namespace N + var expected = @"Namespace N Public Class C Public Shared Operator +(other As C) As C Public Shared Operator +(a As C, b As C) As C @@ -1401,14 +1616,12 @@ End Class End Namespace "; var initial = "Namespace [|N|] \n End Namespace"; - var expected = @" -Namespace N + var expected = @"Namespace N Public Class C(Of T As Structure, U As Class) Public Sub Goo(Of Q As New, R As IComparable)() Public Delegate Sub D(Of T1 As Structure, T2 As Class)(t As T1, u As T2) End Class -End Namespace -"; +End Namespace"; await TestGenerateFromSourceSymbolAsync(generationSource, initial, expected, codeGenerationOptions: new CodeGenerationOptions(generateMethodBodies: false), onlyGenerateMembers: true); diff --git a/src/EditorFeatures/Test/CodeGeneration/CodeGenerationTests.cs b/src/EditorFeatures/Test/CodeGeneration/CodeGenerationTests.cs index ffdf02e21b4da..2d3154cc1f401 100644 --- a/src/EditorFeatures/Test/CodeGeneration/CodeGenerationTests.cs +++ b/src/EditorFeatures/Test/CodeGeneration/CodeGenerationTests.cs @@ -35,7 +35,7 @@ public partial class CodeGenerationTests IList imports = null, IList members = null, CodeGenerationOptions codeGenerationOptions = default(CodeGenerationOptions), - bool ignoreTrivia = true) + bool ignoreTrivia = false) { using (var context = await TestContext.CreateAsync(initial, expected, ignoreTrivia)) { @@ -52,7 +52,7 @@ public partial class CodeGenerationTests Accessibility accessibility = Accessibility.Public, Editing.DeclarationModifiers modifiers = default(Editing.DeclarationModifiers), CodeGenerationOptions codeGenerationOptions = default(CodeGenerationOptions), - bool ignoreTrivia = true, + bool ignoreTrivia = false, bool hasConstantValue = false, object constantValue = null, bool addToCompilationUnit = false) @@ -91,7 +91,7 @@ public partial class CodeGenerationTests ImmutableArray baseArguments = default(ImmutableArray), ImmutableArray thisArguments = default(ImmutableArray), CodeGenerationOptions codeGenerationOptions = default(CodeGenerationOptions), - bool ignoreTrivia = true) + bool ignoreTrivia = false) { using (var context = await TestContext.CreateAsync(initial, expected, ignoreTrivia)) { @@ -122,7 +122,7 @@ public partial class CodeGenerationTests string statements = null, ImmutableArray handlesExpressions = default(ImmutableArray), CodeGenerationOptions codeGenerationOptions = default(CodeGenerationOptions), - bool ignoreTrivia = true) + bool ignoreTrivia = false) { if (statements != null) { @@ -160,7 +160,7 @@ public partial class CodeGenerationTests ImmutableArray> parameters = default(ImmutableArray>), string statements = null, CodeGenerationOptions codeGenerationOptions = default(CodeGenerationOptions), - bool ignoreTrivia = true) + bool ignoreTrivia = false) { if (statements != null) { @@ -197,7 +197,7 @@ public partial class CodeGenerationTests ImmutableArray> parameters = default(ImmutableArray>), string statements = null, CodeGenerationOptions codeGenerationOptions = default(CodeGenerationOptions), - bool ignoreTrivia = true) + bool ignoreTrivia = false) { using (var context = await TestContext.CreateAsync(initial, initial, ignoreResult: true)) { @@ -239,7 +239,7 @@ public partial class CodeGenerationTests Editing.DeclarationModifiers modifiers = default(Editing.DeclarationModifiers), string statements = null, CodeGenerationOptions codeGenerationOptions = default(CodeGenerationOptions), - bool ignoreTrivia = true) + bool ignoreTrivia = false) { if (statements != null) { @@ -267,7 +267,7 @@ public partial class CodeGenerationTests string expected, string statements, CodeGenerationOptions codeGenerationOptions = default(CodeGenerationOptions), - bool ignoreTrivia = true) + bool ignoreTrivia = false) { if (statements != null) { @@ -288,7 +288,7 @@ public partial class CodeGenerationTests string expected, ImmutableArray> parameters, CodeGenerationOptions codeGenerationOptions = default(CodeGenerationOptions), - bool ignoreTrivia = true) + bool ignoreTrivia = false) { using (var context = await TestContext.CreateAsync(initial, expected, ignoreTrivia)) { @@ -309,7 +309,7 @@ public partial class CodeGenerationTests ImmutableArray typeParameters = default(ImmutableArray), ImmutableArray> parameters = default(ImmutableArray>), CodeGenerationOptions codeGenerationOptions = default(CodeGenerationOptions), - bool ignoreTrivia = true) + bool ignoreTrivia = false) { using (var context = await TestContext.CreateAsync(initial, expected, ignoreTrivia)) { @@ -341,7 +341,7 @@ public partial class CodeGenerationTests IMethodSymbol removeMethod = null, IMethodSymbol raiseMethod = null, CodeGenerationOptions codeGenerationOptions = default(CodeGenerationOptions), - bool ignoreTrivia = true) + bool ignoreTrivia = false) { using (var context = await TestContext.CreateAsync(initial, expected, ignoreTrivia)) { @@ -377,7 +377,7 @@ public partial class CodeGenerationTests ImmutableArray> parameters = default(ImmutableArray>), bool isIndexer = false, CodeGenerationOptions codeGenerationOptions = default(CodeGenerationOptions), - bool ignoreTrivia = true, + bool ignoreTrivia = false, IDictionary options = null) { // This assumes that tests will not use place holders for get/set statements at the same time @@ -470,7 +470,7 @@ public partial class CodeGenerationTests SpecialType specialType = SpecialType.None, ImmutableArray> members = default(ImmutableArray>), CodeGenerationOptions codeGenerationOptions = default(CodeGenerationOptions), - bool ignoreTrivia = true) + bool ignoreTrivia = false) { using (var context = await TestContext.CreateAsync(initial, expected, ignoreTrivia)) { @@ -487,7 +487,7 @@ public partial class CodeGenerationTests string expected, Type attributeClass, SyntaxToken? target = null, - bool ignoreTrivia = true) + bool ignoreTrivia = false) { using (var context = await TestContext.CreateAsync(initial, expected, ignoreTrivia)) { @@ -578,7 +578,7 @@ public partial class CodeGenerationTests string expected, bool onlyGenerateMembers = false, CodeGenerationOptions codeGenerationOptions = default(CodeGenerationOptions), - bool ignoreTrivia = true, + bool ignoreTrivia = false, string forceLanguage = null) { using (var context = await TestContext.CreateAsync(initial, expected, ignoreTrivia, forceLanguage)) @@ -837,7 +837,7 @@ internal class TestContext : IDisposable this.Service = Document.Project.LanguageServices.GetService(); } - public static async Task CreateAsync(string initial, string expected, bool ignoreTrivia = true, string forceLanguage = null, bool ignoreResult = false) + public static async Task CreateAsync(string initial, string expected, bool ignoreTrivia = false, string forceLanguage = null, bool ignoreResult = false) { var language = forceLanguage != null ? forceLanguage : GetLanguage(initial); var isVisualBasic = language == LanguageNames.VisualBasic; diff --git a/src/EditorFeatures/Test/MetadataAsSource/AbstractMetadataAsSourceTests.TestContext.cs b/src/EditorFeatures/Test/MetadataAsSource/AbstractMetadataAsSourceTests.TestContext.cs index a70a2843151a2..9cbb488d0292c 100644 --- a/src/EditorFeatures/Test/MetadataAsSource/AbstractMetadataAsSourceTests.TestContext.cs +++ b/src/EditorFeatures/Test/MetadataAsSource/AbstractMetadataAsSourceTests.TestContext.cs @@ -94,7 +94,7 @@ private static string GetSpaceSeparatedTokens(string source) return string.Join(" ", tokens); } - public void VerifyResult(MetadataAsSourceFile file, string expected, bool ignoreTrivia = true) + public void VerifyResult(MetadataAsSourceFile file, string expected, bool ignoreTrivia = false) { var actual = File.ReadAllText(file.FilePath).Trim(); var actualSpan = file.IdentifierLocation.SourceSpan; @@ -104,20 +104,20 @@ public void VerifyResult(MetadataAsSourceFile file, string expected, bool ignore // Compare tokens and verify location relative to the generated tokens expected = GetSpaceSeparatedTokens(expected); actual = GetSpaceSeparatedTokens(actual.Insert(actualSpan.Start, "[|").Insert(actualSpan.End + 2, "|]")); + Assert.Equal(expected, actual); } else { // Compare exact texts and verify that the location returned is exactly that // indicated by expected - MarkupTestFile.GetSpan(expected.TrimStart().TrimEnd(), out expected, out var expectedSpan); + MarkupTestFile.GetSpan(expected, out expected, out var expectedSpan); + Assert.Equal(expected, actual); Assert.Equal(expectedSpan.Start, actualSpan.Start); Assert.Equal(expectedSpan.End, actualSpan.End); } - - Assert.Equal(expected, actual); } - public async Task GenerateAndVerifySourceAsync(string symbolMetadataName, string expected, bool ignoreTrivia = true, Project project = null) + public async Task GenerateAndVerifySourceAsync(string symbolMetadataName, string expected, bool ignoreTrivia = false, Project project = null) { var result = await GenerateSourceAsync(symbolMetadataName, project); VerifyResult(result, expected, ignoreTrivia); diff --git a/src/EditorFeatures/Test/MetadataAsSource/AbstractMetadataAsSourceTests.cs b/src/EditorFeatures/Test/MetadataAsSource/AbstractMetadataAsSourceTests.cs index 115da206fb79b..426cd763267fb 100644 --- a/src/EditorFeatures/Test/MetadataAsSource/AbstractMetadataAsSourceTests.cs +++ b/src/EditorFeatures/Test/MetadataAsSource/AbstractMetadataAsSourceTests.cs @@ -16,7 +16,7 @@ public abstract partial class AbstractMetadataAsSourceTests { internal static async Task GenerateAndVerifySourceAsync( string metadataSource, string symbolName, string projectLanguage, string expected, - bool ignoreTrivia = true, bool includeXmlDocComments = false, string languageVersion = null) + bool ignoreTrivia = false, bool includeXmlDocComments = false, string languageVersion = null) { using (var context = TestContext.Create(projectLanguage, SpecializedCollections.SingletonEnumerable(metadataSource), includeXmlDocComments, languageVersion: languageVersion)) { diff --git a/src/EditorFeatures/Test/MetadataAsSource/MetadataAsSourceTests.VisualBasic.cs b/src/EditorFeatures/Test/MetadataAsSource/MetadataAsSourceTests.VisualBasic.cs index 7a74cad37ced3..e1f6a62f81286 100644 --- a/src/EditorFeatures/Test/MetadataAsSource/MetadataAsSourceTests.VisualBasic.cs +++ b/src/EditorFeatures/Test/MetadataAsSource/MetadataAsSourceTests.VisualBasic.cs @@ -20,8 +20,7 @@ Module M Public Class D End Class End Module"; - await GenerateAndVerifySourceAsync(metadataSource, "M+D", LanguageNames.VisualBasic, $@" -#Region ""{FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"" + await GenerateAndVerifySourceAsync(metadataSource, "M+D", LanguageNames.VisualBasic, $@"#Region ""{FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"" ' {CodeAnalysisResources.InMemoryAssembly} #End Region diff --git a/src/EditorFeatures/Test/MetadataAsSource/MetadataAsSourceTests.cs b/src/EditorFeatures/Test/MetadataAsSource/MetadataAsSourceTests.cs index 283a116f1c4bd..c45380c39fbcc 100644 --- a/src/EditorFeatures/Test/MetadataAsSource/MetadataAsSourceTests.cs +++ b/src/EditorFeatures/Test/MetadataAsSource/MetadataAsSourceTests.cs @@ -19,8 +19,7 @@ public async Task TestClass() var metadataSource = "public class C {}"; var symbolName = "C"; - await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.CSharp, $@" -#region {FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.CSharp, $@"#region {FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null // {CodeAnalysisResources.InMemoryAssembly} #endregion @@ -28,8 +27,7 @@ public class [|C|] {{ public C(); }}"); - await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.VisualBasic, $@" -#Region ""{FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"" + await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.VisualBasic, $@"#Region ""{FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"" ' {CodeAnalysisResources.InMemoryAssembly} #End Region @@ -45,16 +43,14 @@ public async Task TestInterface() var metadataSource = "public interface I {}"; var symbolName = "I"; - await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.CSharp, $@" -#region {FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.CSharp, $@"#region {FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null // {CodeAnalysisResources.InMemoryAssembly} #endregion public interface [|I|] {{ }}"); - await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.VisualBasic, $@" -#Region ""{FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"" + await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.VisualBasic, $@"#Region ""{FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"" ' {CodeAnalysisResources.InMemoryAssembly} #End Region @@ -68,8 +64,7 @@ public async Task TestConstructor() var metadataSource = "public class C {}"; var symbolName = "C..ctor"; - await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.CSharp, $@" -#region {FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.CSharp, $@"#region {FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null // {CodeAnalysisResources.InMemoryAssembly} #endregion @@ -77,8 +72,7 @@ public class C {{ public [|C|](); }}"); - await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.VisualBasic, $@" -#Region ""{FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"" + await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.VisualBasic, $@"#Region ""{FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"" ' {CodeAnalysisResources.InMemoryAssembly} #End Region @@ -93,8 +87,7 @@ public async Task TestMethod() var metadataSource = "public class C { public void Goo() {} }"; var symbolName = "C.Goo"; - await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.CSharp, $@" -#region {FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.CSharp, $@"#region {FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null // {CodeAnalysisResources.InMemoryAssembly} #endregion @@ -104,8 +97,7 @@ public class C public void [|Goo|](); }}"); - await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.VisualBasic, $@" -#Region ""{FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"" + await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.VisualBasic, $@"#Region ""{FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"" ' {CodeAnalysisResources.InMemoryAssembly} #End Region @@ -122,8 +114,7 @@ public async Task TestField() var metadataSource = "public class C { public string S; }"; var symbolName = "C.S"; - await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.CSharp, $@" -#region {FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.CSharp, $@"#region {FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null // {CodeAnalysisResources.InMemoryAssembly} #endregion @@ -133,8 +124,7 @@ public class C public C(); }}"); - await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.VisualBasic, $@" -#Region ""{FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"" + await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.VisualBasic, $@"#Region ""{FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"" ' {CodeAnalysisResources.InMemoryAssembly} #End Region @@ -152,8 +142,7 @@ public async Task TestProperty() var metadataSource = "public class C { public string S { get; protected set; } }"; var symbolName = "C.S"; - await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.CSharp, $@" -#region {FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.CSharp, $@"#region {FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null // {CodeAnalysisResources.InMemoryAssembly} #endregion @@ -163,8 +152,7 @@ public class C public string [|S|] {{ get; protected set; }} }}"); - await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.VisualBasic, $@" -#Region ""{FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"" + await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.VisualBasic, $@"#Region ""{FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"" ' {CodeAnalysisResources.InMemoryAssembly} #End Region @@ -183,8 +171,7 @@ public async Task TestEvent() var metadataSource = "using System; public class C { public event Action E; }"; var symbolName = "C.E"; - await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.CSharp, $@" -#region {FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.CSharp, $@"#region {FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null // {CodeAnalysisResources.InMemoryAssembly} #endregion @@ -196,8 +183,7 @@ public class C public event Action [|E|]; }}"); - await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.VisualBasic, $@" -#Region ""{FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"" + await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.VisualBasic, $@"#Region ""{FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"" ' {CodeAnalysisResources.InMemoryAssembly} #End Region @@ -216,8 +202,7 @@ public async Task TestNestedType() var metadataSource = "public class C { protected class D { } }"; var symbolName = "C+D"; - await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.CSharp, $@" -#region {FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.CSharp, $@"#region {FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null // {CodeAnalysisResources.InMemoryAssembly} #endregion @@ -230,8 +215,7 @@ protected class [|D|] public D(); }} }}"); - await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.VisualBasic, $@" -#Region ""{FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"" + await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.VisualBasic, $@"#Region ""{FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"" ' {CodeAnalysisResources.InMemoryAssembly} #End Region @@ -251,8 +235,7 @@ public async Task TestEnum() var metadataSource = "public enum E { A, B, C }"; var symbolName = "E"; - await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.CSharp, $@" -#region {FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.CSharp, $@"#region {FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null // {CodeAnalysisResources.InMemoryAssembly} #endregion @@ -262,8 +245,7 @@ public enum [|E|] B = 1, C = 2 }}"); - await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.VisualBasic, $@" -#Region ""{FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"" + await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.VisualBasic, $@"#Region ""{FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"" ' {CodeAnalysisResources.InMemoryAssembly} #End Region @@ -281,8 +263,7 @@ public async Task TestEnumFromField() var metadataSource = "public enum E { A, B, C }"; var symbolName = "E.C"; - await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.CSharp, $@" -#region {FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.CSharp, $@"#region {FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null // {CodeAnalysisResources.InMemoryAssembly} #endregion @@ -292,8 +273,7 @@ public enum E B = 1, [|C|] = 2 }}"); - await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.VisualBasic, $@" -#Region ""{FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"" + await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.VisualBasic, $@"#Region ""{FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"" ' {CodeAnalysisResources.InMemoryAssembly} #End Region @@ -311,8 +291,7 @@ public async Task TestEnumWithUnderlyingType() var metadataSource = "public enum E : short { A = 0, B = 1, C = 2 }"; var symbolName = "E.C"; - await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.CSharp, $@" -#region {FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.CSharp, $@"#region {FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null // {CodeAnalysisResources.InMemoryAssembly} #endregion @@ -322,15 +301,14 @@ public enum E : short B = 1, [|C|] = 2 }}"); - await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.VisualBasic, $@" -#Region ""{FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"" + await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.VisualBasic, $@"#Region ""{FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"" ' {CodeAnalysisResources.InMemoryAssembly} #End Region Public Enum E As Short A = 0 B = 1 - [|C|] = 2 + [|C|] = 2 End Enum"); } @@ -341,8 +319,7 @@ public async Task TestEnumWithOverflowingUnderlyingType() var metadataSource = "public enum E : ulong { A = 9223372036854775808 }"; var symbolName = "E.A"; - await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.CSharp, $@" -#region {FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.CSharp, $@"#region {FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null // {CodeAnalysisResources.InMemoryAssembly} #endregion @@ -350,8 +327,7 @@ public enum E : ulong {{ [|A|] = 9223372036854775808 }}"); - await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.VisualBasic, $@" -#Region ""{FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"" + await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.VisualBasic, $@"#Region ""{FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"" ' {CodeAnalysisResources.InMemoryAssembly} #End Region @@ -366,8 +342,7 @@ public async Task TestEnumWithDifferentValues() var metadataSource = "public enum E : short { A = 1, B = 2, C = 3 }"; var symbolName = "E.C"; - await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.CSharp, $@" -#region {FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.CSharp, $@"#region {FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null // {CodeAnalysisResources.InMemoryAssembly} #endregion @@ -377,8 +352,7 @@ public enum E : short B = 2, [|C|] = 3 }}"); - await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.VisualBasic, $@" -#Region ""{FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"" + await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.VisualBasic, $@"#Region ""{FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"" ' {CodeAnalysisResources.InMemoryAssembly} #End Region @@ -396,8 +370,7 @@ public async Task TestTypeInNamespace() var metadataSource = "namespace N { public class C {} }"; var symbolName = "N.C"; - await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.CSharp, $@" -#region {FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.CSharp, $@"#region {FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null // {CodeAnalysisResources.InMemoryAssembly} #endregion @@ -408,8 +381,7 @@ public class [|C|] public C(); }} }}"); - await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.VisualBasic, $@" -#Region ""{FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"" + await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.VisualBasic, $@"#Region ""{FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"" ' {CodeAnalysisResources.InMemoryAssembly} #End Region @@ -427,8 +399,7 @@ public async Task TestInlineConstant() var metadataSource = @"public class C { public const string S = ""Hello mas""; }"; var symbolName = "C.S"; - await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.CSharp, $@" -#region {FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.CSharp, $@"#region {FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null // {CodeAnalysisResources.InMemoryAssembly} #endregion @@ -438,8 +409,7 @@ public class C public C(); }}"); - await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.VisualBasic, $@" -#Region ""{FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"" + await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.VisualBasic, $@"#Region ""{FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"" ' {CodeAnalysisResources.InMemoryAssembly} #End Region @@ -467,8 +437,7 @@ public class C {}"; var symbolName = "C"; - await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.CSharp, $@" -#region {FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.CSharp, $@"#region {FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null // {CodeAnalysisResources.InMemoryAssembly} #endregion @@ -477,8 +446,7 @@ public class [|C|] {{ public C(); }}"); - await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.VisualBasic, $@" -#Region ""{FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"" + await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.VisualBasic, $@"#Region ""{FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"" ' {CodeAnalysisResources.InMemoryAssembly} #End Region @@ -495,16 +463,14 @@ public async Task TestNoDefaultConstructorInStructs() var metadataSource = "public struct S {}"; var symbolName = "S"; - await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.CSharp, $@" -#region {FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.CSharp, $@"#region {FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null // {CodeAnalysisResources.InMemoryAssembly} #endregion public struct [|S|] {{ }}"); - await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.VisualBasic, $@" -#Region ""{FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"" + await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.VisualBasic, $@"#Region ""{FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"" ' {CodeAnalysisResources.InMemoryAssembly} #End Region @@ -518,8 +484,7 @@ public async Task TestReferenceDefinedType() var metadataSource = "public class C { public static C Create() { return new C(); } }"; var symbolName = "C"; - await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.CSharp, $@" -#region {FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.CSharp, $@"#region {FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null // {CodeAnalysisResources.InMemoryAssembly} #endregion @@ -529,8 +494,7 @@ public class [|C|] public static C Create(); }}"); - await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.VisualBasic, $@" -#Region ""{FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"" + await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.VisualBasic, $@"#Region ""{FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"" ' {CodeAnalysisResources.InMemoryAssembly} #End Region @@ -548,8 +512,7 @@ public async Task TestGenericType() var metadataSource = "public class G { public SomeType S; }"; var symbolName = "G`1"; - await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.CSharp, $@" -#region {FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.CSharp, $@"#region {FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null // {CodeAnalysisResources.InMemoryAssembly} #endregion @@ -559,8 +522,7 @@ public class [|G|] public G(); }}"); - await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.VisualBasic, $@" -#Region ""{FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"" + await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.VisualBasic, $@"#Region ""{FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"" ' {CodeAnalysisResources.InMemoryAssembly} #End Region @@ -578,8 +540,7 @@ public async Task TestGenericDelegate() var metadataSource = "public class C { public delegate void D(SomeType s); }"; var symbolName = "C+D`1"; - await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.CSharp, $@" -#region {FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.CSharp, $@"#region {FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null // {CodeAnalysisResources.InMemoryAssembly} #endregion @@ -589,14 +550,12 @@ public class C public delegate void [|D|](SomeType s); }}"); - await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.VisualBasic, $@" -#Region ""{FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"" + await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.VisualBasic, $@"#Region ""{FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"" ' {CodeAnalysisResources.InMemoryAssembly} #End Region Public Class C Public Sub New() - Public Delegate Sub [|D|](Of SomeType)(s As SomeType) End Class"); } @@ -621,8 +580,7 @@ public class C {}"; var symbolName = "C"; - await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.CSharp, $@" -#region {FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.CSharp, $@"#region {FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null // {CodeAnalysisResources.InMemoryAssembly} #endregion @@ -633,8 +591,7 @@ public class [|C|] {{ public C(); }}"); - await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.VisualBasic, $@" -#Region ""{FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"" + await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.VisualBasic, $@"#Region ""{FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"" ' {CodeAnalysisResources.InMemoryAssembly} #End Region @@ -771,8 +728,7 @@ End Get End Set End Property End Class"; - var expected = $@" -#region {FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + var expected = $@"#region {FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null // {CodeAnalysisResources.InMemoryAssembly} #endregion @@ -805,10 +761,10 @@ public class MyAttribute : Attribute public MyAttribute(Type t) { } }"; - var expected = $@" -#region {FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + var expected = $@"#region {FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null // {CodeAnalysisResources.InMemoryAssembly} #endregion + [My(typeof(D))] public class [|C|] {{ @@ -861,8 +817,7 @@ public class C public static C operator + (C c1, C c2) { return new C(); } } "; - var expectedCS = $@" -#region {FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + var expectedCS = $@"#region {FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null // {CodeAnalysisResources.InMemoryAssembly} #endregion @@ -903,13 +858,11 @@ public class [|C|] [Obsolete] public static C operator +(C c1, C c2); -}} -"; +}}"; var symbolName = "C"; await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.CSharp, expectedCS); - var expectedVB = $@" -#Region ""{FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"" + var expectedVB = $@"#Region ""{FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"" ' {CodeAnalysisResources.InMemoryAssembly} #End Region @@ -1003,8 +956,7 @@ public class [|C|] public static C operator +(C c1, C c2); public static C operator -(C c1, C c2); -}} -"; +}}"; var symbolName = "C"; await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.CSharp, expectedCS, ignoreTrivia: false); @@ -1077,8 +1029,7 @@ public interface [|IGoo|] // {FeaturesResources.Summary_colon} // M:IGoo.Method1 Uri Method1(); -}} -"; +}}"; await GenerateAndVerifySourceAsync(source, symbolName, LanguageNames.CSharp, expectedCS, ignoreTrivia: false, includeXmlDocComments: true); var expectedVB = $@"#Region ""{FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"" @@ -1100,8 +1051,7 @@ Imports System ' {FeaturesResources.Summary_colon} ' M:IGoo.Method1 Function Method1() As Uri -End Interface -"; +End Interface"; await GenerateAndVerifySourceAsync(source, symbolName, LanguageNames.VisualBasic, expectedVB, ignoreTrivia: false, includeXmlDocComments: true); } @@ -1124,22 +1074,24 @@ public class Test using System.IO; -public class [|Test|] +public class [|Test|] {{ - public Test(); + public Test(); + public void goo(FileOptions options = FileOptions.None); -}} -"; +}}"; await GenerateAndVerifySourceAsync(source, symbolName, LanguageNames.CSharp, expectedCS); - var expectedVB = $@"#Region ""{FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"" + var expectedVB = $@"#Region ""{FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"" ' {CodeAnalysisResources.InMemoryAssembly} #End Region -Imports System.IO -Public Class [|Test|] - Public Sub New() - Public Sub goo(Optional options As FileOptions = FileOptions.None) +Imports System.IO + +Public Class [|Test|] + Public Sub New() + + Public Sub goo(Optional options As FileOptions = FileOptions.None) End Class"; await GenerateAndVerifySourceAsync(source, symbolName, LanguageNames.VisualBasic, expectedVB); } @@ -1164,25 +1116,25 @@ public TestAttribute(int[] i) #endregion using System; - + [Test(null)] public class [|TestAttribute|] : Attribute {{ public TestAttribute(int[] i); -}} -"; +}}"; await GenerateAndVerifySourceAsync(source, symbolName, LanguageNames.CSharp, expectedCS); - var expectedVB = $@"#Region ""{FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"" + var expectedVB = $@"#Region ""{FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"" ' {CodeAnalysisResources.InMemoryAssembly} #End Region -Imports System + +Imports System Public Class [|TestAttribute|] - Inherits Attribute - - Public Sub New(i() As Integer) + Inherits Attribute + + Public Sub New(i() As Integer) End Class"; await GenerateAndVerifySourceAsync(source, symbolName, LanguageNames.VisualBasic, expectedVB); } @@ -1207,12 +1159,11 @@ void M() var expected = $@"#region {FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null // {CodeAnalysisResources.InMemoryAssembly} #endregion - + public static class ObjectExtensions {{ public static void [|M|](this object o, int x); -}} -"; +}}"; using (var context = TestContext.Create( LanguageNames.CSharp, @@ -1249,12 +1200,13 @@ End Sub var expected = $@"#Region ""{FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"" ' {CodeAnalysisResources.InMemoryAssembly} #End Region + Imports System.Runtime.CompilerServices Namespace NS - - Public Module StringExtensions - Public Sub [|M|](o As String, x As Integer) + + Public Module StringExtensions + Public Sub [|M|](o As String, x As Integer) End Module End Namespace"; @@ -1294,8 +1246,7 @@ public async Task TestIndexersAndOperators() }"; var symbolName = "Program"; - await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.CSharp, $@" -#region {FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.CSharp, $@"#region {FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null // {CodeAnalysisResources.InMemoryAssembly} #endregion @@ -1303,15 +1254,14 @@ public async Task TestIndexersAndOperators() [DefaultMember(""Item"")] public class [|Program|] - {{ - public Program(); +{{ + public Program(); - public int this[int x] {{ get; set; }} + public int this[int x] {{ get; set; }} - public static Program operator +(Program p1, Program p2); - }}"); - await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.VisualBasic, $@" -#Region ""{FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"" + public static Program operator +(Program p1, Program p2); +}}"); + await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.VisualBasic, $@"#Region ""{FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"" ' {CodeAnalysisResources.InMemoryAssembly} #End Region @@ -1345,10 +1295,10 @@ public interface IComImport }"; var symbolName = "IComImport"; - await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.CSharp, $@" -#region {FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.CSharp, $@"#region {FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null // {CodeAnalysisResources.InMemoryAssembly} #endregion + using System.Runtime.InteropServices; [Guid(""666A175D-2448-447A-B786-CCC82CBEF156"")] @@ -1357,6 +1307,7 @@ public interface [|IComImport|] void MOverload(); void X(); void MOverload(int i); + int Prop {{ get; }} }}"); } @@ -1372,8 +1323,7 @@ public class C { }"; var symbolName = "C"; - await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.CSharp, $@" -#region {FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + await GenerateAndVerifySourceAsync(metadataSource, symbolName, LanguageNames.CSharp, $@"#region {FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null // {CodeAnalysisResources.InMemoryAssembly} #endregion @@ -1382,6 +1332,7 @@ public class C { public class [|C|] {{ public C(); + public void M(CancellationToken cancellationToken = default); }}", languageVersion: "CSharp7_1"); } @@ -1423,8 +1374,7 @@ public interface [|IGoo|] // {FeaturesResources.Summary_colon} // M:IGoo.Method1 ABCDE FGHIJK Uri Method1(); -}} -"; +}}"; await GenerateAndVerifySourceAsync(source, symbolName, LanguageNames.CSharp, expectedCS, ignoreTrivia: false, includeXmlDocComments: true); var expectedVB = $@"#Region ""{FeaturesResources.Assembly} ReferencedAssembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"" @@ -1446,8 +1396,7 @@ Imports System ' {FeaturesResources.Summary_colon} ' M:IGoo.Method1 ABCDE FGHIJK Function Method1() As Uri -End Interface -"; +End Interface"; await GenerateAndVerifySourceAsync(source, symbolName, LanguageNames.VisualBasic, expectedVB, ignoreTrivia: false, includeXmlDocComments: true); } } diff --git a/src/EditorFeatures/TestUtilities/CodeActions/AbstractCodeActionOrUserDiagnosticTest.cs b/src/EditorFeatures/TestUtilities/CodeActions/AbstractCodeActionOrUserDiagnosticTest.cs index ba28a1985b8d1..926e17374d8de 100644 --- a/src/EditorFeatures/TestUtilities/CodeActions/AbstractCodeActionOrUserDiagnosticTest.cs +++ b/src/EditorFeatures/TestUtilities/CodeActions/AbstractCodeActionOrUserDiagnosticTest.cs @@ -162,7 +162,7 @@ public TestParameters WithFixProviderData(object fixProviderData) ImmutableArray expectedContainers, string expectedDocumentName, int index = 0, - bool ignoreTrivia = true, + bool ignoreTrivia = false, TestParameters parameters = default(TestParameters)) { await TestAddDocument( @@ -184,7 +184,7 @@ public TestParameters WithFixProviderData(object fixProviderData) int index, string expectedDocumentName, ImmutableArray expectedContainers, - bool ignoreTrivia = true) + bool ignoreTrivia = false) { var codeActions = await GetCodeActionsAsync(workspace, parameters); return await TestAddDocument( @@ -198,7 +198,7 @@ public TestParameters WithFixProviderData(object fixProviderData) ImmutableArray expectedContainers, string expectedDocumentName, int index = 0, - bool ignoreTrivia = true, + bool ignoreTrivia = false, TestParameters parameters = default(TestParameters)) { using (var workspace = CreateWorkspaceFromOptions(initialMarkup, parameters)) @@ -313,7 +313,7 @@ public TestParameters WithFixProviderData(object fixProviderData) string initialMarkup, string expectedMarkup, int index = 0, - bool ignoreTrivia = true, + bool ignoreTrivia = false, CodeActionPriority? priority = null, CompilationOptions compilationOptions = null, IDictionary options = null, @@ -329,7 +329,7 @@ public TestParameters WithFixProviderData(object fixProviderData) string initialMarkup, string expectedMarkup, int index = 0, - bool ignoreTrivia = true, + bool ignoreTrivia = false, CodeActionPriority? priority = null, TestParameters parameters = default(TestParameters)) { @@ -341,7 +341,7 @@ public TestParameters WithFixProviderData(object fixProviderData) string initialMarkup, string expectedMarkup, ParseOptions parseOptions, CompilationOptions compilationOptions = null, - int index = 0, bool ignoreTrivia = true, + int index = 0, bool ignoreTrivia = false, IDictionary options = null, string fixAllActionEquivalenceKey = null, object fixProviderData = null, diff --git a/src/EditorFeatures/TestUtilities/CodeActions/AbstractCodeActionTest.cs b/src/EditorFeatures/TestUtilities/CodeActions/AbstractCodeActionTest.cs index 07a298f411695..bb94a5bf3731a 100644 --- a/src/EditorFeatures/TestUtilities/CodeActions/AbstractCodeActionTest.cs +++ b/src/EditorFeatures/TestUtilities/CodeActions/AbstractCodeActionTest.cs @@ -79,7 +79,7 @@ protected override Task> GetDiagnosticsWorkerAsync(Te int index, ImmutableArray actions, string expectedPreviewContents = null, - bool ignoreTrivia = true) + bool ignoreTrivia = false) { var operations = await VerifyInputsAndGetOperationsAsync(index, actions); @@ -175,7 +175,7 @@ internal void EnableOption(ImmutableArray options, string id) string[] chosenSymbols, Action> optionsCallback = null, int index = 0, - bool ignoreTrivia = true, + bool ignoreTrivia = false, CodeActionPriority? priority = null, TestParameters parameters = default(TestParameters)) { diff --git a/src/EditorFeatures/TestUtilities/MoveType/AbstractMoveTypeTest.cs b/src/EditorFeatures/TestUtilities/MoveType/AbstractMoveTypeTest.cs index 10dc17e228ce6..78ee4e93593f4 100644 --- a/src/EditorFeatures/TestUtilities/MoveType/AbstractMoveTypeTest.cs +++ b/src/EditorFeatures/TestUtilities/MoveType/AbstractMoveTypeTest.cs @@ -28,7 +28,7 @@ protected override CodeRefactoringProvider CreateCodeRefactoringProvider(Workspa string originalCode, string expectedCode = null, bool expectedCodeAction = true, - bool ignoreTrivia = true, + bool ignoreTrivia = false, string fixAllActionEquivalenceKey = null, object fixProviderData = null) { @@ -74,7 +74,7 @@ protected override CodeRefactoringProvider CreateCodeRefactoringProvider(Workspa string originalCode, string expectedDocumentName = null, bool expectedCodeAction = true, - bool ignoreTrivia = true, + bool ignoreTrivia = false, IList destinationDocumentContainers = null, string fixAllActionEquivalenceKey = null, object fixProviderData = null) @@ -150,7 +150,7 @@ protected override CodeRefactoringProvider CreateCodeRefactoringProvider(Workspa ImmutableArray destinationDocumentContainers = default(ImmutableArray), bool expectedCodeAction = true, int index = 0, - bool ignoreTrivia = true, + bool ignoreTrivia = false, Action onAfterWorkspaceCreated = null) { var testOptions = new TestParameters(); diff --git a/src/EditorFeatures/TestUtilities/TestExtensionErrorHandler.cs b/src/EditorFeatures/TestUtilities/TestExtensionErrorHandler.cs index 877c84bb28a53..2277f978369f2 100644 --- a/src/EditorFeatures/TestUtilities/TestExtensionErrorHandler.cs +++ b/src/EditorFeatures/TestUtilities/TestExtensionErrorHandler.cs @@ -1,9 +1,10 @@ // Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Collections.Generic; +using System.Collections.Immutable; using System.ComponentModel.Composition; -using Microsoft.CodeAnalysis.Text; +using System.Runtime.CompilerServices; +using System.Threading; using Microsoft.VisualStudio.Text; namespace Microsoft.CodeAnalysis.Editor.UnitTests @@ -12,7 +13,7 @@ namespace Microsoft.CodeAnalysis.Editor.UnitTests [Export(typeof(IExtensionErrorHandler))] internal class TestExtensionErrorHandler : IExtensionErrorHandler { - private List _exceptions = new List(); + private ImmutableList _exceptions = ImmutableList.Empty; public void HandleError(object sender, Exception exception) { @@ -20,20 +21,32 @@ public void HandleError(object sender, Exception exception) { // Log an exception saying we didn't get an exception. I'd consider throwing here, but double-faults are just caught and consumed by // the editor so that won't give a good debugging experience either. - _exceptions.Add(new Exception($"{nameof(TestExtensionErrorHandler)}.{nameof(HandleError)} called with null exception")); - } - else - { - _exceptions.Add(exception); + try + { + ThrowExceptionToGetStackTrace(); + } + catch (Exception e) + { + exception = e; + } } + + ImmutableInterlocked.Update( + ref _exceptions, + (list, item) => list.Add(item), + exception); + } + + [MethodImpl(MethodImplOptions.NoInlining)] + private static void ThrowExceptionToGetStackTrace() + { + throw new Exception($"{nameof(TestExtensionErrorHandler)}.{nameof(HandleError)} called with null exception"); } - public ICollection GetExceptions() + public ImmutableList GetExceptions() { // We'll clear off our list, so that way we don't report this for other tests - var newExceptions = _exceptions; - _exceptions = new List(); - return newExceptions; + return Interlocked.Exchange(ref _exceptions, ImmutableList.Empty); } } } diff --git a/src/EditorFeatures/TestUtilities2/Utilities/MockSymbolNavigationServiceProvider.vb b/src/EditorFeatures/TestUtilities2/Utilities/MockSymbolNavigationServiceProvider.vb index f3f4d1ca208a1..6cd5e83713428 100644 --- a/src/EditorFeatures/TestUtilities2/Utilities/MockSymbolNavigationServiceProvider.vb +++ b/src/EditorFeatures/TestUtilities2/Utilities/MockSymbolNavigationServiceProvider.vb @@ -29,7 +29,7 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.Utilities Public TryNavigateToSymbolProvidedOptions As OptionSet Public TrySymbolNavigationNotifyProvidedSymbol As ISymbol - Public TrySymbolNavigationNotifyProvidedSolution As Solution + Public TrySymbolNavigationNotifyProvidedProject As Project Public TrySymbolNavigationNotifyReturnValue As Boolean = False Public WouldNavigateToSymbolProvidedDefinitionItem As DefinitionItem @@ -47,10 +47,10 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.Utilities End Function Public Function TrySymbolNavigationNotify(symbol As ISymbol, - solution As Solution, + project As Project, cancellationToken As CancellationToken) As Boolean Implements ISymbolNavigationService.TrySymbolNavigationNotify Me.TrySymbolNavigationNotifyProvidedSymbol = symbol - Me.TrySymbolNavigationNotifyProvidedSolution = solution + Me.TrySymbolNavigationNotifyProvidedProject = project Return TrySymbolNavigationNotifyReturnValue End Function diff --git a/src/EditorFeatures/VisualBasicTest/AddAccessibilityModifiers/AddAccessibilityModifiersTests.vb b/src/EditorFeatures/VisualBasicTest/AddAccessibilityModifiers/AddAccessibilityModifiersTests.vb index e68ebba4fee6c..0c6767a60cea9 100644 --- a/src/EditorFeatures/VisualBasicTest/AddAccessibilityModifiers/AddAccessibilityModifiersTests.vb +++ b/src/EditorFeatures/VisualBasicTest/AddAccessibilityModifiers/AddAccessibilityModifiersTests.vb @@ -157,7 +157,7 @@ namespace N end sub Public property P1 as integer - + Public property P2 as integer get end get diff --git a/src/EditorFeatures/VisualBasicTest/AddParameter/AddParameterTests.vb b/src/EditorFeatures/VisualBasicTest/AddParameter/AddParameterTests.vb index f326ee40275eb..6e4ca53310f02 100644 --- a/src/EditorFeatures/VisualBasicTest/AddParameter/AddParameterTests.vb +++ b/src/EditorFeatures/VisualBasicTest/AddParameter/AddParameterTests.vb @@ -179,7 +179,8 @@ class D sub M() dim a = new C(1, true) end sub -end class") +end class +") End Function @@ -209,7 +210,8 @@ class D sub M() dim a = new C(true, 1) end sub -end class") +end class +") End Function diff --git a/src/EditorFeatures/VisualBasicTest/CodeActions/AbstractVisualBasicCodeActionTest.vb b/src/EditorFeatures/VisualBasicTest/CodeActions/AbstractVisualBasicCodeActionTest.vb index 04c6145f19370..6bcd7e6039b56 100644 --- a/src/EditorFeatures/VisualBasicTest/CodeActions/AbstractVisualBasicCodeActionTest.vb +++ b/src/EditorFeatures/VisualBasicTest/CodeActions/AbstractVisualBasicCodeActionTest.vb @@ -27,7 +27,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.CodeRefactorings Return input.Replace("\n", vbCrLf) End Function - Protected Overloads Async Function TestAsync(initialMarkup As XElement, expected As XElement, Optional index As Integer = 0, Optional ignoreTrivia As Boolean = True) As Threading.Tasks.Task + Protected Overloads Async Function TestAsync(initialMarkup As XElement, expected As XElement, Optional index As Integer = 0, Optional ignoreTrivia As Boolean = False) As Threading.Tasks.Task Dim initialMarkupStr = initialMarkup.ConvertTestSourceTag() Dim expectedStr = expected.ConvertTestSourceTag() diff --git a/src/EditorFeatures/VisualBasicTest/CodeActions/EncapsulateField/EncapsulateFieldTests.vb b/src/EditorFeatures/VisualBasicTest/CodeActions/EncapsulateField/EncapsulateFieldTests.vb index 41a92e571fdcc..550c76a5b86f2 100644 --- a/src/EditorFeatures/VisualBasicTest/CodeActions/EncapsulateField/EncapsulateFieldTests.vb +++ b/src/EditorFeatures/VisualBasicTest/CodeActions/EncapsulateField/EncapsulateFieldTests.vb @@ -525,7 +525,8 @@ Public Class Class1 Sub goo() Name = "" End Sub -End Class.ConvertTestSourceTag() +End Class +.ConvertTestSourceTag() Await TestInRegularAndScriptAsync(text, expected, ignoreTrivia:=False) End Function diff --git a/src/EditorFeatures/VisualBasicTest/CodeActions/ExtractMethod/ExtractMethodTests.vb b/src/EditorFeatures/VisualBasicTest/CodeActions/ExtractMethod/ExtractMethodTests.vb index f43abfde4918a..82082ed5b5800 100644 --- a/src/EditorFeatures/VisualBasicTest/CodeActions/ExtractMethod/ExtractMethodTests.vb +++ b/src/EditorFeatures/VisualBasicTest/CodeActions/ExtractMethod/ExtractMethodTests.vb @@ -34,6 +34,7 @@ End Class", Return {|Rename:GetArg|}(arg) End Function End Sub + Private Shared Function GetArg(arg As Integer) As Integer Return arg End Function @@ -60,6 +61,7 @@ Module Program Sub Main(args As String()) If True Then Dim q As Action = {|Rename:GetQ|}() End Sub + Private Function GetQ() As Action Return Sub() End Sub @@ -81,9 +83,11 @@ End Class", Sub Main() {|Rename:NewMethod|}() End Sub + Private Shared Sub NewMethod() Dim x As New List(Of Program) From {New Program} End Sub + Public Property Name As String End Class") End Function @@ -111,6 +115,7 @@ Module Program Dim q As Object If True Then q = {|Rename:NewMethod|}() End Sub + Private Function NewMethod() As Object Return Sub() End Sub @@ -164,6 +169,7 @@ End Module", Dim p As Object = Nothing Dim Obj1 = If(New With {.a = True}.a, p, {|Rename:NewMethod|}()) End Sub + Private Function NewMethod() As Object Return Nothing End Function @@ -183,6 +189,7 @@ End Module", Sub Main() Dim x(0 To {|Rename:NewMethod|}()) ' Extract method End Sub + Private Function NewMethod() As Integer Return 1 + 2 End Function @@ -208,6 +215,7 @@ End Module", x += 1 Loop End Sub + Private Function NewMethod(x As Integer) As Boolean Return x * x < 100 End Function @@ -277,6 +285,7 @@ End Module", Sub Main() {|Rename:NewMethod|}() End Sub + Private Sub NewMethod() With """""""" Dim x = .GetHashCode Xor &H7F3E ' Introduce Local @@ -455,9 +464,11 @@ End Namespace", Dim x As (Integer, Integer) = {|Rename:NewMethod|}() M(x) End Sub + Private Shared Function NewMethod() As (Integer, Integer) Return (1, 2) End Function + Private Sub M(x As (Integer, Integer)) End Sub End Class @@ -488,6 +499,7 @@ End Namespace", Dim x As (a As Integer, b As Integer) = {|Rename:NewMethod|}() System.Console.WriteLine(x.a) End Sub + Private Shared Function NewMethod() As (a As Integer, b As Integer) Return (1, 2) End Function @@ -519,6 +531,7 @@ End Namespace", Dim x As (a As Integer, Integer) = {|Rename:NewMethod|}() System.Console.WriteLine(x.a) End Sub + Private Shared Function NewMethod() As (a As Integer, Integer) Return (1, 2) End Function diff --git a/src/EditorFeatures/VisualBasicTest/CodeActions/InlineTemporary/InlineTemporaryTests.vb b/src/EditorFeatures/VisualBasicTest/CodeActions/InlineTemporary/InlineTemporaryTests.vb index 4e869ec659d9b..65d80870deb97 100644 --- a/src/EditorFeatures/VisualBasicTest/CodeActions/InlineTemporary/InlineTemporaryTests.vb +++ b/src/EditorFeatures/VisualBasicTest/CodeActions/InlineTemporary/InlineTemporaryTests.vb @@ -3152,6 +3152,7 @@ Module M Dim z = 1 End Sub End Module + Await TestAsync(code, expected, ignoreTrivia:=False) End Function diff --git a/src/EditorFeatures/VisualBasicTest/CodeActions/IntroduceVariable/IntroduceVariableTests.vb b/src/EditorFeatures/VisualBasicTest/CodeActions/IntroduceVariable/IntroduceVariableTests.vb index e1a2fc9a4a2eb..543fc9197d6a8 100644 --- a/src/EditorFeatures/VisualBasicTest/CodeActions/IntroduceVariable/IntroduceVariableTests.vb +++ b/src/EditorFeatures/VisualBasicTest/CodeActions/IntroduceVariable/IntroduceVariableTests.vb @@ -341,8 +341,8 @@ End Module" Dim GooMember1 As String End Structure Sub Main(x As Integer) - Const {|Rename:V|} As String = ""t"" + ""test"" - Dim f1 = New GooStruct With {.GooMember1 = V} + Const {|Rename:V|} As String = ""t"" + ""test"" + Dim f1 = New GooStruct With {.GooMember1 = V} End Sub End Module" Await TestInRegularAndScriptAsync(source, expected, index:=2) @@ -393,8 +393,8 @@ End Module End Sub End Class" Dim expected = "Class Program - Private Const {|Rename:V|} As String = ""t"" + ""test"" - Dim q = New With {.str = V} + Private Const {|Rename:V|} As String = ""t"" + ""test"" + Dim q = New With {.str = V} Dim r = New With {.str = V} Sub Goo() Dim x = V @@ -466,6 +466,7 @@ End Class" End Module" Dim expected = "Module Module1 Private Const {|Rename:V|} As Integer = 42 + Sub Goo(Optional x As Integer = V) End Sub End Module" @@ -483,6 +484,7 @@ End Module" End Module" Dim expected = "Module Module1 Private Const {|Rename:V|} As Integer = 42 + Sub Bar(Optional x As Integer = V) End Sub Sub Goo(Optional x As Integer = V) @@ -692,6 +694,7 @@ count:=2) End Class", "Class Goo Private Const {|Rename:V|} As Integer = 2 + 2 + Sub New() Me.New(V) End Sub @@ -827,6 +830,7 @@ End Class") End Class", "Class Goo Private Const {|Rename:X|} As Integer = 42 + Sub New() MyClass.New(X) End Sub @@ -1014,6 +1018,7 @@ Imports System.Linq Module Program Sub Main(args As String()) Dim q As Object + If True Then Dim {|Rename:p|} As Object = Sub() End Sub @@ -1111,10 +1116,11 @@ count:=2) NewLines(input), "Module Program Private Const {|Rename:V|} As String = """" - - Sub Main(args As String()) - End Sub -End Module") + + + Sub Main(args As String()) + End Sub + End Module") End Function @@ -1257,10 +1263,9 @@ End Module", "Imports System Module Program Sub Main - Dim a = Sub(x As Integer) - Dim {|Rename:value|} As Integer = x + 1 - Console.WriteLine(value) ' Introduce local - End Sub + Dim a = Sub(x As Integer) Dim {|Rename:value|} As Integer = x + 1 + Console.WriteLine(value) + End Sub ' Introduce local End Sub End Module") End Function @@ -1279,6 +1284,7 @@ End Module", Module Program Sub Main Dim a = Sub(x As Integer) + If True Then Dim {|Rename:value|} As Integer = x + 1 Console.WriteLine(value) @@ -1304,6 +1310,7 @@ End Module", Module Program Sub Main Dim a = Sub(x As Integer) + If True Then Console.WriteLine() Else @@ -1350,8 +1357,7 @@ index:=1) End Module", "Module Program Sub Main(args As String()) - Dim query = Sub(a) - Dim {|Rename:arg1|} As Object = a Or a + Dim query = Sub(a) Dim {|Rename:arg1|} As Object = a Or a a = New With {Key .Key = Function(ByVal arg As Integer) As Integer Return arg End Function}.Key.Invoke(arg1) @@ -1442,7 +1448,8 @@ End Class", "Imports System.Linq Public Class Base Public Function Sample(ByVal arg As Integer) As Integer - Dim results = From s In New Integer() {1} Let {|Rename:v|} = Sample(s) + Dim results = From s In New Integer() {1} + Let {|Rename:v|} = Sample(s) Select v Return 0 End Function @@ -1480,8 +1487,8 @@ End Class", "Imports System.Linq Public Class Base Public Function Sample(ByVal arg As Integer) As Integer - Dim results = From s In New Integer() {1} Let {|Rename:v|} = Sample(s) - Where v > 21 + Dim results = From s In New Integer() {1} + Let {|Rename:v|} = Sample(s) Where v > 21 Select Sample(s) Return 0 End Function @@ -1504,8 +1511,8 @@ End Class", "Imports System.Linq Public Class Base Public Function Sample(ByVal arg As Integer) As Integer - Dim results = From s In New Integer() {1} Let {|Rename:v|} = Sample(s) - Where v > 21 + Dim results = From s In New Integer() {1} + Let {|Rename:v|} = Sample(s) Where v > 21 Select v Return 0 End Function @@ -1530,7 +1537,8 @@ End Class", Public Class Base Public Function Sample(ByVal arg As Integer) As Integer Dim results = From s In New Integer() {1} - Where Sample(s) > 21 Let {|Rename:v|} = Sample(s) + Where Sample(s) > 21 + Let {|Rename:v|} = Sample(s) Select v Return 0 End Function @@ -1552,7 +1560,8 @@ End Class", "Imports System.Linq Public Class Base Public Function Sample(ByVal arg As Integer) As Integer - Dim results = From s In New Integer() {1} Let {|Rename:v|} = Sample(s) + Dim results = From s In New Integer() {1} + Let {|Rename:v|} = Sample(s) Where v > 21 Select v Return 0 @@ -1776,8 +1785,8 @@ End Module") Property Prop As New List(Of String) From {[|""One""|], ""two""} End Module", "Module Module1 - Private Const {|Rename:V|} As String = ""One"" - Property Prop As New List(Of String) From {V, ""two""} + Private Const {|Rename:V|} As String = ""One"" + Property Prop As New List(Of String) From {V, ""two""} End Module") End Function @@ -1993,8 +2002,9 @@ Partial Class C End Sub End Class", "Partial Class C - Private Const {|Rename:V|} As String = ""HELLO"" - Sub goo1(Optional x As String = V) + Private Const {|Rename:V|} As String = ""HELLO"" + + Sub goo1(Optional x As String = V) End Sub End Class Partial Class C @@ -2071,6 +2081,7 @@ Imports System.Collections.Generic Imports System.Linq Module Program Private Const {|Rename:V|} As Boolean = True + Sub Main(args As String()) If V Then End If diff --git a/src/EditorFeatures/VisualBasicTest/CodeActions/InvertIf/InvertIfTests.vb b/src/EditorFeatures/VisualBasicTest/CodeActions/InvertIf/InvertIfTests.vb index 9db799c17cbfd..d22cb44a5d031 100644 --- a/src/EditorFeatures/VisualBasicTest/CodeActions/InvertIf/InvertIfTests.vb +++ b/src/EditorFeatures/VisualBasicTest/CodeActions/InvertIf/InvertIfTests.vb @@ -880,7 +880,7 @@ End Module", Sub Main(args As String()) Dim x() As String If x.Length = 0x0 Then - EqualsZero() + EqualsZero() Else GreaterThanZero() End If @@ -1360,6 +1360,7 @@ Module Program End Select End Sub End Module + Await TestAsync(markup, expected, ignoreTrivia:=False) diff --git a/src/EditorFeatures/VisualBasicTest/CodeActions/MoveType/BasicMoveTypeTestsBase.vb b/src/EditorFeatures/VisualBasicTest/CodeActions/MoveType/BasicMoveTypeTestsBase.vb index 2fbb0a9593811..f584b170a3f0e 100644 --- a/src/EditorFeatures/VisualBasicTest/CodeActions/MoveType/BasicMoveTypeTestsBase.vb +++ b/src/EditorFeatures/VisualBasicTest/CodeActions/MoveType/BasicMoveTypeTestsBase.vb @@ -30,7 +30,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.CodeRefactorings.M originalCode As XElement, Optional expectedCode As XElement = Nothing, Optional expectedCodeAction As Boolean = True, - Optional ignoreTrivia As Boolean = True + Optional ignoreTrivia As Boolean = False ) As Task Dim expectedText As String = Nothing @@ -46,7 +46,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.CodeRefactorings.M originalCode As XElement, Optional expectedDocumentName As String = Nothing, Optional expectedCodeAction As Boolean = True, - Optional ignoreTrivia As Boolean = True + Optional ignoreTrivia As Boolean = False ) As Task Return MyBase.TestRenameFileToMatchTypeAsync( @@ -61,7 +61,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.CodeRefactorings.M Optional destinationDocumentContainers As ImmutableArray(Of String) = Nothing, Optional expectedCodeAction As Boolean = True, Optional index As Integer = 0, - Optional ignoreTrivia As Boolean = True + Optional ignoreTrivia As Boolean = False ) As Task Dim originalCodeText = originalCode.ConvertTestSourceTag() diff --git a/src/EditorFeatures/VisualBasicTest/CodeActions/MoveType/MoveTypeTests.MoveToNewFile.vb b/src/EditorFeatures/VisualBasicTest/CodeActions/MoveType/MoveTypeTests.MoveToNewFile.vb index 2f8bdf9ba13a5..4475eb204bb8d 100644 --- a/src/EditorFeatures/VisualBasicTest/CodeActions/MoveType/MoveTypeTests.MoveToNewFile.vb +++ b/src/EditorFeatures/VisualBasicTest/CodeActions/MoveType/MoveTypeTests.MoveToNewFile.vb @@ -46,8 +46,7 @@ End Class Dim expectedDocumentName = "Class1.vb" Dim destinationDocumentText = -" -Class Class1 +"Class Class1 End Class " Await TestMoveTypeToNewFileAsync(code, codeAfterMove, expectedDocumentName, destinationDocumentText) @@ -99,7 +98,6 @@ End Class " Public Partial Class Class1 Class Class2 - End Class End Class " @@ -158,6 +156,8 @@ End Class " Dim codeAfterMove = " +' Used only by inner + ' Not used Imports System.Collections @@ -171,6 +171,8 @@ End Class ' Used only by inner Imports System +' Not used + Partial Class Outer Class Inner Sub M(d as DateTime) @@ -204,7 +206,8 @@ End Class Partial Class Outer Inherits Something Implements ISomething -End Class" +End Class +" Dim expectedDocumentName = "Inner.vb" Dim destinationDocumentText = @@ -217,7 +220,8 @@ Partial Class Outer Sub M(d as DateTime) End Sub End Class -End Class" +End Class +" Await TestMoveTypeToNewFileAsync(code, codeAfterMove, expectedDocumentName, destinationDocumentText) End Function End Class diff --git a/src/EditorFeatures/VisualBasicTest/CodeActions/ReplaceMethodWithProperty/ReplaceMethodWithPropertyTests.vb b/src/EditorFeatures/VisualBasicTest/CodeActions/ReplaceMethodWithProperty/ReplaceMethodWithPropertyTests.vb index f4d6798e48d9d..bca7a6a8e1aa6 100644 --- a/src/EditorFeatures/VisualBasicTest/CodeActions/ReplaceMethodWithProperty/ReplaceMethodWithPropertyTests.vb +++ b/src/EditorFeatures/VisualBasicTest/CodeActions/ReplaceMethodWithProperty/ReplaceMethodWithPropertyTests.vb @@ -92,7 +92,8 @@ End class") End function End class", "class C - ReadOnly Property Goo as integer + + ReadOnly Property Goo as integer Get End Get End Property @@ -136,6 +137,106 @@ End class", End class") End Function + + Public Async Function TestIfDefMethod2() As Task + Await TestInRegularAndScriptAsync( +"class C +#if true + function [||]GetGoo() as integer + End function + + sub SetGoo(i as integer) + end sub +#End if +End class", +"class C +#if true + ReadOnly Property Goo as integer + Get + End Get + End Property + + sub SetGoo(i as integer) + end sub +#End if +End class") + End Function + + + Public Async Function TestIfDefMethod3() As Task + Await TestInRegularAndScriptAsync( +"class C +#if true + function [||]GetGoo() as integer + End function + + sub SetGoo(i as integer) + end sub +#End if +End class", +"class C +#if true + Property Goo as integer + Get + End Get + Set(i as integer) + End Set + End Property +#End if +End class", index:=1) + End Function + + + Public Async Function TestIfDefMethod4() As Task + Await TestInRegularAndScriptAsync( +"class C +#if true + sub SetGoo(i as integer) + end sub + + function [||]GetGoo() as integer + End function +#End if +End class", +"class C +#if true + sub SetGoo(i as integer) + end sub + + ReadOnly Property Goo as integer + Get + End Get + End Property +#End if +End class") + End Function + + + Public Async Function TestIfDefMethod5() As Task + Await TestInRegularAndScriptAsync( +"class C +#if true + sub SetGoo(i as integer) + end sub + + function [||]GetGoo() as integer + End function +#End if +End class", +"class C + +#if true + + Property Goo as integer + Get + End Get + Set(i as integer) + End Set + End Property +#End if +End class", index:=1) + End Function + Public Async Function TestMethodWithTrivia_2() As Task Await TestInRegularAndScriptAsync( @@ -286,6 +387,7 @@ End class", Get End Get End Property + sub Bar() dim x = Goo End sub @@ -307,6 +409,7 @@ End class", Get End Get End Property + sub Bar() dim x = me.Goo End sub @@ -329,6 +432,7 @@ End class", Get End Get End Property + sub Bar() dim x as C dim v = x?.Goo @@ -395,6 +499,7 @@ End class", Get End Get End Property + sub Bar() dim i = Goo End sub @@ -442,6 +547,7 @@ class C Set(i as integer) End Set End Property + sub Bar() dim i as Action(of integer) = addressof {|Conflict:Goo|} End sub @@ -460,10 +566,11 @@ index:=1) End class", "class C public Property Goo as integer - Get End Get - Private Set(i as integer) - End Set - End Property + Get + End Get + Private Set(i as integer) + End Set + End Property End class", index:=1) End Function @@ -487,9 +594,9 @@ End class", Set(i as integer) End Set End Property + sub Bar() - Goo = Goo + 1 - End sub + Goo = Goo + 1 End sub End class", index:=1) End Function diff --git a/src/EditorFeatures/VisualBasicTest/CodeActions/ReplacePropertyWithMethods/ReplacePropertyWithMethodsTests.vb b/src/EditorFeatures/VisualBasicTest/CodeActions/ReplacePropertyWithMethods/ReplacePropertyWithMethodsTests.vb index 20dd5a648f92a..59c03143938b8 100644 --- a/src/EditorFeatures/VisualBasicTest/CodeActions/ReplacePropertyWithMethods/ReplacePropertyWithMethodsTests.vb +++ b/src/EditorFeatures/VisualBasicTest/CodeActions/ReplacePropertyWithMethods/ReplacePropertyWithMethodsTests.vb @@ -86,8 +86,9 @@ end class", Public Function GetProp() As Integer return 0 End Function + public sub M() - dim v = new with { .P = me.GetProp() } + dim v = new with { .P = me.GetProp()} end sub end class") End Function @@ -109,8 +110,10 @@ end class", Public Function GetProp() As Integer return 0 End Function + public sub M() - dim v = new with { .Prop = me.GetProp() } + dim v = new with { + .Prop = me.GetProp()} end sub end class") End Function @@ -134,6 +137,7 @@ end class", Public Function GetProp() As Integer return 0 End Function + public sub RefM(byref i as integer) end sub public sub M() @@ -175,7 +179,8 @@ end class class D -end class") +end class +") End Function @@ -229,9 +234,10 @@ end class", Public Sub SetProp(val As Integer) dim v = val End Sub - sub M() - me.SetProp(1) - end sub + + sub M() + me.SetProp(1 +) end sub end class") End Function @@ -252,6 +258,7 @@ end class", Public Function GetProp() As Integer return 0 End Function + Public Sub SetProp(Value As Integer) dim v = value End Sub @@ -287,7 +294,8 @@ end class") end class", "class C Public Sub SetProp(Value As Integer) - me.SetProp(value + 1) + me.SetProp(value + 1 +) End Sub end class") End Function @@ -303,6 +311,7 @@ end class") end class", "class C Public MustOverride Function GetProp() As Integer + public sub M() dim v = me.GetProp() end sub @@ -327,6 +336,7 @@ end class", Public Overridable Function GetProp() As Integer return 0 End Function + public sub M() dim v = me.GetProp() end sub @@ -375,6 +385,7 @@ end interface") end class", "class C Private _Prop As Integer + Public Function GetProp() As Integer Return _Prop End Function @@ -392,9 +403,11 @@ end class") end class", "class C Private _Prop As Integer + Public Function GetProp() As Integer Return _Prop End Function + public sub new() me._Prop = 1 end sub diff --git a/src/EditorFeatures/VisualBasicTest/CodeActions/UseNamedArguments/UseNamedArgumentsTests.vb b/src/EditorFeatures/VisualBasicTest/CodeActions/UseNamedArguments/UseNamedArgumentsTests.vb index a9d42be2e697a..e88791498de7b 100644 --- a/src/EditorFeatures/VisualBasicTest/CodeActions/UseNamedArguments/UseNamedArgumentsTests.vb +++ b/src/EditorFeatures/VisualBasicTest/CodeActions/UseNamedArguments/UseNamedArgumentsTests.vb @@ -225,7 +225,7 @@ End Class") End Class", "Class C Sub M(arg1 As Integer, optional arg2 As Integer=1, optional arg3 as Integer=1) - M(1,,arg3:=3) + M(1,, arg3:=3) End Sub End Class") End Function diff --git a/src/EditorFeatures/VisualBasicTest/ConvertToInterpolatedString/ConvertPlaceholderToInterpolatedStringTests.vb b/src/EditorFeatures/VisualBasicTest/ConvertToInterpolatedString/ConvertPlaceholderToInterpolatedStringTests.vb index 0312a40097909..c2fb7bdcb73ca 100644 --- a/src/EditorFeatures/VisualBasicTest/ConvertToInterpolatedString/ConvertPlaceholderToInterpolatedStringTests.vb +++ b/src/EditorFeatures/VisualBasicTest/ConvertToInterpolatedString/ConvertPlaceholderToInterpolatedStringTests.vb @@ -28,7 +28,7 @@ End Module.ConvertTestSourceTag() Imports System Module T Sub M() - Dim a = $"{1}" + Dim a = $"{1 }" End Sub End Module.ConvertTestSourceTag() @@ -49,7 +49,7 @@ End Module.ConvertTestSourceTag() Imports System Module T Sub M() - Dim a = $"{1}{2}{3}" + Dim a = $"{1 }{2 }{3 }" End Sub End Module.ConvertTestSourceTag() @@ -70,7 +70,7 @@ End Module.ConvertTestSourceTag() Imports System Module T Sub M() - Dim a = $"{1}{3}{2}" + Dim a = $"{1 }{3 }{2 }" End Sub End Module.ConvertTestSourceTag() @@ -91,7 +91,7 @@ End Module.ConvertTestSourceTag() Imports System Module T Sub M() - Dim a = $"{1}{1}{1}" + Dim a = $"{1 }{1 }{1 }" End Sub End Module.ConvertTestSourceTag() @@ -133,7 +133,7 @@ End Module.ConvertTestSourceTag() Imports System Module T Sub M() - Dim a = $"{0.5}{"Hello"}{3}" + Dim a = $"{0.5 }{"Hello" }{3 }" End Sub End Module.ConvertTestSourceTag() @@ -154,7 +154,7 @@ End Module.ConvertTestSourceTag() Imports System Module T Sub M() - Dim a = $"{0.5}{"Hello"}{3}" + Dim a = $"{0.5 }{"Hello" }{3 }" End Sub End Module.ConvertTestSourceTag() @@ -175,7 +175,7 @@ End Module.ConvertTestSourceTag() Imports System Module T Sub M() - Dim a = $"{(New Object)}" + Dim a = $"{(New Object) }" End Sub End Module.ConvertTestSourceTag() @@ -198,9 +198,7 @@ End Module.ConvertTestSourceTag() Imports System Module T Sub M() - Dim a = $"{If(True, - "Yes", - TryCast(False, Object))}" + Dim a = $"{If(True, "Yes", TryCast(False, Object)) }" End Sub End Module.ConvertTestSourceTag() @@ -276,7 +274,7 @@ Module T Dim population As Integer() = {1025632, 1105967, 1148203} Dim s = String.Format("{0,6} {1,15}\n\n", "Year", "Population") For index = 0 To years.Length - 1 - s += $"{years(index),6} {population(index),15: N0}\n" + s += $"{years(index), 6} {population(index), 15: N0}\n" Next End Sub End Module.ConvertTestSourceTag() @@ -450,7 +448,7 @@ End Module.ConvertTestSourceTag() Imports System Module T Sub M() - Dim a = $"This {"test"} {"also"} works" + Dim a = $"This {"test" } {"also" } works" End Sub End Module.ConvertTestSourceTag() @@ -472,7 +470,7 @@ End Module.ConvertTestSourceTag() Imports System Module T Sub M() - Dim a = $"This {"test"} {"also"} works" + Dim a = $"This {"test" } {"also" } works" End Sub End Module.ConvertTestSourceTag() @@ -494,7 +492,7 @@ End Module.ConvertTestSourceTag() Imports System Module T Sub M() - Dim a = $"{"10"} {"11"} {"12"}" + Dim a = $"{"10" } {"11" } {"12" }" End Sub End Module.ConvertTestSourceTag() @@ -516,7 +514,7 @@ End Module.ConvertTestSourceTag() Imports System Module T Sub M() - Dim a = $"{"10"} {"11"} {"12"}" + Dim a = $"{"10" } {"11" } {"12" }" End Sub End Module.ConvertTestSourceTag() @@ -538,7 +536,7 @@ End Module.ConvertTestSourceTag() Imports System Module T Sub M() - Dim a = $"{"10"} {"11"} {"12"} {3}" + Dim a = $"{"10" } {"11" } {"12" } {3}" End Sub End Module.ConvertTestSourceTag() @@ -560,7 +558,7 @@ End Module.ConvertTestSourceTag() Imports System Module T Sub M() - Dim a = $"{"10"} {"11"} {"12"}" + Dim a = $"{"10" } {"11" } {"12" }" End Sub End Module.ConvertTestSourceTag() diff --git a/src/EditorFeatures/VisualBasicTest/Diagnostics/AbstractVisualBasicDiagnosticProviderBasedUserDiagnosticTest.vb b/src/EditorFeatures/VisualBasicTest/Diagnostics/AbstractVisualBasicDiagnosticProviderBasedUserDiagnosticTest.vb index 7f174a5194036..b87194910fa67 100644 --- a/src/EditorFeatures/VisualBasicTest/Diagnostics/AbstractVisualBasicDiagnosticProviderBasedUserDiagnosticTest.vb +++ b/src/EditorFeatures/VisualBasicTest/Diagnostics/AbstractVisualBasicDiagnosticProviderBasedUserDiagnosticTest.vb @@ -26,7 +26,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.Diagnostics Friend Overloads Async Function TestAsync( initialMarkup As XElement, expected As XElement, Optional index As Integer = 0, - Optional ignoreTrivia As Boolean = True, Optional priority As CodeActionPriority? = Nothing) As Threading.Tasks.Task + Optional ignoreTrivia As Boolean = False, Optional priority As CodeActionPriority? = Nothing) As Threading.Tasks.Task Dim initialMarkupStr = initialMarkup.ConvertTestSourceTag() Dim expectedStr = expected.ConvertTestSourceTag() diff --git a/src/EditorFeatures/VisualBasicTest/Diagnostics/AddImport/AddImportTests.vb b/src/EditorFeatures/VisualBasicTest/Diagnostics/AddImport/AddImportTests.vb index 6267f9297adb0..5ce2bf55a166e 100644 --- a/src/EditorFeatures/VisualBasicTest/Diagnostics/AddImport/AddImportTests.vb +++ b/src/EditorFeatures/VisualBasicTest/Diagnostics/AddImport/AddImportTests.vb @@ -17,7 +17,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.CodeActions.AddImp Friend Overloads Async Function TestAsync(initialMarkup As String, expectedMarkup As String, Optional index As Integer = 0, - Optional ignoreTrivia As Boolean = True, + Optional ignoreTrivia As Boolean = False, Optional priority As CodeActionPriority? = Nothing, Optional placeSystemFirst As Boolean = True) As Task Await TestAsync(initialMarkup, expectedMarkup, index, ignoreTrivia, priority, placeSystemFirst, outOfProcess:=False) @@ -66,6 +66,7 @@ Namespace SomeNamespace End Class End Namespace", "Imports SomeNamespace + Class Class1 Dim v As SomeClass1 End Class @@ -88,8 +89,7 @@ Class Class1 Inherits [|Textbox|] End Class", -" -Imports N1 +"Imports N1 Namespace N1 Public Class TextBox @@ -109,6 +109,7 @@ End Class", priority:=CodeActionPriority.Medium) Dim v As [|Thread|] End Class", "Imports System.Threading + Class Class1 Dim v As Thread End Class") @@ -133,6 +134,7 @@ End Namespace Class SomeClass(Of x As [|Base|]) End Class", "Imports SomeNamespace + Namespace SomeNamespace Class Base End Class @@ -156,6 +158,7 @@ Class Goo End Sub End Class", "Imports SomeNamespace + Namespace SomeNamespace Class SomeClass End Class @@ -181,6 +184,7 @@ Class Goo End Sub End Class", "Imports SomeNamespace + Namespace SomeNamespace Class SomeClass End Class @@ -206,6 +210,7 @@ Class Goo End Sub End Class", "Imports SomeNamespace + Namespace SomeNamespace Class SomeClass End Class @@ -231,6 +236,7 @@ Namespace SomeNamespace End Class End Namespace", "Imports SomeNamespace + Class Goo End Class @@ -257,6 +263,7 @@ Namespace SomeNamespace End Class End Namespace", "Imports SomeNamespace + Class Goo @@ -287,6 +294,7 @@ Namespace SomeNamespace End Class End Namespace", "Imports SomeNamespace + Class Goo @@ -312,6 +320,7 @@ Namespace [Namespace] End Class End Namespace", "Imports [Namespace] + Class SomeClass Dim x As Something End Class @@ -334,6 +343,7 @@ Namespace Outer End Namespace End Namespace", "Imports Outer.Namespace + Class SomeClass Dim x As Something End Class @@ -395,6 +405,7 @@ Namespace SomeNamespace End Class End Namespace", "Imports SomeNamespace + Class Goo Dim x As SomeClass End Class @@ -412,6 +423,7 @@ End Namespace") End Function End Class", "Imports System.Collections + Class Goo Function F() As IDictionary End Function @@ -426,6 +438,7 @@ End Class") End Function End Class", "Imports System.Collections.Generic + Class Goo Function F() As IDictionary End Function @@ -441,6 +454,7 @@ index:=1) End Function End Class", "Imports System.Collections.Generic + Class Goo Function F() As List End Function @@ -455,6 +469,7 @@ End Class") End Function End Class", "Imports System.Collections.Generic + Class Goo Function F() As List(Of Integer) End Function @@ -488,6 +503,7 @@ End Class") End Sub End Class", "Imports System.Collections.Generic + Class Goo Sub Test() Dim x As New List(Of Integer) @@ -504,6 +520,7 @@ End Class") End Sub End Class", "Imports System + Class Goo Sub Test() Dim x As New List(Of Int32) @@ -522,6 +539,7 @@ Class Goo End Class", "Imports System Imports System.Collections.Generic + Class Goo Sub Test() Dim x As New List(Of Integer) @@ -542,6 +560,7 @@ Namespace NS End Namespace", "Imports System Imports System.Collections.Generic + Namespace NS Class Goo Sub Test() @@ -598,6 +617,7 @@ Class Test End Class", "Imports System.Collections.Generic Imports System.Linq + Class Test Private Sub Method(args As IList(Of Integer)) args.Where() @@ -662,6 +682,7 @@ Namespace SomeNamespace End Namespace End Namespace", "Imports SomeNamespace + Class GOo Sub bar() Dim q As InnerNamespace.SomeClass @@ -690,6 +711,7 @@ Namespace SomeNamespace End Namespace End Namespace", "Imports SomeNamespace + Class GOo Sub bar() Dim q As InnerNamespace.SomeClass @@ -719,6 +741,7 @@ Namespace OUTER End Namespace End Namespace", "Imports OUTER.INNER + Module Program Sub Main(args As String()) Dim x As GOO @@ -786,6 +809,7 @@ ignoreTrivia:=False) End Sub End Class", "Imports System.Linq + Class Program Public Sub Linq1() Dim numbers() As Integer = New Integer(9) {5, 4, 1, 3, 9, 8, 6, 7, 2, 0} @@ -809,6 +833,7 @@ Class Program End Class", "Imports System.Collections.Generic Imports System.Linq + Class Program Public Sub Linq1() Dim numbers() As Integer = New Integer(9) {5, 4, 1, 3, 9, 8, 6, 7, 2, 0} @@ -840,6 +865,7 @@ End Class") End Sub End Module", "Imports System.IO + Module Program Sub Main(args As String()) File @@ -860,11 +886,11 @@ Class C #End ExternalSource End Sub End Class", -"#ExternalSource (""Default.aspx"", 1) +"#ExternalSource (""Default.aspx"", 1) Imports System Imports System.IO #End ExternalSource -#ExternalSource (""Default.aspx"", 2) +#ExternalSource (""Default.aspx"", 2) Class C Sub Goo() Dim x As New [|StreamReader|] @@ -945,6 +971,7 @@ ignoreTrivia:=False) End Sub End Module", "Imports System.IO + Module Goo Sub Bar(args As String()) Dim a = From f In args @@ -964,6 +991,7 @@ End Module") End Sub End Module", "Imports System.IO + Module Goo Sub Bar(args As String()) Dim a = From f In args @@ -988,6 +1016,7 @@ Class C End Class", "Imports System.Diagnostics Imports N + Namespace N Public Class Log End Class @@ -1006,6 +1035,7 @@ End Class", index:=1) "<[|Description|]> Public Class Description End Class", "Imports System.ComponentModel + <[|Description|]> Public Class Description End Class") End Function @@ -1038,6 +1068,7 @@ End Namespace", "Option Strict On Imports System.Runtime.CompilerServices Imports NS2 + Namespace NS1 Class Program Sub main() @@ -1088,6 +1119,7 @@ End Namespace", "Option Strict On Imports System.Runtime.CompilerServices Imports NS2 + Namespace NS1 Class Program Sub main() @@ -1148,6 +1180,7 @@ End Namespace", Imports System.Runtime.CompilerServices Imports NS2 Imports NS3 + Namespace NS1 Class Program Sub main() @@ -1477,7 +1510,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.AutomaticCompletion End Class End Namespace", "Imports System -Imports Microsoft.VisualStudio.Utilities +Imports Microsoft.VisualStudio.Utilities Namespace Microsoft.VisualStudio.Utilities Public Class ContentTypeAttribute @@ -1877,6 +1910,7 @@ End Namespace", Imports System.Collections Imports System.Runtime.CompilerServices Imports Ext + Class X Implements IEnumerable Public Function GetEnumerator() As IEnumerator Implements IEnumerable.GetEnumerator @@ -1919,6 +1953,7 @@ End Namespace", Imports System.Collections Imports System.Runtime.CompilerServices Imports Ext + Class X Implements IEnumerable Public Function GetEnumerator() As IEnumerator Implements IEnumerable.GetEnumerator @@ -1961,6 +1996,7 @@ End Namespace", Imports System.Collections Imports System.Runtime.CompilerServices Imports Ext + Class X Implements IEnumerable Public Function GetEnumerator() As IEnumerator Implements IEnumerable.GetEnumerator @@ -2003,6 +2039,7 @@ End Namespace", Imports System.Collections Imports System.Runtime.CompilerServices Imports Ext + Class X Implements IEnumerable Public Function GetEnumerator() As IEnumerator Implements IEnumerable.GetEnumerator @@ -2045,6 +2082,7 @@ End Namespace", Imports System.Collections Imports System.Runtime.CompilerServices Imports Ext + Class X Implements IEnumerable Public Function GetEnumerator() As IEnumerator Implements IEnumerable.GetEnumerator @@ -2094,6 +2132,7 @@ End Namespace", Imports System.Collections Imports System.Runtime.CompilerServices Imports Ext + Class X Implements IEnumerable Public Function GetEnumerator() As IEnumerator Implements IEnumerable.GetEnumerator @@ -2150,6 +2189,7 @@ End Namespace", Imports System.Collections Imports System.Runtime.CompilerServices Imports Ext2 + Class X Implements IEnumerable Public Function GetEnumerator() As IEnumerator Implements IEnumerable.GetEnumerator @@ -2197,6 +2237,7 @@ End Namespace", "Imports System.Linq Imports System.Runtime.CompilerServices Imports X + Module Program Sub Main(args As String()) Dim i = 0.All() @@ -2235,6 +2276,7 @@ End Namespace", "Imports System.Linq Imports System.Runtime.CompilerServices Imports X + Module Program Sub Main(args As String()) Dim a = New Integer? @@ -2282,6 +2324,7 @@ End Namespace", "Imports System.Runtime.CompilerServices Imports X Imports Y + Module Program Sub Main(args As String()) Dim a = 0 @@ -2337,6 +2380,7 @@ End Namespace", "Imports System.Runtime.CompilerServices Imports X Imports Y + Module Program Sub Main(args As String()) Dim a = New Integer? @@ -2436,6 +2480,7 @@ End Namespace", placeSystemFirst:=True) <[|Extension|]> End Class", "Imports System.Runtime.CompilerServices + Class Class1 End Class") @@ -2452,6 +2497,7 @@ End Class") End Class", "Imports System.Collections.Generic + Class C Inherits Attribute Public Sub New(x As System.Type) @@ -2468,6 +2514,7 @@ End Class") <[|Tasks.Task|]> End Class", "Imports System.Threading + Class Class1 End Class") @@ -2481,6 +2528,7 @@ End Class") <[|Extension|]> End Module", "Imports System.Runtime.CompilerServices + Module Goo End Module") @@ -2490,6 +2538,7 @@ End Module") <[|Extension()|]> End Module", "Imports System.Runtime.CompilerServices + Module Goo End Module") @@ -2526,6 +2575,7 @@ Namespace T End Class End Namespace", "Imports T + Class A Dim a As Action = Sub() Try @@ -2554,6 +2604,7 @@ Class C Dim a = New [|Test|]()", "Imports System.Linq Imports X + Namespace X Class Test End Class diff --git a/src/EditorFeatures/VisualBasicTest/Diagnostics/Async/AddAwaitTests.vb b/src/EditorFeatures/VisualBasicTest/Diagnostics/Async/AddAwaitTests.vb index 65d70d870c464..57ae448d5f657 100644 --- a/src/EditorFeatures/VisualBasicTest/Diagnostics/Async/AddAwaitTests.vb +++ b/src/EditorFeatures/VisualBasicTest/Diagnostics/Async/AddAwaitTests.vb @@ -206,9 +206,9 @@ Imports System.Threading.Tasks Module Program Sub MySub() - Dim a = Async Sub() - Await Task.Delay(1) - End Sub + Dim a = Async Sub() + Await Task.Delay(1) + End Sub End Sub End Module diff --git a/src/EditorFeatures/VisualBasicTest/Diagnostics/Async/ChangeToAsyncTests.vb b/src/EditorFeatures/VisualBasicTest/Diagnostics/Async/ChangeToAsyncTests.vb index dfe1e6179d0c1..89706e0dca4eb 100644 --- a/src/EditorFeatures/VisualBasicTest/Diagnostics/Async/ChangeToAsyncTests.vb +++ b/src/EditorFeatures/VisualBasicTest/Diagnostics/Async/ChangeToAsyncTests.vb @@ -24,9 +24,9 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.Diagnostics.Async     Async Function rtrt() As Task         Await gt()     End Function - -    Async Function gt() As Task -    End Function + +Async Function gt() As Task +End Function Await TestAsync(initial, expected) End Function diff --git a/src/EditorFeatures/VisualBasicTest/Diagnostics/GenerateEndConstruct/GenerateEndConstructTests.vb b/src/EditorFeatures/VisualBasicTest/Diagnostics/GenerateEndConstruct/GenerateEndConstructTests.vb index 4a1d4c1c502c7..e53654b73a829 100644 --- a/src/EditorFeatures/VisualBasicTest/Diagnostics/GenerateEndConstruct/GenerateEndConstructTests.vb +++ b/src/EditorFeatures/VisualBasicTest/Diagnostics/GenerateEndConstruct/GenerateEndConstructTests.vb @@ -45,7 +45,7 @@ End Using Dim text = Structure Goo[||] - Dim expected = StringFromLines("Structure Goo", "End Structure", "") + Dim expected = StringFromLines("", "Structure Goo", "End Structure", "") Await TestInRegularAndScriptAsync(text.ConvertTestSourceTag(), expected, ignoreTrivia:=False) End Function @@ -56,7 +56,7 @@ Structure Goo[||] Module Goo[||] - Dim expected = StringFromLines("Module Goo", "End Module", "") + Dim expected = StringFromLines("", "Module Goo", "", "End Module", "") Await TestInRegularAndScriptAsync(text.ConvertTestSourceTag(), expected, ignoreTrivia:=False) End Function @@ -67,7 +67,7 @@ Module Goo[||] Namespace Goo[||] - Dim expected = StringFromLines("Namespace Goo", "End Namespace", "") + Dim expected = StringFromLines("", "Namespace Goo", "", "End Namespace", "") Await TestInRegularAndScriptAsync(text.ConvertTestSourceTag(), expected, ignoreTrivia:=False) End Function @@ -78,7 +78,7 @@ Namespace Goo[||] Class Goo[||] - Dim expected = StringFromLines("Class Goo", "End Class", "") + Dim expected = StringFromLines("", "Class Goo", "", "End Class", "") Await TestInRegularAndScriptAsync(text.ConvertTestSourceTag(), expected, ignoreTrivia:=False) End Function @@ -89,7 +89,7 @@ Class Goo[||] Interface Goo[||] - Dim expected = StringFromLines("Interface Goo", "End Interface", "") + Dim expected = StringFromLines("", "Interface Goo", "", "End Interface", "") Await TestInRegularAndScriptAsync(text.ConvertTestSourceTag(), expected, ignoreTrivia:=False) End Function @@ -100,7 +100,7 @@ Interface Goo[||] Enum Goo[||] - Dim expected = StringFromLines("Enum Goo", "End Enum", "") + Dim expected = StringFromLines("", "Enum Goo", "", "End Enum", "") Await TestInRegularAndScriptAsync(text.ConvertTestSourceTag(), expected, ignoreTrivia:=False) End Function diff --git a/src/EditorFeatures/VisualBasicTest/Diagnostics/GenerateEnumMember/GenerateEnumMemberTests.vb b/src/EditorFeatures/VisualBasicTest/Diagnostics/GenerateEnumMember/GenerateEnumMemberTests.vb index 70f89140fc8c2..7dfc563d58417 100644 --- a/src/EditorFeatures/VisualBasicTest/Diagnostics/GenerateEnumMember/GenerateEnumMemberTests.vb +++ b/src/EditorFeatures/VisualBasicTest/Diagnostics/GenerateEnumMember/GenerateEnumMemberTests.vb @@ -1163,6 +1163,7 @@ End Enum", Color.Blue End Sub End Class + Enum Color As Long Red = &H8000000000000000 Blue = &H8000000000000001 diff --git a/src/EditorFeatures/VisualBasicTest/Diagnostics/GenerateEvent/GenerateEventTests.vb b/src/EditorFeatures/VisualBasicTest/Diagnostics/GenerateEvent/GenerateEventTests.vb index 3fdb90e7ca23c..bb80e7a382333 100644 --- a/src/EditorFeatures/VisualBasicTest/Diagnostics/GenerateEvent/GenerateEventTests.vb +++ b/src/EditorFeatures/VisualBasicTest/Diagnostics/GenerateEvent/GenerateEventTests.vb @@ -143,6 +143,7 @@ End Class") End Class", "Public Class C Public Event MyEvent(x As Integer) + Sub EventHandler(ByVal x As Integer) Handles Me.MyEvent ' Place code to handle events from BaseClass here. End Sub @@ -160,6 +161,7 @@ End Class") End Class", "Public Class C Public Event MyEvent(x As Integer) + Sub EventHandler(ByVal x As Integer) Handles MyClass.MyEvent ' Place code to handle events from BaseClass here. End Sub @@ -193,6 +195,7 @@ End Class", "Public Class B Dim WithEvents x As B Public Event E1(x As String) + Private Sub Test(Optional x As String = Nothing) Handles x.E1 'mark 1 End Sub Private Sub Test2(ParamArray x As String()) Handles x.E2 'mark 2 @@ -214,6 +217,7 @@ End Class", "Public Class B Dim WithEvents x As B Public Event E2(x() As String) + Private Sub Test(Optional x As String = Nothing) Handles x.E1 'mark 1 End Sub Private Sub Test2(ParamArray x As String()) Handles x.E2 'mark 2 @@ -354,7 +358,9 @@ End Class", Public Sub New() AddHandler XEvent, AddressOf EClass_EventHandler End Sub + Public Event XEvent() + Sub EClass_EventHandler() End Sub End Class") @@ -377,7 +383,9 @@ End Class", Public Sub New() RemoveHandler XEvent, AddressOf EClass_EventHandler End Sub + Public Event XEvent() + Sub EClass_EventHandler() End Sub End Class") @@ -400,7 +408,9 @@ End Class", Public Sub New() AddHandler Me.XEvent, AddressOf EClass_EventHandler End Sub + Public Event XEvent() + Sub EClass_EventHandler() End Sub End Class") @@ -423,7 +433,9 @@ End Class", Public Sub New() RemoveHandler Me.XEvent, AddressOf EClass_EventHandler End Sub + Public Event XEvent() + Sub EClass_EventHandler() End Sub End Class") @@ -446,7 +458,9 @@ End Class", Public Sub New() AddHandler MyClass.XEvent, AddressOf EClass_EventHandler End Sub + Public Event XEvent() + Sub EClass_EventHandler() End Sub End Class") @@ -469,7 +483,9 @@ End Class", Public Sub New() RemoveHandler MyClass.XEvent, AddressOf EClass_EventHandler End Sub + Public Event XEvent() + Sub EClass_EventHandler() End Sub End Class") diff --git a/src/EditorFeatures/VisualBasicTest/Diagnostics/GenerateMethod/GenerateMethodTests.vb b/src/EditorFeatures/VisualBasicTest/Diagnostics/GenerateMethod/GenerateMethodTests.vb index 2fb45537e7d7c..7112721e24125 100644 --- a/src/EditorFeatures/VisualBasicTest/Diagnostics/GenerateMethod/GenerateMethodTests.vb +++ b/src/EditorFeatures/VisualBasicTest/Diagnostics/GenerateMethod/GenerateMethodTests.vb @@ -21,10 +21,12 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.Diagnostics.Genera End Sub End Class", "Imports System + Class C Sub M() Goo() End Sub + Private Sub Goo() Throw New NotImplementedException() End Sub @@ -42,8 +44,7 @@ End Class") End Sub End Module End Namespace", -" -Imports System +"Imports System Namespace N Module Module1 @@ -67,10 +68,12 @@ End Namespace") End Sub End Class", "Imports System + Class C Sub M() Me.Goo() End Sub + Private Sub Goo() Throw New NotImplementedException() End Sub @@ -86,10 +89,12 @@ End Class") End Sub End Class", "Imports System + Class C Sub M() C.Goo() End Sub + Private Shared Sub Goo() Throw New NotImplementedException() End Sub @@ -105,10 +110,12 @@ End Class") End Sub End Class", "Imports System + Class C Sub M() Goo(0) End Sub + Private Sub Goo(v As Integer) Throw New NotImplementedException() End Sub @@ -124,10 +131,12 @@ End Class") End Sub End Class", "Imports System + Class C Sub M() Goo(0, 0) End Sub + Private Sub Goo(v1 As Integer, v2 As Integer) Throw New NotImplementedException() End Sub @@ -143,10 +152,12 @@ End Class") End Sub End Class", "Imports System + Class C Sub M(i As Integer) Goo(i) End Sub + Private Sub Goo(i As Integer) Throw New NotImplementedException() End Sub @@ -162,10 +173,12 @@ End Class") End Sub End Class", "Imports System + Class C Sub M(i As Integer) Goo(bar:=i) End Sub + Private Sub Goo(bar As Integer) Throw New NotImplementedException() End Sub @@ -183,13 +196,16 @@ End Class") End Sub End Class", "Imports System + Class C Sub M() Goo() End Sub + Private Sub Goo() Throw New NotImplementedException() End Sub + Sub NextMethod() End Sub End Class") @@ -206,13 +222,16 @@ End Class") End Function End Class", "Imports System + Class C Sub M(i As Integer) Goo(NextMethod()) End Sub + Private Sub Goo(goo As IGoo) Throw New NotImplementedException() End Sub + Function NextMethod() As IGoo End Function End Class") @@ -229,13 +248,16 @@ End Class") End Function End Class", "Imports System + Class C Sub M(i As Integer) Goo(NextMethod) End Sub + Private Sub Goo(nextMethod As String) Throw New NotImplementedException() End Sub + Function NextMethod() As String End Function End Class") @@ -252,13 +274,16 @@ End Class") End Function End Class", "Imports System + Class C Sub M(i As Integer) Goo(NextMethod) End Sub + Private Sub Goo(nextMethod As Func(Of Integer, String)) Throw New NotImplementedException() End Sub + Function NextMethod(i As Integer) As String End Function End Class") @@ -275,6 +300,7 @@ End Class") End Function End Class", "Imports System + Class C Sub M(i As Integer) Goo(AddressOf NextMethod) @@ -297,13 +323,14 @@ End Class") End Sub End Class", "Imports System + Class C Sub M(i As Integer) - Goo(NextMethod) - End Sub - Private Sub Goo(nextMethod As Object) + Goo(NextMethod) End Sub +Private Sub Goo(nextMethod As Object) Throw New NotImplementedException() End Sub + Sub NextMethod() End Sub End Class") @@ -320,13 +347,16 @@ End Class") End Sub End Class", "Imports System + Class C Sub M(i As Integer) Goo(NextMethod) End Sub + Private Sub Goo(nextMethod As Action(Of Integer)) Throw New NotImplementedException() End Sub + Sub NextMethod(i As Integer) End Sub End Class") @@ -342,11 +372,13 @@ End Class") End Sub End Class", "Imports System + Class C Sub M() If Goo() End If End Sub + Private Function Goo() As Boolean Throw New NotImplementedException() End Function @@ -363,13 +395,16 @@ End Class") Dim Bar As Integer End Class", "Imports System + Class C Sub M() Goo(Me.Bar) End Sub + Private Sub Goo(bar As Integer) Throw New NotImplementedException() End Sub + Dim Bar As Integer End Class") End Function @@ -384,13 +419,16 @@ End Class") Dim Bar As Integer End Class", "Imports System + Class C Sub M() Goo((Bar)) End Sub + Private Sub Goo(bar As Integer) Throw New NotImplementedException() End Sub + Dim Bar As Integer End Class") End Function @@ -406,10 +444,12 @@ End Class Class Bar End Class", "Imports System + Class C Sub M() Goo(DirectCast(Me.Baz, Bar)) End Sub + Private Sub Goo(baz As Bar) Throw New NotImplementedException() End Sub @@ -430,13 +470,16 @@ End Class Class Bar End Class", "Imports System + Class C Sub M() Goo(DirectCast(Me.Baz, Bar), Me.Baz) End Sub + Private Sub Goo(baz1 As Bar, baz2 As Integer) Throw New NotImplementedException() End Sub + Dim Baz As Integer End Class Class Bar @@ -452,10 +495,12 @@ End Class") End Sub End Class", "Imports System + Class C Sub M() Goo(Of Integer)() End Sub + Private Sub Goo(Of T)() Throw New NotImplementedException() End Sub @@ -471,10 +516,12 @@ End Class") End Sub End Class", "Imports System + Class C Sub M() Goo(Of Integer, String)() End Sub + Private Sub Goo(Of T1, T2)() Throw New NotImplementedException() End Sub @@ -491,10 +538,12 @@ End Class") End Sub End Class", "Imports System + Class C Sub M(Of X, Y)(x As X, y As Y) Goo(x) End Sub + Private Sub Goo(Of X)(x1 As X) Throw New NotImplementedException() End Sub @@ -510,10 +559,12 @@ End Class") End Sub End Class", "Imports System + Class C Sub M(Of X)(y1 As X(), x1 As System.Func(Of X)) Goo(Of X)(y1, x1) End Sub + Private Sub Goo(Of X)(y1() As X, x1 As Func(Of X)) Throw New NotImplementedException() End Sub @@ -529,10 +580,12 @@ End Class") End Sub End Class", "Imports System + Class C Sub M(Of X, Y)(y1 As Y(), x1 As System.Func(Of X)) Goo(Of X, Y)(y1, x1) End Sub + Private Sub Goo(Of X, Y)(y1() As Y, x1 As Func(Of X)) Throw New NotImplementedException() End Sub @@ -549,10 +602,12 @@ End Class") End Sub End Class", "Imports System + Class C Sub M(Of X, Y)(x As X, y As Y) Goo(x, y) End Sub + Private Sub Goo(Of X, Y)(x1 As X, y1 As Y) Throw New NotImplementedException() End Sub @@ -569,10 +624,12 @@ End Class") End Sub End Class", "Imports System + Class C Sub M(Of X, Y)(y As Y(), x As System.Func(Of X)) Goo(y, x) End Sub + Private Sub Goo(Of Y, X)(y1() As Y, x1 As Func(Of X)) Throw New NotImplementedException() End Sub @@ -590,12 +647,14 @@ End Class") End Class End Class", "Imports System + Class Outer Class C Sub M(o As Outer) o.Goo() End Sub End Class + Private Sub Goo() Throw New NotImplementedException() End Sub @@ -613,13 +672,16 @@ End Class") End Class End Class", "Imports System + Class Outer Class C Sub M(o As Outer) Outer.Goo() End Sub - End Class Private Shared Sub Goo() - Throw New NotImplementedException() + End Class + + Private Shared Sub Goo() + Throw New NotImplementedException() End Sub End Class") End Function @@ -635,6 +697,7 @@ End Class Class Sibling End Class", "Imports System + Class C Sub M(s As Sibling) s.Goo() @@ -658,6 +721,7 @@ End Class Class Sibling End Class", "Imports System + Class C Sub M(s As Sibling) Sibling.Goo() @@ -702,6 +766,7 @@ End Class", Sub M() Goo() End Sub + Friend MustOverride Sub Goo() End Class", index:=1) @@ -717,13 +782,16 @@ index:=1) End Sub End Module", "Imports System + Module Class C Sub M() Goo() End Sub + Private Sub Goo() - Throw New NotImplementedException() End Sub - End Module") + Throw New NotImplementedException() + End Sub +End Module") End Function @@ -737,11 +805,13 @@ Module Class C End Sub End Class", "Imports System + Class C Sub M() Do While Goo() Loop End Sub + Private Function Goo() As Boolean Throw New NotImplementedException() End Function @@ -758,10 +828,12 @@ End Class") End Sub End Class", "Imports System + Class C Sub M() [Sub]() End Sub + Private Sub [Sub]() Throw New NotImplementedException() End Sub @@ -778,10 +850,12 @@ End Class") End Sub End Class", "Imports System + Class C Sub M() Call S End Sub + Private Sub S() Throw New NotImplementedException() End Sub @@ -798,10 +872,12 @@ End Class") End Sub End Class", "Imports System + Class C Sub M() S End Sub + Private Sub S() Throw New NotImplementedException() End Sub @@ -828,10 +904,12 @@ End Class") End Sub End Class", "Imports System + Class C Sub M() S%() End Sub + Private Function S() As Integer Throw New NotImplementedException() End Function @@ -848,10 +926,12 @@ End Class") End Sub End Class", "Imports System + Class C Sub M() S&() End Sub + Private Function S() As Long Throw New NotImplementedException() End Function @@ -868,10 +948,12 @@ End Class") End Sub End Class", "Imports System + Class C Sub M() S@() End Sub + Private Function S() As Decimal Throw New NotImplementedException() End Function @@ -888,10 +970,12 @@ End Class") End Sub End Class", "Imports System + Class C Sub M() S!() End Sub + Private Function S() As Single Throw New NotImplementedException() End Function @@ -908,10 +992,12 @@ End Class") End Sub End Class", "Imports System + Class C Sub M() S#() End Sub + Private Function S() As Double Throw New NotImplementedException() End Function @@ -928,10 +1014,12 @@ End Class") End Sub End Class", "Imports System + Class C Sub M() S$() End Sub + Private Function S() As String Throw New NotImplementedException() End Function @@ -1005,6 +1093,7 @@ Module Program Dim v As Void Goo(v) End Sub + Private Sub Goo(v As Object) Throw New NotImplementedException() End Sub @@ -1043,9 +1132,11 @@ End Sub", Shared Sub Main(args As String()) Goo() End Sub + Private Shared Sub Goo() Throw New NotImplementedException() -End Sub", +End Sub +", parseOptions:=GetScriptOptions()) End Function @@ -1060,9 +1151,11 @@ End Sub", Shared Sub Main(args As String()) Goo() End Sub + Private Shared Sub Goo() Throw New NotImplementedException() -End Sub") +End Sub +") End Function @@ -1079,6 +1172,7 @@ Namespace N Shared Sub Main(args As String()) Goo() End Sub + Private Shared Sub Goo() Throw New NotImplementedException() End Sub @@ -1095,6 +1189,7 @@ End Namespace", "Imports System Namespace N Dim a As Integer = Goo() + Private Function Goo() As Integer Throw New NotImplementedException() End Function @@ -1239,11 +1334,13 @@ End Class") End Sub End Module", "Imports System + Module Program Sub Main(args As String()) Dim [string] As String = ""hello"" [Me]([string]) End Sub + Private Sub [Me]([string] As String) Throw New NotImplementedException() End Sub @@ -1260,10 +1357,12 @@ End Module") End Sub End Class", "Imports System + Class Test Sub M(Of T)(x As T) Goo(Of Integer)(x) End Sub + Private Sub Goo(Of T)(x As T) Throw New NotImplementedException() End Sub @@ -1280,10 +1379,12 @@ End Class") End Sub End Class", "Imports System + Class Test(Of T) Sub M() Method(Of T)() End Sub + Private Sub Method(Of T1)() Throw New NotImplementedException() End Sub @@ -1304,6 +1405,7 @@ Class C Sub M() Goo() End Sub + Private Sub Goo() Throw New NotImplementedException() End Sub @@ -1354,11 +1456,13 @@ Class C End Sub End Class", "Imports System + Delegate Sub D(x As Integer) Class C Public Sub Goo() Dim x As D = New D(AddressOf Method) End Sub + Private Sub Method(x As Integer) Throw New NotImplementedException() End Sub @@ -1389,11 +1493,13 @@ Class C End Sub End Class", "Imports System + Delegate Sub D(x As Integer) Class C Private Sub M() Dim d As New D(AddressOf Test) End Sub + Private Sub Test(x As Integer) Throw New NotImplementedException() End Sub @@ -1436,10 +1542,12 @@ End Class") End Module", "Imports System Imports System.Collections.Generic + Module Program Sub Main(args As String()) For Each v As Integer In HERE() : Next End Sub + Private Function HERE() As IEnumerable(Of Integer) Throw New NotImplementedException() End Function @@ -1459,6 +1567,7 @@ End Module", Sub Main(args As String()) For Each v As Integer In HERE() : Next End Sub + Private Function HERE() As IEnumerable(Of Integer) Throw New NotImplementedException() End Function @@ -1480,6 +1589,7 @@ End Module", Sub Main(args As String()) For Each v In HERE : Next End Sub + Private Function HERE() As IEnumerable(Of Object) Throw New NotImplementedException() End Function @@ -1505,6 +1615,7 @@ End Module", ElseIf HERE Then End If End Sub + Private Function HERE() As Boolean Throw New NotImplementedException() End Function @@ -1526,6 +1637,7 @@ End Module", Sub Main(args As String()) For x As Integer = 1 To HERE End Sub + Private Function HERE() As Integer Throw New NotImplementedException() End Function @@ -1559,9 +1671,11 @@ Module Program Dim products = ToList(product) HERE(products) End Sub + Private Sub HERE(products As IEnumerable(Of Object)) Throw New NotImplementedException() End Sub + Function ToList(Of T)(a As T) As IEnumerable(Of T) Return Nothing End Function @@ -1744,6 +1858,7 @@ Module Program Dim v As Func(Of String) = Nothing Dim a1 = If(False, v, AddressOf TestMethod) End Sub + Private Function TestMethod() As String Throw New NotImplementedException() End Function @@ -1761,6 +1876,7 @@ Class B End Sub End Class", "Imports System + Class C Friend Shared Sub Bar() Throw New NotImplementedException() @@ -1783,10 +1899,12 @@ End Class") End Sub End Module", "Imports System + Module Program Sub Main(args As String()) goo(,,) End Sub + Private Sub goo(Optional p1 As Object = Nothing, Optional p2 As Object = Nothing, Optional p3 As Object = Nothing) Throw New NotImplementedException() End Sub @@ -1803,10 +1921,12 @@ End Module") End Sub End Module", "Imports System + Module Program Sub Main(args As String()) goo(1,,) End Sub + Private Sub goo(v As Integer, Optional p1 As Object = Nothing, Optional p2 As Object = Nothing) Throw New NotImplementedException() End Sub @@ -1823,10 +1943,12 @@ End Module") End Sub End Module", "Imports System + Module Program Sub Main(args As String()) goo(, 1,) End Sub + Private Sub goo(Optional p1 As Object = Nothing, Optional v As Integer = Nothing, Optional p2 As Object = Nothing) Throw New NotImplementedException() End Sub @@ -1843,10 +1965,12 @@ End Module") End Sub End Module", "Imports System + Module Program Sub Main(args As String()) goo(,, 1) End Sub + Private Sub goo(Optional p1 As Object = Nothing, Optional p2 As Object = Nothing, Optional v As Integer = Nothing) Throw New NotImplementedException() End Sub @@ -1863,10 +1987,12 @@ End Module") End Sub End Module", "Imports System + Module Program Sub Main(args As String()) goo(1,, 1) End Sub + Private Sub goo(v1 As Integer, Optional p As Object = Nothing, Optional v2 As Integer = Nothing) Throw New NotImplementedException() End Sub @@ -1883,10 +2009,12 @@ End Module") End Sub End Module", "Imports System + Module Program Sub Main(args As String()) goo(1, 1, ) End Sub + Private Sub goo(v1 As Integer, v2 As Integer, Optional p As Object = Nothing) Throw New NotImplementedException() End Sub @@ -1917,14 +2045,17 @@ End Class") End Class End Module", "Imports System + Module Module1 Sub Main() Dim c1 As New Class1 AddHandler c1.AnEvent, AddressOf EventHandler1 End Sub + Private Sub EventHandler1() Throw New NotImplementedException() End Sub + Public Class Class1 Public Event AnEvent() End Class @@ -1948,6 +2079,7 @@ Module M Sub Goo(Of T, S)(x As List(Of T), y As List(Of S)) Bar(x, Function() y) ' Generate Bar End Sub + Private Sub Bar(Of T, S)(x As List(Of T), p As Func(Of List(Of S))) Throw New NotImplementedException() End Sub @@ -2020,6 +2152,7 @@ Module Program Sub Main(args As String()) Bar(1, {1}) End Sub + Private Sub Bar(v As Integer, p() As Integer) Throw New NotImplementedException() End Sub @@ -2041,6 +2174,7 @@ Module M Sub Main() Goo({{1}}) End Sub + Private Sub Goo(p(,) As Integer) Throw New NotImplementedException() End Sub @@ -2062,6 +2196,7 @@ Module Program Sub Main() Prop(1) = 2 End Sub + Private Function Prop(v As Integer) As Integer Throw New NotImplementedException() End Function @@ -2083,6 +2218,7 @@ Module Program Sub Main() Prop(1) = 2 End Sub + Private Property Prop(v As Integer) As Integer Get Throw New NotImplementedException() @@ -3134,10 +3270,12 @@ End Class End Sub End Class", "Imports System + Public Class C Sub Main(a As C) Dim x As C = a?.B End Sub + Private Function B() As C Throw New NotImplementedException() End Function @@ -3154,10 +3292,12 @@ End Class") End Sub End Class", "Imports System + Public Class C Sub Main(a As C) Dim x = a?.B End Sub + Private Function B() As Object Throw New NotImplementedException() End Function @@ -3174,10 +3314,12 @@ End Class") End Sub End Class", "Imports System + Public Class C Sub Main(a As C) Dim x As Integer? = a?.B End Sub + Private Function B() As Integer Throw New NotImplementedException() End Function @@ -3194,10 +3336,12 @@ End Class") End Sub End Class", "Imports System + Public Class C Sub Main(a As C) Dim x As C? = a?.B End Sub + Private Function B() As C Throw New NotImplementedException() End Function @@ -3433,10 +3577,12 @@ End Class") End Sub End Class", "Imports System + Public Class C Sub Main(a As C) Dim x As C = a?.B() End Sub + Private Function B() As C Throw New NotImplementedException() End Function @@ -3453,10 +3599,12 @@ End Class") End Sub End Class", "Imports System + Public Class C Sub Main(a As C) Dim x = a?.B() End Sub + Private Function B() As Object Throw New NotImplementedException() End Function @@ -3473,10 +3621,12 @@ End Class") End Sub End Class", "Imports System + Public Class C Sub Main(a As C) Dim x As Integer? = a?.B() End Sub + Private Function B() As Integer Throw New NotImplementedException() End Function @@ -3493,10 +3643,12 @@ End Class") End Sub End Class", "Imports System + Public Class C Sub Main(a As C) Dim x As C? = a?.B() End Sub + Private Function B() As C Throw New NotImplementedException() End Function @@ -3513,10 +3665,12 @@ End Class") End Sub End Class", "Imports System + Public Class C Sub Main(a As C) Dim x As C = a?.B() End Sub + Private ReadOnly Property B As C Get Throw New NotImplementedException() @@ -3536,10 +3690,12 @@ index:=1) End Sub End Class", "Imports System + Public Class C Sub Main(a As C) Dim x = a?.B() End Sub + Private ReadOnly Property B As Object Get Throw New NotImplementedException() @@ -3559,10 +3715,12 @@ index:=1) End Sub End Class", "Imports System + Public Class C Sub Main(a As C) Dim x As Integer? = a?.B() End Sub + Private ReadOnly Property B As Integer Get Throw New NotImplementedException() @@ -3582,10 +3740,12 @@ index:=1) End Sub End Class", "Imports System + Public Class C Sub Main(a As C) Dim x As C? = a?.B() End Sub + Private ReadOnly Property B As C Get Throw New NotImplementedException() @@ -3639,11 +3799,13 @@ End Module") End Sub End Module", "Imports System + Module C Sub Test() If TypeOf B Is String Then End If End Sub + Private Function B() As String Throw New NotImplementedException() End Function @@ -3660,11 +3822,13 @@ End Module") End Sub End Module", "Imports System + Module C Sub Test() If TypeOf B() Is String Then End If End Sub + Private Function B() As String Throw New NotImplementedException() End Function @@ -3741,13 +3905,15 @@ Module M Dim x As Boolean = Await [|F|]().ConfigureAwait(False) End Sub End Module", -"Imports System -Imports System.Linq +"Imports System +Imports System.Linq Imports System.Threading.Tasks + Module M Async Sub T() Dim x As Boolean = Await F().ConfigureAwait(False) - End Sub + End Sub + Private Function F() As Task(Of Boolean) Throw New NotImplementedException() End Function @@ -3775,6 +3941,7 @@ Module Program If TypeOf Prop IsNot TypeOfIsNotDerived Then End If End Sub + Private Function Prop() As TypeOfIsNotDerived Throw New NotImplementedException() End Function @@ -3798,6 +3965,7 @@ Module Program Sub M() Dim x = New List(Of Integer) From {T()} End Sub + Private Function T() As Integer Throw New NotImplementedException() End Function @@ -3821,6 +3989,7 @@ Module Program Sub M() Dim x = New Dictionary(Of Integer, Boolean) From {{1, T()}} End Sub + Private Function T() As Boolean Throw New NotImplementedException() End Function @@ -3902,7 +4071,8 @@ Class C Shared Sub TestError() Repository.AgreementType.NewFunction("", "") End Sub -End Class.Value.Replace(vbLf, vbCrLf)) +End Class +.Value.Replace(vbLf, vbCrLf)) End Function diff --git a/src/EditorFeatures/VisualBasicTest/Diagnostics/GenerateType/GenerateTypeTests.vb b/src/EditorFeatures/VisualBasicTest/Diagnostics/GenerateType/GenerateTypeTests.vb index bc28b19f6f777..8f4f79ab004e0 100644 --- a/src/EditorFeatures/VisualBasicTest/Diagnostics/GenerateType/GenerateTypeTests.vb +++ b/src/EditorFeatures/VisualBasicTest/Diagnostics/GenerateType/GenerateTypeTests.vb @@ -35,8 +35,10 @@ End Module", Dim f As Goo(Of Integer) End Sub End Module + Friend Class Goo(Of T) -End Class", +End Class +", index:=1) End Function @@ -48,6 +50,7 @@ index:=1) End Class", "Class C Dim emp As List(Of Employee) + Private Class Employee End Class End Class", @@ -62,6 +65,7 @@ index:=2) End Class", "Class C dim f as Goo + Private Class Goo End Class End Class", @@ -77,8 +81,10 @@ End Class", "Class C dim f as Goo End Class + Friend Class Goo -End Class", +End Class +", index:=1) End Function @@ -103,6 +109,7 @@ End Namespace", Class Goo Private x As New NS.Bar End Class + Friend Class Bar End Class End Namespace", @@ -118,6 +125,7 @@ parseOptions:=Nothing) ' Namespaces not supported in script End Class", "Class C Dim f As Goo = New Goo() + Private Class Goo Public Sub New() End Sub @@ -181,25 +189,33 @@ End Module", Imports System.Collections.Generic Imports System.Linq Imports System.Runtime.Serialization + Module Program Sub Main(args As String()) Throw New Goo() End Sub End Module - Friend Class Goo + + +Friend Class Goo Inherits Exception + Public Sub New() End Sub + Public Sub New(message As String) MyBase.New(message) End Sub + Public Sub New(message As String, innerException As Exception) MyBase.New(message, innerException) End Sub + Protected Sub New(info As SerializationInfo, context As StreamingContext) MyBase.New(info, context) End Sub -End Class", +End Class +", index:=1) End Function @@ -222,14 +238,17 @@ Module Program Call New Goo(1, ""blah"") End Sub End Module + Friend Class Goo Private v1 As Integer Private v2 As String + Public Sub New(v1 As Integer, v2 As String) Me.v1 = v1 Me.v2 = v2 End Sub -End Class", +End Class +", index:=1) End Function @@ -256,12 +275,15 @@ Module Program Dim d As B = New D(4) End Sub End Module + Friend Class D Inherits B + Public Sub New(value As Integer) MyBase.New(value) End Sub End Class + Class B Protected Sub New(value As Integer) End Sub @@ -291,6 +313,7 @@ Namespace Outer Call New Blah() End Sub End Module + Friend Class Blah Public Sub New() End Sub @@ -321,12 +344,15 @@ Module Program Dim d As B = New D(i) End Sub End Module + Friend Class D Inherits B + Public Sub New(i As Integer) Me.i = i End Sub End Class + Class B Protected i As Integer End Class", @@ -352,8 +378,10 @@ Class Outer(Of M) Call New Goo(Of M) End Sub End Class + Friend Class Goo(Of M) -End Class", +End Class +", index:=1) End Function @@ -375,6 +403,7 @@ Class Outer(Of M) Sub Main(i As Integer) Call New Goo(Of M) End Sub + Private Class Goo(Of M) End Class End Class", @@ -393,6 +422,7 @@ End Class", Sub Test() Dim d = New Program.Goo() End Sub + Private Class Goo Public Sub New() End Sub @@ -417,6 +447,7 @@ End Namespace", Dim d = New Goo.Bar() End Sub End Class + Friend Class Bar Public Sub New() End Sub @@ -439,8 +470,10 @@ Imports System.Collections.Generic Imports System.Linq Class Program(Of T As {Goo, IBar}) End Class + Friend Interface IBar -End Interface", +End Interface +", index:=1) End Function @@ -460,7 +493,8 @@ End Class", Public Sub New() End Sub End Class -End Namespace", +End Namespace +", expectedContainers:=ImmutableArray.Create("Goo"), expectedDocumentName:="Bar.vb") End Function @@ -546,7 +580,8 @@ Module Program End Sub End Module", "Friend Class Goo -End Class", +End Class +", expectedContainers:=ImmutableArray(Of String).Empty, expectedDocumentName:="Goo.vb") End Function @@ -570,8 +605,10 @@ Module Program Dim d As IGoo = New Goo() End Sub End Module + Friend Interface IGoo -End Interface", +End Interface +", index:=1) End Function @@ -596,9 +633,11 @@ Module Program Dim d As IGoo = New Goo() End Sub End Module + Friend Class Goo Implements IGoo End Class + Friend Interface IGoo End Interface", index:=1) @@ -617,12 +656,15 @@ End Class", Dim x = New Bar(value:=7) End Sub End Class + Friend Class Bar Private value As Integer + Public Sub New(value As Integer) Me.value = value End Sub -End Class", +End Class +", index:=1) End Function @@ -649,8 +691,10 @@ End Class", Function F() As Bar End Function End Class + Public Class Bar -End Class", +End Class +", index:=1) End Function @@ -663,8 +707,10 @@ End Class", "Class Goo Dim x As New [Class] End Class + Friend Class [Class] -End Class", +End Class +", index:=1) End Function @@ -677,8 +723,10 @@ End Class", "Class Goo Dim x as New [Bar] End Class + Friend Class Bar -End Class", +End Class +", index:=1) End Function @@ -695,6 +743,7 @@ End Namespace", Class Goo Dim x As New NS.Bar End Class + Friend Class Bar End Class End Namespace", @@ -711,6 +760,7 @@ parseOptions:=Nothing) ' Namespaces not supported in script End Module", "Module M Dim x As C + Private Class C End Class End Module", @@ -727,8 +777,10 @@ End Class", "Class C Implements D End Class + Friend Interface D -End Interface", +End Interface +", index:=1) End Function @@ -758,7 +810,8 @@ End Class", "Friend Class Derived Public Sub New() End Sub -End Class", +End Class +", expectedContainers:=ImmutableArray(Of String).Empty, expectedDocumentName:="Derived.vb") End Function @@ -821,9 +874,11 @@ End Class", Dim p() As Base = New Derived(10) {} End Sub End Class + Friend Class Derived Inherits Base -End Class", +End Class +", index:=1) End Function @@ -841,9 +896,11 @@ End Class", Dim p As Base() = New Derived(10) {} End Sub End Class + Friend Class Derived Inherits Base -End Class", +End Class +", index:=1) End Function @@ -861,8 +918,10 @@ End Class", Dim p As Base = New Derived(10) {} End Sub End Class + Friend Class Derived -End Class", +End Class +", index:=1) End Function @@ -882,8 +941,10 @@ End Class", Dim f As Goo(Of Integer) End Sub End Class + Friend Class Goo(Of T) End Class + Class Goo End Class", index:=1) @@ -903,14 +964,17 @@ End Class", Dim a As Test = New Test(x, y) End Sub End Class + Friend Class Test Private x As Object Private y As Object + Public Sub New(x As Object, y As Object) Me.x = x Me.y = y End Sub -End Class", +End Class +", index:=1) End Function @@ -928,14 +992,17 @@ End Class", Dim a As Test(Of T1, T2) = New Test(Of T1, T2)(x, y) End Sub End Class + Friend Class Test(Of T1, T2) Private x As T1 Private y As T2 + Public Sub New(x As T1, y As T2) Me.x = x Me.y = y End Sub -End Class", +End Class +", index:=1) End Function @@ -957,12 +1024,15 @@ End Module", Sub M() End Sub End Module + Friend Class C Private v As Object + Public Sub New(v As Object) Me.v = v End Sub -End Class", +End Class +", index:=1) End Function @@ -980,12 +1050,15 @@ End Class", Dim x As New C(4) End Sub End Class + Friend Class C Private v As Integer + Public Sub New(v As Integer) Me.v = v End Sub -End Class", +End Class +", index:=1) End Function @@ -1008,12 +1081,15 @@ End Class") Class C End Class", "Imports System + Class C End Class + Friend Class AttClassAttribute Inherits Attribute -End Class", +End Class +", index:=1) End Function @@ -1029,9 +1105,11 @@ End Class", Class C End Class + Friend Class AttClassAttribute Inherits Attribute -End Class", +End Class +", index:=1) End Function @@ -1069,6 +1147,7 @@ Module StringExtensions Public Sub Print(ByVal aString As String, x As C) Console.WriteLine(aString) End Sub + Public Class C End Class End Module", @@ -1218,17 +1297,21 @@ index:=1) End Sub End Module", "Imports System + Module Program Sub Main() Dim c = New C(Function() x) End Sub End Module + Friend Class C Private p As Func(Of Object) + Public Sub New(p As Func(Of Object)) Me.p = p End Sub -End Class", +End Class +", index:=1) End Function @@ -1248,14 +1331,17 @@ Module Program Dim x = New C(,) End Sub End Module + Friend Class C Private p1 As Object Private p2 As Object + Public Sub New(p1 As Object, p2 As Object) Me.p1 = p1 Me.p2 = p2 End Sub -End Class", +End Class +", index:=1) End Function @@ -1275,9 +1361,11 @@ Module Program Sub Main() End Sub End Module + Friend Class SystemAttribute Inherits Attribute -End Class", +End Class +", index:=1) End Function @@ -1426,16 +1514,20 @@ Module Program Dim c As New [|Customer|](x:=1, y:=""Hello"") With {.Name = ""John"", .Age = Date.Today} End Sub End Module + Friend Class Customer Private x As Integer Private y As String + Public Sub New(x As Integer, y As String) Me.x = x Me.y = y End Sub + Public Property Name As String Public Property Age As Date -End Class", +End Class +", index:=1) End Function @@ -1455,16 +1547,20 @@ Module Program Dim c As New [|Customer|](x:=1, y:=""Hello"") With {.Name = Nothing, .Age = Date.Today} End Sub End Module + Friend Class Customer Private x As Integer Private y As String + Public Sub New(x As Integer, y As String) Me.x = x Me.y = y End Sub + Public Property Name As Object Public Property Age As Date -End Class", +End Class +", index:=1) End Function @@ -1484,16 +1580,20 @@ Module Program Dim c As New [|Customer|](x:=1, y:=""Hello"") With {.Name = Goo, .Age = Date.Today} End Sub End Module + Friend Class Customer Private x As Integer Private y As String + Public Sub New(x As Integer, y As String) Me.x = x Me.y = y End Sub + Public Property Name As Object Public Property Age As Date -End Class", +End Class +", index:=1) End Function @@ -1513,10 +1613,12 @@ Module Program Dim c As New [|Customer|] With {.Name = ""John"", .Age = Date.Today} End Sub End Module + Friend Class Customer Public Property Name As String Public Property Age As Date -End Class", +End Class +", index:=1) End Function @@ -1536,8 +1638,10 @@ Module Program Dim x = nameof([|Z|]) End Sub End Module + Friend Class Z -End Class", +End Class +", index:=1) End Function @@ -1556,6 +1660,7 @@ Class Program Sub Main() Dim x = nameof([|Z|]) End Sub + Private Class Z End Class End Class", @@ -1577,6 +1682,7 @@ Class Program Sub Main() Dim x = nameof([|Program.Z|]) End Sub + Private Class Z End Class End Class") @@ -1616,8 +1722,10 @@ End Class Await TestInRegularAndScriptAsync( "Imports [|Fizz|]", "Imports Fizz + Friend Class Fizz -End Class", +End Class +", index:=1) End Function @@ -1631,7 +1739,8 @@ End Class", "Public Class B Public Sub New() End Sub -End Class") +End Class +") End Function @@ -1648,7 +1757,8 @@ End Class Public Class B Public Sub New() End Sub -End Class", +End Class +", index:=1) End Function @@ -1661,6 +1771,7 @@ index:=1) End Class", "Public Class A Public B As New B() + Public Class B Public Sub New() End Sub @@ -1677,7 +1788,8 @@ index:=2) Public B As New [|B|] End Class", "Public Class B -End Class") +End Class +") End Function @@ -1692,7 +1804,8 @@ End Class", End Class Public Class B -End Class", +End Class +", index:=1) End Function @@ -1705,6 +1818,7 @@ index:=1) End Class", "Public Class A Public B As New B + Public Class B End Class End Class", @@ -1719,7 +1833,8 @@ index:=2) Public B As New [|B(Of Integer)|] End Class", "Public Class B(Of T) -End Class") +End Class +") End Function @@ -1734,7 +1849,8 @@ End Class", End Class Public Class B(Of T) -End Class", +End Class +", index:=1) End Function @@ -1747,6 +1863,7 @@ index:=1) End Class", "Public Class A Public B As New B(Of Integer) + Public Class B(Of T) End Class End Class", @@ -1773,12 +1890,15 @@ index:=2) <[|Extension|]> End Module", "Imports System + Module Program End Module + Friend Class ExtensionAttribute Inherits Attribute -End Class", +End Class +", index:=1) End Function End Class diff --git a/src/EditorFeatures/VisualBasicTest/Diagnostics/GenerateVariable/GenerateVariableTests.vb b/src/EditorFeatures/VisualBasicTest/Diagnostics/GenerateVariable/GenerateVariableTests.vb index b41ccf41888bf..3df0198a49c6b 100644 --- a/src/EditorFeatures/VisualBasicTest/Diagnostics/GenerateVariable/GenerateVariableTests.vb +++ b/src/EditorFeatures/VisualBasicTest/Diagnostics/GenerateVariable/GenerateVariableTests.vb @@ -28,6 +28,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.Diagnostics.Genera End Module", "Module Program Public Property Bar As Object + Sub Main(args As String()) Goo(Bar) End Sub @@ -44,6 +45,7 @@ End Module") End Module", "Module Program Private Bar As Object + Sub Main(args As String()) Goo(Bar) End Sub @@ -61,6 +63,7 @@ index:=1) End Module", "Module Program Private ReadOnly Bar As Object + Sub Main(args As String()) Goo(Bar) End Sub @@ -79,6 +82,7 @@ index:=2) End Class", "Class C Private Shared Goo As Integer + Shared Sub M Goo = 3 End Sub @@ -249,6 +253,7 @@ Class C End Class", "Module Program Public Property P As Integer + Sub Main(args As String()) End Sub End Module @@ -274,6 +279,7 @@ Class C End Class", "Module Program Friend P As Integer + Sub Main(args As String()) End Sub End Module @@ -296,6 +302,7 @@ index:=1) End Module", "Module Program Private HERE As Object + Sub Main(args As String()) HERE.ToString() End Sub @@ -341,6 +348,7 @@ End Class") End Module", "Module Program Public Property P As Integer + Function Fun() As Integer Return P End Function @@ -359,6 +367,7 @@ End Module") End Module", "Module Program Public Property P As Integer + Sub Main(args As String()) Dim x As Integer x = P @@ -376,6 +385,7 @@ End Module") End Class", "Class GenPropTest Private Shared genStaticUnqualified As String + Public Shared Sub Main() genStaticUnqualified = """" End Sub @@ -392,6 +402,7 @@ End Class") End Class", "Class GenPropTest Private Shared genStaticUnqualified As String + Public Sub Main() GenPropTest.genStaticUnqualified = """" End Sub @@ -408,6 +419,7 @@ End Class") End Class", "Class GenPropTest Private field As String + Public Sub Main() Me.field = """" End Sub @@ -424,6 +436,7 @@ End Class") End Class", "Class GenPropTest Private field As String + Public Sub Main() field = """" End Sub @@ -528,6 +541,7 @@ End Class", index:=1) End Module", "Module Program Private field As Integer + Sub Main(args As String()) field = 5 End Sub @@ -544,6 +558,7 @@ End Module") End Module", "Module Program Public Property Field As Integer + Sub Main(args As String()) Field = 5 End Sub @@ -590,6 +605,7 @@ Class C(Of T) End Class", "Class A Private field As C(Of B) + Sub Main() field = New C(Of B) End Sub @@ -641,6 +657,7 @@ Imports System.Collections.Generic Imports System.Linq Class A Private z As Type + Sub Goo(Of T) z = GetType(T) End Sub @@ -685,6 +702,7 @@ End Interface") End Class", "Class [Class] Public Property [Enum] As Integer + Private Sub Method(i As Integer) [Enum] = 5 End Sub @@ -701,6 +719,7 @@ End Class") End Class", "Class [Class] Private [Enum] As Integer + Private Sub Method(i As Integer) [Enum] = 5 End Sub @@ -723,6 +742,7 @@ index:=1) End Class", "Class [Class] Private test As Object + Private Sub Method() test = Function(ByRef x As Integer) InlineAssignHelper(x, 10) End Sub @@ -954,6 +974,7 @@ Imports System.Collections.Generic Imports System.Linq Module Program Private a As Object + Sub Main(args As String()) a = New With {.a = ., .b = 1} End Sub @@ -983,6 +1004,7 @@ Module StringExtensions End Module Module M Private s As String + Sub Main() Print(s) End Sub @@ -1015,6 +1037,7 @@ Module StringExtensions End Module Module M Private s As String + Sub Main() Print(s) End Sub @@ -1035,6 +1058,7 @@ parseOptions:=Nothing) ' TODO (tomat): Modules nested in Script class not suppor End Module", "Module P Public Property Goo As Integer + Sub M() Dim t As System.Action = Sub() P.Goo = 5 @@ -1085,6 +1109,7 @@ End Module End Module", "Module Program Private a As Integer + Sub Main(args As String()) Main(a + b) End Sub @@ -1101,6 +1126,7 @@ End Module") End Module", "Module Program Private b As Integer + Sub Main(args As String()) Main(a + b) End Sub @@ -1117,6 +1143,7 @@ End Module") End Module", "Module Program Private bar As Object + Sub Main(args As String()) Goo(bar) End Sub @@ -1171,6 +1198,7 @@ Module Program #If True ' Banner Line 1 ' Banner Line 2 + Dim local As Integer = Nothing Integer.TryParse(""123"", local) #End If @@ -1213,6 +1241,7 @@ End Module", "Imports System.Linq Module Program Private v As Object + Sub Main(args As String()) Dim q = From a In args Select v @@ -1233,6 +1262,7 @@ End Module", "Module Program Sub Main() Dim a As Object = Nothing + If (a Mod b <> 0) Then End If End Sub @@ -1265,8 +1295,10 @@ End Module") End Function End Module", "Imports System + Module Program Private d As Func(Of String) + Sub Main(args As String()) d = AddressOf test End Sub @@ -1375,6 +1407,7 @@ End Class", "Imports System Public Class A Private MyExp As Exception + Public Sub B() Throw MyExp End Sub @@ -1394,6 +1427,7 @@ End Class", "Imports System Class C Public Property Z As Object + Sub M() Dim x = NameOf(Z) End Sub @@ -1413,6 +1447,7 @@ End Class", "Imports System Class C Private Z As Object + Sub M() Dim x = NameOf(Z) End Sub @@ -1432,6 +1467,7 @@ End Class", "Imports System Class C Private ReadOnly Z As Object + Sub M() Dim x = NameOf(Z) End Sub @@ -1468,6 +1504,7 @@ End Class", index:=3) End Class", "Public Class C Public Property B As C + Sub Main(a As C) Dim x As C = a?.B End Sub @@ -1485,6 +1522,7 @@ End Class") End Class", "Public Class C Public Property B As Object + Sub Main(a As C) Dim x = a?.B End Sub @@ -1502,6 +1540,7 @@ End Class") End Class", "Public Class C Public Property B As Integer + Sub Main(a As C) Dim x As Integer? = a?.B End Sub @@ -1519,6 +1558,7 @@ End Class") End Class", "Public Class C Public Property B As C + Sub Main(a As C) Dim x As C? = a?.B End Sub @@ -1536,6 +1576,7 @@ End Class") End Class", "Public Class C Private B As C + Sub Main(a As C) Dim x As C = a?.B End Sub @@ -1554,6 +1595,7 @@ index:=1) End Class", "Public Class C Private B As Object + Sub Main(a As C) Dim x = a?.B End Sub @@ -1572,6 +1614,7 @@ index:=1) End Class", "Public Class C Private B As Integer + Sub Main(a As C) Dim x As Integer? = a?.B End Sub @@ -1590,6 +1633,7 @@ index:=1) End Class", "Public Class C Private B As C + Sub Main(a As C) Dim x As C? = a?.B End Sub @@ -1608,6 +1652,7 @@ index:=1) End Class", "Public Class C Private ReadOnly B As C + Sub Main(a As C) Dim x As C = a?.B End Sub @@ -1626,6 +1671,7 @@ index:=2) End Class", "Public Class C Private ReadOnly B As Object + Sub Main(a As C) Dim x = a?.B End Sub @@ -1644,6 +1690,7 @@ index:=2) End Class", "Public Class C Private ReadOnly B As Integer + Sub Main(a As C) Dim x As Integer? = a?.B End Sub @@ -1662,6 +1709,7 @@ index:=2) End Class", "Public Class C Private ReadOnly B As C + Sub Main(a As C) Dim x As C? = a?.B End Sub @@ -2135,6 +2183,7 @@ Friend Class Customer End Class", "Module Program Public Property name As Object + Sub Main(args As String()) Dim x As New Customer With {.Name = name} End Sub @@ -2198,6 +2247,7 @@ Friend Class Customer End Class", "Module Program Private name As Object + Sub Main(args As String()) Dim x As New Customer With {.Name = name} End Sub @@ -2263,6 +2313,7 @@ index:=3) End Module", "Module C Public Property B As String + Sub Test() If TypeOf B Is String Then End If @@ -2281,6 +2332,7 @@ End Module") End Module", "Module C Private B As String + Sub Test() If TypeOf B Is String Then End If @@ -2300,6 +2352,7 @@ index:=1) End Module", "Module C Private ReadOnly B As String + Sub Test() If TypeOf B Is String Then End If @@ -2320,6 +2373,7 @@ End Module", "Module C Sub Test() Dim B As String = Nothing + If TypeOf B Is String Then End If End Sub @@ -2345,6 +2399,7 @@ Imports System.Collections.Generic Imports System.Linq Module Program Public Property Prop As TypeOfIsNotDerived + Sub M() If TypeOf Prop IsNot TypeOfIsNotDerived Then End If @@ -2370,6 +2425,7 @@ Imports System.Collections.Generic Imports System.Linq Module Program Private Prop As TypeOfIsNotDerived + Sub M() If TypeOf Prop IsNot TypeOfIsNotDerived Then End If @@ -2396,6 +2452,7 @@ Imports System.Collections.Generic Imports System.Linq Module Program Private ReadOnly Prop As TypeOfIsNotDerived + Sub M() If TypeOf Prop IsNot TypeOfIsNotDerived Then End If @@ -2423,6 +2480,7 @@ Imports System.Linq Module Program Sub M() Dim Prop As TypeOfIsNotDerived = Nothing + If TypeOf Prop IsNot TypeOfIsNotDerived Then End If End Sub @@ -2508,6 +2566,7 @@ index:=2) End Class", "Class [Class] Private tuple As (Integer, String) + Private Sub Method(i As (Integer, String)) Method(tuple) End Sub @@ -2523,8 +2582,9 @@ End Class") End Sub End Class", "Class [Class] - Private tuple As (a As Integer, String) - Private Sub Method(i As (a As Integer, String)) + Private tuple As (a As Integer, String) + + Private Sub Method(i As (a As Integer, String)) Method(tuple) End Sub End Class") @@ -2540,6 +2600,7 @@ End Class") End Class", "Class [Class] Private tuple As (Integer, String) + Private Sub Method() tuple = (1, ""hello"") End Sub @@ -2555,8 +2616,9 @@ End Class") End Sub End Class", "Class [Class] - Private tuple As (a As Integer, String) - Private Sub Method() + Private tuple As (a As Integer, String) + + Private Sub Method() tuple = (a:=1, ""hello"") End Sub End Class") @@ -2677,7 +2739,6 @@ end class", class C public isDisposed as boolean Private y As Integer - public readonly x as integer public readonly m as integer @@ -2706,7 +2767,6 @@ class C public readonly x as integer public readonly m as integer Private ReadOnly y As Integer - public isDisposed as boolean public sub new() diff --git a/src/EditorFeatures/VisualBasicTest/Diagnostics/InsertMissingCast/InsertMissingCastTests.vb b/src/EditorFeatures/VisualBasicTest/Diagnostics/InsertMissingCast/InsertMissingCastTests.vb index 1b1f1440db7ac..23897015b8b28 100644 --- a/src/EditorFeatures/VisualBasicTest/Diagnostics/InsertMissingCast/InsertMissingCastTests.vb +++ b/src/EditorFeatures/VisualBasicTest/Diagnostics/InsertMissingCast/InsertMissingCastTests.vb @@ -113,8 +113,8 @@ Module M1 Sub goo(d As Integer) End Sub Sub Main() - goo(CInt(""10"")) - End Sub + goo(CInt(""10"")) + End Sub End Module") End Function @@ -149,8 +149,8 @@ End Module", "Option Strict On Module M1 Function goo() As Integer - Return CInt(""10"") - End Function + Return CInt(""10"") + End Function End Module") End Function diff --git a/src/EditorFeatures/VisualBasicTest/Diagnostics/Iterator/IteratorTests.vb b/src/EditorFeatures/VisualBasicTest/Diagnostics/Iterator/IteratorTests.vb index 4451259f7048f..cf5c0ffec1c69 100644 --- a/src/EditorFeatures/VisualBasicTest/Diagnostics/Iterator/IteratorTests.vb +++ b/src/EditorFeatures/VisualBasicTest/Diagnostics/Iterator/IteratorTests.vb @@ -29,8 +29,8 @@ Imports System.Collections.Generic Module Module1 Iterator Function M() As IEnumerable(Of Integer) - Yield 1 - End Function + Yield 1 + End Function End Module") End Function @@ -63,8 +63,8 @@ Imports System.Collections.Generic Module Module1 Sub M() Dim a As Func(Of IEnumerable(Of Integer)) = Iterator Function() - Yield 0 - End Function + Yield 0 + End Function End Sub End Module") End Function diff --git a/src/EditorFeatures/VisualBasicTest/Diagnostics/MakeMethodAsynchronous/MakeMethodAsynchronousTests.vb b/src/EditorFeatures/VisualBasicTest/Diagnostics/MakeMethodAsynchronous/MakeMethodAsynchronousTests.vb index e6960814419f8..fd2f99296f722 100644 --- a/src/EditorFeatures/VisualBasicTest/Diagnostics/MakeMethodAsynchronous/MakeMethodAsynchronousTests.vb +++ b/src/EditorFeatures/VisualBasicTest/Diagnostics/MakeMethodAsynchronous/MakeMethodAsynchronousTests.vb @@ -26,8 +26,8 @@ End Module", Imports System.Threading.Tasks Module Program Async Sub TestAsync() - Await Task.Delay(1) - End Sub + Await Task.Delay(1) + End Sub End Module", index:=1) End Function @@ -46,8 +46,8 @@ End Module", Imports System.Threading.Tasks Module Program Public Shared Async Sub TestAsync() - Await Task.Delay(1) - End Sub + Await Task.Delay(1) + End Sub End Module", index:=1) End Function @@ -66,7 +66,7 @@ Module Program Imports System.Threading.Tasks Module Program Async Function TestAsync() As Task(Of Integer) - Await Task.Delay(1) + Await Task.Delay(1) Function Sub End Module") End Function @@ -85,7 +85,7 @@ Module Program Imports System.Threading.Tasks Module Program Public Shared Async Function TestAsync() As Task(Of Integer) - Await Task.Delay(1) + Await Task.Delay(1) Function Sub End Module" ) @@ -146,7 +146,7 @@ Module Program Dim expected = - Async Function rtrtAsync() As Task +Async Function rtrtAsync() As Task Await Nothing End Function @@ -163,7 +163,7 @@ Module Program Dim expected = - Async Sub rtrtAsync() +Async Sub rtrtAsync() Await Nothing End Sub @@ -180,8 +180,8 @@ Module Program Dim expected = - Async Function rtrtAsync() As Threading.Tasks.Task - Await Nothing +Async Function rtrtAsync() As Threading.Tasks.Task + Await Nothing End Function Await TestAsync(initial, expected) @@ -197,7 +197,7 @@ Module Program Dim expected = - Async Function rtrtAsync() As Task +Async Function rtrtAsync() As Task Await Nothing End Function @@ -214,7 +214,7 @@ Module Program Dim expected = - Async Function rtrtAsync() As Task(Of Integer) +Async Function rtrtAsync() As Task(Of Integer) Await Nothing End Function @@ -231,8 +231,8 @@ Module Program Dim expected = - Async Function rtrtAsync() As Threading.Tasks.Task(Of Integer) - Await Nothing +Async Function rtrtAsync() As Threading.Tasks.Task(Of Integer) + Await Nothing End Function Await TestAsync(initial, expected) diff --git a/src/EditorFeatures/VisualBasicTest/Diagnostics/MoveToTopOfFile/MoveToTopOfFileTests.vb b/src/EditorFeatures/VisualBasicTest/Diagnostics/MoveToTopOfFile/MoveToTopOfFileTests.vb index c590a6c4e2684..680bb1e62eafe 100644 --- a/src/EditorFeatures/VisualBasicTest/Diagnostics/MoveToTopOfFile/MoveToTopOfFileTests.vb +++ b/src/EditorFeatures/VisualBasicTest/Diagnostics/MoveToTopOfFile/MoveToTopOfFileTests.vb @@ -51,10 +51,12 @@ End Module") End Sub End Module [|Imports System|]", -"Imports System Module Program - Sub Main(args As String()) -End Sub -End Module") +"Imports System +Module Program + Sub Main(args As String()) + End Sub +End Module +") End Function @@ -77,7 +79,8 @@ Module Program Sub Main(args As String()) End Sub -End Module +End Module + Await TestInRegularAndScriptAsync(text.ConvertTestSourceTag(), expected.ConvertTestSourceTag()) End Function @@ -102,7 +105,8 @@ Module Program Sub Main(args As String()) End Sub -End Module +End Module + Await TestInRegularAndScriptAsync(text.ConvertTestSourceTag(), expected.ConvertTestSourceTag()) End Function @@ -127,7 +131,8 @@ Module Program Sub Main(args As String()) End Sub -End Module +End Module + Await TestInRegularAndScriptAsync(text.ConvertTestSourceTag(), expected.ConvertTestSourceTag()) End Function @@ -152,7 +157,8 @@ Module Program Sub Main(args As String()) End Sub -End Module +End Module + Await TestInRegularAndScriptAsync(text.ConvertTestSourceTag(), expected.ConvertTestSourceTag()) End Function @@ -208,7 +214,8 @@ End Module Module Program Sub Main(args As String()) End Sub -End Module") +End Module +") End Function @@ -231,7 +238,8 @@ Module Program Sub Main(args As String()) End Sub -End Module +End Module + Await TestInRegularAndScriptAsync(text.ConvertTestSourceTag(), expected.ConvertTestSourceTag()) End Function @@ -256,7 +264,8 @@ Module Program Sub Main(args As String()) End Sub -End Module +End Module + Await TestInRegularAndScriptAsync(text.ConvertTestSourceTag(), expected.ConvertTestSourceTag()) End Function @@ -281,7 +290,8 @@ Module Program Sub Main(args As String()) End Sub -End Module +End Module + Await TestInRegularAndScriptAsync(text.ConvertTestSourceTag(), expected.ConvertTestSourceTag()) End Function @@ -307,7 +317,8 @@ Module Program Sub Main(args As String()) End Sub -End Module +End Module + Await TestInRegularAndScriptAsync(text.ConvertTestSourceTag(), expected.ConvertTestSourceTag()) End Function @@ -335,7 +346,8 @@ Module Program Sub Main(args As String()) End Sub -End Module +End Module + Await TestInRegularAndScriptAsync(text.ConvertTestSourceTag(), expected.ConvertTestSourceTag()) End Function @@ -363,7 +375,8 @@ Module Program Sub Main(args As String()) End Sub -End Module +End Module + Await TestInRegularAndScriptAsync(text.ConvertTestSourceTag(), expected.ConvertTestSourceTag()) End Function @@ -381,15 +394,16 @@ Module Program End Module [|Option Compare Binary|] - Dim expected = -Option Compare Binary + Dim expected = Option Compare Binary + #Const A = 5 Module Program Sub Main(args As String()) End Sub -End Module +End Module + Await TestInRegularAndScriptAsync(text.ConvertTestSourceTag(), expected.ConvertTestSourceTag()) End Function @@ -421,7 +435,8 @@ Module Program Sub Main(args As String()) End Sub -End Module +End Module + Await TestInRegularAndScriptAsync(text.ConvertTestSourceTag(), expected.ConvertTestSourceTag()) End Function @@ -469,8 +484,8 @@ End Module <[|Assembly:|] Reflection.AssemblyCultureAttribute("de")> - Dim expected = -<Assembly: Reflection.AssemblyCultureAttribute("de")> + Dim expected = <Assembly: Reflection.AssemblyCultureAttribute("de")> + Module Program Sub Main(args As String()) @@ -491,12 +506,13 @@ Module Program End Module - Dim expected = -<Assembly: Reflection.AssemblyCultureAttribute("de")> + Dim expected = <Assembly: Reflection.AssemblyCultureAttribute("de")> + Module Program Sub Main(args As String()) + End Sub -End Module +End Module Await TestInRegularAndScriptAsync(text.ConvertTestSourceTag(), expected.ConvertTestSourceTag()) End Function @@ -518,8 +534,9 @@ End Module <Assembly: Reflection.AssemblyCultureAttribute("de")> 'Another Comment Module Program Sub Main(args As String()) + End Sub -End Module +End Module Await TestInRegularAndScriptAsync(text.ConvertTestSourceTag(), expected.ConvertTestSourceTag()) End Function @@ -539,10 +556,10 @@ End Module <[|Assembly:|] Reflection.AssemblyCultureAttribute("de")> - Dim expected = + Dim expected = <Assembly: Reflection.AssemblyCultureAttribute("de")> + ' Copyright ' License information. -<Assembly: Reflection.AssemblyCultureAttribute("de")> Module Program Sub Main(args As String()) @@ -576,9 +593,10 @@ End Class <Assembly:CLSCompliant(True)> [|Imports System|] - Dim expected = -[|Imports System|] -<Assembly:CLSCompliant(True)> + Dim expected = [|Imports System|] + +<Assembly:CLSCompliant(True)> + Await TestInRegularAndScriptAsync(text.ConvertTestSourceTag(), expected.ConvertTestSourceTag()) End Function diff --git a/src/EditorFeatures/VisualBasicTest/Diagnostics/PreferFrameworkType/PreferFrameworkTypeTests.vb b/src/EditorFeatures/VisualBasicTest/Diagnostics/PreferFrameworkType/PreferFrameworkTypeTests.vb index 69e04178955a8..b8eb9a63798eb 100644 --- a/src/EditorFeatures/VisualBasicTest/Diagnostics/PreferFrameworkType/PreferFrameworkTypeTests.vb +++ b/src/EditorFeatures/VisualBasicTest/Diagnostics/PreferFrameworkType/PreferFrameworkTypeTests.vb @@ -200,7 +200,8 @@ End Class "Imports System Class C Protected i As Int32 -End Class", options:=FrameworkTypeInDeclaration) +End Class +", options:=FrameworkTypeInDeclaration) End Function @@ -214,7 +215,8 @@ End Class "Imports System Class C Protected i As Int32 = 5 -End Class", options:=FrameworkTypeInDeclaration) +End Class +", options:=FrameworkTypeInDeclaration) End Function @@ -228,7 +230,8 @@ End Class "Imports System Class C Public Delegate Function PerformCalculation(x As Integer, y As Integer) As Int32 -End Class", options:=FrameworkTypeInDeclaration) +End Class +", options:=FrameworkTypeInDeclaration) End Function @@ -242,7 +245,8 @@ End Class "Imports System Class C Public Property X As Int64 -End Class", options:=FrameworkTypeInDeclaration) +End Class +", options:=FrameworkTypeInDeclaration) End Function @@ -258,7 +262,8 @@ End Class Imports System.Collections.Generic Class C Public Property X As List(Of Int64) -End Class", options:=FrameworkTypeInDeclaration) +End Class +", options:=FrameworkTypeInDeclaration) End Function @@ -274,7 +279,8 @@ End Class Class C Public Function F() As Int32 End Function -End Class", options:=FrameworkTypeInDeclaration) +End Class +", options:=FrameworkTypeInDeclaration) End Function @@ -290,7 +296,8 @@ End Class Class C Public Sub F(x As Int32) End Sub -End Class", options:=FrameworkTypeInDeclaration) +End Class +", options:=FrameworkTypeInDeclaration) End Function @@ -312,7 +319,8 @@ Class C Public Sub Test() Method(Of Int32)() End Sub -End Class", options:=FrameworkTypeInDeclaration) +End Class +", options:=FrameworkTypeInDeclaration) End Function @@ -330,7 +338,8 @@ Class C Public Sub Test() Dim x As Int32 = 5 End Sub -End Class", options:=FrameworkTypeInDeclaration) +End Class +", options:=FrameworkTypeInDeclaration) End Function @@ -348,7 +357,8 @@ Class C Public Sub Test() Dim x = Int32.MaxValue End Sub -End Class", options:=FrameworkTypeInMemberAccess) +End Class +", options:=FrameworkTypeInMemberAccess) End Function @@ -366,7 +376,8 @@ Class C Public Sub Test() Dim x = Int32.Parse(""1"") End Sub -End Class", options:=FrameworkTypeInMemberAccess) +End Class +", options:=FrameworkTypeInMemberAccess) End Function @@ -381,10 +392,11 @@ End Class ", "Imports System Class C - ''' + ''' Public Sub Test() End Sub -End Class", options:=FrameworkTypeInMemberAccess) +End Class +", options:=FrameworkTypeInMemberAccess) End Function @@ -402,7 +414,8 @@ Class C Public Sub Test() Dim x = GetType(Int32) End Sub -End Class", options:=FrameworkTypeInDeclaration) +End Class +", options:=FrameworkTypeInDeclaration) End Function @@ -420,7 +433,8 @@ Class C Public Sub Test() Dim func3 As Func(Of Integer, Integer) = Function(z As Int32) z + 1 End Sub -End Class", options:=FrameworkTypeInDeclaration) +End Class +", options:=FrameworkTypeInDeclaration) End Function @@ -438,7 +452,8 @@ Class C Public Sub Test() Dim z = New DateTime(2016, 8, 23) End Sub -End Class", options:=FrameworkTypeInDeclaration) +End Class +", options:=FrameworkTypeInDeclaration) End Function @@ -456,7 +471,8 @@ Class C Public Sub Test() Dim k As Int32() = New Integer(3) {} End Sub -End Class", options:=FrameworkTypeInDeclaration) +End Class +", options:=FrameworkTypeInDeclaration) End Function @@ -474,7 +490,8 @@ Class C Public Sub Test() Dim k As Integer() = New Int32(3) {0, 1, 2, 3} End Sub -End Class", options:=FrameworkTypeInDeclaration) +End Class +", options:=FrameworkTypeInDeclaration) End Function @@ -494,7 +511,8 @@ Class C Public Sub Test() Dim a As List(Of Int32()(,)(,,,)) End Sub -End Class", options:=FrameworkTypeInDeclaration) +End Class +", options:=FrameworkTypeInDeclaration) End Function @@ -514,7 +532,8 @@ Class C For j As Int32 = 0 To 3 Next End Sub -End Class", options:=FrameworkTypeInDeclaration) +End Class +", options:=FrameworkTypeInDeclaration) End Function @@ -534,7 +553,8 @@ Class C For Each item As Int32 In New Integer() {1, 2, 3} Next End Sub -End Class", options:=FrameworkTypeInDeclaration) +End Class +", options:=FrameworkTypeInDeclaration) End Function diff --git a/src/EditorFeatures/VisualBasicTest/Diagnostics/RemoveUnnecessaryCast/RemoveUnnecessaryCastTests.vb b/src/EditorFeatures/VisualBasicTest/Diagnostics/RemoveUnnecessaryCast/RemoveUnnecessaryCastTests.vb index 3c2af90aca4f7..2f4a5d26fd7c0 100644 --- a/src/EditorFeatures/VisualBasicTest/Diagnostics/RemoveUnnecessaryCast/RemoveUnnecessaryCastTests.vb +++ b/src/EditorFeatures/VisualBasicTest/Diagnostics/RemoveUnnecessaryCast/RemoveUnnecessaryCastTests.vb @@ -348,6 +348,7 @@ Module Module1 End Function End Sub End Module + Await TestAsync(markup, expected, ignoreTrivia:=False) @@ -1510,6 +1511,7 @@ Module Program If True Then : Dim x As Action = (Sub() If True Then) : Else : Return : End If End Sub End Module + Await TestAsync(markup, expected, ignoreTrivia:=False) @@ -1571,6 +1573,7 @@ Module Program x() : Console.WriteLine() End Sub End Module + Await TestAsync(markup, expected, ignoreTrivia:=False) diff --git a/src/EditorFeatures/VisualBasicTest/Diagnostics/SimplifyTypeNames/SimplifyTypeNamesTests.vb b/src/EditorFeatures/VisualBasicTest/Diagnostics/SimplifyTypeNames/SimplifyTypeNamesTests.vb index 7337f8b06fd73..96d4ac5a27a2c 100644 --- a/src/EditorFeatures/VisualBasicTest/Diagnostics/SimplifyTypeNames/SimplifyTypeNamesTests.vb +++ b/src/EditorFeatures/VisualBasicTest/Diagnostics/SimplifyTypeNames/SimplifyTypeNamesTests.vb @@ -120,6 +120,94 @@ Module Program End Module") End Function + + + Public Async Function DoNotChangeToAliasInNameOfIfItChangesNameOfName() As Task + Await TestInRegularAndScript1Async( +"Imports System +Imports Foo = SimplifyInsideNameof.Program + +namespace SimplifyInsideNameof + class Program + shared sub Main() + Console.WriteLine(nameof([|SimplifyInsideNameof.Program|])) + end sub + end class +end namespace", +"Imports System +Imports Foo = SimplifyInsideNameof.Program + +namespace SimplifyInsideNameof + class Program + shared sub Main() + Console.WriteLine(nameof(Program)) + end sub + end class +end namespace") + End Function + + + + Public Async Function DoChangeToAliasInNameOfIfItDoesNotAffectName1() As Task + Await TestInRegularAndScriptAsync( +"Imports System +Imports Goo = SimplifyInsideNameof.Program + +namespace SimplifyInsideNameof + class Program + shared sub Main() + Console.WriteLine(nameof([|SimplifyInsideNameof.Program|].Main)) + end sub + end class +end namespace", +"Imports System +Imports Goo = SimplifyInsideNameof.Program + +namespace SimplifyInsideNameof + class Program + shared sub Main() + Console.WriteLine(nameof(Goo.Main)) + end sub + end class +end namespace") + End Function + + + + Public Async Function DoChangeToAliasInNameOfIfItDoesNotAffectName2() As Task + Await TestInRegularAndScriptAsync( +"Imports System +Imports Goo = N.Goo + +namespace N + class Goo + end class +end namespace + +namespace SimplifyInsideNameof + class Program + shared sub Main() + Console.WriteLine(nameof([|N.Goo|])) + end sub + end class +end namespace", +"Imports System +Imports Goo = N.Goo + +namespace N + class Goo + end class +end namespace + +namespace SimplifyInsideNameof + class Program + shared sub Main() + Console.WriteLine(nameof(Goo)) + end sub + end class +end namespace") + End Function + Public Async Function TestWithCursorAtBeginning() As Task Await TestInRegularAndScriptAsync( @@ -877,6 +965,7 @@ End Namespace", Namespace N1 Class Test Private a As List(Of String()(,)(,,,)) + End Class End Namespace") End Function @@ -1604,7 +1693,7 @@ End Namespace Namespace bar Module b Sub m() - goo.Main(Nothing) + goo.Main(Nothing) End Sub End Module End Namespace @@ -1921,7 +2010,7 @@ Public Class Test_Dev11 '''<summary> ''' <see cref="Microsoft.VisualBasic.Left"/> ''' </Code> - Public Async Function Testtestscenarios() As Task + Public Async Function Testtestscenarios() As Task End Sub End Class diff --git a/src/EditorFeatures/VisualBasicTest/Diagnostics/Suppression/SuppressionTests.vb b/src/EditorFeatures/VisualBasicTest/Diagnostics/Suppression/SuppressionTests.vb index dae579c33ad2a..38c42de7b41af 100644 --- a/src/EditorFeatures/VisualBasicTest/Diagnostics/Suppression/SuppressionTests.vb +++ b/src/EditorFeatures/VisualBasicTest/Diagnostics/Suppression/SuppressionTests.vb @@ -478,37 +478,37 @@ Class C End Sub End Class]]> - Dim expected = + ' Comment + ' Comment +#Disable Warning BC42309 ' {WRN_XMLDocCrefAttributeNotFound1_Title} + ''' Sub M() ' Comment -#Enable Warning BC42309 +#Enable Warning BC42309 ' {WRN_XMLDocCrefAttributeNotFound1_Title} End Sub -End Class]]> +End Class" Dim enableDocCommentProcessing = VisualBasicParseOptions.Default.WithDocumentationMode(DocumentationMode.Diagnose) - Await TestAsync(source.Value, expected.Value, enableDocCommentProcessing) + Await TestAsync(source.Value, expected, enableDocCommentProcessing) ' Also verify that the added directive does indeed suppress the diagnostic. - Dim fixedSource = + ' Comment + ' Comment +#Disable Warning BC42309 ' {WRN_XMLDocCrefAttributeNotFound1_Title} + ''' Sub M() ' Comment -#Enable Warning BC42309 +#Enable Warning BC42309 ' {WRN_XMLDocCrefAttributeNotFound1_Title} End Sub -End Class]]> +End Class" - Await TestMissingAsync(fixedSource.Value, + Await TestMissingAsync(fixedSource, New TestParameters(enableDocCommentProcessing)) End Function @@ -516,22 +516,22 @@ End Class]]> Public Async Function TestPragmaWarningDirectiveAroundTrivia2() As Task Dim source = |]]]> - Dim expected = -#Enable Warning BC42312]]> + Dim expected = $"#Disable Warning BC42312 ' {WRN_XMLDocWithoutLanguageElement_Title} +''' +#Enable Warning BC42312 ' {WRN_XMLDocWithoutLanguageElement_Title}" - Await TestAsync(source.Value, expected.Value, VisualBasicParseOptions.Default.WithDocumentationMode(DocumentationMode.Diagnose)) + Await TestAsync(source.Value, expected, VisualBasicParseOptions.Default.WithDocumentationMode(DocumentationMode.Diagnose)) End Function Public Async Function TestPragmaWarningDirectiveAroundTrivia3() As Task Dim source = |] ]]> - Dim expected = -#Enable Warning BC42312]]> + Dim expected = $"#Disable Warning BC42312 ' {WRN_XMLDocWithoutLanguageElement_Title} +''' +#Enable Warning BC42312 ' {WRN_XMLDocWithoutLanguageElement_Title}" - Await TestAsync(source.Value, expected.Value, VisualBasicParseOptions.Default.WithDocumentationMode(DocumentationMode.Diagnose)) + Await TestAsync(source.Value, expected, VisualBasicParseOptions.Default.WithDocumentationMode(DocumentationMode.Diagnose)) End Function @@ -543,16 +543,16 @@ End Class]]> Class C : End Class ]]> - Dim expected = +#Disable Warning BC42309 ' {WRN_XMLDocCrefAttributeNotFound1_Title} +''' Class C : End Class -#Enable Warning BC42309 +#Enable Warning BC42309 ' {WRN_XMLDocCrefAttributeNotFound1_Title} -]]> +" - Await TestAsync(source.Value, expected.Value, VisualBasicParseOptions.Default.WithDocumentationMode(DocumentationMode.Diagnose)) + Await TestAsync(source.Value, expected, VisualBasicParseOptions.Default.WithDocumentationMode(DocumentationMode.Diagnose)) End Function @@ -562,14 +562,14 @@ Class C : End Class ''' Class C2 : End Class Class C3 : End Class]]> - Dim expected = + Dim expected = $"class C1 : End Class +#Disable Warning BC42309 ' {WRN_XMLDocCrefAttributeNotFound1_Title} +''' Class C2 : End Class -#Enable Warning BC42309 -Class C3 : End Class]]> +#Enable Warning BC42309 ' {WRN_XMLDocCrefAttributeNotFound1_Title} +Class C3 : End Class" - Await TestAsync(source.Value, expected.Value, VisualBasicParseOptions.Default.WithDocumentationMode(DocumentationMode.Diagnose)) + Await TestAsync(source.Value, expected, VisualBasicParseOptions.Default.WithDocumentationMode(DocumentationMode.Diagnose)) End Function @@ -578,14 +578,14 @@ Class C3 : End Class]]> Dim source = - Dim expected = +Class C3 : End Class" - Await TestAsync(source.Value, expected.Value, VisualBasicParseOptions.Default.WithDocumentationMode(DocumentationMode.Diagnose)) + Await TestAsync(source.Value, expected, VisualBasicParseOptions.Default.WithDocumentationMode(DocumentationMode.Diagnose)) End Function End Class diff --git a/src/EditorFeatures/VisualBasicTest/Diagnostics/UseAutoProperty/UseAutoPropertyTests.vb b/src/EditorFeatures/VisualBasicTest/Diagnostics/UseAutoProperty/UseAutoPropertyTests.vb index aff1d2abd0802..fe74418a39cb4 100644 --- a/src/EditorFeatures/VisualBasicTest/Diagnostics/UseAutoProperty/UseAutoPropertyTests.vb +++ b/src/EditorFeatures/VisualBasicTest/Diagnostics/UseAutoProperty/UseAutoPropertyTests.vb @@ -86,7 +86,8 @@ end class") end property|] end class", "class Class1 - readonly property P as integer = 1 + readonly property P as integer += 1 end class") End Function @@ -463,7 +464,7 @@ end class") end class", "class Class1 ReadOnly property P as Integer - public sub new(dim P as integer) + public sub new(dim P as integer) Me.P = 1 end sub end class") @@ -540,8 +541,9 @@ end class") end class", "class Class1 public property P as Integer - public sub Goo() P = 1 - end sub + public sub Goo() + P = 1 + end sub end class") End Function diff --git a/src/EditorFeatures/VisualBasicTest/GenerateConstructor/GenerateConstructorTests.vb b/src/EditorFeatures/VisualBasicTest/GenerateConstructor/GenerateConstructorTests.vb index c759001b63d94..b81759860cada 100644 --- a/src/EditorFeatures/VisualBasicTest/GenerateConstructor/GenerateConstructorTests.vb +++ b/src/EditorFeatures/VisualBasicTest/GenerateConstructor/GenerateConstructorTests.vb @@ -26,11 +26,13 @@ End Class", Private v1 As Integer Private v2 As Integer Private v3 As Integer + Public Sub New(v1 As Integer, v2 As Integer, v3 As Integer) Me.v1 = v1 Me.v2 = v2 Me.v3 = v3 End Sub + Sub Main() Dim f = New C(4, 5, 6) End Sub @@ -56,6 +58,7 @@ End Class", End Class Friend Class B Private v As Integer + Public Sub New(v As Integer) Me.v = v End Sub @@ -106,6 +109,7 @@ End Class Class A Public Sub New() End Sub + Sub New(x As Integer) End Sub End Class") @@ -128,6 +132,7 @@ End Class", End Class Class A Private v As Integer + Public Sub New(v As Integer) Me.v = v End Sub @@ -153,8 +158,10 @@ End Class", End Class Class A Private v As Integer + Public Sub New() End Sub + Public Sub New(v As Integer) Me.v = v End Sub @@ -181,8 +188,10 @@ End Class", End Class Class A Private v As Integer + Public Sub New() End Sub + Public Sub New(v As Integer) Me.v = v End Sub @@ -207,9 +216,11 @@ Public Class A End Class", "Public Partial Class Test Private v As Integer + Public Sub New(v As Integer) Me.v = v End Sub + Public Sub S1() End Sub End Class @@ -242,9 +253,11 @@ Public Class A End Class", "Public Partial Class Test Private v As Integer + Public Sub New(v As Integer) Me.v = v End Sub + Public Sub S1() End Sub End Class @@ -273,6 +286,7 @@ Public Class A End Class", "Public Partial Class Test2 Private v As Integer + Public Sub New(v As Integer) Me.v = v End Sub @@ -316,6 +330,7 @@ End Class", "Class Goo Class Bar Private v As Integer + Public Sub New(v As Integer) Me.v = v End Sub @@ -351,9 +366,11 @@ End Class", "Public Partial Class Test Public Partial Class NestedTest Private v As Integer + Public Sub New(v As Integer) Me.v = v End Sub + Public Sub S1() End Sub End Class @@ -382,6 +399,7 @@ End Class", "Class Outer(Of T) Public Class Inner Private v As Integer + Public Sub New(v As Integer) Me.v = v End Sub @@ -403,6 +421,7 @@ End Class", "Class Base(Of T, V) Private v1 As Integer Private v2 As Integer + Public Sub New(v1 As Integer, v2 As Integer) Me.v1 = v1 Me.v2 = v2 @@ -433,7 +452,9 @@ End Class", End Class Class Derived(Of V) Inherits Base(Of Integer, V) + Private v1 As Integer + Public Sub New(v1 As Integer) Me.v1 = v1 End Sub @@ -471,7 +492,9 @@ Class Derived(Of V) End Class Class MoreDerived Inherits Derived(Of Double) + Private v As Double + Public Sub New(v As Double) Me.v = v End Sub @@ -498,6 +521,7 @@ Class A End Class", "Class Goo Private now As Date + Public Sub New(now As Date) Me.now = now End Sub @@ -524,6 +548,7 @@ Class Derived End Class", "Class Base Private x As Integer + Public Sub New(x As Integer) Me.x = x End Sub @@ -556,6 +581,7 @@ Class Derived End Class", "MustInherit Class Base Private x As Integer + Protected Sub New(x As Integer) Me.x = x End Sub @@ -619,7 +645,7 @@ Class C Public v1 As Integer Private i As Char - Public Sub New(v1 As Integer) + Public Sub New(v1 As Integer) Me.v1 = v1 End Sub @@ -647,6 +673,7 @@ End Class", End Module Friend Class C Private c As C + Public Sub New(c As C) Me.c = c End Sub @@ -672,6 +699,7 @@ End Class Friend Class Test Private x As Object Private y As Object + Public Sub New(x As Object, y As Object) Me.x = x Me.y = y @@ -699,6 +727,7 @@ End Class", End Class Class A Private [class] As Integer + Public Sub New([class] As Integer) Me.class = [class] End Sub @@ -723,6 +752,7 @@ End Class", End Class Class A Private p As Object + Public Sub New(p As Object) Me.p = p End Sub @@ -747,6 +777,7 @@ End Class", End Class Class Bar(Of V) Private v1 As Integer + Public Sub New(v1 As Integer) Me.v1 = v1 End Sub @@ -766,9 +797,11 @@ End Class") End Class", "Class C ReadOnly x As Integer + Public Sub New(x As Integer) Me.x = x End Sub + Sub Test() Dim x As Integer = 1 Dim obj As New C(x) @@ -796,6 +829,7 @@ Class A Public Sub New(P As Integer) Me.P = P End Sub + Public Property P As Integer End Class") End Function @@ -820,9 +854,11 @@ End Class", End Class Class C Private u1 As Integer + Public Sub New(u As Integer) u1 = u End Sub + Public Sub u() End Sub End Class") @@ -847,9 +883,11 @@ End Class", End Class Class A Private P1 As Integer + Public Sub New(P As Integer) P1 = P End Sub + Shared Property P As Integer End Class") End Function @@ -874,6 +912,7 @@ End Class Class B Private x As String Private x1 As Integer + Public Sub New(x As Integer) x1 = x End Sub @@ -903,6 +942,7 @@ End Class Class C Inherits B Private x As String + Public Sub New(u As Integer) Me.u = u End Sub @@ -923,9 +963,11 @@ End Class") End Class", "Class C Private v As Integer + Sub New Me.New(1) End Sub + Public Sub New(v As Integer) Me.v = v End Sub @@ -958,9 +1000,11 @@ End Class") End Class", "Class C Private v As Integer + Sub New MyClass.New(1) End Sub + Public Sub New(v As Integer) Me.v = v End Sub @@ -1002,6 +1046,7 @@ End Class", End Class Class B Private v As Integer + Public Sub New(v As Integer) Me.v = v End Sub @@ -1113,6 +1158,7 @@ Class C End Class Class D Private v As Integer + Public Sub New(v As Integer) Me.v = v End Sub @@ -1163,9 +1209,11 @@ End Module Class C Private prop As String Private v As Integer + Public Sub New(prop As String) Me.prop = prop End Sub + Public Sub New(v As Integer, prop As String) Me.v = v Me.prop = prop @@ -1209,7 +1257,9 @@ End Class", " Public Class MyAttribute Inherits System.Attribute + Private v As Integer + Public Sub New(v As Integer) Me.v = v End Sub @@ -1233,9 +1283,11 @@ End Class", " Public Class MyAttribute Inherits System.Attribute + Private v1 As Boolean Private v2 As Integer Private v3 As String + Public Sub New(v1 As Boolean, v2 As Integer, v3 As String) Me.v1 = v1 Me.v2 = v2 @@ -1297,9 +1349,11 @@ Public Class MyAttribute Inherits System.Attribute Private v As Integer Private v1 As Integer + Public Sub New(v As Integer) Me.v = v End Sub + Public Sub New(v As Integer, v1 As Integer) Me.New(v) Me.v1 = v1 @@ -1329,6 +1383,7 @@ End Enum Public Class MyAttribute Inherits System.Attribute + Private v1 As Short() Private a1 As A Private v2 As Boolean @@ -1340,6 +1395,7 @@ Public Class MyAttribute Private v8 As Double Private v9 As Single Private v10 As String + Public Sub New(v1() As Short, a1 As A, v2 As Boolean, v3 As Integer, v4 As Char, v5 As Short, v6 As Integer, v7 As Long, v8 As Double, v9 As Single, v10 As String) Me.v1 = v1 Me.a1 = a1 @@ -1355,8 +1411,7 @@ Public Class MyAttribute End Sub End Class -Public Class D -End Class") +Public Class D End Class") End Function @@ -1432,9 +1487,11 @@ Module Module1 Class Classic Private int As Integer Private obj As Object + Public Sub New(int As Integer) Me.int = int End Sub + Public Sub New(obj As Object) Me.obj = obj End Sub @@ -1458,6 +1515,7 @@ End Class", "Class Goo Private Class Bar Private v As Integer + Public Sub New(v As Integer) Me.v = v End Sub @@ -1490,12 +1548,14 @@ Class C "Imports System.Linq Class C Private v As Integer + Sub New() Dim s As Action = Sub() - Dim a = New C(0)Public Sub New(v As Integer) - Me.v = v - End Sub - End Class") + Dim a = New C(0)Public Sub New(v As Integer) + Me.v = v + End Sub +End Class +") End Function @@ -1515,17 +1575,18 @@ Class C Class C Private v As Integer Private v1 As Integer + Public Sub New(v As Integer) Me.v = v End Sub Sub New() Dim s As Action = Sub() - Dim a = New C(0, 0) - Public Sub New(v As Integer, v1 As Integer) + Dim a = New C(0, 0)Public Sub New(v As Integer, v1 As Integer) Me.New(v) Me.v1 = v1 End Sub -End Class") +End Class +") End Function End Class diff --git a/src/EditorFeatures/VisualBasicTest/GenerateConstructorFromMembers/GenerateConstructorFromMembersTests.vb b/src/EditorFeatures/VisualBasicTest/GenerateConstructorFromMembers/GenerateConstructorFromMembersTests.vb index 1d9a9e3319f3c..1bb6fbcf1c725 100644 --- a/src/EditorFeatures/VisualBasicTest/GenerateConstructorFromMembers/GenerateConstructorFromMembersTests.vb +++ b/src/EditorFeatures/VisualBasicTest/GenerateConstructorFromMembers/GenerateConstructorFromMembersTests.vb @@ -21,6 +21,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.GenerateConstructo End Class", "Class Program Private i As Integer + Public Sub New(i As Integer{|Navigation:)|} Me.i = i End Sub @@ -37,6 +38,7 @@ End Class", "Class Program Private i As Integer Private b As String + Public Sub New(i As Integer, b As String{|Navigation:)|} Me.i = i Me.b = b @@ -60,6 +62,7 @@ End Class", Public Sub New(i As Integer) Me.i = i End Sub + Public Sub New(b As String{|Navigation:)|} Me.b = b End Sub @@ -82,6 +85,7 @@ End Class", Public Sub New(i As Integer) Me.i = i End Sub + Public Sub New(i As Integer, b As String{|Navigation:)|} Me.i = i Me.b = b @@ -113,6 +117,7 @@ End Class") End Structure", "Structure S Private i As Integer + Public Sub New(i As Integer{|Navigation:)|} Me.i = i End Sub @@ -127,6 +132,7 @@ End Structure") End Class", "Class Program(Of T) Private i As Integer + Public Sub New(i As Integer{|Navigation:)|} Me.i = i End Sub @@ -150,6 +156,7 @@ End Class", Public Sub New(i As Integer) Me.i = i End Sub + Public Sub New(i As Integer, b As String{|Navigation:)|} Me.New(i) Me.b = b @@ -171,6 +178,7 @@ End Class", Me.A = a Me.B = b End Sub + Public Property A As Integer Public Property B As String End Class") @@ -214,6 +222,7 @@ End Class") End Class", "Class Program Private i As Integer + Public Sub New(i As Integer{|Navigation:)|} Me.i = i End Sub @@ -229,6 +238,7 @@ End Class", chosenSymbols:={"i"}) End Class", "Class Program Private i As Integer + Public Sub New({|Navigation:)|} End Sub End Class", chosenSymbols:={}) @@ -245,6 +255,7 @@ End Class", "Class Program Private i As Integer Private j As String + Public Sub New(j As String, i As Integer{|Navigation:)|} Me.j = j Me.i = i @@ -260,6 +271,7 @@ End Class", chosenSymbols:={"j", "i"}) End Class", "Class Program Private i As Integer + Public Sub New(i As Integer{|Navigation:)|} Me.i = i End Sub diff --git a/src/EditorFeatures/VisualBasicTest/GenerateDefaultConstructors/GenerateDefaultConstructorsTests.vb b/src/EditorFeatures/VisualBasicTest/GenerateDefaultConstructors/GenerateDefaultConstructorsTests.vb index dd654f9531533..590521da2f239 100644 --- a/src/EditorFeatures/VisualBasicTest/GenerateDefaultConstructors/GenerateDefaultConstructorsTests.vb +++ b/src/EditorFeatures/VisualBasicTest/GenerateDefaultConstructors/GenerateDefaultConstructorsTests.vb @@ -28,8 +28,10 @@ Imports System.Collections.Generic Imports System.Linq Class Program Inherits Exception + Public Sub New() End Sub + Sub Main(args As String()) End Sub End Class") @@ -51,9 +53,11 @@ Imports System.Collections.Generic Imports System.Linq Class Program Inherits Exception + Public Sub New(message As String) MyBase.New(message) End Sub + Sub Main(args As String()) End Sub End Class", @@ -74,7 +78,6 @@ End Class", "Imports System Imports System.Collections.Generic Imports System.Linq - Class Program Inherits Exception @@ -103,6 +106,7 @@ End Class", Imports System.Collections.Generic Imports System.Linq Imports System.Runtime.Serialization + Class Program Inherits Exception @@ -214,19 +218,24 @@ End Class", Imports System.Collections.Generic Imports System.Linq Imports System.Runtime.Serialization + Class Program Inherits Exception Public Sub New() End Sub + Public Sub New(message As String) MyBase.New(message) End Sub + Public Sub New(message As String, innerException As Exception) MyBase.New(message, innerException) End Sub + Protected Sub New(info As SerializationInfo, context As StreamingContext) MyBase.New(info, context) End Sub + Sub Main(args As String()) End Sub End Class", @@ -258,8 +267,10 @@ Imports System.Collections.Generic Imports System.Linq Class Program Inherits Exception + Public Sub New() End Sub + Public Sub New(message As String) MyBase.New(message) End Sub @@ -299,9 +310,11 @@ Class Program Public Sub New() End Sub + Public Sub New(message As String) MyBase.New(message) End Sub + Public Sub New(message As String, innerException As Exception) MyBase.New(message, innerException) End Sub @@ -331,8 +344,10 @@ Imports System.Collections.Generic Imports System.Linq Class Program Inherits Exception + Public Sub New() End Sub + Sub Main(args As String()) End Sub End Class") diff --git a/src/EditorFeatures/VisualBasicTest/GenerateEqualsAndGetHashCodeFromMembers/GenerateEqualsAndGetHashCodeFromMembersTests.vb b/src/EditorFeatures/VisualBasicTest/GenerateEqualsAndGetHashCodeFromMembers/GenerateEqualsAndGetHashCodeFromMembersTests.vb index 52c1c62ed89e0..99bc1bdc3242e 100644 --- a/src/EditorFeatures/VisualBasicTest/GenerateEqualsAndGetHashCodeFromMembers/GenerateEqualsAndGetHashCodeFromMembersTests.vb +++ b/src/EditorFeatures/VisualBasicTest/GenerateEqualsAndGetHashCodeFromMembers/GenerateEqualsAndGetHashCodeFromMembersTests.vb @@ -90,11 +90,14 @@ index:=1, ignoreTrivia:=False) [|Dim x As New V|] End Class", "Imports System.Collections.Generic + Partial Class c1(Of V As {New}, U) Dim x As New V + Public Overrides Function Equals(obj As Object) As Boolean Dim c = TryCast(obj, c1(Of V, U)) - Return c IsNot Nothing AndAlso EqualityComparer(Of V).Default.Equals(x, c.x) + Return c IsNot Nothing AndAlso + EqualityComparer(Of V).Default.Equals(x, c.x) End Function End Class") End Function diff --git a/src/EditorFeatures/VisualBasicTest/ImplementAbstractClass/ImplementAbstractClassTests.vb b/src/EditorFeatures/VisualBasicTest/ImplementAbstractClass/ImplementAbstractClassTests.vb index e20cac1e355fe..38dae3327142a 100644 --- a/src/EditorFeatures/VisualBasicTest/ImplementAbstractClass/ImplementAbstractClassTests.vb +++ b/src/EditorFeatures/VisualBasicTest/ImplementAbstractClass/ImplementAbstractClassTests.vb @@ -30,9 +30,11 @@ End Class", End Class Public Class Bar Inherits Goo + Public Overrides Sub Goo(i As Integer) Throw New System.NotImplementedException() End Sub + Protected Overrides Function Bar(s As String, ByRef d As Double) As Boolean Throw New System.NotImplementedException() End Function @@ -53,6 +55,7 @@ End Class", End Class Public Class Derived Inherits Base + Protected Overrides Function Bar(x As (a As Integer, Integer)) As (c As Integer, Integer) Throw New System.NotImplementedException() End Function @@ -73,6 +76,7 @@ End Class", End Class Class c Inherits b + Public Overrides Sub g(Optional x As Integer = 3) Throw New System.NotImplementedException() End Sub @@ -93,6 +97,7 @@ End Class", End Class Class c Inherits b + Public Overrides Sub g(Optional x As Boolean = True) Throw New System.NotImplementedException() End Sub @@ -113,6 +118,7 @@ End Class", End Class Class c Inherits b + Public Overrides Sub g(Optional x As Boolean = False) Throw New System.NotImplementedException() End Sub @@ -133,6 +139,7 @@ End Class", End Class Class c Inherits b + Public Overrides Sub g(Optional x As String = ""a"") Throw New System.NotImplementedException() End Sub @@ -153,6 +160,7 @@ End Class", End Class Class c Inherits b + Public Overrides Sub g(Optional x As Char = ""c""c) Throw New System.NotImplementedException() End Sub @@ -173,6 +181,7 @@ End Class", End Class Class c Inherits b + Public Overrides Sub g(Optional x As Long = 3) Throw New System.NotImplementedException() End Sub @@ -188,12 +197,12 @@ End Class Class [|c|] Inherits b End Class", -" -MustInherit Class b +"MustInherit Class b Public MustOverride Sub g(Optional x As Short = 3) End Class Class c Inherits b + Public Overrides Sub g(Optional x As Short = 3) Throw New System.NotImplementedException() End Sub @@ -209,12 +218,12 @@ End Class Class [|c|] Inherits b End Class", -" -MustInherit Class b +"MustInherit Class b Public MustOverride Sub g(Optional x As UShort = 3) End Class Class c Inherits b + Public Overrides Sub g(Optional x As UShort = 3) Throw New System.NotImplementedException() End Sub @@ -235,6 +244,7 @@ End Class", End Class Class c Inherits b + Public Overrides Sub g(Optional x As Integer = -3) Throw New System.NotImplementedException() End Sub @@ -255,6 +265,7 @@ End Class", End Class Class c Inherits b + Public Overrides Sub g(Optional x As UInteger = 3) Throw New System.NotImplementedException() End Sub @@ -275,6 +286,7 @@ End Class", End Class Class c Inherits b + Public Overrides Sub g(Optional x As ULong = 3) Throw New System.NotImplementedException() End Sub @@ -295,6 +307,7 @@ End Class", End Class Class c Inherits b + Public Overrides Sub g(Optional x As Decimal = 3) Throw New System.NotImplementedException() End Sub @@ -315,6 +328,7 @@ End Class", End Class Class c Inherits b + Public Overrides Sub g(Optional x As Double = 3) Throw New System.NotImplementedException() End Sub @@ -339,6 +353,7 @@ MustInherit Class b End Class Class c Inherits b + Public Overrides Sub g(Optional x As S = Nothing) Throw New System.NotImplementedException() End Sub @@ -364,6 +379,7 @@ MustInherit Class b End Class Class c Inherits b + Public Overrides Sub g(Optional x As S? = Nothing) Throw New System.NotImplementedException() End Sub @@ -385,6 +401,7 @@ End Class", End Class Class c Inherits b + Public Overrides Sub g(Optional x As Integer? = Nothing, Optional y As Integer? = 5) Throw New System.NotImplementedException() End Sub @@ -409,6 +426,7 @@ MustInherit Class b End Class Class c Inherits b + Public Overrides Sub g(Optional x As S = Nothing) Throw New System.NotImplementedException() End Sub @@ -429,6 +447,7 @@ MustInherit Class D MustOverride Sub Goo() End Class Class C : Inherits D + Public Overrides Sub Goo() Throw New NotImplementedException() End Sub @@ -449,6 +468,7 @@ MustInherit Class D MustOverride Sub Goo() End Class Class C : Inherits D : Implements IDisposable + Public Overrides Sub Goo() Throw New NotImplementedException() End Sub @@ -470,6 +490,7 @@ End Class", End Class Class C(Of S) Inherits A(Of S) + Public Overrides Sub Goo(Of S1 As S)() Throw New System.NotImplementedException() End Sub diff --git a/src/EditorFeatures/VisualBasicTest/ImplementInterface/ImplementInterfaceTests.vb b/src/EditorFeatures/VisualBasicTest/ImplementInterface/ImplementInterfaceTests.vb index 9e3496c8ca330..d68f1d61220d8 100644 --- a/src/EditorFeatures/VisualBasicTest/ImplementInterface/ImplementInterfaceTests.vb +++ b/src/EditorFeatures/VisualBasicTest/ImplementInterface/ImplementInterfaceTests.vb @@ -29,6 +29,7 @@ End Class", End Interface Class C Implements I + Public Sub M() Implements I.M Throw New System.NotImplementedException() End Sub @@ -48,6 +49,7 @@ End Interface", "Imports System Class Goo Implements IGoo + Public Function Method(x As (Alice As Integer, Bob As Integer)) As (String, String) Implements IGoo.Method Throw New NotImplementedException() End Function @@ -73,9 +75,11 @@ End Class", End Interface Class C Implements I + Private Sub I_M() Implements I.M Throw New System.NotImplementedException() End Sub + Function M() As Integer End Function End Class") @@ -99,6 +103,7 @@ Class C Implements IGoo Public Sub Bar() End Sub + Private Sub IGoo_Bar() Implements IGoo.Bar Throw New System.NotImplementedException() End Sub @@ -122,6 +127,7 @@ End Interface Class C Implements I Private m As Integer + Private Sub I_M() Implements I.M Throw New System.NotImplementedException() End Sub @@ -145,6 +151,7 @@ End Interface Class C Implements I Public Property M As Integer + Private Property I_M As Integer Implements I.M Get Throw New System.NotImplementedException() @@ -178,7 +185,6 @@ End Class", End Interface Class C Implements I - Private Property M As Integer Get Return 5 @@ -223,6 +229,7 @@ End Class Class C Inherits B Implements I + Private Sub I_M() Implements I.M Throw New System.NotImplementedException() End Sub @@ -252,6 +259,7 @@ End Class Class C Inherits B Implements I + Private Sub I_M() Implements I.M Throw New System.NotImplementedException() End Sub @@ -281,6 +289,7 @@ End Class Class C Inherits B Implements I + Private Sub I_M() Implements I.M Throw New System.NotImplementedException() End Sub @@ -301,6 +310,7 @@ End Class", End Interface MustInherit Class C Implements I + Public MustOverride Sub M() Implements I.M End Class", index:=1) @@ -320,6 +330,7 @@ End Class", End Interface Class [Class] Implements IInterface1(Of Integer) + Public Sub Method1(t As Integer) Implements IInterface1(Of Integer).Method1 Throw New System.NotImplementedException() End Sub @@ -340,6 +351,7 @@ End Class", End Interface Class [Class] Implements IInterface1(Of Integer) + Public Sub Method1(Of U)(arg As Integer, arg1 As U) Implements IInterface1(Of Integer).Method1 Throw New System.NotImplementedException() End Sub @@ -362,6 +374,7 @@ Interface IInterface1(Of T) End Interface Class [Class] Implements IInterface1(Of Integer) + Public Sub Method1(Of U As IList(Of Integer))(arg As Integer, arg1 As U) Implements IInterface1(Of Integer).Method1 Throw New System.NotImplementedException() End Sub @@ -382,6 +395,7 @@ End Class", End Interface Class [Class] Implements IInterface1(Of Integer) + Public Sub Method1(Of U As Integer)(arg As Integer, arg1 As U) Implements IInterface1(Of Integer).Method1 Throw New System.NotImplementedException() End Sub @@ -404,6 +418,7 @@ End Interface Class C Implements I Private x As I + Public Sub M() Implements I.M Throw New System.NotImplementedException() End Sub @@ -426,6 +441,7 @@ End Interface Class C Implements I Private x As I + Public Sub M() Implements I.M x.M() End Sub @@ -549,10 +565,12 @@ Class M "Imports System Class M Implements IServiceProvider + Public Function GetService(serviceType As Type) As Object Implements IServiceProvider.GetService Throw New NotImplementedException() End Function -End Class") +End Class +") End Function @@ -570,6 +588,7 @@ End Class", End Interface Class M Implements I1 + Public Property Goo As Integer Implements I1.Goo Get Throw New System.NotImplementedException() @@ -595,6 +614,7 @@ End Class", End Interface Class C Implements I + Public Function M() As String() Implements I.M Throw New System.NotImplementedException() End Function @@ -615,9 +635,11 @@ End Interface", "Class C Implements I Private goo As I + Public Sub Method1(ByRef x As Integer, ByRef y As Integer, z As Integer) Implements I.Method1 Throw New System.NotImplementedException() End Sub + Public Function Method2() As Integer Implements I.Method2 Throw New System.NotImplementedException() End Function @@ -642,6 +664,7 @@ End Class", End Interface Class C Implements I1 + Public Function Method1() As String Implements I1.Method1 Throw New System.NotImplementedException() End Function @@ -662,6 +685,7 @@ End Class", End Interface Class C Implements I1 + Public Sub Method1(ByRef arg As Double) Implements I1.Method1 Throw New System.NotImplementedException() End Sub @@ -695,9 +719,11 @@ End Interface", "Class C Implements I Private goo As I + Public Sub Method1(ByRef x As Integer, ByRef y As Integer, z As Integer) Implements I.Method1 Throw New System.NotImplementedException() End Sub + Public Function Method2() As Integer Implements I.Method2 Throw New System.NotImplementedException() End Function @@ -723,6 +749,7 @@ End Class", End Interface Class C Implements I1 + Default Public Property Goo(arg As Integer) As Object Implements I1.Goo Get Throw New System.NotImplementedException() @@ -756,6 +783,7 @@ End Class", End Interface Class C Implements I1.I2 + Public Sub Goo(arg As I1.Del) Implements I1.I2.Goo Throw New System.NotImplementedException() End Sub @@ -777,6 +805,7 @@ End Class", End Interface Class C Implements I1 + Public Sub Method1(arg() As Integer) Implements I1.Method1 Throw New System.NotImplementedException() End Sub @@ -801,6 +830,7 @@ End Namespace", End Interface Class C Implements I1 + Public Sub Method1() Implements I1.Method1 Throw New System.NotImplementedException() End Sub @@ -824,6 +854,7 @@ End Class", End Interface Class A Implements I2 + Public Function G(ParamArray args() As Double) As Integer Implements I2.G Throw New System.NotImplementedException() End Function @@ -845,6 +876,7 @@ End Class", End Interface Class A Implements I1 + Public Sub Goo() Implements I1.Goo Throw New System.NotImplementedException() End Sub @@ -893,6 +925,7 @@ End Interface Class C Implements I Public Property X As I + Public Sub M() Implements I.M Throw New System.NotImplementedException() End Sub @@ -912,6 +945,7 @@ End Interface Class C Implements I Public Property X As I + Public Sub M() Implements I.M X.M() End Sub @@ -1025,6 +1059,7 @@ End Class Class B Implements I Dim x As A + Public Sub M() Implements I.M DirectCast(x, I).M() End Sub @@ -1109,6 +1144,7 @@ Class B Implements I Implements I2 Dim x As A + Public Sub M() Implements I.M DirectCast(x, I).M() End Sub @@ -1149,6 +1185,7 @@ Class B Implements I Implements I2 Dim x As A + Public Sub M2() Implements I2.M2 DirectCast(x, I2).M2() End Sub @@ -1205,6 +1242,7 @@ Class B Implements I Dim x As A Dim y As A + Public Sub M() Implements I.M DirectCast(x, I).M() End Sub @@ -1239,6 +1277,7 @@ Class B Implements I Dim x As A Dim y As A + Public Sub M() Implements I.M DirectCast(y, I).M() End Sub @@ -1351,6 +1390,7 @@ Class C Implements I2 Dim x As A Dim y as B + Public Sub M() Implements I.M DirectCast(x, I).M() End Sub @@ -1405,6 +1445,7 @@ Class C Implements I2 Dim x As A Dim y as B + Public Sub M2() Implements I2.M2 DirectCast(y, I2).M2() End Sub @@ -1533,6 +1574,7 @@ End Class Class C Inherits B Implements I + Private Sub I_M() Implements I.M Throw New System.NotImplementedException() End Sub @@ -1554,6 +1596,7 @@ End Class", End Interface Class C Implements I ' Implement interface + Public Sub [Rem]() Implements I.[Rem] Throw New System.NotImplementedException() End Sub @@ -1582,6 +1625,7 @@ End Class", "Imports System.ComponentModel Class C Implements INotifyPropertyChanged + Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged End Class") End Function @@ -1615,19 +1659,16 @@ Class Boss Private worker As Worker - Public Custom Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged - - AddHandler(value As PropertyChangedEventHandler) - AddHandler DirectCast(worker, INotifyPropertyChanged).PropertyChanged, value - End AddHandler - - RemoveHandler(value As PropertyChangedEventHandler) - RemoveHandler DirectCast(worker, INotifyPropertyChanged).PropertyChanged, value - End RemoveHandler - - RaiseEvent(sender As Object, e As PropertyChangedEventArgs) - End RaiseEvent - End Event + Public Custom Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged + AddHandler(value As PropertyChangedEventHandler) + AddHandler DirectCast(worker, INotifyPropertyChanged).PropertyChanged, value + End AddHandler + RemoveHandler(value As PropertyChangedEventHandler) + RemoveHandler DirectCast(worker, INotifyPropertyChanged).PropertyChanged, value + End RemoveHandler + RaiseEvent(sender As Object, e As PropertyChangedEventArgs) + End RaiseEvent + End Event End Class", index:=1) End Function @@ -1646,6 +1687,7 @@ End Class", End Interface Class C(Of T, R) Implements I(Of T, R) + Public Sub Goo() Implements I(Of T, R).Goo Throw New System.NotImplementedException() End Sub @@ -1675,6 +1717,7 @@ Interface I2 End Interface Class C Implements I2 + Public Property Bar As Integer Implements I2.Bar Get Throw New System.NotImplementedException() @@ -1683,6 +1726,7 @@ Class C Throw New System.NotImplementedException() End Set End Property + Private Property I1_Bar As Integer Implements I1.Bar Get Throw New System.NotImplementedException() @@ -1731,6 +1775,7 @@ End Class Class C Inherits B Implements I1 + Private Property I1_Bar As Integer Implements I1.Bar Get Throw New System.NotImplementedException() @@ -1739,6 +1784,7 @@ Class C Throw New System.NotImplementedException() End Set End Property + Public Sub Goo() Implements I1.Goo Throw New System.NotImplementedException() End Sub @@ -1760,6 +1806,7 @@ End Class", End Interface Class C Implements I1 + Public Event E(x As String) Implements I1.E End Class") End Function @@ -1778,6 +1825,7 @@ End Class", End Interface Class Bar Implements IGoo + Public Sub Goo(Optional s As String = """""""") Implements IGoo.Goo Throw New System.NotImplementedException() End Sub @@ -1803,6 +1851,7 @@ End Interface Class C Implements I + Public Sub VBNullChar(Optional x As String = Constants.vbNullChar) Implements I.VBNullChar Throw New System.NotImplementedException() End Sub @@ -1832,6 +1881,7 @@ End Interface Namespace N Class Microsoft Implements I + Public Sub VBNullChar(Optional x As String = Constants.vbNullChar) Implements I.VBNullChar Throw New NotImplementedException() End Sub @@ -1861,6 +1911,7 @@ End Interface Class C Implements I + Public Sub ChrW(Optional x As String = Strings.ChrW(1)) Implements I.ChrW Throw New NotImplementedException() End Sub @@ -1882,6 +1933,7 @@ End Class", End Interface Class C Implements I + Public Sub Goo(Optional x As Date = #6/29/2012 12:00:00 AM#) Implements I.Goo Throw New System.NotImplementedException() End Sub @@ -1909,6 +1961,7 @@ End Interface Class C Implements I + Public Sub Goo(Optional x As DayOfWeek = DayOfWeek.Friday) Implements I.Goo Throw New NotImplementedException() End Sub @@ -1932,6 +1985,7 @@ End Interface Class C Implements I + Public Sub Goo(x As Integer()()) Implements I.Goo Throw New System.NotImplementedException() End Sub @@ -1959,6 +2013,7 @@ End Interface Class C Implements I + Public Sub Goo(Optional x As String = ChrW(8220)) Implements I.Goo Throw New NotImplementedException() End Sub @@ -1982,6 +2037,7 @@ End Interface Class C Implements I + Public Sub Goo(Optional x As Long = Long.MinValue) Implements I.Goo Throw New System.NotImplementedException() End Sub @@ -2303,6 +2359,7 @@ End Interface Class C Implements I + Public Sub Goo(x(,) As Integer) Implements I.Goo Throw New System.NotImplementedException() End Sub @@ -2328,6 +2385,7 @@ Interface I End Interface Class C Implements I + Public Sub Goo(Optional x As Char = ChrW(8220)) Implements I.Goo Throw New NotImplementedException() End Sub @@ -2351,6 +2409,7 @@ End Interface Class C Implements I + Public Sub Goo(Optional x As Object = ""‟"") Implements I.Goo Throw New System.NotImplementedException() End Sub @@ -2378,6 +2437,7 @@ End Interface Class C Implements I + Public Sub Goo(Optional x As Decimal = Decimal.MaxValue) Implements I.Goo Throw New NotImplementedException() End Sub @@ -2409,6 +2469,7 @@ Class C Implements I Property DayOfWeek As DayOfWeek + Public Sub Goo(Optional x As DayOfWeek = DayOfWeek.Monday) Implements I.Goo Throw New NotImplementedException() End Sub @@ -2436,6 +2497,7 @@ End Interface Class C Implements I + Public Sub Goo(Optional x As DayOfWeek? = DayOfWeek.Friday) Implements I.Goo Throw New NotImplementedException() End Sub @@ -2461,6 +2523,7 @@ End Interface Class C Implements I + Public Sub Goo(Optional x As Double = 2.8025969286496341E-45) Implements I.Goo Throw New NotImplementedException() End Sub @@ -2488,6 +2551,7 @@ End Interface Class C Implements I + Public Sub Goo(Optional x As Char = ChrW(55401)) Implements I.Goo Throw New NotImplementedException() End Sub @@ -2517,6 +2581,7 @@ End Interface Class C Implements I + Public Sub Goo(Optional x As Char = ChrW(13)) Implements I.Goo Throw New NotImplementedException() End Sub @@ -2544,6 +2609,7 @@ End Interface Class C Implements I + Public Sub Goo(Optional x As ConsoleColor = CType(-1, ConsoleColor)) Implements I.Goo Throw New NotImplementedException() End Sub @@ -2567,6 +2633,7 @@ End Interface Class C Implements I + Public Sub Goo(x As Integer?()) Implements I.Goo Throw New System.NotImplementedException() End Sub @@ -2590,6 +2657,7 @@ End Interface Class C Implements I + Public Sub Goo(Optional x() As Integer = Nothing) Implements I.Goo Throw New System.NotImplementedException() End Sub @@ -2625,6 +2693,7 @@ End Interface Class C Implements I + Public Sub Goo(Optional x As E = E.[Rem]) Implements I.Goo Throw New NotImplementedException() End Sub @@ -2648,6 +2717,7 @@ End Interface Class C Implements I + Public Sub Goo(Optional x As Byte = 1) Implements I.Goo Throw New System.NotImplementedException() End Sub @@ -2671,6 +2741,7 @@ End Interface Class C Implements I + Public Sub Goo(Optional x As Object = 1L) Implements I.Goo Throw New System.NotImplementedException() End Sub @@ -2702,6 +2773,7 @@ End Interface Class C Implements I + Public Sub Goo(Optional x As E = 0) Implements I.Goo Throw New System.NotImplementedException() End Sub @@ -2725,6 +2797,7 @@ End Interface Class C Implements I + Public Sub Goo(Optional x As Object = CByte(1)) Implements I.Goo Throw New System.NotImplementedException() End Sub @@ -2751,6 +2824,7 @@ Class C End Class .Value.Replace(vbLf, vbCrLf), Option Strict On + Interface I Sub M1(Optional x As Decimal = 2D) Sub M2(Optional x As Decimal = 2.0D) @@ -2804,12 +2878,14 @@ Class C Implements [|I|] End Class", "Option Strict On + Interface I Sub Goo(Optional x As Decimal = Long.MinValue) End Interface Class C Implements I + Public Sub Goo(Optional x As Decimal = -9223372036854775808D) Implements I.Goo Throw New System.NotImplementedException() End Sub @@ -2839,6 +2915,7 @@ Interface IB End Interface Class C Implements IB + Public Event E As Action Implements IB.E Private Event IA_E As EventHandler Implements IA.E End Class") @@ -2865,6 +2942,7 @@ End Interface Class C Implements I + Public Sub Goo(Optional x As Object = 1D) Implements I.Goo Throw New NotImplementedException() End Sub @@ -2892,6 +2970,7 @@ End Interface Class C Implements I + Public Sub Goo(Optional x As Object = 1R) Implements I.Goo Throw New NotImplementedException() End Sub @@ -2919,6 +2998,7 @@ End Interface Class C Implements I + Public Sub Goo(Optional x As Decimal = 10000000000000000000D) Implements I.Goo Throw New NotImplementedException() End Sub @@ -2940,6 +3020,7 @@ End Class", End Interface Class C Implements I + Public Sub Goo(Optional x As String = ""𪛖"") Implements I.Goo Throw New System.NotImplementedException() End Sub @@ -2967,6 +3048,7 @@ End Interface Class C Implements I + Public Sub Goo(Optional x As String = vbTab) Implements I.Goo Throw New NotImplementedException() End Sub @@ -2990,6 +3072,7 @@ End Interface Class C Implements I + Public Sub Goo(Of [TO], TP, TQ)() Implements I.Goo Throw New System.NotImplementedException() End Sub @@ -3017,6 +3100,7 @@ End Interface Class C Implements I + Public Sub Goo(Optional x As ULong = 10000000000000000000UL) Implements I.Goo Throw New NotImplementedException() End Sub @@ -3181,6 +3265,7 @@ End Class Class C : Implements [|IServiceProvider|] : End Class", "Imports System Class C : Implements IServiceProvider + Public Function GetService(serviceType As Type) As Object Implements IServiceProvider.GetService Throw New NotImplementedException() End Function @@ -3201,6 +3286,7 @@ MustInherit Class D MustOverride Sub Goo() End Class Class C : Inherits D : Implements IServiceProvider + Public Function GetService(serviceType As Type) As Object Implements IServiceProvider.GetService Throw New NotImplementedException() End Function @@ -3228,6 +3314,7 @@ End Interface Class C Implements I ' Implement + Public Sub Goo(Optional x As Object = CStr(ChrW(1))) Implements I.Goo Throw New NotImplementedException() End Sub @@ -3255,6 +3342,7 @@ End Interface Class C Implements I + Public Sub Goo(Optional x As String = ChrW(1)) Implements I.Goo Throw New NotImplementedException() End Sub @@ -3286,6 +3374,7 @@ Class C Implements I Public Sub ChrW(x As Integer) End Sub + Public Sub Goo(Optional x As String = Strings.ChrW(1)) Implements I.Goo Throw New NotImplementedException() End Sub @@ -3309,6 +3398,7 @@ End Interface Class C Implements I + Public Sub [REM]() Implements I.[REM] Throw New System.NotImplementedException() End Sub @@ -3364,6 +3454,7 @@ Interface I End Interface Class C Implements I ' Implement + Public Sub Goo(Of M)(Optional x As C(Of M()).E = C(Of M()).E.X) Implements I.Goo Throw New System.NotImplementedException() End Sub @@ -3397,6 +3488,7 @@ Interface I End Interface Class C Implements I + Public Sub Goo(Of T)(Optional x As C(Of T()).E = C(Of T()).E.X) Implements I.Goo Throw New System.NotImplementedException() End Sub @@ -3422,6 +3514,7 @@ End Interface Class C Implements I + Public Sub Goo(Optional x As Object = """"""""c) Implements I.Goo Throw New NotImplementedException() End Sub @@ -3457,6 +3550,7 @@ End Class Partial Class C Implements I + Public Sub M() Implements I.M Throw New System.NotImplementedException() End Sub @@ -3484,9 +3578,8 @@ End Interface Class C Implements I - Public Function Goo( - x As Boolean) As - Boolean Implements I.Goo + + Public Function Goo( x As Boolean) As Boolean Implements I.Goo Throw New System.NotImplementedException() End Function End Class") @@ -3509,6 +3602,7 @@ Interface I End Interface Class C Implements I ' Implement + Public Sub Goo(Optional x As Decimal = 1000000000000000000) Implements I.Goo Throw New System.NotImplementedException() End Sub @@ -3532,6 +3626,7 @@ End Interface MustInherit Class C Implements I ' Implement interface abstractly + Public Property Goo As Integer Implements I.Goo Get Throw New System.NotImplementedException() @@ -3560,6 +3655,7 @@ End Structure", End Interface Class c Implements I + Public ReadOnly Property g(Optional x As S? = Nothing) As Object Implements I.g Get Throw New System.NotImplementedException() @@ -3585,6 +3681,7 @@ End Class", End Interface Class c Implements I + Public ReadOnly Property g(Optional x As Long? = Nothing, Optional y As Long? = 5) As Object Implements I.g Get Throw New System.NotImplementedException() @@ -3645,6 +3742,7 @@ End Interface Class C Implements I + Public Property P( x As Integer) As Integer Implements I.P Get Throw New System.NotImplementedException() @@ -3675,6 +3773,7 @@ Partial Class C End Class Partial Class C Implements I + Public Sub Goo() Implements I.Goo Throw New System.NotImplementedException() End Sub @@ -3885,15 +3984,12 @@ Class C Implements I Default Public Property Prop(p As Long) As Integer Implements I.Prop - Get Throw New System.NotImplementedException() End Get - Set(value As Integer) Throw New System.NotImplementedException() End Set - End Property End Class") End Function @@ -4507,10 +4603,10 @@ Imports System interface I Function F() As ValueTuple(Of Object) end interface -class C +class C Implements I -Public Function F() As ValueTuple(Of Object) Implements I.F + Public Function F() As ValueTuple(Of Object) Implements I.F Throw New NotImplementedException() End Function end class diff --git a/src/EditorFeatures/VisualBasicTest/InitializeParameter/AddParameterCheckTests.vb b/src/EditorFeatures/VisualBasicTest/InitializeParameter/AddParameterCheckTests.vb index 601e2daa06bd9..6bd486c1b9681 100644 --- a/src/EditorFeatures/VisualBasicTest/InitializeParameter/AddParameterCheckTests.vb +++ b/src/EditorFeatures/VisualBasicTest/InitializeParameter/AddParameterCheckTests.vb @@ -107,7 +107,7 @@ end class", Imports System class C - private _s as string + private _s as string public sub new(s as string) If s Is Nothing Then diff --git a/src/EditorFeatures/VisualBasicTest/InitializeParameter/InitializeMemberFromParameterTests.vb b/src/EditorFeatures/VisualBasicTest/InitializeParameter/InitializeMemberFromParameterTests.vb index 7e1b57fe3813a..62ffa98ec135a 100644 --- a/src/EditorFeatures/VisualBasicTest/InitializeParameter/InitializeMemberFromParameterTests.vb +++ b/src/EditorFeatures/VisualBasicTest/InitializeParameter/InitializeMemberFromParameterTests.vb @@ -178,7 +178,6 @@ class C end class", " class C - private s As Integer public sub new(s As String) @@ -261,6 +260,7 @@ class C end class", " class C + private s As Integer public sub new([||]s As String) @@ -293,7 +293,7 @@ class C public sub new(s As String, t As String) Me.s = s - Me.t = t + Me.t = t end sub end class") End Function @@ -343,6 +343,7 @@ class C public sub new(s As String) if true then end if + Me.s = s end sub end class") @@ -377,7 +378,6 @@ class C end class", " class C - public sub new(s As String, t As String) Me.S = s Me.T = t @@ -402,10 +402,9 @@ class C end class", " class C - public sub new(s As String, t As String) Me.S = s - Me.T = t + Me.T = t end sub Public ReadOnly Property S As String diff --git a/src/EditorFeatures/VisualBasicTest/MoveDeclarationNearReference/MoveDeclarationNearReferenceTests.vb b/src/EditorFeatures/VisualBasicTest/MoveDeclarationNearReference/MoveDeclarationNearReferenceTests.vb index 6edf5cb6e90b7..eec1204444f46 100644 --- a/src/EditorFeatures/VisualBasicTest/MoveDeclarationNearReference/MoveDeclarationNearReferenceTests.vb +++ b/src/EditorFeatures/VisualBasicTest/MoveDeclarationNearReference/MoveDeclarationNearReferenceTests.vb @@ -71,8 +71,8 @@ end class") end class", "class C sub M() - Console.WriteLine() + dim x as integer if true Console.WriteLine(x) @@ -123,7 +123,8 @@ end class", "class C sub M() if true - dim x as integer = 5 + dim x as integer += 5 Console.WriteLine(x) end if end sub @@ -255,7 +256,7 @@ using System.Linq class Program sub M() for each (v in x) - {|Warning:dim i = CInt(0)|} + {|Warning:dim i = CInt(0)|} Console.Write(i) i = i + 1 next diff --git a/src/EditorFeatures/VisualBasicTest/OrderModifiers/OrderModifiersTests.vb b/src/EditorFeatures/VisualBasicTest/OrderModifiers/OrderModifiersTests.vb index b2bc68956de67..817f68f05f5a8 100644 --- a/src/EditorFeatures/VisualBasicTest/OrderModifiers/OrderModifiersTests.vb +++ b/src/EditorFeatures/VisualBasicTest/OrderModifiers/OrderModifiersTests.vb @@ -21,7 +21,8 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.OrderModifiers end class ", "protected friend class C -end class") +end class +") End Function @@ -30,8 +31,7 @@ end class") "[|friend|] protected structure C end structure", -" -protected friend structure C +"protected friend structure C end structure") End Function @@ -41,10 +41,8 @@ end structure") Await TestInRegularAndScript1Async( "[|friend|] protected interface C end interface", -" -protected friend interface C -end interface -") +"protected friend interface C +end interface") End Function @@ -52,8 +50,7 @@ end interface Await TestInRegularAndScript1Async( "[|friend|] protected enum C end enum", -" -protected friend enum C +"protected friend enum C end enum") End Function @@ -70,8 +67,7 @@ end enum") "class C [|mustoverride|] protected sub M() end class", -" -class C +"class C protected mustoverride sub M() end class") End Function @@ -83,8 +79,7 @@ end class") [|friend|] protected sub M() end sub end class", -" -class C +"class C protected friend sub M() end sub end class") @@ -96,8 +91,7 @@ end class") "class C [|friend|] protected dim a as integer end class", -" -class C +"class C protected friend dim a as integer end class") End Function @@ -109,8 +103,7 @@ end class") [|friend|] protected sub new() end sub end class", -" -class C +"class C protected friend sub new() end sub end class") @@ -122,8 +115,7 @@ end class") "class C [|readonly|] protected property P as integer end class", -" -class C +"class C protected readonly property P as integer end class") End Function @@ -137,8 +129,7 @@ end class") end get end property end class", -" -class C +"class C protected readonly property P as integer get end get @@ -172,9 +163,8 @@ end class [|friend|] protected custom event E as Action end event end class", -" -class C - protected friend custom event E as Action +"class C + protected friend custom event E as Action end event end class") End Function @@ -185,8 +175,7 @@ end class") "class C [|friend|] protected event E as Action end class", -" -class C +"class C protected friend event E as Action end class") End Function @@ -199,11 +188,11 @@ end class") end operator end class ", -" -class C +"class C public shared operator +(c1 as integer, c2 as integer) as integer end operator -end class") +end class +") End Function @@ -213,8 +202,7 @@ end class") [|shared|] public widening operator CType(x as integer) as boolean end operator end class", -" -class C +"class C public shared widening operator CType(x as integer) as boolean end operator end class") @@ -227,12 +215,10 @@ end class") friend protected class Nested end class end class", -" -protected friend class C +"protected friend class C protected friend class Nested end class -end class -") +end class") End Function @@ -243,8 +229,7 @@ end class end class end class ", -" -protected friend class C +"protected friend class C protected friend class Nested end class end class diff --git a/src/EditorFeatures/VisualBasicTest/RemoveUnnecessaryImports/RemoveUnnecessaryImportsTests.vb b/src/EditorFeatures/VisualBasicTest/RemoveUnnecessaryImports/RemoveUnnecessaryImportsTests.vb index 9107fe693d007..0dbe21eb6e48d 100644 --- a/src/EditorFeatures/VisualBasicTest/RemoveUnnecessaryImports/RemoveUnnecessaryImportsTests.vb +++ b/src/EditorFeatures/VisualBasicTest/RemoveUnnecessaryImports/RemoveUnnecessaryImportsTests.vb @@ -417,8 +417,7 @@ Namespace goo Class bar End Class End Namespace|]", -"Imports System, System.Collections.Generic -Module Program +"Imports System, System.Collections.Generic Module Program Sub Main(args As String()) Console.WriteLine(""TEST"") Dim q As List(Of Integer) @@ -516,7 +515,7 @@ Namespace B Public Class CB End Class End Namespace|]", -"Imports A +"Imports A _ Module Program Sub Main(args As String()) Dim q As CA diff --git a/src/EditorFeatures/VisualBasicTest/UseCoalesceExpression/UseCoalesceExpressionForNullableTests.vb b/src/EditorFeatures/VisualBasicTest/UseCoalesceExpression/UseCoalesceExpressionForNullableTests.vb index 63c39d7f49a1f..d9a2768e8ae8c 100644 --- a/src/EditorFeatures/VisualBasicTest/UseCoalesceExpression/UseCoalesceExpressionForNullableTests.vb +++ b/src/EditorFeatures/VisualBasicTest/UseCoalesceExpression/UseCoalesceExpressionForNullableTests.vb @@ -26,7 +26,8 @@ Class C Dim z = [||]If (Not x.HasValue, y, x.Value) End Sub End Class", -"Imports System +" +Imports System Class C Sub M(x as Integer?, y as Integer?) @@ -46,7 +47,8 @@ Class C Dim z = [||]If(x.HasValue, x.Value, y) End Sub End Class", -"Imports System +" +Imports System Class C Sub M(x as Integer?, y as Integer?) @@ -66,7 +68,8 @@ Class C Dim z = [||]If (Not (x + y).HasValue, y, (x + y).Value) End Sub End Class", -"Imports System +" +Imports System Class C Sub M(x as Integer?, y as Integer?) @@ -86,7 +89,8 @@ Class C Dim z = [||]If ((Not x.HasValue), y, x.Value) End Sub End Class", -"Imports System +" +Imports System Class C Sub M(x as Integer?, y as Integer?) @@ -107,7 +111,8 @@ Class C Dim z2 = If(x.HasValue, x.Value, y) End Sub End Class", -"Imports System +" +Imports System Class C Sub M(x as Integer?, y as Integer?) @@ -128,7 +133,8 @@ Class C dim w = {|FixAllInDocument:If|} (x.HasValue, x.Value, If(y.HasValue, y.Value, z)) End Sub End Class", -"Imports System +" +Imports System Class C Sub M(x as Integer?, y as Integer?, z as Integer?) @@ -156,7 +162,7 @@ Imports System.Linq.Expressions Class C Sub M(x as integer?, y as integer) - dim e as Expression(of Func(of integer)) = function() {|Warning:If (x, y)|} + dim e as Expression(of Func(of integer)) = function() {|Warning:If(x, y)|} End Sub End Class") End Function diff --git a/src/EditorFeatures/VisualBasicTest/UseCoalesceExpression/UseCoalesceExpressionTests.vb b/src/EditorFeatures/VisualBasicTest/UseCoalesceExpression/UseCoalesceExpressionTests.vb index 54ffdaaab4e9d..5f47a5ec750ef 100644 --- a/src/EditorFeatures/VisualBasicTest/UseCoalesceExpression/UseCoalesceExpressionTests.vb +++ b/src/EditorFeatures/VisualBasicTest/UseCoalesceExpression/UseCoalesceExpressionTests.vb @@ -26,7 +26,8 @@ Class C Dim z = [||]If (x Is Nothing, y, x) End Sub End Class", -"Imports System +" +Imports System Class C Sub M(x as string, y as string) @@ -46,7 +47,8 @@ Class C Dim z = [||]If(x IsNot Nothing, x, y) End Sub End Class", -"Imports System +" +Imports System Class C Sub M(x as string, y as string) @@ -66,7 +68,8 @@ Class C Dim z = [||]If(Nothing Is x, y, x) End Sub End Class", -"Imports System +" +Imports System Class C Sub M(x as string, y as string) @@ -86,7 +89,8 @@ Class C Dim z = [||]If(Nothing IsNot x, x, y) End Sub End Class", -"Imports System +" +Imports System Class C Sub M(x as string, y as string) @@ -106,7 +110,8 @@ Class C Dim z = [||]If (x.ToString() is Nothing, y, x.ToString()) End Sub End Class", -"Imports System +" +Imports System Class C Sub M(x as string, y as string) @@ -126,7 +131,8 @@ Class C Dim z = [||]If ((x Is Nothing), y, x) End Sub End Class", -"Imports System +" +Imports System Class C Sub M(x as string, y as string) @@ -146,7 +152,8 @@ Class C Dim z = [||]If ((x) Is Nothing, y, x) End Sub End Class", -"Imports System +" +Imports System Class C Sub M(x as string, y as string) @@ -166,7 +173,8 @@ Class C Dim z = [||]If (x Is Nothing, y, (x)) End Sub End Class", -"Imports System +" +Imports System Class C Sub M(x as string, y as string) @@ -186,7 +194,8 @@ Class C Dim z = [||]If (x Is Nothing, (y), x) End Sub End Class", -"Imports System +" +Imports System Class C Sub M(x as string, y as string) @@ -207,7 +216,8 @@ Class C Dim z2 = If(x IsNot Nothing, x, y) End Sub End Class", -"Imports System +" +Imports System Class C Sub M(x as string, y as string) @@ -228,7 +238,8 @@ Class C dim w = {|FixAllInDocument:If|} (x isnot Nothing, x, If(y isnot Nothing, y, z)) End Sub End Class", -"Imports System +" +Imports System Class C Sub M(x as string, y as string, z as string) @@ -256,7 +267,7 @@ Imports System.Linq.Expressions Class C Sub M(x as string, y as string) - dim e as Expression(of Func(of string)) = function() {|Warning:If (x, y)|} + dim e as Expression(of Func(of string)) = function() {|Warning:If(x, y)|} End Sub End Class") End Function diff --git a/src/EditorFeatures/VisualBasicTest/UseInferredMemberName/UseInferredMemberNameTests.vb b/src/EditorFeatures/VisualBasicTest/UseInferredMemberName/UseInferredMemberNameTests.vb index d8b520a61347a..0e17815f268aa 100644 --- a/src/EditorFeatures/VisualBasicTest/UseInferredMemberName/UseInferredMemberNameTests.vb +++ b/src/EditorFeatures/VisualBasicTest/UseInferredMemberName/UseInferredMemberNameTests.vb @@ -121,7 +121,7 @@ Class C Sub M() Dim a As Integer = 1 Dim b As Integer = 2 - Dim t = New With { a, b } + Dim t = New With {a, b} End Sub End Class ", parseOptions:=s_parseOptions) diff --git a/src/EditorFeatures/VisualBasicTest/UseObjectInitializer/UseObjectInitializerTests.vb b/src/EditorFeatures/VisualBasicTest/UseObjectInitializer/UseObjectInitializerTests.vb index 5435df79f770b..9017782248049 100644 --- a/src/EditorFeatures/VisualBasicTest/UseObjectInitializer/UseObjectInitializerTests.vb +++ b/src/EditorFeatures/VisualBasicTest/UseObjectInitializer/UseObjectInitializerTests.vb @@ -378,7 +378,8 @@ Class C } z.y = 2 End Sub -End Class") +End Class +") End Function End Class End Namespace diff --git a/src/EditorFeatures/VisualBasicTest/Utils.vb b/src/EditorFeatures/VisualBasicTest/Utils.vb index 41d90abf29468..93de3c784590e 100644 --- a/src/EditorFeatures/VisualBasicTest/Utils.vb +++ b/src/EditorFeatures/VisualBasicTest/Utils.vb @@ -327,7 +327,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests "End Structure" Case "File" - Return String.Join(vbCrLf, lines) + Return testSource.NormalizedValue Case Else Throw New ArgumentException("Unexpected testSource XML tag.", NameOf(testSource)) diff --git a/src/ExpressionEvaluator/CSharp/Test/ExpressionCompiler/LocalFunctionTests.cs b/src/ExpressionEvaluator/CSharp/Test/ExpressionCompiler/LocalFunctionTests.cs index c5789b3f98909..d87cbad50fb8d 100644 --- a/src/ExpressionEvaluator/CSharp/Test/ExpressionCompiler/LocalFunctionTests.cs +++ b/src/ExpressionEvaluator/CSharp/Test/ExpressionCompiler/LocalFunctionTests.cs @@ -123,7 +123,7 @@ int G() // Code size 7 (0x7) .maxstack 1 .locals init (int V_0) - IL_0000: ldarg.0 + IL_0000: ldarg.1 IL_0001: ldfld ""C C.<>c__DisplayClass1_0.<>4__this"" IL_0006: ret }"); @@ -132,7 +132,7 @@ .locals init (int V_0) // Code size 7 (0x7) .maxstack 1 .locals init (int V_0) - IL_0000: ldarg.0 + IL_0000: ldarg.1 IL_0001: ldfld ""int C.<>c__DisplayClass1_0.y"" IL_0006: ret }"); @@ -146,7 +146,7 @@ .locals init (int V_0) // Code size 13 (0xd) .maxstack 2 .locals init (int V_0) - IL_0000: ldarg.0 + IL_0000: ldarg.1 IL_0001: ldfld ""C C.<>c__DisplayClass1_0.<>4__this"" IL_0006: ldc.i4.1 IL_0007: callvirt ""void C.F(int)"" diff --git a/src/Features/CSharp/Portable/ReplaceMethodWithProperty/CSharpReplaceMethodWithPropertyService.cs b/src/Features/CSharp/Portable/ReplaceMethodWithProperty/CSharpReplaceMethodWithPropertyService.cs index 06fa7403dbf92..48904d61e352f 100644 --- a/src/Features/CSharp/Portable/ReplaceMethodWithProperty/CSharpReplaceMethodWithPropertyService.cs +++ b/src/Features/CSharp/Portable/ReplaceMethodWithProperty/CSharpReplaceMethodWithPropertyService.cs @@ -1,7 +1,6 @@ // Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Collections.Generic; using System.Composition; using System.Linq; using Microsoft.CodeAnalysis.CodeActions; @@ -20,9 +19,6 @@ namespace Microsoft.CodeAnalysis.CSharp.CodeRefactorings.ReplaceMethodWithProper [ExportLanguageService(typeof(IReplaceMethodWithPropertyService), LanguageNames.CSharp), Shared] internal class CSharpReplaceMethodWithPropertyService : AbstractReplaceMethodWithPropertyService, IReplaceMethodWithPropertyService { - public string GetMethodName(SyntaxNode methodNode) - => ((MethodDeclarationSyntax)methodNode).Identifier.ValueText; - public SyntaxNode GetMethodDeclaration(SyntaxToken token) { var containingMethod = token.Parent.FirstAncestorOrSelf(); @@ -64,11 +60,12 @@ public void RemoveSetMethod(SyntaxEditor editor, SyntaxNode setMethodDeclaration return; } - editor.ReplaceNode(getMethodDeclaration, - ConvertMethodsToProperty( - documentOptions, parseOptions, - semanticModel, editor.Generator, - getAndSetMethods, propertyName, nameChanged)); + var newProperty = ConvertMethodsToProperty( + documentOptions, parseOptions, + semanticModel, editor.Generator, + getAndSetMethods, propertyName, nameChanged); + + editor.ReplaceNode(getMethodDeclaration, newProperty); } public SyntaxNode ConvertMethodsToProperty( @@ -147,13 +144,8 @@ public void RemoveSetMethod(SyntaxEditor editor, SyntaxNode setMethodDeclaration getMethodDeclaration.ReturnType, getMethodDeclaration.ExplicitInterfaceSpecifier, nameToken, accessorList: null); - IEnumerable trivia = getMethodDeclaration.GetLeadingTrivia(); - var setMethodDeclaration = getAndSetMethods.SetMethodDeclaration; - if (setMethodDeclaration != null) - { - trivia = trivia.Concat(setMethodDeclaration.GetLeadingTrivia()); - } - property = property.WithLeadingTrivia(trivia.Where(t => !t.IsDirective)); + property = SetLeadingTrivia( + CSharpSyntaxFactsService.Instance, getAndSetMethods, property); var accessorList = SyntaxFactory.AccessorList(SyntaxFactory.SingletonList(getAccessor)); if (setAccessor != null) diff --git a/src/Features/Core/Portable/FindUsages/DefinitionItem.DocumentLocationDefinitionItem.cs b/src/Features/Core/Portable/FindUsages/DefinitionItem.DocumentLocationDefinitionItem.cs index af66937050176..205c4eaf0a3df 100644 --- a/src/Features/Core/Portable/FindUsages/DefinitionItem.DocumentLocationDefinitionItem.cs +++ b/src/Features/Core/Portable/FindUsages/DefinitionItem.DocumentLocationDefinitionItem.cs @@ -101,15 +101,13 @@ private bool TryNavigateToMetadataSymbol(Workspace workspace, string symbolKey) private (Project project, ISymbol symbol) TryResolveSymbolInCurrentSolution( Workspace workspace, string symbolKey) { - if (!this.Properties.TryGetValue(MetadataAssemblyIdentityDisplayName, out var identityDisplayName) || - !AssemblyIdentity.TryParseDisplayName(identityDisplayName, out var identity)) + if (!this.Properties.TryGetValue(MetadataSymbolOriginatingProjectIdGuid, out var projectIdGuid) || + !this.Properties.TryGetValue(MetadataSymbolOriginatingProjectIdDebugName, out var projectDebugName)) { return (null, null); } - var project = workspace.CurrentSolution - .ProjectsWithReferenceToAssembly(identity) - .FirstOrDefault(); + var project = workspace.CurrentSolution.GetProject(ProjectId.CreateFromSerialized(Guid.Parse(projectIdGuid), projectDebugName)); if (project == null) { diff --git a/src/Features/Core/Portable/FindUsages/DefinitionItem.cs b/src/Features/Core/Portable/FindUsages/DefinitionItem.cs index 25af0ed05f5f3..740e8a67d2eac 100644 --- a/src/Features/Core/Portable/FindUsages/DefinitionItem.cs +++ b/src/Features/Core/Portable/FindUsages/DefinitionItem.cs @@ -30,11 +30,11 @@ internal abstract partial class DefinitionItem /// For metadata symbols we encode information in the so we can /// retrieve the symbol later on when navigating. This is needed so that we can go to /// metadata-as-source for metadata symbols. We need to store the - /// for the symbol and the name we get back from - /// for. With these we can effetively recover the symbol. + /// for the symbol and the project ID that originated the symbol. With these we can correctly recover the symbol. /// private const string MetadataSymbolKey = nameof(MetadataSymbolKey); - private const string MetadataAssemblyIdentityDisplayName = nameof(MetadataAssemblyIdentityDisplayName); + private const string MetadataSymbolOriginatingProjectIdGuid = nameof(MetadataSymbolOriginatingProjectIdGuid); + private const string MetadataSymbolOriginatingProjectIdDebugName = nameof(MetadataSymbolOriginatingProjectIdDebugName); /// /// If this item is something that cannot be navigated to. We store this in our @@ -111,7 +111,8 @@ internal abstract partial class DefinitionItem if (Properties.ContainsKey(MetadataSymbolKey)) { - Contract.ThrowIfFalse(Properties.ContainsKey(MetadataAssemblyIdentityDisplayName)); + Contract.ThrowIfFalse(Properties.ContainsKey(MetadataSymbolOriginatingProjectIdGuid)); + Contract.ThrowIfFalse(Properties.ContainsKey(MetadataSymbolOriginatingProjectIdDebugName)); } } @@ -169,17 +170,18 @@ internal abstract partial class DefinitionItem ImmutableArray tags, ImmutableArray displayParts, ImmutableArray nameDisplayParts, - Solution solution, ISymbol symbol, + Project project, + ISymbol symbol, ImmutableDictionary properties = null, bool displayIfNoReferences = true) { properties = properties ?? ImmutableDictionary.Empty; var symbolKey = symbol.GetSymbolKey().ToString(); - var assemblyIdentityDisplayName = symbol.ContainingAssembly?.Identity.GetDisplayName(); properties = properties.Add(MetadataSymbolKey, symbolKey) - .Add(MetadataAssemblyIdentityDisplayName, assemblyIdentityDisplayName); + .Add(MetadataSymbolOriginatingProjectIdGuid, project.Id.Id.ToString()) + .Add(MetadataSymbolOriginatingProjectIdDebugName, project.Id.DebugName); var originationParts = GetOriginationParts(symbol); return new DefaultDefinitionItem( diff --git a/src/Features/Core/Portable/Navigation/DefaultSymbolNavigationService.cs b/src/Features/Core/Portable/Navigation/DefaultSymbolNavigationService.cs index 418e2a4731ade..9c9d1cb902905 100644 --- a/src/Features/Core/Portable/Navigation/DefaultSymbolNavigationService.cs +++ b/src/Features/Core/Portable/Navigation/DefaultSymbolNavigationService.cs @@ -11,7 +11,7 @@ internal class DefaultSymbolNavigationService : ISymbolNavigationService public bool TryNavigateToSymbol(ISymbol symbol, Project project, OptionSet options = null, CancellationToken cancellationToken = default) => false; - public bool TrySymbolNavigationNotify(ISymbol symbol, Solution solution, CancellationToken cancellationToken) + public bool TrySymbolNavigationNotify(ISymbol symbol, Project project, CancellationToken cancellationToken) => false; public bool WouldNavigateToSymbol( diff --git a/src/Features/Core/Portable/Navigation/ISymbolNavigationService.cs b/src/Features/Core/Portable/Navigation/ISymbolNavigationService.cs index 4537374314670..658de752dfc68 100644 --- a/src/Features/Core/Portable/Navigation/ISymbolNavigationService.cs +++ b/src/Features/Core/Portable/Navigation/ISymbolNavigationService.cs @@ -22,7 +22,7 @@ internal interface ISymbolNavigationService : IWorkspaceService /// True if the navigation was handled, indicating that the caller should not /// perform the navigation. - bool TrySymbolNavigationNotify(ISymbol symbol, Solution solution, CancellationToken cancellationToken); + bool TrySymbolNavigationNotify(ISymbol symbol, Project project, CancellationToken cancellationToken); /// True if the navigation would be handled. bool WouldNavigateToSymbol( diff --git a/src/Features/Core/Portable/ReplaceMethodWithProperty/AbstractReplaceMethodWithPropertyService.cs b/src/Features/Core/Portable/ReplaceMethodWithProperty/AbstractReplaceMethodWithPropertyService.cs index d1a348e00b95b..d882d4b50e31f 100644 --- a/src/Features/Core/Portable/ReplaceMethodWithProperty/AbstractReplaceMethodWithPropertyService.cs +++ b/src/Features/Core/Portable/ReplaceMethodWithProperty/AbstractReplaceMethodWithPropertyService.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Linq; +using Microsoft.CodeAnalysis.LanguageServices; namespace Microsoft.CodeAnalysis.ReplaceMethodWithProperty { @@ -29,5 +30,25 @@ private static bool OverridesMetadataSymbol(IMethodSymbol method) return false; } + + protected static TPropertyDeclaration SetLeadingTrivia( + ISyntaxFactsService syntaxFacts, GetAndSetMethods getAndSetMethods, TPropertyDeclaration property) where TPropertyDeclaration : SyntaxNode + { + var getMethodDeclaration = getAndSetMethods.GetMethodDeclaration; + var setMethodDeclaration = getAndSetMethods.SetMethodDeclaration; + if (setMethodDeclaration == null) + { + return property.WithLeadingTrivia(getMethodDeclaration.GetLeadingTrivia()); + } + + var finalLeadingTrivia = getAndSetMethods.GetMethodDeclaration.GetLeadingTrivia().ToList(); + + finalLeadingTrivia.AddRange( + setMethodDeclaration.GetLeadingTrivia() + .SkipWhile(t => syntaxFacts.IsEndOfLineTrivia(t)) + .Where(t => !t.IsDirective)); + + return property.WithLeadingTrivia(finalLeadingTrivia); + } } } diff --git a/src/Features/Core/Portable/ReplaceMethodWithProperty/IReplaceMethodWithPropertyService.cs b/src/Features/Core/Portable/ReplaceMethodWithProperty/IReplaceMethodWithPropertyService.cs index 251c6269a7816..a7d2933f3b314 100644 --- a/src/Features/Core/Portable/ReplaceMethodWithProperty/IReplaceMethodWithPropertyService.cs +++ b/src/Features/Core/Portable/ReplaceMethodWithProperty/IReplaceMethodWithPropertyService.cs @@ -9,7 +9,6 @@ namespace Microsoft.CodeAnalysis.ReplaceMethodWithProperty internal interface IReplaceMethodWithPropertyService : ILanguageService { SyntaxNode GetMethodDeclaration(SyntaxToken token); - string GetMethodName(SyntaxNode methodDeclaration); void ReplaceGetReference(SyntaxEditor editor, SyntaxToken nameToken, string propertyName, bool nameChanged); void ReplaceSetReference(SyntaxEditor editor, SyntaxToken nameToken, string propertyName, bool nameChanged); diff --git a/src/Features/Core/Portable/ReplaceMethodWithProperty/ReplaceMethodWithPropertyCodeRefactoringProvider.cs b/src/Features/Core/Portable/ReplaceMethodWithProperty/ReplaceMethodWithPropertyCodeRefactoringProvider.cs index bdbca17c7cfe7..e1fa0f85970e6 100644 --- a/src/Features/Core/Portable/ReplaceMethodWithProperty/ReplaceMethodWithPropertyCodeRefactoringProvider.cs +++ b/src/Features/Core/Portable/ReplaceMethodWithProperty/ReplaceMethodWithPropertyCodeRefactoringProvider.cs @@ -50,7 +50,8 @@ public override async Task ComputeRefactoringsAsync(CodeRefactoringContext conte // Ok, we're in the signature of the method. Now see if the method is viable to be // replaced with a property. - var methodName = service.GetMethodName(methodDeclaration); + var generator = SyntaxGenerator.GetGenerator(document); + var methodName = generator.GetName(methodDeclaration); var semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false); var methodSymbol = semanticModel.GetDeclaredSymbol(methodDeclaration) as IMethodSymbol; diff --git a/src/Features/VisualBasic/Portable/ReplaceMethodWithProperty/VisualBasicReplaceMethodWithPropertyService.vb b/src/Features/VisualBasic/Portable/ReplaceMethodWithProperty/VisualBasicReplaceMethodWithPropertyService.vb index 4a7cc8bbffda2..2f175f6abfdff 100644 --- a/src/Features/VisualBasic/Portable/ReplaceMethodWithProperty/VisualBasicReplaceMethodWithPropertyService.vb +++ b/src/Features/VisualBasic/Portable/ReplaceMethodWithProperty/VisualBasicReplaceMethodWithPropertyService.vb @@ -15,10 +15,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.CodeRefactorings.ReplaceMethodWithP Inherits AbstractReplaceMethodWithPropertyService Implements IReplaceMethodWithPropertyService - Public Function GetMethodName(methodNode As SyntaxNode) As String Implements IReplaceMethodWithPropertyService.GetMethodName - Return DirectCast(methodNode, MethodStatementSyntax).Identifier.ValueText - End Function - Public Function GetMethodDeclaration(token As SyntaxToken) As SyntaxNode Implements IReplaceMethodWithPropertyService.GetMethodDeclaration Dim containingMethod = token.Parent.FirstAncestorOrSelf(Of MethodStatementSyntax) If containingMethod Is Nothing Then @@ -153,12 +149,8 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.CodeRefactorings.ReplaceMethodWithP End If End If - Dim trivia As IEnumerable(Of SyntaxTrivia) = getMethodStatement.GetLeadingTrivia() - If setMethodStatement IsNot Nothing Then - trivia = trivia.Concat(setMethodStatement.GetLeadingTrivia()) - End If - - newPropertyDeclaration = newPropertyDeclaration.WithLeadingTrivia(trivia) + newPropertyDeclaration = SetLeadingTrivia( + VisualBasicSyntaxFactsService.Instance, getAndSetMethods, newPropertyDeclaration) Return newPropertyDeclaration.WithAdditionalAnnotations(Formatter.Annotation) End Function diff --git a/src/Setup/DevDivPackages/Debugger/DevDivPackagesDebugger.csproj b/src/Setup/DevDivPackages/Debugger/DevDivPackagesDebugger.csproj index 149b2c835773f..6553dcdc6fce7 100644 --- a/src/Setup/DevDivPackages/Debugger/DevDivPackagesDebugger.csproj +++ b/src/Setup/DevDivPackages/Debugger/DevDivPackagesDebugger.csproj @@ -46,6 +46,9 @@ $(SystemRuntimeInteropServicesRuntimeInformationVersion) + + $(SystemRuntimeSerializationPrimitivesVersion) + $(SystemSecurityCryptographyX509CertificatesVersion) diff --git a/src/Setup/DevDivPackages/Roslyn/DevDivPackagesRoslyn.csproj b/src/Setup/DevDivPackages/Roslyn/DevDivPackagesRoslyn.csproj index 888007be7ef7d..791b0b56505e6 100644 --- a/src/Setup/DevDivPackages/Roslyn/DevDivPackagesRoslyn.csproj +++ b/src/Setup/DevDivPackages/Roslyn/DevDivPackagesRoslyn.csproj @@ -25,9 +25,6 @@ $(MicrosoftDiaSymReaderVersion) - - $(MicrosoftDiaSymReaderNativeVersion) - $(MicrosoftCodeAnalysisElfieVersion) @@ -85,6 +82,9 @@ $(SystemSecurityCryptographyAlgorithmsVersion) + + $(SystemSecurityCryptographyCspVersion) + $(SystemSecurityCryptographyEncodingVersion) diff --git a/src/Setup/DevDivVsix/PortableFacades/PortableFacades.swr b/src/Setup/DevDivVsix/PortableFacades/PortableFacades.swr index 6c599270e010d..3f28efbc6ab07 100644 --- a/src/Setup/DevDivVsix/PortableFacades/PortableFacades.swr +++ b/src/Setup/DevDivVsix/PortableFacades/PortableFacades.swr @@ -1,7 +1,7 @@ use vs package name=PortableFacades - version=1.4.0.0 + version=1.5.0.0 folder InstallDir:\Common7\IDE\PrivateAssemblies file source="$(NuGetPackageRoot)\System.AppContext\4.3.0\lib\net46\System.AppContext.dll" vs.file.ngen=yes @@ -16,9 +16,11 @@ folder InstallDir:\Common7\IDE\PrivateAssemblies file source="$(NuGetPackageRoot)\System.Net.Security\4.3.0\runtimes\win\lib\net46\System.Net.Security.dll" vs.file.ngen=yes file source="$(NuGetPackageRoot)\System.Net.Sockets\4.3.0\lib\net46\System.Net.Sockets.dll" vs.file.ngen=yes file source="$(NuGetPackageRoot)\System.Reflection.TypeExtensions\4.3.0\lib\net46\System.Reflection.TypeExtensions.dll" vs.file.ngen=yes + file source="$(NuGetPackageRoot)\System.Runtime.Serialization.Primitives\4.3.0\lib\net46\System.Runtime.Serialization.Primitives.dll" vs.file.ngen=yes file source="$(NuGetPackageRoot)\System.Security.AccessControl\4.3.0\runtimes\win\lib\net46\System.Security.AccessControl.dll" vs.file.ngen=yes file source="$(NuGetPackageRoot)\System.Security.Claims\4.3.0\lib\net46\System.Security.Claims.dll" vs.file.ngen=yes file source="$(NuGetPackageRoot)\System.Security.Cryptography.Algorithms\4.3.0\runtimes\win\lib\net46\System.Security.Cryptography.Algorithms.dll" vs.file.ngen=yes + file source="$(NuGetPackageRoot)\System.Security.Cryptography.Csp\4.3.0\runtimes\win\lib\net46\System.Security.Cryptography.Csp.dll" vs.file.ngen=yes file source="$(NuGetPackageRoot)\System.Security.Cryptography.Encoding\4.3.0\runtimes\win\lib\net46\System.Security.Cryptography.Encoding.dll" vs.file.ngen=yes file source="$(NuGetPackageRoot)\System.Security.Cryptography.Primitives\4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll" vs.file.ngen=yes file source="$(NuGetPackageRoot)\System.Security.Cryptography.X509Certificates\4.3.0\runtimes\win\lib\net46\System.Security.Cryptography.X509Certificates.dll" vs.file.ngen=yes diff --git a/src/Test/PdbUtilities/Pdb/PdbValidation.cs b/src/Test/PdbUtilities/Pdb/PdbValidation.cs index 802c163c2f098..b39b14f9240eb 100644 --- a/src/Test/PdbUtilities/Pdb/PdbValidation.cs +++ b/src/Test/PdbUtilities/Pdb/PdbValidation.cs @@ -30,26 +30,28 @@ public static class PdbValidation public static CompilationVerifier VerifyPdb( this CompilationVerifier verifier, XElement expectedPdb, + IEnumerable embeddedTexts = null, IMethodSymbol debugEntryPoint = null, DebugInformationFormat format = 0, PdbToXmlOptions options = 0, [CallerLineNumber]int expectedValueSourceLine = 0, [CallerFilePath]string expectedValueSourcePath = null) { - verifier.Compilation.VerifyPdb(expectedPdb, debugEntryPoint, format, options, expectedValueSourceLine, expectedValueSourcePath); + verifier.Compilation.VerifyPdb(expectedPdb, embeddedTexts, debugEntryPoint, format, options, expectedValueSourceLine, expectedValueSourcePath); return verifier; } public static CompilationVerifier VerifyPdb( this CompilationVerifier verifier, string expectedPdb, + IEnumerable embeddedTexts = null, IMethodSymbol debugEntryPoint = null, DebugInformationFormat format = 0, PdbToXmlOptions options = 0, [CallerLineNumber]int expectedValueSourceLine = 0, [CallerFilePath]string expectedValueSourcePath = null) { - verifier.Compilation.VerifyPdb(expectedPdb, debugEntryPoint, format, options, expectedValueSourceLine, expectedValueSourcePath); + verifier.Compilation.VerifyPdb(expectedPdb, embeddedTexts, debugEntryPoint, format, options, expectedValueSourceLine, expectedValueSourcePath); return verifier; } @@ -57,13 +59,14 @@ public static class PdbValidation this CompilationVerifier verifier, string qualifiedMethodName, string expectedPdb, + IEnumerable embeddedTexts = null, IMethodSymbol debugEntryPoint = null, DebugInformationFormat format = 0, PdbToXmlOptions options = 0, [CallerLineNumber]int expectedValueSourceLine = 0, [CallerFilePath]string expectedValueSourcePath = null) { - verifier.Compilation.VerifyPdb(qualifiedMethodName, expectedPdb, debugEntryPoint, format, options, expectedValueSourceLine, expectedValueSourcePath); + verifier.Compilation.VerifyPdb(qualifiedMethodName, expectedPdb, embeddedTexts, debugEntryPoint, format, options, expectedValueSourceLine, expectedValueSourcePath); return verifier; } @@ -71,13 +74,14 @@ public static class PdbValidation this CompilationVerifier verifier, string qualifiedMethodName, XElement expectedPdb, + IEnumerable embeddedTexts = null, IMethodSymbol debugEntryPoint = null, DebugInformationFormat format = 0, PdbToXmlOptions options = 0, [CallerLineNumber]int expectedValueSourceLine = 0, [CallerFilePath]string expectedValueSourcePath = null) { - verifier.Compilation.VerifyPdb(qualifiedMethodName, expectedPdb, debugEntryPoint, format, options, expectedValueSourceLine, expectedValueSourcePath); + verifier.Compilation.VerifyPdb(qualifiedMethodName, expectedPdb, embeddedTexts, debugEntryPoint, format, options, expectedValueSourceLine, expectedValueSourcePath); return verifier; } @@ -134,19 +138,21 @@ public static void VerifyPdb(this CompilationDifference diff, IEnumerable embeddedTexts = null, IMethodSymbol debugEntryPoint = null, DebugInformationFormat format = 0, PdbToXmlOptions options = 0, [CallerLineNumber]int expectedValueSourceLine = 0, [CallerFilePath]string expectedValueSourcePath = null) { - VerifyPdb(compilation, "", expectedPdb, debugEntryPoint, format, options, expectedValueSourceLine, expectedValueSourcePath); + VerifyPdb(compilation, "", expectedPdb, embeddedTexts, debugEntryPoint, format, options, expectedValueSourceLine, expectedValueSourcePath); } public static void VerifyPdb( this Compilation compilation, string qualifiedMethodName, string expectedPdb, + IEnumerable embeddedTexts = null, IMethodSymbol debugEntryPoint = null, DebugInformationFormat format = 0, PdbToXmlOptions options = 0, @@ -155,6 +161,7 @@ public static void VerifyPdb(this CompilationDifference diff, IEnumerable" : expectedPdb, @@ -168,19 +175,21 @@ public static void VerifyPdb(this CompilationDifference diff, IEnumerable embeddedTexts = null, IMethodSymbol debugEntryPoint = null, DebugInformationFormat format = 0, PdbToXmlOptions options = 0, [CallerLineNumber]int expectedValueSourceLine = 0, [CallerFilePath]string expectedValueSourcePath = null) { - VerifyPdb(compilation, "", expectedPdb, debugEntryPoint, format, options, expectedValueSourceLine, expectedValueSourcePath); + VerifyPdb(compilation, "", expectedPdb, embeddedTexts, debugEntryPoint, format, options, expectedValueSourceLine, expectedValueSourcePath); } public static void VerifyPdb( this Compilation compilation, string qualifiedMethodName, XElement expectedPdb, + IEnumerable embeddedTexts = null, IMethodSymbol debugEntryPoint = null, DebugInformationFormat format = 0, PdbToXmlOptions options = 0, @@ -189,6 +198,7 @@ public static void VerifyPdb(this CompilationDifference diff, IEnumerable embeddedTexts, IMethodSymbol debugEntryPoint, string qualifiedMethodName, string expectedPdb, @@ -214,18 +225,18 @@ public static void VerifyPdb(this CompilationDifference diff, IEnumerable embeddedTexts = null, IMethodSymbol debugEntryPoint = null, PdbToXmlOptions options = 0, string qualifiedMethodName = "", @@ -352,14 +364,15 @@ private static void RemoveFormatAttributes(XElement pdb) exebits, pdbbits, debugEntryPoint: debugEntryPoint, - options: EmitOptions.Default.WithDebugInformationFormat(portable ? DebugInformationFormat.PortablePdb : DebugInformationFormat.Pdb)); + options: EmitOptions.Default.WithDebugInformationFormat(portable ? DebugInformationFormat.PortablePdb : DebugInformationFormat.Pdb), + embeddedTexts: embeddedTexts); result.Diagnostics.Where(d => d.Severity == DiagnosticSeverity.Error).Verify(); pdbbits.Position = 0; exebits.Position = 0; - options |= PdbToXmlOptions.ResolveTokens | PdbToXmlOptions.ThrowOnError; + options |= PdbToXmlOptions.ResolveTokens | PdbToXmlOptions.IncludeEmbeddedSources | PdbToXmlOptions.ThrowOnError; actual = PdbToXmlConverter.ToXml(pdbbits, exebits, options, methodName: qualifiedMethodName); ValidateDebugDirectory(exebits, portable ? pdbbits : null, compilation.AssemblyName + ".pdb", compilation.IsEmitDeterministic); @@ -388,7 +401,7 @@ public unsafe static byte[] GetSourceLinkData(Stream pdbStream) } finally { - ((ISymUnmanagedDispose)symReader).Destroy(); + symReader.Dispose(); } } diff --git a/src/Test/PdbUtilities/Pdb/SymReaderFactory.cs b/src/Test/PdbUtilities/Pdb/SymReaderFactory.cs index 2502719b6dbe4..6b65823c6882b 100644 --- a/src/Test/PdbUtilities/Pdb/SymReaderFactory.cs +++ b/src/Test/PdbUtilities/Pdb/SymReaderFactory.cs @@ -15,6 +15,9 @@ namespace Roslyn.Test.PdbUtilities { public static class SymReaderFactory { + public static void Dispose(this ISymUnmanagedReader symReader) + => ((ISymUnmanagedDispose)symReader)?.Destroy(); + [DefaultDllImportSearchPaths(DllImportSearchPath.AssemblyDirectory | DllImportSearchPath.SafeDirectories)] [DllImport("Microsoft.DiaSymReader.Native.x86.dll", EntryPoint = "CreateSymReader")] private extern static void CreateSymReader32(ref Guid id, [MarshalAs(UnmanagedType.IUnknown)]out object symReader); diff --git a/src/Test/Utilities/Portable/Assert/AssertEx.cs b/src/Test/Utilities/Portable/Assert/AssertEx.cs index e22220d9978b5..62bf96ab024af 100644 --- a/src/Test/Utilities/Portable/Assert/AssertEx.cs +++ b/src/Test/Utilities/Portable/Assert/AssertEx.cs @@ -181,33 +181,38 @@ public static void Equal(ImmutableArray expected, ImmutableArray actual Equal(expected, (IEnumerable)actual, comparer, message, itemSeparator); } - public static void Equal(IEnumerable expected, IEnumerable actual, IEqualityComparer comparer = null, string message = null, - string itemSeparator = null, Func itemInspector = null) + public static void Equal( + IEnumerable expected, + IEnumerable actual, + IEqualityComparer comparer = null, + string message = null, + string itemSeparator = null, + Func itemInspector = null, + string expectedValueSourcePath = null, + int expectedValueSourceLine = 0) { - if (ReferenceEquals(expected, actual)) - { - return; - } - if (expected == null) { - Fail("expected was null, but actual wasn't\r\n" + message); + Assert.Null(actual); } - else if (actual == null) + else { - Fail("actual was null, but expected wasn't\r\n" + message); + Assert.NotNull(actual); } - else if (!SequenceEqual(expected, actual, comparer)) + + if (SequenceEqual(expected, actual, comparer)) { - string assertMessage = GetAssertMessage(expected, actual, comparer, itemInspector, itemSeparator); + return; + } - if (message != null) - { - assertMessage = message + "\r\n" + assertMessage; - } + string assertMessage = GetAssertMessage(expected, actual, comparer, itemInspector, itemSeparator, expectedValueSourcePath, expectedValueSourceLine); - Assert.True(false, assertMessage); + if (message != null) + { + assertMessage = message + "\r\n" + assertMessage; } + + Assert.True(false, assertMessage); } public static void NotEqual(IEnumerable expected, IEnumerable actual, IEqualityComparer comparer = null, string message = null, @@ -230,6 +235,11 @@ public static void Equal(ImmutableArray expected, ImmutableArray actual private static bool SequenceEqual(IEnumerable expected, IEnumerable actual, IEqualityComparer comparer = null) { + if (ReferenceEquals(expected, actual)) + { + return true; + } + var enumerator1 = expected.GetEnumerator(); var enumerator2 = actual.GetEnumerator(); @@ -260,20 +270,18 @@ private static bool SequenceEqual(IEnumerable expected, IEnumerable act return true; } - public static void SetEqual( - IEnumerable expected, - IEnumerable actual, - IEqualityComparer comparer = null, - string message = "", - string itemSeparator = "\r\n") + public static void SetEqual(IEnumerable expected, IEnumerable actual, IEqualityComparer comparer = null, string message = null, string itemSeparator = "\r\n") { var expectedSet = new HashSet(expected, comparer); var result = expected.Count() == actual.Count() && expectedSet.SetEquals(actual); if (!result) { - message += GetAssertMessage( - ToString(expected, itemSeparator), - ToString(actual, itemSeparator)); + if (string.IsNullOrEmpty(message)) + { + message = GetAssertMessage( + ToString(expected, itemSeparator), + ToString(actual, itemSeparator)); + } Assert.True(result, message); } @@ -450,10 +458,6 @@ public static string GetAssertMessage(IEnumerable expected, IEnumerable { itemInspector = b => $"0x{b:X2}"; } - else if (expected is IEnumerable) - { - itemInspector = new Func(obj => (obj != null) ? string.Format("\"{0}\"", obj.ToString()) : ""); - } else { itemInspector = new Func(obj => (obj != null) ? obj.ToString() : ""); @@ -533,5 +537,29 @@ public static void Empty(IEnumerable items, string message = "") Fail($"Expected 0 items but found {list.Count}: {message}\r\nItems:\r\n {string.Join("\r\n ", list)}"); } } + + private sealed class LineComparer : IEqualityComparer + { + public static readonly LineComparer Instance = new LineComparer(); + + public bool Equals(string left, string right) => left.Trim() == right.Trim(); + public int GetHashCode(string str) => str.Trim().GetHashCode(); + } + + public static void AssertLinesEqual(string expected, string actual, string message, string expectedValueSourcePath, int expectedValueSourceLine, bool escapeQuotes) + { + IEnumerable GetLines(string str) => + str.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); + + AssertEx.Equal( + GetLines(expected), + GetLines(actual), + comparer: LineComparer.Instance, + message: message, + itemInspector: escapeQuotes ? new Func(line => line.Replace("\"", "\"\"")) : null, + itemSeparator: Environment.NewLine, + expectedValueSourcePath: expectedValueSourcePath, + expectedValueSourceLine: expectedValueSourceLine); + } } } diff --git a/src/Test/Utilities/Portable/Compilation/CompilationExtensions.cs b/src/Test/Utilities/Portable/Compilation/CompilationExtensions.cs index c6d10600653a7..32d247b081b58 100644 --- a/src/Test/Utilities/Portable/Compilation/CompilationExtensions.cs +++ b/src/Test/Utilities/Portable/Compilation/CompilationExtensions.cs @@ -13,7 +13,6 @@ using Microsoft.CodeAnalysis.CodeGen; using Microsoft.CodeAnalysis.Emit; using Microsoft.CodeAnalysis.Test.Extensions; -using Roslyn.Test.PdbUtilities; using Roslyn.Test.Utilities; using Roslyn.Utilities; using Xunit; diff --git a/src/Test/Utilities/Portable/Diagnostics/CouldHaveMoreSpecificTypeAnalyzer.cs b/src/Test/Utilities/Portable/Diagnostics/CouldHaveMoreSpecificTypeAnalyzer.cs index af597867dd823..66862cd347c60 100644 --- a/src/Test/Utilities/Portable/Diagnostics/CouldHaveMoreSpecificTypeAnalyzer.cs +++ b/src/Test/Utilities/Portable/Diagnostics/CouldHaveMoreSpecificTypeAnalyzer.cs @@ -61,11 +61,11 @@ public sealed override void Initialize(AnalysisContext context) } else if (operationContext.Operation is IIncrementExpression increment) { - string text = increment.Syntax.ToString(); SyntaxNode syntax = increment.Syntax; ITypeSymbol type = increment.Type; Optional constantValue = new Optional(1); - var value = new LiteralExpression(operationContext.Compilation.GetSemanticModel(syntax.SyntaxTree), syntax, type, constantValue); + bool isImplicit = increment.IsImplicit; + var value = new LiteralExpression(operationContext.Compilation.GetSemanticModel(syntax.SyntaxTree), syntax, type, constantValue, isImplicit); AssignTo(increment.Target, localsSourceTypes, fieldsSourceTypes, value); } diff --git a/src/Test/Utilities/Portable/Diagnostics/OperationTestAnalyzer.cs b/src/Test/Utilities/Portable/Diagnostics/OperationTestAnalyzer.cs index fc7f7b942a0da..2f989b7e684f3 100644 --- a/src/Test/Utilities/Portable/Diagnostics/OperationTestAnalyzer.cs +++ b/src/Test/Utilities/Portable/Diagnostics/OperationTestAnalyzer.cs @@ -286,8 +286,7 @@ private static ILiteralExpression CreateIncrementOneLiteralExpression(SemanticMo SyntaxNode syntax = increment.Syntax; ITypeSymbol type = increment.Type; Optional constantValue = new Optional(1); - - return new LiteralExpression(semanticModel, syntax, type, constantValue); + return new LiteralExpression(semanticModel, syntax, type, constantValue, increment.IsImplicit); } private static int Abs(int value) diff --git a/src/VisualStudio/Core/Def/Implementation/Progression/GraphNavigatorExtension.cs b/src/VisualStudio/Core/Def/Implementation/Progression/GraphNavigatorExtension.cs index 90be125936b12..542eadf8304d8 100644 --- a/src/VisualStudio/Core/Def/Implementation/Progression/GraphNavigatorExtension.cs +++ b/src/VisualStudio/Core/Def/Implementation/Progression/GraphNavigatorExtension.cs @@ -96,7 +96,7 @@ public void NavigateTo(GraphObject graphObject) if (symbol != null && !(symbol is ITypeSymbol) && !symbol.IsConstructor() && - symbolNavigationService.TrySymbolNavigationNotify(symbol, project.Solution, CancellationToken.None)) + symbolNavigationService.TrySymbolNavigationNotify(symbol, project, CancellationToken.None)) { return; } diff --git a/src/VisualStudio/Core/Def/Implementation/Workspace/VisualStudioSymbolNavigationService.cs b/src/VisualStudio/Core/Def/Implementation/Workspace/VisualStudioSymbolNavigationService.cs index cb37b08a1f26a..ad059af44e34b 100644 --- a/src/VisualStudio/Core/Def/Implementation/Workspace/VisualStudioSymbolNavigationService.cs +++ b/src/VisualStudio/Core/Def/Implementation/Workspace/VisualStudioSymbolNavigationService.cs @@ -149,21 +149,21 @@ public bool TryNavigateToSymbol(ISymbol symbol, Project project, OptionSet optio return true; } - public bool TrySymbolNavigationNotify(ISymbol symbol, Solution solution, CancellationToken cancellationToken) + public bool TrySymbolNavigationNotify(ISymbol symbol, Project project, CancellationToken cancellationToken) { - return TryNotifyForSpecificSymbol(symbol, solution, cancellationToken); + return TryNotifyForSpecificSymbol(symbol, project, cancellationToken); } private bool TryNotifyForSpecificSymbol( - ISymbol symbol, Solution solution, CancellationToken cancellationToken) + ISymbol symbol, Project project, CancellationToken cancellationToken) { AssertIsForeground(); - var definitionItem = symbol.ToNonClassifiedDefinitionItem(solution, includeHiddenLocations: true); + var definitionItem = symbol.ToNonClassifiedDefinitionItem(project, includeHiddenLocations: true); definitionItem.Properties.TryGetValue(DefinitionItem.RQNameKey1, out var rqName); if (!TryGetNavigationAPIRequiredArguments( - definitionItem, rqName, solution, cancellationToken, + definitionItem, rqName, cancellationToken, out var hierarchy, out var itemID, out var navigationNotify)) { return false; @@ -213,7 +213,7 @@ public bool TrySymbolNavigationNotify(ISymbol symbol, Solution solution, Cancell } if (!TryGetNavigationAPIRequiredArguments( - definitionItem, rqName, solution, cancellationToken, + definitionItem, rqName, cancellationToken, out var hierarchy, out var itemID, out var navigationNotify)) { return false; @@ -244,7 +244,6 @@ public bool TrySymbolNavigationNotify(ISymbol symbol, Solution solution, Cancell private bool TryGetNavigationAPIRequiredArguments( DefinitionItem definitionItem, string rqName, - Solution solution, CancellationToken cancellationToken, out IVsHierarchy hierarchy, out uint itemID, diff --git a/src/Workspaces/CSharp/Portable/Extensions/ContextQuery/SyntaxTreeExtensions.cs b/src/Workspaces/CSharp/Portable/Extensions/ContextQuery/SyntaxTreeExtensions.cs index e4d45c896bbae..ded28cf4df7ec 100644 --- a/src/Workspaces/CSharp/Portable/Extensions/ContextQuery/SyntaxTreeExtensions.cs +++ b/src/Workspaces/CSharp/Portable/Extensions/ContextQuery/SyntaxTreeExtensions.cs @@ -2497,15 +2497,10 @@ public static bool IsNameOfContext(this SyntaxTree syntaxTree, int position, Sem // if the nameof expression has a missing close paren, it is parsed as an invocation expression. if (token.Parent.IsKind(SyntaxKind.ArgumentList) && - token.Parent.IsParentKind(SyntaxKind.InvocationExpression)) + token.Parent.Parent is InvocationExpressionSyntax invocationExpression && + invocationExpression.IsNameOfInvocation()) { - var invocationExpression = (InvocationExpressionSyntax)token.Parent.Parent; - if (!invocationExpression.IsRightSideOfDotOrArrowOrColonColon() && - invocationExpression.Expression.IsKind(SyntaxKind.IdentifierName) && - ((IdentifierNameSyntax)invocationExpression.Expression).Identifier.IsKindOrHasMatchingText(SyntaxKind.NameOfKeyword)) - { - parentExpression = invocationExpression; - } + parentExpression = invocationExpression; } if (parentExpression != null) diff --git a/src/Workspaces/CSharp/Portable/Extensions/ExpressionSyntaxExtensions.cs b/src/Workspaces/CSharp/Portable/Extensions/ExpressionSyntaxExtensions.cs index e16f296d5c0e9..94196367554e0 100644 --- a/src/Workspaces/CSharp/Portable/Extensions/ExpressionSyntaxExtensions.cs +++ b/src/Workspaces/CSharp/Portable/Extensions/ExpressionSyntaxExtensions.cs @@ -412,9 +412,7 @@ public static bool IsNamedArgumentIdentifier(this ExpressionSyntax expression) } public static bool IsInsideNameOf(this ExpressionSyntax expression) - { - return expression.SyntaxTree.IsNameOfContext(expression.SpanStart); - } + => expression.SyntaxTree.IsNameOfContext(expression.SpanStart); private static bool CanReplace(ISymbol symbol) { @@ -1114,6 +1112,23 @@ private static bool ValidateAliasForTarget(IAliasSymbol aliasReplacement, Semant { var aliasName = aliasReplacement.Name; + // If we're the argument of a nameof(X.Y) call, then we can't simplify to an + // alias unless the alias has the same name as us (i.e. 'Y'). + if (node.IsNameOfArgumentExpression()) + { + var nameofValueOpt = semanticModel.GetConstantValue(node.Parent.Parent.Parent); + if (!nameofValueOpt.HasValue) + { + return false; + } + + if (nameofValueOpt.Value is string existingVal && + existingVal != aliasName) + { + return false; + } + } + var boundSymbols = semanticModel.LookupNamespacesAndTypes(node.SpanStart, name: aliasName); if (boundSymbols.Length == 1) @@ -1128,6 +1143,20 @@ private static bool ValidateAliasForTarget(IAliasSymbol aliasReplacement, Semant return false; } + public static bool IsNameOfArgumentExpression(this ExpressionSyntax expression) + { + return expression.IsParentKind(SyntaxKind.Argument) && + expression.Parent.IsParentKind(SyntaxKind.ArgumentList) && + expression.Parent.Parent.Parent is InvocationExpressionSyntax invocation && + invocation.IsNameOfInvocation(); + } + + public static bool IsNameOfInvocation(this InvocationExpressionSyntax invocation) + { + return invocation.Expression is IdentifierNameSyntax identifierName && + identifierName.Identifier.IsKindOrHasMatchingText(SyntaxKind.NameOfKeyword); + } + public static IAliasSymbol GetAliasForSymbol(INamespaceOrTypeSymbol symbol, SyntaxToken token, SemanticModel semanticModel, CancellationToken cancellationToken) { var originalSemanticModel = semanticModel.GetOriginalSemanticModel(); diff --git a/src/Workspaces/Core/Portable/FindSymbols/FindReferences/DependentProjectsFinder.cs b/src/Workspaces/Core/Portable/FindSymbols/FindReferences/DependentProjectsFinder.cs index f5ce18fb1c29b..4edd44685cfe7 100644 --- a/src/Workspaces/Core/Portable/FindSymbols/FindReferences/DependentProjectsFinder.cs +++ b/src/Workspaces/Core/Portable/FindSymbols/FindReferences/DependentProjectsFinder.cs @@ -453,54 +453,5 @@ public static bool HasReferenceToAssembly(this Project project, string assemblyN return null; } - - /// - /// Finds projects in this solution that have a reference to an assembly with the - /// identity provided. Projects will be ordered such that those that have a - /// reference that is - /// will be returned before those that are - /// . - /// - public static IEnumerable ProjectsWithReferenceToAssembly( - this Solution solution, AssemblyIdentity identity) - { - var projectMatchesIgnoringVersion = new List(); - foreach (var project in solution.Projects) - { - var referenceType = project.GetAssemblyReferenceType(a => - { - var result = AssemblyIdentityComparer.Default.Compare(a.Identity, identity); - - // If the assembly and the identity are NotEquivalent, return null to indicate - // that we need to keep checking the rest of the assemblies. Otherwise, - // return the result we got which will bubble out into 'referenceType'. - return result == AssemblyIdentityComparer.ComparisonResult.NotEquivalent - ? (AssemblyIdentityComparer.ComparisonResult?)null - : result; - }); - - if (referenceType.HasValue) - { - if (referenceType.Value == AssemblyIdentityComparer.ComparisonResult.Equivalent) - { - // We found an assembly reference exactly matching the assembly identity. - // Return it immediately. - yield return project; - } - else if (referenceType.Value == AssemblyIdentityComparer.ComparisonResult.EquivalentIgnoringVersion) - { - // We found an assembly reference matching the assembly identity if - // versions were ignored. Return it after all the exact matches are - // returned. - projectMatchesIgnoringVersion.Add(project); - } - } - } - - foreach (var project in projectMatchesIgnoringVersion) - { - yield return project; - } - } } } diff --git a/src/Workspaces/VisualBasic/Portable/Extensions/ExpressionSyntaxExtensions.vb b/src/Workspaces/VisualBasic/Portable/Extensions/ExpressionSyntaxExtensions.vb index 095fed6c2c48b..ee8e8a0176b1b 100644 --- a/src/Workspaces/VisualBasic/Portable/Extensions/ExpressionSyntaxExtensions.vb +++ b/src/Workspaces/VisualBasic/Portable/Extensions/ExpressionSyntaxExtensions.vb @@ -1761,6 +1761,21 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Extensions ' It's possible there is another symbol with the same name as the alias that binds first Private Function ValidateAliasForTarget(aliasReplacement As IAliasSymbol, semanticModel As SemanticModel, node As ExpressionSyntax, symbol As ISymbol) As Boolean Dim aliasName = aliasReplacement.Name + + ' If we're the argument of a NameOf(X.Y) call, then we can't simplify to an + ' alias unless the alias has the same name as us (i.e. 'Y'). + If node.IsNameOfArgumentExpression() Then + Dim nameofValueOpt = semanticModel.GetConstantValue(node.Parent.Parent.Parent) + If Not nameofValueOpt.HasValue Then + Return False + End If + + Dim existingValue = TryCast(nameofValueOpt.Value, String) + If existingValue Is Nothing OrElse existingValue <> aliasName Then + Return False + End If + End If + Dim boundSymbols = semanticModel.LookupNamespacesAndTypes(node.SpanStart, name:=aliasName) If boundSymbols.Length = 1 Then Dim boundAlias = TryCast(boundSymbols(0), IAliasSymbol) @@ -1776,6 +1791,11 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Extensions Return False End Function + + Public Function IsNameOfArgumentExpression(expression As ExpressionSyntax) As Boolean + Return expression.IsParentKind(SyntaxKind.NameOfExpression) + End Function + Private Function CanReplaceWithReducedName( name As NameSyntax,