未做类的公共共享code在C#项目之间 [英] Sharing code in C# between projects without making classes public

查看:211
本文介绍了未做类的公共共享code在C#项目之间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个C#库,有很多内部功能只露出几个公共类和接口。我想几个项目之间共享这个code和每一个项目可能需要延长的内部类与子类。

I have a C# library with lots of internal functionality exposing only a few public classes and interfaces. I would like to share this code between several projects, and each project may need to extend the internal classes with subclasses.

我不喜欢做所有这些类公众,以创造一个公共库的想法。我认为这暴露了他们太多轻松反编译,并打破了设计。

I don't like the idea of making all these classes public in order to create a common library. I think it exposes them too much to easy decompilation and break the design.

是唯一真正的选择要创建的源$ C ​​$ C副本,并保持项目之间同步这些文件?或者是有一些方法可以让我分享code,仍然可以得到每个项目只露出几个目的的公共接口和类?

Is the only real option to create a copy of the source code and keep those files in sync between projects? Or is there some way I can share code and still get a single library for each project exposing only the few intended public interfaces and classes?

我在使用Visual Studio 2010。

I'm using Visual Studio 2010.

更新

感谢有关反编译和私人访问澄清。我想我可以考虑申请,通过混淆了几个输入库,都在一起,希望混淆甚至是他们的公共连接。

Thanks for the clarification regarding decompilation and "private" access. I think I could consider applying an obfuscator over several input libraries, all together, hopefully obfuscating even their public connections.

从设计的角度来看,好像答案是明确使用朋友集会。

From the design standpoint, seems like the answer is definitively to use friend assemblies.

推荐答案

您可能想看看这样的朋友组件:

You may want to look at doing friend assemblies:

<一个href="http://msdn.microsoft.com/en-us/library/0tke9fxk(v=vs.80).aspx">http://msdn.microsoft.com/en-us/library/0tke9fxk(v=vs.80).aspx

[assembly:InternalsVisibleTo("someassembly")]

这篇关于未做类的公共共享code在C#项目之间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