This repository has been archived by the owner on Dec 18, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 224
Flow project.json info into assembly info. #2950
Closed
Closed
Changes from 2 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
b80d982
Flow project.json info into assembly info.
1fb3c35
Update Travis URL for this branch.
097c7e5
IExcecutionEnvironment OperatingSystemVersion modifications
pakrym 09ab851
React to aspnet/Universe#290 fix
dougbu 575e2de
Fix local build break
dougbu 19f601d
Flow project.json info into assembly info.
e3ba3e0
Update Travis URL for this branch.
b654560
Add functional test to verify assembly info.
0627e80
Merge branch 'cesarbs/dnx-assembly-info' of https://github.com/aspnet…
d95f49c
Revert change in README.md.
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -128,7 +128,7 @@ public CompilationContext CompileProject( | |
references, | ||
compilationSettings.CompilationOptions); | ||
|
||
compilation = ApplyVersionInfo(compilation, projectContext, parseOptions); | ||
compilation = ApplyProjectInfo(compilation, projectContext, parseOptions); | ||
|
||
var compilationContext = new CompilationContext( | ||
compilation, | ||
|
@@ -252,58 +252,44 @@ private CompilationModules GetCompileModules(CompilationTarget target) | |
}); | ||
} | ||
|
||
private static CSharpCompilation ApplyVersionInfo(CSharpCompilation compilation, CompilationProjectContext project, | ||
private static CSharpCompilation ApplyProjectInfo(CSharpCompilation compilation, CompilationProjectContext project, | ||
CSharpParseOptions parseOptions) | ||
{ | ||
const string assemblyFileVersionName = "System.Reflection.AssemblyFileVersionAttribute"; | ||
const string assemblyVersionName = "System.Reflection.AssemblyVersionAttribute"; | ||
const string assemblyInformationalVersion = "System.Reflection.AssemblyInformationalVersionAttribute"; | ||
var attributeNameToProjectValue = new Dictionary<string, string>(StringComparer.Ordinal) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see any checks for null or invalid values. What happens if the language is null or empty? same for copyright and description. |
||
{ | ||
["System.Reflection.AssemblyTitleAttribute"] = project.Title, | ||
["System.Reflection.AssemblyDescriptionAttribute"] = project.Description, | ||
["System.Reflection.AssemblyCopyrightAttribute"] = project.Copyright, | ||
["System.Reflection.AssemblyCultureAttribute"] = project.Language, | ||
["System.Reflection.AssemblyFileVersionAttribute"] = project.AssemblyFileVersion.ToString(), | ||
["System.Reflection.AssemblyVersionAttribute"] = RemovePrereleaseTag(project.Version), | ||
["System.Reflection.AssemblyInformationalVersionAttribute"] = project.Version | ||
}; | ||
|
||
var assemblyAttributes = compilation.Assembly.GetAttributes(); | ||
|
||
var foundAssemblyFileVersion = false; | ||
var foundAssemblyVersion = false; | ||
var foundAssemblyInformationalVersion = false; | ||
|
||
foreach (var assembly in assemblyAttributes) | ||
foreach (var attribute in assemblyAttributes) | ||
{ | ||
string attributeName = assembly.AttributeClass.ToString(); | ||
string attributeName = attribute.AttributeClass.ToString(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: use var instead of string |
||
|
||
if (string.Equals(attributeName, assemblyFileVersionName, StringComparison.Ordinal)) | ||
{ | ||
foundAssemblyFileVersion = true; | ||
} | ||
else if (string.Equals(attributeName, assemblyVersionName, StringComparison.Ordinal)) | ||
{ | ||
foundAssemblyVersion = true; | ||
} | ||
else if (string.Equals(attributeName, assemblyInformationalVersion, StringComparison.Ordinal)) | ||
if (attributeNameToProjectValue.ContainsKey(attributeName)) | ||
{ | ||
foundAssemblyInformationalVersion = true; | ||
attributeNameToProjectValue.Remove(attributeName); | ||
} | ||
} | ||
|
||
var versionAttributes = new StringBuilder(); | ||
if (!foundAssemblyFileVersion) | ||
{ | ||
versionAttributes.AppendLine($"[assembly:{assemblyFileVersionName}(\"{project.AssemblyFileVersion}\")]"); | ||
} | ||
|
||
if (!foundAssemblyVersion) | ||
{ | ||
versionAttributes.AppendLine($"[assembly:{assemblyVersionName}(\"{RemovePrereleaseTag(project.Version)}\")]"); | ||
} | ||
var attributes = new StringBuilder(); | ||
|
||
if (!foundAssemblyInformationalVersion) | ||
foreach (var attributeValue in attributeNameToProjectValue) | ||
{ | ||
versionAttributes.AppendLine($"[assembly:{assemblyInformationalVersion}(\"{project.Version}\")]"); | ||
attributes.AppendLine($"[assembly:{attributeValue.Key}(\"{attributeValue.Value}\")]"); | ||
} | ||
|
||
if (versionAttributes.Length != 0) | ||
if (attributes.Length != 0) | ||
{ | ||
compilation = compilation.AddSyntaxTrees(new[] | ||
{ | ||
CSharpSyntaxTree.ParseText(versionAttributes.ToString(), parseOptions) | ||
CSharpSyntaxTree.ParseText(attributes.ToString(), parseOptions) | ||
}); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you update the branch?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To see the thingy going green in the repo page :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
volkswagen!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's pretty weird 😄 You can just check travis itself.