Updated build config scripting. Updated some changes to custom rule.

This commit is contained in:
Zachary Gramana 2013-08-16 13:53:27 -07:00
Родитель 4d425c2c46
Коммит 0c7063fb05
3 изменённых файлов: 17 добавлений и 8 удалений

Просмотреть файл

@ -50,7 +50,7 @@
| ReviewMisleadingFieldNamesRule | VariableNamesShouldNotMatchFieldNamesRule"
from="Gendarme.Rules.Maintainability.dll"/>
<rules include="*" from="Gendarme.Rules.Globalization.dll"/>
<rules include="*" from="Gendarme.Rules.Xamarin.dll"/>
<!-- rules include="*" from="Gendarme.Rules.Xamarin.dll" -->
<!-- no rule from Gendarme.Rules.Gendarme is included in this set -->
<!-- no rule from Gendarme.Rules.Interoperability.Com is included in this set -->
<!-- no rule from Gendarme.Rules.NUnit is included in this set -->

Просмотреть файл

@ -20,7 +20,8 @@
<ConsolePause>false</ConsolePause>
<CustomCommands>
<CustomCommands>
<Command type="Custom" name="Run Gendarme" command="${SolutionDir}/../bin/gendarme.exe --set xamarin /Users/zgramana/Xamarin/Tests/Components/NetworkComms.Net-2.3.0/lib/ios/NetworkCommsDotNetCore.dll" workingdir="${SolutionDir}/../bin/" />
<Command type="Execute" command="${SolutionDir}/../bin/gendarme.exe --set component-store --severity critical /Users/zgramana/Xamarin/Tests/Components/examples/lib/ios/Target.1.dll" workingdir="${SolutionDir}/../bin" />
<Command type="Clean" />
</CustomCommands>
</CustomCommands>
</PropertyGroup>
@ -32,8 +33,9 @@
<ConsolePause>false</ConsolePause>
<CustomCommands>
<CustomCommands>
<Command type="Build" command="cp lib/* ${TargetDir}" workingdir="${SolutionDir}/../" externalConsole="True" />
<Command type="AfterBuild" command="cp lib/* ${TargetDir}" workingdir="${SolutionDir}/../" externalConsole="True" />
<Command type="AfterClean" command="ls lib &gt; temp; cd bin; cat ../temp | xargs -o rm -f ; cd ..; rm temp" workingdir="${SolutionDir}/../" externalConsole="True" />
<Command type="Execute" command="${SolutionDir}/../bin/gendarme.exe --set component-store --severity critical --confidence high /Users/zgramana/Xamarin/Tests/Components/examples/lib/ios/Target.1.dll" workingdir="${SolutionDir}/../bin" />
</CustomCommands>
</CustomCommands>
</PropertyGroup>

Просмотреть файл

@ -17,7 +17,7 @@ namespace Gendarme.Rules.Xamarin
public RuleResult CheckAssembly (AssemblyDefinition assembly)
{
// Short circuit for non-Xamarin targets (e.g. winrt, wp8).
if (!TargetsPrereleaseXamarinIOS.TargetsXamarinPlatforms (assembly))
if (!TargetsPrereleaseXamarinIOS.TargetsXamarin (assembly))
return RuleResult.DoesNotApply;
// Look for the TargetPlatform attribute, which indicates
@ -55,13 +55,20 @@ namespace Gendarme.Rules.Xamarin
static bool CheckForMT2002 (AssemblyDefinition assembly)
{
var result = false;
// We need to see if this module's member references table
// has an entry to a method that we know was not implemented
// in Stable, but was implemented in Beta or Alpha.
var refs = assembly.MainModule.GetMemberReferences ();
var types = assembly.MainModule.GetTypeReferences ();
var badRef = refs.SingleOrDefault (m => m.FullName == "System.Boolean System.Type::op_Equality(System.Type,System.Type)");
if (badRef != null)
if (refs.Any (m => m.FullName == "System.Boolean System.Type::op_Equality(System.Type,System.Type)"))
result = true;
// In .NET 4.5, System.Runtime.CompilerServices.ExtensionAttribute was moved to mscorelib.
// In previous versions, it lived in System.core.
else if (types.Any (t => t.FullName == "System.Runtime.CompilerServices.ExtensionAttribute"
&& t.Scope.Name == "mscorlib"))
result = true;
return result;
@ -72,9 +79,9 @@ namespace Gendarme.Rules.Xamarin
/// </summary>
/// <returns><c>true</c>, if xamarin platforms was targetsed, <c>false</c> otherwise.</returns>
/// <param name="assembly">Assembly.</param>
static bool TargetsXamarinPlatforms (AssemblyDefinition assembly)
static bool TargetsXamarin (AssemblyDefinition assembly)
{
return assembly.MainModule.AssemblyReferences.Any (aref => aref.PublicKeyToken.Equals (XamarinRuntimeAssemblyToken));
return assembly.MainModule.AssemblyReferences.Any (aref => aref.PublicKeyToken.SequenceEqual (XamarinRuntimeAssemblyToken));
}
}
}