Skip to content

Upgrade to NH 5.2.0 #56

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

Merged
merged 3 commits into from
Dec 5, 2018

Conversation

fredericDelaporte
Copy link
Member

@fredericDelaporte fredericDelaporte commented Nov 27, 2018

In order to benefit from the CacheBase (nhibernate/nhibernate-core#1777), upgrade to NHibernate 5.2.0.

This change requires .Net Core 2.1 SDK
@@ -28,259 +28,6 @@
registerPlugin:
- type: AsyncGenerator.Core.Plugins.EmptyRegionRemover
assemblyName: AsyncGenerator.Core
- filePath: CoreMemoryCache\NHibernate.Caches.CoreMemoryCache\NHibernate.Caches.CoreMemoryCache.csproj
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most caches do no more need an async generation, as their cache implementation do not support async. The inherited default async handling is then suitable for them.

/// <summary>
/// Pluggable cache implementation using <see cref="IDistributedCache"/> implementations.
/// </summary>
public partial class CoreDistributedCache : ICache
public class CoreDistributedCache : CoreDistributedCacheBase,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For avoiding binary breaking changes, I only see this ugly solution.

Removing a non-virtual method for a virtual inherited one is a breaking change, as some caller may try to call it, as explained here:

Adding virtual to a member
While this change would often work without breaking too many scenarios because C# compiler tends to emit callvirt IL instructions to call non-virtual methods (callvirt performs a null check, while a normal call won't), we can't rely on it. C# is not the only language we target and the C# compiler increasingly tries to optimize callvirt to a normal call whenever the target method is non-virtual and the this is provably not null (such as a method accessed through the ?. null propagation operator). Making a method virtual would mean that consumer code would often end up calling it non-virtually.

And we are in a worst case: we have removed many of these members (all the async ones for all the other caches), counting on virtual inherited ones for replacing them.

Moreover the old void Lock cannot coexist with object Lock in the same class, so we anyway need an "intermediate" class.

public class CoreDistributedCache : CoreDistributedCacheBase,
#pragma warning disable 618
ICache
#pragma warning restore 618
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do not need it for avoiding a binary breaking change, but it avoids having to rewrite all the XML comments.

@fredericDelaporte fredericDelaporte changed the title WIP - Upgrade to NH 5.2.0 Upgrade to NH 5.2.0 Dec 3, 2018
@fredericDelaporte
Copy link
Member Author

I intend to merge this soon, in order to allow other pending PR to be done.

@fredericDelaporte fredericDelaporte merged commit 024bac4 into nhibernate:master Dec 5, 2018
@fredericDelaporte fredericDelaporte deleted the NH5.2.0 branch December 5, 2018 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant