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

Cannot parse AssemblyInfo.cs files generated by MonoDevelop #943

Closed
pvwichen opened this issue Jun 2, 2016 · 3 comments
Closed

Cannot parse AssemblyInfo.cs files generated by MonoDevelop #943

pvwichen opened this issue Jun 2, 2016 · 3 comments
Assignees
Labels
Milestone

Comments

@pvwichen
Copy link
Contributor

pvwichen commented Jun 2, 2016

What You Are Seeing?

When using the alias ParseAssemblyInfo, it returns null values if the AssemblyInfo.cs file was generated by MonoDevelop even though the file appears to be valid.

MonoDevelop is adding an extra space between the attribute name and the opening parenthesis.
[assembly: AssemblyTitle ("AssemblyTitle")]

What is Expected?

When using ParseAssemblyInfo, its regular expressions should allow for whitespace between the attribute name and opening parenthesis.

I can create a pull request if accepted.

What version of Cake are you using?

Cake 0.12.0

Are you running on a 32 or 64 bit system?

64-bit

What environment are you running on? Windows? Linux? Mac?

Windows, Linux, Mac

Are you running on a CI Server? If so, which one?

Jenkins, TeamCity

How Did You Get This To Happen? (Steps to Reproduce)

Use ParseAssemblyInfo to parse an AssemblyInfo.cs file containing:

using System.Reflection; 
using System.Runtime.CompilerServices; 

// Information about this assembly is defined by the following attributes. 
// Change them to the values specific to your project. 

[assembly: AssemblyTitle ("AssemblyTitle")] 
[assembly: AssemblyDescription ("AssemblyDescription")] 
[assembly: AssemblyConfiguration ("")] 
[assembly: AssemblyCompany ("")] 
[assembly: AssemblyProduct ("")] 
[assembly: AssemblyCopyright ("Copyright")] 
[assembly: AssemblyTrademark ("")] 
[assembly: AssemblyCulture ("")] 

// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". 
// The form "{Major}.{Minor}.*" will automatically update the build and revision, 
// and "{Major}.{Minor}.{Build}.*" will update just the revision. 

[assembly: AssemblyVersion ("1.0.*")] 

// The following attributes are used to specify the signing key for the assembly, 
// if desired. See the Mono documentation for more information about signing. 

//[assembly: AssemblyDelaySign(false)] 
//[assembly: AssemblyKeyFile("")] 

AssemblyDescription will be null.

@devlead
Copy link
Member

devlead commented Jun 2, 2016

@pvwichen found what's casuing it, file above adds an space between attribute and parentheses which apparently breaks the parser.
VisualStudio doesn't add these spaces, so there seems to be a slight indiscretion between MonoDevelop and VS.

I created a gist with a small test case here as reference when sorting issue.

Basically:

using System.Reflection;
using System.Runtime.CompilerServices;

// Information about this assembly is defined by the following attributes.
// Change them to the values specific to your project.

[assembly: AssemblyTitle ("AssemblyTitle")]
[assembly: AssemblyDescription ("AssemblyDescription")]
[assembly: AssemblyConfiguration ("Configuration")]
[assembly: AssemblyCompany ("Company")]
[assembly: AssemblyProduct ("Product")]
[assembly: AssemblyCopyright ("Copyright")]
[assembly: AssemblyTrademark ("Trademark")]
[assembly: AssemblyCulture ("en-US")]

// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
// and "{Major}.{Minor}.{Build}.*" will update just the revision.

[assembly: AssemblyVersion ("1.0.*")]

// The following attributes are used to specify the signing key for the assembly,
// if desired. See the Mono documentation for more information about signing.

//[assembly: AssemblyDelaySign(false)]
//[assembly: AssemblyKeyFile("")]

will fail but this will succeed:

using System.Reflection;
using System.Runtime.CompilerServices;

// Information about this assembly is defined by the following attributes.
// Change them to the values specific to your project.

[assembly: AssemblyTitle("AssemblyTitle")]
[assembly: AssemblyDescription("AssemblyDescription")]
[assembly: AssemblyConfiguration("Configuration")]
[assembly: AssemblyCompany("Company")]
[assembly: AssemblyProduct("Product")]
[assembly: AssemblyCopyright("Copyright")]
[assembly: AssemblyTrademark("Trademark")]
[assembly: AssemblyCulture("en-US")]

// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
// and "{Major}.{Minor}.{Build}.*" will update just the revision.

[assembly: AssemblyVersion("1.0.*")]

// The following attributes are used to specify the signing key for the assembly,
// if desired. See the Mono documentation for more information about signing.

//[assembly: AssemblyDelaySign(false)]
//[assembly: AssemblyKeyFile("")]

Test case will output

Fail:
{
  "ClsCompliant": false,
  "Company": "",
  "ComVisible": false,
  "Configuration": "",
  "Copyright": "",
  "Description": "",
  "AssemblyFileVersion": "1.0.0.0",
  "Guid": "",
  "AssemblyInformationalVersion": "1.0.0.0",
  "Product": "",
  "Title": "",
  "Trademark": "",
  "AssemblyVersion": "1.0.0.0",
  "InternalsVisibleTo": []
}
Success:
{
  "ClsCompliant": false,
  "Company": "Company",
  "ComVisible": false,
  "Configuration": "Configuration",
  "Copyright": "Copyright",
  "Description": "AssemblyDescription",
  "AssemblyFileVersion": "1.0.0.0",
  "Guid": "",
  "AssemblyInformationalVersion": "1.0.0.0",
  "Product": "Product",
  "Title": "AssemblyTitle",
  "Trademark": "Trademark",
  "AssemblyVersion": "1.0.*",
  "InternalsVisibleTo": []
}

@devlead devlead added the Bug label Jun 2, 2016
gep13 added a commit to gep13/cake that referenced this issue Jun 2, 2016
gep13 added a commit to gep13/cake that referenced this issue Jun 2, 2016
gep13 added a commit to gep13/cake that referenced this issue Jun 2, 2016
gep13 added a commit to gep13/cake that referenced this issue Jun 2, 2016
@gep13
Copy link
Member

gep13 commented Jun 2, 2016

@pvwichen this was a simple change to the regular expression that is used to extract the data. I have created a PR to correct this, and to add some more tests around how it is parsed.

@devlead devlead added this to the v0.13.0 milestone Jun 3, 2016
gep13 added a commit to gep13/cake that referenced this issue Jun 5, 2016
devlead added a commit that referenced this issue Jun 5, 2016
GH943: Correcting AssemblyInfo Parsing
@gep13
Copy link
Member

gep13 commented Jun 5, 2016

@pvwichen this should be fixed in the next release of Cake, 0.13.0.

@gep13 gep13 closed this as completed Jun 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants