Skip to content

fixup! IQueryCache constraint should be an IQueryCacheFactory constraint #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

Merged
merged 1 commit into from
Sep 17, 2018

Conversation

fredericDelaporte
Copy link

Reduce breaking changes and test more thoroughly

Reduce breaking changes and test more thoroughly
throw new InvalidOperationException("This method is invalid and should not be used. Use QueryCacheFactory method instead.");
}

public void QueryCacheFactory<TFactory>() where TFactory : IQueryCacheFactory
Copy link
Author

Choose a reason for hiding this comment

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

The general wording for method setting factory seems to include Factory as a suffix to the method name. So here we can dodge the overload trouble by renaming the method.

{
ReflectHelper
.CastOrThrow<CacheConfigurationProperties>(config, "Setting the query cache factory with Loquacious")
.QueryCacheFactory<TFactory>();
Copy link
Author

Choose a reason for hiding this comment

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

@InlineAsm, that is how we handle simulating addition of an interface method: only the NHibernate implementation will be supported, so long for external implementations. This is a valid stance for things not expected to be implemented outside of NHibernate itself, which is the case for the loquacious configuration. (It is likely not even injectable with custom implementations anyway.)

(For cases which are expected to be implemented outside of NHibernate, we additionally introduce for the cast a brand new interface till the next major version, to be implemented by who wants to support the feature.)

namespace NHibernate.Cfg.Loquacious
{
public interface IQueryCacheConfiguration
{
ICacheConfiguration Through<TFactory>() where TFactory : IQueryCacheFactory;
// 6.0 TODO: enable constraint
ICacheConfiguration Through<TFactory>(); // where TFactory : IQueryCacheFactory;
Copy link
Author

Choose a reason for hiding this comment

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

Removing a constraint breaks compilation on implementing classes, at least for implicit implementations. I guess it is not a binary breaking change though, I do not think the IL cares for constraint.
This case is unfortunately not documented in the breaking change guidelines of core fx.

Since this interface is not supposed to be implemented by anything outside of NHibernate code itself, I think it is acceptable in a minor release.

@InlineAsm InlineAsm merged commit 146171d into InlineAsm:master Sep 17, 2018
@fredericDelaporte fredericDelaporte deleted the loquaciousQueryCache branch September 18, 2018 08:08
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

Successfully merging this pull request may close these issues.

2 participants