Example #1
0
    public static ClassDeclarationSyntax ClassWithInjected<TInjected>(string className)
    {
        var (typeName, variableName) = NamingHelper.GetNames<TInjected>();

        var classCode = $@"class {className}
                          {{
                              private readonly {typeName} _{variableName};

                              public {className}( {typeName} {variableName})
                              {{
                                  _{variableName} = {variableName};
                              }}
                          }}";

        return ParseClass(classCode);
    }