Permalink
Browse files

Enabling StyleCop rule for one class per file in source code

  • Loading branch information...
1 parent ea22906 commit 7236a72de4fe5d73368afa61b423c3510aae6f26 youssefm committed Aug 28, 2012
View
5 Settings.StyleCop
@@ -334,11 +334,6 @@
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
- <Rule Name="FileMayOnlyContainASingleClass">
- <RuleSettings>
- <BooleanProperty Name="Enabled">False</BooleanProperty>
- </RuleSettings>
- </Rule>
<Rule Name="StatementMustNotUseUnnecessaryParenthesis">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
View
3 src/Common/TaskHelpersExtensions.cs
@@ -827,6 +827,7 @@ private struct AsyncVoid
}
}
+ [SuppressMessage("Microsoft.StyleCop.CSharp.MaintainabilityRules", "SA1402:FileMayOnlyContainASingleClass", Justification = "Packaged as one file to make it easy to link against")]
internal abstract class CatchInfoBase<TTask>
where TTask : Task
{
@@ -868,6 +869,7 @@ internal struct CatchResult
}
}
+ [SuppressMessage("Microsoft.StyleCop.CSharp.MaintainabilityRules", "SA1402:FileMayOnlyContainASingleClass", Justification = "Packaged as one file to make it easy to link against")]
internal class CatchInfo : CatchInfoBase<Task>
{
private static CatchResult _completed = new CatchResult { Task = TaskHelpers.Completed() };
@@ -907,6 +909,7 @@ public CatchResult Throw(Exception ex)
}
}
+ [SuppressMessage("Microsoft.StyleCop.CSharp.MaintainabilityRules", "SA1402:FileMayOnlyContainASingleClass", Justification = "Packaged as one file to make it easy to link against")]
internal class CatchInfo<T> : CatchInfoBase<Task<T>>
{
public CatchInfo(Task<T> task)
View
1 src/Microsoft.Web.Http.Data/Microsoft.Web.Http.Data.csproj
@@ -18,6 +18,7 @@
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
<RestorePackages>true</RestorePackages>
+ <IsStyleCopEnabled>false</IsStyleCopEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
View
49 ...ributes/AttributeEdmPropertyConvention.cs → ...ertyConventionOfTPropertyConfiguration.cs
@@ -69,53 +69,4 @@ public void Apply(TPropertyConfiguration edmProperty, IStructuralTypeConfigurati
/// <param name="attribute">The attribute to be used during configuration.</param>
public abstract void Apply(TPropertyConfiguration edmProperty, IStructuralTypeConfiguration structuralTypeConfiguration, Attribute attribute);
}
-
- /// <summary>
- /// Base class for all attribute based <see cref="IEdmPropertyConvention"/>'s.
- /// </summary>
- /// <typeparam name="TPropertyConfiguration">The type of the property this configuration applies to.</typeparam>
- /// <typeparam name="TAttribute">The type of the attribute this convention looks for.</typeparam>
- public abstract class AttributeEdmPropertyConvention<TPropertyConfiguration, TAttribute> : AttributeEdmPropertyConvention<TPropertyConfiguration>
- where TPropertyConfiguration : PropertyConfiguration
- where TAttribute : Attribute
- {
- protected AttributeEdmPropertyConvention(bool allowMultiple)
- : base((attribute) => typeof(TAttribute) == attribute.GetType(), allowMultiple)
- {
- }
-
- /// <summary>
- /// Applies the convention.
- /// </summary>
- /// <param name="edmProperty">The property being configured.</param>
- /// <param name="structuralTypeConfiguration">The type being configured.</param>
- /// <param name="attribute">The attribute to be used during configuration.</param>
- 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);
- }
-
- /// <summary>
- /// Applies the convention.
- /// </summary>
- /// <param name="edmProperty">The property being configured.</param>
- /// <param name="structuralTypeConfiguration">The type being configured.</param>
- /// <param name="attribute">The attribute to be used during configuration.</param>
- public abstract void Apply(TPropertyConfiguration edmProperty, IStructuralTypeConfiguration structuralTypeConfiguration, TAttribute attribute);
- }
}
View
53 ...entions/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
+{
+ /// <summary>
+ /// Base class for all attribute based <see cref="IEdmPropertyConvention"/>'s.
+ /// </summary>
+ /// <typeparam name="TPropertyConfiguration">The type of the property this configuration applies to.</typeparam>
+ /// <typeparam name="TAttribute">The type of the attribute this convention looks for.</typeparam>
+ public abstract class AttributeEdmPropertyConvention<TPropertyConfiguration, TAttribute> : AttributeEdmPropertyConvention<TPropertyConfiguration>
+ where TPropertyConfiguration : PropertyConfiguration
+ where TAttribute : Attribute
+ {
+ protected AttributeEdmPropertyConvention(bool allowMultiple)
+ : base((attribute) => typeof(TAttribute) == attribute.GetType(), allowMultiple)
+ {
+ }
+
+ /// <summary>
+ /// Applies the convention.
+ /// </summary>
+ /// <param name="edmProperty">The property being configured.</param>
+ /// <param name="structuralTypeConfiguration">The type being configured.</param>
+ /// <param name="attribute">The attribute to be used during configuration.</param>
+ 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);
+ }
+
+ /// <summary>
+ /// Applies the convention.
+ /// </summary>
+ /// <param name="edmProperty">The property being configured.</param>
+ /// <param name="structuralTypeConfiguration">The type being configured.</param>
+ /// <param name="attribute">The attribute to be used during configuration.</param>
+ public abstract void Apply(TPropertyConfiguration edmProperty, IStructuralTypeConfiguration structuralTypeConfiguration, TAttribute attribute);
+ }
+}
View
3 src/System.Web.Http.OData/System.Web.Http.OData.csproj
@@ -107,7 +107,8 @@
<Compile Include="OData\Builder\ComplexPropertyConfiguration.cs" />
<Compile Include="OData\Builder\ComplexTypeConfiguration.cs" />
<Compile Include="OData\Builder\Conventions\Attributes\AttributeConvention.cs" />
- <Compile Include="OData\Builder\Conventions\Attributes\AttributeEdmPropertyConvention.cs" />
+ <Compile Include="OData\Builder\Conventions\Attributes\AttributeEdmPropertyConventionOfTPropertyConfiguration.cs" />
+ <Compile Include="OData\Builder\Conventions\Attributes\AttributeEdmPropertyConventionOfTPropertyConfigurationAndTAttribute.cs" />
<Compile Include="OData\Builder\Conventions\Attributes\NotMappedAttributeEdmPropertyConvention.cs" />
<Compile Include="OData\Builder\Conventions\IConvention.cs" />
<Compile Include="OData\Builder\Conventions\IEdmPropertyConvention.cs" />
View
5 test/Settings.StyleCop
@@ -65,6 +65,11 @@
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
+ <Rule Name="FileMayOnlyContainASingleClass">
+ <RuleSettings>
+ <BooleanProperty Name="Enabled">False</BooleanProperty>
+ </RuleSettings>
+ </Rule>
<Rule Name="FileMayOnlyContainASingleNamespace">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>

0 comments on commit 7236a72

Please sign in to comment.