microsoft / winforms-designer-extensibility

MIT License
56 stars 13 forks source link

How to avoid conditional compilation when using Designer attribute? #37

Open valiahmetovv opened 4 months ago

valiahmetovv commented 4 months ago

He @KlausLoeffelmann

I have a component which requires both net462 and .NET design time support, so i have created stub RootDesigners for net462 and .NET, but i cant apply them without conditionall compilation

The following line seems to work only for net462 environment. [Designer("Server.CompoundObjectRootDesigner", typeof(IRootDesigner)), ToolboxItem(false)]

In .NET environment it leads to the following error: image

So for .NET i have to use this, but it will not work in net462 environment: [Designer("CompoundObjectRootDesigner", typeof(IRootDesigner)), ToolboxItem(false)]

Is it possible to support same convention for both targets? Or is conditional compilation the recommended approach:

if NET462

[Designer("Server.CompoundObjectRootDesigner", typeof(IRootDesigner)), ToolboxItem(false)]

else

[Designer("CompoundObjectRootDesigner", typeof(IRootDesigner)), ToolboxItem(false)]

endif

Thanks