ModelsBuilder: Feature 'expression body property accessor' is not available in C# 6. Please use language version 7.0 or greater
I'm using ModelsBuilder API to generate my models in Visual Studio using the Visual Studio extension. I can not generate my models currently and the following output is shown in the output window of Visual Studio:
UmbracoModelsBuilder: UmbracoModelsBuilder failed to generate code: Exception: Response status code does not indicate success (InternalServerError)
{"Message":"An error has occurred.","ExceptionMessage":"Feature 'expression body property accessor' is not available in C# 6. Please use language version 7.0 or greater.","ExceptionType":"Umbraco.ModelsBuilder.Building.CompilerException","StackTrace":" at Umbraco.ModelsBuilder.Building.Compiler.ThrowExceptionFromDiagnostic(String path, String code, Diagnostic diagnostic) in D:\\d\\Zbu ModelsBuilder-7\\Umbraco.ModelsBuilder\\Building\\Compiler.cs:line 161\r\n at Umbraco.ModelsBuilder.Building.Compiler.<>c__DisplayClass12_0.<GetCompilation>b__0(KeyValuePair`2 x) in D:\\d\\Zbu ModelsBuilder-7\\Umbraco.ModelsBuilder\\Building\\Compiler.cs:line 50\r\n at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()\r\n at System.Linq.Buffer`1..ctor(IEnumerable`1 source)\r\n at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)\r\n at Umbraco.ModelsBuilder.Building.Compiler.GetCompilation(String assemblyName, IDictionary`2 files, SyntaxTree[]& trees) in D:\\d\\Zbu ModelsBuilder-7\\Umbraco.ModelsBuilder\\Building\\Compiler.cs:line 46\r\n at Umbraco.ModelsBuilder.Building.CodeParser.Parse(IDictionary`2 files, IEnumerable`1 references) in D:\\d\\Zbu ModelsBuilder-7\\Umbraco.ModelsBuilder\\Building\\CodeParser.cs:line 38\r\n at Umbraco.ModelsBuilder.Api.ApiHelper.GetModels(String modelsNamespace, IDictionary`2 files) in D:\\d\\Zbu ModelsBuilder-7\\Umbraco.ModelsBuilder\\Api\\ApiHelper.cs:line 16\r\n at Umbraco.ModelsBuilder.Api.ModelsBuilderApiController.GetModels(GetModelsData data) in D:\\d\\Zbu ModelsBuilder-7\\Umbraco.ModelsBuilder.Api\\ModelsBuilderApiController.cs:line 65\r\n at lambda_method(Closure , Object , Object[] )\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Filters.AuthorizationFilterAttribute.<ExecuteAuthorizationFilterAsyncCore>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()"}
UmbracoModelsBuilder: at Umbraco.ModelsBuilder.Api.ApiClient.EnsureSuccess(HttpResponseMessage result)
at Umbraco.ModelsBuilder.Api.ApiClient.GetModels(Dictionary`2 ourFiles, String modelsNamespace)
at Umbraco.ModelsBuilder.CustomTool.CustomTool.UmbracoModelsBuilder.GenerateRaw(String wszInputFilePath, String wszDefaultNamespace, IntPtr[] rgbOutputFileContents, UInt32& pcbOutput, String& errMsg)
Unfortunately, even in debug mode, there is nothing in the log files. The error gives no indication as to where the problem might exist and as far as I can tell I have no partial classes that are using expression body property accessors. I only have one partial class that adds an additional property to one of the models using the traditional block body approach as follows:
public partial class News
{
private IEnumerable<NewsArticle> articles;
public IEnumerable<NewsArticle> Articles
{
get
{
return articles ?? this.Content.Children<NewsArticle>();
}
set
{
this.articles = value;
}
}
}
Thanks Nik - that did the trick! I didn't think it was supported, at least not according to the docs. However, it still doesn't explain why this was happening in the first place when I am not implementing the expression bodied properties in any of my models. I've burnt enough time on this now so will have to just accept that it now works so I can move on but it will continue to bug me I'm sure :(
ModelsBuilder: Feature 'expression body property accessor' is not available in C# 6. Please use language version 7.0 or greater
I'm using ModelsBuilder API to generate my models in Visual Studio using the Visual Studio extension. I can not generate my models currently and the following output is shown in the output window of Visual Studio:
Unfortunately, even in debug mode, there is nothing in the log files. The error gives no indication as to where the problem might exist and as far as I can tell I have no partial classes that are using expression body property accessors. I only have one partial class that adds an additional property to one of the models using the traditional block body approach as follows:
My appsettings for ModelsBuilder are as follows:
And I have the following packages installed after upgrading
Microsoft.CodeAnalysis.Analyzers
in the hope of rectifying the problem.Any ideas where to go next with this?
Edit: I should also note that if I change my
ModelsMode
toAppData
I can successfully generate the models via the Developer section.Hi Simon,
I think you need to edit this config line:
I think you need to change it to have a value of
CSharp7
but I'm not 100%.Thanks Nik - that did the trick! I didn't think it was supported, at least not according to the docs. However, it still doesn't explain why this was happening in the first place when I am not implementing the expression bodied properties in any of my models. I've burnt enough time on this now so will have to just accept that it now works so I can move on but it will continue to bug me I'm sure :(
is working on a reply...