首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在C#中禁用日志服务合规性检查

在C#中禁用日志服务合规性检查
EN

Stack Overflow用户
提问于 2010-11-02 01:26:47
回答 2查看 7.8K关注 0票数 7

我正在编写一些方法具有以下属性的代码:

代码语言:javascript
复制
[CLSCompliantAttribute(false)] 

为什么当我按原样构建代码时,我看到正在执行遵从性检查,而当我注释掉它时,似乎没有执行遵从性检查?

我已经预料到了相反的行为。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2010-11-02 01:29:36

添加[CLSCompliant(false)]会将添加到其中的成员标记为不符合。

如果您将成员标记为不符合,编译器将不会警告您它不符合。(因为您已经说过它不符合。)

但是,如果该成员被标记为符合(显式或间接来自程序集级属性),但它实际上是不符合的(例如,它接受uint),编译器将警告您(因为该属性现在位于关于该成员的位置)。

票数 9
EN

Stack Overflow用户

发布于 2017-03-28 20:51:18

例如,您可以将其添加到AssemblyInfo.cs,并对所有程序集进行分组:*。像这样:

代码语言:javascript
复制
using System;
using System.Reflection;
using System.Runtime.InteropServices;
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]
[assembly: CLSCompliant(false)]


// Setting ComVisible to false makes the types in this assembly not visible 
// to COM components.  If you need to access a type in this assembly from 
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is     exposed to COM
[assembly: Guid("d29c53b6-88e4-4b33-bb86-f39b4c733542")]

// Version information for an assembly consists of the following four     values:
//
//      Major Version
//      Minor Version 
//      Build Number
//      Revision
//
// You can specify all the values or you can default the Revision and Build     Numbers 
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4071375

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档