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

Add GitVersionInformationAttribute to make reflection easier [rebased] #531

Merged

Conversation

JakeGinnivan
Copy link
Contributor

This is #526 rebased to fix conflicts with #525

JakeGinnivan added a commit that referenced this pull request Jul 22, 2015
Add GitVersionInformationAttribute to make reflection easier [rebased]
@JakeGinnivan JakeGinnivan merged commit 4a44d12 into GitTools:master Jul 22, 2015
@JakeGinnivan JakeGinnivan deleted the feature/versioninfo-attribute branch July 22, 2015 02:51
@SimonCropp
Copy link
Contributor

SimonCropp commented Jul 26, 2015

@asbjornu @JakeGinnivan how is the attribute less code when using reflection.

var assemblyName = assembly.GetName().Name;

var gitVersionInformationType = assembly.GetType(assemblyName + ".GitVersionInformation");
var versionField = gitVersionInformationType.GetField("NuGetVersion");
Trace.WriteLine(versionField.GetValue(null));

var gitVersionInformationAttributeType = assembly.GetType(assemblyName + ".GitVersionInformationAttribute");
var attribute = assembly.GetCustomAttribute(gitVersionInformationAttributeType);
var attributeVersionField = gitVersionInformationAttributeType.GetProperty("NuGetVersion");
Trace.WriteLine(attributeVersionField.GetValue(attribute));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants