Skip to content

Commit

Permalink
remove harmony and added attributes inheritance support
Browse files Browse the repository at this point in the history
  • Loading branch information
Davydov Dmitry committed Dec 27, 2023
1 parent f6096ee commit 168d4db
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 164 deletions.
2 changes: 1 addition & 1 deletion Allure.XUnit.Reporters/Allure.XUnit.Reporters.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetName>Allure.XUnit.reporters</TargetName>
<TargetFrameworks>netcoreapp2.0;netstandard2.1;net5.0;net6.0</TargetFrameworks>
<TargetFrameworks>netcoreapp2.0;netstandard2.1;net5.0;net6.0;net7.0</TargetFrameworks>
<Nullable>enable</Nullable>
</PropertyGroup>

Expand Down
103 changes: 53 additions & 50 deletions Allure.XUnit/Allure.XUnit.csproj
Original file line number Diff line number Diff line change
@@ -1,54 +1,57 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp2.0;netstandard2.1;net5.0;net6.0</TargetFrameworks>
<IsPackable>true</IsPackable>
<Title>Allure.XUnit</Title>
<Authors>Shumakov Ivan</Authors>
<Description>Allure.XUnit</Description>
<PackageIcon>Allure-X-Color.png</PackageIcon>
<PackageProjectUrl>https://www.nuget.org/packages/Allure.XUnit</PackageProjectUrl>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageTags>allure xunit</PackageTags>
</PropertyGroup>

<PropertyGroup>
<TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);PackAllureXunitReportersFiles</TargetsForTfmSpecificBuildOutput>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AspectInjector" Version="2.8.2" />
<PackageReference Include="Lib.Harmony" Version="2.3.0-prerelease.2" />
<PackageReference Include="xunit.runner.utility" Version="2.4.1" />
</ItemGroup>

<ItemGroup>
<None Include="README.md" Pack="true" PackagePath="\" />
<None Include="./../img/Allure-X-Color.png" Pack="true" PackagePath="\" />
<None Update="LICENSE.md">
<Pack>true</Pack>
<PackagePath>/</PackagePath>
</None>
</ItemGroup>

<ItemGroup>
<PackageReference Include="xunit.assert" Version="2.4.1" />
<PackageReference Include="xunit.core" Version="2.4.1" />
<PackageReference Include="xunit.runner.reporters" Version="2.4.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Allure.Net.Commons\Allure.Net.Commons.csproj">
<!-- todo: Remove Allure.Net.Commons references-->
<!-- <PrivateAssets>all</PrivateAssets>-->
</ProjectReference>
</ItemGroup>

<Target Name="PackAllureXunitReportersFiles">
<ItemGroup>
<BuildOutputInPackage Include="./../Allure.XUnit.Reporters/bin/$(Configuration)/$(TargetFramework)/Allure.XUnit.reporters.dll" />
<BuildOutputInPackage Include="./../Allure.XUnit.Reporters/bin/$(Configuration)/$(TargetFramework)/Allure.XUnit.reporters.pdb" />
</ItemGroup>
</Target>
<PropertyGroup>
<TargetFrameworks>netcoreapp2.0;netstandard2.1;net5.0;net6.0;net7.0</TargetFrameworks>
<IsPackable>true</IsPackable>
<Title>PerlemAI.Allure.XUnit</Title>
<PackageId>PerlemAI.Allure.XUnit</PackageId>
<Authors>PerlemAI</Authors>
<Company>PerlemAI</Company>
<Description>PerlemAI.Allure.XUnit</Description>
<PackageIcon>Allure-X-Color.png</PackageIcon>
<PackageProjectUrl>https://www.nuget.org/packages/PerlemAI.Allure.XUnit</PackageProjectUrl>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageTags>allure xunit</PackageTags>
<Version>7.0.0-rc1</Version>
</PropertyGroup>

<PropertyGroup>
<TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);PackAllureXunitReportersFiles</TargetsForTfmSpecificBuildOutput>
<AssemblyName>PerlemAI.$(MSBuildProjectName)</AssemblyName>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AspectInjector" Version="2.8.2" />
<PackageReference Include="xunit.runner.utility" Version="2.4.1" />
</ItemGroup>

<ItemGroup>
<None Include="README.md" Pack="true" PackagePath="\" />
<None Include="./../img/Allure-X-Color.png" Pack="true" PackagePath="\" />
<None Update="LICENSE.md">
<Pack>true</Pack>
<PackagePath>/</PackagePath>
</None>
</ItemGroup>

<ItemGroup>
<PackageReference Include="xunit.assert" Version="2.4.1" />
<PackageReference Include="xunit.core" Version="2.4.1" />
<PackageReference Include="xunit.runner.reporters" Version="2.4.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Allure.Net.Commons\Allure.Net.Commons.csproj">
<!-- todo: Remove Allure.Net.Commons references-->
<!-- <PrivateAssets>all</PrivateAssets>-->
</ProjectReference>
</ItemGroup>

<Target Name="PackAllureXunitReportersFiles">
<ItemGroup>
<BuildOutputInPackage Include="./../Allure.XUnit.Reporters/bin/$(Configuration)/$(TargetFramework)/Allure.XUnit.reporters.dll" />
<BuildOutputInPackage Include="./../Allure.XUnit.Reporters/bin/$(Configuration)/$(TargetFramework)/Allure.XUnit.reporters.pdb" />
</ItemGroup>
</Target>

</Project>
1 change: 0 additions & 1 deletion Allure.XUnit/AllureXunitFacade.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ public static IMessageSink CreateAllureXunitMessageHandler(
IRunnerLogger logger
)
{
AllureXunitPatcher.PatchXunit(logger);
var secondReporter = ResolveSecondReporter();
var (startupMessage, sink) = ResolveMessageAndSink(
new AllureMessageSink(logger),
Expand Down
27 changes: 21 additions & 6 deletions Allure.XUnit/AllureXunitHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,12 +257,8 @@ static void UpdateTestDataFromAttributes(
ITestMethod method
)
{
var classAttributes = method.TestClass.Class.GetCustomAttributes(
typeof(IAllureInfo)
);
var methodAttributes = method.Method.GetCustomAttributes(
typeof(IAllureInfo)
);
var classAttributes = GetCustomAttributesRecursive(method.TestClass.Class, typeof(IAllureInfo));
var methodAttributes = method.Method.GetCustomAttributes(typeof(IAllureInfo));

foreach (var attribute in classAttributes.Concat(methodAttributes))
{
Expand Down Expand Up @@ -404,6 +400,25 @@ static string BuildFullName(ITestCase testCase)
);
}

private static IEnumerable<IAttributeInfo> GetCustomAttributesRecursive(ITypeInfo typeInfo, Type attributeType)
{
foreach (var type in GetInheritanceTree(typeInfo).Reverse())
{
foreach (var attribute in type.GetCustomAttributes(attributeType.AssemblyQualifiedName))
yield return attribute;
}

static IEnumerable<ITypeInfo> GetInheritanceTree(ITypeInfo typeInfo)
{
var currentType = typeInfo;
while (currentType.ToRuntimeType() != typeof(object))
{
yield return currentType;
currentType = currentType.BaseType;
}
}
}

#region Obsolete public methods
const string OBS_MSG_UNINTENDED_PUBLIC =
"This method wasn't supposed to be in the public API. It's not " +
Expand Down
106 changes: 0 additions & 106 deletions Allure.XUnit/AllureXunitPatcher.cs

This file was deleted.

0 comments on commit 168d4db

Please sign in to comment.