Skip to content

Implement design changes for "pattern" Index/Range indexers #34897

Merged
agocke merged 7 commits intodotnet:masterfrom
agocke:pattern-index-range
Apr 12, 2019
Merged

Implement design changes for "pattern" Index/Range indexers #34897
agocke merged 7 commits intodotnet:masterfrom
agocke:pattern-index-range

Conversation

@agocke
Copy link
Member

@agocke agocke commented Apr 10, 2019

Implements most of the design changes specified in
https://github.com/dotnet/csharplang/blob/c229cae634bd59a6a13b9ed464a4cab782a95e5d/proposals/index-range-changes.md

This PR focuses on getting the simple end-to-end scenario working,
not focusing entirely on codegen quality. I expect to follow-up later
with the optimizations mentioned about eliminating use of the
Index/Range helpers entirely if they can be elided.

@agocke agocke force-pushed the pattern-index-range branch 2 times, most recently from 0c0e1d4 to 2ebfc58 Compare April 10, 2019 21:41
@agocke agocke changed the title WIP Implement design changes for "pattern" Index/Range indexers Apr 10, 2019
Implements most of the design changes specified in
https://github.com/dotnet/csharplang/blob/c229cae634bd59a6a13b9ed464a4cab782a95e5d/proposals/index-range-changes.md

This PR focuses on getting the simple end-to-end scenario working,
not focusing entirely on codegen quality. I expect to follow-up later
with the optimizations mentioned about eliminating use of the
Index/Range helpers entirely if they can be elided.
@agocke agocke force-pushed the pattern-index-range branch from 2ebfc58 to ae2c987 Compare April 10, 2019 22:26
@agocke agocke marked this pull request as ready for review April 10, 2019 22:28
@agocke agocke requested a review from a team as a code owner April 10, 2019 22:28
@agocke agocke added this to the 16.1.P2 milestone Apr 10, 2019
@agocke agocke requested a review from jaredpar April 10, 2019 22:28
@agocke
Copy link
Member Author

agocke commented Apr 10, 2019

@333fred Could you take a look at the IOperation stuff and see if it's good enough for a first pass?

@jaredpar
Copy link
Member

Done with review pass (iteration 1).

@jaredpar
Copy link
Member

Done with review pass (iteration 2). Mostly small comments.

/// <summary>
/// The required name for the <c>Count</c> property used in a pattern-based Index or Range indexer.
/// </summary>
public const string CountPropertyName = "Count";
Copy link
Contributor

Choose a reason for hiding this comment

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

public const string CountPropertyName = "Count"; [](start = 8, length = 48)

Why would we want to expose these constants publicly?

Copy link
Member Author

Choose a reason for hiding this comment

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

Great question! I don't know, but it seems like all of these are public. Why should these members be different?

Copy link
Contributor

Choose a reason for hiding this comment

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

Why should these members be different?

Why should we have these members in this type?


In reply to: 274721942 [](ancestors = 274721942)

Copy link
Member Author

Choose a reason for hiding this comment

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

It's where we store the names for other patterns, like foreach or async dispose. I could put them elsewhere, this just seemed like the natural place.

@agocke
Copy link
Member Author

agocke commented Apr 12, 2019

@jaredpar @AlekseyTs Any further comments?

indexerAccessExpression = BadIndexerExpression(node, expr, analyzedArguments, lookupResult.Error, diagnostics);
if (TryBindIndexOrRangeIndexer(
node,
expr,
Copy link
Member

Choose a reason for hiding this comment

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

We commonly style indexer access expressions as receiver[expr], so naming this expr here seems confusing.

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, indexers can have multiple arguments, so it would be receiver[arg1, arg2, arg3] so using expr as the argument name just means we're inserting an expression (which could be any of those components).

@agocke agocke merged commit 357fa7e into dotnet:master Apr 12, 2019
@agocke agocke deleted the pattern-index-range branch April 12, 2019 22:40
333fred added a commit to 333fred/roslyn that referenced this pull request Apr 17, 2019
* dotnet/master: (495 commits)
  Roslyn Installer: Stop processes that block VSIX installation. (dotnet#34886)
  Remove unused helper BeginInvokeOnUIThread
  Apply a hang mitigating timeout to InvokeOnUIThread
  Apply a hang mitigating timeout in RestoreNuGetPackages
  Apply a hang mitigating timeout to WaitForApplicationIdle
  Fix Value/Ref checks for pattern Index/Range (dotnet#35004)
  Fix assert in remove unused member analyzer
  Treat unconstrained type parameters declared in `#nullable disable` context as having an oblivious nullability in case they are substituted with a reference type. (dotnet#34797)
  Add symbol name to tests. Fix to be the correct name emitted
  PR feedback
  Improve IDE0052 diagnostic message for properties with used setter but unused getter
  Use original definition symbol for fetching control flow graph of generic local functions.
  Properly treat ambiguous explicit interface implementations (dotnet#34584)
  Remove the dependence between the order in NullableAnnotation and metadata attribute values (dotnet#34909)
  Fix warning level test.
  Fix bootstrap on Linux/Mac (dotnet#34978)
  disable completion for immediate window commands (dotnet#32631)
  Updated PreviewWarning color
  Implement design changes for "pattern" Index/Range indexers  (dotnet#34897)
  Add IVTs to 16.1 version of RemoteLS
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants