Added unit test to verify issue #1

The renaming analysis fails in case a text block contains a [ but no
closing ].
This commit is contained in:
Martin Karing 2018-08-11 11:06:07 +02:00
Родитель b3910a7a3f
Коммит ff5b187505
8 изменённых файлов: 144 добавлений и 1 удалений

Просмотреть файл

@ -15,6 +15,7 @@ indent_style = space
[*.xml]
[*.xaml]
indent_size = 2
indent_style = space
[*.{cs,vb}]

Просмотреть файл

@ -32,6 +32,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
appveyor.yml = appveyor.yml
global.json = global.json
LICENSE.md = LICENSE.md
README.md = README.md
EndProjectSection
@ -42,7 +43,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AntiTamper", "Tests\AntiTam
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AntiTamper.Test", "Tests\AntiTamper.Test\AntiTamper.Test.csproj", "{3F5558BD-7B94-4CB0-A46C-A7252B5BCA17}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Confuser.MSBuild.Tasks", "Confuser.MSBuild.Tasks\Confuser.MSBuild.Tasks.csproj", "{91B12706-DC6A-45DE-97F1-FAF0901FF6AF}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Confuser.MSBuild.Tasks", "Confuser.MSBuild.Tasks\Confuser.MSBuild.Tasks.csproj", "{91B12706-DC6A-45DE-97F1-FAF0901FF6AF}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WpfRenaming", "Tests\WpfRenaming\WpfRenaming.csproj", "{BA9D2748-1342-41A3-87F2-343E82D99813}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WpfRenaming.Test", "Tests\WpfRenaming.Test\WpfRenaming.Test.csproj", "{30B8883F-A0A2-4256-ADCF-A790525D3696}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -106,6 +111,14 @@ Global
{91B12706-DC6A-45DE-97F1-FAF0901FF6AF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{91B12706-DC6A-45DE-97F1-FAF0901FF6AF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{91B12706-DC6A-45DE-97F1-FAF0901FF6AF}.Release|Any CPU.Build.0 = Release|Any CPU
{BA9D2748-1342-41A3-87F2-343E82D99813}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BA9D2748-1342-41A3-87F2-343E82D99813}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BA9D2748-1342-41A3-87F2-343E82D99813}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BA9D2748-1342-41A3-87F2-343E82D99813}.Release|Any CPU.Build.0 = Release|Any CPU
{30B8883F-A0A2-4256-ADCF-A790525D3696}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{30B8883F-A0A2-4256-ADCF-A790525D3696}.Debug|Any CPU.Build.0 = Debug|Any CPU
{30B8883F-A0A2-4256-ADCF-A790525D3696}.Release|Any CPU.ActiveCfg = Release|Any CPU
{30B8883F-A0A2-4256-ADCF-A790525D3696}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -116,6 +129,8 @@ Global
{73226E13-1701-424E-A4F2-3E4D575A1DD0} = {356BDB31-853E-43BB-8F9A-D8AC08F69EBB}
{6A2BA6F7-3399-4890-9453-2D5BE8EEBBA9} = {356BDB31-853E-43BB-8F9A-D8AC08F69EBB}
{3F5558BD-7B94-4CB0-A46C-A7252B5BCA17} = {356BDB31-853E-43BB-8F9A-D8AC08F69EBB}
{BA9D2748-1342-41A3-87F2-343E82D99813} = {356BDB31-853E-43BB-8F9A-D8AC08F69EBB}
{30B8883F-A0A2-4256-ADCF-A790525D3696} = {356BDB31-853E-43BB-8F9A-D8AC08F69EBB}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {0D937D9E-E04B-4A68-B639-D4260473A388}

Просмотреть файл

@ -0,0 +1,44 @@
using System;
using System.IO;
using System.Threading.Tasks;
using Confuser.Core;
using Confuser.Core.Project;
using Confuser.UnitTest;
using Xunit;
using Xunit.Abstractions;
namespace WpfRenaming.Test {
public class ProcessWpfTest {
private readonly ITestOutputHelper outputHelper;
public ProcessWpfTest(ITestOutputHelper outputHelper) =>
this.outputHelper = outputHelper ?? throw new ArgumentNullException(nameof(outputHelper));
/// <see cref="https://github.com/mkaring/ConfuserEx/issues/1"/>
[Fact]
[Trait("Category", "Analysis")]
[Trait("Protection", "rename")]
public async Task ProcessWithoutObfuscationTest() {
var baseDir = Environment.CurrentDirectory;
var outputDir = Path.Combine(baseDir, "testtmp");
var inputFile = Path.Combine(baseDir, "WpfRenaming.dll");
var outputFile = Path.Combine(outputDir, "WpfRenaming.dll");
FileUtilities.ClearOutput(outputFile);
var proj = new ConfuserProject {
BaseDirectory = baseDir,
OutputDirectory = outputDir
};
proj.Add(new ProjectModule() { Path = inputFile });
var parameters = new ConfuserParameters {
Project = proj,
Logger = new XunitLogger(outputHelper)
};
await ConfuserEngine.Run(parameters);
Assert.True(File.Exists(outputFile));
}
}
}

Просмотреть файл

@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net461</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.8.0" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Confuser.Core\Confuser.Core.csproj" />
<ProjectReference Include="..\..\Confuser.Protections\Confuser.Protections.csproj" />
<ProjectReference Include="..\WpfRenaming\WpfRenaming.csproj" />
<ProjectReference Include="..\Confuser.UnitTest\Confuser.UnitTest.csproj" />
</ItemGroup>
</Project>

Просмотреть файл

@ -0,0 +1,19 @@
<UserControl x:Class="WpfRenaming.UserControl1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:WpfRenaming"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<StackPanel>
<TextBlock>[1234567</TextBlock>
<TextBlock Text="[1234567" />
<TextBlock Text="{Binding TargetNullValue=[1234567}" />
<TextBlock>
<TextBlock.Text>
<Binding Path="" TargetNullValue="[1234567" />
</TextBlock.Text>
</TextBlock>
</StackPanel>
</UserControl>

Просмотреть файл

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace WpfRenaming
{
/// <summary>
/// Interaktionslogik für UserControl1.xaml
/// </summary>
public partial class UserControl1 : UserControl
{
public UserControl1()
{
InitializeComponent();
}
}
}

Просмотреть файл

@ -0,0 +1,9 @@
<Project Sdk="MSBuild.Sdk.Extras">
<PropertyGroup>
<TargetFramework>net461</TargetFramework>
<ExtrasEnableWpfProjectSetup>true</ExtrasEnableWpfProjectSetup>
<MyType>Custom</MyType>
</PropertyGroup>
</Project>

5
global.json Normal file
Просмотреть файл

@ -0,0 +1,5 @@
{
"msbuild-sdks": {
"MSBuild.Sdk.Extras": "1.6.46"
}
}