Plugs are used to fill "holes" in .NET libraries and replace them with different code. Holes exist for example when a method in .NET library uses a Windows API call. That API call will not be available on Cosmos. One method would be to emulate the Windows API as WINE does, but the API is a low level C style API relying on memory structures. Emulating it would be highly inefficient. Instead, Cosmos replaces specific methods and property implementations that rely on Windows API calls. Plugs can also be used to provide an alternate implementation for a method, even if it does not rely on the Windows API.
Plugs can be implemented in the following manners:
When a Cosmos project is compiled, IL2CPU creates a list of plugs. When it encounters a method or property for which a plug exists, instead of using the IL contained in the existing implementation, it substitutes the plug version instead.
Non source targets should never need to use assembly language, but if they do the plugs must be cascaded since assembly language plugs can only be applied to classes with modifiable source.
Plugs can be applied at the class, or to an individual method or property. Plug implementations are defined by applying attributes to the class which provides the plug implementation.
Plugs assemblies in Cosmos are named in the following manner.
Cosmos.<ring>.Plugs.<Unique section of target namespace>
ie Cosmos.System.Plugs.System
Normally only one section will exist after plugs, but mutliple sections could exist to further seperate a group of plugs into multiple assemblies. In the previous example we can determine the following information:
Plugs should be implemented in the highest ring possible and according to the code in the plug, not according to the class to which the plug targets. Most plugs should be in fact in the system ring. Except for a few special plugs needed by the compiler, off hand I cannot think of any that should be implemented in any ring lower than the system ring.
Plug Target
Please specify the PlugTarget using the fully qualified name, like: global::System.Console. To avoid later name colisions.