Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Use Nullable Type Attributes for Properties/Fields where Initialization is Outside the Constructor

未关闭
#89 4 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
25/100
Issue 类型
功能
描述清晰度
需要澄清
活跃度
停滞
技术栈
csharp
领域
tooling

调研方向

首先查看 issue 中的 nullable-analysis 示例,尤其是 TestContext 和计算得到的 Name 属性。定位 repository 中代码分析规则的入口点以及现有的 pragma 相关行为;完成的标准是:规则针对构造函数之外的初始化提出 nullable 属性,而不是生成 pragma。

由索引模型根据 Issue 内容生成。

描述

invalid proposal

Given properties that the compiler can't detect initialization for, such as MSTest's TestContext or a calculated Name property that splits the assignment to FirstName and LastName, use nullable attributes.
Examples:

[DisallowNull][NotNull]
public TestContext? TestContext {get;set;}

and

Person(string name) { Name = name; }
[DisallowNull][NotNull]
public string? FirstName {get;set;}
[DisallowNull][NotNull]
public string? FirstName {get;set;}
public string Name 
{
    get => $"{FirstName} {LastName}";
    set => { ... }
}

Proposal:
Create a code analysis rule that adds the attributes rather than creates generates a pragma.

主要语言
C#
星标
12
派生
16
平均合并
2 分钟
30 天内合并 PR
10

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

IntelliTect/CodingGuidelines 的其他 Issue

查看 IntelliTect/CodingGuidelines 的全部 Issue

相似的 Issue

更多 C# Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。