-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hide replace/original functionality behind a feature flag. #11157
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,16 @@ namespace Microsoft.CodeAnalysis.CSharp.UnitTests.Symbols | |
{ | ||
public class ReplaceOriginalTests : CSharpTestBase | ||
{ | ||
private static CSharpCompilation CreateCompilationWithMscorlib(string text) | ||
{ | ||
return CreateCompilationWithMscorlib(text, parseOptions: TestOptions.Regular.WithReplaceFeature()); | ||
} | ||
|
||
private static CSharpCompilation CreateCompilationWithMscorlib(string text, CSharpCompilationOptions options) | ||
{ | ||
return CreateCompilationWithMscorlib(text, options: options, parseOptions: TestOptions.Regular.WithReplaceFeature()); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done in a new change. Thanks |
||
|
||
[WorkItem(11123, "https://github.com/dotnet/roslyn/issues/11123")] | ||
[Fact] | ||
public void Members() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,15 +4,17 @@ | |
using Microsoft.CodeAnalysis.CSharp.Syntax; | ||
using Microsoft.CodeAnalysis.CSharp.Symbols; | ||
using Xunit; | ||
using Microsoft.CodeAnalysis.CSharp.Test.Utilities; | ||
using System; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sort usings There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done in a new change |
||
|
||
namespace Microsoft.CodeAnalysis.CSharp.UnitTests | ||
{ | ||
public class ReplaceParsingTests | ||
public class ReplaceParsingTests: CSharpTestBase | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider marking tests with the feature attribute. |
||
{ | ||
[Fact] | ||
public void ReplaceClass() | ||
{ | ||
var root = SyntaxFactory.ParseCompilationUnit("abstract replace override class C { }"); | ||
var root = SyntaxFactory.ParseCompilationUnit("abstract replace override class C { }", options: TestOptions.Regular.WithReplaceFeature()); | ||
root.Errors().Verify(); | ||
var type = (TypeDeclarationSyntax)root.Members[0]; | ||
Assert.Equal( | ||
|
@@ -23,7 +25,7 @@ public void ReplaceClass() | |
[Fact] | ||
public void ReplaceMethod() | ||
{ | ||
var root = SyntaxFactory.ParseCompilationUnit("class C { virtual replace protected void M() { } }"); | ||
var root = SyntaxFactory.ParseCompilationUnit("class C { virtual replace protected void M() { } }", options: TestOptions.Regular.WithReplaceFeature()); | ||
root.Errors().Verify(); | ||
var type = (TypeDeclarationSyntax)root.Members[0]; | ||
Assert.Equal( | ||
|
@@ -35,6 +37,17 @@ public void ReplaceMethod() | |
DeclarationModifiers.Virtual | DeclarationModifiers.Protected | DeclarationModifiers.Replace); | ||
} | ||
|
||
[Fact] | ||
public void ReplaceMethodNoFeature() | ||
{ | ||
var source = "class C { virtual replace protected void M() { } }"; | ||
CreateCompilationWithMscorlib(source, options: TestOptions.DebugDll).VerifyDiagnostics( | ||
// (1,19): error CS8058: Feature 'replaced members' is experimental and unsupported; use '/features:replace' to enable. | ||
// class C { virtual replace protected void M() { } } | ||
Diagnostic(ErrorCode.ERR_FeatureIsExperimental, "replace").WithArguments("replaced members", "replace").WithLocation(1, 19) | ||
); | ||
} | ||
|
||
[Fact] | ||
public void OriginalExpression() | ||
{ | ||
|
@@ -72,7 +85,7 @@ public void OriginalInReplace() | |
|
||
private void OriginalInMember(string text, bool inReplace) | ||
{ | ||
var tree = SyntaxFactory.ParseSyntaxTree(text); | ||
var tree = SyntaxFactory.ParseSyntaxTree(text, options: TestOptions.Regular.WithReplaceFeature()); | ||
var root = tree.GetCompilationUnitRoot(); | ||
root.Errors().Verify(); | ||
var token = root.DescendantTokens().Where(t => t.Text == "original").Single(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider marking tests with the feature attribute.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AlekseyTs agree. This is now a pre-req before merging to future so let's do this now.