Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop using init-only setter for netstandard #450

Merged
merged 7 commits into from
Jun 14, 2024

Conversation

zhiyuanliang-ms
Copy link
Contributor

Why this PR?

#435

Visible change

Replace init setter to set

@zhenlan
Copy link
Member

zhenlan commented May 16, 2024

Is it possible we can add test to make sure we are netstandard/netfx 4.x compatible?

@zhiyuanliang-ms
Copy link
Contributor Author

zhiyuanliang-ms commented May 20, 2024

Is it possible we can add test to make sure we are netstandard/netfx 4.x compatible?

Currently, the TargetFrameworks is netstand2.0 but the LangVersion is 9.0, maybe we should set the LangVersion to 7.3 or remove the LangVersion.
https://github.com/microsoft/FeatureManagement-Dotnet/blob/main/src/Microsoft.FeatureManagement/Microsoft.FeatureManagement.csproj

I checked other .net libraries which targets on netstandard, I found they didn't specify the LangVersion
https://github.com/dotnet/runtime/blob/main/src/libraries/Microsoft.Bcl.TimeProvider/src/Microsoft.Bcl.TimeProvider.csproj

Maybe, we should do the same thing.

@zhiyuanliang-ms
Copy link
Contributor Author

zhiyuanliang-ms commented May 20, 2024

@jimmyca15 @zhenlan

Maybe we should set the LangVersion to 8.0. The things get quite tricky here.
We have an API: IAsyncEnumerable<string> GetFeatureNamesAsync() of IFeatureManager,

However, async stream is not available in C# 7.3 (need 8.0+), so the GetFeatureNamesAsync will not work for .NET framework app.

@alexaka1
Copy link

alexaka1 commented May 21, 2024

The await foreach() syntax is exclusive to 8.0 and up, but you can still use the type manually in 7.3, getting an enumerator and calling next asynchronously in a while loop.
https://learn.microsoft.com/en-us/archive/msdn-magazine/2019/november/csharp-iterating-with-async-enumerables-in-csharp-8#a-tour-through-async-enumerables
https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.iasyncenumerable-1.getasyncenumerator?view=netframework-4.8#system-collections-generic-iasyncenumerable-1-getasyncenumerator(system-threading-cancellationtoken)

@jimmyca15
Copy link
Member

Using language version 8.0.0 would ensure we couldn't write init only setters. It also prevents us from taking advantage of new language features but that may be what makes sense since we are supporting netstandard.

@@ -15,7 +15,8 @@
<SignAssembly>true</SignAssembly>
<DelaySign>false</DelaySign>
<AssemblyOriginatorKeyFile>..\..\build\Microsoft.FeatureManagement.snk</AssemblyOriginatorKeyFile>
<LangVersion>9.0</LangVersion>
<!-- Microsoft.FeatureManagement uses the feature of async streams which is not supported in versions of C# earlier than 8.0. -->
Copy link
Member

Choose a reason for hiding this comment

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

We should mention why we don't use later than version 8.0

@zhiyuanliang-ms
Copy link
Contributor Author

/AzurePipeline run

@zhiyuanliang-ms
Copy link
Contributor Author

/AzurePipeline run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants