Skip to content
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

Runtime capability to allow attribute editing #52986

Merged
merged 64 commits into from
Jun 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
9781e3a
Return type info for attributes
davidwengier Apr 27, 2021
e13f526
Report rude edits for attribute changes if the runtime doesn't suppor…
davidwengier Apr 27, 2021
b0cc771
Update tests
davidwengier Apr 27, 2021
ea03734
Use different rude edit kinds for telemetry
davidwengier Apr 27, 2021
9d13c1b
Fix more tests
davidwengier Apr 27, 2021
928654d
Fix more tests
davidwengier Apr 27, 2021
a47ecd4
Move analysis to semantics for VB and fix some tests
davidwengier Apr 27, 2021
9f3ca3e
Fix VB tests
davidwengier Apr 28, 2021
da7c24b
Temporarily skip tests
davidwengier Apr 28, 2021
ae7149d
Add test for new capability
davidwengier Apr 28, 2021
8820259
Fix spanish tests
davidwengier Apr 28, 2021
e4c16ea
Fix Spanish VB tests
davidwengier Apr 28, 2021
37e6cb2
Remove old non-partial-method-compatible code
davidwengier Apr 30, 2021
0c068d0
Report rude and/or semantic edits for attributes
davidwengier Apr 30, 2021
b6818f9
Make sure the right symbols are analyzed
davidwengier Apr 30, 2021
aa80e06
Let the analysis through to semantics, to check attributes
davidwengier Apr 30, 2021
c715075
Analyze field attributes for changes
davidwengier Apr 30, 2021
740d4c5
Don't label attributes or attribute lists
davidwengier Apr 30, 2021
751d31d
Add new tests
davidwengier Apr 30, 2021
9283f84
Update existing tests
davidwengier Apr 30, 2021
37d162e
Report statement attribute changes via semantics
davidwengier Apr 30, 2021
9d3a7f3
Update tests
davidwengier Apr 30, 2021
a9b495c
Don't label attributes in VB
davidwengier Apr 30, 2021
4dcb220
Return the right symbol info
davidwengier Apr 30, 2021
b96dc46
Let analysis through to semantics
davidwengier Apr 30, 2021
93547f2
Partially update VB tests
davidwengier Apr 30, 2021
28d5e5a
Fix more VB tests
davidwengier May 1, 2021
18bb650
Tests and rude edits for top level attribuets in C#
davidwengier May 2, 2021
16fa66c
Only want symbols for As clause when updating
davidwengier May 2, 2021
dba5e87
Fix test
davidwengier May 2, 2021
3aa29a6
Top level attributes are syntactic rude edits in VB
davidwengier May 2, 2021
f7e2904
Add reorder test for C#
davidwengier May 2, 2021
4f023e2
More attribute labelling out of shared code
davidwengier May 2, 2021
d2f6c6e
Restore ordering in VB comparer
davidwengier May 2, 2021
61d9e78
Typo
davidwengier May 3, 2021
568cb7e
Create a new rude edit kind for attribute changes
davidwengier May 3, 2021
fefcd02
Add test to prove that my algorithm was unnecessarily smart
davidwengier May 3, 2021
d2e74e0
Fix attribute diffing algorithm
davidwengier May 3, 2021
dbf624f
Update tests for new diagnostics
davidwengier May 3, 2021
baab268
Fix tests
davidwengier May 3, 2021
59953fb
Fix VB delegate parameters
davidwengier May 3, 2021
f60ef2f
"top level" -> "module/assembly"
davidwengier May 11, 2021
3acb5e0
Rename
davidwengier May 11, 2021
42b064d
Rename
davidwengier May 11, 2021
b6b46f4
Clean up and simplify field handling
davidwengier May 11, 2021
4c3c6e7
Rename
davidwengier May 11, 2021
c9315ee
Simplify
davidwengier May 11, 2021
f2db0f0
Simplify
davidwengier May 11, 2021
dcc6148
Compare attribute constructor arguments correctly
davidwengier May 11, 2021
94291d6
Labels
davidwengier May 11, 2021
7887194
Temporarily allow custom attribute updates
davidwengier May 13, 2021
377ae4f
Formatting
davidwengier May 13, 2021
94052d7
Add a test to test the thing that I totally didn't forget to implemen…
davidwengier May 13, 2021
0e4597c
Merge in EnCCustomAttributes branch
davidwengier May 13, 2021
513d7d0
Revert "Merge in EnCCustomAttributes branch"
davidwengier May 27, 2021
29fe01d
Remove temporary capabilities
davidwengier May 27, 2021
66af6e5
Change method to return rather than use an out parameter
davidwengier May 27, 2021
a7e0972
Add deny list for attributes that are not custom attributes
davidwengier Jun 3, 2021
e6c1c37
Merge remote-tracking branch 'upstream/main' into EnCAttributeEdits
davidwengier Jun 4, 2021
a9b31df
Updates after merge
davidwengier Jun 5, 2021
795aa4f
Cleanup
davidwengier Jun 5, 2021
5f3d6f2
Fix parameter and type parameter handling
davidwengier Jun 7, 2021
3e052dd
Fix tests
davidwengier Jun 7, 2021
2bb5640
PR feedback
davidwengier Jun 7, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class CSharpEditAndContinueAnalyzerTests

#region Helpers

private static void TestSpans(string source, Func<SyntaxKind, bool> hasLabel)
private static void TestSpans(string source, Func<SyntaxNode, bool> hasLabel)
{
var tree = SyntaxFactory.ParseSyntaxTree(source);

Expand All @@ -41,7 +41,7 @@ private static void TestSpans(string source, Func<SyntaxKind, bool> hasLabel)
var expectedText = source.Substring(expected.Start, expected.Length);
var token = tree.GetRoot().FindToken(expected.Start);
var node = token.Parent;
while (!hasLabel(node.Kind()))
while (!hasLabel(node))
{
node = node.Parent;
}
Expand Down Expand Up @@ -146,8 +146,7 @@ public void ErrorSpans_TopLevel()

/*<span>*/delegate C<T> D2()/*</span>*/;

[/*<span>*/Attrib/*</span>*/]
/*<span>*/[Attrib]/*</span>*/
[Attrib]
/*<span>*/public class Z/*</span>*/
{
/*<span>*/int f/*</span>*/;
Expand Down Expand Up @@ -181,7 +180,7 @@ public void ErrorSpans_TopLevel()

}
";
TestSpans(source, kind => SyntaxComparer.TopLevel.HasLabel(kind));
TestSpans(source, node => SyntaxComparer.TopLevel.HasLabel(node));
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7201,12 +7201,11 @@ public void LocalFunction_AddAttribute()
var edits = GetMethodEdits(src1, src2);

edits.VerifyEdits(
"Insert [[A]]@2",
"Insert [A]@3");
"Update [void L() { }]@2 -> [[A]void L() { }]@2");

// Get top edits so we can validate rude edits
GetTopEdits(edits).VerifyRudeDiagnostics(
Diagnostic(RudeEditKind.Insert, "[A]", FeaturesResources.attribute));
Diagnostic(RudeEditKind.ChangingAttributesNotSupportedByRuntime, "L", FeaturesResources.local_function));
}

[Fact]
Expand All @@ -7218,12 +7217,11 @@ public void LocalFunction_RemoveAttribute()
var edits = GetMethodEdits(src1, src2);

edits.VerifyEdits(
"Delete [[A]]@2",
"Delete [A]@3");
"Update [[A]void L() { }]@2 -> [void L() { }]@2");

// Get top edits so we can validate rude edits
GetTopEdits(edits).VerifyRudeDiagnostics(
Diagnostic(RudeEditKind.Delete, "L", FeaturesResources.attribute));
Diagnostic(RudeEditKind.ChangingAttributesNotSupportedByRuntime, "L", FeaturesResources.local_function));
}

[Fact]
Expand All @@ -7234,7 +7232,7 @@ public void LocalFunction_ReorderAttribute()

var edits = GetMethodEdits(src1, src2);

edits.VerifyEdits("Reorder [B]@6 -> @3");
edits.VerifyEdits("Update [[A, B]void L() { }]@2 -> [[B, A]void L() { }]@2");

// Get top edits so we can validate rude edits
GetTopEdits(edits).VerifyRudeDiagnostics();
Expand All @@ -7249,15 +7247,9 @@ public void LocalFunction_CombineAttributeLists()
var edits = GetMethodEdits(src1, src2);

edits.VerifyEdits(
"Update [[A]]@2 -> [[A, B]]@2",
"Insert [B]@6",
"Delete [[B]]@5",
"Delete [B]@6");
"Update [[A][B]void L() { }]@2 -> [[A, B]void L() { }]@2");

// Get top edits so we can validate rude edits
GetTopEdits(edits).VerifyRudeDiagnostics(
Diagnostic(RudeEditKind.Insert, "B", FeaturesResources.attribute),
Diagnostic(RudeEditKind.Delete, "L", FeaturesResources.attribute));
GetTopEdits(edits).VerifyRudeDiagnostics();
}

[Fact]
Expand All @@ -7269,13 +7261,9 @@ public void LocalFunction_SplitAttributeLists()
var edits = GetMethodEdits(src1, src2);

edits.VerifyEdits(
"Update [[A, B]]@2 -> [[A]]@2",
"Insert [[B]]@5",
"Insert [B]@6",
"Delete [B]@6");
"Update [[A, B]void L() { }]@2 -> [[A][B]void L() { }]@2");

GetTopEdits(edits).VerifyRudeDiagnostics(
Diagnostic(RudeEditKind.Insert, "[B]", FeaturesResources.attribute));
GetTopEdits(edits).VerifyRudeDiagnostics();
}

[Fact]
Expand All @@ -7286,10 +7274,11 @@ public void LocalFunction_ChangeAttributeListTarget1()

var edits = GetMethodEdits(src1, src2);

edits.VerifyEdits("Update [[return: A]]@2 -> [[A]]@2");
edits.VerifyEdits("Update [[return: A]void L() { }]@2 -> [[A]void L() { }]@2");

GetTopEdits(edits).VerifyRudeDiagnostics(
Diagnostic(RudeEditKind.Update, "[A]", FeaturesResources.attribute));
Diagnostic(RudeEditKind.ChangingAttributesNotSupportedByRuntime, "L", FeaturesResources.local_function),
Diagnostic(RudeEditKind.ChangingAttributesNotSupportedByRuntime, "L", FeaturesResources.local_function));
}

[Fact]
Expand All @@ -7300,10 +7289,11 @@ public void LocalFunction_ChangeAttributeListTarget2()

var edits = GetMethodEdits(src1, src2);

edits.VerifyEdits("Update [[A]]@2 -> [[return: A]]@2");
edits.VerifyEdits("Update [[A]void L() { }]@2 -> [[return: A]void L() { }]@2");

GetTopEdits(edits).VerifyRudeDiagnostics(
Diagnostic(RudeEditKind.Update, "return:", CSharpFeaturesResources.attribute_target));
Diagnostic(RudeEditKind.ChangingAttributesNotSupportedByRuntime, "L", FeaturesResources.local_function),
Diagnostic(RudeEditKind.ChangingAttributesNotSupportedByRuntime, "L", FeaturesResources.local_function));
}

[Fact]
Expand All @@ -7315,11 +7305,10 @@ public void LocalFunction_ReturnType_AddAttribute()
var edits = GetMethodEdits(src1, src2);

edits.VerifyEdits(
"Insert [[return: A]]@2",
"Insert [A]@11");
"Update [int L() { return 1; }]@2 -> [[return: A]int L() { return 1; }]@2");

GetTopEdits(edits).VerifyRudeDiagnostics(
Diagnostic(RudeEditKind.Insert, "[return: A]", FeaturesResources.attribute));
Diagnostic(RudeEditKind.ChangingAttributesNotSupportedByRuntime, "L", FeaturesResources.local_function));
}

[Fact]
Expand All @@ -7331,11 +7320,10 @@ public void LocalFunction_ReturnType_RemoveAttribute()
var edits = GetMethodEdits(src1, src2);

edits.VerifyEdits(
"Delete [[return: A]]@2",
"Delete [A]@11");
"Update [[return: A]int L() { return 1; }]@2 -> [int L() { return 1; }]@2");

