Skip to content
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

.NET Standard 2.0 support #221

Open
12 of 13 tasks
MichaCo opened this issue Mar 10, 2018 · 18 comments
Open
12 of 13 tasks

.NET Standard 2.0 support #221

MichaCo opened this issue Mar 10, 2018 · 18 comments

Comments

@MichaCo
Copy link
Owner

MichaCo commented Mar 10, 2018

:update:
Version 1.2.0 of CacheManager was released with the 1.x branch targeting .NetStandard 2.0, including the change to the new redis client version.

Breaking Change

I will drop any lower netstandard target in packages which had .netstandard1.x.
Also, .NET4.0 support will be removed.
Because this is a bigger change, this will be a major version release (2.0), together with upgrading Stackexchange.Redis to 2.x, see #251.

Changes

  • Setup Unit Tests to run against netstandard1.x and netstandard2.x as code paths will be different
  • Add nestandard2.0 to CM.Core
    • Binary Serialization supported in netstandard2.0 but System.Type will not be supported... => no support for Binary Serializer in netstandard2.0
    • Support "old" configuration system by using System.Configuration.ConfigurationManager
    • Support Performance Counters
      (package is currently in preview and breaks other projects because of mismatching deps)
  • Multitarget System.Runtime.Caching based cache handle with netstandard2.0
    • differences of this cache on nestandard2.0 vs full framework seem to be accepted by MS and will be documented
  • Changing all (appropriate) sub packages to target netstandard2.0, too and change deps versions
    • Json package keeps referencing Newtonsoft.Json 9.0.1 for old targets. netstandard2.0 will require 11.0.1 though
    • Update MS.Bond deps to 7.0.1 (except .NET4.0 which is supported till Bond 6.0 only)
    • Update Protobuf-net reference to 2.3.7 which also has a netstandard2.0 target now (although it still references older corefx packages)
    • CM Logging and Configuration additions to the MS packages will reference MS' version 2.0.0 as minimal version for netstandard2.0 target.
    • Use Redis package with netstandard2.0 target (doesn't exist yet)
  • Update readme with new targets
  • Maybe integrated MS DI as a core dependency and replace the setup code with actually using DI.
@MichaCo MichaCo added this to the 1.2.0 milestone Mar 10, 2018
@MichaCo MichaCo self-assigned this Mar 10, 2018
MichaCo added a commit that referenced this issue Mar 10, 2018
…ETStandard2.0 target.

More if deffing and workarounds for ConfigurationManager in tests... #221
MichaCo added a commit that referenced this issue Mar 10, 2018
@bbqchickenrobot
Copy link

any news on this? or more poignantly, any where to get the nuget package(s)? :)

@MichaCo
Copy link
Owner Author

MichaCo commented Apr 15, 2018

@bbqchickenrobot you can get the beta packages from the myget feed and give it a try until I release it.
I have to do more testing and maybe waiting for 2.1...
In case you want to use System.Runtime.Caching on .NET Core, be aware that this is not released by MS yet (I'm using 4.5.0-preview1 atm)...

@maldworth
Copy link

So if it looks like system.type will not have binary serialization support, does that mean we will just have to use .WithJsonSerializer() if we are targeting .netstandard2.0?

@MichaCo
Copy link
Owner Author

MichaCo commented Apr 24, 2018

@maldworth You can use any other serializer wich supports .NET Core

@MichaCo MichaCo mentioned this issue Nov 15, 2018
MichaCo added a commit that referenced this issue Nov 15, 2018
Change StackExchangeRedis reference to 2.x #251
MichaCo added a commit that referenced this issue Nov 15, 2018
@MichaCo
Copy link
Owner Author

MichaCo commented Nov 15, 2018

Main changes to target netstandard 2.0 are done
I decided to drop most old targets in the process. E.g. .NET 4.0 will not be available anymore and .netstandard1.x not either.
Most of the packages now require .NET461 | netstandard2.0
This allows a lot simplifications in code. I was able to remove almost all ifdefs, which makes testing a lot easier...

I'm not really happy of how some DI things work right now with the DI extension package, so I might actually rework that quite a bit.
The idea would be to integrated the Microsoft.Extensions.Di into the CacheManager.Core package.
That would become a primary dependency everywhere though.
I then would replace my custom initialization via reflection with actually using the DI.
I might implement named CacheManager instances/configuartion, too.
The existing exposed functionality of CacheFactory should still work though by hiding the DI container...

@gautelo
Copy link

gautelo commented Nov 23, 2018

Very happy to see this effort! :)

@MichaCo
Copy link
Owner Author

MichaCo commented Dec 6, 2018

