Skip to content
This repository has been archived by the owner on Sep 16, 2023. It is now read-only.

BoDiReplacement

Craig Fowler edited this page Feb 13, 2018 · 7 revisions

FlexDi publishes a 'BoDi compatibility' NugGet package. The package provides a BoDi.dll assembly, including the following types which you would expect to find in the original BoDi assembly. These types expose the same public API as their counterparts in the original BoDi, allowing it to be used as a drop-in replacement. You may wish to read the list of FlexDi versions, matched with the supported BoDi versions.

  • BoDi.ObjectContainerException
  • BoDi.IObjectContainer
  • BoDi.ObjectContainer
  • BoDi.BoDiConfigurationSection
  • BoDi.ContainerRegistrationCollection
  • BoDi.ContainerRegistrationConfigElement

Internally this ObjectContainer implementation is an adapter class. It's purpose is to:

  • Wrap a FlexDi container
  • Expose the exact same public API as the original ObjectContainer class
  • Set up the FlexDi configuration to match BoDi's behaviour
  • Redirect calls to its public methods into the wrapped container
  • Transform any exceptions caught, so that any expected exceptions raise BoDi's own BoDi.ObjectContainerException

Differences to BoDi & limitations

There are a few known differences/limitations when using FlexDi's BoDi compatibility assembly. In short, if you are using BoDi as a DLL with .NET framework then you need not be concerned - you will not encounter any breaking differences.

BoDi compatibility only available in DLL form

One of BoDi's features is that it is available in a single source file. The BoDi.Embedded NuGet package adds BoDi to a project as a .cs file, to be compiled into your own assembly.

FlexDi's compatibility package does not support this type of inclusion. It only provides an assembly.

No 'limited runtime' support

BoDi includes a build profile named Limited runtime. This excludes references to a number of .NET framework features which would not be available in a 'limited' .NET runtime. BoDi's code does not make it precisely clear which environment this is intended to support but it is presumed that it is intended to support runtimes such as .NET Compact Framework.

At present this is not supported, although issue #23 exists to re-evaluate this decision and to possibly add support for one or more versions of the netstandard runtime.

Inner exceptions will be populated with FlexDi exceptions

The FlexDi BoDi adapter raises exceptions for all of the same reasons as the original BoDi object container. When exceptions are raised they will be of the BoDi exception type BoDi.ObjectContainerException.

The minor difference you may observe is that these exceptions will carry the FlexDi exceptions which caused them as inner exceptions. The 'shape' of the stack traces will also differ from the original FlexDi.

This is not considered a breaking change; no client code should rely upon the inner exception or stack traces of non-public methods.

Exception messages may differ

The human-readable messages associated with BoDi.ObjectContainerException raised by the FlexDi BoDi adapter may differ from those which the original BoDi raises. In general though, exception messages are the same or closely similar to the original BoDi exceptions.

This is not considered a breaking change; no client code should rely upon the exception message.

Bugfix: Circular dependencies are detected in dynamic resolution scenarios

In scenarios like the one shown in the integration test ShouldThrowExceptionForDynamicCircuarDepenencies, the original BoDi would raise StackOverflowException instead of detecting the circular dependency and raising an object container exception.

This was resolved as issue #7, so that a container exception is thrown indicating the circular dependency. This is not considered a breaking change. It is implausible to think that any code depends upon a stack overflow.