cls-compliant

Pattern for naming CLS compatible alternative Properties

孤街醉人 提交于 2020-01-04 08:11:55
问题 If i have a property like this [CLSCompliant(false)] public uint Something { ... } and want to write an alternative, i can not just write an overload as i would do for methods. But how should i name it? Is there some general way in the .NET libs? public long SomethingAlternative { ... } 回答1: I would suggest SomethingAsInt64 to explicitly indicate the behavioural difference. 回答2: Maybe do it the reverse way: make the complaint version "something" and the non-compliant as "SomethingUnsigned"

Pattern for naming CLS compatible alternative Properties

不问归期 提交于 2020-01-04 08:11:09
问题 If i have a property like this [CLSCompliant(false)] public uint Something { ... } and want to write an alternative, i can not just write an overload as i would do for methods. But how should i name it? Is there some general way in the .NET libs? public long SomethingAlternative { ... } 回答1: I would suggest SomethingAsInt64 to explicitly indicate the behavioural difference. 回答2: Maybe do it the reverse way: make the complaint version "something" and the non-compliant as "SomethingUnsigned"

Why is my class not CLS-compliant?

瘦欲@ 提交于 2019-12-30 18:26:06
问题 This really baffles me. I've tried removing the readonly, changing names.. What am I doing wrong here? public abstract class CatalogBase<T> where T : class { protected readonly String DataPath; protected readonly XmlSerializer Serializer; private readonly XmlSerializerNamespaces _namespaces; protected CatalogBase(String dataPath) { DataPath = dataPath; Serializer = new XmlSerializer(typeof (T)); _namespaces = new XmlSerializerNamespaces(); _namespaces.Add(String.Empty, String.Empty); } public

'Arrays as attribute arguments is not CLS-compliant' warning, but no type information given

与世无争的帅哥 提交于 2019-12-30 17:29:06
问题 When compiling my solution, I get several warnings of the following: warning CS3016: Arrays as attribute arguments is not CLS-compliant No other information on what type is not compliant is given. In my projects I have some attributes that take params array arguments in their constructors, but they are all internal, and that shouldn't affect CLS-compliance. Why is this warning being given, and what type is it being given on? 回答1: CS3016. If you have an attribute which takes an array as

CIL, CLS, and CTS in .NET

北城余情 提交于 2019-12-29 06:54:12
问题 What is the CIL, CTS, and CLS in .NET and what is the difference between them? 回答1: CIL (Common Intermediate Language) is the byte code to which your C# or Visual Basic code is compiled. It's the "machine code" of the .NET execution engine. The CTS (Common Type System) is the representation of types (classes and structures) at the compiled level. Basically, it's saying that all .NET languages will use a common way of representing types (classes and structures). The CLS (Common Language

CLSCompliant(true) drags in unused references

时间秒杀一切 提交于 2019-12-24 05:43:11
问题 Can anyone explain the following behavior? In summary, if you create multiple CLS compliant libraries in Visual Studio 2008 and have them share a common namespace root, a library referencing another library will require references to that library's references even though it doesn't consume them. It's pretty difficult to explain in a single sentence, but here are steps to reproduce the behavior (pay close attention to the namespaces): Create a library called LibraryA and add a a single class

Base type is not CLS-compliant, what reasons of this warning?

喜夏-厌秋 提交于 2019-12-18 18:37:16
问题 I have got warning from subject on one of my classes. Actually class is very simple, just an inheritor of my generic base type. Also I have some other inheritors from that generic class across the solution, and there are no such warnings. What could be the reason(s) of this? Compiler does not give any clues of why base type is not CLS-compliant 回答1: You probably have [assembly:CLSCompliant(true)] somewhere in that specific project. This triggers the compiler to check all types to be CLS

Is warning CS3006 valid in this case?

▼魔方 西西 提交于 2019-12-14 04:18:34
问题 The code below generates a warning CS3006 "Overloaded method MyNamespace.Sample.MyMethod(int[])' differing only in ref or out, or in array rank, is not CLS-compliant". Is this warning valid, i.e. is this genuinely not CLS-compliant? I'd have thought an explicit interface implementation would not count as an overload. [assembly: CLSCompliant(true)] namespace MyNamespace { public class Sample : ISample { public void MyMethod(int[] array) { return; } void ISample.MyMethod(ref int[] array) { this

mshtml and CLS-compliance

耗尽温柔 提交于 2019-12-12 19:13:58
问题 I am witnessing some odd behaviour with mshtml and CLS-compliance. I have an assembly marked CLSCompliant(true). This assembly does not expose any types from mshtml publicly. I can make the code conform to CLS fairly easily, but several things seem to break it: Introducing a "using mshtml;" statement instead of referencing the namespace manually each time I use a type. For some reason, this breaks CLS compliance. If I convert the following: var doc = webBrowser.Document as mshtml.HTMLDocument

Is there a tool for checking CLS compliance?

試著忘記壹切 提交于 2019-12-10 13:32:21
问题 Is there a tool that can analyse my .NET code (C# and VB.NET) and tell me why things are not CLS Compliant? Visual Studio is happy to tell me a parameter is not CLS compliant, but it doesn't get me any closer to fixing the problem as I don't know the cause. Example Visual Studio error: Parameter 'xyz' is not CLS-Compliant 回答1: I can't say I know of a tool, and I tend to use the MSDN page Language Independence and Language-Independent Components to check if the type of the parameter/variable