Skip to content

Conversation

@zhiyuanliang-ms
Copy link
Member

Why this PR?

#435

Visible change

Replace init setter to set

@zhiyuanliang-ms zhiyuanliang-ms requested a review from jimmyca15 May 15, 2024 09:34
@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
Member 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
Member 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.

<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
Member Author

/AzurePipeline run

@zhiyuanliang-ms
Copy link
Member Author

/AzurePipeline run

@azure-pipelines
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.

5 participants