scriptsharp icon indicating copy to clipboard operation
scriptsharp copied to clipboard

Interface in different namespace causes a silent build failure

Open DVaughan opened this issue 13 years ago • 4 comments

Thanks for this great project! Here's an issue I've stumbled across.

When implementing an interface on a partial class, if the interface resides in a different namespace than the class, the build silently fails.

Foo.cs:

using RootNamespace.Inner;

namespace RootNamespace { /* builds / //public sealed partial class Foo / Adding IBah doesn't build */ public sealed partial class Foo : IBah { } }

Foo.Advanced.cs:

namespace RootNamespace { public sealed partial class Foo { } }

IBah.cs:

namespace RootNamespace.Inner { public interface IBah { } }

DVaughan avatar Jun 16 '12 16:06 DVaughan

Try declaring both partials as implementing IBah.

nikhilk avatar Jun 16 '12 23:06 nikhilk

Ok that works. Thanks Nikhil.

While it's not a big deal, if you wanted to use partials and linked files across projects you may not want to share the interface. It sounds like an edge case, but perhaps not so much because the application I'm building takes this approach. It is an SPA with one page for the 'main' application and another page that is a slimmed-down set of views for unauthenticated users. It uses linked files.

Cheers, Daniel

DVaughan avatar Jun 17 '12 05:06 DVaughan

I think I understand your scenario. Its clearly a bug, but wanted to send you a workaround, in case it helped unblock you.

Potentially, there is a way to share code using a helper class, rather than partials off of the same class?

nikhilk avatar Jun 17 '12 22:06 nikhilk

Thanks Nikhil, I appreciate you getting back to me so fast with a work around.

Cheers, Daniel

DVaughan avatar Jun 18 '12 08:06 DVaughan