@@ -9,7 +9,7 @@ namespace RestSharp.Build
9
9
{
10
10
public class NuSpecUpdateTask : Task
11
11
{
12
- private Assembly _assembly ;
12
+ private Assembly assembly ;
13
13
14
14
public string Id { get ; private set ; }
15
15
@@ -27,7 +27,7 @@ public NuSpecUpdateTask() : this(null) { }
27
27
28
28
public NuSpecUpdateTask ( Assembly assembly )
29
29
{
30
- this . _assembly = assembly ;
30
+ this . assembly = assembly ;
31
31
}
32
32
33
33
public override bool Execute ( )
@@ -36,18 +36,18 @@ public override bool Execute()
36
36
return false ;
37
37
38
38
var path = Path . GetFullPath ( this . SourceAssemblyFile ) ;
39
- this . _assembly = this . _assembly ?? Assembly . LoadFile ( path ) ;
39
+ this . assembly = this . assembly ?? Assembly . LoadFile ( path ) ;
40
40
41
- var name = this . _assembly . GetName ( ) ;
41
+ var name = this . assembly . GetName ( ) ;
42
42
43
43
#if SIGNED
44
44
this . Id = name . Name + "Signed" ;
45
45
#else
46
46
this . Id = name . Name ;
47
47
#endif
48
- this . Authors = this . GetAuthors ( this . _assembly ) ;
49
- this . Description = this . GetDescription ( this . _assembly ) ;
50
- this . Version = this . GetVersion ( this . _assembly ) ;
48
+ this . Authors = GetAuthors ( this . assembly ) ;
49
+ this . Description = GetDescription ( this . assembly ) ;
50
+ this . Version = GetVersion ( this . assembly ) ;
51
51
52
52
this . GenerateComputedSpecFile ( ) ;
53
53
@@ -59,16 +59,16 @@ private void GenerateComputedSpecFile()
59
59
var doc = XDocument . Load ( this . SpecFile ) ;
60
60
var metaNode = doc . Descendants ( "metadata" ) . First ( ) ;
61
61
62
- this . ReplaceToken ( metaNode , "id" , this . Id ) ;
63
- this . ReplaceToken ( metaNode , "authors" , this . Authors ) ;
64
- this . ReplaceToken ( metaNode , "owners" , this . Authors ) ;
65
- this . ReplaceToken ( metaNode , "description" , this . Description ) ;
66
- this . ReplaceToken ( metaNode , "version" , this . Version ) ;
62
+ ReplaceToken ( metaNode , "id" , this . Id ) ;
63
+ ReplaceToken ( metaNode , "authors" , this . Authors ) ;
64
+ ReplaceToken ( metaNode , "owners" , this . Authors ) ;
65
+ ReplaceToken ( metaNode , "description" , this . Description ) ;
66
+ ReplaceToken ( metaNode , "version" , this . Version ) ;
67
67
68
68
doc . Save ( this . SpecFile . Replace ( ".nuspec" , "-computed.nuspec" ) ) ;
69
69
}
70
70
71
- private void ReplaceToken ( XElement metaNode , XName name , string value )
71
+ private static void ReplaceToken ( XContainer metaNode , XName name , string value )
72
72
{
73
73
var node = metaNode . Element ( name ) ;
74
74
var token = string . Format ( "${0}$" , name . ToString ( ) . TrimEnd ( 's' ) ) ;
@@ -78,26 +78,26 @@ private void ReplaceToken(XElement metaNode, XName name, string value)
78
78
token = "$author$" ;
79
79
}
80
80
81
- if ( node . Value . Equals ( token , StringComparison . OrdinalIgnoreCase ) )
81
+ if ( node != null && node . Value . Equals ( token , StringComparison . OrdinalIgnoreCase ) )
82
82
{
83
83
node . SetValue ( value ) ;
84
84
}
85
85
}
86
86
87
- private string GetDescription ( Assembly asm )
87
+ private static string GetDescription ( ICustomAttributeProvider asm )
88
88
{
89
- return this . GetAttribute < AssemblyDescriptionAttribute > ( asm ) . Description ;
89
+ return GetAttribute < AssemblyDescriptionAttribute > ( asm ) . Description ;
90
90
}
91
91
92
- private string GetAuthors ( Assembly asm )
92
+ private static string GetAuthors ( ICustomAttributeProvider asm )
93
93
{
94
- return this . GetAttribute < AssemblyCompanyAttribute > ( asm ) . Company ;
94
+ return GetAttribute < AssemblyCompanyAttribute > ( asm ) . Company ;
95
95
}
96
96
97
- private string GetVersion ( Assembly asm )
97
+ private static string GetVersion ( Assembly asm )
98
98
{
99
99
var version = asm . GetName ( ) . Version . ToString ( ) ;
100
- var attr = this . GetAttribute < AssemblyInformationalVersionAttribute > ( asm ) ;
100
+ var attr = GetAttribute < AssemblyInformationalVersionAttribute > ( asm ) ;
101
101
102
102
if ( attr != null )
103
103
{
@@ -107,7 +107,7 @@ private string GetVersion(Assembly asm)
107
107
return version ;
108
108
}
109
109
110
- private TAttr GetAttribute < TAttr > ( Assembly asm ) where TAttr : Attribute
110
+ private static TAttr GetAttribute < TAttr > ( ICustomAttributeProvider asm ) where TAttr : Attribute
111
111
{
112
112
var attrs = asm . GetCustomAttributes ( typeof ( TAttr ) , false ) ;
113
113
0 commit comments