Expanding on /internalize functionality #133

Closed
opened 2013-05-01 08:21:16 -05:00 by Stevie-O · 2 comments
Stevie-O commented 2013-05-01 08:21:16 -05:00 (Migrated from github.com)

This isn't an issue, per se, but I couldn't find a better place to put it.

I'm working on a project that involves merging several individual assemblies into a single DLL.
I ran into two problems:

  1. Internalization was pretty braindead: Internalize all types not in the primary assembly.

    This created a problem because I had some things like this:

    MainAssembly:
        public class Foo : Bar
        {
            public Baz baz;
        }
    
    OtherAssembly:
        public class Bar {}
        public class Baz {}
    

    The internalization of Bar and Baz created a mess with Foo.

  2. For various reasons, there were some public methods on Foo weren't appropriate to expose externally, but had to be public when everything was split across multiple assemblies due to various limitations.

    I needed a way to change those methods to 'internal' when they no longer needed to be used.

I created a fork for ILRepack here: https://github.com/Stevie-O/il-repack/commits/smartmerge

and added the following features:

  • Extended the /internalize exclude file syntax to support the following:
    • Inverted rules (if a type matches the regex, it will be internalized, even if it is in the "main" assembly)

    • Internalization of individual class members

      With a properly constructed line, individual members (properties, fields, methods, events) of a type may be changed to internal.

  • Automatically exclude types from internalization if they are exposed by another, non-internalized type somehow:
    • An exposed type exposes its base classes.
    • A public field exposes the field's type.
    • A public property exposes the property's type
    • A public method exposes the return type and all parameters' types.
    • A public event exposes the delegate type for the event's handlers.
This isn't an issue, per se, but I couldn't find a better place to put it. I'm working on a project that involves merging several individual assemblies into a single DLL. I ran into two problems: 1. Internalization was pretty braindead: Internalize all types not in the primary assembly. This created a problem because I had some things like this: ``` MainAssembly: public class Foo : Bar { public Baz baz; } OtherAssembly: public class Bar {} public class Baz {} ``` The internalization of Bar and Baz created a mess with Foo. 2. For various reasons, there were some public methods on Foo weren't appropriate to expose externally, but had to be public when everything was split across multiple assemblies due to various limitations. I needed a way to change those methods to 'internal' when they no longer needed to be used. I created a fork for ILRepack here: https://github.com/Stevie-O/il-repack/commits/smartmerge and added the following features: - Extended the /internalize exclude file syntax to support the following: - Inverted rules (if a type matches the regex, it will be internalized, even if it is in the "main" assembly) - Internalization of individual class members With a properly constructed line, individual members (properties, fields, methods, events) of a type may be changed to internal. - Automatically exclude types from internalization if they are exposed by another, non-internalized type somehow: - An exposed type exposes its base classes. - A public field exposes the field's type. - A public property exposes the property's type - A public method exposes the return type and all parameters' types. - A public event exposes the delegate type for the event's handlers.
jbevain commented 2013-05-01 10:01:49 -05:00 (Migrated from github.com)

Well, a better place would be the ILRepack project :)

Well, a better place would be the ILRepack project :)
Stevie-O commented 2013-05-01 13:49:57 -05:00 (Migrated from github.com)

Gah, I was in the wrong freaking window! I'm sorry, I can't believe I did that.

Gah, I was in the wrong freaking window! I'm sorry, I can't believe I did that.
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-jbevain/cecil#133
No description provided.