Skip to content

Commit

Permalink
Fix for #225. ANR.Culture should not return neutral as it turns out
Browse files Browse the repository at this point in the history
  • Loading branch information
jbevain committed Jun 1, 2015
1 parent 64e7378 commit fd8f1b0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
6 changes: 3 additions & 3 deletions Mono.Cecil/AssemblyNameReference.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public string Name {
}

public string Culture {
get { return string.IsNullOrEmpty (culture) ? "neutral" : culture; }
get { return culture; }
set {
culture = value;
full_name = null;
Expand Down Expand Up @@ -152,7 +152,7 @@ public string FullName {
builder.Append (version.ToString (fieldCount: 4));
builder.Append (sep);
builder.Append ("Culture=");
builder.Append (Culture);
builder.Append (string.IsNullOrEmpty (culture) ? "neutral" : culture);
builder.Append (sep);
builder.Append ("PublicKeyToken=");

Expand Down Expand Up @@ -194,7 +194,7 @@ public static AssemblyNameReference Parse (string fullName)
name.Version = new Version (parts [1]);
break;
case "culture":
name.Culture = parts [1];
name.Culture = parts [1] == "neutral" ? "" : parts [1];
break;
case "publickeytoken":
var pk_token = parts [1];
Expand Down
2 changes: 1 addition & 1 deletion Test/Mono.Cecil.Tests/AssemblyTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public void Name ()
Assert.IsNotNull (name);
Assert.AreEqual ("hello", name.Name);
Assert.AreEqual ("neutral", name.Culture);
Assert.AreEqual ("", name.Culture);
Assert.AreEqual (new Version (0, 0, 0, 0), name.Version);
Assert.AreEqual (AssemblyHashAlgorithm.SHA1, name.HashAlgorithm);
});
Expand Down
12 changes: 12 additions & 0 deletions Test/Mono.Cecil.Tests/ImportReflectionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,18 @@ public void ImportStringConcat ()
Assert.AreEqual ("FooBar", concat ("Foo", "Bar"));
}

[Test]
public void GeneratedAssemblyCulture ()
{
var id = Compile<Func<int, int>> ((module, body) => {
var il = body.GetILProcessor ();
il.Emit (OpCodes.Ldarg_0);
il.Emit (OpCodes.Ret);
});

Assert.AreEqual ("", id.Method.DeclaringType.Assembly.GetName ().CultureName);
}

public class Generic<T> {
public T Field;

Expand Down

0 comments on commit fd8f1b0

Please sign in to comment.