Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/cecil.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Mono.Cecil/AssemblyWriter.cs37
-rw-r--r--Test/Mono.Cecil.Tests/TypeTests.cs13
2 files changed, 7 insertions, 43 deletions
diff --git a/Mono.Cecil/AssemblyWriter.cs b/Mono.Cecil/AssemblyWriter.cs
index 2b9c507..4fc264d 100644
--- a/Mono.Cecil/AssemblyWriter.cs
+++ b/Mono.Cecil/AssemblyWriter.cs
@@ -1435,7 +1435,8 @@ namespace Mono.Cecil {
if (type.HasInterfaces)
AddInterfaces (type);
- AddLayoutInfo (type);
+ if (type.HasLayoutInfo)
+ AddLayoutInfo (type);
if (type.HasFields)
AddFields (type);
@@ -1554,36 +1555,12 @@ namespace Mono.Cecil {
void AddLayoutInfo (TypeDefinition type)
{
- if (type.HasLayoutInfo) {
- var table = GetTable<ClassLayoutTable> (Table.ClassLayout);
+ var table = GetTable<ClassLayoutTable> (Table.ClassLayout);
- table.AddRow (new ClassLayoutRow (
- (ushort) type.PackingSize,
- (uint) type.ClassSize,
- type.token.RID));
-
- return;
- }
-
- if (type.IsValueType && HasNoInstanceField (type)) {
- var table = GetTable<ClassLayoutTable> (Table.ClassLayout);
-
- table.AddRow (new ClassLayoutRow (0, 1, type.token.RID));
- }
- }
-
- static bool HasNoInstanceField (TypeDefinition type)
- {
- if (!type.HasFields)
- return true;
-
- var fields = type.Fields;
-
- for (int i = 0; i < fields.Count; i++)
- if (!fields [i].IsStatic)
- return false;
-
- return true;
+ table.AddRow (new ClassLayoutRow (
+ (ushort) type.PackingSize,
+ (uint) type.ClassSize,
+ type.token.RID));
}
void AddNestedTypes (TypeDefinition type)
diff --git a/Test/Mono.Cecil.Tests/TypeTests.cs b/Test/Mono.Cecil.Tests/TypeTests.cs
index 8d7f3fa..fddc8e6 100644
--- a/Test/Mono.Cecil.Tests/TypeTests.cs
+++ b/Test/Mono.Cecil.Tests/TypeTests.cs
@@ -31,19 +31,6 @@ namespace Mono.Cecil.Tests {
}
[Test]
- public void EmptyStructLayout ()
- {
- TestModule ("hello.exe", module =>
- {
- var foo = new TypeDefinition ("", "Foo",
- TypeAttributes.Sealed | TypeAttributes.BeforeFieldInit | TypeAttributes.SequentialLayout,
- module.ImportReference (typeof (ValueType))) ;
-
- module.Types.Add (foo) ;
- }) ;
- }
-
- [Test]
public void SimpleInterfaces ()
{
TestIL ("types.il", module => {