Skip to content

Conversation

@jaredpar
Copy link
Member

@jaredpar jaredpar commented May 1, 2023

This puts OrderBy back into our Workspaces layer. It also addresses a number of other places where our internal API was not consistent with public API when polyfills were involved.

Please consult the markdown doc for the rational here. That is going to be a repo artifact so lets focus the why discussion there. Want it to be clear for future readers why this change is being made.

This puts `OrderBy` back into our Workspaces layer. It also addresses a
number of other places where our `internal` API was not consistent with
`public` API when polyfills were involved.

Please consult the markdown doc for the rational here. That is going to
be a repo artifact so lets focus the _why_ discussion there. Want it to
be clear for future readers why this change is being made.
@jaredpar jaredpar requested a review from a team as a code owner May 1, 2023 16:26
@ghost ghost added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels May 1, 2023

It is not reasonable for us to take the union of all TFM and multi-target every single project to them. That would add several hundred compilations to any build operation which would in turn negatively impact our developer throughput. Instead we attempt to use the TFM where needed. That keeps our builds smaller but increases complexity a bit as we end up shipping a mix of TFM for binaries across our layers.

# Require consistent API across Target Frameworks
Copy link
Member Author

Choose a reason for hiding this comment

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

@sharwell is looking into an analyzer that can make this automatically enforced vs manually enforced. That will be handled in a different PR. This doc will still serve as a good why that analyzer exists.

@jaredpar
Copy link
Member Author

jaredpar commented May 1, 2023

@dotnet/roslyn-infrastructure, @dotnet/roslyn-compiler PTAL

@jaredpar jaredpar removed the untriaged Issues and PRs which have not yet been triaged by a lead label May 1, 2023
@jaredpar jaredpar added this to the 17.7 milestone May 1, 2023

This problem primarily comes from our use of polyfill APIs. To avoid this we employ the following rule:

> When there is an `#if NET.*` that declares a non-private member, there must be an `#else` that defines an equivalent binary compatible symbol
Copy link
Contributor

@sharwell sharwell May 1, 2023

Choose a reason for hiding this comment

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

In this case, #if NET.* is a regular expression, but it could be confused as a glob by the reader where . is literal.

Copy link
Member Author

Choose a reason for hiding this comment

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

Tried to clean that up a bit.

Copy link
Contributor

Choose a reason for hiding this comment

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

Why not use NET... everywhere for consistency?

jaredpar and others added 2 commits May 1, 2023 10:29
Co-authored-by: Sam Harwell <[email protected]>
Co-authored-by: Chris Sienkiewicz <[email protected]>
@jaredpar
Copy link
Member Author

jaredpar commented May 1, 2023

@sharwell, @chsienki thanks for the feedback. Updated.


```csharp
#if NET7_0_OR_GREATER
public static IOrderedEnumerable<T> Order<T>(IEnumerable<T> source) where T : IComparable<T>
Copy link
Member

Choose a reason for hiding this comment

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

Feels like there's less of a chance of error if we just #if the this keyword, rather than the whole signature.

Copy link
Member Author

Choose a reason for hiding this comment

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

I thought that too but it looked really awful when I wrote it that way.

Copy link
Contributor

Choose a reason for hiding this comment

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

public static IOrderedEnumerable<T> Order<T>(
    #if !NET7_0_OR_GREATER
    this
    #endif 
    IEnumerable<T> source) where T : IComparable<T>

Yea... idk if I like that

jaredpar and others added 2 commits May 2, 2023 07:54
@jaredpar jaredpar enabled auto-merge (squash) May 2, 2023 15:05
@jaredpar
Copy link
Member Author

jaredpar commented May 2, 2023

Test failure is unrelated.

@jaredpar jaredpar disabled auto-merge May 2, 2023 19:59
@jaredpar jaredpar merged commit 1005c28 into dotnet:main May 2, 2023
@jaredpar jaredpar deleted the api branch May 2, 2023 19:59
@ghost ghost modified the milestones: 17.7, Next May 2, 2023
@Cosifne Cosifne modified the milestones: Next, 17.7 P2 May 31, 2023
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.

8 participants