Skip to content

Commit

Permalink
Fixed #17.
Browse files Browse the repository at this point in the history
  • Loading branch information
lextm committed Sep 3, 2014
1 parent 153a614 commit 236b159
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 2 deletions.
4 changes: 4 additions & 0 deletions Obfuscar/Obfuscator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1287,6 +1287,10 @@ public void PostProcessing ()

var module = info.Definition.MainModule;
var attribute = new TypeReference ("System.Runtime.CompilerServices", "SuppressIldasmAttribute", module, module.TypeSystem.Corlib).Resolve ();
var reference = module.TypeSystem.Corlib as AssemblyNameReference;
if (attribute.Module.Assembly.FullName != reference.FullName)
return;

CustomAttribute found = null;
foreach (CustomAttribute existing in module.CustomAttributes)
{
Expand Down
1 change: 1 addition & 0 deletions Tests/ObfuscarTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
<Compile Include="BamlTests.cs" />
<Compile Include="CustomAttributeTests.cs" />
<Compile Include="FunctionOverridingTests.cs" />
<Compile Include="PortableTests.cs" />
<Compile Include="SigningTests.cs" />
<Compile Include="SkipNestedTypeTests.cs" />
<Compile Include="SkipVirtualMethodTest.cs" />
Expand Down
72 changes: 72 additions & 0 deletions Tests/PortableTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#region Copyright (c) 2007 Ryan Williams <[email protected]>
/// <copyright>
/// Copyright (c) 2007 Ryan Williams <[email protected]>
///
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
///
/// The above copyright notice and this permission notice shall be included in
/// all copies or substantial portions of the Software.
///
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
/// THE SOFTWARE.
/// </copyright>
#endregion

using System;
using System.IO;
using System.Collections.Generic;
using System.Text;
using System.CodeDom.Compiler;

using NUnit.Framework;
using Mono.Cecil;
using Obfuscar;
using System.Linq;

namespace ObfuscarTests
{
[TestFixture]
public class PortableTests
{
[Test]
public void CheckPortable()
{
string xml = string.Format(
@"<?xml version='1.0'?>" +
@"<Obfuscator>" +
@"<Var name='InPath' value='{0}' />" +
@"<Var name='OutPath' value='{1}' />" +
@"<Var name='HideStrings' value='false' />" +
@"<Var name='KeyFile' value='$(InPath)\..\dockpanelsuite.snk' />" +
@"<Module file='$(InPath)\SharpSnmpLib.Portable.dll' />" +
@"</Obfuscator>", TestHelper.InputPath, TestHelper.OutputPath);

TestHelper.CleanInput();

// build it with the keyfile option (embeds the public key, and signs the assembly)
File.Copy(Path.Combine(TestHelper.InputPath, @"..\SharpSnmpLib.Portable.dll"), Path.Combine(TestHelper.InputPath, "SharpSnmpLib.Portable.dll"));

var map = TestHelper.Obfuscate(xml).Mapping;

AssemblyDefinition inAssmDef = AssemblyDefinition.ReadAssembly(
Path.Combine(TestHelper.InputPath, "SharpSnmpLib.Portable.dll"));

AssemblyDefinition outAssmDef = AssemblyDefinition.ReadAssembly(
Path.Combine(TestHelper.OutputPath, "SharpSnmpLib.Portable.dll"));

var corlibs = outAssmDef.MainModule.AssemblyReferences.Where(reference => reference.Name == "mscorlib");
Assert.AreEqual(1, corlibs.Count());
Assert.AreEqual("2.0.5.0", corlibs.First().Version.ToString());
}
}
}
Binary file added Tests/SharpSnmpLib.Portable.dll
Binary file not shown.
4 changes: 2 additions & 2 deletions ThirdParty/SharedAssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
// You can specify all the values or you can use the default the Revision and
// Build Numbers by using the '*' as shown below:

[assembly: AssemblyVersion("2.0.010629.00")]
[assembly: AssemblyVersion("2.0.010903.03")]
[assembly: AssemblyProduct("Obfuscar 2.0 RC")]
#if (!CF)
[assembly: AssemblyFileVersion("2.0.010629.00")]
[assembly: AssemblyFileVersion("2.0.010903.03")]
#endif

0 comments on commit 236b159

Please sign in to comment.