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

Relax ordering constraints around 'ref' and 'partial' modifiers #23533

Closed
wants to merge 13 commits into from

Conversation

alrz
Copy link
Contributor

@alrz alrz commented Dec 2, 2017

Proposal: dotnet/csharplang#946 (as part of C# 7.3)

Also related: dotnet/csharplang#1022

@alrz alrz changed the base branch from master to features/compiler December 3, 2017 01:47
@alrz alrz requested a review from a team as a code owner December 3, 2017 01:47
@alrz
Copy link
Contributor Author

alrz commented Dec 4, 2017

requested a review from dotnet/roslyn-ide as a code owner 2 days ago

That's weird. This doesn't touch any ide code. (maybe we should add root slashes to paths?)

/cc @jasonmalinowski This is for the compiler team to review. Thanks.
#Resolved

@jasonmalinowski
Copy link
Member

jasonmalinowski commented Dec 4, 2017

@alrz: I see you rebased the branch. If you branched master, retargeted to the PR to features/compiler, but hadn't rebased your branch first, then you might have in that window of time carried along an IDE fix which got that added.

Or you found a bug in GitHub. We'll see if we see it again? #Resolved

@alrz
Copy link
Contributor Author

alrz commented Dec 4, 2017

@jasonmalinowski

Also, by clicking on "code owner" in "requested a review from dotnet/roslyn-ide as a code owner" line you will be redirected to the line that caused it. it's on master. sounds like a GitHub bug. #Resolved

@jasonmalinowski
Copy link
Member

jasonmalinowski commented Dec 4, 2017

@alrz Yeah, did you change GitHub branch target and then do a rebase? Yeah GitHub shows it's the EditorFeatures line, but unfortunately doesn't let us see the point-in-time diff it was looking at when it decided to do that. #Resolved

@jasonmalinowski jasonmalinowski requested review from a team and removed request for a team December 4, 2017 22:35
@alrz
Copy link
Contributor Author

alrz commented Dec 5, 2017

"Relax ordering constraints around ref and partial modifiers on type declarations" (possibly will be treated as a 7.2 bug fix)

@gafter should I rebase to master? #Resolved

@gafter
Copy link
Member

gafter commented Dec 5, 2017

@alrz We'll let you know

@jcouv @jaredpar FYI this is a community contribution for "Relax ordering constraints around 'ref' and 'partial' modifiers on type declarations" #Resolved

@alrz
Copy link
Contributor Author

alrz commented Dec 7, 2017

IMO this should be behind a feature flag if we intend to relax partial ordering as well (this is implemented in this PR). there's another fix for dotnet/csharplang#1022 in #23643 (per LDM 2017-12-04)

We allow ref this but not the other way around. That's wrong! We can't disallow ref this, but we should allow and prefer this ref.

which I think could be a bug fix. #Resolved

var isPartialType = this.IsPartialType();
var isPartialMember = this.IsPartialMember();
if (isPartialType || isPartialMember)
var isPartialFollowedByType = this.IsPartialType();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should change or remove the IsPartialType helper. It no longer does what it says it does.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also add tests for the case described in the comment for ParseIdentifierToken

var isPartialMember = this.IsPartialMember();
if (isPartialType || isPartialMember)
var isPartialFollowedByType = this.IsPartialType();
var isPartialType = isPartialFollowedByType || IsNonContextualModifier(nextToken);
Copy link
Member

@agocke agocke Dec 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the result if we try to parse partial partial ref struct? #Resolved

Copy link
Contributor Author

@alrz alrz Dec 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the diagnostic will be similar to what we have today (expected ; etc). I'll add the test.

// (2,1): error CS0267: The 'partial' modifier can only appear immediately before 'class', 'struct', 'interface', or 'void'
// partial public class C // CS0267
Diagnostic(ErrorCode.ERR_PartialMisplaced, "partial").WithLocation(2, 1));
CreateStandardCompilation(test).VerifyDiagnostics();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In all of the cases where compilation now succeeds, I think we should access the type symbol for the declaration from the Compilation and verify that all the modifiers we expect are now present on the type.

@jcouv jcouv modified the milestones: 15.6, 15.7 Dec 8, 2017
@alrz
Copy link
Contributor Author

alrz commented Dec 9, 2017

the update xlf thing is such a drag. now for every resx change we need to commit 15 files? I thought we were going to narrow it down to one (just resx, not even .designer.cs) #Resolved

@sharwell
Copy link
Member

sharwell commented Dec 11, 2017

