Code cleanup. Further customized rules.xml.

This commit is contained in:
Zachary Gramana 2013-06-05 14:20:23 -04:00
Родитель f14ab871db
Коммит c5464937cc
6 изменённых файлов: 32 добавлений и 43 удалений

1
.gitignore поставляемый
Просмотреть файл

@ -12,6 +12,7 @@ TestResults
*.suo
*.user
*.sln.docstates
*.userprefs
# Build results
[Dd]ebug/

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

@ -36,13 +36,19 @@
<rules include="*" from="Gendarme.Rules.Design.Linq.dll"/>
<rules include="*" from="Gendarme.Rules.Exceptions.dll" />
<rules include="*" from="Gendarme.Rules.Interoperability.dll"/>
<rules include="*" from="Gendarme.Rules.Naming.dll"/>
<rules include="*" exclude="UseCorrectPrefixRule" from="Gendarme.Rules.Naming.dll"/>
<rules include="*" from="Gendarme.Rules.Performance.dll" />
<rules include="*" from="Gendarme.Rules.Portability.dll" />
<rules include="*" from="Gendarme.Rules.Security.dll" />
<rules include="*" from="Gendarme.Rules.Security.Cas.dll" />
<rules include="*" from="Gendarme.Rules.Serialization.dll" />
<rules include="*" from="Gendarme.Rules.Maintainability.dll"/>
<rules include="*" exclude="MissingSerializableAttributeOnISerializableTypeRule"
from="Gendarme.Rules.Serialization.dll" />
<rules include="*" exclude="AvoidComplexMethodsRule
| AvoidAlwaysNullFieldRule | AvoidDeepInheritanceTreeRule
| AvoidLackOfCohesionOfMethodsRule | AvoidUnnecessarySpecializationRule
| ConsiderUsingStopwatchRule | PreferStringIsNullOrEmptyRule
| ReviewMisleadingFieldNamesRule | VariableNamesShouldNotMatchFieldNamesRule"
from="Gendarme.Rules.Maintainability.dll"/>
<rules include="*" from="Gendarme.Rules.Globalization.dll"/>
<rules include="*" from="Gendarme.Rules.Xamarin.dll"/>
<!-- no rule from Gendarme.Rules.Gendarme is included in this set -->

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

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="3.5" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@ -9,7 +9,6 @@
<OutputType>Library</OutputType>
<RootNamespace>Xamarin.Components.Analysis</RootNamespace>
<AssemblyName>Gendarme.Rules.Xamarin</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@ -19,6 +18,11 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<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/" />
</CustomCommands>
</CustomCommands>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Optimize>true</Optimize>

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

@ -1,6 +1,6 @@

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gendarme.Rules.Xamarin", "Gendarme.Rules.Xamarin.csproj", "{6C4585A1-E675-4ABF-8D99-456EFDB1B8E8}"
EndProject
Global

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

@ -1,29 +0,0 @@
<Properties>
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
<MonoDevelop.Ide.Workbench ActiveDocument="TargetsPrereleaseXamarinIOS.cs">
<Files>
<File FileName="TargetsPrereleaseXamarinIOS.cs" Line="1" Column="1" />
</Files>
<Pads>
<Pad Id="ProjectPad">
<State expanded="True">
<Node name="Gendarme.Rules.Xamarin" expanded="True" selected="True">
<Node name="Properties" expanded="True" />
</Node>
</State>
</Pad>
<Pad Id="ClassPad">
<State expanded="True" selected="True" />
</Pad>
<Pad Id="MonoDevelop.Debugger.WatchPad">
<State>
<Value>refs[467]</Value>
</State>
</Pad>
</Pads>
</MonoDevelop.Ide.Workbench>
<MonoDevelop.Ide.DebuggingService.Breakpoints>
<BreakpointStore />
</MonoDevelop.Ide.DebuggingService.Breakpoints>
<MonoDevelop.Ide.DebuggingService.PinnedWatches />
</Properties>

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

@ -17,22 +17,29 @@ namespace Gendarme.Rules.Xamarin
// Look for the TargetPlatform attribute, which indicates
// .NET 4.0 support. This is only available in XI 6.3+.
// e.g. TargetFramework ("MonoTouch,Version=v4.0", DisplayName = "MonoTouch")
var result = assembly.CustomAttributes.Any (attrib =>
attrib.AttributeType.Name == "TargetFrameworkAttribute"
&& attrib.ConstructorArguments.Any (carg => carg.Value.Equals("MonoTouch,Version=v4.0"))
);
// This is seen as warning MT0011.
var result = CheckForMT0011 (assembly);
if (result)
Runner.Report (assembly, Severity.Critical, Confidence.High, "This assembly targets MonoTouch,Version=v4.0, which is not a stable release (MT0011).");
// Now we attempt to detect the use of type/members that were not available in MonoTouch 6.2.x.
// There's no point in checking if we already know we have a violation.
if (!result && TargetsPrereleaseXamarinIOS.CheckForMT2002 (assembly))
{
result = true;
if (result)
Runner.Report (assembly, Severity.Critical, Confidence.High, "This assembly was not compiled using Xamarin.iOS Stable.");
Runner.Report (assembly, Severity.Critical, Confidence.High, "This assembly was not compiled using Xamarin.iOS Stable (MT2002).");
}
return result ? RuleResult.Failure : RuleResult.Success;
}
static bool CheckForMT0011 (AssemblyDefinition assembly)
{
return assembly.CustomAttributes.Any (attrib => attrib.AttributeType.Name == "TargetFrameworkAttribute"
&& attrib.ConstructorArguments.Any (carg => carg.Value.Equals ("MonoTouch,Version=v4.0"))
);
}
/// <summary>
/// Checks for the conditions that result in MT2002.
/// </summary>