Question

I have a question the answer i cant find for. I have solution with Module projects. There are the same class types in each. My purpose is to make them all partial and define partial method. I tried to use the same namespace and the same Project namespace, but it doesnt work. Can somebody give me an advice how to do that? Thanks so much. Upd. any workaround (in there is no straight way) will be appreciated

Was it helpful?

Solution 2

Unfortunately, you cannot have a partial class span multiple projects. Partial classes are only combined within individual projects/assemblies.

See this StackOverflow post for more information and some possible workarounds (e.g. inheritance and extension methods).

OTHER TIPS

Partial classes are compiler magic. In other words no matter you have partial class, while compiling compiler will combine all partial classes into single unit.

Since this all happens separately for each assembly it is not possible.

Very close workaround which I can see is Inheritance.

It will not work out of the box because it would mean that the same class will live in two separate assemblies (metafiles).

Workaround: you can try to merge one project into another on Pre-Build event

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top