Skip to content

Commit f69039b

Browse files
committed
Merge branch 'stylecop2' of https://git01.codeplex.com/forks/randylevy/unitydev into randylevy/unitydev-stylecop
Reconciled conflicts during merge Conflicts: source/Unity.Configuration/Src/SectionExtensionContext.cs source/Unity.Configuration/Tests/Unity.Configuration.Tests/When_LoadingConfigUsingOldContainersSyntax.cs source/Unity.Configuration/Tests/Unity.Configuration.Tests/When_LoadingConfigUsingOldTypeAliasElements.cs source/Unity.Configuration/Tests/Unity.Configuration.Tests/When_LoadingConfigWithInstances.cs source/Unity.Configuration/Tests/Unity.Configuration.Tests/When_LoadingConfigWithMethodInjection.cs source/Unity.Configuration/Tests/Unity.Configuration.Tests/When_LoadingConfigWithMultipleContainers.cs source/Unity.Configuration/Tests/Unity.Configuration.Tests/When_LoadingConfigWithOldTypeMappingSyntax.cs source/Unity.Configuration/Tests/Unity.Configuration.Tests/When_LoadingConfigWithTypeMappings.cs source/Unity.Configuration/Tests/Unity.Configuration.Tests/When_LoadingConfigurationWithArrayInjection.cs source/Unity.Configuration/Tests/Unity.Configuration.Tests/When_LoadingSectionWithAliases.cs source/Unity.Configuration/Tests/Unity.Configuration.Tests/When_LoadingSectionWithProperties.cs source/Unity.Interception/Tests/Tests.Unity.Interception/ParameterCollectionFixture.cs source/Unity/Src/GlobalSuppressions.cs source/Unity/Src/ObjectBuilder/Strategies/BuildPlan/DynamicMethod/DynamicBuildPlanGenerationContext.cs source/Unity/Src/RegistrationByConvention/DuplicateTypeMappingException.cs source/Unity/Src/RegistrationByConvention/UnityContainerRegistrationByConventionExtensions.cs source/Unity/Src/RegistrationByConvention/WithMappings.cs source/Unity/Tests/ObjectBuilder/BuildKeyMappingStrategyTest.cs source/Unity/Tests/ObjectBuilder/InternalAndPrivatePlanFixture.Desktop.cs source/Unity/Tests/TestSupport.Unity/AssertExtensions.cs source/Unity/Tests/Unity.NetCore.Tests/ObjectBuilder/DynamicMethodCallFixture.NetCore.cs source/Unity/Tests/Unity.NetCore.Tests/ObjectBuilder/DynamicMethodPropertySetterFixture.NetCore.cs source/Unity/Tests/Unity.Tests/DeferredResolveFixture.cs source/Unity/Tests/Unity.Tests/GenericChainingFixture.cs source/Unity/Tests/Unity.Tests/InjectingArraysFixture.cs source/Unity/Tests/Unity.Tests/PerThreadLifetimeManagerFixture.cs source/Unity/Tests/Unity.Tests/ResolvingArraysFixture.cs source/Unity/Tests/Unity.Tests/StaticFactoryFixture.cs source/Unity/Tests/Unity.Tests/UnityContainerFixture.cs
2 parents 6a46d37 + 4cd92e2 commit f69039b

File tree

445 files changed

+2880
-2812
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

445 files changed

+2880
-2812
lines changed

build/packages.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
<packages>
33
<package id="OpenCover" version="4.5.1923" />
44
<package id="ReportGenerator" version="1.9.0.0" />
5+
<package id="StyleCop" version="4.7.10.0" />
56
</packages>

