33
44#if ! WINDOWS_UWP && ! WIN_UI
55
6+ using Microsoft . VisualStudio . TestPlatform . MSTest . TestAdapter . Helpers ;
67using Microsoft . VisualStudio . TestPlatform . MSTestAdapter . PlatformServices . Deployment ;
78using Microsoft . VisualStudio . TestPlatform . ObjectModel ;
89using Microsoft . VisualStudio . TestTools . UnitTesting ;
@@ -14,8 +15,7 @@ namespace Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Uti
1415/// </summary>
1516internal sealed class DeploymentItemUtility
1617{
17- // REVIEW: it would be better if this was a ReflectionHelper, because helper is able to cache. But we don't have reflection helper here, because this is platform services dll.
18- private readonly ReflectionUtility _reflectionUtility ;
18+ private readonly ReflectHelper _reflectHelper ;
1919
2020 /// <summary>
2121 /// A cache for class level deployment items.
@@ -25,10 +25,10 @@ internal sealed class DeploymentItemUtility
2525 /// <summary>
2626 /// Initializes a new instance of the <see cref="DeploymentItemUtility"/> class.
2727 /// </summary>
28- /// <param name="reflectionUtility "> The reflect helper. </param>
29- internal DeploymentItemUtility ( ReflectionUtility reflectionUtility )
28+ /// <param name="reflectHelper "> The reflect helper. </param>
29+ internal DeploymentItemUtility ( ReflectHelper reflectHelper )
3030 {
31- _reflectionUtility = reflectionUtility ;
31+ _reflectHelper = reflectHelper ;
3232 _classLevelDeploymentItems = [ ] ;
3333 }
3434
@@ -42,9 +42,7 @@ internal IList<DeploymentItem> GetClassLevelDeploymentItems(Type type, ICollecti
4242 {
4343 if ( ! _classLevelDeploymentItems . TryGetValue ( type , out IList < DeploymentItem > ? value ) )
4444 {
45- IReadOnlyList < object > deploymentItemAttributes = _reflectionUtility . GetCustomAttributes (
46- type ,
47- typeof ( DeploymentItemAttribute ) ) ;
45+ IEnumerable < DeploymentItemAttribute > deploymentItemAttributes = _reflectHelper . GetAttributes < DeploymentItemAttribute > ( type ) ;
4846 value = GetDeploymentItems ( deploymentItemAttributes , warnings ) ;
4947 _classLevelDeploymentItems [ type ] = value ;
5048 }
@@ -61,7 +59,7 @@ internal IList<DeploymentItem> GetClassLevelDeploymentItems(Type type, ICollecti
6159 internal KeyValuePair < string , string > [ ] ? GetDeploymentItems ( MethodInfo method , IEnumerable < DeploymentItem > classLevelDeploymentItems ,
6260 ICollection < string > warnings )
6361 {
64- List < DeploymentItem > testLevelDeploymentItems = GetDeploymentItems ( _reflectionUtility . GetCustomAttributes ( method , typeof ( DeploymentItemAttribute ) ) , warnings ) ;
62+ List < DeploymentItem > testLevelDeploymentItems = GetDeploymentItems ( _reflectHelper . GetAttributes < DeploymentItemAttribute > ( method ) , warnings ) ;
6563
6664 return ToKeyValuePairs ( Concat ( testLevelDeploymentItems , classLevelDeploymentItems ) ) ;
6765 }
@@ -174,11 +172,11 @@ private static bool IsInvalidPath(string path)
174172 return false ;
175173 }
176174
177- private static List < DeploymentItem > GetDeploymentItems ( IEnumerable deploymentItemAttributes , ICollection < string > warnings )
175+ private static List < DeploymentItem > GetDeploymentItems ( IEnumerable < DeploymentItemAttribute > deploymentItemAttributes , ICollection < string > warnings )
178176 {
179177 var deploymentItems = new List < DeploymentItem > ( ) ;
180178
181- foreach ( DeploymentItemAttribute deploymentItemAttribute in deploymentItemAttributes . Cast < DeploymentItemAttribute > ( ) )
179+ foreach ( DeploymentItemAttribute deploymentItemAttribute in deploymentItemAttributes )
182180 {
183181 if ( IsValidDeploymentItem ( deploymentItemAttribute . Path , deploymentItemAttribute . OutputDirectory , out string ? warning ) )
184182 {
0 commit comments