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; var scriptNode = doc.createElement("SCRIPT") as mshtml.IHTMLScriptElement; var nodes = doc.getElementsByTagName("head"); foreach (var head in nodes) { var htmlHead = (mshtml.HTMLHeadElement)head; if (htmlHead != null) htmlHead.appendChild((mshtml.IHTMLDOMNode)scriptNode); }
to this:
foreach (var head in nodes.OfType<mshtml.IHTMLDOMNode>()) head.appendChild((mshtml.IHTMLDOMNode)scriptNode);
This also seems to break CLS compliance.
Can anyone offer any insight as to what might be going on here? Because for me, none of this breaks CLS compliance.
PS When I say breaks CLS compliance, 167 warnings are raised about each type in the mshtml namespace that begins with an underscore, or similar CLS violations.
Thanks.