-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed
Labels
Area-IDEFeature - Required MembersRequired properties and fieldsRequired properties and fieldsuntriagedIssues and PRs which have not yet been triaged by a leadIssues and PRs which have not yet been triaged by a lead
Description
[Update(jcouv):] The ask is that required properties not be recommended by the IDE on .NET 6 or lower.
Describe the bug
When I want to use required properties in a project targeting net6.0 with LangVersion set to latest I face some compile errors.
To Reproduce
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
</PropertyGroup>
</Project>
namespace Csharp11OnDotnet6;
public class Person
{
public required string Name { get; init; }
}
2.dotnet build
Exceptions (if any)
error CS0656: Missing compiler required member 'System.Runtime.CompilerServices.RequiredMemberAttribute..ctor'
error CS0656: Missing compiler required member 'System.Runtime.CompilerServices.CompilerFeatureRequi
redAttribute..ctor'
Expected Behavior: build successful
Metadata
Metadata
Assignees
Labels
Area-IDEFeature - Required MembersRequired properties and fieldsRequired properties and fieldsuntriagedIssues and PRs which have not yet been triaged by a leadIssues and PRs which have not yet been triaged by a lead