Antaris / RazorEngine

Open source templating engine based on Microsoft's Razor parsing engine
http://antaris.github.io/RazorEngine
Other
2.14k stars 577 forks source link

Support for null propagation operator in templates #503

Open kotpal opened 6 years ago

kotpal commented 6 years ago

When will RazorEngine support null propagation operator (?.) in the templates?

germanger commented 3 years ago

Please!

GeXiaoguo commented 3 years ago

Didn't know this was an issue. I set this up with RazorEngine 3.10.0 and RazorEngine.Roslyn v3.6.1-rc1 and null propagation works This is the code for creating the service

            var config = new TemplateServiceConfiguration();
            config.Language = Language.CSharp;
            config.CompilerServiceFactory = new RoslynCompilerServiceFactory();
            var service = RazorEngineService.Create(config);

and with the following configuration in web.config

  <system.codedom>
    <compilers>
      <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:7.3 /nowarn:1659;1699;1701" />
      <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:7.3 /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />
    </compilers>
  </system.codedom>