build/stylecop.targets

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
<!--
2+
this file is a stripped-down copy of StyleCop.Targets.
3+
the original is a component of StyleCop's MSBuild integration feature.
4+
-->
5+
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
6+
7+
<PropertyGroup>
8+
<StyleCopAssembly>packages\StyleCop.4.7.10.0\lib\StyleCop.dll</StyleCopAssembly>
9+
</PropertyGroup>
10+
11+
<UsingTask AssemblyFile="$(StyleCopAssembly)" TaskName="StyleCopTask" />
12+
13+
<PropertyGroup Condition="Exists('$(StyleCopAssembly)')">
14+
<BuildDependsOn>$(BuildDependsOn);StyleCop</BuildDependsOn>
15+
<RebuildDependsOn>StyleCopForceFullAnalysis;$(RebuildDependsOn)</RebuildDependsOn>
16+
</PropertyGroup>
17+
18+
<PropertyGroup>
19+
<StyleCopForceFullAnalysis Condition="'$(StyleCopForceFullAnalysis)' == ''">false</StyleCopForceFullAnalysis>
20+
<StyleCopCacheResults Condition="'$(StyleCopCacheResults)' == ''">true</StyleCopCacheResults>
21+
<StyleCopTreatErrorsAsWarnings Condition="'$(StyleCopTreatErrorsAsWarnings)' == ''">true</StyleCopTreatErrorsAsWarnings>
22+
<StyleCopEnabled Condition="'$(StyleCopEnabled)' == ''">true</StyleCopEnabled>
23+
<StyleCopOverrideSettingsFile Condition="'$(StyleCopOverrideSettingsFile)' == ''"> </StyleCopOverrideSettingsFile>
24+
<StyleCopOutputFile Condition="'$(StyleCopOutputFile)' == ''">$(IntermediateOutputPath)StyleCopViolations.xml</StyleCopOutputFile>
25+
26+
<StyleCopMaxViolationCount Condition="'$(StyleCopMaxViolationCount)' == ''">-1</StyleCopMaxViolationCount>
27+
<!--
28+
0 means use default violation count limit
29+
a positive number will become the violation count limit
30+
a negative number will removes the limit
31+
-->
32+
</PropertyGroup>
33+
34+
<Target Name="StyleCopForceFullAnalysis">
35+
<CreateProperty Value="true">
36+
<Output
37+
TaskParameter="Value"
38+
PropertyName="StyleCopForceFullAnalysis" />
39+
</CreateProperty>
40+
</Target>
41+
42+
<Target Name="StyleCop" Condition="'$(StyleCopEnabled)' != 'false'">
43+
44+
<Message
45+
Text="forcing full StyleCop reanalysis."
46+
Condition="'$(StyleCopForceFullAnalysis)' == 'true'"
47+
Importance="Low" />
48+
49+
<!--
50+
include all project Compile items,
51+
but exclude any with ExcludeFromStyleCop = true or ExcludeFromSourceAnalysis = true
52+
-->
53+
<CreateItem
54+
Include="@(Compile)"
55+
Condition="('%(Compile.ExcludeFromStyleCop)' != 'true') and ('%(Compile.ExcludeFromSourceAnalysis)' != 'true')">
56+
<Output
57+
TaskParameter="Include"
58+
ItemName="StyleCopFiles" />
59+
</CreateItem>
60+
61+
<Message
62+
Text="Analyzing @(StyleCopFiles)"
63+
Importance="Low" />
64+
65+
<!--
66+
compile the list of exclude files
67+
in order to display the list
68+
-->
69+
<CreateItem
70+
Include="@(Compile)"
71+
Condition="('%(Compile.ExcludeFromStyleCop)' == 'true') or ('%(Compile.ExcludeFromSourceAnalysis)' == 'true')">
72+
<Output
73+
TaskParameter="Include"
74+
ItemName="StyleCopExcludedFiles" />
75+
</CreateItem>
76+
77+
<!--
78+
this operation appears redundant
79+
-->
80+
<ItemGroup>
81+
<StyleCopFiles Remove="@(ExcludeFromStyleCop)" />
82+
</ItemGroup>
83+
84+
<Message
85+
Text="Excluding @(StyleCopExcludedFiles)"
86+
Importance="Normal" />
87+
88+
<StyleCopTask
89+
ProjectFullPath="$(MSBuildProjectDirectory)"
90+
SourceFiles="@(StyleCopFiles)"
91+
AdditionalAddinPaths="@(StyleCopAdditionalAddinPaths)"
92+
ForceFullAnalysis="$(StyleCopForceFullAnalysis)"
93+
DefineConstants="$(DefineConstants)"
94+
TreatErrorsAsWarnings="$(StyleCopTreatErrorsAsWarnings)"
95+
CacheResults="$(StyleCopCacheResults)"
96+
OverrideSettingsFile="$(StyleCopOverrideSettingsFile)"
97+
OutputFile="$(StyleCopOutputFile)"
98+
MaxViolationCount="$(StyleCopMaxViolationCount)" />
99+
100+
<!--
101+
maintain a list of files
102+
to make clean up easier
103+
-->
104+
<CreateItem Include="$(StyleCopOutputFile)">
105+
<Output
106+
TaskParameter="Include"
107+
ItemName="FileWrites" />
108+
</CreateItem>
109+
110+
<!--
111+
explicitly include the cache in
112+
the list of files to clean up
113+
-->
114+
<CreateItem
115+
Include="StyleCop.Cache"
116+
Condition="'$(StyleCopCacheResults)' == 'true'">
117+
<Output
118+
TaskParameter="Include"
119+
ItemName="FileWrites" />
120+
</CreateItem>
121+
</Target>
122+
</Project>

