相关疑难解决方法(0)

在C#中禁止"永远不会使用"和"永远不会分配"警告

我在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)

c# suppress-warnings visual-studio

105
推荐指数
3
解决办法
6万
查看次数

标签 统计

c# ×1

suppress-warnings ×1

visual-studio ×1