Skip to content

Commit

Permalink
Merge pull request cake-build#2476 from Joev-/GH2473
Browse files Browse the repository at this point in the history
(cake-buildGH-2473) Support fully qualified attributes in AssemblyInfo
  • Loading branch information
patriksvensson committed Feb 15, 2019
2 parents 8332c3a + ca4d9a7 commit 9419aa4
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 4 deletions.
22 changes: 22 additions & 0 deletions src/Cake.Common.Tests/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions src/Cake.Common.Tests/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1074,4 +1074,28 @@ Line #3]]></releaseNotes>
</files>
&lt;/package&gt;</value>
</data>
<data name="FullyQualifiedAssemblyInfo" xml:space="preserve">
<value>//------------------------------------------------------------------------------
// &lt;auto-generated&gt;
// 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.
// &lt;/auto-generated&gt;
//------------------------------------------------------------------------------

using System;
using System.Reflection;

[assembly: System.Reflection.AssemblyCompanyAttribute("FullyQualifiedCompanyAttribute")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("FullyQualifiedConfigurationAttribute")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.3.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.3.0")]
[assembly: System.Reflection.AssemblyProductAttribute("FullyQualifiedProductAttribute")]
[assembly: System.Reflection.AssemblyTitleAttribute("FullyQualifiedTitleAttribute")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.3.0.0")]

// Generated by the MSBuild WriteCodeFragment class.</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,27 @@ public void Should_Correctly_Parse_MonoDevelop_AssemblyInfo_File()
Assert.Equal(result.Copyright, "MonoDevelopCopyright");
Assert.Equal(result.Trademark, "MonoDevelopTrademark");
}

[Fact]
public void Should_Read_FullyQualifiedAssemblyAttributes()
{
// Given
var fixture = new AssemblyInfoParserFixture();
fixture.CreateAssemblyInfo = false;
fixture.WithAssemblyInfoContents(Resources.FullyQualifiedAssemblyInfo.NormalizeLineEndings());

// When
var result = fixture.Parse();

// Then
Assert.Equal("FullyQualifiedCompanyAttribute", result.Company);
Assert.Equal("FullyQualifiedConfigurationAttribute", result.Configuration);
Assert.Equal("1.3.0.0", result.AssemblyFileVersion);
Assert.Equal("1.3.0", result.AssemblyInformationalVersion);
Assert.Equal("FullyQualifiedProductAttribute", result.Product);
Assert.Equal("FullyQualifiedTitleAttribute", result.Title);
Assert.Equal("1.3.0.0", result.AssemblyVersion);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ namespace Cake.Common.Solution.Project.Properties
/// </summary>
public sealed class AssemblyInfoParser
{
private const string CSharpNonQuotedPattern = @"^\s*\[assembly: {0} ?\((?<attributeValue>.*)\)";
private const string CSharpQuotedPattern = @"^\s*\[assembly: {0} ?\(""(?<attributeValue>.*)""\)";
private const string VBNonQuotedPattern = @"^\s*\<Assembly: {0} ?\((?<attributeValue>.*)\)";
private const string VBQuotedPattern = @"^\s*\<Assembly: {0} ?\(""(?<attributeValue>.*)""\)";
private const string CSharpNonQuotedPattern = @"^\s*\[assembly: (?:System\.Reflection\.)?{0}(?:Attribute)? ?\((?<attributeValue>.*)\)";
private const string CSharpQuotedPattern = @"^\s*\[assembly: (?:System\.Reflection\.)?{0}(?:Attribute)? ?\(""(?<attributeValue>.*)""\)";
private const string VBNonQuotedPattern = @"^\s*\<Assembly: (?:System\.Reflection\.)?{0}(?:Attribute)? ?\((?<attributeValue>.*)\)";
private const string VBQuotedPattern = @"^\s*\<Assembly: (?:System\.Reflection\.)?{0}(?:Attribute)? ?\(""(?<attributeValue>.*)""\)";
private const string DefaultVersion = "1.0.0.0";

private readonly IFileSystem _fileSystem;
Expand Down

0 comments on commit 9419aa4

Please sign in to comment.