-
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
Prepare partial properties feature for merge #73773
Merged
RikkiGibson
merged 16 commits into
dotnet:features/partial-properties
from
RikkiGibson:partial-properties-10
May 31, 2024
Merged
Changes from 15 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
6b5a681
Bookkeeping of prototype comments
RikkiGibson c61014b
pack enum values
RikkiGibson f546237
Merge remote-tracking branch 'upstream/features/partial-properties' i…
RikkiGibson b1f178f
regenerate errorfacts
RikkiGibson b1418ad
insertion verified
RikkiGibson 9872ff5
Address test plan review feedback
RikkiGibson 1578737
fix indent
RikkiGibson 2f064c3
Add more suggested tests
RikkiGibson 0e84cb2
fix display string
RikkiGibson 93fb17a
Fix tests in UsedAssemblies leg
RikkiGibson 63e1536
Merge remote-tracking branch 'upstream/features/partial-properties' i…
RikkiGibson 74eeafc
Update src/Features/Core/Portable/Completion/Providers/AbstractPartia…
Cosifne 787e342
Update src/Workspaces/CSharp/Portable/Rename/CSharpRenameRewriterLang…
Cosifne a10c81f
Update src/Compilers/CSharp/Test/Symbol/Symbols/PartialPropertiesTest…
RikkiGibson 58385ce
add suggested tests
RikkiGibson c743ca9
method parameter attribute
RikkiGibson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
2 changes: 1 addition & 1 deletion
2
src/Compilers/CSharp/Portable/Generated/ErrorFacts.Generated.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -95,7 +95,7 @@ protected SourcePropertySymbolBase( | |
{ | ||
Debug.Assert(!isExpressionBodied || !isAutoProperty); | ||
Debug.Assert(!isExpressionBodied || !hasInitializer); | ||
Debug.Assert(!isExpressionBodied || accessorsHaveImplementation); // PROTOTYPE(partial-properties): further adjust asserts? | ||
Debug.Assert(!isExpressionBodied || accessorsHaveImplementation); | ||
Debug.Assert((modifiers & DeclarationModifiers.Required) == 0 || this is SourcePropertySymbol); | ||
|
||
_syntaxRef = syntax.GetReference(); | ||
|
@@ -279,20 +279,20 @@ explicitlyImplementedProperty is null ? | |
internal bool IsExpressionBodied | ||
=> (_propertyFlags & Flags.IsExpressionBodied) != 0; | ||
|
||
private void CheckInitializer( | ||
bool isAutoProperty, | ||
bool isInterface, | ||
bool isStatic, | ||
Location location, | ||
BindingDiagnosticBag diagnostics) | ||
protected void CheckInitializerIfNeeded(BindingDiagnosticBag diagnostics) | ||
{ | ||
if (isInterface && !isStatic) | ||
if ((_propertyFlags & Flags.HasInitializer) == 0) | ||
{ | ||
diagnostics.Add(ErrorCode.ERR_InstancePropertyInitializerInInterface, location); | ||
return; | ||
} | ||
else if (!isAutoProperty) | ||
|
||
if (ContainingType.IsInterface && !IsStatic) | ||
{ | ||
diagnostics.Add(ErrorCode.ERR_InitializerOnNonAutoProperty, location); | ||
diagnostics.Add(ErrorCode.ERR_InstancePropertyInitializerInInterface, Location); | ||
} | ||
else if (!IsAutoProperty) | ||
{ | ||
diagnostics.Add(ErrorCode.ERR_InitializerOnNonAutoProperty, Location); | ||
} | ||
} | ||
|
||
|
@@ -692,11 +692,7 @@ internal override void AfterAddingTypeMembersChecks(ConversionsBase conversions, | |
this.CheckAccessibility(Location, diagnostics, isExplicitInterfaceImplementation); | ||
this.CheckModifiers(isExplicitInterfaceImplementation, Location, IsIndexer, diagnostics); | ||
|
||
bool hasInitializer = (_propertyFlags & Flags.HasInitializer) != 0; | ||
if (hasInitializer) | ||
{ | ||
CheckInitializer(IsAutoProperty, ContainingType.IsInterface, IsStatic, Location, diagnostics); | ||
} | ||
CheckInitializerIfNeeded(diagnostics); | ||
|
||
if (RefKind != RefKind.None && IsRequired) | ||
{ | ||
|
@@ -1109,20 +1105,23 @@ private CustomAttributesBag<CSharpAttributeData> GetAttributesBag() | |
// prevent infinite recursion: | ||
Debug.Assert(!ReferenceEquals(copyFrom, this)); | ||
|
||
// The property is responsible for completion of the backing field | ||
// NB: when the **field keyword feature** is implemented, it's possible that synthesized field symbols will also be merged or shared between partial property parts. | ||
// If we do that then this check should possibly be moved, and asserts adjusted accordingly. | ||
_ = BackingField?.GetAttributes(); | ||
Comment on lines
+1108
to
+1111
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. @cston This comment and the below assert are likely relevant for the field keyword feature. |
||
|
||
bool bagCreatedOnThisThread; | ||
if (copyFrom is not null) | ||
{ | ||
// When partial properties get the ability to have a backing field, | ||
// the implementer will have to decide how the BackingField symbol works in 'copyFrom' scenarios. | ||
Debug.Assert(BackingField is null); | ||
Debug.Assert(!IsAutoProperty); | ||
|
||
var attributesBag = copyFrom.GetAttributesBag(); | ||
bagCreatedOnThisThread = Interlocked.CompareExchange(ref _lazyCustomAttributesBag, attributesBag, null) == null; | ||
} | ||
else | ||
{ | ||
// The property is responsible for completion of the backing field | ||
_ = BackingField?.GetAttributes(); | ||
bagCreatedOnThisThread = LoadAndValidateAttributes(GetAttributeDeclarations(), ref _lazyCustomAttributesBag); | ||
} | ||
|
||
|
This file contains 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
This file contains 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
Oops, something went wrong.
Oops, something went wrong.
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.
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.
@cston I was anticipating that perhaps the synthesized BackingField symbol will be shared between partial property parts, or otherwise the two field symbols will reference each other similarly as the associated partial property symbols. But, this work won't happen until field keyword feature is implemented, and how specifically it will be done is TBD.
Currently, a different backing field symbol can be created for each partial property part, which is used only for error recovery (e.g. when an initializer is used on the property.)