Skip to content

Upgrading to Unity.Abstractions v5.x #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Brains opened this issue Mar 21, 2020 · 14 comments
Closed

Upgrading to Unity.Abstractions v5.x #1

Brains opened this issue Mar 21, 2020 · 14 comments

Comments

@Brains
Copy link

Brains commented Mar 21, 2020

Can't use your library with Unity.Abstractions v5.x because of

Upgrading Unity Container (Changelog)
The public key token of the assembly has changed, so you may need to remove redundant assembly bindings from config files. For example: This binding will now be ineffective, and can be removed:

      <dependentAssembly>
        <assemblyIdentity name="Unity.Abstractions" publicKeyToken="6d32ff45e0ccc69f" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-3.3.0.0" newVersion="3.3.0.0" />
      </dependentAssembly>

Note:

  • The old public key token value is 6d32ff45e0ccc69f
  • The new public key token is 489b6accfaf20ef0

So your library references Unity.Abstractions 3.3.0.0 with old token while my project references recent Unity.Container which in turn references Unity.Abstractions with new token. Hence, nuget considers two versions of the same library as different assemblies and requires both. However, can't install both since it is single nuget package.

Can you please update your library with Unity.Abstractions of new token?

@Brains
Copy link
Author

Brains commented Mar 21, 2020

@Brains
Copy link
Author

Brains commented Mar 21, 2020

No actually it compiles if I revert packages to

<package id="Unity.Abstractions" version="3.3.0" targetFramework="net462" />
<package id="Unity.Container" version="5.8.6" targetFramework="net462" />

but it breaks RegisterFactory extension method and few other stuff

I guess updating the library with recent packages is more proper way but not sure.

@Brains
Copy link
Author

Brains commented Mar 21, 2020

Actually, things might appear more complicated

Upgrading to Unity.Abstractions 4.0.0.0
A few breaking changes have been made.
For more information see How to upgrade to v4+ #97

@mykolav
Copy link
Owner

mykolav commented Mar 26, 2020

Hi @Brains

Thank you for taking time to investigate and the detailed report.

A colleague at work ran into a similar problem with Unity.Abstractions v5.x
As you already discovered, there were breaking changes introduced to Unity, so I'll need to take a closer look to figure out how to update.

From a cursory glance, it seems there is a lot of useful info in the discussion you linked to.

Unfortunately, at the moment, I cannot provide an estimate of how long it's going to take me to update the code, but I'll try to not make it too long.

@Brains
Copy link
Author

Brains commented Mar 27, 2020

Sure, thanks.

@tomzorz
Copy link

tomzorz commented Jun 18, 2020

Hey @mykolav - any update on this? We've just ran into the same issue. If you're taking PRs I can probably take a weekend to try and fix it.

@mykolav
Copy link
Owner

mykolav commented Jun 18, 2020

@tomzorz
Sorry, no updates from me, have been snowed under a bit.

I'd sure be glad to take a PR.
Do you use the ParameterizedAutoFactory.Unity5 nuget package?

@mykolav
Copy link
Owner

mykolav commented Jun 18, 2020

@tomzorz

If you decide to delve into it, please notice the ParameterizedAutoFactory.Unity4 and ParameterizedAutoFactory.Unity5 projects include files from the ParameterizedAutoFactory.Unity folder in the following way:

  <ItemGroup>
    <Compile Include="..\ParameterizedAutoFactory.Unity\ParameterizedAutoFactoryBuilderStrategy.cs" Link="ParameterizedAutoFactoryBuilderStrategy.cs" />
    <Compile Include="..\ParameterizedAutoFactory.Unity\ParameterizedAutoFactoryExtension.cs" Link="ParameterizedAutoFactoryExtension.cs" />
  </ItemGroup>

It can potentially be somewhat confusing. But I didn't come up with a better way to share the code.

@tomzorz
Copy link

tomzorz commented Jun 18, 2020

We wanted to use the v5 one, but then I got yelled at by error messages :) Thanks for the heads-up, I'll probably take a look in the coming weeks.

@mykolav
Copy link
Owner

mykolav commented Aug 25, 2020

Hello @Brains and @tomzorz

I upgraded the extension's dependencies to Unity.Abstractions 4.0.0,
and expect it to work with any version of Unity.Abstractions >= 4.0.0.

Please give the updated package a try and let me know whether it works for you.

@mykolav
Copy link
Owner

mykolav commented Aug 25, 2020

Hello @Brains and @tomzorz

As it turns out, ConstructorProcessor that this extension uses changed between Unity 5.9.0 and Unity 5.11.1
I had to upload another nuget package compatible with Unity >= 5.11.1

https://www.nuget.org/packages/ParameterizedAutoFactory.Unity5/0.0.11

@Brains
Copy link
Author

Brains commented Sep 1, 2020

@mykolav Sorry for 7 days delay, was very busy at work.
Tried the latests updated package, works like a charm. Finally, I can replace endless Override.Parameter in my code.
Thank you very much for your efforts and for updated package as well.

Offtopic: I am going to add support for FSharp.Core.FSharpFunc along with System.Func since do most injections into F# projects. Will do pull request soon, if the idea is not super complicated.

@mykolav
Copy link
Owner

mykolav commented Sep 2, 2020

@Brains Great to hear it!

Speaking of the PR. Thanks for suggesting it!
I like the idea in general.

But I'd really like this extension to have Unity as the only dependency.
So if you weren't going to introduce a dependency on FSharp.Core.dll, then I can't think of any other concerns.
On the other hand, if support of FSharpFunc means a dependency on FSharp.Core.dll, let's talk about it in more details first.

@Brains
Copy link
Author

Brains commented Sep 3, 2020

Sure, I will return later with pull request and will discuss.

Actually, I am totally ok without merging into your repo back, FSharpFunc is quite specific stuff, not much people are going to use it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants