Enabling StyleCop rule for one class per file in source code

This commit is contained in:
youssefm 2012-08-27 17:39:25 -07:00
Родитель ea2290640e
Коммит 7236a72de4
7 изменённых файлов: 64 добавлений и 55 удалений

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

@ -334,11 +334,6 @@
<BooleanProperty Name="Enabled">False</BooleanProperty> <BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings> </RuleSettings>
</Rule> </Rule>
<Rule Name="FileMayOnlyContainASingleClass">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="StatementMustNotUseUnnecessaryParenthesis"> <Rule Name="StatementMustNotUseUnnecessaryParenthesis">
<RuleSettings> <RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty> <BooleanProperty Name="Enabled">False</BooleanProperty>

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

@ -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<TTask> internal abstract class CatchInfoBase<TTask>
where TTask : Task 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<Task> internal class CatchInfo : CatchInfoBase<Task>
{ {
private static CatchResult _completed = new CatchResult { Task = TaskHelpers.Completed() }; 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<T> : CatchInfoBase<Task<T>> internal class CatchInfo<T> : CatchInfoBase<Task<T>>
{ {
public CatchInfo(Task<T> task) public CatchInfo(Task<T> task)

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

@ -18,6 +18,7 @@
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
<RestorePackages>true</RestorePackages> <RestorePackages>true</RestorePackages>
<IsStyleCopEnabled>false</IsStyleCopEnabled>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>

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

@ -69,53 +69,4 @@ namespace System.Web.Http.OData.Builder.Conventions.Attributes
/// <param name="attribute">The attribute to be used during configuration.</param> /// <param name="attribute">The attribute to be used during configuration.</param>
public abstract void Apply(TPropertyConfiguration edmProperty, IStructuralTypeConfiguration structuralTypeConfiguration, Attribute attribute); 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);
}
} }

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

@ -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);
}
}

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

@ -107,7 +107,8 @@
<Compile Include="OData\Builder\ComplexPropertyConfiguration.cs" /> <Compile Include="OData\Builder\ComplexPropertyConfiguration.cs" />
<Compile Include="OData\Builder\ComplexTypeConfiguration.cs" /> <Compile Include="OData\Builder\ComplexTypeConfiguration.cs" />
<Compile Include="OData\Builder\Conventions\Attributes\AttributeConvention.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\Attributes\NotMappedAttributeEdmPropertyConvention.cs" />
<Compile Include="OData\Builder\Conventions\IConvention.cs" /> <Compile Include="OData\Builder\Conventions\IConvention.cs" />
<Compile Include="OData\Builder\Conventions\IEdmPropertyConvention.cs" /> <Compile Include="OData\Builder\Conventions\IEdmPropertyConvention.cs" />

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

@ -65,6 +65,11 @@
<BooleanProperty Name="Enabled">False</BooleanProperty> <BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings> </RuleSettings>
</Rule> </Rule>
<Rule Name="FileMayOnlyContainASingleClass">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="FileMayOnlyContainASingleNamespace"> <Rule Name="FileMayOnlyContainASingleNamespace">
<RuleSettings> <RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty> <BooleanProperty Name="Enabled">False</BooleanProperty>