Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • teus 42 posts 74 karma points
    Feb 15, 2017 @ 11:38
    teus
    1

    Models.Builder not working with C#6 code

    If we use c#6 features(for instance the 'null propagating operator' e.g. '?.' ) in a partial class which extends the generated class, the UmbracoModelsBuilder fails.

    Can I update the ModelsBuilder to compile c#6?

    Regards Teus

    Error: UmbracoModelsBuilder: Starting v3.0.0.90 15-2-2017 12:22:02. UmbracoModelsBuilder: UmbracoModelsBuilder failed to generate code: Exception: Response status code does not indicate success (InternalServerError) {"Message":"An error has occurred.","ExceptionMessage":"Feature 'null propagating operator' is not available in C# 5. Please use language version 6 or greater.","ExceptionType":"Umbraco.ModelsBuilder.Building.CompilerException","StackTrace":" at Umbraco.ModelsBuilder.Building.Compiler.ThrowExceptionFromDiagnostic(String path, String code, Diagnostic diagnostic) in C:\Users\Stéphane\Documents\Development\Umbraco\Zbu\Zbu.ModelsBuilder\Umbraco.ModelsBuilder\Building\Compiler.cs:line 161\r\n at Umbraco.ModelsBuilder.Building.Compiler.<>cDisplayClass12_0.0(KeyValuePair2 x) in C:\\Users\\Stéphane\\Documents\\Development\\Umbraco\\Zbu\\Zbu.ModelsBuilder\\Umbraco.ModelsBuilder\\Building\\Compiler.cs:line 50\r\n at System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext()\r\n at System.Linq.Buffer1..ctor(IEnumerable1 source)\r\n at System.Linq.Enumerable.ToArray[TSource](IEnumerable1 source)\r\n at Umbraco.ModelsBuilder.Building.Compiler.GetCompilation(String assemblyName, IDictionary2 files, SyntaxTree[]& trees) in C:\Users\Stéphane\Documents\Development\Umbraco\Zbu\Zbu.ModelsBuilder\Umbraco.ModelsBuilder\Building\Compiler.cs:line 46\r\n at Umbraco.ModelsBuilder.Building.CodeParser.Parse(IDictionary2 files, IEnumerable1 references) in C:\Users\Stéphane\Documents\Development\Umbraco\Zbu\Zbu.ModelsBuilder\Umbraco.ModelsBuilder\Building\CodeParser.cs:line 38\r\n at Umbraco.ModelsBuilder.Api.ApiHelper.GetModels(String modelsNamespace, IDictionary2 files) in C:\\Users\\Stéphane\\Documents\\Development\\Umbraco\\Zbu\\Zbu.ModelsBuilder\\Umbraco.ModelsBuilder\\Api\\ApiHelper.cs:line 16\r\n at Umbraco.ModelsBuilder.Api.ModelsBuilderApiController.GetModels(GetModelsData data) in C:\\Users\\Stéphane\\Documents\\Development\\Umbraco\\Zbu\\Zbu.ModelsBuilder\\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.ExecuteAsync(HttpControllerContext controllerContext, IDictionary2 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.

  • Daniël Knippers 153 posts 1116 karma points MVP 2x c-trib
    Feb 19, 2017 @ 20:33
    Daniël Knippers
    105

    Hi Teus,

    You can enable C# 6 syntax by adding this line to your Web.config in AppSettings:

    <add key="Umbraco.ModelsBuilder.LanguageVersion" value="CSharp6" />

    Other configuration options can be found here

  • RAVI PRAKASH PANDEY 1 post 21 karma points
    Sep 03, 2018 @ 08:09
    RAVI PRAKASH PANDEY
    0

    This resolve my problem also. Thanks

  • teus 42 posts 74 karma points
    Mar 01, 2017 @ 08:27
    teus
    0

    Thanks Daniel, that solved it! Sorry for the late reply . Regards Teus

Please Sign in or register to post replies

Write your reply to:

Draft