lundi 23 février 2015

How to determine if a member is CLS Compliant at runtime

I'm developing a tool to use SAP ME Web Services from a VB.NET application. I created a C# Class Library importing all web services as Service References. When I reference the C# Class Library in a VB.NET Class Library I'm not able to access Not CLS Compliant Members, obviously. I want to create new classes in VB to wrap each Not CLS Compliant member. Using Visual Studio IDE I found the entire list of all Not CLS Members reading the compiler warnings. Now I need to do it programmatically: I want load the C# Assembly and determine all the Not CLS Compliant Members. This is an example:



Private Function FindNonCLSIdentifiers(inputAssembly As Assembly) As List(Of String)
Dim InputTypes = From Type In inputAssembly.GetTypes Select Type Order By Type.FullName
Dim FoundTypes = New List(Of String)
Dim Result = New List(Of String)

For Each InputType In InputTypes
If FoundTypes.Contains(UCase(InputType.FullName)) Then
Result.Add(InputType.FullName)
Else
FoundTypes.Add(UCase(InputType.FullName))
End If
Next

Return Result
End Function


This sample doesn't work correctly.


Do you know the right way to do it?


Thank you!






Aucun commentaire:

Enregistrer un commentaire