dotnet/roslyn
在 GitHub 查看Fixing CS7036 (generate constructor based on base class) should give an option to use Primary Constructor
Open
#74,602 创建于 2024年7月30日
Area-IDEhelp wanted
仓库指标
- Star
- (20,414 star)
- PR 合并指标
- (平均合并 6天 17小时) (30 天内合并 256 个 PR)
描述
Discussed in https://github.com/dotnet/roslyn/discussions/74598
Originally posted by datvm July 30, 2024 I am not sure if this is a duplicate because I think this is a very popular scenario. Assume we have this code:
class BaseClass(CancellationToken ct)
{
}
class DerivedClass : BaseClass
{
}
VS would suggest to "Generate constructor 'DerivedClass(ct)'":
After that, VS continues to suggest to use Primary Constructor instead which gives this code:
class DerivedClass(CancellationToken ct) : BaseClass(ct)
{
}
I think the analyzer should merge the two steps into one?