Inner class becomes closed when combined with tools such as ILMerge or SmartAssembly?

Recently, I have discovered several tools that allow you to combine the .Net library with a Windows application.

Now the real question is how to change the behavior of the library,

  1. The inner class is internal to the library? Or it becomes internal to the application with which it was merged?
  2. Is it likely that the library will not work properly?

Extension question:

  1. Is not it better to at the confluence of the internal assembly was made closed so that it was impossible to use the application in which they are combined?
+4
source share
4 answers

Classes can not be closed unless they are embedded.

But consider this: if you merge assemblies A and B, you have to compile them before the merger. When they were compiled, internal methods of each were not available for the other. Therefore, in the combined code may be a method which causes internal methods other assembly.

Is not it better that by combining the internal assembly, it was necessary to make sensitive to this application does not use the application in which they were combined?

How will it work? If a top-level type was closed, he would not be available for any other types. So you can not identify the particular types (if they are not enclosed in a different type).

Assume that in the assembly A is C, and D classes, where C is the internal, and D is some method of class C. When a class C becomes closed (in some versions hypothetical CTS, where possible), a class D interrupted.

+6
source

top-level types, which are not nested in other types may have only internal or publicly accessible. default accessibility is internal to these types.

From MSDN link

1 The inner class is inside the library? or becomes an internal application, was merged with?

He remains internal to the application.

2 Is there any chance that the library does not work properly?

Technically this is possible. Assume that the class A is internal to App, as well as for one of lib (with the same namespace). Before the merger will have no problems. After the merger, it becomes a problem to resolve ambiguous references.

How does it work (SmartAssemply / ILMerger), is another problem (which I do not know)? They can provide information about the error, but maybe not. They may choose to convert or might not.

Isn't it better that when you merge the internal assembly, you need to make it confidential so that this application is not used by the application into which they were combined?

As indicated, the top-level types can not be private / protected.

+2
source

MSDN is quite clear:

Internal types or members are available only within the file in the same assembly ...

Since you have combined them into a single assembly, inner classes are available for all files in the joint assembly.

0
source

ILMerge can split the library, although this is only the case if the library is poorly designed.

Breakage will not have anything to do with the internal . But if the reflection is used to verify that the assembly is then loaded or looking in a particular type of assembly, the results will change.

I'd be much more concerned about the consequences of the merger with Security Attributes Code Access Security, than internal . But essentially, do not join the assembly to be carried out at different levels of trust.

0
source

All Articles