Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

c# try .. catch appears to be not supported #18

Open
jobyjcteoco opened this issue Mar 6, 2024 · 0 comments
Open

c# try .. catch appears to be not supported #18

jobyjcteoco opened this issue Mar 6, 2024 · 0 comments

Comments

@jobyjcteoco
Copy link

Hello,

Thank you so much for this library which allows us to write T4 files for the .Net core assemblies. Since debugging is not available with this library, I was trying to find out the issues with our template files which used to work with old gen engine by adding Try.. Catch sections, but it doesn't appear to be honouring those and always outputting 'ErrorGeneratingOutput' in the generated file which doesn't help much in diagnosing the issues. I have added a simple template here which deliberately creates an exception here:

<#@ template hostspecific="false" debug="false" language="C#" #>
<#@ output extension=".generated.txt" encoding="utf-8" #>
<#@ assembly name="System.Core" #>
<#@ assembly name="System.Text.Json" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ import namespace="System.Text.Json" #>
<#@ import namespace="System.Text.Json.Serialization" #>
<# BuildTests("Jack"); #>
<#+
    void BuildTests(string param)
    {
    try
        {
        #>
        Hello <#= param #>
        <#+
            var a = 10/0; //To get an exception

            #>
            Number: <#= a #>
        <#+
        }
        catch(Exception ex)
        {
        #>
            Error: <#= ex.ToString() #>
        <#+
        }
    }
#>

Any advice is much appreciated which would allow us to find and fix the issues with our template files.

Kind regards,
Joby

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant