From 7236a72de4fe5d73368afa61b423c3510aae6f26 Mon Sep 17 00:00:00 2001 From: youssefm Date: Mon, 27 Aug 2012 17:39:25 -0700 Subject: [PATCH] Enabling StyleCop rule for one class per file in source code --- Settings.StyleCop | 5 -- src/Common/TaskHelpersExtensions.cs | 3 ++ .../Microsoft.Web.Http.Data.csproj | 1 + ...ertyConventionOfTPropertyConfiguration.cs} | 49 ----------------- ...onOfTPropertyConfigurationAndTAttribute.cs | 53 +++++++++++++++++++ .../System.Web.Http.OData.csproj | 3 +- test/Settings.StyleCop | 5 ++ 7 files changed, 64 insertions(+), 55 deletions(-) rename src/System.Web.Http.OData/OData/Builder/Conventions/Attributes/{AttributeEdmPropertyConvention.cs => AttributeEdmPropertyConventionOfTPropertyConfiguration.cs} (57%) create mode 100644 src/System.Web.Http.OData/OData/Builder/Conventions/Attributes/AttributeEdmPropertyConventionOfTPropertyConfigurationAndTAttribute.cs diff --git a/Settings.StyleCop b/Settings.StyleCop index 585ed4c2..621fac48 100644 --- a/Settings.StyleCop +++ b/Settings.StyleCop @@ -334,11 +334,6 @@ False - - - False - - False diff --git a/src/Common/TaskHelpersExtensions.cs b/src/Common/TaskHelpersExtensions.cs index 49754cc0..c231d924 100644 --- a/src/Common/TaskHelpersExtensions.cs +++ b/src/Common/TaskHelpersExtensions.cs @@ -827,6 +827,7 @@ namespace System.Threading.Tasks } } + [SuppressMessage("Microsoft.StyleCop.CSharp.MaintainabilityRules", "SA1402:FileMayOnlyContainASingleClass", Justification = "Packaged as one file to make it easy to link against")] internal abstract class CatchInfoBase where TTask : Task { @@ -868,6 +869,7 @@ namespace System.Threading.Tasks } } + [SuppressMessage("Microsoft.StyleCop.CSharp.MaintainabilityRules", "SA1402:FileMayOnlyContainASingleClass", Justification = "Packaged as one file to make it easy to link against")] internal class CatchInfo : CatchInfoBase { private static CatchResult _completed = new CatchResult { Task = TaskHelpers.Completed() }; @@ -907,6 +909,7 @@ namespace System.Threading.Tasks } } + [SuppressMessage("Microsoft.StyleCop.CSharp.MaintainabilityRules", "SA1402:FileMayOnlyContainASingleClass", Justification = "Packaged as one file to make it easy to link against")] internal class CatchInfo : CatchInfoBase> { public CatchInfo(Task task) diff --git a/src/Microsoft.Web.Http.Data/Microsoft.Web.Http.Data.csproj b/src/Microsoft.Web.Http.Data/Microsoft.Web.Http.Data.csproj index 8ce55646..e4bba2be 100644 --- a/src/Microsoft.Web.Http.Data/Microsoft.Web.Http.Data.csproj +++ b/src/Microsoft.Web.Http.Data/Microsoft.Web.Http.Data.csproj @@ -18,6 +18,7 @@ true ..\..\ true + false true diff --git a/src/System.Web.Http.OData/OData/Builder/Conventions/Attributes/AttributeEdmPropertyConvention.cs b/src/System.Web.Http.OData/OData/Builder/Conventions/Attributes/AttributeEdmPropertyConventionOfTPropertyConfiguration.cs similarity index 57% rename from src/System.Web.Http.OData/OData/Builder/Conventions/Attributes/AttributeEdmPropertyConvention.cs rename to src/System.Web.Http.OData/OData/Builder/Conventions/Attributes/AttributeEdmPropertyConventionOfTPropertyConfiguration.cs index 86c7ff91..d5a81c40 100644 --- a/src/System.Web.Http.OData/OData/Builder/Conventions/Attributes/AttributeEdmPropertyConvention.cs +++ b/src/System.Web.Http.OData/OData/Builder/Conventions/Attributes/AttributeEdmPropertyConventionOfTPropertyConfiguration.cs @@ -69,53 +69,4 @@ namespace System.Web.Http.OData.Builder.Conventions.Attributes /// The attribute to be used during configuration. public abstract void Apply(TPropertyConfiguration edmProperty, IStructuralTypeConfiguration structuralTypeConfiguration, Attribute attribute); } - - /// - /// Base class for all attribute based 's. - /// - /// The type of the property this configuration applies to. - /// The type of the attribute this convention looks for. - public abstract class AttributeEdmPropertyConvention : AttributeEdmPropertyConvention - where TPropertyConfiguration : PropertyConfiguration - where TAttribute : Attribute - { - protected AttributeEdmPropertyConvention(bool allowMultiple) - : base((attribute) => typeof(TAttribute) == attribute.GetType(), allowMultiple) - { - } - - /// - /// Applies the convention. - /// - /// The property being configured. - /// The type being configured. - /// The attribute to be used during configuration. - public override void Apply(TPropertyConfiguration edmProperty, IStructuralTypeConfiguration structuralTypeConfiguration, Attribute attribute) - { - if (edmProperty == null) - { - throw Error.ArgumentNull("edmProperty"); - } - - if (structuralTypeConfiguration == null) - { - throw Error.ArgumentNull("structuralTypeConfiguration"); - } - - if (attribute == null) - { - throw Error.ArgumentNull("attribute"); - } - - Apply(edmProperty, structuralTypeConfiguration, attribute as TAttribute); - } - - /// - /// Applies the convention. - /// - /// The property being configured. - /// The type being configured. - /// The attribute to be used during configuration. - public abstract void Apply(TPropertyConfiguration edmProperty, IStructuralTypeConfiguration structuralTypeConfiguration, TAttribute attribute); - } } \ No newline at end of file diff --git a/src/System.Web.Http.OData/OData/Builder/Conventions/Attributes/AttributeEdmPropertyConventionOfTPropertyConfigurationAndTAttribute.cs b/src/System.Web.Http.OData/OData/Builder/Conventions/Attributes/AttributeEdmPropertyConventionOfTPropertyConfigurationAndTAttribute.cs new file mode 100644 index 00000000..c659fcbd --- /dev/null +++ b/src/System.Web.Http.OData/OData/Builder/Conventions/Attributes/AttributeEdmPropertyConventionOfTPropertyConfigurationAndTAttribute.cs @@ -0,0 +1,53 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information. + +namespace System.Web.Http.OData.Builder.Conventions.Attributes +{ + /// + /// Base class for all attribute based 's. + /// + /// The type of the property this configuration applies to. + /// The type of the attribute this convention looks for. + public abstract class AttributeEdmPropertyConvention : AttributeEdmPropertyConvention + where TPropertyConfiguration : PropertyConfiguration + where TAttribute : Attribute + { + protected AttributeEdmPropertyConvention(bool allowMultiple) + : base((attribute) => typeof(TAttribute) == attribute.GetType(), allowMultiple) + { + } + + /// + /// Applies the convention. + /// + /// The property being configured. + /// The type being configured. + /// The attribute to be used during configuration. + public override void Apply(TPropertyConfiguration edmProperty, IStructuralTypeConfiguration structuralTypeConfiguration, Attribute attribute) + { + if (edmProperty == null) + { + throw Error.ArgumentNull("edmProperty"); + } + + if (structuralTypeConfiguration == null) + { + throw Error.ArgumentNull("structuralTypeConfiguration"); + } + + if (attribute == null) + { + throw Error.ArgumentNull("attribute"); + } + + Apply(edmProperty, structuralTypeConfiguration, attribute as TAttribute); + } + + /// + /// Applies the convention. + /// + /// The property being configured. + /// The type being configured. + /// The attribute to be used during configuration. + public abstract void Apply(TPropertyConfiguration edmProperty, IStructuralTypeConfiguration structuralTypeConfiguration, TAttribute attribute); + } +} \ No newline at end of file diff --git a/src/System.Web.Http.OData/System.Web.Http.OData.csproj b/src/System.Web.Http.OData/System.Web.Http.OData.csproj index ac01d5a3..de82ce2c 100644 --- a/src/System.Web.Http.OData/System.Web.Http.OData.csproj +++ b/src/System.Web.Http.OData/System.Web.Http.OData.csproj @@ -107,7 +107,8 @@ - + + diff --git a/test/Settings.StyleCop b/test/Settings.StyleCop index 0b82cccc..8b3833e4 100644 --- a/test/Settings.StyleCop +++ b/test/Settings.StyleCop @@ -65,6 +65,11 @@ False + + + False + + False