我在C#项目中有一个HTTPSystemDefinitions.cs文件,它基本上描述了托管代码消耗的旧Windows ISAPI.
这包括与ISAPI相关的完整结构集,不是全部或代码消耗的结构.在编译时,这些结构的所有字段成员都会发出如下警告: -
警告字段'UnionSquare.ISAPI.HTTP_FILTER_PREPROC_HEADERS.SetHeader'永远不会分配给,并且始终具有其默认值null
要么
警告从不使用字段'UnionSquare.ISAPI.HTTP_FILTER_PREPROC_HEADERS.HttpStatus'
可以禁用这些#pragma warning disable吗?如果是这样,相应的错误号是什么?如果没有,我还能做什么?请记住,我只对这个文件做了什么,重要的是我看到来自其他文件的警告.
编辑
结构示例: -
struct HTTP_FILTER_PREPROC_HEADERS
{
//
// For SF_NOTIFY_PREPROC_HEADERS, retrieves the specified header value.
// Header names should include the trailing ':'. The special values
// 'method', 'url' and 'version' can be used to retrieve the individual
// portions of the request line
//
internal GetHeaderDelegate GetHeader;
internal SetHeaderDelegate SetHeader;
internal AddHeaderDelegate AddHeader;
UInt32 HttpStatus; // New in 4.0, status for SEND_RESPONSE
UInt32 dwReserved; // New in …Run Code Online (Sandbox Code Playgroud) 目标:在我使用自定义属性时删除编译器警告“CS0649”(从未分配字段)。
我有一个自定义属性(下面的代码只是示例):
[AttributeUsage(AttributeTargets.Field)]
public class MyCustomAttribute : Attribute { }
Run Code Online (Sandbox Code Playgroud)
然后我在一个字段上使用该属性:
[MyCustom]
private readonly SomeType someType;
Run Code Online (Sandbox Code Playgroud)
我的申请会自动填写 someType一个值,因此我们无需担心初始化它。
我仍然会在 Visual Studio 下看到一条波浪线,someType并且警告消息“字段“someType”从未分配给,并且它的默认值始终为空。
是否有我可以添加的属性或其他方法来MyCustomAttribute删除此编译器警告?
注意:我不想修改该字段或键入该字段在更远的范围内。我只是想添加属性,然后警告消失。