NeVeSpl / NTypewriter

File/code generator using Scriban text templates populated with C# code metadata from Roslyn API.
https://nevespl.github.io/NTypewriter/
MIT License
126 stars 24 forks source link

Type.AllReferencedTypes ignores nullable reference types #56

Closed rgicquel-sigma closed 2 years ago

rgicquel-sigma commented 2 years ago

Hi,

It seems that Type.AllReferencedTypes ignores nullable reference types.

Here is what I'm trying to do:

Template:

for class in data.Classes | Symbols.WhereNameEndsWith "TestDTO"

    capture output

        for type in class | Type.AllReferencedTypes | Array.Uniq -}}
import { {{ type }} } from './{{ type.BareName }}';
{{      end
    end

    Save output "test_output"
end

Class to transform:

public class TestDTO
{
    public SomeOtherClass? TestProp1 { get; set; }
}

In the output, no line is present when TestProp1 is nullable. I would expect to see:

import { SomeOtherClass } from './SomeOtherClass':

Otherwise, thanks for your work. I used Typewriter a few years ago and NTypewriter is a huge improvement!