Good morning,
We have encountered an error that does not let us keep working without changing our Model.
Our test model to reproduce the bug:
Unable to find source-code formatter for language: .net. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
public class Car { public Guid Id { get; set; } public ExtraInfo ExtraInfo { get; set; } } public class ExtraInfo { public int NotNullableType { get; set; } public int? Type { get; set; } }
The issue:
Unable to find source-code formatter for language: .net. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
private static void Test(MongoDbCollection<Car> mongoDbCollection) { var queryable = mongoDbCollection.AsQueryable(); // 1 - Both paths are correct queryable.Where(c => c.ExtraInfo.Type == 1 && c.ExtraInfo.NotNullableType == 1).ToList(); // 2 - Path is correct queryable.Where(c => c.ExtraInfo.Type == null).ToList(); // 3 - Path is incorrect (.Value breaks something) queryable.Where(c => c.ExtraInfo.Type.Value == 2).ToList(); // 4 - Path is incorrect (.Value keeps breaking something) int? infoType = 3; queryable.Where(c => c.ExtraInfo.Type.Value == infoType).ToList(); // 5 - Path is correct when not nullable type only. "list.Contains()" method signature requires to use ".Value" when it is a nullable var list = new List<int> { 4, 5 }; queryable.Where(c => list.Contains(c.ExtraInfo.Type.Value) || list.Contains(c.ExtraInfo.NotNullableType)).ToList(); }
And the mongo query translations are these ones:
// 1 - Both paths are correct "command" : { "aggregate" : "cars", "pipeline" : [{ "$match" : { "ExtraInfo.Type" : 1, "ExtraInfo.NotNullableType" : 1 } }] } // 2 - Path is correct "command" : { "aggregate" : "cars", "pipeline" : [{ "$match" : { "ExtraInfo.Type" : null } }] } // 3 - Path is incorrect (.Value breaks something) "command" : { "aggregate" : "cars", "pipeline" : [{ "$match" : { "Type" : 2 } }] } // 4 - Path is incorrect (.Value keeps breaking something) "command" : { "aggregate" : "cars", "pipeline" : [{ "$match" : { "Type" : 3 } }] } // 5 - Path is correct when not nullable type only. "list.Contains()" method signature requires to use ".Value" when it is a nullable "command" : { "aggregate" : "cars", "pipeline" : [{ "$match" : { "$or" : [{ "Type" : { "$in" : [4, 5] } }, { "ExtraInfo.NotNullableType" : { "$in" : [4, 5] } }] } }] }
Hope it helps to find the problem,
Thanks!