Skip to content

Improve compilation symbols when multi-targeting #1813

Closed
@yaakov-h

Description

The SDK defines a bunch of compilation symbols when multi-targeting.

For example, when targeting .NET Standard 1.3, developers can use #if NETSTANDARD1_3 to conditionally use APIs that are available with that target framework.

However, when multi-targeting across different versions, developers have to use multiple of these. For example:

#if NETSTANDARD1_3 || NETSTANDARD1_6 || NETSTANDARD2_0

It would be nice to have more inclusive compilation symbols, so that a developer could, for example, use:

#if NETSTANDARD1_3_OR_GREATER

This would be defined when targeting .NET Standard 1.3, 1.4, 1.5, 1.6. 2.0, 2.1, etc., but not when targeting .NET Standard 1.0, 1.1, 1.2, or .NET Framework, Xamarin, .NET Core etc.

Doing so would decrease the friction when introducing a newer platform (e.g. .NET Standard 3.0 one day) to a multi-targeting library that aims to keep backwards compatibility for older runtimes, but also taking advantage of newer APIs where they are available.

Inspired by dotnet/csharplang#1182

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions