我在C#項(xiàng)目中有一個(gè)HTTPSystemDefinitions.cs文件,該文件基本上描述了較舊的Windows ISAPI,供托管代碼使用。這包括與ISAPI相關(guān)的完整結(jié)構(gòu)集,而不是全部或被代碼使用。在編譯時(shí),這些結(jié)構(gòu)的所有字段成員都將引起如下警告:警告字段'UnionSquare.ISAPI.HTTP_FILTER_PREPROC_HEADERS.SetHeader'從未分配給該字段,并且其默認(rèn)值始終為null要么警告從未使用字段'UnionSquare.ISAPI.HTTP_FILTER_PREPROC_HEADERS.HttpStatus'這些可以禁用#pragma warning disable嗎?如果是這樣,相應(yīng)的錯(cuò)誤號(hào)是什么?如果沒(méi)有,我還能做什么?請(qǐng)記住,我只是要對(duì)此文件執(zhí)行此操作,重要的是我可以看到其他文件發(fā)出的此類警告。編輯示例結(jié)構(gòu):-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 4.0}
3 回答

慕哥9229398
TA貢獻(xiàn)1877條經(jīng)驗(yàn) 獲得超6個(gè)贊
解決這些警告的另一個(gè)“解決方案”是制作struct public
。然后不會(huì)發(fā)出警告,因?yàn)榫幾g器無(wú)法知道是否在程序集外部使用(分配)了這些字段。
也就是說(shuō),“互操作”組件通常不應(yīng)公開,而應(yīng)為internal
或private
。
- 3 回答
- 0 關(guān)注
- 1375 瀏覽
添加回答
舉報(bào)
0/150
提交
取消