Skip to content

Commit 34599f4

Browse files
author
Immo Landwerth
committed
WIP: Notes
1 parent b54735a commit 34599f4

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

accepted/2021/preview-features/preview-features.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,3 +418,75 @@ Originally I used the term *experimental* but we decided to change it to
418418
<50%, e.g. in `runtimelabs`
419419
* Overall, the goal is draw more people in and motivate them to try the
420420
features. The term *preview* seems more helpful than *experimental*.
421+
422+
----------------------
423+
424+
## Notes
425+
426+
* Should we support multiple feature flags _as well_?
427+
- If a feature is runtime only, we use environment variables today quite
428+
successfully. Maybe we should only differentiate between features that
429+
impact the binary on disk (compiler, APIs) vs. process lifetime. For
430+
runtime features we often do perf work and we want to know whether it
431+
helps or not.
432+
- For runtime libraries, we generally don't believe a library can or should
433+
declare a hard dependency on runtime only features, because they are often
434+
perf tweaks.
435+
- We don't believe we can change names of feature flags because historically
436+
not been able to rename them.
437+
- Maybe documenting them on docs.microsoft.com as unsupported is good
438+
enough.
439+
- We generally don't use `AppContext` switches for preview features, but we
440+
use it for more than just compat switches, e.g. trimming.
441+
* Should we use `LangVersion` as the main switch?
442+
- For language features, it's well established that people set this
443+
property.
444+
- The `LangVersion` property doesn't have quite the right name and it would
445+
now cause transitivity requirements.
446+
- Using this property might not work well for VB and F#
447+
- The biggest counter argument is that the compiler can be in stable version
448+
but the TFM you're targeting is not.
449+
- If we use a separate property, then this means the user could have preview
450+
features off, but language is in preview mode. This would result in
451+
configuration where the user can use runtime features that are in preview.
452+
One option is to use `RuntimeFeatures` and mark the field as
453+
`[RequiresPreviewFeatures]` that causes the compiler to enforce the
454+
containing assembly/type/member to be marked as
455+
`[RequiresPreviewFeatures]` as well. Aleksey believes this check needs to
456+
be in-place regardless of number of checks. Another option is to simply
457+
fail the build as an invalid configuration.
458+
* Analyzer vs Compiler feature
459+
* VS releases
460+
* Multiple TFMs
461+
462+
## From Jeremy
463+
464+
For the compiler versioning (and other languages) vs "API impacted platform
465+
features" (or whatever you want to call them):
466+
467+
* Maybe it's OK if C#-2025 can't compile certain syntaxes against .NET 6 with
468+
experimental support .. e.g. we changed something in how generic math works
469+
and they've decided "its been a couple releases, time to move on".
470+
* Conversely, even if the compiler supports that combination, if we changed
471+
generic math then there may be a runtime break on assemblies compiled against
472+
net6-preview vs net7, so an explicit experimental gesture is still a
473+
requirement
474+
475+
The three scenarios I commented on in chat may also be useful in addition to
476+
those points:
477+
478+
* Preview language feature with experimental API: string8 str = 8"Hello, World";
479+
* Should generate the "I used experimental API, my callers need to accept that"
480+
attribute.
481+
* Stable language syntax with experimental API
482+
- `Utf8String str = new Utf8String("Hello, World");`
483+
* Should generate the attribute
484+
* Preview language features that would work on net5 or older: things like
485+
autoprops or records or required partial members.
486+
* The attribute doesn't seem needed here. Why should this necessarily dead-end
487+
your NuGet package?
488+
489+
(To be clear: I don't think we need to make anything be smart enough that
490+
attribute generation is tied to actual usage, if making the gesture emits it
491+
even when you don't need it that's OK (except when it isn't) -- I'm just
492+
pointing out they're two different axes)

0 commit comments

Comments
 (0)