Oxygene - make interface automatic publivc


(Jens Gadensgaard Hermann) #1

We use Oxygene to have code both for our Delphi and .NET programmers, but we have a problem with all types declared in interface part of the unit - they are private or protected in Oxygene compiled dll from eg C#.

The only solution we have found so far is to add {$IFDEF DOTNET}public{$ENDIF} for all types to have the right level and still be able to compile in Delphi.

Is there an option which makes unit interface parts public by default?


(Carlo Kok) #2

Unfortunately, we currently don’t have an option to do this no. However something like this can probably be done with an aspect:

yourproject (anywhere in the project, just once):
[assembly:ClassLibrary23.MakeEverythingPublic]

classlibrary23:

namespace ClassLibrary23;

interface

uses 
  RemObjects.Elements.Cirrus;

type
  MakeEverythingPublic = public class(Attribute, RemObjects.Elements.Cirrus.ITypeInterfaceDecorator)
  private
  protected
  public
    method HandleInterface(Services: IServices; aType: ITypeDefinition);
  end;
  
implementation

method MakeEverythingPublic.HandleInterface(Services: IServices; aType: ITypeDefinition);
begin
  aType.Visibility := Visibility.Public;
end;

end.

Ie create a new class library, add an aspect class that makes the type public and reference it via:

[assembly:ClassLibrary23.MakeEverythingPublic]