source/Settings.StyleCop

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,34 @@
11
<StyleCopSettings Version="105">
22
<GlobalSettings>
33
<StringProperty Name="MergeSettingsFiles">NoMerge</StringProperty>
4+
<CollectionProperty Name="RecognizedWords">
5+
<Value>arg</Value>
6+
<Value>aspx</Value>
7+
<Value>byref</Value>
8+
<Value>Combinator</Value>
9+
<Value>combinators</Value>
10+
<Value>deserializing</Value>
11+
<Value>enum</Value>
12+
<Value>finalizer</Value>
13+
<Value>Func</Value>
14+
<Value>Fx</Value>
15+
<Value>FxCop</Value>
16+
<Value>Intelli</Value>
17+
<Value>IntelliSense</Value>
18+
<Value>LINQ</Value>
19+
<Value>MemberInfo</Value>
20+
<Value>MVC</Value>
21+
<Value>noop</Value>
22+
<Value>ordinally</Value>
23+
<Value>params</Value>
24+
<Value>proxied</Value>
25+
<Value>proxyable</Value>
26+
<Value>remoting</Value>
27+
<Value>ruleset</Value>
28+
<Value>stateful</Value>
29+
<Value>subelement</Value>
30+
<Value>TypeMappings</Value>
31+
</CollectionProperty>
432
</GlobalSettings>
533
<Parsers>
634
<Parser ParserId="StyleCop.CSharp.CsParser">

source/Unity.Configuration/Src/AliasElement.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ public class AliasElement : DeserializableConfigurationElement
2121
/// </summary>
2222
public AliasElement()
2323
{
24-
2524
}
2625

2726
/// <summary>
@@ -35,9 +34,9 @@ public AliasElement()
3534
public AliasElement(string alias, Type targetType)
3635
{
3736
Guard.ArgumentNotNull(targetType, "targetType");
38-
39-
Alias = alias;
40-
TypeName = targetType.AssemblyQualifiedName;
37+
38+
this.Alias = alias;
39+
this.TypeName = targetType.AssemblyQualifiedName;
4140
}
4241

4342
/// <summary>
@@ -46,7 +45,7 @@ public AliasElement(string alias, Type targetType)
4645
[ConfigurationProperty(AliasPropertyName, IsRequired = true, IsKey = true)]
4746
public string Alias
4847
{
49-
get { return (string) base[AliasPropertyName]; }
48+
get { return (string)base[AliasPropertyName]; }
5049
set { base[AliasPropertyName] = value; }
5150
}
5251

@@ -56,7 +55,7 @@ public string Alias
5655
[ConfigurationProperty(TypeNamePropertyName, IsRequired = true)]
5756
public string TypeName
5857
{
59-
get { return (string) base[TypeNamePropertyName]; }
58+
get { return (string)base[TypeNamePropertyName]; }
6059
set { base[TypeNamePropertyName] = value; }
6160
}
6261

@@ -72,8 +71,8 @@ public string TypeName
7271
public override void SerializeContent(XmlWriter writer)
7372
{
7473
Guard.ArgumentNotNull(writer, "writer");
75-
writer.WriteAttributeString(AliasPropertyName, Alias);
76-
writer.WriteAttributeString(TypeNamePropertyName, TypeName);
74+
writer.WriteAttributeString(AliasPropertyName, this.Alias);
75+
writer.WriteAttributeString(TypeNamePropertyName, this.TypeName);
7776
}
7877
}
7978
}

