Enabling StyleCop rule for one class per file in source code
This commit is contained in:
Родитель
ea2290640e
Коммит
7236a72de4
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
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>
|
||||
{
|
||||
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>>
|
||||
{
|
||||
public CatchInfo(Task<T> task)
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -69,53 +69,4 @@ namespace System.Web.Http.OData.Builder.Conventions.Attributes
|
|||
/// <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);
|
||||
}
|
||||
}
|
|
@ -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\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" />
|
||||
|
|
|
@ -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>
|
||||
|
|
Загрузка…
Ссылка в новой задаче