forked from yck1509/ConfuserEx
-
-
Notifications
You must be signed in to change notification settings - Fork 380
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#421 Fixed the Obfuscation Attribute marker
The marker did not correctly handle the inheritance ob the obfuscation attribute. This results in members not being excluded correctly, when the attribute asks to do that.
- Loading branch information
Showing
8 changed files
with
146 additions
and
1 deletion.
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
14 changes: 14 additions & 0 deletions
14
Tests/421_NewtonsoftJsonSerialization.Test/421_NewtonsoftJsonSerialization.Test.csproj
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,14 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net461</TargetFramework> | ||
<RootNamespace>NewtonsoftJsonSerialization.Test</RootNamespace> | ||
<IsPackable>false</IsPackable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Confuser.UnitTest\Confuser.UnitTest.csproj" /> | ||
<ProjectReference Include="..\421_NewtonsoftJsonSerialization\421_NewtonsoftJsonSerialization.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
29 changes: 29 additions & 0 deletions
29
Tests/421_NewtonsoftJsonSerialization.Test/NewtonsoftJsonTest.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,29 @@ | ||
using System.Threading.Tasks; | ||
using Confuser.Core; | ||
using Confuser.Core.Project; | ||
using Confuser.UnitTest; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace NewtonsoftJsonSerialization.Test { | ||
public class NewtonsoftJsonTest : TestBase { | ||
public NewtonsoftJsonTest(ITestOutputHelper outputHelper) : base(outputHelper) { } | ||
|
||
[Fact] | ||
[Trait("Category", "Protection")] | ||
[Trait("Protection", "rename")] | ||
[Trait("Issue", "https://github.com/mkaring/ConfuserEx/issues/421")] | ||
public async Task SignatureMismatch() => | ||
await Run( | ||
new[] { | ||
"421_NewtonsoftJsonSerialization.exe", | ||
"external:Newtonsoft.Json.dll" | ||
}, | ||
new [] { | ||
"{\"a\":\"a\",\"b\":\"b\",\"c\":\"c\"}", | ||
"{\"a\":\"a\",\"b\":\"b\",\"c\":\"c\"}" | ||
}, | ||
new SettingItem<Protection>("rename") | ||
); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
Tests/421_NewtonsoftJsonSerialization/421_NewtonsoftJsonSerialization.csproj
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,14 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net461</TargetFramework> | ||
<RootNamespace>NewtonsoftJsonSerialization</RootNamespace> | ||
<LangVersion>7.3</LangVersion> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" /> | ||
</ItemGroup> | ||
|
||
</Project> |
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,21 @@ | ||
using System.Reflection; | ||
using Newtonsoft.Json; | ||
|
||
namespace NewtonsoftJsonSerialization { | ||
[Obfuscation(Exclude = true)] | ||
internal class ObfExcluded { | ||
[JsonProperty("a")] public string a; | ||
|
||
[JsonProperty("b")] public string b; | ||
|
||
[JsonProperty("c")] public string c; | ||
|
||
public ObfExcluded(string a, string b, string c) { | ||
this.a = a; | ||
this.b = b; | ||
this.c = c; | ||
} | ||
|
||
public override string ToString() => JsonConvert.SerializeObject(this); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
Tests/421_NewtonsoftJsonSerialization/ObfMarkedWithAttribute.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,20 @@ | ||
using Newtonsoft.Json; | ||
|
||
namespace NewtonsoftJsonSerialization { | ||
[JsonObject] | ||
internal class ObfMarkedWithAttribute { | ||
[JsonProperty("a")] public string a; | ||
|
||
[JsonProperty("b")] public string b; | ||
|
||
[JsonProperty("c")] public string c; | ||
|
||
public ObfMarkedWithAttribute(string a, string b, string c) { | ||
this.a = a; | ||
this.b = b; | ||
this.c = c; | ||
} | ||
|
||
public override string ToString() => JsonConvert.SerializeObject(this); | ||
} | ||
} |
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,16 @@ | ||
using System; | ||
|
||
namespace NewtonsoftJsonSerialization { | ||
class Program { | ||
static int Main(string[] args) { | ||
Console.WriteLine("START"); | ||
|
||
Console.WriteLine(new ObfMarkedWithAttribute("a", "b", "c").ToString()); | ||
Console.WriteLine(new ObfExcluded("a", "b", "c").ToString()); | ||
|
||
Console.WriteLine("END"); | ||
|
||
return 42; | ||
} | ||
} | ||
} |