I decided to re-release 1.1.2 with just the Redis upgarde and some .NET Standard 2.0 support additions.
That's version 1.2.0 which has just been released!

There are no new features or ported functionality to .NETStandard 2.0 in that CacheManager 1.2.0 release. It is exactly the same code as 1.1.2 but with those 2 additions.

Hope that helps!

@Miggleness
Copy link

Need help with anything?

@asamaha1
Copy link

Hello, any news on when the 2.x version will be released ? Thank you.

@alandillon
Copy link

Any updates?

@amirxnz
Copy link

amirxnz commented Aug 12, 2019

Hi,
We really like CacheManager and would like to continue using it in the future. We are in the process of migrating to .net core and this is something that we obviously need to take into consideration. Understood its an open source project and nobody owes anyone anything.
We would still kindly ask any update of whether it is still on your personal roadmap?

Thanks!

@MichaCo
Copy link
Owner Author

MichaCo commented Aug 12, 2019

@amirxnz you can totally use the current release with .NET Core and ASP.NET Core, I'm using it for the past 2 years in production.

CM Version 1.2.0 targets .netstandard 2.0, which means you can use it with everything .NET Core and there shouldn't really be any issues... Otherwise, let me know.

@amirxnz
Copy link

amirxnz commented Aug 12, 2019

Hi,
Thank you for the answer.

We are having some trouble with the CacheManager.SystemRuntimeCaching?
It looks like 1.2 is only for framework 4.5? (https://www.nuget.org/packages/CacheManager.SystemRuntimeCaching)

It is our understanding that this package is needed if we want to keep the results locally in addition to having a redis backplane? Is this correct?

Thanks

@MichaCo
Copy link
Owner Author

MichaCo commented Aug 12, 2019

System.Runtime.Caching has been back ported to .NET Core with some minor breaking changes.
The CacheManager package for that one is not released yet, that's correct.

As an alternative, you can use CM with Microsoft.Extensions.Caching instead or just the simple dictionary cache from the CacheManager.Core package. Both work cross plat.

@amirxnz
Copy link

amirxnz commented Aug 13, 2019

Is my understanding correct that iff we use the simple "WithDictionaryHandle()" that means that we need to make sure there are no concurrency issues?
However "CM with Microsoft.Extensions.Caching" is already thread-safe since it uses a concurrent dictionary?
Are there any downsides to using Microsoft.Extensions.Caching?

Thanks again for all your support, we really appreciate it

@MichaCo
Copy link
Owner Author

MichaCo commented Aug 14, 2019

Hey @amirxnz, no, the simple CM Dictionary handle also uses a ConcurrentDictionary internally and is supposed to be thread-safe.
The main difference to Microsoft.Extensions.Caching is that CM Dictionary is faster because it doesn't implement a complicated CacheItem policy thing. And CM Dictionary checks for expired items more frequently.
Microsoft.Extensions.Caching does run a check every 2 minutes or so, CM Dictionary does it every 10sec I think.

So, just choose the one you think works best for you.

@amirxnz
Copy link

amirxnz commented Aug 15, 2019

Ok Thanks!
I think we'll start with CM Dictionary and see how that treats us.

@dengyangxi
Copy link

dengyangxi commented Oct 25, 2020

ask for help

https://github.com/MichaCo/CacheManager/issues/323

I have two projects operating a redis.
One is the . Net framework and the other is the . Net CORE

This causes the. Net framework project to write to a cache . . Net core project that cannot be serialized

But. Net core does not have withbinaryserializer. How can I replace it ?

`
#if !NETSTANDARD2

/// <summary>
/// Configures a <see cref="BinaryCacheSerializer"/> to be used for serialization and deserialization.
/// </summary>
/// <returns>The builder part.</returns>
public ConfigurationBuilderCachePart WithBinarySerializer()
{
    Configuration.SerializerType = typeof(BinaryCacheSerializer);
    return this;
}

/// <summary>
/// Configures a <see cref="BinaryCacheSerializer"/> to be used for serialization and deserialization.
/// </summary>
/// <param name="serializationFormatter">The <see cref="BinaryFormatter"/> for serialization.</param>
/// <param name="deserializationFormatter">The <see cref="BinaryFormatter"/> for deserialization.</param>
/// <returns>The builder part.</returns>
public ConfigurationBuilderCachePart WithBinarySerializer(BinaryFormatter serializationFormatter, BinaryFormatter deserializationFormatter)
{
    Configuration.SerializerType = typeof(BinaryCacheSerializer);
    Configuration.SerializerTypeArguments = new object[] { serializationFormatter, deserializationFormatter };
    return this;
}

#endif
`

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

No branches or pull requests

9 participants