IndexOutOfRangeException in CreateNavigationExpansionExpression(Expression sourceExpression, IEntityType entityType) / get_Chars(Int32 index) when EF class named "<>f__AnonymousType01Child" in 7.0.2 version
Hi, i am recived
---> System.IndexOutOfRangeException: Index was outside the bounds of the array.
at System.String.get_Chars(Int32 index)
at Microsoft.EntityFrameworkCore.Query.Internal.NavigationExpandingExpressionVisitor.CreateNavigationExpansionExpression(Expression sourceExpression, IEntityType entityType)
at Microsoft.EntityFrameworkCore.Query.Internal.NavigationExpandingExpressionVisitor.VisitExtension(Expression extensionExpression)
at Microsoft.EntityFrameworkCore.Query.Internal.NavigationExpandingExpressionVisitor.VisitMethodCall(MethodCallExpression methodCallExpression)
at Microsoft.EntityFrameworkCore.Query.Internal.NavigationExpandingExpressionVisitor.Expand(Expression query)
at Microsoft.EntityFrameworkCore.Query.QueryTranslationPreprocessor.Process(Expression query)
at Microsoft.EntcityFrameworkCore.Query.QueryCompilationContext.CreateQueryExecutor[TResult](Expression query)
at Microsoft.EntityFrameworkCore.Storage.Database.CompileQuery[TResult](Expression query, Boolean async)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.CompileQueryCore[TResult](IDatabase database, Expression query, IModel model, Boolean async)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass9_01.<Execute>b__0() at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQuery[TResult](Object cacheKey, Func1 compiler)
at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.Execute[TResult](Expression query)
at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryProvider.Execute[TResult](Expression expression)
at System.Linq.Queryable.Count[TSource](IQueryable`1 source)
when my EF Core class named '' "<>f__AnonymousType01Child" in 7.0.2 I am think issue in ShortName() implementation
This issue is lacking enough information for us to be able to fully understand what is happening. Please attach a small, runnable project or post a small, runnable code listing that reproduces what you are seeing so that we can investigate.
Sorry, i am cannot do it. I am used code generation in large application. In 6.x version all works. After upgrating to 7.0.2 ia get this exception. my EF Core class named ''<>f__AnonymousType01Child". Now i am did EF Core class named ''f__AnonymousType01Child" and all ok. I.e. enough remove <> as first symbols
@P9avel We can't help here without enough information to understand what is going on. You will need to attempt to strip down your code to create a runnable repro.
As @ajcvickers wrote, just posting an exception stack trace is very rarely enough. You'll need to provide us with the necessary information to allow us to reproduce the problem.
Hello. I see you, am try creating small example
EF Team Triage: Closing this issue as the requested additional details have not been provided and we have been unable to reproduce it.
BTW this is a canned response and may have info or details that do not directly apply to this particular issue. While we'd like to spend the time to uniquely address every incoming issue, we get a lot traffic on the EF projects and that is not practical. To ensure we maximize the time we have to work on fixing bugs, implementing new features, etc. we use canned responses for common triage decisions.
The problem is here:
private NavigationExpansionExpression CreateNavigationExpansionExpression(
Expression sourceExpression,
IEntityType entityType)
{
// if sourceExpression is not a query root we will throw when trying to construct temporal root expression
// regular queries don't use the query root so they will still be fine
var entityReference = new EntityReference(entityType, sourceExpression as EntityQueryRootExpression);
PopulateEagerLoadedNavigations(entityReference.IncludePaths);
var currentTree = new NavigationTreeExpression(entityReference);
var parameterName = GetParameterName(entityType.ShortName()[0].ToString().ToLowerInvariant());
return new NavigationExpansionExpression(sourceExpression, currentTree, currentTree, parameterName);
}
var parameterName = GetParameterName(entityType.ShortName()[0].ToString().ToLowerInvariant());
ShortName property return empty string
string ShortName()
{
if (!HasSharedClrType)
{
var name = ClrType.ShortDisplayName();
var lessIndex = name.IndexOf("<", StringComparison.Ordinal);
if (lessIndex == -1)
{
return name;
}
return name[..lessIndex];
}
```In case the type start with < ShortName method return empty string
Note from triage: @maumar to investigate.
reopen for potential servicing
When you planning build 7.0.6 ?
@P9avel Second Tuesday of June