@@ -91,39 +91,28 @@ static void VerifyAssemblyVersion(AssemblyVersioningScheme avs)
91
91
Approvals . Verify ( assemblyInfoText ) ;
92
92
93
93
var compilation = CSharpCompilation . Create ( "Fake.dll" )
94
- . WithOptions ( new CSharpCompilationOptions ( OutputKind . NetModule ) )
95
- . AddReferences ( MetadataReference . CreateFromFile ( typeof ( object ) . Assembly . Location ) )
96
- . AddSyntaxTrees ( CSharpSyntaxTree . ParseText ( assemblyInfoText ) ) ;
94
+ . WithOptions ( new CSharpCompilationOptions ( OutputKind . NetModule ) )
95
+ . AddReferences ( MetadataReference . CreateFromFile ( typeof ( object ) . Assembly . Location ) )
96
+ . AddSyntaxTrees ( CSharpSyntaxTree . ParseText ( assemblyInfoText ) ) ;
97
97
98
98
var emitResult = compilation . Emit ( new MemoryStream ( ) ) ;
99
99
Assert . IsTrue ( emitResult . Success , string . Join ( Environment . NewLine , emitResult . Diagnostics . Select ( x => x . Descriptor ) ) ) ;
100
100
}
101
101
102
102
static void VerifyGitVersionInformationAttribute ( Assembly assembly , VersionVariables versionVariables )
103
103
{
104
- var gitVersionInformationAttributeData = assembly . CustomAttributes
105
- . FirstOrDefault ( a => a . AttributeType . Name == "GitVersionInformationAttribute" ) ;
106
-
107
- Assert . IsNotNull ( gitVersionInformationAttributeData ) ;
108
-
109
- var gitVersionInformationAttributeType = gitVersionInformationAttributeData . AttributeType ;
110
- var gitVersionInformationAttribute = assembly
111
- . GetCustomAttributes ( gitVersionInformationAttributeType )
112
- . FirstOrDefault ( ) ;
113
-
114
- Assert . IsNotNull ( gitVersionInformationAttribute ) ;
115
-
116
- var properties = gitVersionInformationAttributeType . GetProperties ( BindingFlags . Instance | BindingFlags . Public ) ;
104
+ var gitVersionInformation = assembly . GetType ( "Fake.GitVersionInformation" ) ;
105
+ var fields = gitVersionInformation . GetFields ( BindingFlags . Static | BindingFlags . Public ) ;
117
106
118
107
foreach ( var variable in versionVariables )
119
108
{
120
109
Assert . IsNotNull ( variable . Value ) ;
121
110
122
- var property = properties . FirstOrDefault ( p => p . Name == variable . Key ) ;
123
- Assert . IsNotNull ( property ) ;
111
+ var field = fields . FirstOrDefault ( p => p . Name == variable . Key ) ;
112
+ Assert . IsNotNull ( field ) ;
124
113
125
- var propertyValue = property . GetValue ( gitVersionInformationAttribute , null ) ;
126
- Assert . AreEqual ( variable . Value , propertyValue , "{0} had an invalid value." , property . Name ) ;
114
+ var value = field . GetValue ( null ) ;
115
+ Assert . AreEqual ( variable . Value , value , "{0} had an invalid value." , field . Name ) ;
127
116
}
128
117
}
129
118
}
0 commit comments