Skip to content

Commit

Permalink
Attribute refactoring (#2676)
Browse files Browse the repository at this point in the history
  • Loading branch information
Haplois committed Dec 15, 2020
1 parent 57c4e48 commit 5fe257c
Show file tree
Hide file tree
Showing 19 changed files with 66 additions and 152 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@
<EnableCodeAnalysis>true</EnableCodeAnalysis>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\Microsoft.TestPlatform.ObjectModel\Microsoft.TestPlatform.ObjectModel.csproj" />
<ProjectReference Include="..\..\..\src\Microsoft.TestPlatform.CoreUtilities\Microsoft.TestPlatform.CoreUtilities.csproj" />
<Compile Include="$(TestPlatformRoot)src\Microsoft.TestPlatform.TestHostProvider\Properties\TestExtensionTypesAttribute.cs" Link="Properties\TestExtensionTypesAttribute.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="$(TestPlatformRoot)src\Microsoft.TestPlatform.ObjectModel\Microsoft.TestPlatform.ObjectModel.csproj" />
<ProjectReference Include="$(TestPlatformRoot)src\Microsoft.TestPlatform.CoreUtilities\Microsoft.TestPlatform.CoreUtilities.csproj" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resources\Resources.resx" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@

using System.Reflection;
using System.Runtime.InteropServices;

using Microsoft.TestPlatform.Extensions.EventLogCollector;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities;
using Microsoft.VisualStudio.TestPlatform;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
Expand All @@ -22,3 +23,5 @@

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("4c1f0d81-67a9-4bf3-a006-615ab4a7fcd6")]

[assembly: TestExtensionTypes(typeof(EventLogDataCollector))]

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@
<None Remove="DefaultCodeCoverageConfig.xml" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Microsoft.TestPlatform.ObjectModel\Microsoft.TestPlatform.ObjectModel.csproj" />
<ProjectReference Include="..\..\Microsoft.TestPlatform.Utilities\Microsoft.TestPlatform.Utilities.csproj" />
<Compile Include="$(TestPlatformRoot)src\Microsoft.TestPlatform.TestHostProvider\Properties\TestExtensionTypesAttribute.cs" Link="Properties\TestExtensionTypesAttribute.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="$(TestPlatformRoot)src\Microsoft.TestPlatform.ObjectModel\Microsoft.TestPlatform.ObjectModel.csproj" />
<ProjectReference Include="$(TestPlatformRoot)src\Microsoft.TestPlatform.Utilities\Microsoft.TestPlatform.Utilities.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Internal.CodeCoverage" Version="$(CodeCoverageExternalsVersion)" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
using System.Reflection;
using System.Runtime.InteropServices;

using Microsoft.VisualStudio.Coverage;
using Microsoft.VisualStudio.TestPlatform;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
Expand All @@ -20,3 +23,5 @@

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("b06e12a5-025f-42aa-8f09-c6666c65ece7")]

[assembly: TestExtensionTypes(typeof(DynamicCoverageDataCollector))]
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Microsoft.VisualStudio.TestPlatform.Common.Utilities

internal static class TypesToLoadUtilities
{
public const string TypesToLoadAttributeFullName = "Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities.TypesToLoadAttribute";
public const string TypesToLoadAttributeFullName = "Microsoft.VisualStudio.TestPlatform.TestExtensionTypesAttribute";

internal static IEnumerable<Type> GetTypesToLoad(Assembly assembly)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@
<!-- to copy the netcore.client dependency to bin folder on build -->
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(TestPlatformRoot)src\Microsoft.TestPlatform.TestHostProvider\Properties\TestExtensionTypesAttribute.cs" Link="Properties\TestExtensionTypesAttribute.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resources\Resources.resx" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Microsoft.TestPlatform.ObjectModel\Microsoft.TestPlatform.ObjectModel.csproj" />
<ProjectReference Include="..\..\src\Microsoft.TestPlatform.CoreUtilities\Microsoft.TestPlatform.CoreUtilities.csproj" />
<ProjectReference Include="$(TestPlatformRoot)src\Microsoft.TestPlatform.ObjectModel\Microsoft.TestPlatform.ObjectModel.csproj" />
<ProjectReference Include="$(TestPlatformRoot)src\Microsoft.TestPlatform.CoreUtilities\Microsoft.TestPlatform.CoreUtilities.csproj" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net472' AND '$(OS)' != 'Windows_NT' ">
<Reference Include="System" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
using System.Reflection;
using System.Runtime.InteropServices;

using Microsoft.TestPlatform.Extensions.BlameDataCollector;
using Microsoft.VisualStudio.TestPlatform;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
Expand All @@ -20,3 +23,5 @@

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("716373d6-9162-4ac6-9ae7-b5a3a4286808")]