source/Unity.Configuration/Src/AliasElementCollection.cs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ namespace Microsoft.Practices.Unity.Configuration
1212
[ConfigurationCollection(typeof(AliasElement))]
1313
public class AliasElementCollection : DeserializableConfigurationElementCollection<AliasElement>
1414
{
15-
private static readonly UnknownElementHandlerMap<AliasElementCollection> unknownElementHandlerMap
15+
private static readonly UnknownElementHandlerMap<AliasElementCollection> UnknownElementHandlerMap
1616
= new UnknownElementHandlerMap<AliasElementCollection>
1717
{
18-
{ "typeAlias", (aec, xr) => aec.ReadUnwrappedElement(xr, aec)}
18+
{ "typeAlias", (aec, xr) => aec.ReadUnwrappedElement(xr, aec) }
1919
};
2020

2121
/// <summary>
@@ -27,7 +27,7 @@ private static readonly UnknownElementHandlerMap<AliasElementCollection> unknown
2727
{
2828
get
2929
{
30-
var element = (AliasElement) BaseGet(alias);
30+
var element = (AliasElement)BaseGet(alias);
3131
if (element != null)
3232
{
3333
return element.TypeName;
@@ -36,11 +36,11 @@ private static readonly UnknownElementHandlerMap<AliasElementCollection> unknown
3636
}
3737
set
3838
{
39-
if (BaseGet(alias) != null)
39+
if (this.BaseGet(alias) != null)
4040
{
41-
BaseRemove(alias);
41+
this.BaseRemove(alias);
4242
}
43-
BaseAdd(new AliasElement {Alias = alias, TypeName = value}, true);
43+
this.BaseAdd(new AliasElement { Alias = alias, TypeName = value }, true);
4444
}
4545
}
4646

@@ -50,14 +50,13 @@ private static readonly UnknownElementHandlerMap<AliasElementCollection> unknown
5050
/// <returns>
5151
/// true if the unrecognized element was deserialized successfully; otherwise, false. The default is false.
5252
/// </returns>
53-
/// <param name="elementName">The name of the unrecognized element.
54-
/// </param><param name="reader">An input stream that reads XML from the configuration file.
55-
/// </param><exception cref="T:System.Configuration.ConfigurationErrorsException">The element specified in <paramref name="elementName"/> is the &lt;clear&gt; element.
56-
/// </exception><exception cref="T:System.ArgumentException"><paramref name="elementName"/> starts with the reserved prefix "config" or "lock".
57-
/// </exception>
53+
/// <param name="elementName">The name of the unrecognized element.</param>
54+
/// <param name="reader">An input stream that reads XML from the configuration file.</param>
55+
/// <exception cref="T:System.Configuration.ConfigurationErrorsException">The element specified in <paramref name="elementName"/> is the &lt;clear&gt; element.</exception>
56+
/// <exception cref="T:System.ArgumentException"><paramref name="elementName"/> starts with the reserved prefix "config" or "lock".</exception>
5857
protected override bool OnDeserializeUnrecognizedElement(string elementName, XmlReader reader)
5958
{
60-
return unknownElementHandlerMap.ProcessElement(this, elementName, reader) ||
59+
return UnknownElementHandlerMap.ProcessElement(this, elementName, reader) ||
6160
base.OnDeserializeUnrecognizedElement(elementName, reader);
6261
}
6362

@@ -67,11 +66,10 @@ protected override bool OnDeserializeUnrecognizedElement(string elementName, Xml
6766
/// <returns>
6867
/// An <see cref="T:System.Object"/> that acts as the key for the specified <see cref="T:System.Configuration.ConfigurationElement"/>.
6968
/// </returns>
70-
/// <param name="element">The <see cref="T:System.Configuration.ConfigurationElement"/> to return the key for.
71-
/// </param>
69+
/// <param name="element">The <see cref="T:System.Configuration.ConfigurationElement"/> to return the key for. </param>
7270
protected override object GetElementKey(ConfigurationElement element)
7371
{
74-
return ((AliasElement) element).Alias;
72+
return ((AliasElement)element).Alias;
7573
}
7674
}
7775
}

source/Unity.Configuration/Src/ArrayElement.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,11 @@ public ParameterValueElementCollection Values
5151
/// <param name="writer">Writer to send XML content to.</param>
5252
public override void SerializeContent(XmlWriter writer)
5353
{
54-
writer.WriteAttributeIfNotEmpty(TypeNamePropertyName, TypeName);
55-
foreach (var valueElement in Values)
54+
writer.WriteAttributeIfNotEmpty(TypeNamePropertyName, this.TypeName);
55+
foreach (var valueElement in this.Values)
5656
{
5757
ValueElementHelper.SerializeParameterValueElement(writer, valueElement, true);
5858
}
59-
6059
}
6160

6261
/// <summary>
@@ -70,11 +69,11 @@ public override void SerializeContent(XmlWriter writer)
7069
/// <returns></returns>
7170
public override InjectionParameterValue GetInjectionParameterValue(IUnityContainer container, Type parameterType)
7271
{
73-
GuardTypeIsAnArray(parameterType);
72+
this.GuardTypeIsAnArray(parameterType);
7473

75-
Type elementType = GetElementType(parameterType);
74+
Type elementType = this.GetElementType(parameterType);
7675

77-
var values = Values.Select(v => v.GetInjectionParameterValue(container, elementType));
76+
var values = this.Values.Select(v => v.GetInjectionParameterValue(container, elementType));
7877

7978
if (elementType.IsGenericParameter)
8079
{
@@ -85,7 +84,7 @@ public override InjectionParameterValue GetInjectionParameterValue(IUnityContain
8584

8685
private void GuardTypeIsAnArray(Type externalParameterType)
8786
{
88-
if (string.IsNullOrEmpty(TypeName))
87+
if (string.IsNullOrEmpty(this.TypeName))
8988
{
9089
if (!externalParameterType.IsArray)
9190
{
@@ -97,7 +96,7 @@ private void GuardTypeIsAnArray(Type externalParameterType)
9796

9897
private Type GetElementType(Type parameterType)
9998
{
100-
return TypeResolver.ResolveTypeWithDefault(TypeName, null) ?? parameterType.GetElementType();
99+
return TypeResolver.ResolveTypeWithDefault(this.TypeName, null) ?? parameterType.GetElementType();
101100
}
102101
}
103102
}

source/Unity.Configuration/Src/AssemblyElementCollection.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace Microsoft.Practices.Unity.Configuration
88
/// <summary>
99
/// A collection of <see cref='AssemblyElement'/>s in configuration.
1010
/// </summary>
11-
[ConfigurationCollection(typeof (AssemblyElement))]
11+
[ConfigurationCollection(typeof(AssemblyElement))]
1212
public class AssemblyElementCollection : DeserializableConfigurationElementCollection<AssemblyElement>
1313
{
1414
/// <summary>
@@ -17,11 +17,10 @@ public class AssemblyElementCollection : DeserializableConfigurationElementColle
1717
/// <returns>
1818
/// An <see cref="T:System.Object"/> that acts as the key for the specified <see cref="T:System.Configuration.ConfigurationElement"/>.
1919
/// </returns>
20-
/// <param name="element">The <see cref="T:System.Configuration.ConfigurationElement"/> to return the key for.
21-
/// </param>
20+
/// <param name="element">The <see cref="T:System.Configuration.ConfigurationElement"/> to return the key for. </param>
2221
protected override object GetElementKey(ConfigurationElement element)
2322
{
24-
return ((AssemblyElement) element).Name;
23+
return ((AssemblyElement)element).Name;
2524
}
2625
}
2726
}

source/Unity.Configuration/Src/ConfigurationHelpers/ConfigurationElementExtensions.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public static class ConfigurationElementExtensions
2727
/// <returns>The created element.</returns>
2828
[SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "baseElement",
2929
Justification = "Made this an extension method to get nice usage syntax.")]
30-
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:ValidateArgumentsOfPublicMethods",
30+
[SuppressMessage("Microsoft.Design", "CA1062:ValidateArgumentsOfPublicMethods",
3131
Justification = "Validation done by Guard class")]
3232
public static TElementType ReadUnwrappedElement<TElementType>(this ConfigurationElement baseElement,
3333
XmlReader reader, DeserializableConfigurationElementCollectionBase<TElementType> elementCollection)
@@ -56,7 +56,7 @@ public static TElementType ReadUnwrappedElement<TElementType>(this Configuration
5656
/// <returns>The created element.</returns>
5757
[SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "baseElement",
5858
Justification = "Made this an extension method to get nice usage syntax.")]
59-
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:ValidateArgumentsOfPublicMethods",
59+
[SuppressMessage("Microsoft.Design", "CA1062:ValidateArgumentsOfPublicMethods",
6060
Justification = "Validation done by Guard class")]
6161
public static TElementType ReadElementByType<TElementType>(this ConfigurationElement baseElement,
6262
XmlReader reader, Type elementType, DeserializableConfigurationElementCollectionBase<TElementType> elementCollection)
@@ -65,9 +65,9 @@ public static TElementType ReadElementByType<TElementType>(this ConfigurationEle
6565
Guard.ArgumentNotNull(reader, "reader");
6666
Guard.ArgumentNotNull(elementType, "elementType");
6767
Guard.ArgumentNotNull(elementCollection, "elementCollection");
68-
Guard.TypeIsAssignable(typeof (TElementType), elementType, "elementType");
68+
Guard.TypeIsAssignable(typeof(TElementType), elementType, "elementType");
6969

70-
var element = (TElementType) Activator.CreateInstance(elementType);
70+
var element = (TElementType)Activator.CreateInstance(elementType);
7171
element.Deserialize(reader);
7272
elementCollection.Add(element);
7373
return element;

0 commit comments

Comments
 (0)