-
Notifications
You must be signed in to change notification settings - Fork 0
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
using System; | ||
using NHibernate.Cache; | ||
using NHibernate.Util; | ||
|
||
namespace NHibernate.Cfg.Loquacious | ||
{ | ||
public interface ICacheConfiguration | ||
|
@@ -17,6 +20,18 @@ public interface ICacheConfigurationProperties | |
string RegionsPrefix { set; } | ||
int DefaultExpiration { set; } | ||
void Provider<TProvider>() where TProvider : ICacheProvider; | ||
void QueryCache<TFactory>() where TFactory : IQueryCacheFactory; | ||
[Obsolete("This method is invalid and should not be used. Use the QueryCacheFactory extension method instead.", true)] | ||
void QueryCache<TFactory>() where TFactory : IQueryCache; | ||
} | ||
|
||
// 6.0 TODO: merge into ICacheConfigurationProperties | ||
public static class CacheConfigurationPropertiesExtensions | ||
{ | ||
public static void QueryCacheFactory<TFactory>(this ICacheConfigurationProperties config) where TFactory : IQueryCacheFactory | ||
{ | ||
ReflectHelper | ||
.CastOrThrow<CacheConfigurationProperties>(config, "Setting the query cache factory with Loquacious") | ||
.QueryCacheFactory<TFactory>(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.) |
||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
using NHibernate.Cache; | ||
|
||
namespace NHibernate.Cfg.Loquacious | ||
{ | ||
public interface IQueryCacheConfiguration | ||
{ | ||
ICacheConfiguration Through<TFactory>() where TFactory : IQueryCacheFactory; | ||
// 6.0 TODO: enable constraint | ||
ICacheConfiguration Through<TFactory>(); // where TFactory : IQueryCacheFactory; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. 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. |
||
} | ||
} |
There was a problem hiding this comment.
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.