GetTopEdits(edits).VerifyRudeDiagnostics(
Diagnostic(RudeEditKind.Delete, "L", FeaturesResources.attribute));
Diagnostic(RudeEditKind.ChangingAttributesNotSupportedByRuntime, "L", FeaturesResources.local_function));
}

[Fact]
Expand All @@ -7346,7 +7334,7 @@ public void LocalFunction_ReturnType_ReorderAttribute()

var edits = GetMethodEdits(src1, src2);

edits.VerifyEdits("Reorder [B]@14 -> @11");
edits.VerifyEdits("Update [[return: A, B]int L() { return 1; }]@2 -> [[return: B, A]int L() { return 1; }]@2");

GetTopEdits(edits).VerifyRudeDiagnostics();
}
Expand All @@ -7360,11 +7348,10 @@ public void LocalFunction_Parameter_AddAttribute()
var edits = GetMethodEdits(src1, src2);

edits.VerifyEdits(
"Insert [[A]]@9",
"Insert [A]@10");
"Update [int i]@9 -> [[A]int i]@9");

GetTopEdits(edits).VerifyRudeDiagnostics(
Diagnostic(RudeEditKind.Insert, "[A]", FeaturesResources.attribute));
Diagnostic(RudeEditKind.ChangingAttributesNotSupportedByRuntime, "int i", FeaturesResources.parameter));
}

[Fact]
Expand All @@ -7376,11 +7363,10 @@ public void LocalFunction_Parameter_RemoveAttribute()
var edits = GetMethodEdits(src1, src2);

edits.VerifyEdits(
"Delete [[A]]@9",
"Delete [A]@10");
"Update [[A]int i]@9 -> [int i]@9");

GetTopEdits(edits).VerifyRudeDiagnostics(
Diagnostic(RudeEditKind.Delete, "int i", FeaturesResources.attribute));
Diagnostic(RudeEditKind.ChangingAttributesNotSupportedByRuntime, "int i", FeaturesResources.parameter));
}

[Fact]
Expand All @@ -7391,7 +7377,7 @@ public void LocalFunction_Parameter_ReorderAttribute()

var edits = GetMethodEdits(src1, src2);

edits.VerifyEdits("Reorder [B]@13 -> @10");
edits.VerifyEdits("Update [[A, B]int i]@9 -> [[B, A]int i]@9");

GetTopEdits(edits).VerifyRudeDiagnostics();
}
Expand All @@ -7405,11 +7391,10 @@ public void LocalFunction_TypeParameter_AddAttribute()
var edits = GetMethodEdits(src1, src2);

edits.VerifyEdits(
"Insert [[A]]@9",
"Insert [A]@10");
"Update [T]@9 -> [[A] T]@9");

GetTopEdits(edits).VerifyRudeDiagnostics(
Diagnostic(RudeEditKind.Insert, "[A]", FeaturesResources.attribute));
Diagnostic(RudeEditKind.ChangingAttributesNotSupportedByRuntime, "T", FeaturesResources.type_parameter));
}

[Fact]
Expand All @@ -7421,11 +7406,10 @@ public void LocalFunction_TypeParameter_RemoveAttribute()
var edits = GetMethodEdits(src1, src2);

edits.VerifyEdits(
"Delete [[A]]@9",
"Delete [A]@10");
"Update [[A] T]@9 -> [T]@9");

GetTopEdits(edits).VerifyRudeDiagnostics(
Diagnostic(RudeEditKind.Delete, "T", FeaturesResources.attribute));
Diagnostic(RudeEditKind.ChangingAttributesNotSupportedByRuntime, "T", FeaturesResources.type_parameter));
}

[Fact]
Expand All @@ -7436,7 +7420,7 @@ public void LocalFunction_TypeParameter_ReorderAttribute()

var edits = GetMethodEdits(src1, src2);

edits.VerifyEdits("Reorder [B]@13 -> @10");
edits.VerifyEdits("Update [[A, B] T]@9 -> [[B, A] T]@9");

GetTopEdits(edits).VerifyRudeDiagnostics();
}
Expand Down
Loading