[assembly: TestExtensionTypes(typeof(BlameLogger), typeof(BlameCollector))]

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Microsoft.TestPlatform.ObjectModel\Microsoft.TestPlatform.ObjectModel.csproj" />
<ProjectReference Include="..\Microsoft.TestPlatform.CoreUtilities\Microsoft.TestPlatform.CoreUtilities.csproj" />
<Compile Include="$(TestPlatformRoot)src\Microsoft.TestPlatform.TestHostProvider\Properties\TestExtensionTypesAttribute.cs" Link="Properties\TestExtensionTypesAttribute.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="$(TestPlatformRoot)src\Microsoft.TestPlatform.ObjectModel\Microsoft.TestPlatform.ObjectModel.csproj" />
<ProjectReference Include="$(TestPlatformRoot)src\Microsoft.TestPlatform.CoreUtilities\Microsoft.TestPlatform.CoreUtilities.csproj" />
</ItemGroup>
<ItemGroup>
<Compile Update="Resources\Resources.Designer.cs">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
using System.Reflection;
using System.Runtime.InteropServices;

using Microsoft.VisualStudio.TestPlatform;
using Microsoft.VisualStudio.TestPlatform.Extensions.HtmlLogger;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
Expand All @@ -21,3 +24,5 @@

// The following GUID is for the ID of the typelib if this project is exposed to COM.
[assembly: Guid("1f26e9c7-5018-4091-a22a-89280f2f98a9")]

[assembly: TestExtensionTypes(typeof(HtmlLogger))]

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Microsoft.TestPlatform.ObjectModel\Microsoft.TestPlatform.ObjectModel.csproj" />
<ProjectReference Include="..\Microsoft.TestPlatform.CoreUtilities\Microsoft.TestPlatform.CoreUtilities.csproj" />
<Compile Include="$(TestPlatformRoot)src\Microsoft.TestPlatform.TestHostProvider\Properties\TestExtensionTypesAttribute.cs" Link="Properties\TestExtensionTypesAttribute.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="$(TestPlatformRoot)src\Microsoft.TestPlatform.ObjectModel\Microsoft.TestPlatform.ObjectModel.csproj" />
<ProjectReference Include="$(TestPlatformRoot)src\Microsoft.TestPlatform.CoreUtilities\Microsoft.TestPlatform.CoreUtilities.csproj" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<PackageReference Include="System.Security.Principal.Windows">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@

using System.Reflection;
using System.Runtime.InteropServices;

using Microsoft.VisualStudio.TestPlatform;
using Microsoft.VisualStudio.TestPlatform.Extensions.TrxLogger;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
Expand All @@ -22,4 +23,6 @@
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("60d876ee-f278-4bf8-bc8a-15b356895c6f")]
[assembly: Guid("60d876ee-f278-4bf8-bc8a-15b356895c6f")]

[assembly: TestExtensionTypes(typeof(TrxLogger))]

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -346,11 +346,14 @@ public static IEnumerable<Attribute> GetCustomAttributes(this Assembly assembly,
ValidateArg.NotNull(assembly, nameof(assembly));
ValidateArg.NotNullOrWhiteSpace(fullyQualifiedName, nameof(fullyQualifiedName));

var attributes = assembly
if(assembly.GetType(fullyQualifiedName) is Type attribute)
{
return assembly.GetCustomAttributes(attribute);
}

return assembly
.GetCustomAttributes()
.Where(i => i.GetType().FullName == fullyQualifiedName);

return attributes;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
using System.Reflection;
using System.Runtime.InteropServices;

using Microsoft.VisualStudio.TestPlatform;
using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
Expand All @@ -20,3 +23,5 @@

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("83693884-04ee-4083-bae1-e7827b8f5fbc")]

[assembly: TestExtensionTypes(typeof(DefaultTestHostManager), typeof(DotnetTestHostManager))]
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
// 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
namespace Microsoft.VisualStudio.TestPlatform
{
using System;

/// <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
internal sealed class TestExtensionTypesAttribute : Attribute
{
public TypesToLoadAttribute(params Type[] types)
public TestExtensionTypesAttribute(params Type[] types)
{
this.Types = types;
}
Expand Down

This file was deleted.

0 comments on commit 5fe257c

Please sign in to comment.