hyankov
hyankov

Reputation: 4130

Upgrading Unity to 5.11

We have an old code which has

public override void PreBuildUp(IBuilderContext context)
{
  var type = context.OriginalBuildKey.Type;

Now it has to be

public override void PreBuildUp(ref BuilderContext context)
{

What's corresponding to OriginalBuildKey property in the context that is now of type BuilderContext? I can't figure it out.

Upvotes: 2

Views: 471

Answers (1)

Mark Burton
Mark Burton

Reputation: 151

I recently had the same issue trying to update AutoMoq-Unity5 to Unity 5.11.

Comparing the current version of BuilderContext.cs with the earlier 5.9 version I saw the change was

From

[DebuggerDisplay("Resolving: {OriginalBuildKey.Type},  Name: {OriginalBuildKey.Name}")]
    public class BuilderContext : IBuilderContext

To

    [DebuggerDisplay("Resolving: {Type},  Name: {Name}")]
    public struct BuilderContext : IResolveContext

So as you mentioned I changed my code from

        public override void PreBuildUp(IBuilderContext context)
        {

To use the BuilderContext by reference

        public override void PreBuildUp(ref BuilderContext context)
        {

And where I used OriginalBuildKey.Type I now have changed from

        private static Type GetTheTypeFromTheBuilderContext(IBuilderContext context)
        {
            return (context.OriginalBuildKey).Type;
        }

to

        private static Type GetTheTypeFromTheBuilderContext(IResolveContext context)
        {
            return context.Type;
        }

My unit tests are passing at that.

Upvotes: 5

Related Questions