提交 d4d502e4 编写于 作者: A AlekseyTs

Revert "Revert "Revert "*DON'T MERGE INTO MASTER* Hide IOperation API behind a feature flag"""

This reverts commit a96d7825.
上级 1672f0fd
...@@ -2908,12 +2908,6 @@ internal bool EnableEnumArrayBlockInitialization ...@@ -2908,12 +2908,6 @@ internal bool EnableEnumArrayBlockInitialization
return sustainedLowLatency != null && sustainedLowLatency.ContainingAssembly == Assembly.CorLibrary; return sustainedLowLatency != null && sustainedLowLatency.ContainingAssembly == Assembly.CorLibrary;
} }
} }
internal override bool IsIOperationFeatureEnabled()
{
var options = (CSharpParseOptions)this.SyntaxTrees.FirstOrDefault()?.Options;
return options?.IsFeatureEnabled(MessageID.IDS_FeatureIOperation) ?? false;
}
private class SymbolSearcher private class SymbolSearcher
{ {
......
...@@ -119,8 +119,6 @@ internal enum MessageID ...@@ -119,8 +119,6 @@ internal enum MessageID
IDS_FeatureLocalFunctions = MessageBase + 12708, IDS_FeatureLocalFunctions = MessageBase + 12708,
IDS_FeatureRefLocalsReturns = MessageBase + 12710, IDS_FeatureRefLocalsReturns = MessageBase + 12710,
IDS_FeatureIOperation = MessageBase + 12711,
} }
// Message IDs may refer to strings that need to be localized. // Message IDs may refer to strings that need to be localized.
...@@ -176,8 +174,6 @@ internal static string RequiredFeature(this MessageID feature) ...@@ -176,8 +174,6 @@ internal static string RequiredFeature(this MessageID feature)
return "patterns"; return "patterns";
case MessageID.IDS_FeaturePatternMatching2: case MessageID.IDS_FeaturePatternMatching2:
return "patternsExperimental"; return "patternsExperimental";
case MessageID.IDS_FeatureIOperation:
return "IOperation";
default: default:
return null; return null;
} }
......
...@@ -892,7 +892,7 @@ public void TestReportingDiagnosticWithInvalidLocation() ...@@ -892,7 +892,7 @@ public void TestReportingDiagnosticWithInvalidLocation()
{ {
var source1 = @"class C1 { void M() { int i = 0; i++; } }"; var source1 = @"class C1 { void M() { int i = 0; i++; } }";
var source2 = @"class C2 { void M() { int i = 0; i++; } }"; var source2 = @"class C2 { void M() { int i = 0; i++; } }";
var compilation = CreateCompilationWithMscorlib45(source1, parseOptions: TestOptions.RegularWithIOperationFeature); var compilation = CreateCompilationWithMscorlib45(source1);
var anotherCompilation = CreateCompilationWithMscorlib45(source2); var anotherCompilation = CreateCompilationWithMscorlib45(source2);
var treeInAnotherCompilation = anotherCompilation.SyntaxTrees.Single(); var treeInAnotherCompilation = anotherCompilation.SyntaxTrees.Single();
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // 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;
using System.Collections.Generic;
using System.Collections.Immutable; using System.Collections.Immutable;
using System.Linq;
using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Semantics; using Microsoft.CodeAnalysis.Semantics;
...@@ -18,9 +16,7 @@ public class AnalysisContextInfoTests ...@@ -18,9 +16,7 @@ public class AnalysisContextInfoTests
public void InitializeTest() public void InitializeTest()
{ {
var code = @"class C { void M() { return; } }"; var code = @"class C { void M() { return; } }";
var parseOptions = new CSharpParseOptions(kind: SourceCodeKind.Regular, documentationMode: DocumentationMode.None) var compilation = CreateCompilation(code);
.WithFeatures(new[] { new KeyValuePair<string, string>("IOperation", "true") });
var compilation = CreateCompilation(code, parseOptions: parseOptions);
Verify(compilation, nameof(AnalysisContext.RegisterCodeBlockAction)); Verify(compilation, nameof(AnalysisContext.RegisterCodeBlockAction));
Verify(compilation, nameof(AnalysisContext.RegisterCodeBlockStartAction)); Verify(compilation, nameof(AnalysisContext.RegisterCodeBlockStartAction));
...@@ -97,12 +93,12 @@ private static DiagnosticDescriptor GetRule(string id) ...@@ -97,12 +93,12 @@ private static DiagnosticDescriptor GetRule(string id)
isEnabledByDefault: true); isEnabledByDefault: true);
} }
private static Compilation CreateCompilation(string source, CSharpParseOptions parseOptions = null) private static Compilation CreateCompilation(string source)
{ {
string fileName = "Test.cs"; string fileName = "Test.cs";
string projectName = "TestProject"; string projectName = "TestProject";
var syntaxTree = CSharpSyntaxTree.ParseText(source, path: fileName, options: parseOptions); var syntaxTree = CSharpSyntaxTree.ParseText(source, path: fileName);
return CSharpCompilation.Create( return CSharpCompilation.Create(
projectName, projectName,
......
...@@ -2097,110 +2097,4 @@ public sealed override void Initialize(AnalysisContext context) ...@@ -2097,110 +2097,4 @@ public sealed override void Initialize(AnalysisContext context)
OperationKind.LiteralExpression); OperationKind.LiteralExpression);
} }
} }
// This analyzer is to test operation action registration method in AnalysisContext
public class IOperationFeatureFlagTestAnalyzer1 : DiagnosticAnalyzer
{
private const string ReliabilityCategory = "Reliability";
public static readonly DiagnosticDescriptor OperationActionDescriptor = new DiagnosticDescriptor(
"OperationAction1",
"An operation related action is invoked",
"An {0} action is invoked in {1} context.",
ReliabilityCategory,
DiagnosticSeverity.Warning,
isEnabledByDefault: true);
public sealed override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics
=> ImmutableArray.Create(OperationActionDescriptor);
public sealed override void Initialize(AnalysisContext context)
{
context.RegisterOperationAction(
(operationContext) =>
{
operationContext.ReportDiagnostic(
Diagnostic.Create(OperationActionDescriptor, operationContext.Operation.Syntax.GetLocation(), "Operation", "Analysis"));
},
OperationKind.LiteralExpression);
}
}
// This analyzer is to test operation action registration method in CompilationStartAnalysisContext
public class IOperationFeatureFlagTestAnalyzer2 : DiagnosticAnalyzer
{
private const string ReliabilityCategory = "Reliability";
public static readonly DiagnosticDescriptor OperationActionDescriptor = new DiagnosticDescriptor(
"OperationAction2",
"An operation related action is invoked",
"An {0} action is invoked in {1} context.",
ReliabilityCategory,
DiagnosticSeverity.Warning,
isEnabledByDefault: true);
public sealed override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics
=> ImmutableArray.Create(OperationActionDescriptor);
public sealed override void Initialize(AnalysisContext context)
{
context.RegisterCompilationStartAction(
(compilationStartContext) =>
{
compilationStartContext.RegisterOperationAction(
(operationContext) =>
{
operationContext.ReportDiagnostic(
Diagnostic.Create(OperationActionDescriptor, operationContext.Operation.Syntax.GetLocation(), "Operation", "CompilationStart within Analysis"));
},
OperationKind.LiteralExpression);
});
}
}
// This analyzer is to test GetOperation method in SemanticModel
public class IOperationFeatureFlagTestAnalyzer3 : DiagnosticAnalyzer
{
private const string ReliabilityCategory = "Reliability";
public static readonly DiagnosticDescriptor GetOperationDescriptor = new DiagnosticDescriptor(
"GetOperation",
"An IOperation is returned by SemanticModel",
"An IOperation is returned by SemanticModel.",
ReliabilityCategory,
DiagnosticSeverity.Warning,
isEnabledByDefault: true);
public sealed override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics
=> ImmutableArray.Create(GetOperationDescriptor);
public sealed override void Initialize(AnalysisContext context)
{
context.RegisterSyntaxNodeAction(
(syntaxContext) =>
{
var node = syntaxContext.Node;
var model = syntaxContext.SemanticModel;
if (model.GetOperation(node) != null)
{
syntaxContext.ReportDiagnostic(Diagnostic.Create(GetOperationDescriptor, node.GetLocation()));
}
},
Microsoft.CodeAnalysis.CSharp.SyntaxKind.NumericLiteralExpression);
context.RegisterSyntaxNodeAction(
(syntaxContext) =>
{
var node = syntaxContext.Node;
var model = syntaxContext.SemanticModel;
if (model.GetOperation(node) != null)
{
syntaxContext.ReportDiagnostic(Diagnostic.Create(GetOperationDescriptor, node.GetLocation()));
}
},
Microsoft.CodeAnalysis.VisualBasic.SyntaxKind.NumericLiteralExpression);
}
}
} }
\ No newline at end of file
...@@ -712,15 +712,6 @@ internal class CodeAnalysisResources { ...@@ -712,15 +712,6 @@ internal class CodeAnalysisResources {
} }
} }
/// <summary>
/// Looks up a localized string similar to Feature &apos;IOperation&apos; is disabled..
/// </summary>
internal static string IOperationFeatureDisabled {
get {
return ResourceManager.GetString("IOperationFeatureDisabled", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Argument to &apos;/keepalive&apos; option is not a 32-bit integer.. /// Looks up a localized string similar to Argument to &apos;/keepalive&apos; option is not a 32-bit integer..
/// </summary> /// </summary>
......
...@@ -513,7 +513,4 @@ ...@@ -513,7 +513,4 @@
<value>Exception occurred with following context: <value>Exception occurred with following context:
{0}</value> {0}</value>
</data> </data>
<data name="IOperationFeatureDisabled" xml:space="preserve">
<value>Feature 'IOperation' is disabled.</value>
</data>
</root> </root>
\ No newline at end of file
...@@ -2217,7 +2217,5 @@ internal bool IsTypeMissing(WellKnownType type) ...@@ -2217,7 +2217,5 @@ internal bool IsTypeMissing(WellKnownType type)
{ {
return _lazyMakeWellKnownTypeMissingMap != null && _lazyMakeWellKnownTypeMissingMap.ContainsKey((int)type); return _lazyMakeWellKnownTypeMissingMap != null && _lazyMakeWellKnownTypeMissingMap.ContainsKey((int)type);
} }
internal abstract bool IsIOperationFeatureEnabled();
} }
} }
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // 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.Generic;
using System.Collections.Immutable; using System.Collections.Immutable;
using System.Linq; using System.Linq;
...@@ -72,19 +71,7 @@ public SyntaxTree SyntaxTree ...@@ -72,19 +71,7 @@ public SyntaxTree SyntaxTree
/// <returns></returns> /// <returns></returns>
public IOperation GetOperation(SyntaxNode node, CancellationToken cancellationToken = default(CancellationToken)) public IOperation GetOperation(SyntaxNode node, CancellationToken cancellationToken = default(CancellationToken))
{ {
if (this.Compilation.IsIOperationFeatureEnabled()) return this.GetOperationCore(node, cancellationToken);
{
try
{
return GetOperationCore(node, cancellationToken);
}
catch (Exception e) when (FatalError.ReportWithoutCrashUnlessCanceled(e))
{
// Log a Non-fatal-watson and then ignore the crash in the attempt of getting operation
}
return null;
}
throw new InvalidOperationException(CodeAnalysisResources.IOperationFeatureDisabled);
} }
protected abstract IOperation GetOperationCore(SyntaxNode node, CancellationToken cancellationToken); protected abstract IOperation GetOperationCore(SyntaxNode node, CancellationToken cancellationToken);
......
...@@ -1422,7 +1422,7 @@ private bool ShouldExecuteOperationBlockActions(AnalysisScope analysisScope, ISy ...@@ -1422,7 +1422,7 @@ private bool ShouldExecuteOperationBlockActions(AnalysisScope analysisScope, ISy
var symbol = symbolEvent.Symbol; var symbol = symbolEvent.Symbol;
var executeSyntaxNodeActions = ShouldExecuteSyntaxNodeActions(analysisScope); var executeSyntaxNodeActions = ShouldExecuteSyntaxNodeActions(analysisScope);
var executeCodeBlockActions = ShouldExecuteCodeBlockActions(analysisScope, symbol); var executeCodeBlockActions = ShouldExecuteCodeBlockActions(analysisScope, symbol);
var executeOperationActions = this.analyzerExecutor.Compilation.IsIOperationFeatureEnabled() && ShouldExecuteOperationActions(analysisScope); var executeOperationActions = ShouldExecuteOperationActions(analysisScope);
var executeOperationBlockActions = ShouldExecuteOperationBlockActions(analysisScope, symbol); var executeOperationBlockActions = ShouldExecuteOperationBlockActions(analysisScope, symbol);
if (executeSyntaxNodeActions || executeOperationActions || executeCodeBlockActions || executeOperationBlockActions) if (executeSyntaxNodeActions || executeOperationActions || executeCodeBlockActions || executeOperationBlockActions)
......
...@@ -200,7 +200,7 @@ public void ExecuteInitializeMethod(DiagnosticAnalyzer analyzer, HostSessionStar ...@@ -200,7 +200,7 @@ public void ExecuteInitializeMethod(DiagnosticAnalyzer analyzer, HostSessionStar
{ {
// The Initialize method should be run asynchronously in case it is not well behaved, e.g. does not terminate. // The Initialize method should be run asynchronously in case it is not well behaved, e.g. does not terminate.
ExecuteAndCatchIfThrows(analyzer, ExecuteAndCatchIfThrows(analyzer,
() => analyzer.Initialize(new AnalyzerAnalysisContext(analyzer, sessionScope, _compilation.IsIOperationFeatureEnabled()))); () => analyzer.Initialize(new AnalyzerAnalysisContext(analyzer, sessionScope)));
} }
/// <summary> /// <summary>
......
...@@ -70,14 +70,6 @@ internal static void VerifyDiagnosticLocationsInCompilation(Diagnostic diagnosti ...@@ -70,14 +70,6 @@ internal static void VerifyDiagnosticLocationsInCompilation(Diagnostic diagnosti
} }
} }
} }
internal static void VerifyIOperationFeatureFlag(bool isIOperationFeatureEnabled)
{
if (!isIOperationFeatureEnabled)
{
throw new InvalidOperationException(CodeAnalysisResources.IOperationFeatureDisabled);
}
}
private static void VerifyDiagnosticLocationInCompilation(string id, Location location, Compilation compilation) private static void VerifyDiagnosticLocationInCompilation(string id, Location location, Compilation compilation)
{ {
......
...@@ -17,14 +17,11 @@ internal sealed class AnalyzerAnalysisContext : AnalysisContext ...@@ -17,14 +17,11 @@ internal sealed class AnalyzerAnalysisContext : AnalysisContext
{ {
private readonly DiagnosticAnalyzer _analyzer; private readonly DiagnosticAnalyzer _analyzer;
private readonly HostSessionStartAnalysisScope _scope; private readonly HostSessionStartAnalysisScope _scope;
private readonly bool _isIOperationFeatureEnabled;
public AnalyzerAnalysisContext(DiagnosticAnalyzer analyzer, HostSessionStartAnalysisScope scope, bool isIOperationFeatureEnabled = false) public AnalyzerAnalysisContext(DiagnosticAnalyzer analyzer, HostSessionStartAnalysisScope scope)
{ {
_analyzer = analyzer; _analyzer = analyzer;
_scope = scope; _scope = scope;
_isIOperationFeatureEnabled = isIOperationFeatureEnabled;
} }
public override void RegisterCompilationStartAction(Action<CompilationStartAnalysisContext> action) public override void RegisterCompilationStartAction(Action<CompilationStartAnalysisContext> action)
...@@ -77,21 +74,18 @@ public override void RegisterSyntaxNodeAction<TLanguageKindEnum>(Action<SyntaxNo ...@@ -77,21 +74,18 @@ public override void RegisterSyntaxNodeAction<TLanguageKindEnum>(Action<SyntaxNo
public override void RegisterOperationAction(Action<OperationAnalysisContext> action, ImmutableArray<OperationKind> operationKinds) public override void RegisterOperationAction(Action<OperationAnalysisContext> action, ImmutableArray<OperationKind> operationKinds)
{ {
DiagnosticAnalysisContextHelpers.VerifyIOperationFeatureFlag(_isIOperationFeatureEnabled);
DiagnosticAnalysisContextHelpers.VerifyArguments(action, operationKinds); DiagnosticAnalysisContextHelpers.VerifyArguments(action, operationKinds);
_scope.RegisterOperationAction(_analyzer, action, operationKinds); _scope.RegisterOperationAction(_analyzer, action, operationKinds);
} }
public override void RegisterOperationBlockStartAction(Action<OperationBlockStartAnalysisContext> action) public override void RegisterOperationBlockStartAction(Action<OperationBlockStartAnalysisContext> action)
{ {
DiagnosticAnalysisContextHelpers.VerifyIOperationFeatureFlag(_isIOperationFeatureEnabled);
DiagnosticAnalysisContextHelpers.VerifyArguments(action); DiagnosticAnalysisContextHelpers.VerifyArguments(action);
_scope.RegisterOperationBlockStartAction(_analyzer, action); _scope.RegisterOperationBlockStartAction(_analyzer, action);
} }
public override void RegisterOperationBlockAction(Action<OperationBlockAnalysisContext> action) public override void RegisterOperationBlockAction(Action<OperationBlockAnalysisContext> action)
{ {
DiagnosticAnalysisContextHelpers.VerifyIOperationFeatureFlag(_isIOperationFeatureEnabled);
DiagnosticAnalysisContextHelpers.VerifyArguments(action); DiagnosticAnalysisContextHelpers.VerifyArguments(action);
_scope.RegisterOperationBlockAction(_analyzer, action); _scope.RegisterOperationBlockAction(_analyzer, action);
} }
...@@ -115,8 +109,6 @@ internal sealed class AnalyzerCompilationStartAnalysisContext : CompilationStart ...@@ -115,8 +109,6 @@ internal sealed class AnalyzerCompilationStartAnalysisContext : CompilationStart
private readonly DiagnosticAnalyzer _analyzer; private readonly DiagnosticAnalyzer _analyzer;
private readonly HostCompilationStartAnalysisScope _scope; private readonly HostCompilationStartAnalysisScope _scope;
private readonly CompilationAnalysisValueProviderFactory _compilationAnalysisValueProviderFactory; private readonly CompilationAnalysisValueProviderFactory _compilationAnalysisValueProviderFactory;
private readonly bool _isIOperationFeatureEnabled;
public AnalyzerCompilationStartAnalysisContext( public AnalyzerCompilationStartAnalysisContext(
DiagnosticAnalyzer analyzer, DiagnosticAnalyzer analyzer,
...@@ -130,7 +122,6 @@ internal sealed class AnalyzerCompilationStartAnalysisContext : CompilationStart ...@@ -130,7 +122,6 @@ internal sealed class AnalyzerCompilationStartAnalysisContext : CompilationStart
_analyzer = analyzer; _analyzer = analyzer;
_scope = scope; _scope = scope;
_compilationAnalysisValueProviderFactory = compilationAnalysisValueProviderFactory; _compilationAnalysisValueProviderFactory = compilationAnalysisValueProviderFactory;
_isIOperationFeatureEnabled = compilation.IsIOperationFeatureEnabled();
} }
public override void RegisterCompilationEndAction(Action<CompilationAnalysisContext> action) public override void RegisterCompilationEndAction(Action<CompilationAnalysisContext> action)
...@@ -170,20 +161,17 @@ public override void RegisterSyntaxNodeAction<TLanguageKindEnum>(Action<SyntaxNo ...@@ -170,20 +161,17 @@ public override void RegisterSyntaxNodeAction<TLanguageKindEnum>(Action<SyntaxNo
public override void RegisterOperationBlockStartAction(Action<OperationBlockStartAnalysisContext> action) public override void RegisterOperationBlockStartAction(Action<OperationBlockStartAnalysisContext> action)
{ {
DiagnosticAnalysisContextHelpers.VerifyIOperationFeatureFlag(_isIOperationFeatureEnabled);
_scope.RegisterOperationBlockStartAction(_analyzer, action); _scope.RegisterOperationBlockStartAction(_analyzer, action);
} }
public override void RegisterOperationBlockAction(Action<OperationBlockAnalysisContext> action) public override void RegisterOperationBlockAction(Action<OperationBlockAnalysisContext> action)
{ {
DiagnosticAnalysisContextHelpers.VerifyIOperationFeatureFlag(_isIOperationFeatureEnabled);
DiagnosticAnalysisContextHelpers.VerifyArguments(action); DiagnosticAnalysisContextHelpers.VerifyArguments(action);
_scope.RegisterOperationBlockAction(_analyzer, action); _scope.RegisterOperationBlockAction(_analyzer, action);
} }
public override void RegisterOperationAction(Action<OperationAnalysisContext> action, ImmutableArray<OperationKind> operationKinds) public override void RegisterOperationAction(Action<OperationAnalysisContext> action, ImmutableArray<OperationKind> operationKinds)
{ {
DiagnosticAnalysisContextHelpers.VerifyIOperationFeatureFlag(_isIOperationFeatureEnabled);
_scope.RegisterOperationAction(_analyzer, action, operationKinds); _scope.RegisterOperationAction(_analyzer, action, operationKinds);
} }
......
...@@ -13,9 +13,7 @@ public static class TestOptions ...@@ -13,9 +13,7 @@ public static class TestOptions
public static readonly CSharpParseOptions Script = new CSharpParseOptions(kind: SourceCodeKind.Script, documentationMode: DocumentationMode.None); public static readonly CSharpParseOptions Script = new CSharpParseOptions(kind: SourceCodeKind.Script, documentationMode: DocumentationMode.None);
public static readonly CSharpParseOptions Regular = new CSharpParseOptions(kind: SourceCodeKind.Regular, documentationMode: DocumentationMode.None); public static readonly CSharpParseOptions Regular = new CSharpParseOptions(kind: SourceCodeKind.Regular, documentationMode: DocumentationMode.None);
public static readonly CSharpParseOptions RegularWithDocumentationComments = new CSharpParseOptions(kind: SourceCodeKind.Regular, documentationMode: DocumentationMode.Diagnose); public static readonly CSharpParseOptions RegularWithDocumentationComments = new CSharpParseOptions(kind: SourceCodeKind.Regular, documentationMode: DocumentationMode.Diagnose);
public static readonly CSharpParseOptions RegularWithIOperationFeature = Regular.WithIOperationsFeature();
private static readonly SmallDictionary<string, string> s_experimentalFeatures = new SmallDictionary<string, string> { { "localFunctions", "true" }, { "refLocalsAndReturns", "true" } }; private static readonly SmallDictionary<string, string> s_experimentalFeatures = new SmallDictionary<string, string> { { "localFunctions", "true" }, { "refLocalsAndReturns", "true" } };
public static readonly CSharpParseOptions ExperimentalParseOptions = public static readonly CSharpParseOptions ExperimentalParseOptions =
new CSharpParseOptions(kind: SourceCodeKind.Regular, documentationMode: DocumentationMode.None, languageVersion: LanguageVersion.CSharp6).WithFeatures(s_experimentalFeatures); new CSharpParseOptions(kind: SourceCodeKind.Regular, documentationMode: DocumentationMode.None, languageVersion: LanguageVersion.CSharp6).WithFeatures(s_experimentalFeatures);
...@@ -65,10 +63,5 @@ public static CSharpParseOptions WithRefsFeature(this CSharpParseOptions options ...@@ -65,10 +63,5 @@ public static CSharpParseOptions WithRefsFeature(this CSharpParseOptions options
{ {
return options.WithFeature("refLocalsAndReturns", "true"); return options.WithFeature("refLocalsAndReturns", "true");
} }
public static CSharpParseOptions WithIOperationsFeature(this CSharpParseOptions options)
{
return options.WithFeature("IOperation", "true");
}
} }
} }
...@@ -6,8 +6,6 @@ Public Class TestOptions ...@@ -6,8 +6,6 @@ Public Class TestOptions
Public Shared ReadOnly Script As New VisualBasicParseOptions(kind:=SourceCodeKind.Script) Public Shared ReadOnly Script As New VisualBasicParseOptions(kind:=SourceCodeKind.Script)
Public Shared ReadOnly Regular As New VisualBasicParseOptions(kind:=SourceCodeKind.Regular) Public Shared ReadOnly Regular As New VisualBasicParseOptions(kind:=SourceCodeKind.Regular)
Public Shared ReadOnly RegularWithIOperationFeature As VisualBasicParseOptions = Regular.WithIOperationFeature()
Public Shared ReadOnly ReleaseDll As VisualBasicCompilationOptions = New VisualBasicCompilationOptions(OutputKind.DynamicallyLinkedLibrary, optimizationLevel:=OptimizationLevel.Release).WithExtendedCustomDebugInformation(True) Public Shared ReadOnly ReleaseDll As VisualBasicCompilationOptions = New VisualBasicCompilationOptions(OutputKind.DynamicallyLinkedLibrary, optimizationLevel:=OptimizationLevel.Release).WithExtendedCustomDebugInformation(True)
Public Shared ReadOnly ReleaseExe As VisualBasicCompilationOptions = New VisualBasicCompilationOptions(OutputKind.ConsoleApplication, optimizationLevel:=OptimizationLevel.Release).WithExtendedCustomDebugInformation(True) Public Shared ReadOnly ReleaseExe As VisualBasicCompilationOptions = New VisualBasicCompilationOptions(OutputKind.ConsoleApplication, optimizationLevel:=OptimizationLevel.Release).WithExtendedCustomDebugInformation(True)
...@@ -47,9 +45,4 @@ Friend Module TestOptionExtensions ...@@ -47,9 +45,4 @@ Friend Module TestOptionExtensions
Public Function WithDeterministicFeature(options As VisualBasicParseOptions) As VisualBasicParseOptions Public Function WithDeterministicFeature(options As VisualBasicParseOptions) As VisualBasicParseOptions
Return options.WithFeature("Deterministic", "true") Return options.WithFeature("Deterministic", "true")
End Function End Function
<Extension()>
Public Function WithIOperationFeature(options As VisualBasicParseOptions) As VisualBasicParseOptions
Return options.WithFeature("IOperation", "true")
End Function
End Module End Module
...@@ -2646,15 +2646,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic ...@@ -2646,15 +2646,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Return New SymbolSearcher(Me).GetSymbolsWithName(predicate, filter, cancellationToken) Return New SymbolSearcher(Me).GetSymbolsWithName(predicate, filter, cancellationToken)
End Function End Function
Friend Overrides Function IsIOperationFeatureEnabled() As Boolean
Dim options = DirectCast(Me.SyntaxTrees.First().Options, VisualBasicParseOptions)
Dim IOperationFeatureFlag = InternalSyntax.FeatureExtensions.GetFeatureFlag(InternalSyntax.Feature.IOperation)
If IOperationFeatureFlag IsNot Nothing Then
Return options.Features.ContainsKey(IOperationFeatureFlag)
End If
Return False
End Function
#End Region #End Region
Private Class SymbolSearcher Private Class SymbolSearcher
......
...@@ -1954,6 +1954,5 @@ Namespace Microsoft.CodeAnalysis.VisualBasic ...@@ -1954,6 +1954,5 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
FEATURE_ImplementingReadonlyOrWriteonlyPropertyWithReadwrite FEATURE_ImplementingReadonlyOrWriteonlyPropertyWithReadwrite
FEATURE_DigitSeparators FEATURE_DigitSeparators
FEATURE_BinaryLiterals FEATURE_BinaryLiterals
FEATURE_IOperation
End Enum End Enum
End Namespace End Namespace
...@@ -31,7 +31,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Syntax.InternalSyntax ...@@ -31,7 +31,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Syntax.InternalSyntax
ImplementingReadonlyOrWriteonlyPropertyWithReadwrite ImplementingReadonlyOrWriteonlyPropertyWithReadwrite
DigitSeparators DigitSeparators
BinaryLiterals BinaryLiterals
IOperation
End Enum End Enum
Friend Module FeatureExtensions Friend Module FeatureExtensions
...@@ -41,12 +40,9 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Syntax.InternalSyntax ...@@ -41,12 +40,9 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Syntax.InternalSyntax
Case Feature.DigitSeparators Case Feature.DigitSeparators
Return "digitSeparators" Return "digitSeparators"
Case feature.BinaryLiterals Case Feature.BinaryLiterals
Return "binaryLiterals" Return "binaryLiterals"
Case Feature.IOperation
Return "IOperation"
Case Else Case Else
Return Nothing Return Nothing
End Select End Select
...@@ -145,8 +141,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Syntax.InternalSyntax ...@@ -145,8 +141,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Syntax.InternalSyntax
Return ERRID.FEATURE_DigitSeparators Return ERRID.FEATURE_DigitSeparators
Case Feature.BinaryLiterals Case Feature.BinaryLiterals
Return ERRID.FEATURE_BinaryLiterals Return ERRID.FEATURE_BinaryLiterals
Case Feature.IOperation
Return ERRID.FEATURE_IOperation
Case Else Case Else
Throw ExceptionUtilities.UnexpectedValue(feature) Throw ExceptionUtilities.UnexpectedValue(feature)
End Select End Select
......
...@@ -50,7 +50,7 @@ End Module ...@@ -50,7 +50,7 @@ End Module
</file> </file>
</compilation> </compilation>
Dim comp = CompilationUtils.CreateCompilationWithMscorlibAndVBRuntime(source, parseOptions:=TestOptions.RegularWithIOperationFeature) Dim comp = CompilationUtils.CreateCompilationWithMscorlibAndVBRuntime(source)
Dim tree = comp.SyntaxTrees.Single() Dim tree = comp.SyntaxTrees.Single()
Dim model = comp.GetSemanticModel(tree) Dim model = comp.GetSemanticModel(tree)
Dim nodes = tree.GetRoot().DescendantNodes().OfType(Of AssignmentStatementSyntax).ToArray() Dim nodes = tree.GetRoot().DescendantNodes().OfType(Of AssignmentStatementSyntax).ToArray()
...@@ -140,7 +140,7 @@ End Module ...@@ -140,7 +140,7 @@ End Module
</file> </file>
</compilation> </compilation>
Dim comp = CompilationUtils.CreateCompilationWithMscorlibAndVBRuntime(source, parseOptions:=TestOptions.RegularWithIOperationFeature) Dim comp = CompilationUtils.CreateCompilationWithMscorlibAndVBRuntime(source)
Dim tree = comp.SyntaxTrees.Single() Dim tree = comp.SyntaxTrees.Single()
Dim model = comp.GetSemanticModel(tree) Dim model = comp.GetSemanticModel(tree)
Dim nodes = tree.GetRoot().DescendantNodes().OfType(Of AssignmentStatementSyntax).ToArray() Dim nodes = tree.GetRoot().DescendantNodes().OfType(Of AssignmentStatementSyntax).ToArray()
......
...@@ -30,7 +30,6 @@ public partial class TestWorkspace ...@@ -30,7 +30,6 @@ public partial class TestWorkspace
private const string ReportDiagnosticAttributeName = "ReportDiagnostic"; private const string ReportDiagnosticAttributeName = "ReportDiagnostic";
private const string ParseOptionsElementName = "ParseOptions"; private const string ParseOptionsElementName = "ParseOptions";
private const string LanguageVersionAttributeName = "LanguageVersion"; private const string LanguageVersionAttributeName = "LanguageVersion";
private const string FeaturesAttributeName = "Features";
private const string DocumentationModeAttributeName = "DocumentationMode"; private const string DocumentationModeAttributeName = "DocumentationMode";
private const string DocumentElementName = "Document"; private const string DocumentElementName = "Document";
private const string AnalyzerElementName = "Analyzer"; private const string AnalyzerElementName = "Analyzer";
......
...@@ -350,12 +350,6 @@ private static ParseOptions GetParseOptionsWorker(XElement projectElement, strin ...@@ -350,12 +350,6 @@ private static ParseOptions GetParseOptionsWorker(XElement projectElement, strin
parseOptions = parseOptions.WithDocumentationMode(documentationMode.Value); parseOptions = parseOptions.WithDocumentationMode(documentationMode.Value);
} }
var featuresAttribute = projectElement.Attribute(FeaturesAttributeName);
if (featuresAttribute != null)
{
parseOptions = parseOptions.WithFeatures(featuresAttribute.Value.Split(',').Select(f => KeyValuePair.Create(f, "true")));
}
return parseOptions; return parseOptions;
} }
......
...@@ -412,7 +412,7 @@ Namespace Microsoft.CodeAnalysis.Editor.Implementation.Diagnostics.UnitTests ...@@ -412,7 +412,7 @@ Namespace Microsoft.CodeAnalysis.Editor.Implementation.Diagnostics.UnitTests
<WpfFact, WorkItem(937956, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/937956"), Trait(Traits.Feature, Traits.Features.Diagnostics)> <WpfFact, WorkItem(937956, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/937956"), Trait(Traits.Feature, Traits.Features.Diagnostics)>
Public Sub TestDiagnosticAnalyzerExceptionHandledGracefully() Public Sub TestDiagnosticAnalyzerExceptionHandledGracefully()
Dim test = <Workspace> Dim test = <Workspace>
<Project Language="C#" CommonReferences="true" Features="IOperation"> <Project Language="C#" CommonReferences="true">
<Document FilePath="Test.cs"> <Document FilePath="Test.cs">
class Foo { } class Foo { }
</Document> </Document>
...@@ -513,7 +513,7 @@ Namespace Microsoft.CodeAnalysis.Editor.Implementation.Diagnostics.UnitTests ...@@ -513,7 +513,7 @@ Namespace Microsoft.CodeAnalysis.Editor.Implementation.Diagnostics.UnitTests
<WpfFact, WorkItem(937939, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/937939"), Trait(Traits.Feature, Traits.Features.Diagnostics)> <WpfFact, WorkItem(937939, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/937939"), Trait(Traits.Feature, Traits.Features.Diagnostics)>
Public Sub TestOperationAnalyzers() Public Sub TestOperationAnalyzers()
Dim test = <Workspace> Dim test = <Workspace>
<Project Language="C#" CommonReferences="true" Features="IOperation"> <Project Language="C#" CommonReferences="true">
<Document FilePath="Test.cs"> <Document FilePath="Test.cs">
class Foo { void M() { int x = 0; } } class Foo { void M() { int x = 0; } }
</Document> </Document>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册