Runtime capability to allow attribute editing#52986
Merged
davidwengier merged 64 commits intodotnet:mainfrom Jun 8, 2021
Merged
Runtime capability to allow attribute editing#52986davidwengier merged 64 commits intodotnet:mainfrom
davidwengier merged 64 commits intodotnet:mainfrom
Conversation
2eb4a43 to
5a39d3d
Compare
881f943 to
2ef2257
Compare
Member
|
Let's target |
tmat
reviewed
May 8, 2021
tmat
reviewed
May 8, 2021
tmat
reviewed
May 8, 2021
tmat
reviewed
May 8, 2021
tmat
reviewed
May 8, 2021
tmat
reviewed
May 8, 2021
tmat
reviewed
May 8, 2021
tmat
reviewed
May 8, 2021
tmat
reviewed
May 8, 2021
tmat
reviewed
May 8, 2021
tmat
reviewed
May 8, 2021
tmat
reviewed
May 8, 2021
tmat
reviewed
May 8, 2021
Member
Author
|
@tmat Added the deny list for non-custom attributes, PTAL. |
Member
Author
|
Merged and resolved conflicts. That was a pain :P |
tmat
reviewed
Jun 7, 2021
| continue; | ||
| } | ||
|
|
||
| #if TODO_ACCESSORS |
Member
Member
Author
There was a problem hiding this comment.
Yep. Did you mean to delete it? The linked issue is still unresolved so I left it just in case.
tmat
reviewed
Jun 7, 2021
|
|
||
| foreach (var parameter in newSymbol.GetParameters()) | ||
| { | ||
| var oldParameter = oldSymbol?.GetParameters().SingleOrDefault(p => p.Name.Equals(parameter.Name)); |
Member
tmat
reviewed
Jun 7, 2021
| if (newSymbol is INamedTypeSymbol or IFieldSymbol or IPropertySymbol) | ||
| { | ||
| var symbolKey = SymbolKey.Create(newSymbol, cancellationToken); | ||
| semanticEdits.Add(new SemanticEditInfo(SemanticEditKind.Update, symbolKey, syntaxMap, null, null)); |
tmat
reviewed
Jun 7, 2021
|
|
||
| public int GetHashCode(KeyValuePair<string, TypedConstant> obj) | ||
| => obj.GetHashCode(); | ||
| } |
Member
There was a problem hiding this comment.
Nit: let's move this code above the test accessor, e.g. to the Helpers region
tmat
reviewed
Jun 7, 2021
|
|
||
| #region Comparers | ||
|
|
||
| private class TypedConstantComparer : IEqualityComparer<TypedConstant> |
tmat
reviewed
Jun 7, 2021
| => obj.GetHashCode(); | ||
| } | ||
|
|
||
| private class NamedArgumentComparer : IEqualityComparer<KeyValuePair<string, TypedConstant>> |
tmat
reviewed
Jun 7, 2021
| NewTypeDefinition = 1 << 4, | ||
|
|
||
| /// <summary> | ||
| /// Adding, updating and deleting of custom attributes (as distinct from attributes that effect metadata) |
Member
tmat
reviewed
Jun 7, 2021
| /// <summary> | ||
| /// Adding, updating and deleting of custom attributes (as distinct from attributes that effect metadata) | ||
| /// </summary> | ||
| UpdateCustomAttributes = 1 << 5, |
Member
tmat
reviewed
Jun 7, 2021
| case SyntaxKind.AttributeList: | ||
| ReportError(RudeEditKind.Insert); | ||
| // To allow inserting of attributes we need to check if the inserted attribute | ||
| // is a pseudo-custom attribute that CLR allows us to change, or if it is a compiler well-know attribute |
tmat
reviewed
Jun 7, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #49012
Adds a new runtime capability to control attribute edits. If the capability is not present, rude edits are reported. If the capability is present, semantic edits are reported.
This still needs more work done to only allow changing attributes that are stored in the CustomAttributes table.