the update xlf thing is such a drag. now for every resx change we need to commit 15 files? I thought we were going to narrow it down to one (just resx, not even .designer.cs)

/cc @tmeschter @nguerrera #Resolved

@tmeschter
Copy link
Contributor

tmeschter commented Dec 11, 2017

@alrz We're in the process of moving localization work into the dotnet/roslyn repository. The upside is that we will, eventually, be able to take community contributions to improve translations. The downside is the need to keep the .xlf files up-to-date with the .resx files to ensure our translators are not working with stale data. We're looking into ways of automating this so you won't have to deal with it in normal developer workflows.

Note that changes to .resx and .designer.cs will generally have to happen together for correctness reasons, but that's always how it has been. #Resolved

@AlekseyTs
Copy link
Contributor

AlekseyTs commented Dec 11, 2017

@alrz Has this been approved by LDM? #Resolved

@jcouv
Copy link
Member

jcouv commented Dec 11, 2017

@AlekseyTs The last notes on this only recorded that we want to relax for ref, but from my recollection and Andy's there was later agreement to relax for partial.
Mads should be in office some time next week. I'll get confirmation from him then. #Resolved

@alrz
Copy link
Contributor Author

alrz commented Dec 14, 2017

@tmeschter

Note that changes to .resx and .designer.cs will generally have to happen together for correctness reasons, but that's always how it has been.

I think we can actually exclude .designer.cs from worktree just like .g.i.cs for xaml files.
#Resolved

@tmeschter
Copy link
Contributor

tmeschter commented Dec 14, 2017

I think we can actually exclude .designer.cs from worktree just like .g.i.cs for xaml files.

No, that's not safe. The .designer.cs file is updated by VS as the .resx files changes; it is not updated during the build. If you don't commit and flow changes to the .designer.cs along with the .resx then you'll quickly run into problems where your changes build on your local system, but don't build on a CI system. #Resolved

@tmeschter
Copy link
Contributor

tmeschter commented Dec 14, 2017

The conflicts in the .xlf files can be dealt with as follows:

  1. Resolve the conflicts in the .resx file as you would normally.
  2. Bulk resolve all conflicts in the .xlf files in favor of the other branch (this preserves all updated translations coming from the other branch).
  3. Build to bring the .xlf files in sync with the .resx files again.
  4. Commit all .xlf files updated in step 3. #Resolved

@jcouv jcouv added this to the 16.4 milestone Sep 6, 2019
// For instance, we return true for both of these:
//
// partial partial<T>()
// partial partail<T> partial()
Copy link
Member

@jcouv jcouv Sep 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

partail [](start = 22, length = 7)

typo?

@jcouv
Copy link
Member

jcouv commented Sep 12, 2019

The parsing of modifiers has been updated in the meantime, causing some conflicts.

@alrz
Copy link
Contributor Author

alrz commented Sep 29, 2019

some of test failures are there just because the default langversion doesn't include preview features. should we adjust those tests or include preview in default?

@jcouv
Copy link
Member

jcouv commented Sep 30, 2019

@alrz The tests should be adjusted to use Preview language version. Once we lock the release each feature goes into, those tests will be updated with a specific language version (TestOptions.Regular9 and such).

@alrz alrz requested review from jcouv and removed request for a team October 3, 2019 10:07
@jinujoseph jinujoseph removed this from the 16.4 milestone Dec 11, 2019
@alrz
Copy link
Contributor Author

alrz commented Dec 18, 2019

We probably need to consider the data modifier here as well since it's a contextual keyword.

/cc @agocke

@agocke
Copy link
Member

agocke commented Dec 18, 2019

@alrz Agreed. I'm going to regard this feature as necessary if we want to add a data keyword. I'm not going to try to design a required ordering for all these keywords.

@agocke
Copy link
Member

agocke commented Feb 28, 2020

@alrz If you don't mind I'm gonna rebase this to master in a new PR. I'm gonna build on it for my records work.

@alrz
Copy link
Contributor Author

alrz commented Feb 29, 2020

Sure. I think we can close this one now. Thanks.

I'll keep the branch for you to rebase.

@alrz alrz closed this Feb 29, 2020
@agocke
Copy link
Member

agocke commented Mar 2, 2020

Thanks! Draft PR #42097

I'll keep your code and just add any changes needed for records.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers Community The pull request was submitted by a contributor who is not a Microsoft employee.
Projects
None yet
Development

Successfully merging this pull request may close these issues.