JavaScript is not currently enabled, but is required for full CodeSonar manual search and browse functionality.
If you are viewing this file in your hub's Web GUI, enable JavaScript in your browser: you will also need it for GUI functionality.
If you opened this file directly from disk, your browser may be directly suppressing JavaScript functionality: certain browsers perform this suppression on local files (but not files delivered by web servers) for security reasons.
| CodeSonar® 9.2p0 | CONFIDENTIAL | CodeSecure Inc |
The C# API is essentially identical to the Java API.
The C# API is in beta at this stage. Please report any problems to CodeSecure support. The C# API is only supported on Windows. It may be possible for a determined POSIX user to create a C plugin that loads the Mono virtual machine and loads your assembly.
In order to build a C# plugin, compile the files at $CSONAR/src/api/csharp/*.cs, plus all the C# files you write, into a .NET assembly (dll file). For example:
The contents of MyPlugin.cs might look like this:
using System;
class echo_point_visitor: point_visitor{
public echo_point_visitor(){}
public override void visit(point p)
{
/* Always wrap visitors in exception handlers. If an
* exception isn't caught, behavior is undefined.
*/
try{
Console.WriteLine("csharp visits " + p);
}
catch( Exception e )
{
Console.WriteLine(e);
}
}
};
public class Main
{
public static int main(String dummy)
{
/* Always wrap everything in an exception handler. If an
* exception isn't caught, behavior is undefined.
*/
try{
analysis.add_point_visitor(new echo_point_visitor());
}
catch( Exception e )
{
Console.WriteLine(e);
}
return 0; // ignored
}
}
Set the CSHARP_PLUGINS, and CSHARP_PLUGIN_DOTNET_VERSION .conf settings appropriately. For example:
CSHARP_PLUGINS += h:\MyPlugin.dll
CSHARP_PLUGIN_DOTNET_VERSION = v4.0.30319
There is fairly little documentation for the C# API at this point. The interface can be seen by browsing the $CSONAR/src/api/csharp/*.cs files. The C# API is essentially identical to the Java API. The major difference between Java and C# is that enumeration values in Java can be referenced with expressions such as point_kind.getCALL_SITE(). C# supports attributes, so the equivalent C# expression is point_kind.CALL_SITE.
To report problems with this documentation, please visit https://support.codesecure.com/.