Iron Rebuilder is a set of tools for .net with the goal of using attributes to reduce the amount of boiler plate code and to allow safer, less buggy code.
Overview
A tool that runs post-build to replace references to the IronRebuilderAttributes’s attributes with their desired effect. See Current Attributes and Planned Attributes for more information on individual attributes.
The exe is run IronRebuilder –f “”
Or
The exe is run IronRebuilder –f “,”
A string name can be added with -s <file.snk>
Note that multiple files can be specified at once, allowing you to use the GenericEnum in one assembly that calls into another and relies on GenericEnum. For example
If assembly 1 has public void DoSomething<[GenericEnum] T>… And you wish to call it from assembly 2’s method public void DoSometingMore<[GenericEnum] T> { DoSomething … } You will need to rebuild them together, as the complier won’t know that T is an Enum in DoSomethingMore otherwise.
This DLL contains all the iron attributes that the IronRebuilder uses. This assembly does not need to be shipped (and can have copy-local set to false) if the IronRebuilder is run after complication, or if the IronRebuilderService is used with all of the replacements.
This DLL contains the guts of the IronRebuilder. It provides code replacers for all of the attributes in IronAttributes.dll
Allows generic parameters to extend Enum. To work, the generic parameter must either not extend anything or must extend struct (recommended because of the note below)
Example:
Class1<[GenericEnum]TEnum> where TEnum : struct { … }
Produces a class equivalent to the code below, if it was compliable Class1 where TEnum : Enum { … }
Note: Since the replacements are run after the code is compiled, the compiler will allow misuse of the generic parameter within the produced artifact. IronRebuilderService.dll will detect and report theses errors, and IronRebuilder.exe will fail upon this detection outputting the error to the console.
Allows internal methods to also be protected. Unlike protected internal in C#, this would require the caller/user to be both able to access protected and internal mthods.
Adds a null check and a throw for null argurments
Example: public void DoSomething([NotNull] value) { … } Becomes public void DoSomething(value) { if (value == null) { throw new ArgumentNullException(“value); } … }
- Include the IronRebuilderAttributes nuget in your project (you can change copy local to false for the dll)
- Include the IronRebuilder nuget in your project
- Add a post-build to call iron rebuilder in your project’s .csproj. Note that this must run before any nuget packing or the packed nuget will not be correct
No, since IronRebuilder.exe (and the IronRebuilderService.dll if all replacements are used) removes references to all of the attributes in IronRebuilderAttributes.dll, it is not necessary to ship IronRebuilderAttributes.dll with your code. For IronRebuilder.exe and IronRebuilderService.dll they do not need to be shipped, for the same reason you don’t need to ship your compiler with your code.
Both, although some of the errors, will only appear in the console and not in the errors list.
Look in the Console tab. Either Iron rebuilder, or Visual Studio detected an error, that Visual Studio is not used to seeing.
Yes, using the IronAttributesService assembly you can add your own replacements
Use the -s option with IronRebuilder.exe and specify the file
###When can I sign my assembly? After the rebuild
Can a project (Project1) have a project reference on an project (Project2) that uses IronRebuilder without using IronRebuilder in Project 1###
Yes, but there can be some odd behaviour. When first building you may see the error in the next question or similar. Attempting to build again will have the correct error in the output of the build console
Look in the console tab for the error. There is one known warning, below [1] that is known to sound scary but be ok once the errors are fixed. The error is caused by misuse of an item in the project that was rebuilt. One example of this is if you use a [GenericEnum] and have a generic parameter that is not an enum.
Warning IDE0006 Error encountered while loading the project. Some project features, such as full solution analysis for the failed project and projects that depend on it, have been disabled.