public void VisualBasicGenerator(bool?thisAssemblyClass)
    {
        var info = new AssemblyVersionInfo();

        info.AssemblyCompany     = "company";
        info.AssemblyFileVersion = "1.3.1.0";
        info.AssemblyVersion     = "1.3.0.0";
        info.CodeLanguage        = "vb";

        if (thisAssemblyClass.HasValue)
        {
            info.EmitThisAssemblyClass = thisAssemblyClass.GetValueOrDefault();
        }

        var built = info.BuildCode();

        var expected = $@"'------------------------------------------------------------------------------
' <auto-generated>
'     This code was generated by a tool.
'     Runtime Version:4.0.30319.42000
'
'     Changes to this file may cause incorrect behavior and will be lost if
'     the code is regenerated.
' </auto-generated>
'------------------------------------------------------------------------------

<Assembly: System.Reflection.AssemblyVersionAttribute(""1.3.0.0"")>
<Assembly: System.Reflection.AssemblyFileVersionAttribute(""1.3.1.0"")>
<Assembly: System.Reflection.AssemblyInformationalVersionAttribute("""")>
{(thisAssemblyClass.GetValueOrDefault(true) ? $@"#If NETFRAMEWORK  Or  NETCOREAPP  Or  NETSTANDARD2_0  Or  NETSTANDARD2_1 Then
<System.CodeDom.Compiler.GeneratedCode(""{AssemblyVersionInfo.GeneratorName}"",""{AssemblyVersionInfo.GeneratorVersion}"")>
<System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage>
Partial Friend NotInheritable Class ThisAssembly
#ElseIf NETSTANDARD  Or  NETFRAMEWORK  Or  NETCOREAPP Then
<System.CodeDom.Compiler.GeneratedCode(""{AssemblyVersionInfo.GeneratorName}"",""{AssemblyVersionInfo.GeneratorVersion}"")>
Partial Friend NotInheritable Class ThisAssembly
#Else
Partial Friend NotInheritable Class ThisAssembly
#End If
    Friend Const AssemblyCompany As String = ""company""
    Friend Const AssemblyFileVersion As String = ""1.3.1.0""
    Friend Const AssemblyVersion As String = ""1.3.0.0""
    Friend Const IsPrerelease As Boolean = False
    Friend Const IsPublicRelease As Boolean = False
    Friend Const RootNamespace As String = """"
End Class
" : "")}";

        Assert.Equal(expected, built);
    }
Beispiel #2
0
    public void FSharpGenerator(bool?thisAssemblyClass)
    {
        var info = new AssemblyVersionInfo();

        info.AssemblyCompany     = "company";
        info.AssemblyFileVersion = "1.3.1.0";
        info.AssemblyVersion     = "1.3.0.0";
        info.CodeLanguage        = "f#";

        if (thisAssemblyClass.HasValue)
        {
            info.EmitThisAssemblyClass = thisAssemblyClass.GetValueOrDefault();
        }

        var built = info.BuildCode();

        var expected = $@"//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:4.0.30319.42000
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace AssemblyInfo
[<assembly: System.Reflection.AssemblyVersionAttribute(""1.3.0.0"")>]
[<assembly: System.Reflection.AssemblyFileVersionAttribute(""1.3.1.0"")>]
[<assembly: System.Reflection.AssemblyInformationalVersionAttribute("""")>]
{(thisAssemblyClass.GetValueOrDefault(true) ? $@"do()
#if NETSTANDARD || NETFRAMEWORK || NETCOREAPP
[<System.CodeDom.Compiler.GeneratedCode(""{AssemblyVersionInfo.GeneratorName}"",""{AssemblyVersionInfo.GeneratorVersion}"")>]
#endif
#if NETFRAMEWORK || NETCOREAPP || NETSTANDARD2_0 || NETSTANDARD2_1
[<System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage>]
#endif
type internal ThisAssembly() =
  static member internal AssemblyVersion = ""1.3.0.0""
  static member internal AssemblyFileVersion = ""1.3.1.0""
  static member internal AssemblyCompany = ""company""
  static member internal IsPublicRelease = false
  static member internal IsPrerelease = false
  static member internal RootNamespace = """"
do()
" : "")}";

        Assert.Equal(expected, built);
    }
Beispiel #3
0
    public void CSharpGenerator()
    {
        var info = new AssemblyVersionInfo();

        info.AssemblyCompany     = "company";
        info.AssemblyFileVersion = "1.3.1.0";
        info.AssemblyVersion     = "1.3.0.0";
        info.CodeLanguage        = "c#";

        var built = info.BuildCode();

        var expected = @"//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:4.0.30319.42000
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

[assembly: System.Reflection.AssemblyVersionAttribute(""1.3.0.0"")]
[assembly: System.Reflection.AssemblyFileVersionAttribute(""1.3.1.0"")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("""")]
#if NETSTANDARD || NETFRAMEWORK || NETCOREAPP
[System.CodeDom.Compiler.GeneratedCode(""" + AssemblyVersionInfo.GeneratorName + @""",""" + AssemblyVersionInfo.GeneratorVersion + @""")]
#endif
#if NETFRAMEWORK || NETCOREAPP || NETSTANDARD2_0 || NETSTANDARD2_1
[System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
#endif
internal static partial class ThisAssembly {
    internal const string AssemblyVersion = ""1.3.0.0"";
    internal const string AssemblyFileVersion = ""1.3.1.0"";
    internal const string AssemblyCompany = ""company"";
    internal const bool IsPublicRelease = false;
    internal const bool IsPrerelease = false;
    internal const string RootNamespace = """";
}
";

        Assert.Equal(expected, built);
    }
    public void FSharpGenerator()
    {
        var info = new AssemblyVersionInfo();

        info.AssemblyCompany     = "company";
        info.AssemblyFileVersion = "1.3.1.0";
        info.AssemblyVersion     = "1.3.0.0";
        info.CodeLanguage        = "f#";

        var built = info.BuildCode();

        var expected = @"//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:4.0.30319.42000
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace AssemblyInfo
[<assembly: System.Reflection.AssemblyVersionAttribute(""1.3.0.0"")>]
[<assembly: System.Reflection.AssemblyFileVersionAttribute(""1.3.1.0"")>]
[<assembly: System.Reflection.AssemblyInformationalVersionAttribute("""")>]
do()
#if NETSTANDARD || NETFRAMEWORK || NETCOREAPP
[<System.CodeDom.Compiler.GeneratedCode(""" + AssemblyVersionInfo.GeneratorName + @""",""" + AssemblyVersionInfo.GeneratorVersion + @""")>]
#endif
type internal ThisAssembly() =
  static member internal AssemblyVersion = ""1.3.0.0""
  static member internal AssemblyFileVersion = ""1.3.1.0""
  static member internal AssemblyCompany = ""company""
  static member internal RootNamespace = """"
do()
";

        Assert.Equal(expected, built);
    }
    public void FSharpGenerator(bool?thisAssemblyClass)
    {
        var info = new AssemblyVersionInfo();

        info.AssemblyCompany              = "company";
        info.AssemblyFileVersion          = "1.3.1.0";
        info.AssemblyVersion              = "1.3.0.0";
        info.AdditionalThisAssemblyFields =
            new TaskItem[]
        {
            new TaskItem(
                "CustomString1",
                new Dictionary <string, string>()
            {
                { "String", "abc" }
            }),
            new TaskItem(
                "CustomString2",
                new Dictionary <string, string>()
            {
                { "String", "" }
            }),
            new TaskItem(
                "CustomString3",
                new Dictionary <string, string>()
            {
                { "String", "" }, { "EmitIfEmpty", "true" }
            }),
            new TaskItem(
                "CustomBool",
                new Dictionary <string, string>()
            {
                { "Boolean", "true" }
            }),
            new TaskItem(
                "CustomTicks",
                new Dictionary <string, string>()
            {
                { "Ticks", "637509805729817056" }
            }),
        };
        info.CodeLanguage = "f#";

        if (thisAssemblyClass.HasValue)
        {
            info.EmitThisAssemblyClass = thisAssemblyClass.GetValueOrDefault();
        }

        var built = info.BuildCode();

        var expected = $@"//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:4.0.30319.42000
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace AssemblyInfo
[<assembly: System.Reflection.AssemblyVersionAttribute(""1.3.0.0"")>]
[<assembly: System.Reflection.AssemblyFileVersionAttribute(""1.3.1.0"")>]
[<assembly: System.Reflection.AssemblyInformationalVersionAttribute("""")>]
{(thisAssemblyClass.GetValueOrDefault(true) ? $@"do()
#if NETSTANDARD || NETFRAMEWORK || NETCOREAPP
[<System.CodeDom.Compiler.GeneratedCode(""{AssemblyVersionInfo.GeneratorName}"",""{AssemblyVersionInfo.GeneratorVersion}"")>]
#endif
#if NETFRAMEWORK || NETCOREAPP || NETSTANDARD2_0 || NETSTANDARD2_1
[<System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage>]
#endif
type internal ThisAssembly() =
  static member internal AssemblyCompany = ""company""
  static member internal AssemblyFileVersion = ""1.3.1.0""
  static member internal AssemblyVersion = ""1.3.0.0""
  static member internal CustomBool = true
  static member internal CustomString1 = ""abc""
  static member internal CustomString3 = """"
  static member internal CustomTicks = new System.DateTime(637509805729817056L, System.DateTimeKind.Utc)
  static member internal IsPrerelease = false
  static member internal IsPublicRelease = false
  static member internal RootNamespace = """"
do()
" : "")}";

        Assert.Equal(expected, built);
    }