Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit c0c4af0

Browse files
dotnet-botdsplaisted
authored andcommitted
Add System.Composition source code, update projects to build in corefx
1 parent bd264e6 commit c0c4af0

File tree

188 files changed

+59104
-0
lines changed

Some content is hidden

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

188 files changed

+59104
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright (c) Microsoft. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
using System.Resources;
5+
using System.Reflection;
6+
using System.Runtime.InteropServices;
7+
using System.Security;
8+
9+
// General Information about an assembly is controlled through the following
10+
// set of attributes. Change these attribute values to modify the information
11+
// associated with an assembly.
12+
[assembly: AssemblyConfiguration("")]
13+
[assembly: AssemblyTrademark("")]
14+
[assembly: AssemblyCulture("")]
15+
[assembly: NeutralResourcesLanguage("en")]
16+
17+
[assembly: ComVisible(false)]
18+
[assembly: SecurityTransparent]
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
5+
<PropertyGroup>
6+
<ProjectGuid>{C6257381-C624-494A-A9D9-5586E60856EA}</ProjectGuid>
7+
<OutputType>Library</OutputType>
8+
<AppDesignerFolder>Properties</AppDesignerFolder>
9+
<RootNamespace>System.Composition</RootNamespace>
10+
<AssemblyName>System.Composition.AttributedModel</AssemblyName>
11+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
12+
<TargetFrameworkProfile>Profile259</TargetFrameworkProfile>
13+
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
14+
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
15+
<RestorePackages>true</RestorePackages>
16+
<MinimumVisualStudioVersion>11.0</MinimumVisualStudioVersion>
17+
</PropertyGroup>
18+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
19+
</PropertyGroup>
20+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
21+
</PropertyGroup>
22+
<ItemGroup>
23+
<Compile Include="Properties\AssemblyInfo.cs" />
24+
<Compile Include="System\Composition\Convention\AttributedModelProvider.cs" />
25+
<Compile Include="System\Composition\ExportAttribute.cs" />
26+
<Compile Include="System\Composition\ExportMetadataAttribute.cs" />
27+
<Compile Include="System\Composition\ImportAttribute.cs" />
28+
<Compile Include="System\Composition\ImportingConstructorAttribute.cs" />
29+
<Compile Include="System\Composition\ImportManyAttribute.cs" />
30+
<Compile Include="System\Composition\ImportMetadataConstraintAttribute.cs" />
31+
<Compile Include="System\Composition\MetadataAttributeAttribute.cs" />
32+
<Compile Include="System\Composition\OnImportsSatisfiedAttribute.cs" />
33+
<Compile Include="System\Composition\PartMetadataAttribute.cs" />
34+
<Compile Include="System\Composition\PartNotDiscoverableAttribute.cs" />
35+
<Compile Include="System\Composition\SharedAttribute.cs" />
36+
<Compile Include="System\Composition\SharingBoundaryAttribute.cs" />
37+
</ItemGroup>
38+
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
39+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
40+
Other similar extension points exist, see Microsoft.Common.targets.
41+
<Target Name="BeforeBuild">
42+
</Target>
43+
<Target Name="AfterBuild">
44+
</Target>
45+
-->
46+
</Project>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Copyright (c) Microsoft. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
using System;
5+
using System.Collections.Generic;
6+
using System.Linq;
7+
using System.Reflection;
8+
using System.Text;
9+
using System.Threading.Tasks;
10+
11+
namespace System.Composition.Convention
12+
{
13+
/// <summary>
14+
/// Provider of augmented reflection data in support of conventions.
15+
/// </summary>
16+
public abstract class AttributedModelProvider
17+
{
18+
/// <summary>
19+
/// Provide the list of attributes applied to the specified member.
20+
/// </summary>
21+
/// <param name="reflectedType">The reflectedType the type used to retrieve the memberInfo.</param>
22+
/// <param name="member">The member to supply attributes for.</param>
23+
/// <returns>The list of applied attributes.</returns>
24+
public abstract IEnumerable<Attribute> GetCustomAttributes(System.Type reflectedType, MemberInfo member);
25+
26+
/// <summary>
27+
/// <param name="reflectedType">The reflectedType the type used to retrieve the parameterInfo.</param>
28+
/// <param name="parameter">The member to supply attributes for.</param>
29+
/// <returns>The list of applied attributes.</returns>
30+
/// </summary>
31+
public abstract IEnumerable<Attribute> GetCustomAttributes(System.Type reflectedType, ParameterInfo parameter);
32+
}
33+
}
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
// Copyright (c) Microsoft. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
using System;
5+
using System.Diagnostics.CodeAnalysis;
6+
7+
namespace System.Composition
8+
{
9+
/// <summary>
10+
/// Specifies that a type, property, field, or method provides a particular export.
11+
/// </summary>
12+
[SuppressMessage("Microsoft.Performance", "CA1813:AvoidUnsealedAttributes")]
13+
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property,
14+
AllowMultiple = true, Inherited = false)]
15+
public class ExportAttribute : Attribute
16+
{
17+
/// <summary>
18+
/// Initializes a new instance of the <see cref="ExportAttribute"/> class, exporting the
19+
/// type or member marked with this attribute under the default contract name.
20+
/// </summary>
21+
public ExportAttribute()
22+
: this((string)null, (Type)null)
23+
{
24+
}
25+
26+
/// <summary>
27+
/// Initializes a new instance of the <see cref="ExportAttribute"/> class, exporting the
28+
/// type or member marked with this attribute under a contract name derived from the
29+
/// specified type.
30+
/// </summary>
31+
/// <param name="contractType">
32+
/// A <see cref="Type"/> of which to derive the contract name to export the type or
33+
/// member marked with this attribute, under; or <see langword="null"/> to use the
34+
/// default contract name.
35+
/// </param>
36+
public ExportAttribute(Type contractType)
37+
: this((string)null, contractType)
38+
{
39+
}
40+
41+
/// <summary>
42+
/// Initializes a new instance of the <see cref="ExportAttribute"/> class, exporting the
43+
/// type or member marked with this attribute under the specified contract name.
44+
/// </summary>
45+
/// <param name="contractName">
46+
/// A <see cref="String"/> containing the contract name to export the type or member
47+
/// marked with this attribute, under; or <see langword="null"/> or an empty string
48+
/// ("") to use the default contract name.
49+
/// </param>
50+
public ExportAttribute(string contractName)
51+
: this(contractName, (Type)null)
52+
{
53+
}
54+
55+
/// <summary>
56+
/// Initializes a new instance of the <see cref="ExportAttribute"/> class, exporting the
57+
/// type or member marked with this attribute under the specified contract name.
58+
/// </summary>
59+
/// <param name="contractName">
60+
/// A <see cref="String"/> containing the contract name to export the type or member
61+
/// marked with this attribute, under; or <see langword="null"/> or an empty string
62+
/// ("") to use the default contract name.
63+
/// </param>
64+
/// <param name="contractType">
65+
/// A <see cref="Type"/> of which to derive the contract name to export the type or
66+
/// member marked with this attribute, under; or <see langword="null"/> to use the
67+
/// default contract name.
68+
/// </param>
69+
public ExportAttribute(string contractName, Type contractType)
70+
{
71+
ContractName = contractName;
72+
ContractType = contractType;
73+
}
74+
75+
/// <summary>
76+
/// Gets the contract name to export the type or member under.
77+
/// </summary>
78+
/// <value>
79+
/// A <see cref="String"/> containing the contract name to export the type or member
80+
/// marked with this attribute, under. The default value is an empty string ("").
81+
/// </value>
82+
public string ContractName { get; private set; }
83+
84+
/// <summary>
85+
/// Get the contract type that is exported by the member that this attribute is attached to.
86+
/// </summary>
87+
/// <value>
88+
/// A <see cref="Type"/> of the export that is be provided. The default value is
89+
/// <see langword="null"/> which means that the type will be obtained by looking at the type on
90+
/// the member that this export is attached to.
91+
/// </value>
92+
public Type ContractType { get; private set; }
93+
}
94+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// Copyright (c) Microsoft. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
using System;
5+
6+
namespace System.Composition
7+
{
8+
/// <summary>
9+
/// Specifies metadata for a type, property, field, or method marked with the
10+
/// <see cref="ExportAttribute"/>.
11+
/// </summary>
12+
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Property,
13+
AllowMultiple = true, Inherited = false)]
14+
public sealed class ExportMetadataAttribute : Attribute
15+
{
16+
/// <summary>
17+
/// Initializes a new instance of the <see cref="ExportMetadataAttribute"/> with the
18+
/// specified name and metadata value.
19+
/// </summary>
20+
/// <param name="name">
21+
/// A <see cref="String"/> containing the name of the metadata value; or
22+
/// <see langword="null"/> to set the <see cref="Name"/> property to an empty
23+
/// string ("").
24+
/// </param>
25+
/// <param name="value">
26+
/// An <see cref="object"/> containing the metadata value. This can be
27+
/// <see langword="null"/>.
28+
/// </param>
29+
public ExportMetadataAttribute(string name, object value)
30+
{
31+
Name = name ?? string.Empty;
32+
Value = value;
33+
}
34+
35+
/// <summary>
36+
/// Gets the name of the metadata value.
37+
/// </summary>
38+
/// <value>
39+
/// A <see cref="String"/> containing the name of the metadata value.
40+
/// </value>
41+
public string Name { get; private set; }
42+
43+
/// <summary>
44+
/// Gets the metadata value.
45+
/// </summary>
46+
/// <value>
47+
/// An <see cref="object"/> containing the metadata value.
48+
/// </value>
49+
public object Value { get; private set; }
50+
}
51+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// Copyright (c) Microsoft. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
using System;
5+
using System.Diagnostics.CodeAnalysis;
6+
7+
namespace System.Composition
8+
{
9+
/// <summary>
10+
/// Specifies that a property, field, or parameter imports a particular export.
11+
/// </summary>
12+
[SuppressMessage("Microsoft.Performance", "CA1813:AvoidUnsealedAttributes")]
13+
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Parameter,
14+
AllowMultiple = false, Inherited = false)]
15+
public class ImportAttribute : Attribute
16+
{
17+
/// <summary>
18+
/// Initializes a new instance of the <see cref="ImportAttribute"/> class, importing the
19+
/// export without a contract name.
20+
/// </summary>
21+
public ImportAttribute()
22+
: this((string)null)
23+
{
24+
}
25+
26+
/// <summary>
27+
/// Initializes a new instance of the <see cref="ImportAttribute"/> class, importing the
28+
/// export with the specified contract name.
29+
/// </summary>
30+
/// <param name="contractName">
31+
/// A <see cref="String"/> containing the contract name of the export to import, or
32+
/// <see langword="null"/> or an empty string ("") to use the default contract name.
33+
/// </param>
34+
public ImportAttribute(string contractName)
35+
{
36+
ContractName = contractName;
37+
}
38+
39+
/// <summary>
40+
/// Gets the contract name of the export to import.
41+
/// </summary>
42+
/// <value>
43+
/// A <see cref="String"/> containing the contract name of the export to import. The
44+
/// default value is null.
45+
/// </value>
46+
public string ContractName { get; private set; }
47+
48+
/// <summary>
49+
/// Gets or sets a value indicating whether the property, field or parameter will be left
50+
/// at its default value when an export with the contract name is not present in
51+
/// the container.
52+
/// </summary>
53+
public bool AllowDefault { get; set; }
54+
}
55+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// Copyright (c) Microsoft. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
using System;
5+
using System.Diagnostics.CodeAnalysis;
6+
7+
namespace System.Composition
8+
{
9+
/// <summary>
10+
/// Specifies that a property, field, or parameter imports a particular set of exports.
11+
/// </summary>
12+
[SuppressMessage("Microsoft.Performance", "CA1813:AvoidUnsealedAttributes")]
13+
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Parameter,
14+
AllowMultiple = false, Inherited = false)]
15+
public class ImportManyAttribute : Attribute
16+
{
17+
/// <summary>
18+
/// Initializes a new instance of the <see cref="ImportManyAttribute"/> class, importing the
19+
/// set of exports without a contract name.
20+
/// </summary>
21+
public ImportManyAttribute()
22+
: this((string)null)
23+
{
24+
}
25+
26+
/// <summary>
27+
/// Initializes a new instance of the <see cref="ImportManyAttribute"/> class, importing the
28+
/// set of exports with the specified contract name.
29+
/// </summary>
30+
/// <param name="contractName">
31+
/// A <see cref="String"/> containing the contract name of the exports to import, or
32+
/// <see langword="null"/>.
33+
/// </param>
34+
public ImportManyAttribute(string contractName)
35+
{
36+
ContractName = contractName;
37+
}
38+
39+
/// <summary>
40+
/// Gets the contract name of the exports to import.
41+
/// </summary>
42+
/// <value>
43+
/// A <see cref="String"/> containing the contract name of the exports to import. The
44+
/// default value is null.
45+
/// </value>
46+
public string ContractName { get; private set; }
47+
}
48+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Copyright (c) Microsoft. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
using System;
5+
using System.Collections.Generic;
6+
using System.Linq;
7+
using System.Text;
8+
9+
namespace System.Composition
10+
{
11+
/// <summary>
12+
/// When applied on an import, requires certain metadata values on the exporter.
13+
/// </summary>
14+
[AttributeUsage(AttributeTargets.Property, Inherited = false)]
15+
public sealed class ImportMetadataConstraintAttribute : Attribute
16+
{
17+
private readonly string _name;
18+
private readonly object _value;
19+
20+
/// <summary>
21+
/// Require a specific metadata value on the exporter.
22+
/// </summary>
23+
/// <param name="name">The name of the metadata item to match.</param>
24+
/// <param name="value">The value to match.</param>
25+
public ImportMetadataConstraintAttribute(string name, object value)
26+
{
27+
_name = name;
28+
_value = value;
29+
}
30+
31+
/// <summary>
32+
/// The metadata key to match.
33+
/// </summary>
34+
public string Name { get { return _name; } }
35+
36+
/// <summary>
37+
/// The value to match.
38+
/// </summary>
39+
public object Value { get { return _value; } }
40+
}
41+
}

0 commit comments

Comments
 (0)