-
Notifications
You must be signed in to change notification settings - Fork 326
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removed TypesToLoadAttribute from ObjectModel. (#2674)
* Removed TypesToLoadAttribute from ObjectModel, and moved the functionallity into adapters themselves.
- Loading branch information
Showing
22 changed files
with
256 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
...rs/Microsoft.TestPlatform.Extensions.EventLogCollector/Properties/TypesToLoadAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System; | ||
using Microsoft.TestPlatform.Extensions.EventLogCollector; | ||
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; | ||
|
||
[assembly: TypesToLoad(typeof(EventLogDataCollector))] | ||
|
||
namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities | ||
{ | ||
/// <summary> | ||
/// Custom Attribute to specify the exact types which should be loaded from assembly | ||
/// </summary> | ||
[AttributeUsage(AttributeTargets.Assembly, Inherited = false, AllowMultiple = false)] | ||
internal sealed class TypesToLoadAttribute : Attribute | ||
{ | ||
public TypesToLoadAttribute(params Type[] types) | ||
{ | ||
this.Types = types; | ||
} | ||
|
||
public Type[] Types { get; } | ||
} | ||
} |
15 changes: 9 additions & 6 deletions
15
...ctModel/Utilities/TypesToLoadAttribute.cs → ...lector/Properties/TypesToLoadAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,25 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System; | ||
using Microsoft.VisualStudio.Coverage; | ||
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; | ||
|
||
[assembly: TypesToLoad(typeof(DynamicCoverageDataCollector))] | ||
|
||
namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities | ||
{ | ||
using System; | ||
|
||
/// <summary> | ||
/// Custom Attribute to specify the exact types which should be loaded from assembly | ||
/// </summary> | ||
[AttributeUsage(AttributeTargets.Assembly, Inherited = false, AllowMultiple = false)] | ||
[CLSCompliant(false)] | ||
public sealed class TypesToLoadAttribute : Attribute | ||
internal sealed class TypesToLoadAttribute : Attribute | ||
{ | ||
public TypesToLoadAttribute(params Type[] types) | ||
{ | ||
Types = types; | ||
this.Types = types; | ||
} | ||
|
||
public Type[] Types { get; } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/Microsoft.TestPlatform.Common/Utilities/TypesToLoadUtilities.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright(c) Microsoft Corporation.All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
namespace Microsoft.VisualStudio.TestPlatform.Common.Utilities | ||
{ | ||
using Microsoft.VisualStudio.TestPlatform.ObjectModel; | ||
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Reflection; | ||
using System.Linq; | ||
|
||
internal static class TypesToLoadUtilities | ||
{ | ||
public const string TypesToLoadAttributeFullName = "Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities.TypesToLoadAttribute"; | ||
|
||
internal static IEnumerable<Type> GetTypesToLoad(Assembly assembly) | ||
{ | ||
ValidateArg.NotNull(assembly, nameof(assembly)); | ||
|
||
var typesToLoad = assembly | ||
.GetCustomAttributes(TypesToLoadAttributeFullName) | ||
.SelectMany(i => GetTypesToLoad(i)); | ||
|
||
return typesToLoad; | ||
} | ||
|
||
private static IEnumerable<Type> GetTypesToLoad(Attribute attribute) | ||
{ | ||
if (attribute == null) | ||
return Enumerable.Empty<Type>(); | ||
|
||
var type = attribute.GetType(); | ||
var typesProperty = type.GetProperty("Types"); | ||
if(typesProperty == null) | ||
return Enumerable.Empty<Type>(); | ||
|
||
return typesProperty.GetValue(attribute) as Type[]; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/Microsoft.TestPlatform.Extensions.BlameDataCollector/Properties/TypesToLoadAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System; | ||
|
||
using Microsoft.TestPlatform.Extensions.BlameDataCollector; | ||
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; | ||
|
||
[assembly: TypesToLoad(typeof(BlameLogger), typeof(BlameCollector))] | ||
|
||
namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities | ||
{ | ||
/// <summary> | ||
/// Custom Attribute to specify the exact types which should be loaded from assembly | ||
/// </summary> | ||
[AttributeUsage(AttributeTargets.Assembly, Inherited = false, AllowMultiple = false)] | ||
internal sealed class TypesToLoadAttribute : Attribute | ||
{ | ||
public TypesToLoadAttribute(params Type[] types) | ||
{ | ||
this.Types = types; | ||
} | ||
|
||
public Type[] Types { get; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/Microsoft.TestPlatform.Extensions.HtmlLogger/Properties/TypesToLoadAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System; | ||
using Microsoft.VisualStudio.TestPlatform.Extensions.HtmlLogger; | ||
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; | ||
|
||
[assembly: TypesToLoad(typeof(HtmlLogger))] | ||
|
||
namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities | ||
{ | ||
/// <summary> | ||
/// Custom Attribute to specify the exact types which should be loaded from assembly | ||
/// </summary> | ||
[AttributeUsage(AttributeTargets.Assembly, Inherited = false, AllowMultiple = false)] | ||
internal sealed class TypesToLoadAttribute : Attribute | ||
{ | ||
public TypesToLoadAttribute(params Type[] types) | ||
{ | ||
this.Types = types; | ||
} | ||
|
||
public Type[] Types { get; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/Microsoft.TestPlatform.Extensions.TrxLogger/Properties/TypesToLoadAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System; | ||
using Microsoft.VisualStudio.TestPlatform.Extensions.TrxLogger; | ||
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; | ||
|
||
[assembly: TypesToLoad(typeof(TrxLogger))] | ||
|
||
namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities | ||
{ | ||
/// <summary> | ||
/// Custom Attribute to specify the exact types which should be loaded from assembly | ||
/// </summary> | ||
[AttributeUsage(AttributeTargets.Assembly, Inherited = false, AllowMultiple = false)] | ||
internal sealed class TypesToLoadAttribute : Attribute | ||
{ | ||
public TypesToLoadAttribute(params Type[] types) | ||
{ | ||
this.Types = types; | ||
} | ||
|
||
public Type[] Types { get; } | ||
} | ||
} |
Oops, something went wrong.