[Monodevelop-patches-list] r1735 - in trunk/MonoDevelop/src/AddIns/Misc: . AssemblyAnalyser AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Engine AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/DesignRules AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer.AddIn AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer.AddIn/Gui AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer.AddIn/Gui/Panels
commit-watcher at mono-cvs.ximian.com
commit-watcher at mono-cvs.ximian.com
Thu Jun 10 22:19:09 EDT 2004
Author: jluke
Date: 2004-06-10 22:19:09 -0400 (Thu, 10 Jun 2004)
New Revision: 1735
Added:
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/AssemblyAnalyser.key
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/AssemblyAnalyzer.cmbx
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer.AddIn/
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer.AddIn/AssemblyAnalyser.addin.xml
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer.AddIn/AssemblyInfo.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer.AddIn/Commands.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer.AddIn/Gui/
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer.AddIn/Gui/AssemblyAnalyserControl.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer.AddIn/Gui/AssemblyAnalyserView.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer.AddIn/Gui/Panels/
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer.AddIn/Gui/Panels/AssemblyRuleViewControl.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer.AddIn/Gui/Panels/AssemblyTreeControl.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer.AddIn/Gui/Panels/ResultDetailsView.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer.AddIn/Gui/Panels/ResultListControl.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer.AddIn/ICSharpCode.AssemblyAnalyser.Addin.prjx
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer.AddIn/Makefile
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/AssemblyInfo.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Engine/
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Engine/AssemblyAnalyser.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Engine/Resolution.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/ICSharpCode.AssemblyAnalyser.prjx
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Makefile
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/AbstractReflectionRule.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/AbstractRule.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/DesignRules/
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/DesignRules/AbstractTypesPublicConstructorsRule.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/DesignRules/AssemblyClsCompliantRule.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/DesignRules/AssemblyStrongNameRule.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/DesignRules/AssemblyVersionNumberRule.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/DesignRules/AvoidNamespacesWithFewMembers.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/DesignRules/EventFirstParameterIsObjectRule.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/DesignRules/EventHandlersReturnVoidRule.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/DesignRules/EventSecondParameterIsEventArgsRule.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/DesignRules/EventsHaveTwoParametersRule.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/DesignRules/InterfaceNotEmptyRule.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/DesignRules/PropertiesShouldNotHaveSetOnly.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/DesignRules/TypesHaveNoPublicInstanceFields.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/DesignRules/TypesShouldBeInNamespacesRule.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/IAssemblyRule.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/IConstructorRule.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/IEventRule.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/IFieldRule.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/IMemberRule.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/IMethodBaseRule.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/IMethodRule.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/IModuleRule.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/INamespaceRule.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/IParameterRule.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/IPropertyRule.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/IReflectionRule.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/IRule.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/ITypeRule.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/AttributeSuffixIsAttributeRule.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/CheckCollectionSuffix.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/DelegatesHaveNoDelegateSuffix.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/DictionaryTypeSuffixIsDictionary.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/EnumsHaveNoEnumSuffix.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/EventArgsSuffixIsEventArgsRule.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/EventFirstParameterNameIsSender.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/EventHandlerSuffixIsEventHandler.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/EventSecondParameterNameIsE.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/EventsDoNotHaveBeforeOrAfterPrefix.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/ExceptionSuffixIsExceptionRule.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/FlagEnumerationsArePlural.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/InterfacesPrefixIsI.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/MembersArePascalCased.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/MembersDoNotContainUnderscores.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/MembershipConditionNamesSuffixIsMembershipCondition.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/NamespacesArePascalCased.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/NamespacesDoNotContainUnderscores.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/OnlyAttributesSuffixAttributeRule.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/OnlyCollectionsSuffixCollectionRule.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/OnlyEventArgsSuffixEventArgsRule.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/OnlyEventHandlerSuffixIsEventHandlerRule.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/OnlyExceptionsSuffixExceptionRule.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/OnlyPermissionsSuffixPermissionRule.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/OnlyStreamsSuffixStreamRule.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/ParameterNamesDoNotHaveUnderscores.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/ParametersAreCamelCased.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/PermissionSuffixIsPermissionRule.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/StreamSuffixIsStreamRule.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/TypeNamesDoNotContainUnderscores.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/TypesArePascalCased.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/TypesImplementingInterfacesHaveNoSuffixImplRule.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingUtilities.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/PriorityLevel.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/ProtectionLevels.cs
trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/TODO.txt
Log:
import beginnig of port of AssemblyAnalyzer
the AddIn Gui stuff needs to be ported, etc.
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/AssemblyAnalyser.key
===================================================================
(Binary files differ)
Property changes on: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/AssemblyAnalyser.key
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/AssemblyAnalyzer.cmbx
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/AssemblyAnalyzer.cmbx 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/AssemblyAnalyzer.cmbx 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,20 @@
+<Combine fileversion="1.0" name="AssemblyAnalyser" description="">
+ <StartMode startupentry="ICSharpCode.AssemblyAnalyser.AddIn" single="True">
+ <Execute entry="ICSharpCode.AssemblyAnalyser.AddIn" type="None" />
+ <Execute entry="ICSharpCode.AssemblyAnalyser" type="None" />
+ </StartMode>
+ <Entries>
+ <Entry filename=".\ICSharpCode.AssemblyAnalyzer.AddIn\ICSharpCode.AssemblyAnalyser.Addin.prjx" />
+ <Entry filename=".\ICSharpCode.AssemblyAnalyzer\ICSharpCode.AssemblyAnalyser.prjx" />
+ </Entries>
+ <Configurations active="Debug">
+ <Configuration name="Release">
+ <Entry name="ICSharpCode.AssemblyAnalyser.AddIn" configurationname="Debug" build="False" />
+ <Entry name="ICSharpCode.AssemblyAnalyser" configurationname="Debug" build="False" />
+ </Configuration>
+ <Configuration name="Debug">
+ <Entry name="ICSharpCode.AssemblyAnalyser.AddIn" configurationname="Debug" build="False" />
+ <Entry name="ICSharpCode.AssemblyAnalyser" configurationname="Debug" build="False" />
+ </Configuration>
+ </Configurations>
+</Combine>
\ No newline at end of file
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/AssemblyInfo.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/AssemblyInfo.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/AssemblyInfo.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,37 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+// Information about this assembly is defined by the following
+// attributes.
+//
+// change them to the information which is associated with the assembly
+// you compile.
+
+[assembly: AssemblyTitle("MonoDevelop.AssemblyAnalyser")]
+[assembly: AssemblyDescription("Analyses the assembly for .NET coding standards")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("")]
+[assembly: AssemblyCopyright("")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// The assembly version has following format :
+//
+// Major.Minor.Build.Revision
+//
+// You can specify all values by your own or you can build default build and revision
+// numbers with the '*' character (the default):
+
+[assembly: AssemblyVersion("1.0.*")]
+
+// The following attributes specify the key for the sign of your assembly. See the
+// .NET Framework documentation for more information about signing.
+// This is not required, if you don't want signing let these attributes like they're.
+[assembly: AssemblyDelaySign(false)]
+#if TEST
+[assembly: AssemblyKeyFile("")]
+#else
+[assembly: AssemblyKeyFile("")]
+//[assembly: AssemblyKeyFile("../src/AddIns/Misc/AssemblyAnalyser/AssemblyAnalyser.key")]
+#endif
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Engine/AssemblyAnalyser.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Engine/AssemblyAnalyser.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Engine/AssemblyAnalyser.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,213 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Collections;
+using System.Reflection;
+using MonoDevelop.AssemblyAnalyser.Rules;
+
+namespace MonoDevelop.AssemblyAnalyser
+{
+ /// <summary>
+ /// Description of AssemblyAnalyser.
+ /// </summary>
+ public class AssemblyAnalyser : System.MarshalByRefObject
+ {
+ ArrayList assemblyRules = new ArrayList();
+ ArrayList moduleRules = new ArrayList();
+ ArrayList typeRules = new ArrayList();
+ ArrayList namespaceRules = new ArrayList();
+ ArrayList memberRules = new ArrayList();
+ ArrayList methodBaseRules = new ArrayList();
+ ArrayList constructorRules = new ArrayList();
+ ArrayList eventRules = new ArrayList();
+ ArrayList fieldRules = new ArrayList();
+ ArrayList methodRules = new ArrayList();
+ ArrayList parameterRules = new ArrayList();
+ ArrayList propertyRules = new ArrayList();
+
+ ArrayList resolutions = new ArrayList();
+
+ Hashtable namespaces = new Hashtable();
+
+ public ArrayList Resolutions {
+ get {
+ return resolutions;
+ }
+ }
+
+ public AssemblyAnalyser()
+ {
+
+ Type[] types = typeof(AssemblyAnalyser).Assembly.GetTypes();
+ foreach (Type type in types) {
+ if (!type.IsAbstract && type.IsClass) {
+ if (type.GetInterface(typeof(IAssemblyRule).FullName) != null) {
+ assemblyRules.Add(type.Assembly.CreateInstance(type.FullName));
+ } else if (type.GetInterface(typeof(IConstructorRule).FullName) != null) {
+ constructorRules.Add(type.Assembly.CreateInstance(type.FullName));
+ } else if (type.GetInterface(typeof(IEventRule).FullName) != null) {
+ eventRules.Add(type.Assembly.CreateInstance(type.FullName));
+ } else if (type.GetInterface(typeof(IFieldRule).FullName) != null) {
+ fieldRules.Add(type.Assembly.CreateInstance(type.FullName));
+ } else if (type.GetInterface(typeof(IMemberRule).FullName) != null) {
+ memberRules.Add(type.Assembly.CreateInstance(type.FullName));
+ } else if (type.GetInterface(typeof(IMethodBaseRule).FullName) != null) {
+ methodBaseRules.Add(type.Assembly.CreateInstance(type.FullName));
+ } else if (type.GetInterface(typeof(IMethodRule).FullName) != null) {
+ methodRules.Add(type.Assembly.CreateInstance(type.FullName));
+ } else if (type.GetInterface(typeof(IModuleRule).FullName) != null) {
+ moduleRules.Add(type.Assembly.CreateInstance(type.FullName));
+ } else if (type.GetInterface(typeof(INamespaceRule).FullName) != null) {
+ namespaceRules.Add(type.Assembly.CreateInstance(type.FullName));
+ } else if (type.GetInterface(typeof(IParameterRule).FullName) != null) {
+ parameterRules.Add(type.Assembly.CreateInstance(type.FullName));
+ } else if (type.GetInterface(typeof(IPropertyRule).FullName) != null) {
+ propertyRules.Add(type.Assembly.CreateInstance(type.FullName));
+ } else if (type.GetInterface(typeof(ITypeRule).FullName) != null) {
+ typeRules.Add(type.Assembly.CreateInstance(type.FullName));
+ }
+ }
+ }
+ }
+
+ void AddResolutions(Resolution resolution)
+ {
+ if (resolution != null) {
+ resolutions.Add(resolution);
+ }
+ }
+
+ public void Analyse(string fileName)
+ {
+ Assembly assembly = null;
+ try {
+ assembly = Assembly.LoadFrom(fileName);
+ } catch (Exception e) {
+ resolutions.Add(new Resolution(new CustomRule("${res:MonoDevelop.AssemblyAnalyser.AssemblyCantBeLoaded.Description}",
+ "${res:MonoDevelop.AssemblyAnalyser.AssemblyCantBeLoaded.Details}", PriorityLevel.CriticalError, 100),
+ "${res:MonoDevelop.AssemblyAnalyser.AssemblyCantBeLoaded.Resolution}",
+ fileName,
+ new string[,] { { "FileName", fileName }, {"ExceptionMessage", e.Message}}));
+ return;
+ }
+ Analyse(assembly);
+ }
+
+ public void Analyse(Module module, Type type)
+ {
+ if (type.IsSpecialName || !(Char.IsLetter(type.Name[0]) || type.Name[0] == '_')) {
+ return;
+ }
+ string ns = type.Namespace == null ? "" : type.Namespace;
+ if (namespaces[ns] == null) {
+ namespaces[ns] = new ArrayList();
+ }
+ ((ArrayList)namespaces[ns]).Add(type);
+
+ foreach (ITypeRule typeRule in typeRules) {
+ AddResolutions(typeRule.Check(type));
+ }
+
+ foreach (Type nestedType in type.GetNestedTypes()) {
+ Analyse(module, nestedType);
+ }
+ BindingFlags bf = BindingFlags.DeclaredOnly |
+ BindingFlags.Public |
+ BindingFlags.NonPublic |
+ BindingFlags.Static |
+ BindingFlags.Instance;
+
+
+ foreach (MemberInfo memberInfo in type.GetMembers(bf)) {
+ foreach (IMemberRule memberRule in memberRules) {
+ AddResolutions(memberRule.Check(module, memberInfo));
+ }
+ }
+
+ foreach (ConstructorInfo constructorInfo in type.GetConstructors(bf)) {
+ if (!constructorInfo.IsSpecialName) {
+ // search parameters
+ foreach (ParameterInfo parameter in constructorInfo.GetParameters()) {
+ foreach (IParameterRule parameterRule in parameterRules) {
+ AddResolutions(parameterRule.Check(module, parameter));
+ }
+ }
+
+ foreach (IConstructorRule constructorRule in constructorRules) {
+ AddResolutions(constructorRule.Check(constructorInfo));
+ }
+ }
+ }
+
+ foreach (EventInfo eventInfo in type.GetEvents(bf)) {
+ if (!eventInfo.IsSpecialName) {
+ foreach (IEventRule eventRule in eventRules) {
+ AddResolutions(eventRule.Check(eventInfo));
+ }
+ }
+ }
+
+ foreach (FieldInfo fieldInfo in type.GetFields(bf)) {
+ if (!fieldInfo.IsSpecialName) {
+ foreach (IFieldRule fieldRule in fieldRules) {
+ AddResolutions(fieldRule.Check(module, fieldInfo));
+ }
+ }
+ }
+
+ // TODO: IMethodBaseRule
+ foreach (MethodInfo methodInfo in type.GetMethods(bf)) {
+ if (!methodInfo.IsSpecialName) {
+ Console.WriteLine(methodInfo.Attributes);
+
+ // search parameters
+ foreach (ParameterInfo parameter in methodInfo.GetParameters()) {
+ foreach (IParameterRule parameterRule in parameterRules) {
+ AddResolutions(parameterRule.Check(module, parameter));
+ }
+ }
+
+ foreach (IMethodRule methodRule in methodRules) {
+ AddResolutions(methodRule.Check(module, methodInfo));
+ }
+ }
+ }
+
+ foreach (PropertyInfo propertyInfo in type.GetProperties(bf)) {
+ if (!propertyInfo.IsSpecialName) {
+ foreach (IPropertyRule propertyRule in propertyRules) {
+ AddResolutions(propertyRule.Check(propertyInfo));
+ }
+ }
+ }
+ }
+ public void Analyse(Assembly assembly)
+ {
+ namespaces = new Hashtable();
+ resolutions = new ArrayList();
+ foreach (IAssemblyRule assemblyRule in assemblyRules) {
+ AddResolutions(assemblyRule.Check(assembly));
+ }
+
+ foreach (Module module in assembly.GetModules()) {
+ foreach (IModuleRule moduleRule in moduleRules) {
+ AddResolutions(moduleRule.Check(module));
+ }
+ foreach (Type type in module.GetTypes()) {
+ Analyse(module, type);
+ }
+ }
+
+ foreach (DictionaryEntry namespaceEntry in namespaces) {
+ foreach (INamespaceRule namespaceRule in namespaceRules) {
+ AddResolutions(namespaceRule.Check(namespaceEntry.Key.ToString(), (ArrayList)namespaceEntry.Value));
+ }
+ }
+ }
+ }
+}
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Engine/Resolution.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Engine/Resolution.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Engine/Resolution.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,59 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using MonoDevelop.AssemblyAnalyser.Rules;
+
+namespace MonoDevelop.AssemblyAnalyser
+{
+ /// </summary>
+ /// <summary>
+ /// Description of Resolution.
+ public class Resolution : System.MarshalByRefObject
+ {
+ IRule failedRule;
+ string text;
+ string item;
+ string[,] variables;
+
+ public IRule FailedRule {
+ get {
+ return failedRule;
+ }
+ }
+ public string Text {
+ get {
+ return text;
+ }
+ }
+ public string Item {
+ get {
+ return item;
+ }
+ }
+ public string[,] Variables {
+ get {
+ return variables;
+ }
+ }
+
+ public Resolution(IRule failedRule, string text, string item)
+ {
+ this.failedRule = failedRule;
+ this.text = text;
+ this.item = item;
+ }
+
+ public Resolution(IRule failedRule, string text, string item, string[,] variables)
+ {
+ this.failedRule = failedRule;
+ this.text = text;
+ this.item = item;
+ this.variables = variables;
+ }
+ }
+}
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/ICSharpCode.AssemblyAnalyser.prjx
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/ICSharpCode.AssemblyAnalyser.prjx 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/ICSharpCode.AssemblyAnalyser.prjx 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,96 @@
+<Project name="ICSharpCode.AssemblyAnalyser" standardNamespace="ICSharpCode.AssemblyAnalyser" description="" newfilesearch="None" enableviewstate="True" version="1.1" projecttype="C#">
+ <Contents>
+ <File name=".\AssemblyInfo.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Rules" subtype="Directory" buildaction="Compile" dependson="" data="" />
+ <File name=".\Rules\IAssemblyRule.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Rules\IConstructorRule.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Rules\IEventRule.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Rules\IFieldRule.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Rules\IMemberRule.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Rules\IMethodBaseRule.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Rules\IMethodRule.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Rules\IModuleRule.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Rules\INamespaceRule.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Rules\IParameterRule.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Rules\IPropertyRule.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Rules\IReflectionRule.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Rules\IRule.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Rules\ITypeRule.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Rules\ProtectionLevels.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Rules\PriorityLevel.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Engine" subtype="Directory" buildaction="Compile" dependson="" data="" />
+ <File name=".\Engine\AssemblyAnalyser.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Rules\AbstractRule.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Rules\AbstractReflectionRule.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Engine\Resolution.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Rules\DesignRules\AssemblyStrongNameRule.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Rules\DesignRules\AssemblyVersionNumberRule.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Rules\DesignRules\InterfaceNotEmptyRule.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Rules\DesignRules\AbstractTypesPublicConstructorsRule.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Rules\NamingRules" subtype="Directory" buildaction="Compile" dependson="" data="" />
+ <File name=".\Rules\NamingRules\AttributeSuffixIsAttributeRule.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Rules\NamingRules\CheckCollectionSuffix.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Rules\NamingRules\DelegatesHaveNoDelegateSuffix.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Rules\NamingRules\DictionaryTypeSuffixIsDictionary.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Rules\NamingRules\EnumsHaveNoEnumSuffix.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Rules\NamingRules\EventArgsSuffixIsEventArgsRule.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Rules\NamingRules\EventFirstParameterNameIsSender.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Rules\NamingRules\EventHandlerSuffixIsEventHandler.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Rules\NamingRules\EventsDoNotHaveBeforeOrAfterPrefix.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Rules\NamingRules\EventSecondParameterNameIsE.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Rules\NamingRules\ExceptionSuffixIsExceptionRule.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Rules\NamingRules\FlagEnumerationsArePlural.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Rules\NamingRules\InterfacesPrefixIsI.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Rules\NamingUtilities.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Rules\NamingRules\MembersArePascalCased.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Rules\NamingRules\OnlyAttributesSuffixAttributeRule.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Rules\NamingRules\OnlyCollectionsSuffixCollectionRule.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Rules\NamingRules\OnlyStreamsSuffixStreamRule.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Rules\NamingRules\StreamSuffixIsStreamRule.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Rules\NamingRules\TypeNamesDoNotContainUnderscores.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\TODO.txt" subtype="Code" buildaction="Nothing" dependson="" data="" />
+ <File name=".\Rules\NamingRules\TypesImplementingInterfacesHaveNoSuffixImplRule.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Rules\NamingRules\OnlyEventArgsSuffixEventArgsRule.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Rules\NamingRules\OnlyExceptionsSuffixExceptionRule.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Rules\NamingRules\NamespacesArePascalCased.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Rules\NamingRules\NamespacesDoNotContainUnderscores.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Rules\NamingRules\MembershipConditionNamesSuffixIsMembershipCondition.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Rules\NamingRules\PermissionSuffixIsPermissionRule.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Rules\NamingRules\MembersDoNotContainUnderscores.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Rules\NamingRules\OnlyEventHandlerSuffixIsEventHandlerRule.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Rules\NamingRules\OnlyPermissionsSuffixPermissionRule.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Rules\NamingRules\TypesArePascalCased.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Rules\NamingRules\ParameterNamesDoNotHaveUnderscores.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Rules\NamingRules\ParametersAreCamelCased.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Rules\DesignRules\EventHandlersReturnVoidRule.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Rules\DesignRules\EventFirstParameterIsObjectRule.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Rules\DesignRules\EventSecondParameterIsEventArgsRule.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Rules\DesignRules\EventsHaveTwoParametersRule.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Rules\DesignRules\TypesShouldBeInNamespacesRule.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Rules\DesignRules\AvoidNamespacesWithFewMembers.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Rules\DesignRules\PropertiesShouldNotHaveSetOnly.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Rules\DesignRules\TypesHaveNoPublicInstanceFields.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Rules\DesignRules\AssemblyClsCompliantRule.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ </Contents>
+ <References>
+ <Reference type="Gac" refto="nunit.framework, Version=2.1.4.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77" localcopy="False" />
+ </References>
+ <DeploymentInformation target="" script="" strategy="File" />
+ <Configuration runwithwarnings="True" name="Debug">
+ <CodeGeneration runtime="MsNet" compiler="Csc" compilerversion="" warninglevel="4" nowarn="" includedebuginformation="True" optimize="False" unsafecodeallowed="False" generateoverflowchecks="True" mainclass="" target="Library" definesymbols="TEST" generatexmldocumentation="False" win32Icon="" />
+ <Execution commandlineparameters="" consolepause="True" />
+ <Output directory="..\..\..\..\..\bin" assembly="ICSharpCode.AssemblyAnalyser" executeScript="..\..\..\..\..\bin\SharpDevelop.exe" executeBeforeBuild="" executeAfterBuild="" />
+ </Configuration>
+ <Configurations active="Debug">
+ <Configuration runwithwarnings="True" name="Debug">
+ <CodeGeneration runtime="MsNet" compiler="Csc" compilerversion="" warninglevel="4" nowarn="" includedebuginformation="True" optimize="False" unsafecodeallowed="False" generateoverflowchecks="True" mainclass="" target="Library" definesymbols="TEST" generatexmldocumentation="False" win32Icon="" />
+ <Execution commandlineparameters="" consolepause="True" />
+ <Output directory="..\..\..\..\..\bin" assembly="ICSharpCode.AssemblyAnalyser" executeScript="..\..\..\..\..\bin\SharpDevelop.exe" executeBeforeBuild="" executeAfterBuild="" />
+ </Configuration>
+ <Configuration runwithwarnings="False" name="Release">
+ <CodeGeneration runtime="MsNet" compiler="Csc" compilerversion="" warninglevel="4" nowarn="" includedebuginformation="False" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" mainclass="" target="Library" definesymbols="" generatexmldocumentation="False" win32Icon="" />
+ <Execution commandlineparameters="" consolepause="True" />
+ <Output directory="..\..\..\..\..\bin" assembly="ICSharpCode.AssemblyAnalyser" executeScript="..\..\..\..\..\bin\SharpDevelop.exe" executeBeforeBuild="" executeAfterBuild="" />
+ </Configuration>
+ </Configurations>
+</Project>
\ No newline at end of file
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Makefile
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Makefile 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Makefile 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,77 @@
+
+ASSEMBLY = ICSharpCode.AssemblyAnalyzer.dll
+CSC = mcs /debug
+
+FILES = \
+./Engine/AssemblyAnalyser.cs \
+./Engine/Resolution.cs \
+./Rules/AbstractRule.cs \
+./Rules/IParameterRule.cs \
+./Rules/IMemberRule.cs \
+./Rules/IConstructorRule.cs \
+./Rules/IPropertyRule.cs \
+./Rules/NamingUtilities.cs \
+./Rules/IAssemblyRule.cs \
+./Rules/AbstractReflectionRule.cs \
+./Rules/DesignRules/AssemblyVersionNumberRule.cs \
+./Rules/DesignRules/TypesShouldBeInNamespacesRule.cs \
+./Rules/DesignRules/EventsHaveTwoParametersRule.cs \
+./Rules/DesignRules/AssemblyClsCompliantRule.cs \
+./Rules/DesignRules/PropertiesShouldNotHaveSetOnly.cs \
+./Rules/DesignRules/InterfaceNotEmptyRule.cs \
+./Rules/DesignRules/EventSecondParameterIsEventArgsRule.cs \
+./Rules/DesignRules/EventHandlersReturnVoidRule.cs \
+./Rules/DesignRules/TypesHaveNoPublicInstanceFields.cs \
+./Rules/DesignRules/AbstractTypesPublicConstructorsRule.cs \
+./Rules/DesignRules/AvoidNamespacesWithFewMembers.cs \
+./Rules/DesignRules/EventFirstParameterIsObjectRule.cs \
+./Rules/DesignRules/AssemblyStrongNameRule.cs \
+./Rules/ProtectionLevels.cs \
+./Rules/IModuleRule.cs \
+./Rules/ITypeRule.cs \
+./Rules/IMethodRule.cs \
+./Rules/IRule.cs \
+./Rules/IReflectionRule.cs \
+./Rules/IFieldRule.cs \
+./Rules/IMethodBaseRule.cs \
+./Rules/PriorityLevel.cs \
+./Rules/NamingRules/CheckCollectionSuffix.cs \
+./Rules/NamingRules/PermissionSuffixIsPermissionRule.cs \
+./Rules/NamingRules/NamespacesArePascalCased.cs \
+./Rules/NamingRules/ParametersAreCamelCased.cs \
+./Rules/NamingRules/EventFirstParameterNameIsSender.cs \
+./Rules/NamingRules/FlagEnumerationsArePlural.cs \
+./Rules/NamingRules/MembershipConditionNamesSuffixIsMembershipCondition.cs \
+./Rules/NamingRules/InterfacesPrefixIsI.cs \
+./Rules/NamingRules/MembersDoNotContainUnderscores.cs \
+./Rules/NamingRules/ExceptionSuffixIsExceptionRule.cs \
+./Rules/NamingRules/ParameterNamesDoNotHaveUnderscores.cs \
+./Rules/NamingRules/MembersArePascalCased.cs \
+./Rules/NamingRules/OnlyEventHandlerSuffixIsEventHandlerRule.cs \
+./Rules/NamingRules/OnlyPermissionsSuffixPermissionRule.cs \
+./Rules/NamingRules/OnlyExceptionsSuffixExceptionRule.cs \
+./Rules/NamingRules/TypeNamesDoNotContainUnderscores.cs \
+./Rules/NamingRules/OnlyStreamsSuffixStreamRule.cs \
+./Rules/NamingRules/EnumsHaveNoEnumSuffix.cs \
+./Rules/NamingRules/NamespacesDoNotContainUnderscores.cs \
+./Rules/NamingRules/TypesArePascalCased.cs \
+./Rules/NamingRules/OnlyAttributesSuffixAttributeRule.cs \
+./Rules/NamingRules/OnlyCollectionsSuffixCollectionRule.cs \
+./Rules/NamingRules/DelegatesHaveNoDelegateSuffix.cs \
+./Rules/NamingRules/EventsDoNotHaveBeforeOrAfterPrefix.cs \
+./Rules/NamingRules/TypesImplementingInterfacesHaveNoSuffixImplRule.cs \
+./Rules/NamingRules/EventHandlerSuffixIsEventHandler.cs \
+./Rules/NamingRules/EventSecondParameterNameIsE.cs \
+./Rules/NamingRules/EventArgsSuffixIsEventArgsRule.cs \
+./Rules/NamingRules/StreamSuffixIsStreamRule.cs \
+./Rules/NamingRules/DictionaryTypeSuffixIsDictionary.cs \
+./Rules/NamingRules/OnlyEventArgsSuffixEventArgsRule.cs \
+./Rules/NamingRules/AttributeSuffixIsAttributeRule.cs \
+./Rules/IEventRule.cs \
+./Rules/INamespaceRule.cs \
+./AssemblyInfo.cs
+
+all: $(ASSEMBLY)
+
+$(ASSEMBLY): $(FILES)
+ $(CSC) /out:$(ASSEMBLY) /target:library $(FILES)
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/AbstractReflectionRule.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/AbstractReflectionRule.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/AbstractReflectionRule.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,41 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ /// <summary>
+ /// Description of AbstractReflectionRule.
+ /// </summary>
+ public abstract class AbstractReflectionRule : AbstractRule, MonoDevelop.AssemblyAnalyser.Rules.IReflectionRule
+ {
+ protected ProtectionLevels memberProtectionLevel = ProtectionLevels.All;
+ protected ProtectionLevels nestedTypeProtectionLevel = ProtectionLevels.All;
+ protected ProtectionLevels typeProtectionLevel = ProtectionLevels.All;
+
+ #region MonoDevelop.AssemblyAnalyser.Rules.IReflectionRule interface implementation
+ public virtual ProtectionLevels MemberProtectionLevel {
+ get {
+ return memberProtectionLevel;
+ }
+ }
+
+ public virtual ProtectionLevels NestedTypeProtectionLevel {
+ get {
+ return nestedTypeProtectionLevel;
+ }
+ }
+
+ public virtual ProtectionLevels TypeProtectionLevel {
+ get {
+ return typeProtectionLevel;
+ }
+ }
+ #endregion
+ }
+}
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/AbstractRule.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/AbstractRule.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/AbstractRule.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,82 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Reflection;
+
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ /// <summary>
+ /// Description of AbstractRule.
+ /// </summary>
+ public abstract class AbstractRule : System.MarshalByRefObject, IRule
+ {
+ protected PriorityLevel priorityLevel = PriorityLevel.Error;
+ protected int certainty = 99;
+
+ #region MonoDevelop.AssemblyAnalyser.Rules.IRule interface implementation
+ public PriorityLevel PriorityLevel {
+ get {
+ return priorityLevel;
+ }
+ }
+
+ public int Certainty {
+ get {
+ return certainty;
+ }
+ }
+
+ public abstract string Description {
+ get;
+ }
+
+ public abstract string Details {
+ get;
+ }
+
+ public virtual void EndAnalysis()
+ {
+ }
+
+ public virtual void StartAnalysis()
+ {
+ }
+ #endregion
+ }
+
+ public class CustomRule : AbstractRule
+ {
+ string description;
+ string details;
+
+ public override string Description {
+ get {
+ return description;
+ }
+ }
+
+ public override string Details {
+ get {
+ return details;
+ }
+ }
+
+ public CustomRule(string description, string details)
+ {
+ this.description = description;
+ this.details = details;
+ }
+ public CustomRule(string description, string details, PriorityLevel priorityLevel, int certainty)
+ {
+ this.description = description;
+ this.details = details;
+ this.priorityLevel = priorityLevel;
+ this.certainty = certainty;
+ }
+ }
+}
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/DesignRules/AbstractTypesPublicConstructorsRule.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/DesignRules/AbstractTypesPublicConstructorsRule.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/DesignRules/AbstractTypesPublicConstructorsRule.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,100 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Reflection;
+
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ /// <summary>
+ /// Description of AssemblyStrongName.
+ /// </summary>
+ public class AbstractTypesPublicConstructorsRule : AbstractReflectionRule, ITypeRule
+ {
+ public override string Description {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.AbstractTypesPublicConstructors.Description}";
+ }
+ }
+
+ public override string Details {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.AbstractTypesPublicConstructors.Details}";
+ }
+ }
+
+ public AbstractTypesPublicConstructorsRule()
+ {
+ priorityLevel = PriorityLevel.CriticalWarning;
+ }
+
+ public Resolution Check(Type type)
+ {
+ if (type.IsAbstract) {
+ foreach (ConstructorInfo info in type.GetConstructors()) {
+ if (info.IsPublic) {
+ return new Resolution(this, "${res:MonoDevelop.AssemblyAnalyser.Rules.AbstractTypesPublicConstructors.Resolution}", type.FullName, new string[,] { { "TypeName", type.FullName }});
+ }
+ }
+ }
+ return null;
+ }
+ }
+}
+
+#region Unit Test
+#if TEST
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ using NUnit.Framework;
+
+ [TestFixture]
+ public class AbstractTypesPublicConstructorsRuleTest
+ {
+ abstract class AbstractClassPublic1 {
+ public AbstractClassPublic1()
+ {
+ }
+ }
+ abstract class AbstractClassPublic2 {
+ protected AbstractClassPublic2()
+ {
+ }
+ public AbstractClassPublic2(int x, int y)
+ {
+ }
+ }
+ [Test]
+ public void TestAbstractTypesWithPublicConstructor()
+ {
+ AbstractTypesPublicConstructorsRule rule = new AbstractTypesPublicConstructorsRule();
+ Assertion.AssertNotNull(rule.Check(typeof(AbstractClassPublic1)));
+ Assertion.AssertNotNull(rule.Check(typeof(AbstractClassPublic2)));
+ }
+
+ abstract class AbstractClass1 {
+ protected AbstractClass1()
+ {
+ }
+ }
+ abstract class AbstractClass2 {
+ protected AbstractClass2(int x, int y)
+ {
+ }
+ }
+
+ [Test]
+ public void TestAbstractTypesWithoutPublicConstructor()
+ {
+ AbstractTypesPublicConstructorsRule rule = new AbstractTypesPublicConstructorsRule();
+ Assertion.AssertNull(rule.Check(typeof(AbstractClass1)));
+ Assertion.AssertNull(rule.Check(typeof(AbstractClass2)));
+ }
+ }
+}
+#endif
+#endregion
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/DesignRules/AssemblyClsCompliantRule.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/DesignRules/AssemblyClsCompliantRule.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/DesignRules/AssemblyClsCompliantRule.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,51 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.IO;
+using System.Reflection;
+
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ /// <summary>
+ /// Description of AssemblyStrongName.
+ /// </summary>
+ public class AssemblyClsCompliantRule : AbstractReflectionRule, IAssemblyRule
+ {
+ public override string Description {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.AssemblyClsCompliantRule.Description}";
+ }
+ }
+
+ public override string Details {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.AssemblyClsCompliantRule.Details}";
+ }
+ }
+
+ public AssemblyClsCompliantRule()
+ {
+ certainty = 99;
+ }
+
+ public Resolution Check(Assembly assembly)
+ {
+ object[] attributes = assembly.GetCustomAttributes(typeof(System.CLSCompliantAttribute), true);
+ if (attributes == null || attributes.Length == 0) {
+ return new Resolution(this, "${res:MonoDevelop.AssemblyAnalyser.Rules.AssemblyClsCompliantRule.Resolution1}", assembly.Location, new string[,] { {"AssemblyName", Path.GetFileName(assembly.Location)} });
+ } else {
+ foreach (CLSCompliantAttribute attr in attributes) {
+ if (!attr.IsCompliant) {
+ return new Resolution(this, "${res:MonoDevelop.AssemblyAnalyser.Rules.AssemblyClsCompliantRule.Resolution2}", assembly.Location, new string[,] { {"AssemblyName", Path.GetFileName(assembly.Location)} });
+ }
+ }
+ }
+ return null;
+ }
+ }
+}
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/DesignRules/AssemblyStrongNameRule.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/DesignRules/AssemblyStrongNameRule.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/DesignRules/AssemblyStrongNameRule.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,45 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.IO;
+using System.Reflection;
+
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ /// <summary>
+ /// Description of AssemblyStrongName.
+ /// </summary>
+ public class AssemblyStrongNameRule : AbstractReflectionRule, IAssemblyRule
+ {
+ public override string Description {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.AssemblyStrongName.Description}";
+ }
+ }
+
+ public override string Details {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.AssemblyStrongName.Details}";
+ }
+ }
+
+ public AssemblyStrongNameRule()
+ {
+ certainty = 95;
+ }
+
+ public Resolution Check(Assembly assembly)
+ {
+ byte[] publicKeyToken = assembly.GetName().GetPublicKeyToken();
+ if (publicKeyToken == null || publicKeyToken.Length == 0) {
+ return new Resolution(this, "${res:MonoDevelop.AssemblyAnalyser.Rules.AssemblyStrongName.Resolution}", assembly.Location, new string[,] { {"AssemblyName", Path.GetFileName(assembly.Location)} });
+ }
+ return null;
+ }
+ }
+}
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/DesignRules/AssemblyVersionNumberRule.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/DesignRules/AssemblyVersionNumberRule.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/DesignRules/AssemblyVersionNumberRule.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,45 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.IO;
+using System.Reflection;
+using MonoDevelop.AssemblyAnalyser.Rules;
+
+namespace MonoDevelop.AssemblyAnalyser
+{
+ /// <summary>
+ /// Description of AssemblyVersionNumber.
+ /// </summary>
+ public class AssemblyVersionNumberRule : AbstractReflectionRule, IAssemblyRule
+ {
+ public override string Description {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.AssemblyVersionNumber.Description}";
+ }
+ }
+
+ public override string Details {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.AssemblyVersionNumber.Details}";
+ }
+ }
+
+ public AssemblyVersionNumberRule()
+ {
+ certainty = 95;
+ }
+
+ public Resolution Check(Assembly assembly)
+ {
+ if (assembly.GetName().Version == new Version(0, 0, 0, 0)) {
+ return new Resolution(this, "${res:MonoDevelop.AssemblyAnalyser.Rules.AssemblyVersionNumber.Resolution}", assembly.Location, new string[,] { {"AssemblyName", Path.GetFileName(assembly.Location)} });
+ }
+ return null;
+ }
+ }
+}
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/DesignRules/AvoidNamespacesWithFewMembers.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/DesignRules/AvoidNamespacesWithFewMembers.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/DesignRules/AvoidNamespacesWithFewMembers.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,75 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Collections;
+
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ /// <summary>
+ /// Description of AvoidNamespacesWithFewMembers.
+ /// </summary>
+ public class AvoidNamespacesWithFewMembers : AbstractReflectionRule, INamespaceRule
+ {
+ public override string Description {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.AvoidNamespacesWithFewMembers.Description}";
+ }
+ }
+
+ public override string Details {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.AvoidNamespacesWithFewMembers.Details}";
+ }
+ }
+
+ public AvoidNamespacesWithFewMembers()
+ {
+ base.certainty = 50;
+ base.priorityLevel = PriorityLevel.Warning;
+ }
+
+ public Resolution Check(string namespaceName, ICollection types)
+ {
+ if (namespaceName != null && namespaceName.Length > 0 && types.Count < 5) {
+ return new Resolution(this, "${res:MonoDevelop.AssemblyAnalyser.Rules.AvoidNamespacesWithFewMembers.Resolution}", namespaceName, new string[,]{{"NamespaceName", namespaceName}});
+ }
+ return null;
+ }
+ }
+}
+#region Unit Test
+#if TEST
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ using NUnit.Framework;
+
+ [TestFixture]
+ public class AvoidNamespacesWithFewMembersTest
+ {
+ [Test]
+ public void TestCorrectNamespaces()
+ {
+ AvoidNamespacesWithFewMembers rule = new AvoidNamespacesWithFewMembers();
+ Assertion.AssertNull(rule.Check("MyNamespace", new Type[] {typeof(System.Object),
+ typeof(System.Object),
+ typeof(System.Object),
+ typeof(System.Object),
+ typeof(System.Object),
+ typeof(System.Object)}));
+ }
+
+ [Test]
+ public void TestIncorrectAttribute()
+ {
+ AvoidNamespacesWithFewMembers rule = new AvoidNamespacesWithFewMembers();
+ Assertion.AssertNotNull(rule.Check("a", new Type[] {}));
+ }
+ }
+}
+#endif
+#endregion
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/DesignRules/EventFirstParameterIsObjectRule.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/DesignRules/EventFirstParameterIsObjectRule.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/DesignRules/EventFirstParameterIsObjectRule.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,90 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Reflection;
+
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ /// <summary>
+ /// Description of EventFirstParameterIsObject.
+ /// </summary>
+ public class EventFirstParameterIsObjectRule : AbstractReflectionRule, IEventRule
+ {
+ public override string Description {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.EventFirstParameterIsObject.Description}";
+ }
+ }
+
+ public override string Details {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.EventFirstParameterIsObject.Details}";
+ }
+ }
+
+ public EventFirstParameterIsObjectRule()
+ {
+ base.certainty = 99;
+ }
+
+ public Resolution Check(EventInfo evnt)
+ {
+ MethodInfo invokeMethod = evnt.EventHandlerType.GetMethod("Invoke");
+ ParameterInfo[] parameters = invokeMethod.GetParameters();
+
+ if (parameters.Length > 0 && parameters[0].ParameterType != typeof(System.Object)) {
+ return new Resolution(this, "${res:MonoDevelop.AssemblyAnalyser.Rules.EventFirstParameterIsObject.Resolution}", evnt.EventHandlerType.FullName, new string[,] { { "EventType", evnt.EventHandlerType.FullName }, { "OldParameterType", parameters[0].ParameterType.FullName }});
+ }
+ return null;
+ }
+ }
+}
+
+#region Unit Test
+#if TEST
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ using NUnit.Framework;
+
+ [TestFixture]
+ public class EventFirstParameterIsObjectRuleTest
+ {
+ public delegate void CorrectEventHandler(object sender, EventArgs e);
+ public event CorrectEventHandler CorrectEvent;
+ protected virtual void OnCorrectEvent(EventArgs e)
+ {
+ if (CorrectEvent != null) {
+ CorrectEvent(this, e);
+ }
+ }
+ [Test]
+ public void TestCorrectEventHandler()
+ {
+ EventFirstParameterIsObjectRule rule = new EventFirstParameterIsObjectRule();
+ Assertion.AssertNull(rule.Check(this.GetType().GetEvent("CorrectEvent")));
+ }
+
+ public delegate void IncorrectEventHandler(int sender, EventArgs e);
+ public event IncorrectEventHandler IncorrectEvent;
+ protected virtual void OnIncorrectEvent(EventArgs e)
+ {
+ if (IncorrectEvent != null) {
+ IncorrectEvent(6, e);
+ }
+ }
+
+ [Test]
+ public void TestIncorrectEventHandler()
+ {
+ EventFirstParameterIsObjectRule rule = new EventFirstParameterIsObjectRule();
+ Assertion.AssertNotNull(rule.Check(this.GetType().GetEvent("IncorrectEvent")));
+ }
+ }
+}
+#endif
+#endregion
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/DesignRules/EventHandlersReturnVoidRule.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/DesignRules/EventHandlersReturnVoidRule.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/DesignRules/EventHandlersReturnVoidRule.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,88 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Reflection;
+
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ /// <summary>
+ /// Description of EventFirstParameterNameIsSender.
+ /// </summary>
+ public class EventHandlersReturnVoidRule : AbstractReflectionRule, IEventRule
+ {
+ public override string Description {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.EventHandlersReturnVoid.Description}";
+ }
+ }
+
+ public override string Details {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.EventHandlersReturnVoid.Details}";
+ }
+ }
+
+ public EventHandlersReturnVoidRule()
+ {
+ base.certainty = 99;
+ }
+
+ public Resolution Check(EventInfo evnt)
+ {
+ MethodInfo invokeMethod = evnt.EventHandlerType.GetMethod("Invoke");
+ if (invokeMethod.ReturnType != typeof(void)) {
+ return new Resolution(this, "${res:MonoDevelop.AssemblyAnalyser.Rules.EventHandlersReturnVoid.Resolution}", evnt.EventHandlerType.FullName, new string[,] { { "EventType", evnt.EventHandlerType.FullName }, {"OldReturnType", invokeMethod.ReturnType.FullName}});
+ }
+ return null;
+ }
+ }
+}
+
+#region Unit Test
+#if TEST
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ using NUnit.Framework;
+
+ [TestFixture]
+ public class EventHandlersReturnVoidRuleTest
+ {
+ public delegate void CorrectEventHandler(object sender, EventArgs e);
+ public event CorrectEventHandler CorrectEvent;
+ protected virtual void OnCorrectEvent(EventArgs e)
+ {
+ if (CorrectEvent != null) {
+ CorrectEvent(this, e);
+ }
+ }
+ [Test]
+ public void TestCorrectEventHandler()
+ {
+ EventHandlersReturnVoidRule rule = new EventHandlersReturnVoidRule();
+ Assertion.AssertNull(rule.Check(this.GetType().GetEvent("CorrectEvent")));
+ }
+
+ public delegate int IncorrectEventHandler(object sender, EventArgs e);
+ public event IncorrectEventHandler IncorrectEvent;
+ protected virtual void OnIncorrectEvent(EventArgs e)
+ {
+ if (IncorrectEvent != null) {
+ IncorrectEvent(this, e);
+ }
+ }
+
+ [Test]
+ public void TestIncorrectEventHandler()
+ {
+ EventHandlersReturnVoidRule rule = new EventHandlersReturnVoidRule();
+ Assertion.AssertNotNull(rule.Check(this.GetType().GetEvent("IncorrectEvent")));
+ }
+ }
+}
+#endif
+#endregion
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/DesignRules/EventSecondParameterIsEventArgsRule.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/DesignRules/EventSecondParameterIsEventArgsRule.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/DesignRules/EventSecondParameterIsEventArgsRule.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,90 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Reflection;
+
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ /// <summary>
+ /// Description of EventFirstParameterIsObject.
+ /// </summary>
+ public class EventSecondParameterIsEventArgsRule : AbstractReflectionRule, IEventRule
+ {
+ public override string Description {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.EventSecondParameterIsEventArgs.Description}";
+ }
+ }
+
+ public override string Details {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.EventSecondParameterIsEventArgs.Details}";
+ }
+ }
+
+ public EventSecondParameterIsEventArgsRule()
+ {
+ base.certainty = 99;
+ }
+
+ public Resolution Check(EventInfo evnt)
+ {
+ MethodInfo invokeMethod = evnt.EventHandlerType.GetMethod("Invoke");
+ ParameterInfo[] parameters = invokeMethod.GetParameters();
+
+ if (parameters.Length > 1 && !typeof(System.EventArgs).IsAssignableFrom(parameters[1].ParameterType)) {
+ return new Resolution(this, "${res:MonoDevelop.AssemblyAnalyser.Rules.EventSecondParameterIsEventArgs.Resolution}", evnt.EventHandlerType.FullName, new string[,] { { "EventType", evnt.EventHandlerType.FullName }, { "OldParameterType", parameters[1].ParameterType.FullName }});
+ }
+ return null;
+ }
+ }
+}
+
+#region Unit Test
+#if TEST
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ using NUnit.Framework;
+
+ [TestFixture]
+ public class EventSecondParameterIsEventArgsRuleTest
+ {
+ public delegate void CorrectEventHandler(object sender, EventArgs e);
+ public event CorrectEventHandler CorrectEvent;
+ protected virtual void OnCorrectEvent(EventArgs e)
+ {
+ if (CorrectEvent != null) {
+ CorrectEvent(this, e);
+ }
+ }
+ [Test]
+ public void TestCorrectEventHandler()
+ {
+ EventSecondParameterIsEventArgsRule rule = new EventSecondParameterIsEventArgsRule();
+ Assertion.AssertNull(rule.Check(this.GetType().GetEvent("CorrectEvent")));
+ }
+
+ public delegate void IncorrectEventHandler(object sender, int e);
+ public event IncorrectEventHandler IncorrectEvent;
+ protected virtual void OnIncorrectEvent(int e)
+ {
+ if (IncorrectEvent != null) {
+ IncorrectEvent(this, e);
+ }
+ }
+
+ [Test]
+ public void TestIncorrectEventHandler()
+ {
+ EventSecondParameterIsEventArgsRule rule = new EventSecondParameterIsEventArgsRule();
+ Assertion.AssertNotNull(rule.Check(this.GetType().GetEvent("IncorrectEvent")));
+ }
+ }
+}
+#endif
+#endregion
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/DesignRules/EventsHaveTwoParametersRule.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/DesignRules/EventsHaveTwoParametersRule.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/DesignRules/EventsHaveTwoParametersRule.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,90 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Reflection;
+
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ /// <summary>
+ /// Description of EventsHaveTwoParameters.
+ /// </summary>
+ public class EventsHaveTwoParametersRule : AbstractReflectionRule, IEventRule
+ {
+ public override string Description {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.EventsHaveTwoParameters.Description}";
+ }
+ }
+
+ public override string Details {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.EventsHaveTwoParameters.Details}";
+ }
+ }
+
+ public EventsHaveTwoParametersRule()
+ {
+ base.certainty = 99;
+ }
+
+ public Resolution Check(EventInfo evnt)
+ {
+ MethodInfo invokeMethod = evnt.EventHandlerType.GetMethod("Invoke");
+ ParameterInfo[] parameters = invokeMethod.GetParameters();
+
+ if (parameters.Length != 2) {
+ return new Resolution(this, "${res:MonoDevelop.AssemblyAnalyser.Rules.EventsHaveTwoParameters.Resolution}", evnt.EventHandlerType.FullName, new string[,] { { "EventType", evnt.EventHandlerType.FullName }});
+ }
+ return null;
+ }
+ }
+}
+
+#region Unit Test
+#if TEST
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ using NUnit.Framework;
+
+ [TestFixture]
+ public class EventsHaveTwoParametersTest
+ {
+ public delegate void CorrectEventHandler(object sender, EventArgs e);
+ public event CorrectEventHandler CorrectEvent;
+ protected virtual void OnCorrectEvent(EventArgs e)
+ {
+ if (CorrectEvent != null) {
+ CorrectEvent(this, e);
+ }
+ }
+ [Test]
+ public void TestCorrectEventHandler()
+ {
+ EventsHaveTwoParametersRule rule = new EventsHaveTwoParametersRule();
+ Assertion.AssertNull(rule.Check(this.GetType().GetEvent("CorrectEvent")));
+ }
+
+ public delegate void IncorrectEventHandler(object sender, EventArgs e, int i);
+ public event IncorrectEventHandler IncorrectEvent;
+ protected virtual void OnIncorrectEvent(EventArgs e)
+ {
+ if (IncorrectEvent != null) {
+ IncorrectEvent(this, e, 5);
+ }
+ }
+
+ [Test]
+ public void TestIncorrectEventHandler()
+ {
+ EventsHaveTwoParametersRule rule = new EventsHaveTwoParametersRule();
+ Assertion.AssertNotNull(rule.Check(this.GetType().GetEvent("IncorrectEvent")));
+ }
+ }
+}
+#endif
+#endregion
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/DesignRules/InterfaceNotEmptyRule.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/DesignRules/InterfaceNotEmptyRule.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/DesignRules/InterfaceNotEmptyRule.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,84 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Reflection;
+
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ /// <summary>
+ /// Description of InterfaceNotEmpty.
+ /// </summary>
+ public class InterfaceNotEmptyRule : AbstractReflectionRule, ITypeRule
+ {
+ public override string Description {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.InterfaceNotEmpty.Description}";
+ }
+ }
+
+ public override string Details {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.InterfaceNotEmpty.Details}";
+ }
+ }
+ public Resolution Check(Type type)
+ {
+ if (type.IsInterface && type.GetMembers().Length == 0) {
+ return new Resolution(this, "${res:MonoDevelop.AssemblyAnalyser.Rules.InterfaceNotEmpty.Resolution}", type.FullName, new string[,] { { "TypeName", type.FullName }});
+ }
+ return null;
+ }
+ }
+}
+
+#region Unit Test
+#if TEST
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ using NUnit.Framework;
+
+ [TestFixture]
+ public class InterfaceNotEmptyRuleTests
+ {
+ interface NonEmptyInterface1
+ {
+ void A();
+ }
+ interface NonEmptyInterface2
+ {
+ event EventHandler TestEvent;
+ }
+ interface NonEmptyInterface3
+ {
+ int MyProperty {
+ get;
+ }
+ }
+ [Test]
+ public void TestNonEmptyInterface()
+ {
+ InterfaceNotEmptyRule rule = new InterfaceNotEmptyRule();
+ Assertion.AssertNull(rule.Check(typeof(NonEmptyInterface1)));
+ Assertion.AssertNull(rule.Check(typeof(NonEmptyInterface2)));
+ Assertion.AssertNull(rule.Check(typeof(NonEmptyInterface3)));
+ }
+
+ interface EmptyInterface
+ {
+ }
+
+ [Test]
+ public void TestEmptyInterface()
+ {
+ InterfaceNotEmptyRule rule = new InterfaceNotEmptyRule();
+ Assertion.AssertNotNull(rule.Check(typeof(EmptyInterface)));
+ }
+ }
+}
+#endif
+#endregion
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/DesignRules/PropertiesShouldNotHaveSetOnly.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/DesignRules/PropertiesShouldNotHaveSetOnly.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/DesignRules/PropertiesShouldNotHaveSetOnly.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,99 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Reflection;
+
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ /// <summary>
+ /// Description of PropertiesShouldNotHaveSetOnly.
+ /// </summary>
+ public class PropertiesShouldNotHaveSetOnly : AbstractReflectionRule, IPropertyRule
+ {
+ public override string Description {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.PropertiesShouldNotHaveSetOnly.Description}";
+ }
+ }
+
+ public override string Details {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.PropertiesShouldNotHaveSetOnly.Details}";
+ }
+ }
+
+ public Resolution Check(PropertyInfo property)
+ {
+ if (!property.CanRead && property.CanWrite) {
+ return new Resolution(this,
+ "${res:MonoDevelop.AssemblyAnalyser.Rules.PropertiesShouldNotHaveSetOnly.Resolution}",
+ NamingUtilities.Combine(property.DeclaringType.FullName, property.Name),
+ new string[,] {
+ {"PropertyName", property.Name},
+ {"DeclaringType", property.DeclaringType.FullName},
+ });
+ }
+ return null;
+ }
+ }
+}
+
+#region Unit Test
+#if TEST
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ using NUnit.Framework;
+
+ [TestFixture]
+ public class PropertiesShouldNotHaveSetOnlyTest
+ {
+ class A {
+ public int Inta {
+ get {
+ return 5;
+ }
+ set {
+
+ }
+ }
+ public string StrB {
+ get {
+ return "";
+ }
+ }
+ }
+ [Test]
+ public void TestCorrectProperties()
+ {
+ PropertiesShouldNotHaveSetOnly rule = new PropertiesShouldNotHaveSetOnly();
+ Assertion.AssertNull(rule.Check(typeof(A).GetProperty("Inta")));
+ Assertion.AssertNull(rule.Check(typeof(A).GetProperty("StrB")));
+ }
+
+ class B {
+ public int Inta {
+ set {
+ }
+ }
+ public string StrB {
+ set {
+ }
+ }
+ }
+
+ [Test]
+ public void TestIncorrectProperties()
+ {
+ PropertiesShouldNotHaveSetOnly rule = new PropertiesShouldNotHaveSetOnly();
+ Assertion.AssertNotNull(rule.Check(typeof(B).GetProperty("Inta")));
+ Assertion.AssertNotNull(rule.Check(typeof(B).GetProperty("StrB")));
+ }
+ }
+}
+#endif
+#endregion
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/DesignRules/TypesHaveNoPublicInstanceFields.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/DesignRules/TypesHaveNoPublicInstanceFields.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/DesignRules/TypesHaveNoPublicInstanceFields.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,105 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Reflection;
+
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ /// <summary>
+ /// Description of PropertiesShouldNotHaveSetOnly.
+ /// </summary>
+ public class TypesHaveNoPublicInstanceFields : AbstractReflectionRule, IFieldRule
+ {
+ public override string Description {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.TypesHaveNoPublicInstanceFields.Description}";
+ }
+ }
+
+ public override string Details {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.TypesHaveNoPublicInstanceFields.Details}";
+ }
+ }
+
+ public TypesHaveNoPublicInstanceFields()
+ {
+ base.certainty = 90;
+ }
+
+ public Resolution Check(Module module, FieldInfo field)
+ {
+ if (!field.IsStatic && (field.IsPublic || field.IsAssembly)) {
+ return new Resolution(this,
+ "${res:MonoDevelop.AssemblyAnalyser.Rules.TypesHaveNoPublicInstanceFields.Resolution}",
+ NamingUtilities.Combine(field.DeclaringType.FullName, field.Name),
+ new string[,] {
+ {"FieldName", field.Name},
+ {"DeclaringType", field.DeclaringType.FullName},
+ });
+ }
+ return null;
+ }
+ }
+}
+
+#region Unit Test
+#if TEST
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ using NUnit.Framework;
+
+ [TestFixture]
+ public class TypesHaveNoPublicInstanceFieldsTest
+ {
+ class A {
+ int a;
+ protected string b;
+ public static int c = 12;
+ public int AA {
+ get {
+ return a;
+ }
+ set {
+ a = value;
+ }
+ }
+ public string B {
+ get {
+ return b;
+ }
+ set {
+ b = value;
+ }
+ }
+ }
+ [Test]
+ public void TestCorrectFields()
+ {
+ TypesHaveNoPublicInstanceFields rule = new TypesHaveNoPublicInstanceFields();
+ Assertion.AssertNull(rule.Check(null, typeof(A).GetField("a", BindingFlags.NonPublic | BindingFlags.Instance)));
+ Assertion.AssertNull(rule.Check(null, typeof(A).GetField("b", BindingFlags.NonPublic | BindingFlags.Instance)));
+ Assertion.AssertNull(rule.Check(null, typeof(A).GetField("c", BindingFlags.Public | BindingFlags.Static)));
+ }
+
+ class B {
+ public int a = 5;
+ internal string b ="";
+ }
+
+ [Test]
+ public void TestIncorrectFields()
+ {
+ TypesHaveNoPublicInstanceFields rule = new TypesHaveNoPublicInstanceFields();
+ Assertion.AssertNotNull(rule.Check(null, typeof(B).GetField("a", BindingFlags.Public | BindingFlags.Instance)));
+ Assertion.AssertNotNull(rule.Check(null, typeof(B).GetField("b", BindingFlags.NonPublic | BindingFlags.Instance)));
+ }
+ }
+}
+#endif
+#endregion
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/DesignRules/TypesShouldBeInNamespacesRule.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/DesignRules/TypesShouldBeInNamespacesRule.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/DesignRules/TypesShouldBeInNamespacesRule.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,74 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Reflection;
+
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ /// <summary>
+ /// Description of TypesShouldBeInNamespaces.
+ /// </summary>
+ public class TypesShouldBeInNamespacesRule : AbstractReflectionRule, ITypeRule
+ {
+ public override string Description {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.TypesShouldBeInNamespaces.Description}";
+ }
+ }
+
+ public override string Details {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.TypesShouldBeInNamespaces.Details}";
+ }
+ }
+
+ public Resolution Check(Type type)
+ {
+ if (type.Namespace == null || type.Namespace.Length == 0) {
+ return new Resolution(this, "${res:MonoDevelop.AssemblyAnalyser.Rules.TypesShouldBeInNamespaces.Resolution}", type.FullName, new string[,] { { "TypeName", type.FullName }});
+ }
+ return null;
+ }
+ }
+}
+
+#region Unit Test
+#if TEST
+class OutsideNamespace
+{
+
+}
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ using NUnit.Framework;
+
+ [TestFixture]
+ public class TypesShouldBeInNamespacesRuleTest
+ {
+ interface ICorrectInterface
+ {
+ }
+ [Test]
+ public void TestCorrectAttribute()
+ {
+ TypesShouldBeInNamespacesRule rule = new TypesShouldBeInNamespacesRule();
+ Assertion.AssertNull(rule.Check(typeof(System.ICloneable)));
+ Assertion.AssertNull(rule.Check(typeof(TypesShouldBeInNamespacesRuleTest)));
+ Assertion.AssertNull(rule.Check(typeof(ICorrectInterface)));
+ }
+
+ [Test]
+ public void TestIncorrectAttribute()
+ {
+ TypesShouldBeInNamespacesRule rule = new TypesShouldBeInNamespacesRule();
+ Assertion.AssertNotNull(rule.Check(typeof(OutsideNamespace)));
+ }
+ }
+}
+#endif
+#endregion
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/IAssemblyRule.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/IAssemblyRule.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/IAssemblyRule.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,20 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Reflection;
+
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ /// <summary>
+ /// Description of IAssemblyRule.
+ /// </summary>
+ public interface IAssemblyRule : IReflectionRule
+ {
+ Resolution Check(Assembly assembly);
+ }
+}
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/IConstructorRule.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/IConstructorRule.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/IConstructorRule.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,20 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Reflection;
+
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ /// <summary>
+ /// Description of IConstructorRule.
+ /// </summary>
+ public interface IConstructorRule : IReflectionRule
+ {
+ Resolution Check(ConstructorInfo constructor);
+ }
+}
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/IEventRule.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/IEventRule.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/IEventRule.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,20 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Reflection;
+
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ /// <summary>
+ /// Description of IEventRule.
+ /// </summary>
+ public interface IEventRule : IReflectionRule
+ {
+ Resolution Check(EventInfo evnt);
+ }
+}
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/IFieldRule.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/IFieldRule.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/IFieldRule.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,20 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Reflection;
+
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ /// <summary>
+ /// Description of IFieldRule.
+ /// </summary>
+ public interface IFieldRule : IReflectionRule
+ {
+ Resolution Check(Module module, FieldInfo field);
+ }
+}
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/IMemberRule.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/IMemberRule.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/IMemberRule.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,20 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Reflection;
+
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ /// <summary>
+ /// Description of IMemberRule.
+ /// </summary>
+ public interface IMemberRule : IReflectionRule
+ {
+ Resolution Check(Module module, MemberInfo member);
+ }
+}
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/IMethodBaseRule.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/IMethodBaseRule.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/IMethodBaseRule.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,20 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Reflection;
+
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ /// <summary>
+ /// Description of IMethodBaseRule.
+ /// </summary>
+ public interface IMethodBaseRule : IReflectionRule
+ {
+ Resolution Check(Module module, MethodBase methodBase);
+ }
+}
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/IMethodRule.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/IMethodRule.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/IMethodRule.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,20 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Reflection;
+
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ /// <summary>
+ /// Description of IMethodRule.
+ /// </summary>
+ public interface IMethodRule : IReflectionRule
+ {
+ Resolution Check(Module module, MethodInfo method);
+ }
+}
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/IModuleRule.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/IModuleRule.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/IModuleRule.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,20 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Reflection;
+
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ /// <summary>
+ /// Description of IModuleRule.
+ /// </summary>
+ public interface IModuleRule : IReflectionRule
+ {
+ Resolution Check(Module module);
+ }
+}
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/INamespaceRule.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/INamespaceRule.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/INamespaceRule.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,21 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Collections;
+using System.Reflection;
+
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ /// <summary>
+ /// Description of INamespaceRule.
+ /// </summary>
+ public interface INamespaceRule : IReflectionRule
+ {
+ Resolution Check(string namespaceName, ICollection types);
+ }
+}
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/IParameterRule.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/IParameterRule.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/IParameterRule.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,20 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Reflection;
+
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ /// <summary>
+ /// Description of IParameterRule.
+ /// </summary>
+ public interface IParameterRule : IReflectionRule
+ {
+ Resolution Check(Module module, ParameterInfo param);
+ }
+}
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/IPropertyRule.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/IPropertyRule.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/IPropertyRule.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,20 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Reflection;
+
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ /// <summary>
+ /// Description of IPropertyRule.
+ /// </summary>
+ public interface IPropertyRule : IReflectionRule
+ {
+ Resolution Check(PropertyInfo property);
+ }
+}
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/IReflectionRule.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/IReflectionRule.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/IReflectionRule.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,31 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Reflection;
+
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ /// <summary>
+ /// Description of IAssemblyRule.
+ /// </summary>
+ public interface IReflectionRule : IRule
+ {
+ ProtectionLevels MemberProtectionLevel {
+ get;
+ }
+
+ ProtectionLevels NestedTypeProtectionLevel {
+ get;
+ }
+
+ ProtectionLevels TypeProtectionLevel {
+ get;
+ }
+
+ }
+}
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/IRule.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/IRule.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/IRule.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,37 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Reflection;
+
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ /// <summary>
+ /// Description of IRule.
+ /// </summary>
+ public interface IRule
+ {
+ void EndAnalysis();
+ void StartAnalysis();
+
+ PriorityLevel PriorityLevel {
+ get;
+ }
+
+ int Certainty {
+ get;
+ }
+
+ string Description {
+ get;
+ }
+
+ string Details {
+ get;
+ }
+ }
+}
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/ITypeRule.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/ITypeRule.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/ITypeRule.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,20 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Reflection;
+
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ /// <summary>
+ /// Description of ITypeRule.
+ /// </summary>
+ public interface ITypeRule : IReflectionRule
+ {
+ Resolution Check(Type type);
+ }
+}
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/AttributeSuffixIsAttributeRule.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/AttributeSuffixIsAttributeRule.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/AttributeSuffixIsAttributeRule.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,71 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Reflection;
+
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ /// <summary>
+ /// Description of AttributeSuffixIsAttribute.
+ /// </summary>
+ public class AttributeSuffixIsAttributeRule : AbstractReflectionRule, ITypeRule
+ {
+ public override string Description {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.AttributeSuffixIsAttribute.Description}";
+ }
+ }
+
+ public override string Details {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.AttributeSuffixIsAttribute.Details}";
+ }
+ }
+
+ public Resolution Check(Type type)
+ {
+ if (type.IsSubclassOf(typeof(System.Attribute)) && !type.Name.EndsWith("Attribute")) {
+ return new Resolution(this, "${res:MonoDevelop.AssemblyAnalyser.Rules.AttributeSuffixIsAttribute.Resolution}", type.FullName, new string[,] { { "TypeName", type.FullName }});
+ }
+ return null;
+ }
+ }
+}
+
+#region Unit Test
+#if TEST
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ using NUnit.Framework;
+
+ [TestFixture]
+ public class AttributeSuffixIsAttributeRuleTest
+ {
+ class MyAttribute : System.Attribute
+ {
+ }
+ [Test]
+ public void TestCorrectAttribute()
+ {
+ AttributeSuffixIsAttributeRule rule = new AttributeSuffixIsAttributeRule();
+ Assertion.AssertNull(rule.Check(typeof(MyAttribute)));
+ }
+
+ class MyAttr : System.Attribute
+ {
+ }
+ [Test]
+ public void TestIncorrectAttribute()
+ {
+ AttributeSuffixIsAttributeRule rule = new AttributeSuffixIsAttributeRule();
+ Assertion.AssertNotNull(rule.Check(typeof(MyAttr)));
+ }
+ }
+}
+#endif
+#endregion
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/CheckCollectionSuffix.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/CheckCollectionSuffix.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/CheckCollectionSuffix.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,138 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Collections;
+using System.Reflection;
+
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ /// <summary>
+ /// Description of CheckCollectionSuffix.
+ /// </summary>
+ public class CheckCollectionSuffix : AbstractReflectionRule, ITypeRule
+ {
+ public override string Description {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.CheckCollectionSuffix.Description}";
+ }
+ }
+
+ public override string Details {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.CheckCollectionSuffix.Details}";
+ }
+ }
+
+ public CheckCollectionSuffix()
+ {
+ base.certainty = 90;
+ }
+
+ public Resolution Check(Type type)
+ {
+ if ((typeof(ICollection).IsAssignableFrom(type) || typeof(IEnumerable).IsAssignableFrom(type)) && !typeof(System.Collections.IDictionary).IsAssignableFrom(type)) {
+ if (typeof(Queue).IsAssignableFrom(type)) {
+ if (!type.Name.EndsWith("Queue")) {
+ return new Resolution(this, "${res:MonoDevelop.AssemblyAnalyser.Rules.CheckCollectionSuffix.Resolution1}", type.FullName, new string[,] { { "TypeName", type.FullName }} );
+ }
+ } else if (typeof(Stack).IsAssignableFrom(type)) {
+ if (!type.Name.EndsWith("Stack")) {
+ return new Resolution(this, "${res:MonoDevelop.AssemblyAnalyser.Rules.CheckCollectionSuffix.Resolution2}", type.FullName, new string[,] { { "TypeName", type.FullName }});
+ }
+ } else {
+ if (!type.Name.EndsWith("Collection")) {
+ return new Resolution(this, "${res:MonoDevelop.AssemblyAnalyser.Rules.CheckCollectionSuffix.Resolution3}", type.FullName, new string[,] { { "TypeName", type.FullName }});
+ }
+ }
+ }
+ return null;
+ }
+ }
+}
+#region Unit Test
+#if TEST
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ using NUnit.Framework;
+
+ [TestFixture]
+ public class CheckCollectionSuffixTest
+ {
+ #region Collection suffix tests
+ class MyCollection : System.Collections.ArrayList
+ {
+ }
+ class MyDictionary : System.Collections.Hashtable
+ {
+ }
+ [Test]
+ public void TestCorrectCollection()
+ {
+ CheckCollectionSuffix checkCollectionSuffix = new CheckCollectionSuffix();
+ Assertion.AssertNull(checkCollectionSuffix.Check(typeof(MyCollection)));
+ Assertion.AssertNull(checkCollectionSuffix.Check(typeof(MyDictionary)));
+ Assertion.AssertNull(checkCollectionSuffix.Check(typeof(CheckCollectionSuffixTest)));
+ }
+
+ class MyColl : System.Collections.ArrayList
+ {
+ }
+ [Test]
+ public void TestIncorrectCollection()
+ {
+ CheckCollectionSuffix checkCollectionSuffix = new CheckCollectionSuffix();
+ Assertion.AssertNotNull(checkCollectionSuffix.Check(typeof(MyColl)));
+ }
+ #endregion
+
+ #region Queue suffix tests
+ class MyQueue : System.Collections.Queue
+ {
+ }
+ [Test]
+ public void TestCorrectQueue()
+ {
+ CheckCollectionSuffix checkCollectionSuffix = new CheckCollectionSuffix();
+ Assertion.AssertNull(checkCollectionSuffix.Check(typeof(MyQueue)));
+ }
+
+ class MyQWEQWEQ : System.Collections.Queue
+ {
+ }
+ [Test]
+ public void TestIncorrectQueue()
+ {
+ CheckCollectionSuffix checkCollectionSuffix = new CheckCollectionSuffix();
+ Assertion.AssertNotNull(checkCollectionSuffix.Check(typeof(MyQWEQWEQ)));
+ }
+ #endregion
+
+ #region Stack suffix tests
+ class MyStack : System.Collections.Stack
+ {
+ }
+ [Test]
+ public void TestCorrectStack()
+ {
+ CheckCollectionSuffix checkCollectionSuffix = new CheckCollectionSuffix();
+ Assertion.AssertNull(checkCollectionSuffix.Check(typeof(MyStack)));
+ }
+ class MySfwefew : System.Collections.Stack
+ {
+ }
+ [Test]
+ public void TestIncorrectStack()
+ {
+ CheckCollectionSuffix checkCollectionSuffix = new CheckCollectionSuffix();
+ Assertion.AssertNotNull(checkCollectionSuffix.Check(typeof(MySfwefew)));
+ }
+ #endregion
+ }
+}
+#endif
+#endregion
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/DelegatesHaveNoDelegateSuffix.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/DelegatesHaveNoDelegateSuffix.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/DelegatesHaveNoDelegateSuffix.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,71 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Reflection;
+
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ /// <summary>
+ /// Description of DelegatesHaveNoDelegateSuffix.
+ /// </summary>
+ public class DelegatesHaveNoDelegateSuffix : AbstractReflectionRule, ITypeRule
+ {
+ public override string Description {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.DelegatesHaveNoDelegateSuffix.Description}";
+ }
+ }
+
+ public override string Details {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.DelegatesHaveNoDelegateSuffix.Details}";
+ }
+ }
+
+ public DelegatesHaveNoDelegateSuffix()
+ {
+ base.certainty = 99;
+ }
+
+ public Resolution Check(Type type)
+ {
+ if (type.IsSubclassOf(typeof(System.Delegate)) && type.Name.EndsWith("Delegate")) {
+ return new Resolution(this, "${res:MonoDevelop.AssemblyAnalyser.Rules.DelegatesHaveNoDelegateSuffix.Resolution}", type.FullName, new string[,] { { "TypeName", type.FullName }});
+ }
+ return null;
+ }
+ }
+}
+#region Unit Test
+#if TEST
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ using NUnit.Framework;
+
+ [TestFixture]
+ public class DelegatesHaveNoDelegateSuffixTest
+ {
+ delegate void MyDelegateWithoutDelegateSuffix();
+ [Test]
+ public void TestCorrectDelegate()
+ {
+ DelegatesHaveNoDelegateSuffix delegatesHaveNoDelegateSuffix = new DelegatesHaveNoDelegateSuffix();
+ Assertion.AssertNull(delegatesHaveNoDelegateSuffix.Check(typeof(MyDelegateWithoutDelegateSuffix)));
+ }
+
+ delegate void MyDelegateWithDelegateSuffixDelegate();
+ [Test]
+ public void TestIncorrectDelegate()
+ {
+ DelegatesHaveNoDelegateSuffix delegatesHaveNoDelegateSuffix = new DelegatesHaveNoDelegateSuffix();
+ Assertion.AssertNotNull(delegatesHaveNoDelegateSuffix.Check(typeof(MyDelegateWithDelegateSuffixDelegate)));
+ }
+ }
+}
+#endif
+#endregion
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/DictionaryTypeSuffixIsDictionary.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/DictionaryTypeSuffixIsDictionary.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/DictionaryTypeSuffixIsDictionary.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,72 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Reflection;
+
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ /// <summary>
+ /// Description of DelegatesHaveNoDelegateSuffix.
+ /// </summary>
+ public class DictionaryTypeSuffixIsDictionary : AbstractReflectionRule, ITypeRule
+ {
+ public override string Description {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.DictionaryTypeSuffixIsDictionary.Description}";
+ }
+ }
+
+ public override string Details {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.DictionaryTypeSuffixIsDictionary.Details}";
+ }
+ }
+
+ public Resolution Check(Type type)
+ {
+ if (typeof(System.Collections.IDictionary).IsAssignableFrom(type) && !type.Name.EndsWith("Dictionary")) {
+ return new Resolution(this, "${res:MonoDevelop.AssemblyAnalyser.Rules.DictionaryTypeSuffixIsDictionary.Resolution}", type.FullName, new string[,] { { "TypeName", type.FullName }});
+ }
+ return null;
+ }
+ }
+}
+#region Unit Test
+
+#if TEST
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ using NUnit.Framework;
+
+ [TestFixture]
+ public class DictionaryTypeSuffixIsDictionaryTest
+ {
+ class CorrectDictionary : System.Collections.Hashtable
+ {
+ }
+ [Test]
+ public void TestCorrectDictionary()
+ {
+ DictionaryTypeSuffixIsDictionary dictionaryTypeSuffixIsDictionary = new DictionaryTypeSuffixIsDictionary();
+ Assertion.AssertNull(dictionaryTypeSuffixIsDictionary.Check(typeof(CorrectDictionary)));
+ }
+
+ class IncorrectDictionaryWrongSuffix : System.Collections.Hashtable
+ {
+ }
+ [Test]
+ public void TestIncorrectDictionary()
+ {
+ DictionaryTypeSuffixIsDictionary dictionaryTypeSuffixIsDictionary = new DictionaryTypeSuffixIsDictionary();
+ Assertion.AssertNotNull(dictionaryTypeSuffixIsDictionary.Check(typeof(IncorrectDictionaryWrongSuffix)));
+ }
+
+ }
+}
+#endif
+#endregion
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/EnumsHaveNoEnumSuffix.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/EnumsHaveNoEnumSuffix.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/EnumsHaveNoEnumSuffix.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,78 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Reflection;
+
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ /// <summary>
+ /// Description of DelegatesHaveNoDelegateSuffix.
+ /// </summary>
+ public class EnumsHaveNoEnumSuffix : AbstractReflectionRule, ITypeRule
+ {
+ public override string Description {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.EnumsHaveNoEnumSuffix.Description}";
+ }
+ }
+
+ public override string Details {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.EnumsHaveNoEnumSuffix.Details}";
+ }
+ }
+
+ public EnumsHaveNoEnumSuffix()
+ {
+ base.certainty = 99;
+ }
+
+ public Resolution Check(Type type)
+ {
+ if (type.IsSubclassOf(typeof(System.Enum)) && type.Name.EndsWith("Enum")) {
+ return new Resolution(this, "${res:MonoDevelop.AssemblyAnalyser.Rules.EnumsHaveNoEnumSuffix.Resolution}", type.FullName, new string[,] { { "TypeName", type.FullName }});
+ }
+ return null;
+ }
+ }
+}
+#region Unit Test
+#if TEST
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ using NUnit.Framework;
+
+ [TestFixture]
+ public class EnumsHaveNoEnumSuffixTest
+ {
+ enum CorrectEnumWithAnotherSuffix
+ {
+ A, B, C
+ }
+ [Test]
+ public void TestCorrectEnum()
+ {
+ EnumsHaveNoEnumSuffix enumsHaveNoEnumSuffix = new EnumsHaveNoEnumSuffix();
+ Assertion.AssertNull(enumsHaveNoEnumSuffix.Check(typeof(CorrectEnumWithAnotherSuffix)));
+ }
+
+ enum IncorrectEnum
+ {
+ A, B, C
+ }
+ [Test]
+ public void TestIncorrectDictionary()
+ {
+ EnumsHaveNoEnumSuffix enumsHaveNoEnumSuffix = new EnumsHaveNoEnumSuffix();
+ Assertion.AssertNotNull(enumsHaveNoEnumSuffix.Check(typeof(IncorrectEnum)));
+ }
+
+ }
+}
+#endif
+#endregion
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/EventArgsSuffixIsEventArgsRule.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/EventArgsSuffixIsEventArgsRule.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/EventArgsSuffixIsEventArgsRule.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,72 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Reflection;
+
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ /// <summary>
+ /// Description of AttributeSuffixIsAttribute.
+ /// </summary>
+ public class EventArgsSuffixIsEventArgsRule : AbstractReflectionRule, ITypeRule
+ {
+ public override string Description {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.EventArgsSuffixIsEventArgs.Description}";
+ }
+ }
+
+ public override string Details {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.EventArgsSuffixIsEventArgs.Details}";
+ }
+ }
+
+ public Resolution Check(Type type)
+ {
+ if (typeof(System.EventArgs).IsAssignableFrom(type) && !type.Name.EndsWith("EventArgs")) {
+ return new Resolution(this, "${res:MonoDevelop.AssemblyAnalyser.Rules.EventArgsSuffixIsEventArgs.Resolution}", type.FullName, new string[,] { { "TypeName", type.FullName }});
+ }
+ return null;
+ }
+ }
+}
+
+#region Unit Test
+#if TEST
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ using NUnit.Framework;
+
+ [TestFixture]
+ public class EventArgsSuffixIsEventArgsRuleTest
+ {
+ class CorrectEventArgs : System.EventArgs
+ {
+ }
+ [Test]
+ public void TestCorrectEventArgs()
+ {
+ EventArgsSuffixIsEventArgsRule rule = new EventArgsSuffixIsEventArgsRule();
+ Assertion.AssertNull(rule.Check(typeof(CorrectEventArgs)));
+ }
+
+ class IncorrectEventArgsWithWrongSuffix : System.EventArgs
+ {
+ }
+ [Test]
+ public void TestIncorrectEventArgs()
+ {
+ EventArgsSuffixIsEventArgsRule rule = new EventArgsSuffixIsEventArgsRule();
+ Assertion.AssertNotNull(rule.Check(typeof(IncorrectEventArgsWithWrongSuffix)));
+ }
+
+ }
+}
+#endif
+#endregion
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/EventFirstParameterNameIsSender.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/EventFirstParameterNameIsSender.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/EventFirstParameterNameIsSender.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,90 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Reflection;
+
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ /// <summary>
+ /// Description of EventFirstParameterNameIsSender.
+ /// </summary>
+ public class EventFirstParameterNameIsSender : AbstractReflectionRule, IEventRule
+ {
+ public override string Description {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.EventFirstParameterNameIsSender.Description}";
+ }
+ }
+
+ public override string Details {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.EventFirstParameterNameIsSender.Details}";
+ }
+ }
+
+ public EventFirstParameterNameIsSender()
+ {
+ base.certainty = 99;
+ }
+
+ public Resolution Check(EventInfo evnt)
+ {
+ MethodInfo invokeMethod = evnt.EventHandlerType.GetMethod("Invoke");
+ ParameterInfo[] parameters = invokeMethod.GetParameters();
+
+ if (parameters.Length > 0 && parameters[0].Name != "sender") {
+ return new Resolution(this, "${res:MonoDevelop.AssemblyAnalyser.Rules.EventFirstParameterNameIsSender.Resolution}", evnt.EventHandlerType.FullName, new string[,] { { "EventType", evnt.EventHandlerType.FullName }, { "OldParameterName", parameters[0].Name }});
+ }
+ return null;
+ }
+ }
+}
+
+#region Unit Test
+#if TEST
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ using NUnit.Framework;
+
+ [TestFixture]
+ public class EventFirstParameterNameIsSenderTest
+ {
+ public delegate void CorrectEventHandler(object sender, EventArgs e);
+ public event CorrectEventHandler CorrectEvent;
+ protected virtual void OnCorrectEvent(EventArgs e)
+ {
+ if (CorrectEvent != null) {
+ CorrectEvent(this, e);
+ }
+ }
+ [Test]
+ public void TestCorrectEventHandler()
+ {
+ EventFirstParameterNameIsSender eventFirstParameterNameIsSender = new EventFirstParameterNameIsSender();
+ Assertion.AssertNull(eventFirstParameterNameIsSender.Check(this.GetType().GetEvent("CorrectEvent")));
+ }
+
+ public delegate void IncorrectEventHandler(object s, EventArgs e);
+ public event IncorrectEventHandler IncorrectEvent;
+ protected virtual void OnIncorrectEvent(EventArgs e)
+ {
+ if (IncorrectEvent != null) {
+ IncorrectEvent(this, e);
+ }
+ }
+
+ [Test]
+ public void TestIncorrectEventHandler()
+ {
+ EventFirstParameterNameIsSender eventFirstParameterNameIsSender = new EventFirstParameterNameIsSender();
+ Assertion.AssertNotNull(eventFirstParameterNameIsSender.Check(this.GetType().GetEvent("IncorrectEvent")));
+ }
+ }
+}
+#endif
+#endregion
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/EventHandlerSuffixIsEventHandler.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/EventHandlerSuffixIsEventHandler.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/EventHandlerSuffixIsEventHandler.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,93 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Reflection;
+
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ /// <summary>
+ /// Description of EventHandlerSuffixIsEventHandler.
+ /// </summary>
+ public class EventHandlerSuffixIsEventHandler : AbstractReflectionRule, IEventRule
+ {
+ public override string Description {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.EventHandlerSuffixIsEventHandler.Description}";
+ }
+ }
+
+ public override string Details {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.EventHandlerSuffixIsEventHandler.Details}";
+ }
+ }
+
+ public Resolution Check(EventInfo evnt)
+ {
+ if (!evnt.EventHandlerType.Name.EndsWith("EventHandler")) {
+ return new Resolution(this, "${res:MonoDevelop.AssemblyAnalyser.Rules.EventHandlerSuffixIsEventHandler.Resolution}", evnt.EventHandlerType.FullName, new string[,] { { "EventType", evnt.EventHandlerType.FullName }});
+ }
+ return null;
+ }
+ }
+}
+#region Unit Test
+#if TEST
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ using NUnit.Framework;
+
+ [TestFixture]
+ public class EventsDoNotHaveBeforeOrAfterPrefixTest
+ {
+ public event EventHandler CorrectEvent;
+ protected virtual void OnCorrectEvent(EventArgs e)
+ {
+ if (CorrectEvent != null) {
+ CorrectEvent(this, e);
+ }
+ }
+ [Test]
+ public void TestCorrectEventHandler()
+ {
+ EventsDoNotHaveBeforeOrAfterPrefix eventsDoNotHaveBeforeOrAfterPrefix = new EventsDoNotHaveBeforeOrAfterPrefix();
+ Assertion.AssertNull(eventsDoNotHaveBeforeOrAfterPrefix.Check(this.GetType().GetEvent("CorrectEvent")));
+ }
+
+ public event EventHandler BeforeIncorrectEvent;
+ protected virtual void OnBeforeIncorrectEvent(EventArgs e)
+ {
+ if (BeforeIncorrectEvent != null) {
+ BeforeIncorrectEvent(this, e);
+ }
+ }
+ [Test]
+ public void TestIncorrectEventHandler1()
+ {
+ EventsDoNotHaveBeforeOrAfterPrefix eventsDoNotHaveBeforeOrAfterPrefix = new EventsDoNotHaveBeforeOrAfterPrefix();
+ Assertion.AssertNotNull(eventsDoNotHaveBeforeOrAfterPrefix.Check(this.GetType().GetEvent("BeforeIncorrectEvent")));
+ }
+
+ public event EventHandler AfterIncorrectEvent;
+ protected virtual void OnAfterIncorrectEvent(EventArgs e)
+ {
+ if (AfterIncorrectEvent != null) {
+ AfterIncorrectEvent(this, e);
+ }
+ }
+ [Test]
+ public void TestIncorrectEventHandler2()
+ {
+ EventsDoNotHaveBeforeOrAfterPrefix eventsDoNotHaveBeforeOrAfterPrefix = new EventsDoNotHaveBeforeOrAfterPrefix();
+ Assertion.AssertNotNull(eventsDoNotHaveBeforeOrAfterPrefix.Check(this.GetType().GetEvent("AfterIncorrectEvent")));
+ }
+
+ }
+}
+#endif
+#endregion
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/EventSecondParameterNameIsE.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/EventSecondParameterNameIsE.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/EventSecondParameterNameIsE.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,89 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Reflection;
+
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ /// <summary>
+ /// Description of EventFirstParameterNameIsSender.
+ /// </summary>
+ public class EventSecondParameterNameIsE : AbstractReflectionRule, IEventRule
+ {
+ public override string Description {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.EventSecondParameterNameIsE.Description}";
+ }
+ }
+
+ public override string Details {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.EventSecondParameterNameIsE.Details}";
+ }
+ }
+
+ public EventSecondParameterNameIsE()
+ {
+ base.certainty = 99;
+ }
+
+ public Resolution Check(EventInfo evnt)
+ {
+ MethodInfo invokeMethod = evnt.EventHandlerType.GetMethod("Invoke");
+ ParameterInfo[] parameters = invokeMethod.GetParameters();
+
+ if (parameters.Length > 1 && parameters[1].Name != "e") {
+ return new Resolution(this, "${res:MonoDevelop.AssemblyAnalyser.Rules.EventSecondParameterNameIsE.Resolution}", evnt.EventHandlerType.FullName, new string[,] { { "EventType", evnt.EventHandlerType.FullName }, { "OldParameterName", parameters[1].Name }});
+ }
+ return null;
+ }
+ }
+}
+#region Unit Test
+#if TEST
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ using NUnit.Framework;
+
+ [TestFixture]
+ public class EventSecondParameterNameIsETest
+ {
+ public delegate void CorrectEventHandler(object sender, EventArgs e);
+ public event CorrectEventHandler CorrectEvent;
+ protected virtual void OnCorrectEvent(EventArgs e)
+ {
+ if (CorrectEvent != null) {
+ CorrectEvent(this, e);
+ }
+ }
+ [Test]
+ public void TestCorrectEventHandler()
+ {
+ EventSecondParameterNameIsE eventSecondParameterNameIsE = new EventSecondParameterNameIsE();
+ Assertion.AssertNull(eventSecondParameterNameIsE.Check(this.GetType().GetEvent("CorrectEvent")));
+ }
+
+ public delegate void IncorrectEventHandler(object sender, EventArgs notE);
+ public event IncorrectEventHandler IncorrectEvent;
+ protected virtual void OnIncorrectEvent(EventArgs e)
+ {
+ if (IncorrectEvent != null) {
+ IncorrectEvent(this, e);
+ }
+ }
+
+ [Test]
+ public void TestIncorrectEventHandler()
+ {
+ EventSecondParameterNameIsE eventSecondParameterNameIsE = new EventSecondParameterNameIsE();
+ Assertion.AssertNotNull(eventSecondParameterNameIsE.Check(this.GetType().GetEvent("IncorrectEvent")));
+ }
+ }
+}
+#endif
+#endregion
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/EventsDoNotHaveBeforeOrAfterPrefix.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/EventsDoNotHaveBeforeOrAfterPrefix.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/EventsDoNotHaveBeforeOrAfterPrefix.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,89 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Reflection;
+
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ /// <summary>
+ /// Description of EventsDoNotHaveBeforeOrAfterPrefix.
+ /// </summary>
+ public class EventsDoNotHaveBeforeOrAfterPrefix : AbstractReflectionRule, IEventRule
+ {
+ public override string Description {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.EventsDoNotHaveBeforeOrAfterPrefix.Description}";
+ }
+ }
+
+ public override string Details {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.EventsDoNotHaveBeforeOrAfterPrefix.Details}";
+ }
+ }
+
+ public EventsDoNotHaveBeforeOrAfterPrefix()
+ {
+ base.certainty = 90;
+ }
+
+ public Resolution Check(EventInfo evnt)
+ {
+ if (evnt.Name.StartsWith("Before")) {
+ return new Resolution(this, "${res:MonoDevelop.AssemblyAnalyser.Rules.EventsDoNotHaveBeforeOrAfterPrefix.Resolution1}", NamingUtilities.Combine(evnt.ReflectedType.FullName, evnt.Name), new string[,] { { "EventName", evnt.Name }, { "ReflectedType", evnt.ReflectedType.FullName }});
+ } else if (evnt.Name.StartsWith("After")) {
+ return new Resolution(this, "${res:MonoDevelop.AssemblyAnalyser.Rules.EventsDoNotHaveBeforeOrAfterPrefix.Resolution2}", NamingUtilities.Combine(evnt.ReflectedType.FullName, evnt.Name), new string[,] { { "EventName", evnt.Name }, { "ReflectedType", evnt.ReflectedType.FullName }});
+ }
+ return null;
+ }
+ }
+}
+#region Unit Test
+#if TEST
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ using NUnit.Framework;
+
+ [TestFixture]
+ public class EventHandlerSuffixIsEventHandlerTest
+ {
+ public delegate void CorrectEventHandler(object sender, EventArgs e);
+ public event CorrectEventHandler CorrectEvent;
+ protected virtual void OnCorrectEvent(EventArgs e)
+ {
+ if (CorrectEvent != null) {
+ CorrectEvent(this, e);
+ }
+ }
+ [Test]
+ public void TestCorrectEventHandler()
+ {
+ EventHandlerSuffixIsEventHandler eventHandlerSuffixIsEventHandler = new EventHandlerSuffixIsEventHandler();
+ Assertion.AssertNull(eventHandlerSuffixIsEventHandler.Check(this.GetType().GetEvent("CorrectEvent")));
+ }
+
+ public delegate void IncorrectEventHandlerWithWrongSuffix(object sender, EventArgs e);
+ public event IncorrectEventHandlerWithWrongSuffix IncorrectEvent;
+ protected virtual void OnIncorrectEvent(EventArgs e)
+ {
+ if (IncorrectEvent != null) {
+ IncorrectEvent(this, e);
+ }
+ }
+
+ [Test]
+ public void TestIncorrectEventHandler()
+ {
+ EventHandlerSuffixIsEventHandler eventHandlerSuffixIsEventHandler = new EventHandlerSuffixIsEventHandler();
+ EventInfo evnt = this.GetType().GetEvent("IncorrectEvent");
+ Assertion.AssertNotNull("Type name is >" + evnt.EventHandlerType.FullName + "<", eventHandlerSuffixIsEventHandler.Check(evnt));
+ }
+ }
+}
+#endif
+#endregion
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/ExceptionSuffixIsExceptionRule.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/ExceptionSuffixIsExceptionRule.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/ExceptionSuffixIsExceptionRule.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,75 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Reflection;
+
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ /// <summary>
+ /// Description of ExceptionSuffixIsException.
+ /// </summary>
+ public class ExceptionSuffixIsExceptionRule : AbstractReflectionRule, ITypeRule
+ {
+ public override string Description {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.ExceptionSuffixIsException.Description}";
+ }
+ }
+
+ public override string Details {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.ExceptionSuffixIsException.Details}";
+ }
+ }
+
+ public ExceptionSuffixIsExceptionRule()
+ {
+ base.certainty = 99;
+ }
+
+ public Resolution Check(Type type)
+ {
+ if (typeof(System.Exception).IsAssignableFrom(type) && !type.Name.EndsWith("Exception")) {
+ return new Resolution(this, "${res:MonoDevelop.AssemblyAnalyser.Rules.ExceptionSuffixIsException.Resolution}", type.FullName, new string[,] { { "TypeName", type.FullName }});
+ }
+ return null;
+ }
+ }
+}
+#region Unit Test
+#if TEST
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ using NUnit.Framework;
+
+ [TestFixture]
+ public class ExceptionSuffixIsExceptionRuleTest
+ {
+ class MyException : System.Exception
+ {
+ }
+ [Test]
+ public void TestCorrectException()
+ {
+ ExceptionSuffixIsExceptionRule rule = new ExceptionSuffixIsExceptionRule();
+ Assertion.AssertNull(rule.Check(typeof(MyException)));
+ }
+
+ class MyExcpt : System.Exception
+ {
+ }
+ [Test]
+ public void TestIncorrectException()
+ {
+ ExceptionSuffixIsExceptionRule rule = new ExceptionSuffixIsExceptionRule();
+ Assertion.AssertNotNull(rule.Check(typeof(MyExcpt)));
+ }
+ }
+}
+#endif
+#endregion
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/FlagEnumerationsArePlural.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/FlagEnumerationsArePlural.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/FlagEnumerationsArePlural.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,83 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Reflection;
+
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ /// <summary>
+ /// Description of AttributeSuffixIsAttribute.
+ /// </summary>
+ public class FlagEnumerationsArePlural : AbstractReflectionRule, ITypeRule
+ {
+ public override string Description {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.FlagEnumerationsArePlural.Description}";
+ }
+ }
+
+ public override string Details {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.FlagEnumerationsArePlural.Details}";
+ }
+ }
+
+ public FlagEnumerationsArePlural()
+ {
+ base.certainty = 75;
+ }
+
+ public Resolution Check(Type type)
+ {
+ if (type.IsSubclassOf(typeof(System.Enum)) && type.IsDefined(typeof(System.FlagsAttribute), true)) {
+ if (!type.Name.EndsWith("s") && !type.Name.EndsWith("ae") && !type.Name.EndsWith("i")) {
+ return new Resolution(this, "${res:MonoDevelop.AssemblyAnalyser.Rules.FlagEnumerationsArePlural.Resolution}", type.FullName, new string[,] { { "TypeName", type.FullName }});
+ }
+ }
+ return null;
+ }
+ }
+}
+#region Unit Test
+#if TEST
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ using NUnit.Framework;
+
+ [TestFixture]
+ public class FlagEnumerationsArePluralTest
+ {
+ [Flags()]
+ enum CorrectFlags { a, b, c}
+ [Flags()]
+ enum CorrectNovae { Type1, Type2}
+ [Flags()]
+ enum CorrectSpaghetti { Bolognese, Napoli}
+
+ [Test]
+ public void TestCorrectPluralEnums()
+ {
+ FlagEnumerationsArePlural elagEnumerationsArePlural = new FlagEnumerationsArePlural();
+ Assertion.AssertNull(elagEnumerationsArePlural.Check(typeof(CorrectFlags)));
+ Assertion.AssertNull(elagEnumerationsArePlural.Check(typeof(CorrectNovae)));
+ Assertion.AssertNull(elagEnumerationsArePlural.Check(typeof(CorrectSpaghetti)));
+ }
+
+ [Flags()]
+ enum SomeFlag { Bolognese, Napoli}
+
+ [Test]
+ public void TestIncorrectPluralEnums()
+ {
+ FlagEnumerationsArePlural elagEnumerationsArePlural = new FlagEnumerationsArePlural();
+ Assertion.AssertNotNull(elagEnumerationsArePlural.Check(typeof(SomeFlag)));
+ }
+ }
+}
+#endif
+#endregion
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/InterfacesPrefixIsI.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/InterfacesPrefixIsI.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/InterfacesPrefixIsI.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,78 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Reflection;
+
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ /// <summary>
+ /// Description of AttributeSuffixIsAttribute.
+ /// </summary>
+ public class InterfacesPrefixIsI : AbstractReflectionRule, ITypeRule
+ {
+ public override string Description {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.InterfacesPrefixIsI.Description}";
+ }
+ }
+
+ public override string Details {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.InterfacesPrefixIsI.Details}";
+ }
+ }
+
+ public InterfacesPrefixIsI()
+ {
+ base.certainty = 99;
+ }
+
+ public Resolution Check(Type type)
+ {
+ if (type.IsInterface && !type.Name.StartsWith("I")) {
+ return new Resolution(this, "${res:MonoDevelop.AssemblyAnalyser.Rules.InterfacesPrefixIsI.Resolution}", type.FullName, new string[,] { { "TypeName", type.FullName }});
+ }
+ return null;
+ }
+ }
+}
+
+#region Unit Test
+#if TEST
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ using NUnit.Framework;
+
+ [TestFixture]
+ public class InterfacesPrefixIsITest
+ {
+ interface ICorrectInterface
+ {
+ }
+ [Test]
+ public void TestCorrectAttribute()
+ {
+ InterfacesPrefixIsI interfacesPrefixIsI = new InterfacesPrefixIsI();
+ Assertion.AssertNull(interfacesPrefixIsI.Check(typeof(System.ICloneable)));
+ Assertion.AssertNull(interfacesPrefixIsI.Check(typeof(System.IComparable)));
+ Assertion.AssertNull(interfacesPrefixIsI.Check(typeof(ICorrectInterface)));
+ }
+
+ interface WrongInterface
+ {
+ }
+ [Test]
+ public void TestIncorrectAttribute()
+ {
+ InterfacesPrefixIsI interfacesPrefixIsI = new InterfacesPrefixIsI();
+ Assertion.AssertNotNull(interfacesPrefixIsI.Check(typeof(WrongInterface)));
+ }
+ }
+}
+#endif
+#endregion
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/MembersArePascalCased.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/MembersArePascalCased.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/MembersArePascalCased.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,59 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Reflection;
+
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ /// <summary>
+ /// Description of AttributeSuffixIsAttribute.
+ /// </summary>
+ public class MembersArePascalCased : AbstractReflectionRule, IMemberRule
+ {
+ public override string Description {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.MembersArePascalCased.Description}";
+ }
+ }
+
+ public override string Details {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.MembersArePascalCased.Details}";
+ }
+ }
+
+ public MembersArePascalCased()
+ {
+ base.certainty = 99;
+ }
+
+ public Resolution Check(Module module, MemberInfo member)
+ {
+ if (member is FieldInfo || member is ConstructorInfo) {
+ return null;
+ }
+ if (member is MethodInfo) {
+ MethodInfo mi = (MethodInfo)member;
+ if (mi.IsSpecialName) {
+ return null;
+ }
+ }
+
+ if (!NamingUtilities.IsPascalCase(member.Name)) {
+ return new Resolution(this,
+ "${res:MonoDevelop.AssemblyAnalyser.Rules.MembersArePascalCased.Resolution}",
+ NamingUtilities.Combine(member.DeclaringType.FullName, member.Name),
+ new string[,] {
+ {"MemberName", member.Name},
+ {"DeclaringType", member.DeclaringType.FullName},
+ {"AlternateName", NamingUtilities.PascalCase(member.Name)}});
+ }
+ return null;
+ }
+ }
+}
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/MembersDoNotContainUnderscores.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/MembersDoNotContainUnderscores.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/MembersDoNotContainUnderscores.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,54 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Reflection;
+
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ /// <summary>
+ /// Description of AttributeSuffixIsAttribute.
+ /// </summary>
+ public class MembersDoNotContainUnderscores : AbstractReflectionRule, IMemberRule
+ {
+ public override string Description {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.MembersDoNotContainUnderscores.Description}";
+ }
+ }
+
+ public override string Details {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.MembersDoNotContainUnderscores.Details}";
+ }
+ }
+
+ public MembersDoNotContainUnderscores()
+ {
+ base.certainty = 99;
+ }
+
+ public Resolution Check(Module module, MemberInfo member)
+ {
+ if (member is FieldInfo || member is ConstructorInfo) {
+ return null;
+ }
+ if (member is MethodInfo) {
+ MethodInfo mi = (MethodInfo)member;
+ if (mi.IsSpecialName) {
+ return null;
+ }
+ }
+
+ if (NamingUtilities.ContainsUnderscore(member.Name)) {
+ return new Resolution(this, "${res:MonoDevelop.AssemblyAnalyser.Rules.MembersDoNotContainUnderscores.Resolution}", NamingUtilities.Combine(member.ReflectedType.FullName, member.Name), new string[,] { {"MemberName", member.Name}, {"DeclaringType", member.DeclaringType.FullName} });
+ }
+
+ return null;
+ }
+ }
+}
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/MembershipConditionNamesSuffixIsMembershipCondition.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/MembershipConditionNamesSuffixIsMembershipCondition.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/MembershipConditionNamesSuffixIsMembershipCondition.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,110 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Reflection;
+
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ /// <summary>
+ /// Description of AttributeSuffixIsAttribute.
+ /// </summary>
+ public class MembershipConditionNamesSuffixIsMembershipCondition : AbstractReflectionRule, ITypeRule
+ {
+ public override string Description {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.MembershipConditionNamesSuffixIsMembershipCondition.Description}";
+ }
+ }
+
+ // System.Attribute
+ public override string Details {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.MembershipConditionNamesSuffixIsMembershipCondition.Details}";
+ }
+ }
+
+ public Resolution Check(Type type)
+ {
+ if (typeof(System.Security.Policy.IMembershipCondition).IsAssignableFrom(type) && !type.Name.EndsWith("MembershipCondition")) {
+ return new Resolution(this, "${res:MonoDevelop.AssemblyAnalyser.Rules.MembershipConditionNamesSuffixIsMembershipCondition.Resolution}", type.FullName, new string[,] { { "TypeName", type.FullName }});
+ }
+ return null;
+ }
+ }
+}
+
+#region Unit Test
+#if TEST
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ using NUnit.Framework;
+
+ [TestFixture]
+ public class MembershipConditionNamesSuffixIsMembershipConditionTest
+ {
+ class MyClass
+ {
+ }
+ [Test]
+ public void TestCorrectMembershipCondition()
+ {
+ MembershipConditionNamesSuffixIsMembershipCondition membershipConditionNamesSuffixIsMembershipCondition = new MembershipConditionNamesSuffixIsMembershipCondition();
+ Assertion.AssertNull(membershipConditionNamesSuffixIsMembershipCondition.Check(typeof(System.Security.Policy.AllMembershipCondition)));
+ Assertion.AssertNull(membershipConditionNamesSuffixIsMembershipCondition.Check(typeof(System.Security.Policy.ZoneMembershipCondition)));
+ Assertion.AssertNull(membershipConditionNamesSuffixIsMembershipCondition.Check(typeof(MyClass)));
+ }
+
+ class MyClass2 : System.Security.Policy.IMembershipCondition
+ {
+ #region System.Security.ISecurityEncodable interface implementation
+ public void FromXml(System.Security.SecurityElement e)
+ {
+
+ }
+
+ public System.Security.SecurityElement ToXml()
+ {
+ return null;
+ }
+ #endregion
+
+ #region System.Security.ISecurityPolicyEncodable interface implementation
+ public void FromXml(System.Security.SecurityElement e, System.Security.Policy.PolicyLevel level)
+ {
+
+ }
+
+ public System.Security.SecurityElement ToXml(System.Security.Policy.PolicyLevel level)
+ {
+ return null;
+ }
+ #endregion
+
+ #region System.Security.Policy.IMembershipCondition interface implementation
+ public System.Security.Policy.IMembershipCondition Copy()
+ {
+ return null;
+ }
+
+ public bool Check(System.Security.Policy.Evidence evidence)
+ {
+ return false;
+ }
+ #endregion
+ }
+
+ [Test]
+ public void TestIncorrectAttribute()
+ {
+ MembershipConditionNamesSuffixIsMembershipCondition membershipConditionNamesSuffixIsMembershipCondition = new MembershipConditionNamesSuffixIsMembershipCondition();
+ Assertion.AssertNotNull(membershipConditionNamesSuffixIsMembershipCondition.Check(typeof(MyClass2)));
+ }
+ }
+}
+#endif
+#endregion
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/NamespacesArePascalCased.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/NamespacesArePascalCased.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/NamespacesArePascalCased.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,79 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Collections;
+
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ /// <summary>
+ /// Description of NamespacesArePascalCased.
+ /// </summary>
+ public class NamespacesArePascalCased : AbstractReflectionRule, INamespaceRule
+ {
+ public override string Description {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.NamespacesArePascalCased.Description}";
+ }
+ }
+
+ public override string Details {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.NamespacesArePascalCased.Details}";
+ }
+ }
+
+ public NamespacesArePascalCased()
+ {
+ base.certainty = 99;
+ }
+
+ public Resolution Check(string namespaceName, ICollection types)
+ {
+ string[] namespaces = namespaceName.Split('.');
+ foreach (string name in namespaces) {
+ if (!NamingUtilities.IsPascalCase(name)) {
+ for (int i = 0; i < namespaces.Length; ++i) {
+ namespaces[i] = NamingUtilities.PascalCase(namespaces[i]);
+ }
+ return new Resolution(this, "${res:MonoDevelop.AssemblyAnalyser.Rules.NamespacesArePascalCased.Resolution}", namespaceName, new string[,]{{"NamespaceName", namespaceName}, {"AlternateName", String.Join(".", namespaces) }});
+ }
+ }
+ return null;
+ }
+ }
+}
+#region Unit Test
+#if TEST
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ using NUnit.Framework;
+
+ [TestFixture]
+ public class NamespacesArePascalCasedTest
+ {
+ [Test]
+ public void TestCorrectNamespaces()
+ {
+ NamespacesArePascalCased namespacesArePascalCased = new NamespacesArePascalCased();
+ Assertion.AssertNull("Empty Namespace", namespacesArePascalCased.Check("", null));
+ Assertion.AssertNull("Single Namespace", namespacesArePascalCased.Check("MyNamespace", null));
+ Assertion.AssertNull("Complex Namespace", namespacesArePascalCased.Check("System.Windows.Form", null));
+ }
+
+ [Test]
+ public void TestIncorrectAttribute()
+ {
+ NamespacesArePascalCased namespacesArePascalCased = new NamespacesArePascalCased();
+ Assertion.AssertNotNull(namespacesArePascalCased.Check("a", null));
+ Assertion.AssertNotNull(namespacesArePascalCased.Check("A.Namespace.isWrong", null));
+ Assertion.AssertNotNull(namespacesArePascalCased.Check("System.windows.Form", null));
+ }
+ }
+}
+#endif
+#endregion
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/NamespacesDoNotContainUnderscores.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/NamespacesDoNotContainUnderscores.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/NamespacesDoNotContainUnderscores.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,73 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Collections;
+
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ /// <summary>
+ /// Description of NamespacesArePascalCased.
+ /// </summary>
+ public class NamespacesDoNotContainUnderscores : AbstractReflectionRule, INamespaceRule
+ {
+ public override string Description {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.NamespacesDoNotContainUnderscores.Description}";
+ }
+ }
+
+ public override string Details {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.NamespacesDoNotContainUnderscores.Details}";
+ }
+ }
+
+ public NamespacesDoNotContainUnderscores()
+ {
+ base.certainty = 99;
+ }
+
+ public Resolution Check(string namespaceName, ICollection types)
+ {
+ if (NamingUtilities.ContainsUnderscore(namespaceName)) {
+ return new Resolution(this, "${res:MonoDevelop.AssemblyAnalyser.Rules.NamespacesDoNotContainUnderscores.Resolution}", namespaceName, new string[,]{{"NamespaceName", namespaceName}});
+ }
+ return null;
+ }
+ }
+}
+#region Unit Test
+#if TEST
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ using NUnit.Framework;
+
+ [TestFixture]
+ public class NamespacesDoNotContainUnderscoresTest
+ {
+ [Test]
+ public void TestCorrectNamespaces()
+ {
+ NamespacesDoNotContainUnderscores rule = new NamespacesDoNotContainUnderscores();
+ Assertion.AssertNull("Empty Namespace", rule.Check("", null));
+ Assertion.AssertNull("Single Namespace", rule.Check("MyNamespace", null));
+ Assertion.AssertNull("Complex Namespace", rule.Check("System.Windows.Form", null));
+ }
+
+ [Test]
+ public void TestIncorrectNamespaces()
+ {
+ NamespacesDoNotContainUnderscores rule = new NamespacesDoNotContainUnderscores();
+ Assertion.AssertNotNull(rule.Check("_", null));
+ Assertion.AssertNotNull(rule.Check("A.Namespace.isWrong_", null));
+ Assertion.AssertNotNull(rule.Check("System._Windows.Form", null));
+ }
+ }
+}
+#endif
+#endregion
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/OnlyAttributesSuffixAttributeRule.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/OnlyAttributesSuffixAttributeRule.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/OnlyAttributesSuffixAttributeRule.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,80 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Reflection;
+
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ /// <summary>
+ /// Description of OnlyAttributesSuffixAttribute.
+ /// </summary>
+ public class OnlyAttributesSuffixAttributeRule : AbstractReflectionRule, ITypeRule
+ {
+ public override string Description {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.OnlyAttributesSuffixAttribute.Description}";
+ }
+ }
+
+ public override string Details {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.OnlyAttributesSuffixAttribute.Details}";
+ }
+ }
+
+ public OnlyAttributesSuffixAttributeRule()
+ {
+ base.certainty = 99;
+ base.priorityLevel = PriorityLevel.CriticalError;
+ }
+
+ public Resolution Check(Type type)
+ {
+ if (!type.IsSubclassOf(typeof(System.Attribute)) && type.Name.EndsWith("Attribute")) {
+ return new Resolution(this, "${res:MonoDevelop.AssemblyAnalyser.Rules.OnlyAttributesSuffixAttribute.Resolution}", type.FullName, new string[,] { { "TypeName", type.FullName }});
+ }
+ return null;
+ }
+ }
+}
+#region Unit Test
+#if TEST
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ using NUnit.Framework;
+
+ [TestFixture]
+ public class OnlyAttributesSuffixAttributeTest
+ {
+ class MyOtherClass
+ {
+ }
+ class RealAttribute : System.Attribute
+ {
+ }
+ [Test]
+ public void TestCorrectAttribute()
+ {
+ OnlyAttributesSuffixAttributeRule rule = new OnlyAttributesSuffixAttributeRule();
+ Assertion.AssertNull(rule.Check(typeof(MyOtherClass)));
+ Assertion.AssertNull(rule.Check(typeof(RealAttribute)));
+ }
+
+ class MyAttribute
+ {
+ }
+ [Test]
+ public void TestIncorrectAttribute()
+ {
+ OnlyAttributesSuffixAttributeRule rule = new OnlyAttributesSuffixAttributeRule();
+ Assertion.AssertNotNull(rule.Check(typeof(MyAttribute)));
+ }
+ }
+}
+#endif
+#endregion
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/OnlyCollectionsSuffixCollectionRule.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/OnlyCollectionsSuffixCollectionRule.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/OnlyCollectionsSuffixCollectionRule.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,133 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Collections;
+using System.Reflection;
+
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ /// <summary>
+ /// Description of CheckCollectionSuffix.
+ /// </summary>
+ public class OnlyCollectionsSuffixCollectionRule : AbstractReflectionRule, ITypeRule
+ {
+ public override string Description {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.OnlyCollectionsSuffixCollection.Description}";
+ }
+ }
+
+ public override string Details {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.OnlyCollectionsSuffixCollection.Details}";
+ }
+ }
+
+ public OnlyCollectionsSuffixCollectionRule()
+ {
+ base.certainty = 99;
+ base.priorityLevel = PriorityLevel.CriticalError;
+ }
+
+ public Resolution Check(Type type)
+ {
+ if (!typeof(ICollection).IsAssignableFrom(type) && !typeof(IEnumerable).IsAssignableFrom(type)) {
+ if (!typeof(Queue).IsAssignableFrom(type) && type.Name.EndsWith("Queue")) {
+ return new Resolution(this, "${res:MonoDevelop.AssemblyAnalyser.Rules.OnlyCollectionsSuffixCollection.Resolution1}", type.FullName, new string[,] { { "TypeName", type.FullName }});
+ } else if (!typeof(Stack).IsAssignableFrom(type) && type.Name.EndsWith("Stack")) {
+ return new Resolution(this, "${res:MonoDevelop.AssemblyAnalyser.Rules.OnlyCollectionsSuffixCollection.Resolution2}", type.FullName, new string[,] { { "TypeName", type.FullName }});
+ } else if (type.Name.EndsWith("Collection")) {
+ return new Resolution(this, "${res:MonoDevelop.AssemblyAnalyser.Rules.OnlyCollectionsSuffixCollection.Resolution3}", type.FullName, new string[,] { { "TypeName", type.FullName }});
+ }
+ }
+ return null;
+ }
+ }
+}
+#region Unit Test
+#if TEST
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ using NUnit.Framework;
+
+ [TestFixture]
+ public class OnlyCollectionsSuffixCollectionRuleTest
+ {
+ #region Collection suffix tests
+ class MyCollection : System.Collections.ArrayList
+ {
+ }
+ class OtherClass
+ {
+ }
+ [Test]
+ public void TestCorrectCollection()
+ {
+ OnlyCollectionsSuffixCollectionRule rule = new OnlyCollectionsSuffixCollectionRule();
+ Assertion.AssertNull(rule.Check(typeof(MyCollection)));
+ Assertion.AssertNull(rule.Check(typeof(OtherClass)));
+ }
+
+ class My2Collection
+ {
+ }
+ [Test]
+ public void TestIncorrectCollection()
+ {
+ OnlyCollectionsSuffixCollectionRule rule = new OnlyCollectionsSuffixCollectionRule();
+ Assertion.AssertNotNull(rule.Check(typeof(My2Collection)));
+ }
+ #endregion
+
+ #region Queue suffix tests
+ class MyQueue : System.Collections.Queue
+ {
+ }
+ [Test]
+ public void TestCorrectQueue()
+ {
+ OnlyCollectionsSuffixCollectionRule rule = new OnlyCollectionsSuffixCollectionRule();
+ Assertion.AssertNull(rule.Check(typeof(MyQueue)));
+ }
+
+ class My2Queue
+ {
+ }
+ [Test]
+ public void TestIncorrectQueue()
+ {
+ OnlyCollectionsSuffixCollectionRule rule = new OnlyCollectionsSuffixCollectionRule();
+ Assertion.AssertNotNull(rule.Check(typeof(My2Queue)));
+ }
+ #endregion
+
+ #region Stack suffix tests
+ class MyStack : System.Collections.Stack
+ {
+ }
+ [Test]
+ public void TestCorrectStack()
+ {
+ OnlyCollectionsSuffixCollectionRule rule = new OnlyCollectionsSuffixCollectionRule();
+ Assertion.AssertNull(rule.Check(typeof(MyStack)));
+ }
+
+ class My2Stack
+ {
+ }
+ [Test]
+ public void TestIncorrectStack()
+ {
+ OnlyCollectionsSuffixCollectionRule rule = new OnlyCollectionsSuffixCollectionRule();
+ Assertion.AssertNotNull(rule.Check(typeof(My2Stack)));
+ }
+ #endregion
+ }
+}
+#endif
+#endregion
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/OnlyEventArgsSuffixEventArgsRule.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/OnlyEventArgsSuffixEventArgsRule.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/OnlyEventArgsSuffixEventArgsRule.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,85 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Reflection;
+
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ /// <summary>
+ /// Description of OnlyEventArgsSuffixEventArgsRule.
+ /// </summary>
+ public class OnlyEventArgsSuffixEventArgsRule : AbstractReflectionRule, ITypeRule
+ {
+ public override string Description {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.OnlyEventArgsSuffixEventArgs.Description}";
+ }
+ }
+
+ public override string Details {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.OnlyEventArgsSuffixEventArgs.Details}";
+ }
+ }
+
+ public OnlyEventArgsSuffixEventArgsRule()
+ {
+ base.certainty = 99;
+ base.priorityLevel = PriorityLevel.CriticalError;
+ }
+
+ public Resolution Check(Type type)
+ {
+ if (!typeof(System.EventArgs).IsAssignableFrom(type) && type.Name.EndsWith("EventArgs")) {
+ return new Resolution(this, "${res:MonoDevelop.AssemblyAnalyser.Rules.OnlyEventArgsSuffixEventArgs.Resolution}", type.FullName, new string[,] { { "TypeName", type.FullName }});
+ }
+ return null;
+ }
+ }
+}
+#region Unit Test
+#if TEST
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ using NUnit.Framework;
+
+ [TestFixture]
+ public class OnlyEventArgsSuffixEventArgsRuleTest
+ {
+ class CorrectEventArgs : System.EventArgs
+ {
+ }
+ class OtherClass
+ {
+ }
+ class MyEventArgs : CorrectEventArgs
+ {
+ }
+ [Test]
+ public void TestCorrectEventArgs()
+ {
+ OnlyEventArgsSuffixEventArgsRule rule = new OnlyEventArgsSuffixEventArgsRule();
+ Assertion.AssertNull(rule.Check(typeof(CorrectEventArgs)));
+ Assertion.AssertNull(rule.Check(typeof(OtherClass)));
+ Assertion.AssertNull(rule.Check(typeof(MyEventArgs)));
+ }
+
+ class IncorrectEventArgs
+ {
+ }
+ [Test]
+ public void TestIncorrectEventArgs()
+ {
+ OnlyEventArgsSuffixEventArgsRule rule = new OnlyEventArgsSuffixEventArgsRule();
+ Assertion.AssertNotNull(rule.Check(typeof(IncorrectEventArgs)));
+ }
+
+ }
+}
+#endif
+#endregion
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/OnlyEventHandlerSuffixIsEventHandlerRule.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/OnlyEventHandlerSuffixIsEventHandlerRule.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/OnlyEventHandlerSuffixIsEventHandlerRule.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,50 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Reflection;
+
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ /// <summary>
+ /// Description of OnlyEventHandlerSuffixIsEventHandlerRule.
+ /// </summary>
+ public class OnlyEventHandlerSuffixIsEventHandlerRule : AbstractReflectionRule, IMemberRule
+ {
+ public override string Description {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.OnlyEventHandlerSuffixIsEventHandler.Description}";
+ }
+ }
+
+ public override string Details {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.OnlyEventHandlerSuffixIsEventHandler.Details}";
+ }
+ }
+
+ public OnlyEventHandlerSuffixIsEventHandlerRule()
+ {
+ base.certainty = 99;
+ base.priorityLevel = PriorityLevel.CriticalError;
+ }
+
+ public Resolution Check(Module module, MemberInfo member)
+ {
+ if (member is MethodInfo) {
+ MethodInfo mi = (MethodInfo)member;
+ if (mi.IsSpecialName) {
+ return null;
+ }
+ }
+ if (member.Name.EndsWith("EventHandler")) {
+ return new Resolution(this, "${res:MonoDevelop.AssemblyAnalyser.Rules.OnlyEventHandlerSuffixIsEventHandler.Resolution}", NamingUtilities.Combine(member.ReflectedType.FullName, member.Name), new string[,] { {"MemberName", member.Name}, {"DeclaringType", member.DeclaringType.FullName} });
+ }
+ return null;
+ }
+ }
+}
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/OnlyExceptionsSuffixExceptionRule.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/OnlyExceptionsSuffixExceptionRule.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/OnlyExceptionsSuffixExceptionRule.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,80 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Reflection;
+
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ /// <summary>
+ /// Description of OnlyExceptionsSuffixExceptionRule.
+ /// </summary>
+ public class OnlyExceptionsSuffixExceptionRule : AbstractReflectionRule, ITypeRule
+ {
+ public override string Description {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.OnlyExceptionsSuffixException.Description}";
+ }
+ }
+
+ public override string Details {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.OnlyExceptionsSuffixException.Details}";
+ }
+ }
+
+ public OnlyExceptionsSuffixExceptionRule()
+ {
+ base.certainty = 99;
+ base.priorityLevel = PriorityLevel.CriticalError;
+ }
+
+
+ public Resolution Check(Type type)
+ {
+ if (!typeof(System.Exception).IsAssignableFrom(type) && type.Name.EndsWith("Exception")) {
+ return new Resolution(this, "${res:MonoDevelop.AssemblyAnalyser.Rules.OnlyExceptionsSuffixException.Resolution}", type.FullName, new string[,] { { "TypeName", type.FullName }});
+ }
+ return null;
+ }
+ }
+}
+#region Unit Test
+#if TEST
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ using NUnit.Framework;
+
+ [TestFixture]
+ public class OnlyExceptionsSuffixExceptionRuleTest
+ {
+ class MyException : System.Exception
+ {
+ }
+ class OtherClass
+ {}
+ [Test]
+ public void TestCorrectException()
+ {
+ OnlyExceptionsSuffixExceptionRule rule = new OnlyExceptionsSuffixExceptionRule();
+ Assertion.AssertNull(rule.Check(typeof(MyException)));
+ Assertion.AssertNull(rule.Check(typeof(OtherClass)));
+ }
+
+ class NotAnException
+ {
+ }
+ [Test]
+ public void TestIncorrectException()
+ {
+ OnlyExceptionsSuffixExceptionRule rule = new OnlyExceptionsSuffixExceptionRule();
+ Assertion.AssertNotNull(rule.Check(typeof(NotAnException)));
+ }
+ }
+}
+#endif
+#endregion
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/OnlyPermissionsSuffixPermissionRule.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/OnlyPermissionsSuffixPermissionRule.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/OnlyPermissionsSuffixPermissionRule.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,77 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Reflection;
+
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ /// <summary>
+ /// Description of OnlyExceptionsSuffixException.
+ /// </summary>
+ public class OnlyPermissionsSuffixPermissionRule : AbstractReflectionRule, ITypeRule
+ {
+ public override string Description {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.OnlyPermissionsSuffixPermission.Description}";
+ }
+ }
+
+ public override string Details {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.OnlyPermissionsSuffixPermission.Details}";
+ }
+ }
+
+ public OnlyPermissionsSuffixPermissionRule()
+ {
+ base.certainty = 99;
+ base.priorityLevel = PriorityLevel.CriticalError;
+ }
+
+ public Resolution Check(Type type)
+ {
+ if (!typeof(System.Security.IPermission).IsAssignableFrom(type) && type.Name.EndsWith("Permission")) {
+ return new Resolution(this, "${res:MonoDevelop.AssemblyAnalyser.Rules.OnlyPermissionsSuffixPermission.Resolution}", type.FullName, new string[,] { { "TypeName", type.FullName }});
+ }
+ return null;
+ }
+ }
+}
+#region Unit Test
+#if TEST
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ using NUnit.Framework;
+
+ [TestFixture]
+ public class OnlyPermissionsSuffixPermissionRuleTest
+ {
+ class OtherClass
+ {}
+ [Test]
+ public void TestCorrectPermission()
+ {
+ OnlyPermissionsSuffixPermissionRule rule = new OnlyPermissionsSuffixPermissionRule();
+ Assertion.AssertNull(rule.Check(typeof(System.Security.Permissions.EnvironmentPermission)));
+ Assertion.AssertNull(rule.Check(typeof(System.Security.Permissions.FileIOPermission)));
+ Assertion.AssertNull(rule.Check(typeof(OtherClass)));
+ }
+
+ class NotAnPermission
+ {
+ }
+ [Test]
+ public void TestIncorrectPermission()
+ {
+ OnlyPermissionsSuffixPermissionRule rule = new OnlyPermissionsSuffixPermissionRule();
+ Assertion.AssertNotNull(rule.Check(typeof(NotAnPermission)));
+ }
+ }
+}
+#endif
+#endregion
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/OnlyStreamsSuffixStreamRule.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/OnlyStreamsSuffixStreamRule.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/OnlyStreamsSuffixStreamRule.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,84 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Reflection;
+
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ /// <summary>
+ /// Description of OnlyStreamsSuffixStreamRule.
+ /// </summary>
+ public class OnlyStreamsSuffixStreamRule : AbstractReflectionRule, ITypeRule
+ {
+ public override string Description {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.OnlyStreamsSuffixStream.Description}";
+ }
+ }
+
+ public override string Details {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.OnlyStreamsSuffixStream.Details}";
+ }
+ }
+
+ public OnlyStreamsSuffixStreamRule()
+ {
+ base.certainty = 99;
+ base.priorityLevel = PriorityLevel.CriticalError;
+ }
+
+
+ public Resolution Check(Type type)
+ {
+ if (!typeof(System.IO.Stream).IsAssignableFrom(type) && type.Name.EndsWith("Stream")) {
+ return new Resolution(this, "${res:MonoDevelop.AssemblyAnalyser.Rules.OnlyStreamsSuffixStream.Resolution}", type.FullName, new string[,] { { "TypeName", type.FullName }});
+ }
+ return null;
+ }
+ }
+}
+#region Unit Test
+#if TEST
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ using System.IO;
+ using NUnit.Framework;
+
+ [TestFixture]
+ public class OnlyStreamsSuffixStreamRuleTest
+ {
+ class MyOtherClass
+ {
+ }
+ class RealStream : System.IO.FileStream
+ {
+ public RealStream(string path,FileMode mode) : base(path, mode)
+ {}
+ }
+ [Test]
+ public void TestCorrectStream()
+ {
+ OnlyStreamsSuffixStreamRule rule = new OnlyStreamsSuffixStreamRule();
+ Assertion.AssertNull(rule.Check(typeof(MyOtherClass)));
+ Assertion.AssertNull(rule.Check(typeof(RealStream)));
+ }
+
+ class MyStream
+ {
+ }
+ [Test]
+ public void TestIncorrectStream()
+ {
+ OnlyStreamsSuffixStreamRule rule = new OnlyStreamsSuffixStreamRule();
+ Assertion.AssertNotNull(rule.Check(typeof(MyStream)));
+ }
+ }
+}
+#endif
+#endregion
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/ParameterNamesDoNotHaveUnderscores.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/ParameterNamesDoNotHaveUnderscores.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/ParameterNamesDoNotHaveUnderscores.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,98 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Reflection;
+using System.Collections;
+
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ /// <summary>
+ /// Description of ParameterNamesDoNotHaveUnderscores.
+ /// </summary>
+ public class ParameterNamesDoNotHaveUnderscores : AbstractReflectionRule, IParameterRule
+ {
+ public override string Description {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.ParameterNamesDoNotHaveUnderscores.Description}";
+ }
+ }
+
+ public override string Details {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.ParameterNamesDoNotHaveUnderscores.Details}";
+ }
+ }
+
+ public ParameterNamesDoNotHaveUnderscores()
+ {
+ base.certainty = 99;
+ }
+
+ public Resolution Check(Module module, ParameterInfo param)
+ {
+ if (param.Name != null && param.Name.IndexOf('_') >= 0) {
+ string memberName = NamingUtilities.Combine(param.Member.DeclaringType.FullName, param.Member.Name);
+ return new Resolution(this, "${res:MonoDevelop.AssemblyAnalyser.Rules.ParameterNamesDoNotHaveUnderscores.Resolution}", memberName, new string[,] {{"ParameterName", param.Name}, {"MemberName", memberName}});
+ }
+ return null;
+ }
+ }
+}
+#region Unit Test
+#if TEST
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ using NUnit.Framework;
+
+ [TestFixture]
+ public class ParameterNamesDoNotHaveUnderscoresTest
+ {
+ public class A {
+ public void TestMethod1(int right)
+ {
+ }
+ public void TestMethod2(int a, int b, int c, int d)
+ {
+ }
+ public void TestMethod3(int wrong_)
+ {
+ }
+ public void TestMethod4(int _a, int b_c, int ____, int wrong_)
+ {
+ }
+ public static void TestMethod(MethodInfo methodInfo, bool isNull)
+ {
+ ParameterNamesDoNotHaveUnderscores parameterNamesDoNotHaveUnderscores = new ParameterNamesDoNotHaveUnderscores();
+ foreach (ParameterInfo parameter in methodInfo.GetParameters()) {
+ if (isNull) {
+ Assertion.AssertNull(parameterNamesDoNotHaveUnderscores.Check(null, parameter));
+ } else {
+ Assertion.AssertNotNull(parameterNamesDoNotHaveUnderscores.Check(null, parameter));
+ }
+ }
+ }
+ }
+
+
+ [Test]
+ public void TestCorrectParameters()
+ {
+ A.TestMethod(typeof(A).GetMethod("TestMethod1"), true);
+ A.TestMethod(typeof(A).GetMethod("TestMethod2"), true);
+ }
+
+ [Test]
+ public void TestIncorrectParameters()
+ {
+ A.TestMethod(typeof(A).GetMethod("TestMethod3"), false);
+ A.TestMethod(typeof(A).GetMethod("TestMethod4"), false);
+ }
+ }
+}
+#endif
+#endregion
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/ParametersAreCamelCased.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/ParametersAreCamelCased.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/ParametersAreCamelCased.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,98 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Reflection;
+using System.Collections;
+
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ /// <summary>
+ /// Description of NamespacesArePascalCased.
+ /// </summary>
+ public class ParametersAreCamelCased : AbstractReflectionRule, IParameterRule
+ {
+ public override string Description {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.ParametersAreCamelCased.Description}";
+ }
+ }
+
+ public override string Details {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.ParametersAreCamelCased.Details}";
+ }
+ }
+
+ public ParametersAreCamelCased()
+ {
+ base.certainty = 99;
+ }
+
+ public Resolution Check(Module module, ParameterInfo param)
+ {
+ if (!NamingUtilities.IsCamelCase(param.Name)) {
+ string memberName = NamingUtilities.Combine(param.Member.DeclaringType.FullName, param.Member.Name);
+ return new Resolution(this, "${res:MonoDevelop.AssemblyAnalyser.Rules.ParametersAreCamelCased.Resolution}", memberName, new string[,] {{"ParameterName", param.Name}, {"MemberName", memberName}, {"AlternateName", NamingUtilities.CamelCase(param.Name)}});
+ }
+ return null;
+ }
+ }
+}
+#region Unit Test
+#if TEST
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ using NUnit.Framework;
+
+ [TestFixture]
+ public class ParametersAreCamelCasedTest
+ {
+ public class A {
+ public void TestMethod1(int right)
+ {
+ }
+ public void TestMethod2(int a, int b, int c, int d)
+ {
+ }
+ public void TestMethod3(int Wrong)
+ {
+ }
+ public void TestMethod4(int A, int B, int C, int D)
+ {
+ }
+ public static void TestMethod(MethodInfo methodInfo, bool isNull)
+ {
+ ParametersAreCamelCased parametersAreCamelCased = new ParametersAreCamelCased();
+ foreach (ParameterInfo parameter in methodInfo.GetParameters()) {
+ if (isNull) {
+ Assertion.AssertNull(parametersAreCamelCased.Check(null, parameter));
+ } else {
+ Assertion.AssertNotNull(parametersAreCamelCased.Check(null, parameter));
+ }
+ }
+ }
+ }
+
+
+ [Test]
+ public void TestCorrectParameters()
+ {
+ A.TestMethod(typeof(A).GetMethod("TestMethod1"), true);
+ A.TestMethod(typeof(A).GetMethod("TestMethod2"), true);
+ }
+
+ [Test]
+ public void TestIncorrectParameters()
+ {
+ A.TestMethod(typeof(A).GetMethod("TestMethod3"), false);
+ A.TestMethod(typeof(A).GetMethod("TestMethod4"), false);
+ }
+ }
+}
+#endif
+#endregion
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/PermissionSuffixIsPermissionRule.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/PermissionSuffixIsPermissionRule.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/PermissionSuffixIsPermissionRule.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,62 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Reflection;
+
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ /// <summary>
+ /// Description of PermissionSuffixIsPermissionRule.
+ /// </summary>
+ public class PermissionSuffixIsPermissionRule : AbstractReflectionRule, ITypeRule
+ {
+ public override string Description {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.PermissionSuffixIsPermission.Description}";
+ }
+ }
+
+ // System.Attribute
+ public override string Details {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.PermissionSuffixIsPermission.Details}";
+ }
+ }
+
+ public Resolution Check(Type type)
+ {
+ if (typeof(System.Security.IPermission).IsAssignableFrom(type) && !type.Name.EndsWith("Permission")) {
+ return new Resolution(this, "${res:MonoDevelop.AssemblyAnalyser.Rules.PermissionSuffixIsPermission.Resolution}", type.FullName, new string[,] { { "TypeName", type.FullName }});
+ }
+ return null;
+ }
+ }
+}
+
+#region Unit Test
+#if TEST
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ using NUnit.Framework;
+
+ [TestFixture]
+ public class PermissionSuffixIsPermissionRuleTest
+ {
+ [Test]
+ public void TestCorrectPermission()
+ {
+ PermissionSuffixIsPermissionRule rule = new PermissionSuffixIsPermissionRule();
+ Assertion.AssertNull(rule.Check(typeof(System.Security.Permissions.EnvironmentPermission)));
+ Assertion.AssertNull(rule.Check(typeof(System.Security.Permissions.FileIOPermission)));
+ Assertion.AssertNull(rule.Check(typeof(PermissionSuffixIsPermissionRuleTest)));
+ }
+
+ }
+}
+#endif
+#endregion
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/StreamSuffixIsStreamRule.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/StreamSuffixIsStreamRule.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/StreamSuffixIsStreamRule.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,84 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Reflection;
+
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ /// <summary>
+ /// Description of StreamSuffixIsStreamRule.
+ /// </summary>
+ public class StreamSuffixIsStreamRule : AbstractReflectionRule, ITypeRule
+ {
+ public override string Description {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.StreamSuffixIsStream.Description}";
+ }
+ }
+
+ public override string Details {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.StreamSuffixIsStream.Details}";
+ }
+ }
+
+ public StreamSuffixIsStreamRule()
+ {
+ base.certainty = 99;
+ }
+
+ public Resolution Check(Type type)
+ {
+ if (typeof(System.IO.Stream).IsAssignableFrom(type) && !type.Name.EndsWith("Stream")) {
+ return new Resolution(this, "${res:MonoDevelop.AssemblyAnalyser.Rules.StreamSuffixIsStream.Resolution}", type.FullName, new string[,] { { "TypeName", type.FullName }});
+ }
+ return null;
+ }
+ }
+}
+#region Unit Test
+#if TEST
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ using System.IO;
+ using NUnit.Framework;
+
+ [TestFixture]
+ public class StreamSuffixIsStreamRuleTest
+ {
+ class MyOtherClass
+ {
+ }
+ class RealStream : System.IO.FileStream
+ {
+ public RealStream(string path,FileMode mode) : base(path, mode)
+ {}
+ }
+ [Test]
+ public void TestCorrectStream()
+ {
+ StreamSuffixIsStreamRule rule = new StreamSuffixIsStreamRule();
+ Assertion.AssertNull(rule.Check(typeof(MyOtherClass)));
+ Assertion.AssertNull(rule.Check(typeof(RealStream)));
+ }
+
+ class WrongStrm : System.IO.FileStream
+ {
+ public WrongStrm(string path,FileMode mode) : base(path, mode)
+ {}
+ }
+ [Test]
+ public void TestIncorrectStream()
+ {
+ StreamSuffixIsStreamRule rule = new StreamSuffixIsStreamRule();
+ Assertion.AssertNotNull(rule.Check(typeof(WrongStrm)));
+ }
+ }
+}
+#endif
+#endregion
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/TypeNamesDoNotContainUnderscores.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/TypeNamesDoNotContainUnderscores.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/TypeNamesDoNotContainUnderscores.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,75 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Reflection;
+
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ /// <summary>
+ /// Description of AttributeSuffixIsAttribute.
+ /// </summary>
+ public class TypeNamesDoNotContainUnderscores : AbstractReflectionRule, ITypeRule
+ {
+ public override string Description {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.TypeNamesDoNotContainUnderscores.Description}";
+ }
+ }
+
+ public override string Details {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.TypeNamesDoNotContainUnderscores.Details}";
+ }
+ }
+
+ public TypeNamesDoNotContainUnderscores()
+ {
+ base.certainty = 99;
+ }
+
+ public Resolution Check(Type type)
+ {
+ if (NamingUtilities.ContainsUnderscore(type.Name)) {
+ return new Resolution(this, "${res:MonoDevelop.AssemblyAnalyser.Rules.TypeNamesDoNotContainUnderscores.Resolution}", type.FullName, new string[,] { { "TypeName", type.FullName }});
+ }
+ return null;
+ }
+ }
+}
+#region Unit Test
+#if TEST
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ using NUnit.Framework;
+
+ [TestFixture]
+ public class TypeNamesDoNotContainUnderscoresTest
+ {
+ interface ICorrectInterface
+ {
+ }
+ [Test]
+ public void TestCorrectTypenames()
+ {
+ TypeNamesDoNotContainUnderscores typeNamesDoNotContainUnderscores = new TypeNamesDoNotContainUnderscores();
+ Assertion.AssertNull(typeNamesDoNotContainUnderscores.Check(typeof(ICorrectInterface)));
+ }
+
+ class Wrong_Class
+ {
+ }
+ [Test]
+ public void TestIncorrectTypenames()
+ {
+ TypeNamesDoNotContainUnderscores typeNamesDoNotContainUnderscores = new TypeNamesDoNotContainUnderscores();
+ Assertion.AssertNotNull(typeNamesDoNotContainUnderscores.Check(typeof(Wrong_Class)));
+ }
+ }
+}
+#endif
+#endregion
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/TypesArePascalCased.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/TypesArePascalCased.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/TypesArePascalCased.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,81 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Reflection;
+
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ /// <summary>
+ /// Description of AttributeSuffixIsAttribute.
+ /// </summary>
+ public class TypesArePascalCased : AbstractReflectionRule, ITypeRule
+ {
+ public override string Description {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.TypesArePascalCased.Description}";
+ }
+ }
+
+ public override string Details {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.TypesArePascalCased.Details}";
+ }
+ }
+
+ public TypesArePascalCased()
+ {
+ base.certainty = 99;
+ }
+
+ public Resolution Check(Type type)
+ {
+ if (!NamingUtilities.IsPascalCase(type.Name)) {
+ return new Resolution(this, "${res:MonoDevelop.AssemblyAnalyser.Rules.TypesArePascalCased.Resolution}", type.FullName, new string[,] { { "TypeName", type.FullName }, {"AlternateName", NamingUtilities.PascalCase(type.Name)}});
+ }
+ return null;
+ }
+ }
+}
+#region Unit Test
+#if TEST
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ using NUnit.Framework;
+
+ [TestFixture]
+ public class TypesArePascalCasedTest
+ {
+ interface IInterface
+ {
+ }
+ class AClassImplTest
+ {
+
+ }
+ [Test]
+ public void TestCorrectTypenames()
+ {
+ TypesArePascalCased typesArePascalCased = new TypesArePascalCased();
+ Assertion.AssertNull(typesArePascalCased.Check(typeof(IInterface)));
+ Assertion.AssertNull(typesArePascalCased.Check(typeof(AClassImplTest)));
+ }
+
+ class wrong
+ {
+
+ }
+ [Test]
+ public void TestIncorrectTypenames()
+ {
+ TypesArePascalCased typesArePascalCased = new TypesArePascalCased();
+ Assertion.AssertNotNull(typesArePascalCased.Check(typeof(wrong)));
+ }
+ }
+}
+#endif
+#endregion
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/TypesImplementingInterfacesHaveNoSuffixImplRule.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/TypesImplementingInterfacesHaveNoSuffixImplRule.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingRules/TypesImplementingInterfacesHaveNoSuffixImplRule.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,75 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Reflection;
+
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ /// <summary>
+ /// Description of TypesImplementingInterfacesHaveNoSuffixImplRule.
+ /// </summary>
+ public class TypesImplementingInterfacesHaveNoSuffixImplRule : AbstractReflectionRule, ITypeRule
+ {
+ public override string Description {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.TypesImplementingInterfacesHaveNoSuffixImpl.Description}";
+ }
+ }
+
+ public override string Details {
+ get {
+ return "${res:MonoDevelop.AssemblyAnalyser.Rules.TypesImplementingInterfacesHaveNoSuffixImpl.Details}";
+ }
+ }
+
+ public Resolution Check(Type type)
+ {
+ if (type.GetInterfaces().Length > 0 && type.Name.EndsWith("Impl")) {
+ return new Resolution(this, "${res:MonoDevelop.AssemblyAnalyser.Rules.TypesImplementingInterfacesHaveNoSuffixImpl.Resolution}", type.FullName, new string[,] { { "TypeName", type.FullName }});
+ }
+ return null;
+ }
+ }
+}
+#region Unit Test
+#if TEST
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ using NUnit.Framework;
+
+ [TestFixture]
+ public class TypesImplementingInterfacesHaveNoSuffixImplRuleTest
+ {
+ interface IInterface
+ {
+ }
+ class AClassImplTest : IInterface
+ {
+
+ }
+ [Test]
+ public void TestCorrectTypenames()
+ {
+ TypesImplementingInterfacesHaveNoSuffixImplRule rule = new TypesImplementingInterfacesHaveNoSuffixImplRule();
+ Assertion.AssertNull(rule.Check(typeof(AClassImplTest)));
+ }
+
+ class BImpl : IInterface
+ {
+
+ }
+ [Test]
+ public void TestIncorrectTypenames()
+ {
+ TypesImplementingInterfacesHaveNoSuffixImplRule rule = new TypesImplementingInterfacesHaveNoSuffixImplRule();
+ Assertion.AssertNotNull(rule.Check(typeof(BImpl)));
+ }
+ }
+}
+#endif
+#endregion
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingUtilities.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingUtilities.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/NamingUtilities.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,73 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ /// <summary>
+ /// Description of NamingUtilities.
+ /// </summary>
+ public sealed class NamingUtilities
+ {
+ /// <summary>
+ /// Pascal casing is like 'PascalCase'
+ /// </summary>
+ public static bool IsPascalCase(string name)
+ {
+ if (name == null || name.Length == 0) {
+ return true;
+ }
+ return Char.IsUpper(name[0]);
+ }
+
+ public static string PascalCase(string name)
+ {
+ if (name == null || name.Length == 0) {
+ return name;
+ }
+ return Char.ToUpper(name[0]) + name.Substring(1);
+ }
+
+
+ /// <summary>
+ /// Camel casing is like 'camelCase'
+ /// </summary>
+ public static bool IsCamelCase(string name)
+ {
+ if (name == null || name.Length == 0) {
+ return true;
+ }
+ return Char.IsLower(name[0]);
+ }
+
+
+ public static string CamelCase(string name)
+ {
+ if (name == null || name.Length == 0) {
+ return name;
+ }
+ return Char.ToLower(name[0]) + name.Substring(1);
+ }
+
+ public static bool ContainsUnderscore(string name)
+ {
+ if (name == null || name.Length == 0) {
+ return false;
+ }
+ return name.IndexOf('_') >= 0;
+ }
+
+ public static string Combine(string typeName, string memberName)
+ {
+ return String.Concat(typeName,
+ '.',
+ memberName);
+ }
+
+ }
+}
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/PriorityLevel.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/PriorityLevel.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/PriorityLevel.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,24 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Reflection;
+
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ /// <summary>
+ /// Description of IAssemblyRule.
+ /// </summary>
+ public enum PriorityLevel
+ {
+ Information,
+ Warning,
+ CriticalWarning,
+ Error,
+ CriticalError
+ }
+}
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/ProtectionLevels.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/ProtectionLevels.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/Rules/ProtectionLevels.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,35 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Reflection;
+
+namespace MonoDevelop.AssemblyAnalyser.Rules
+{
+ [Flags]
+ public enum ProtectionLevels
+ {
+ None = 0,
+
+ Public = 1,
+ Family = 2,
+ Private = 4,
+ Assembly = 8,
+ FamilyAndAssembly = 16,
+ FamilyOrAssembly = 32,
+
+ NestedPublic = 64,
+ NestedFamily = 128,
+ NestedPrivate = 256,
+ NestedAssembly = 512,
+ NestedFamilyAndAssembly = 1024,
+ NestedFamilyOrAssembly = 2048,
+
+ All = Public | Family | Private | Assembly | FamilyAndAssembly | FamilyOrAssembly |
+ NestedPublic | NestedFamily | NestedPrivate | NestedAssembly | NestedFamilyAndAssembly | NestedFamilyOrAssembly,
+ }
+}
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/TODO.txt
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/TODO.txt 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer/TODO.txt 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,206 @@
+Goal:
+Basically 're-invent' FxCop (a very, very good no cost tool from Microsoft)
+
+Todo:
+Translate all FxCop rules to Assembly Analyser and write a unit test that tests
+the rule in action (except maybe 'Assembly' and 'Module' rules.
+
+Status (FxCop rules):
+
+DesignRules:
+ * AbstractTypesShouldNotHaveConstructors IS AbstractTypesPublicConstructors
+AddAndSubtractOverrideShouldHaveOperatorEqualsOverride
+ * AssembliesAreMarkedClsCompliant IS AssemblyClsCompliantRule
+ * AssembliesHaveStrongNames IS AssemblyStrongName
+ * AssembliesHaveVersionNumbers IS AssemblyVersionNumber
+AssembliesShouldBeComVisibleAttributed
+AttributesAreAttributeUsageAttributed
+AttributesShouldHaveAccessorsForAllArguments
+AvoidDefaultConstructorForStructures
+AvoidMarkingMembersObsolete
+AvoidMarkingTypesObsolete
+ * AvoidNamespacesWithFewMembers IS AvoidNamespacesWithFewMembers
+AvoidOutParameters
+AvoidValueTypesPassedAsByRefParameters
+ConsiderHavingOnlyOneDimensionForIndexer
+ConsiderReplacingMethodsWithProperties
+ConsiderReplacingRepetitiveArgsWithParameterArray
+DefaultParametersAreNotUsed
+EnumerationsShouldBeFlagsAttributed
+EnumerationsShouldBeInt32
+EnumerationsShouldBeIntegralType
+ * EventFirstParametersAreTypeObject IS EventFirstParameterIsObject
+ * EventHandlersReturnVoid IS EventHandlersReturnVoid
+ * EventSecondParametersAreEventArgsType IS EventSecondParameterIsEventArgs
+ * EventsHaveTwoParameters IS EventsHaveTwoParameters
+EventsShouldBeUsed
+ExceptionAndSystemExceptionTypesAreNotCaught
+ExceptionsRequireMultipleConstructors
+ExplicitMethodImplementationsInUnsealedClassesHaveVisibleAlternates
+ExternallyVisibleNestedTypesShouldNotBeUsed
+ICollectionImplementationsHaveStronglyTypedMembers
+IComparableImplementationsOverrideEquals
+IComparableImplementationsOverrideOperators
+IEnumeratorImplementationsHaveStronglyTypedMembers
+IListImplementationsHaveStronglyTypedMembers
+ * InterfacesShouldNotBeEmpty IS InterfaceNotEmpty
+ISerializableTypesAreMarkedSerializable
+ObsoleteAttributeOnMemberShouldProvideMessage
+ObsoleteAttributeOnTypeShouldProvideMessage
+OnlyIntegralValuesOrStringsShouldBeUsedForIndexers
+PointersAndMultiDimensionalArraysAreNotPassedAsParameters
+ * PropertiesShouldNotBeWriteOnly IS PropertiesShouldNotHaveSetOnly
+ReferenceTypesAreNotPassedAsByRefParameters
+ReferenceTypesShouldNotOverrideOperatorEquals
+SealedTypesDoNotDeclareProtectedMembers
+SealedTypesDoNotDeclareVirtualMembers
+TypesAllocatingUnmanagedResourcesImplementIDisposable
+ * TypesBelongToNamespaces IS TypesShouldBeInNamespaces
+ * TypesDoNotHavePublicInstanceFields IS TypesHaveNoPublicInstanceFields
+TypesHavingOnlyStaticMembersShouldBeSealed
+TypesHavingOnlyStaticMembersShouldNotHaveConstructors
+
+NamingRules:
+ * AttributeNamesHaveAttributeSuffix IS AttributeSuffixIsAttribute
+ * CollectionNamesHaveCollectionSuffix IS CheckCollectionSuffix
+ * ConditionNamesHaveConditionSuffix IS MembershipConditionNamesSuffixIsMembershipCondition (I think 'MembershipCondition' is more correct than just 'Condition', right?)
+ * DelegateNamesDoNotHaveDelegateSuffix IS DelegatesHaveNoDelegateSuffix
+ * DictionaryNamesHaveDictionarySuffix IS DictionaryTypeSuffixIsDictionary
+ * EnumerationNamesDoNotHaveEnumSuffix IS EnumsHaveNoEnumSuffix
+ * EventArgsNamesHaveEventArgsSuffix IS EventArgsSuffixIsEventArgs
+ * EventFirstParametersHaveNameSender IS EventFirstParameterNameIsSender
+ * EventHandlerNamesHaveEventHandlerSuffix IS EventHandlerSuffixIsEventHandler
+ * EventsDoNotHaveBeforeOrAfterPrefix IS EventsDoNotHaveBeforeOrAfterPrefix
+ * EventSecondParametersHaveNameE IS EventSecondParameterNameIsE
+ * ExceptionNamesHaveExceptionSuffix IS ExceptionSuffixIsException
+ * FlagEnumerationsShouldHavePluralNames IS FlagEnumerationsArePlural
+ * InterfaceNamesHaveIPrefix IS InterfacesPrefixIsI
+ * MemberNamesArePascalCased IS MembersArePascalCased
+MemberNamesDifferByMoreThanCase
+ * MemberNamesDoNotHaveUnderscores IS MembersDoNotContainUnderscores
+MemberNamesHaveOnlyShortAcronymsAllCaps
+MemberNamesHaveShortAcronymsAllCaps
+ * NamespaceNamesArePascalCased IS NamespacesArePascalCased
+NamespaceNamesDifferByMoreThanCase
+ * NamespaceNamesDoNotHaveUnderscores IS NamespacesDoNotContainUnderscores
+NamespaceNamesDoNotMatchKeywords
+NamespaceNamesHaveOnlyShortAcronymsAllCaps
+NamespaceNamesHaveShortAcronymsAllCaps
+ * OnlyAttributeNamesHaveAttributeSuffix IS OnlyAttributesSuffixAttribute
+ * OnlyCollectionNamesHaveCollectionSuffix IS OnlyCollectionsSuffixCollection
+ -> OnlyDictionaryNamesHaveDictionarySuffix HANDLED IN OnlyCollectionsSuffixCollection
+ * OnlyEventArgsNamesHaveEventArgsSuffix IS OnlyEventArgsSuffixEventArgs
+ ( OnlyEventHandlerNamesHaveEventHandlerSuffix is OnlyEventHandlerSuffixIsEventHandler
+ * OnlyExceptionNamesHaveExceptionSuffix IS OnlyExceptionsSuffixException
+OnlyFlagEnumerationsShouldHavePluralNames
+ * OnlyPermissionNamesHavePermissionSuffix IS OnlyPermissionsSuffixPermission
+ -> OnlyQueueNamesHaveQueueSuffix HANDLED IN OnlyCollectionsSuffixCollection
+ -> OnlyStackNamesHaveStackSuffix HANDLED IN OnlyCollectionsSuffixCollection
+ * OnlyStreamNamesHaveStreamSuffix IS OnlyStreamsSuffixStream
+ * ParameterNamesAreCamelCased IS ParametersAreCamelCased
+ParameterNamesDifferByMoreThanCase
+ParameterNamesDoNotContainLanguageSpecificTypeNames
+ * ParameterNamesDoNotHaveUnderscores IS ParameterNamesDoNotHaveUnderscores
+ParameterNamesDoNotMatchKeywords
+ParameterNamesDoNotMatchMemberNames
+ParameterNamesHaveOnlyShortAcronymsAllCaps
+ParameterNamesHaveShortAcronymsAllCaps
+ParameterNamesShouldHaveCompleteWords
+ParameterNamesShouldNotContainTypeNames
+ * PermissionNamesHavePermissionSuffix IS PermissionSuffixIsPermission
+PropertyNamesShouldNotMatchGetMethodNames
+ * StreamNamesHaveStreamSuffix IS StreamSuffixIsStream
+ * TypeNamesArePascalCased IS TypesArePascalCased
+TypeNamesDifferByMoreThanCase
+TypeNamesDoNotHaveCPrefix
+ * TypeNamesDoNotHaveUnderscores IS TypeNamesDoNotContainUnderscores
+TypeNamesDoNotMatchKeywords
+TypeNamesDoNotMatchNamespaceNames
+TypeNamesHaveOnlyShortAcronymsAllCaps
+TypeNamesHaveShortAcronymsAllCaps
+ * TypesImplementingInterfacesDoNotHaveImplSuffix IS TypesImplementingInterfacesHaveNoSuffixImpl
+
+
+Performance Rules:
+
+AvoidBuildingNonCallableCode
+AvoidBuildingUninstantiatedInternalClasses
+AvoidUnsealedAttributes
+ConsiderJaggedArrayInsteadOfMultiDimensionalArrayInFields
+ConsiderJaggedArrayInsteadOfMultiDimensionalArrayInMethods
+ConsiderJaggedArrayInsteadOfMultiDimensionalArrayInProperties
+ConsiderOverridingEqualsAndOperatorEqualsOnValueTypes
+DisposeMethodsCallSuppressFinalize
+PropertiesShouldNotReturnArrays
+TestForEmptyStringsUsingStringLength
+
+Security Rules:
+
+ArrayFieldsShouldNotBeReadOnly
+AssertRequiresDemand
+ConsiderPermitOnlyOrDenySecurityReview
+DemandsOnValueTypeConstructorsDoNotPreventInstantiation
+DemandsOnValueTypesDoNotPreventInstantiation
+EventHandlersRequireSecurity
+GetObjectDataIsSerializationFormatterSecurityPermissionAttributed
+IntPtrFieldsHavePrivateAccessLevel
+LinkDemandsOnTypesDoNotPreventAccessToTypeFields
+MembersDoNotSuppressUnmanagedCodeSecurity
+MembersThatCallLateBoundMembersRequireDeclarativeSecurity
+MethodLevelSecurityOverridesTypeLevelSecurity
+MethodsInTypesWithIntPtrFieldAndFinalizeMethodRequireGCKeepAlive
+PartiallyTrustedMethodsCallPartiallyTrustedMethodsOnly
+PartiallyTrustedTypesExtendPartiallyTrustedTypesOnly
+PInvokeMethodCallWithSuppressUnmanagedCodeSecurityAttributeRequiresSecurityCheck
+PublicTypesImplementingNonPublicInterfacesShouldBeSealed
+SerializationMagicConstructorsRequireSecurityCheck
+StaticConstructorsHavePrivateAccessLevel
+TypesAreNotPublicPInvokeMethodsAndSuppressUnmanagedCodeSecurityAttributed
+TypesDoNotSuppressUnmanagedCodeSecurity
+UnsealedPublicTypesDoNotHaveInternalVirtualMembers
+UnsecuredMembersDoNotCallMembersProtectedByLinkDemands
+VirtualMethodsAndOverridesRequireSameLinkDemands
+
+Usage Rules:
+
+AssembliesHavePermissionRequests
+AssembliesHaveValidStrongNames
+AvoidNonConstantStaticFields
+AvoidWebMethodAttributedServicedComponentMembers
+ConsiderCallingDataMembersDisposeMethod
+ConstructorsShouldNotCallBaseClassVirtualMethods
+CreateDomainIsNotCalledWithNullParameters
+DisposeMethodsCallBaseClassDispose
+DisposeMethodsRequireFinalizeMethod
+EnumerationsShouldNotBeFlagsAttributed
+EqualsOverridesRequireGetHashCodeOverride
+ExceptionsAreMarkedSerializable
+ExceptionsShouldNotBeThrownFromFilterBlocks
+FinalizeMethodsCallBaseClassFinalize
+FinalizeMethodsHaveProtectedAccessLevel
+InheritedPublicMembersDoNotChangeToPrivate
+MemberNamesShouldBeSpelledCorrectly
+MembersDifferByMoreThanReturnType
+NamespaceNamesShouldBeSpelledCorrectly
+OperatorEqualsOverridesRequireEqualsOverride
+OperatorOverloadsHaveNamedAlternativeMethods
+OperatorsHaveSymmetricalOverloads
+ParameterNamesShouldBeSpelledCorrectly
+PInvokeOnlyValidEntryPoints
+PropertiesReturningCollectionsShouldBeReadOnly
+ResourceFilesAreBuiltUsingReleaseVersions
+ResourceStringsShouldBeSpelledCorrectly
+SerializableTypesShouldHaveMagicConstructor
+TypeNamesShouldBeSpelledCorrectly
+UseParamsForVariableArguments
+ValueTypesEqualsOverridesRequireOperatorEqualsOverride
+ValueTypesWithRvaFieldsDoNotHaveNonPublicFields
+WindowsFormsApplicationsAreMarkedStaThread
+
+Globalization Rules:
+
+CultureInfoShouldBePassed
+IFormatProviderShouldBePassed
+LocaleShouldBeSetForDataTypes
+
+COM Rules:
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer.AddIn/AssemblyAnalyser.addin.xml
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer.AddIn/AssemblyAnalyser.addin.xml 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer.AddIn/AssemblyAnalyser.addin.xml 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,24 @@
+<AddIn
+ name = "Assembly Analyzer"
+ author = "Mike Krueger"
+ copyright = "GPL"
+ url = "http://www.icsharpcode.net"
+ description = "FxCop clone"
+ version = "1.0.0"
+>
+ <Runtime>
+ <Import assembly="ICSharpCode.AssemblyAnalyser.AddIn.dll"/>
+ </Runtime>
+
+ <Extension path = "/SharpDevelop/Workbench/MainMenu/View">
+ <Conditional iscombineopen="True" action="Disable">
+ <MenuItem
+ id = "AssemblyAnalyser"
+ insertafter = "ShowStartPage"
+ insertbefore = "StartPageSeparator"
+ label = "${res:XML.MainMenu.ViewMenu.AssemblyAnalyser}"
+ class = "MonoDevelop.AssemblyAnalyser.ShowAssemblyAnalyser"
+ />
+ </Conditional>
+ </Extension>
+</AddIn>
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer.AddIn/AssemblyInfo.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer.AddIn/AssemblyInfo.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer.AddIn/AssemblyInfo.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,32 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+// Information about this assembly is defined by the following
+// attributes.
+//
+// change them to the information which is associated with the assembly
+// you compile.
+
+[assembly: AssemblyTitle("")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("")]
+[assembly: AssemblyCopyright("")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// The assembly version has following format :
+//
+// Major.Minor.Build.Revision
+//
+// You can specify all values by your own or you can build default build and revision
+// numbers with the '*' character (the default):
+
+[assembly: AssemblyVersion("1.0.*")]
+
+// The following attributes specify the key for the sign of your assembly. See the
+// .NET Framework documentation for more information about signing.
+// This is not required, if you don't want signing let these attributes like they're.
+[assembly: AssemblyDelaySign(false)]
+[assembly: AssemblyKeyFile("")]
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer.AddIn/Commands.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer.AddIn/Commands.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer.AddIn/Commands.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,27 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+using System;
+using System.Reflection;
+
+using MonoDevelop.AssemblyAnalyser.Rules;
+using MonoDevelop.Core.AddIns.Codons;
+using MonoDevelop.Gui;
+
+namespace MonoDevelop.AssemblyAnalyser
+{
+ public class ShowAssemblyAnalyser : AbstractMenuCommand
+ {
+ public override void Run()
+ {
+ if (AssemblyAnalyserView.AssemblyAnalyserViewInstance == null) {
+ WorkbenchSingleton.Workbench.ShowView(new AssemblyAnalyserView());
+ } else {
+ AssemblyAnalyserView.AssemblyAnalyserViewInstance.WorkbenchWindow.SelectWindow();
+ }
+ }
+ }
+}
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer.AddIn/Gui/AssemblyAnalyserControl.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer.AddIn/Gui/AssemblyAnalyserControl.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer.AddIn/Gui/AssemblyAnalyserControl.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,173 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.IO;
+using System.Collections;
+using System.Reflection;
+using System.Windows.Forms;
+
+namespace MonoDevelop.AssemblyAnalyser
+{
+ /// <summary>
+ /// Description of AssemblyAnalyserControl.
+ /// </summary>
+ public class AssemblyAnalyserControl : System.Windows.Forms.UserControl
+ {
+ private System.Windows.Forms.Splitter splitter2;
+ private System.Windows.Forms.TabControl tabControl;
+ private MonoDevelop.AssemblyAnalyser.ResultListControl resultListControl;
+ private System.Windows.Forms.Splitter splitter;
+ private MonoDevelop.AssemblyAnalyser.AssemblyTreeControl assemblyTreeControl;
+ private System.Windows.Forms.Panel panel;
+ private System.Windows.Forms.TabPage assembliesTabPage;
+ private MonoDevelop.AssemblyAnalyser.ResultDetailsView resultDetailsView;
+
+ public AssemblyAnalyserControl()
+ {
+ //
+ // The InitializeComponent() call is required for Windows Forms designer support.
+ //
+
+ InitializeComponent();
+ resultListControl.ResultDetailsView = resultDetailsView;
+ assemblyTreeControl.ResultListControl = resultListControl;
+
+ }
+
+ public void ClearContents()
+ {
+ resultListControl.ClearContents();
+ assemblyTreeControl.ClearContents();
+ }
+
+ public void AnalyzeAssembly(AssemblyAnalyser analyser, string fileName)
+ {
+ if (File.Exists(fileName)) {
+ analyser.Analyse(fileName);
+ assemblyTreeControl.AddAssembly(fileName, analyser.Resolutions);
+ }
+ }
+
+ public void PrintAllResolutions()
+ {
+ assemblyTreeControl.PrintAllResolutions();
+ }
+
+ #region Windows Forms Designer generated code
+ /// <summary>
+ /// This method is required for Windows Forms designer support.
+ /// Do not change the method contents inside the source code editor. The Forms designer might
+ /// not be able to load this method if it was changed manually.
+ /// </summary>
+ private void InitializeComponent() {
+ this.resultDetailsView = new MonoDevelop.AssemblyAnalyser.ResultDetailsView();
+ this.assembliesTabPage = new System.Windows.Forms.TabPage();
+ this.panel = new System.Windows.Forms.Panel();
+ this.assemblyTreeControl = new MonoDevelop.AssemblyAnalyser.AssemblyTreeControl();
+ this.splitter = new System.Windows.Forms.Splitter();
+ this.resultListControl = new MonoDevelop.AssemblyAnalyser.ResultListControl();
+ this.tabControl = new System.Windows.Forms.TabControl();
+ this.splitter2 = new System.Windows.Forms.Splitter();
+ this.assembliesTabPage.SuspendLayout();
+ this.panel.SuspendLayout();
+ this.tabControl.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // resultDetailsView
+ //
+ this.resultDetailsView.Dock = System.Windows.Forms.DockStyle.Bottom;
+ this.resultDetailsView.Location = new System.Drawing.Point(0, 304);
+ this.resultDetailsView.Name = "resultDetailsView";
+ this.resultDetailsView.Size = new System.Drawing.Size(544, 200);
+ this.resultDetailsView.TabIndex = 1;
+ //
+ // assembliesTabPage
+ //
+ this.assembliesTabPage.Controls.Add(this.assemblyTreeControl);
+ this.assembliesTabPage.Location = new System.Drawing.Point(4, 22);
+ this.assembliesTabPage.Name = "assembliesTabPage";
+ this.assembliesTabPage.Size = new System.Drawing.Size(192, 478);
+ this.assembliesTabPage.TabIndex = 0;
+ this.assembliesTabPage.Text = "Assemblies";
+ //
+ // panel
+ //
+ this.panel.Controls.Add(this.resultListControl);
+ this.panel.Controls.Add(this.splitter2);
+ this.panel.Controls.Add(this.resultDetailsView);
+ this.panel.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.panel.Location = new System.Drawing.Point(204, 0);
+ this.panel.Name = "panel";
+ this.panel.Size = new System.Drawing.Size(544, 504);
+ this.panel.TabIndex = 2;
+ //
+ // assemblyTreeControl
+ //
+ this.assemblyTreeControl.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.assemblyTreeControl.Location = new System.Drawing.Point(0, 0);
+ this.assemblyTreeControl.Name = "assemblyTreeControl";
+ this.assemblyTreeControl.Size = new System.Drawing.Size(192, 478);
+ this.assemblyTreeControl.TabIndex = 0;
+ //
+ // splitter
+ //
+ this.splitter.Location = new System.Drawing.Point(200, 0);
+ this.splitter.Name = "splitter";
+ this.splitter.Size = new System.Drawing.Size(4, 504);
+ this.splitter.TabIndex = 1;
+ this.splitter.TabStop = false;
+ //
+ // resultListControl
+ //
+ this.resultListControl.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.resultListControl.Location = new System.Drawing.Point(0, 0);
+ this.resultListControl.Name = "resultListControl";
+ this.resultListControl.Size = new System.Drawing.Size(544, 300);
+ this.resultListControl.TabIndex = 3;
+ this.resultListControl.Load += new System.EventHandler(this.ResultListControlLoad);
+ //
+ // tabControl
+ //
+ this.tabControl.Controls.Add(this.assembliesTabPage);
+ this.tabControl.Dock = System.Windows.Forms.DockStyle.Left;
+ this.tabControl.Location = new System.Drawing.Point(0, 0);
+ this.tabControl.Name = "tabControl";
+ this.tabControl.SelectedIndex = 0;
+ this.tabControl.Size = new System.Drawing.Size(200, 504);
+ this.tabControl.TabIndex = 0;
+ //
+ // splitter2
+ //
+ this.splitter2.Dock = System.Windows.Forms.DockStyle.Bottom;
+ this.splitter2.Location = new System.Drawing.Point(0, 300);
+ this.splitter2.Name = "splitter2";
+ this.splitter2.Size = new System.Drawing.Size(544, 4);
+ this.splitter2.TabIndex = 2;
+ this.splitter2.TabStop = false;
+ //
+ // AssemblyAnalyserControl
+ //
+ this.Controls.Add(this.panel);
+ this.Controls.Add(this.splitter);
+ this.Controls.Add(this.tabControl);
+ this.Name = "AssemblyAnalyserControl";
+ this.Size = new System.Drawing.Size(748, 504);
+ this.assembliesTabPage.ResumeLayout(false);
+ this.panel.ResumeLayout(false);
+ this.tabControl.ResumeLayout(false);
+ this.ResumeLayout(false);
+ }
+ #endregion
+
+ void ResultListControlLoad(object sender, System.EventArgs e)
+ {
+
+ }
+
+ }
+}
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer.AddIn/Gui/AssemblyAnalyserView.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer.AddIn/Gui/AssemblyAnalyserView.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer.AddIn/Gui/AssemblyAnalyserView.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,127 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Collections;
+using System.Reflection;
+using System.Security.Policy;
+using System.Threading;
+using System.Windows.Forms;
+
+using MonoDevelop.Gui;
+using MonoDevelop.Core;
+using MonoDevelop.Services;
+using MonoDevelop.Gui.HtmlControl;
+using MonoDevelop.Core.Services;
+using MonoDevelop.Internal.Project;
+
+namespace MonoDevelop.AssemblyAnalyser
+{
+ /// <summary>
+ /// Description of AssemblyAnalyserView.
+ /// </summary>
+ public class AssemblyAnalyserView : AbstractViewContent
+ {
+ public static AssemblyAnalyserView AssemblyAnalyserViewInstance = null;
+
+ AssemblyAnalyserControl assemblyAnalyserControl;
+
+ AppDomain analyserDomain = null;
+ AssemblyAnalyser currentAnalyser = null;
+ public override Control Control {
+ get {
+ return assemblyAnalyserControl;
+ }
+ }
+ public override bool IsViewOnly {
+ get {
+ return true;
+ }
+ }
+
+ public override bool IsReadOnly {
+ get {
+ return false;
+ }
+ }
+
+ public AssemblyAnalyserView() : base("Assembly Analyser")
+ {
+ AssemblyAnalyserViewInstance = this;
+ assemblyAnalyserControl = new AssemblyAnalyserControl();
+ IProjectService projectService = (IProjectService)MonoDevelop.Core.Services.ServiceManager.Services.GetService(typeof(IProjectService));
+ projectService.StartBuild += new EventHandler(ProjectServiceStartBuild);
+ projectService.EndBuild += new EventHandler(ProjectServiceEndBuild);
+ RefreshProjectAssemblies();
+ }
+
+ public void RefreshProjectAssemblies()
+ {
+ if (currentAnalyser == null) {
+ currentAnalyser = CreateRemoteAnalyser();
+ }
+ IProjectService projectService = (IProjectService)MonoDevelop.Core.Services.ServiceManager.Services.GetService(typeof(IProjectService));
+ ArrayList projectCombineEntries = Combine.GetAllProjects(projectService.CurrentOpenCombine);
+ assemblyAnalyserControl.ClearContents();
+ foreach (ProjectCombineEntry projectEntry in projectCombineEntries) {
+ string outputAssembly = projectService.GetOutputAssemblyName(projectEntry.Project);
+ assemblyAnalyserControl.AnalyzeAssembly(currentAnalyser, outputAssembly);
+ }
+ assemblyAnalyserControl.PrintAllResolutions();
+ }
+
+ public override void Load(string fileName)
+ {
+ }
+
+ public override void Dispose()
+ {
+ DisposeAnalyser();
+
+ IProjectService projectService = (IProjectService)MonoDevelop.Core.Services.ServiceManager.Services.GetService(typeof(IProjectService));
+ projectService.StartBuild -= new EventHandler(ProjectServiceStartBuild);
+ projectService.EndBuild -= new EventHandler(ProjectServiceEndBuild);
+
+ IStatusBarService statusBarService = (IStatusBarService)MonoDevelop.Core.Services.ServiceManager.Services.GetService(typeof(IStatusBarService));
+
+ statusBarService.SetMessage("${res:MainWindow.StatusBar.ReadyMessage}");
+ AssemblyAnalyserViewInstance = null;
+ }
+
+ void DisposeAnalyser()
+ {
+ currentAnalyser = null;
+ AppDomain.Unload(analyserDomain);
+ analyserDomain = null;
+ }
+
+ void ProjectServiceStartBuild(object sender, EventArgs e)
+ {
+ assemblyAnalyserControl.ClearContents();
+ DisposeAnalyser();
+ }
+
+ void ProjectServiceEndBuild(object sender, EventArgs e)
+ {
+ assemblyAnalyserControl.Invoke(new ThreadStart(RefreshProjectAssemblies));
+ }
+
+ AssemblyAnalyser CreateRemoteAnalyser()
+ {
+ AppDomainSetup setup = new AppDomainSetup();
+ Evidence evidence = new Evidence(AppDomain.CurrentDomain.Evidence);
+ setup.ApplicationName = "Analyser";
+ setup.ApplicationBase = Application.StartupPath;
+
+ analyserDomain = AppDomain.CreateDomain("AnalyserDomain", evidence, setup);
+ return (AssemblyAnalyser)analyserDomain.CreateInstanceAndUnwrap(
+ typeof(AssemblyAnalyser).Assembly.FullName,
+ typeof(AssemblyAnalyser).FullName,
+ false, BindingFlags.Default,null,null,null,null,null);
+ }
+ }
+}
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer.AddIn/Gui/Panels/AssemblyRuleViewControl.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer.AddIn/Gui/Panels/AssemblyRuleViewControl.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer.AddIn/Gui/Panels/AssemblyRuleViewControl.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,59 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Drawing;
+using System.Windows.Forms;
+
+namespace MonoDevelop.AssemblyAnalyser
+{
+ /// <summary>
+ /// Description of AssemblyRuleViewControl.
+ /// </summary>
+ [ToolboxBitmap(typeof(System.Windows.Forms.TreeView))]
+ public class AssemblyRuleViewControl : System.Windows.Forms.UserControl
+ {
+ private System.Windows.Forms.TreeView ruleTreeView;
+ public AssemblyRuleViewControl()
+ {
+ //
+ // The InitializeComponent() call is required for Windows Forms designer support.
+ //
+ InitializeComponent();
+
+ }
+
+ #region Windows Forms Designer generated code
+ /// <summary>
+ /// This method is required for Windows Forms designer support.
+ /// Do not change the method contents inside the source code editor. The Forms designer might
+ /// not be able to load this method if it was changed manually.
+ /// </summary>
+ private void InitializeComponent() {
+ this.ruleTreeView = new System.Windows.Forms.TreeView();
+ this.SuspendLayout();
+ //
+ // ruleTreeView
+ //
+ this.ruleTreeView.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.ruleTreeView.ImageIndex = -1;
+ this.ruleTreeView.Location = new System.Drawing.Point(0, 0);
+ this.ruleTreeView.Name = "ruleTreeView";
+ this.ruleTreeView.SelectedImageIndex = -1;
+ this.ruleTreeView.Size = new System.Drawing.Size(292, 266);
+ this.ruleTreeView.TabIndex = 0;
+ //
+ // AssemblyRuleViewControl
+ //
+ this.Controls.Add(this.ruleTreeView);
+ this.Name = "AssemblyRuleViewControl";
+ this.Size = new System.Drawing.Size(292, 266);
+ this.ResumeLayout(false);
+ }
+ #endregion
+ }
+}
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer.AddIn/Gui/Panels/AssemblyTreeControl.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer.AddIn/Gui/Panels/AssemblyTreeControl.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer.AddIn/Gui/Panels/AssemblyTreeControl.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,132 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Collections;
+using System.IO;
+using System.Drawing;
+using System.Reflection;
+using System.Windows.Forms;
+using MonoDevelop.Core.Services;
+using MonoDevelop.Services;
+namespace MonoDevelop.AssemblyAnalyser
+{
+ /// <summary>
+ /// Description of AssemblyTreeControl.
+ /// </summary>
+ [ToolboxBitmap(typeof(System.Windows.Forms.TreeView))]
+ public class AssemblyTreeControl : System.Windows.Forms.UserControl
+ {
+ private System.Windows.Forms.TreeView assemblyTreeView;
+ TreeNode assembliesNode;
+ ResultListControl resultListControl;
+
+ public ResultListControl ResultListControl {
+ get {
+ return resultListControl;
+ }
+ set {
+ resultListControl = value;
+ }
+ }
+
+ public AssemblyTreeControl()
+ {
+ //
+ // The InitializeComponent() call is required for Windows Forms designer support.
+ //
+ InitializeComponent();
+ StringParserService stringParserService = (StringParserService)ServiceManager.Services.GetService(typeof(StringParserService));
+ ClassBrowserIconsService classBrowserIconService = (ClassBrowserIconsService)ServiceManager.Services.GetService(typeof(ClassBrowserIconsService));
+ assemblyTreeView.ImageList = classBrowserIconService.ImageList;
+
+ assembliesNode = new TreeNode(stringParserService.Parse("${res:MonoDevelop.AssemblyAnalyser.AssemblyTreeControl.AssembliesNode}"));
+ assembliesNode.ImageIndex = assembliesNode.SelectedImageIndex = 0;
+ assemblyTreeView.Nodes.Add(assembliesNode);
+ assemblyTreeView.AfterCollapse += new TreeViewEventHandler(AssemblyTreeViewAfterCollapse);
+ assemblyTreeView.AfterExpand += new TreeViewEventHandler(AssemblyTreeViewAfterExpand);
+ assemblyTreeView.AfterSelect += new TreeViewEventHandler(AssemblyTreeViewAfterSelect);
+ }
+
+ void AssemblyTreeViewAfterCollapse(object sender, TreeViewEventArgs e)
+ {
+ if (e.Node == assembliesNode) {
+ assembliesNode.ImageIndex = assembliesNode.SelectedImageIndex = 0;
+ }
+ }
+
+ void AssemblyTreeViewAfterExpand(object sender, TreeViewEventArgs e)
+ {
+ if (e.Node == assembliesNode) {
+ assembliesNode.ImageIndex = assembliesNode.SelectedImageIndex = 1;
+ }
+ }
+
+ void AssemblyTreeViewAfterSelect(object sender, TreeViewEventArgs e)
+ {
+ if (e.Node.Tag == null) {
+ PrintAllResolutions();
+ } else {
+ this.resultListControl.PrintReport((ArrayList)e.Node.Tag);
+ }
+ }
+
+ public void PrintAllResolutions()
+ {
+ ArrayList allResolutions = new ArrayList();
+ foreach (TreeNode node in assembliesNode.Nodes) {
+ allResolutions.AddRange((ArrayList)node.Tag);
+ }
+ this.resultListControl.PrintReport(allResolutions);
+ }
+
+ public void ClearContents()
+ {
+ Console.WriteLine("CLEAR CONTENTS");
+ assembliesNode.Nodes.Clear();
+ }
+
+ public void AddAssembly(string assemblyFileName, ArrayList resolutions)
+ {
+ TreeNode newNode = new TreeNode(Path.GetFileName(assemblyFileName));
+ newNode.Tag = resolutions;
+ newNode.ImageIndex = newNode.SelectedImageIndex = 2;
+ assembliesNode.Nodes.Add(newNode);
+ assembliesNode.Expand();
+ }
+
+ #region Windows Forms Designer generated code
+ /// <summary>
+ /// This method is required for Windows Forms designer support.
+ /// Do not change the method contents inside the source code editor. The Forms designer might
+ /// not be able to load this method if it was changed manually.
+ /// </summary>
+ private void InitializeComponent() {
+ this.assemblyTreeView = new System.Windows.Forms.TreeView();
+ this.SuspendLayout();
+ //
+ // assemblyTreeView
+ //
+ this.assemblyTreeView.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.assemblyTreeView.HideSelection = false;
+ this.assemblyTreeView.ImageIndex = -1;
+ this.assemblyTreeView.Location = new System.Drawing.Point(0, 0);
+ this.assemblyTreeView.Name = "assemblyTreeView";
+ this.assemblyTreeView.SelectedImageIndex = -1;
+ this.assemblyTreeView.Size = new System.Drawing.Size(292, 266);
+ this.assemblyTreeView.TabIndex = 0;
+ //
+ // AssemblyTreeControl
+ //
+ this.Controls.Add(this.assemblyTreeView);
+ this.Name = "AssemblyTreeControl";
+ this.Size = new System.Drawing.Size(292, 266);
+ this.ResumeLayout(false);
+ }
+ #endregion
+ }
+}
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer.AddIn/Gui/Panels/ResultDetailsView.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer.AddIn/Gui/Panels/ResultDetailsView.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer.AddIn/Gui/Panels/ResultDetailsView.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,119 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.IO;
+using System.Drawing;
+using System.Windows.Forms;
+
+using MonoDevelop.Gui;
+using MonoDevelop.Core;
+using MonoDevelop.Services;
+using MonoDevelop.BrowserDisplayBinding;
+using MonoDevelop.Gui.HtmlControl;
+using MonoDevelop.Core.Services;
+using MonoDevelop.AssemblyAnalyser.Rules;
+using MonoDevelop.Gui.Pads;
+
+namespace MonoDevelop.AssemblyAnalyser
+{
+ /// <summary>
+ /// Description of ResultDetailsView.
+ /// </summary>
+ [ToolboxBitmap(typeof(System.Windows.Forms.RichTextBox))]
+ public class ResultDetailsView : System.Windows.Forms.UserControl
+ {
+ HtmlControl htmlControl;
+ Resolution currentResolution;
+ public ResultDetailsView()
+ {
+ //
+ // The InitializeComponent() call is required for Windows Forms designer support.
+ //
+ InitializeComponent();
+
+ htmlControl = new HtmlControl();
+ htmlControl.Dock = DockStyle.Fill;
+ PropertyService propertyService = (PropertyService)ServiceManager.Services.GetService(typeof(PropertyService));
+ htmlControl.CascadingStyleSheet = propertyService.DataDirectory + Path.DirectorySeparatorChar +
+ "resources" + Path.DirectorySeparatorChar +
+ "css" + Path.DirectorySeparatorChar +
+ "MsdnHelp.css";
+
+ ClearContents();
+ htmlControl.BeforeNavigate += new BrowserNavigateEventHandler(HtmlControlBeforeNavigate);
+ this.Controls.Add(htmlControl);
+ }
+
+ void HtmlControlBeforeNavigate(object sender, BrowserNavigateEventArgs e)
+ {
+ e.Cancel = true;
+ Console.WriteLine(" >{0}< ", e.Url);
+ if (e.Url.StartsWith("help://types/")) {
+ string typeName = e.Url.Substring("help://types/".Length);
+ HelpBrowser helpBrowser = (HelpBrowser)WorkbenchSingleton.Workbench.GetPad(typeof(HelpBrowser));
+ helpBrowser.ShowHelpFromType(typeName);
+ } else if (e.Url.StartsWith("help://gotocause")) {
+ GotoCurrentCause();
+ }
+ }
+
+ public void ClearContents()
+ {
+ htmlControl.Html = "<HTML><BODY></BODY></HTML>";
+ }
+
+ void GotoCurrentCause()
+ {
+ IParserService parserService = (IParserService)MonoDevelop.Core.Services.ServiceManager.Services.GetService(typeof(IParserService));
+ Position position = parserService.GetPosition(currentResolution.Item.Replace('+', '.'));
+
+ if (position != null && position.Cu != null) {
+ IFileService fileService = (IFileService)MonoDevelop.Core.Services.ServiceManager.Services.GetService(typeof(IFileService));
+ fileService.JumpToFilePosition(position.Cu.FileName, Math.Max(0, position.Line - 1), Math.Max(0, position.Column - 1));
+ }
+ }
+
+ bool CanGoto(Resolution res)
+ {
+ IParserService parserService = (IParserService)MonoDevelop.Core.Services.ServiceManager.Services.GetService(typeof(IParserService));
+ Position position = parserService.GetPosition(res.Item.Replace('+', '.'));
+ return position != null && position.Cu != null;
+ }
+
+ public void ViewResolution(Resolution resolution)
+ {
+ this.currentResolution = resolution;
+ StringParserService stringParserService = (StringParserService)ServiceManager.Services.GetService(typeof(StringParserService));
+
+ htmlControl.Html = @"<HTML><BODY ID='bodyID' CLASS='dtBODY'>
+ <DIV ID='nstext'>
+ <DL>" + stringParserService.Parse(resolution.FailedRule.Description) + @"</DL>
+ <H4 CLASS='dtH4'>" + stringParserService.Parse("${res:MonoDevelop.AssemblyAnalyser.ResultDetailsView.DescriptionLabel}") + @"</H4>
+ <DL>" + stringParserService.Parse(resolution.FailedRule.Details) + @"</DL>
+ <H4 CLASS='dtH4'>" + stringParserService.Parse("${res:MonoDevelop.AssemblyAnalyser.ResultDetailsView.ResolutionLabel}") + @"</H4>
+ <DL>" + stringParserService.Parse(resolution.Text, resolution.Variables) + @"</DL>
+ " + (CanGoto(resolution) ? stringParserService.Parse("<A HREF=\"help://gotocause\">${res:MonoDevelop.AssemblyAnalyser.ResultDetailsView.JumpToSourceCodeLink}</A>") : "") + @"
+ </DIV></BODY></HTML>";
+ }
+
+ #region Windows Forms Designer generated code
+ /// <summary>
+ /// This method is required for Windows Forms designer support.
+ /// Do not change the method contents inside the source code editor. The Forms designer might
+ /// not be able to load this method if it was changed manually.
+ /// </summary>
+ private void InitializeComponent() {
+ //
+ // ResultDetailsView
+ //
+ this.Name = "ResultDetailsView";
+ this.Size = new System.Drawing.Size(292, 266);
+ }
+ #endregion
+ }
+}
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer.AddIn/Gui/Panels/ResultListControl.cs
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer.AddIn/Gui/Panels/ResultListControl.cs 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer.AddIn/Gui/Panels/ResultListControl.cs 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,228 @@
+// <file>
+// <copyright see="prj:///doc/copyright.txt"/>
+// <license see="prj:///doc/license.txt"/>
+// <owner name="Mike Krueger" email="mike at icsharpcode.net"/>
+// <version value="$version"/>
+// </file>
+
+using System;
+using System.Collections;
+using System.Drawing;
+using System.Windows.Forms;
+
+using MonoDevelop.Core.Services;
+using MonoDevelop.AssemblyAnalyser.Rules;
+using MonoDevelop.Services;
+
+namespace MonoDevelop.AssemblyAnalyser
+{
+ /// <summary>
+ /// Description of ResultListControl.
+ /// </summary>
+ [ToolboxBitmap(typeof(System.Windows.Forms.ListView))]
+ public class ResultListControl : System.Windows.Forms.UserControl
+ {
+ private System.Windows.Forms.ListView listView;
+ private System.Windows.Forms.ColumnHeader criticalHeader;
+ private System.Windows.Forms.ColumnHeader itemHeader;
+ private System.Windows.Forms.ColumnHeader ruleHeader;
+ private System.Windows.Forms.ColumnHeader certaintyHeader;
+ private System.Windows.Forms.ColumnHeader levelHeader;
+
+ ResultDetailsView resultDetailsView = null;
+
+ public ResultDetailsView ResultDetailsView {
+ get {
+ return resultDetailsView;
+ }
+ set {
+ resultDetailsView = value;
+ }
+ }
+
+ public ResultListControl()
+ {
+ //
+ // The InitializeComponent() call is required for Windows Forms designer support.
+ //
+ InitializeComponent();
+
+ StringParserService stringParserService = (StringParserService)ServiceManager.Services.GetService(typeof(StringParserService));
+ levelHeader.Text = stringParserService.Parse("${res:MonoDevelop.AssemblyAnalyser.ResultListControl.LevelHeader}");
+ certaintyHeader.Text = stringParserService.Parse("${res:MonoDevelop.AssemblyAnalyser.ResultListControl.CertaintyHeader}");
+ ruleHeader.Text = stringParserService.Parse("${res:MonoDevelop.AssemblyAnalyser.ResultListControl.RuleHeader}");
+ itemHeader.Text = stringParserService.Parse("${res:MonoDevelop.AssemblyAnalyser.ResultListControl.ItemHeader}");
+ }
+
+ public void ClearContents()
+ {
+ this.listView.SelectedIndexChanged -= new System.EventHandler(this.ListViewSelectedIndexChanged);
+ listView.Items.Clear();
+ this.listView.SelectedIndexChanged += new System.EventHandler(this.ListViewSelectedIndexChanged);
+ }
+
+ public void PrintReport(ArrayList resolutions)
+ {
+ try {
+ listView.BeginUpdate();
+ listView.Items.Clear();
+ StringParserService stringParserService = (StringParserService)ServiceManager.Services.GetService(typeof(StringParserService));
+ int cerr = 0, err = 0, cwar = 0, war = 0, inf = 0;
+ foreach (Resolution resolution in resolutions) {
+ string critical = String.Empty;
+ string type = String.Empty;
+ Color foreColor = Color.Black;
+
+ switch (resolution.FailedRule.PriorityLevel) {
+ case PriorityLevel.CriticalError:
+ critical = "!";
+ type = stringParserService.Parse("${res:MonoDevelop.AssemblyAnalyser.ResultListControl.ErrorType}");
+ foreColor = Color.Red;
+ ++cerr;
+ break;
+ case PriorityLevel.Error:
+ type = stringParserService.Parse("${res:MonoDevelop.AssemblyAnalyser.ResultListControl.ErrorType}");
+ foreColor = Color.DarkRed;
+ ++err;
+ break;
+ case PriorityLevel.CriticalWarning:
+ critical = "!";
+ type = stringParserService.Parse("${res:MonoDevelop.AssemblyAnalyser.ResultListControl.WarningType}");
+ foreColor = Color.Blue;
+ ++cwar;
+ break;
+ case PriorityLevel.Warning:
+ type = stringParserService.Parse("${res:MonoDevelop.AssemblyAnalyser.ResultListControl.WarningType}");
+ foreColor = Color.DarkBlue;
+ ++war;
+ break;
+ case PriorityLevel.Information:
+ type = stringParserService.Parse("${res:MonoDevelop.AssemblyAnalyser.ResultListControl.InformationType}");
+ ++inf;
+ break;
+ }
+ string certainity = resolution.FailedRule.Certainty.ToString() + "%";
+ string text = stringParserService.Parse(resolution.FailedRule.Description);
+ string item = stringParserService.Parse(resolution.Item);
+ ListViewItem listViewItem = new ListViewItem(new string[] {critical, type, certainity, text, item});
+ listViewItem.Font = new Font("Arial", 9, FontStyle.Bold);
+ listViewItem.ForeColor = foreColor;
+ listViewItem.Tag = resolution;
+ listView.Items.Add(listViewItem);
+
+ }
+ IStatusBarService statusBarService = (IStatusBarService)MonoDevelop.Core.Services.ServiceManager.Services.GetService(typeof(IStatusBarService));
+ if (resolutions.Count == 0) {
+ statusBarService.SetMessage("${res:MonoDevelop.AssemblyAnalyser.ResultListControl.NoDefectsFoundStatusBarMessage}");
+ } else {
+ statusBarService.SetMessage(stringParserService.Parse("${res:MonoDevelop.AssemblyAnalyser.ResultListControl.TotalDefectsStatusBarMessage}",
+ new string[,] {
+ {"TotalDefects", resolutions.Count.ToString()},
+ {"CriticalErrors", cerr.ToString()},
+ {"Errors",err.ToString()},
+ {"CriticalWarnings", cwar.ToString()},
+ {"Warnings", war.ToString()},
+ {"Informations", inf.ToString()}
+ }));
+ }
+ } catch (Exception e) {
+ Console.WriteLine("Got exception : " + e.ToString());
+ } finally {
+ listView.EndUpdate();
+ }
+ }
+
+ #region Windows Forms Designer generated code
+ /// <summary>
+ /// This method is required for Windows Forms designer support.
+ /// Do not change the method contents inside the source code editor. The Forms designer might
+ /// not be able to load this method if it was changed manually.
+ /// </summary>
+ private void InitializeComponent() {
+ this.levelHeader = new System.Windows.Forms.ColumnHeader();
+ this.certaintyHeader = new System.Windows.Forms.ColumnHeader();
+ this.ruleHeader = new System.Windows.Forms.ColumnHeader();
+ this.itemHeader = new System.Windows.Forms.ColumnHeader();
+ this.criticalHeader = new System.Windows.Forms.ColumnHeader();
+ this.listView = new System.Windows.Forms.ListView();
+ this.SuspendLayout();
+ //
+ // levelHeader
+ //
+ this.levelHeader.Text = "Level";
+ this.levelHeader.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
+ //
+ // certaintyHeader
+ //
+ this.certaintyHeader.Text = "Certainty";
+ this.certaintyHeader.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+ //
+ // ruleHeader
+ //
+ this.ruleHeader.Text = "Rule";
+ this.ruleHeader.Width = 350;
+ //
+ // itemHeader
+ //
+ this.itemHeader.Text = "Item";
+ this.itemHeader.Width = 200;
+ //
+ // criticalHeader
+ //
+ this.criticalHeader.Text = "!";
+ this.criticalHeader.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
+ this.criticalHeader.Width = 20;
+ //
+ // listView
+ //
+ this.listView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
+ this.criticalHeader,
+ this.levelHeader,
+ this.certaintyHeader,
+ this.ruleHeader,
+ this.itemHeader});
+ this.listView.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.listView.FullRowSelect = true;
+ this.listView.HideSelection = false;
+ this.listView.Location = new System.Drawing.Point(0, 0);
+ this.listView.MultiSelect = false;
+ this.listView.Name = "listView";
+ this.listView.Size = new System.Drawing.Size(572, 396);
+ this.listView.TabIndex = 3;
+ this.listView.View = System.Windows.Forms.View.Details;
+ this.listView.ItemActivate += new System.EventHandler(this.ListViewItemActivate);
+ this.listView.SelectedIndexChanged += new System.EventHandler(this.ListViewSelectedIndexChanged);
+ //
+ // ResultListControl
+ //
+ this.Controls.Add(this.listView);
+ this.Name = "ResultListControl";
+ this.Size = new System.Drawing.Size(572, 396);
+ this.ResumeLayout(false);
+ }
+ #endregion
+ void ListViewSelectedIndexChanged(object sender, System.EventArgs e)
+ {
+ if (resultDetailsView != null && listView.SelectedItems.Count > 0) {
+ resultDetailsView.ViewResolution((Resolution)listView.SelectedItems[0].Tag);
+ }
+ listView.Focus();
+ }
+ void ListViewItemActivate(object sender, System.EventArgs e)
+ {
+ ListViewItem item = listView.SelectedItems[0];
+ if (item != null && item.Tag != null) {
+ Resolution res = (Resolution)item.Tag;
+ IParserService parserService = (IParserService)MonoDevelop.Core.Services.ServiceManager.Services.GetService(typeof(IParserService));
+ Position position = parserService.GetPosition(res.Item.Replace('+', '.'));
+
+ if (position != null && position.Cu != null) {
+ IFileService fileService = (IFileService)MonoDevelop.Core.Services.ServiceManager.Services.GetService(typeof(IFileService));
+ Console.WriteLine("File name : " + position.Cu.FileName);
+ fileService.JumpToFilePosition(position.Cu.FileName, Math.Max(0, position.Line - 1), Math.Max(0, position.Column - 1));
+ }
+ }
+ }
+
+ }
+}
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer.AddIn/ICSharpCode.AssemblyAnalyser.Addin.prjx
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer.AddIn/ICSharpCode.AssemblyAnalyser.Addin.prjx 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer.AddIn/ICSharpCode.AssemblyAnalyser.Addin.prjx 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,41 @@
+<Project name="ICSharpCode.AssemblyAnalyser.AddIn" standardNamespace="ICSharpCode.AssemblyAnalyser" description="" newfilesearch="None" enableviewstate="True" version="1.1" projecttype="C#">
+ <Contents>
+ <File name=".\Commands.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\AssemblyInfo.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Gui" subtype="Directory" buildaction="Compile" dependson="" data="" />
+ <File name=".\Gui\AssemblyAnalyserView.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Gui\AssemblyAnalyserControl.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Gui\Panels\AssemblyTreeControl.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Gui\Panels\AssemblyRuleViewControl.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Gui\Panels" subtype="Directory" buildaction="Compile" dependson="" data="" />
+ <File name=".\Gui\Panels\ResultListControl.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\Gui\Panels\ResultDetailsView.cs" subtype="Code" buildaction="Compile" dependson="" data="" />
+ <File name=".\AssemblyAnalyser.addin" subtype="Code" buildaction="Nothing" dependson="" data="" />
+ <File name=".\ICSharpCode.AssemblyAnalyser.AssemblyAnalyserControl.resources" subtype="Code" buildaction="EmbedAsResource" dependson="" data="" />
+ <File name=".\ICSharpCode.AssemblyAnalyser.ResultListControl.resources" subtype="Code" buildaction="EmbedAsResource" dependson="" data="" />
+ </Contents>
+ <References>
+ <Reference type="Assembly" refto="..\..\..\..\..\bin\ICSharpCode.Core.dll" localcopy="False" />
+ <Reference type="Assembly" refto="..\..\..\..\..\bin\SharpDevelop.Base.dll" localcopy="False" />
+ <Reference type="Gac" refto="nunit.framework, Version=2.1.4.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77" localcopy="False" />
+ <Reference type="Project" refto="ICSharpCode.AssemblyAnalyser" localcopy="False" />
+ </References>
+ <DeploymentInformation target="" script="" strategy="File" />
+ <Configuration runwithwarnings="True" name="Debug">
+ <CodeGeneration runtime="MsNet" compiler="Csc" compilerversion="" warninglevel="4" nowarn="" includedebuginformation="True" optimize="False" unsafecodeallowed="False" generateoverflowchecks="True" mainclass="" target="Library" definesymbols="TEST" generatexmldocumentation="False" win32Icon="" />
+ <Execution commandlineparameters="" consolepause="True" />
+ <Output directory="..\..\..\..\..\AddIns\AddIns\Misc\AssemblyAnalyser" assembly="ICSharpCode.AssemblyAnalyser.Addin" executeScript="..\..\..\..\..\bin\SharpDevelop.exe" executeBeforeBuild="" executeAfterBuild="" />
+ </Configuration>
+ <Configurations active="Debug">
+ <Configuration runwithwarnings="True" name="Debug">
+ <CodeGeneration runtime="MsNet" compiler="Csc" compilerversion="" warninglevel="4" nowarn="" includedebuginformation="True" optimize="False" unsafecodeallowed="False" generateoverflowchecks="True" mainclass="" target="Library" definesymbols="TEST" generatexmldocumentation="False" win32Icon="" />
+ <Execution commandlineparameters="" consolepause="True" />
+ <Output directory="..\..\..\..\..\AddIns\AddIns\Misc\AssemblyAnalyser" assembly="ICSharpCode.AssemblyAnalyser.Addin" executeScript="..\..\..\..\..\bin\SharpDevelop.exe" executeBeforeBuild="" executeAfterBuild="" />
+ </Configuration>
+ <Configuration runwithwarnings="False" name="Release">
+ <CodeGeneration runtime="MsNet" compiler="Csc" compilerversion="" warninglevel="4" nowarn="" includedebuginformation="False" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" mainclass="" target="Library" definesymbols="" generatexmldocumentation="False" win32Icon="" />
+ <Execution commandlineparameters="" consolepause="True" />
+ <Output directory="..\..\..\..\..\AddIns\AddIns\Misc\AssemblyAnalyser" assembly="ICSharpCode.AssemblyAnalyser.Addin" executeScript="..\..\..\..\..\bin\SharpDevelop.exe" executeBeforeBuild="" executeAfterBuild="" />
+ </Configuration>
+ </Configurations>
+</Project>
\ No newline at end of file
Added: trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer.AddIn/Makefile
===================================================================
--- trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer.AddIn/Makefile 2004-06-10 22:23:41 UTC (rev 1734)
+++ trunk/MonoDevelop/src/AddIns/Misc/AssemblyAnalyser/ICSharpCode.AssemblyAnalyzer.AddIn/Makefile 2004-06-11 02:19:09 UTC (rev 1735)
@@ -0,0 +1,22 @@
+
+ASSEMBLY = ICSharpCode.AssemblyAnalyzer.Addin.dll
+CSC = mcs /debug
+
+REFS = \
+ /r:../../../../../build/bin/MonoDevelop.Core.dll \
+ /r:../../../../../build/bin/MonoDevelop.Base.dll
+
+FILES = \
+./Gui/AssemblyAnalyserControl.cs \
+./Gui/AssemblyAnalyserView.cs \
+./Gui/Panels/ResultListControl.cs \
+./Gui/Panels/AssemblyRuleViewControl.cs \
+./Gui/Panels/AssemblyTreeControl.cs \
+./Gui/Panels/ResultDetailsView.cs \
+./Commands.cs \
+./AssemblyInfo.cs
+
+all: $(ASSEMBLY)
+
+$(ASSEMBLY): $(FILES)
+ $(CSC) /out:$(ASSEMBLY) /target:library $(FILES) $(REFS)
More information about the Monodevelop-patches-list
mailing list