Skip to content

Commit 6126092

Browse files
authored
Merge ef67ea5 into ebf655b
2 parents ebf655b + ef67ea5 commit 6126092

File tree

8 files changed

+146
-1
lines changed

8 files changed

+146
-1
lines changed

Confuser.Core/ObfAttrMarker.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ void ApplyInfo(IDnlibDef context, ProtectionSettings settings, IEnumerable<Prote
113113
continue;
114114

115115
if (info.Condition == null && info.Exclude) {
116-
if (type == ApplyInfoType.CurrentInfoOnly ||
116+
if ((type == ApplyInfoType.ParentInfo && info.ApplyToMember) ||
117+
type == ApplyInfoType.CurrentInfoOnly ||
117118
(type == ApplyInfoType.CurrentInfoInherits && info.ApplyToMember)) {
118119
settings.Clear();
119120
}

Confuser2.sln

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlockingReferencesHelper",
143143
EndProject
144144
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlockingReferences.Test", "Tests\BlockingReferences.Test\BlockingReferences.Test.csproj", "{4FB03AD0-96FF-4730-801A-4F997795D920}"
145145
EndProject
146+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "421_NewtonsoftJsonSerialization", "Tests\421_NewtonsoftJsonSerialization\421_NewtonsoftJsonSerialization.csproj", "{4EF73752-78B0-4E0D-A33B-B6637B6C2177}"
147+
EndProject
148+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "421_NewtonsoftJsonSerialization.Test", "Tests\421_NewtonsoftJsonSerialization.Test\421_NewtonsoftJsonSerialization.Test.csproj", "{B1CB9A30-FEA6-4467-BEC5-4803CCE9BF78}"
149+
EndProject
146150
Global
147151
GlobalSection(SolutionConfigurationPlatforms) = preSolution
148152
Debug|Any CPU = Debug|Any CPU
@@ -909,6 +913,30 @@ Global
909913
{4FB03AD0-96FF-4730-801A-4F997795D920}.Release|x64.Build.0 = Release|Any CPU
910914
{4FB03AD0-96FF-4730-801A-4F997795D920}.Release|x86.ActiveCfg = Release|Any CPU
911915
{4FB03AD0-96FF-4730-801A-4F997795D920}.Release|x86.Build.0 = Release|Any CPU
916+
{4EF73752-78B0-4E0D-A33B-B6637B6C2177}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
917+
{4EF73752-78B0-4E0D-A33B-B6637B6C2177}.Debug|Any CPU.Build.0 = Debug|Any CPU
918+
{4EF73752-78B0-4E0D-A33B-B6637B6C2177}.Debug|x64.ActiveCfg = Debug|Any CPU
919+
{4EF73752-78B0-4E0D-A33B-B6637B6C2177}.Debug|x64.Build.0 = Debug|Any CPU
920+
{4EF73752-78B0-4E0D-A33B-B6637B6C2177}.Debug|x86.ActiveCfg = Debug|Any CPU
921+
{4EF73752-78B0-4E0D-A33B-B6637B6C2177}.Debug|x86.Build.0 = Debug|Any CPU
922+
{4EF73752-78B0-4E0D-A33B-B6637B6C2177}.Release|Any CPU.ActiveCfg = Release|Any CPU
923+
{4EF73752-78B0-4E0D-A33B-B6637B6C2177}.Release|Any CPU.Build.0 = Release|Any CPU
924+
{4EF73752-78B0-4E0D-A33B-B6637B6C2177}.Release|x64.ActiveCfg = Release|Any CPU
925+
{4EF73752-78B0-4E0D-A33B-B6637B6C2177}.Release|x64.Build.0 = Release|Any CPU
926+
{4EF73752-78B0-4E0D-A33B-B6637B6C2177}.Release|x86.ActiveCfg = Release|Any CPU
927+
{4EF73752-78B0-4E0D-A33B-B6637B6C2177}.Release|x86.Build.0 = Release|Any CPU
928+
{B1CB9A30-FEA6-4467-BEC5-4803CCE9BF78}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
929+
{B1CB9A30-FEA6-4467-BEC5-4803CCE9BF78}.Debug|Any CPU.Build.0 = Debug|Any CPU
930+
{B1CB9A30-FEA6-4467-BEC5-4803CCE9BF78}.Debug|x64.ActiveCfg = Debug|Any CPU
931+
{B1CB9A30-FEA6-4467-BEC5-4803CCE9BF78}.Debug|x64.Build.0 = Debug|Any CPU
932+
{B1CB9A30-FEA6-4467-BEC5-4803CCE9BF78}.Debug|x86.ActiveCfg = Debug|Any CPU
933+
{B1CB9A30-FEA6-4467-BEC5-4803CCE9BF78}.Debug|x86.Build.0 = Debug|Any CPU
934+
{B1CB9A30-FEA6-4467-BEC5-4803CCE9BF78}.Release|Any CPU.ActiveCfg = Release|Any CPU
935+
{B1CB9A30-FEA6-4467-BEC5-4803CCE9BF78}.Release|Any CPU.Build.0 = Release|Any CPU
936+
{B1CB9A30-FEA6-4467-BEC5-4803CCE9BF78}.Release|x64.ActiveCfg = Release|Any CPU
937+
{B1CB9A30-FEA6-4467-BEC5-4803CCE9BF78}.Release|x64.Build.0 = Release|Any CPU
938+
{B1CB9A30-FEA6-4467-BEC5-4803CCE9BF78}.Release|x86.ActiveCfg = Release|Any CPU
939+
{B1CB9A30-FEA6-4467-BEC5-4803CCE9BF78}.Release|x86.Build.0 = Release|Any CPU
912940
EndGlobalSection
913941
GlobalSection(SolutionProperties) = preSolution
914942
HideSolutionNode = FALSE
@@ -969,6 +997,8 @@ Global
969997
{F602DAFE-E8A2-4CB2-AF0E-656CD357D821} = {356BDB31-853E-43BB-8F9A-D8AC08F69EBB}
970998
{9EB8DC3B-60DC-451E-8C18-3D7E38D463FD} = {356BDB31-853E-43BB-8F9A-D8AC08F69EBB}
971999
{4FB03AD0-96FF-4730-801A-4F997795D920} = {356BDB31-853E-43BB-8F9A-D8AC08F69EBB}
1000+
{4EF73752-78B0-4E0D-A33B-B6637B6C2177} = {356BDB31-853E-43BB-8F9A-D8AC08F69EBB}
1001+
{B1CB9A30-FEA6-4467-BEC5-4803CCE9BF78} = {356BDB31-853E-43BB-8F9A-D8AC08F69EBB}
9721002
EndGlobalSection
9731003
GlobalSection(ExtensibilityGlobals) = postSolution
9741004
SolutionGuid = {0D937D9E-E04B-4A68-B639-D4260473A388}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net461</TargetFramework>
5+
<RootNamespace>NewtonsoftJsonSerialization.Test</RootNamespace>
6+
<IsPackable>false</IsPackable>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<ProjectReference Include="..\Confuser.UnitTest\Confuser.UnitTest.csproj" />
11+
<ProjectReference Include="..\421_NewtonsoftJsonSerialization\421_NewtonsoftJsonSerialization.csproj" />
12+
</ItemGroup>
13+
14+
</Project>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using System.Threading.Tasks;
2+
using Confuser.Core;
3+
using Confuser.Core.Project;
4+
using Confuser.UnitTest;
5+
using Xunit;
6+
using Xunit.Abstractions;
7+
8+
namespace NewtonsoftJsonSerialization.Test {
9+
public class NewtonsoftJsonTest : TestBase {
10+
public NewtonsoftJsonTest(ITestOutputHelper outputHelper) : base(outputHelper) { }
11+
12+
[Fact]
13+
[Trait("Category", "Protection")]
14+
[Trait("Protection", "rename")]
15+
[Trait("Issue", "https://github.com/mkaring/ConfuserEx/issues/421")]
16+
public async Task SignatureMismatch() =>
17+
await Run(
18+
new[] {
19+
"421_NewtonsoftJsonSerialization.exe",
20+
"external:Newtonsoft.Json.dll"
21+
},
22+
new [] {
23+
"{\"a\":\"a\",\"b\":\"b\",\"c\":\"c\"}",
24+
"{\"a\":\"a\",\"b\":\"b\",\"c\":\"c\"}"
25+
},
26+
new SettingItem<Protection>("rename")
27+
);
28+
}
29+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net461</TargetFramework>
6+
<RootNamespace>NewtonsoftJsonSerialization</RootNamespace>
7+
<LangVersion>7.3</LangVersion>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
12+
</ItemGroup>
13+
14+
</Project>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System.Reflection;
2+
using Newtonsoft.Json;
3+
4+
namespace NewtonsoftJsonSerialization {
5+
[Obfuscation(Exclude = true)]
6+
internal class ObfExcluded {
7+
[JsonProperty("a")] public string a;
8+
9+
[JsonProperty("b")] public string b;
10+
11+
[JsonProperty("c")] public string c;
12+
13+
public ObfExcluded(string a, string b, string c) {
14+
this.a = a;
15+
this.b = b;
16+
this.c = c;
17+
}
18+
19+
public override string ToString() => JsonConvert.SerializeObject(this);
20+
}
21+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using Newtonsoft.Json;
2+
3+
namespace NewtonsoftJsonSerialization {
4+
[JsonObject]
5+
internal class ObfMarkedWithAttribute {
6+
[JsonProperty("a")] public string a;
7+
8+
[JsonProperty("b")] public string b;
9+
10+
[JsonProperty("c")] public string c;
11+
12+
public ObfMarkedWithAttribute(string a, string b, string c) {
13+
this.a = a;
14+
this.b = b;
15+
this.c = c;
16+
}
17+
18+
public override string ToString() => JsonConvert.SerializeObject(this);
19+
}
20+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System;
2+
3+
namespace NewtonsoftJsonSerialization {
4+
class Program {
5+
static int Main(string[] args) {
6+
Console.WriteLine("START");
7+
8+
Console.WriteLine(new ObfMarkedWithAttribute("a", "b", "c").ToString());
9+
Console.WriteLine(new ObfExcluded("a", "b", "c").ToString());
10+
11+
Console.WriteLine("END");
12+
13+
return 42;
14+
}
15+
}
16+
}

0 commit comments

Comments
 (0)