-
Notifications
You must be signed in to change notification settings - Fork 935
Description
Since the latest Visual Studio version (17.13)/C# version some of our code started to fail at runtime.
The problem is that Microsoft implemeted the "First-class Span types" language feature (https://github.com/dotnet/csharplang/blob/main/proposals/first-class-span-types.md)
I'm using the LangVersion=preview settings (because of the "field" keyword)
For example we have the following code:
var ids = new Guid[] { guid1, guid2... };
foreach (var r in session.Query<MyClass>().Where(x => ids.Contains(x.Id)))
{
...
}
Earlier (before 11.02.2025) this code worked, but now it throws the following exception:
NHibernate.HibernateException
HResult=0x80131500
Message=Evaluation failure on op_Implicit(value(System.Guid[]))
Source=NHibernate
StackTrace:
at NHibernate.Linq.Visitors.NhPartialEvaluatingExpressionVisitor.Visit(Expression expression)
....
Inner Exception 1:
NotSupportedException: Specified method is not supported.
Because earlier the predicate expression in the Where method was calling the Enumerable.Contains
extension method, but now it calls the MemoryExtensions.Contains
method.
There is a workaround:
var ids = new Guid[] { guid1, guid2... };
foreach (var r in session.Query<MyClass>().Where(x => ((IEnumerable<Guid>)ids).Contains(x.Id)))
{
...
}
but it needs to change our code everywhere. And hard to find every places since there is no build error, only a runtime exception.