Enable C# 9.0 features#13090
Enable C# 9.0 features#13090rjmholt merged 4 commits intoPowerShell:masterPowerShell/PowerShell:masterfrom iSazonov:speedup-debug-compileiSazonov/PowerShell:speedup-debug-compileCopy head branch name to clipboard
Conversation
There was a problem hiding this comment.
I have a concern that a language feature in preview may not make to the official release, so what if we start to use a syntax in code and that feature is pulled out?
There was a problem hiding this comment.
One feature I want is new is not. It is unbelievable that it will be removed.
Other new C# features are very specific and are not of interest at the moment. We will reject its till release in code reviews.
We already did this when Span appeared.
There was a problem hiding this comment.
I think it's a valid concern, but the risk is low, especially if we're judicious about which features we use, as @iSazonov says. We're already taking .NET preview versions, and I'd say the risk of needing to roll those back is much greater.
There was a problem hiding this comment.
As long as we can for a non-preview version of PowerShell ensure that we pin to a non-preview version of the C# language then I'd be happy with this change.
But it needs extra rigour to ensure that we don ship a 7.0.3 / 7.1.0 that uses preview language versions.
I expect most of that rigour is already in place, but still needed to be called out, just in case
There was a problem hiding this comment.
Well we don't synchronise to C# language version releases like .NET releases, so we are forced to retain preview language versions for stable releases. When release time comes, pinning to a stable version would mean downgrading the version and changing all the code relying on the preview features we've been using to that point, which is bad for several reasons.
But I don't think it's uncommon to build a stable product on a preview language version, and unlike .NET preview releases, the language features all compile down to the same things. Using a preview C# version will affect the development, but is unlikely to affect the product.
I think the real risk is that a preview feature is taken out of the language because it doesn't meet some bar, at which point we'll need to go and change all the code that uses that feature in order to build again.
I'll add that it makes backporting harder theoretically, but so would just incrementing the language version to another stable version.
There was a problem hiding this comment.
From what I can gather, this is actually a moot discussion because C# 9 should stabilise with .NET 5. The only risk that remains then is that something we depend on in preview does not progress to stable. However, the risk here is identical to relying on a preview .NET API -- we would need to revert to using the old implementation if it happened.
There was a problem hiding this comment.
Thanks for the clarification @rjmholt that makes a lot of sense :-)
There was a problem hiding this comment.
I've followed up with the .NET team on this to understand if our assumptions here can be relied on. I think until that's the case, it's fair for us to hold this PR
There was a problem hiding this comment.
Ok I’ve confirmed that C# 9 is planned to stabilise with .NET 5 — so our only remaining concern is the tolerance of removed preview features
There was a problem hiding this comment.
Current plan is only modernizing our code with is not null feature. No plans exist to use other new features in near month or two before C# 9.0 will be stabilized.
|
Looks like there's a test failure on Unix: I've rerun the tests, but they may fail again |
c9c152a to
334d363
Compare
|
Rebased... maybe resolve CI failures. |
|
|
||
| <TargetFramework>net5.0</TargetFramework> | ||
| <LangVersion>8.0</LangVersion> | ||
| <PublishReadyToRun>true</PublishReadyToRun> |
|
@iSazonov please resolve conflicts (I know they're because I merged the other PR...) |
|
@TravisEz13 please re-review |
Review has been addressed and is now outdated
|
@xtqqczze If you want you could cleanup code (I will review) with |
|
@iSazonov Yes I can cleanup code. I will open seperate PR for |
|
🎉 Handy links: |
PR Summary
Enable C# 9.0 features. Mainly to get
is notfor patterns likeif (!(obj is null))->if(obj is not null)PR Context
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready.