Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions Mono.Cecil/ModuleDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ public sealed class ModuleDefinition : ModuleReference, ICustomAttributeProvider

internal AssemblyDefinition assembly;
MethodDefinition entry_point;
bool entry_point_set;

internal IReflectionImporter reflection_importer;
internal IMetadataImporter metadata_importer;
Expand Down Expand Up @@ -539,15 +540,21 @@ public Collection<ExportedType> ExportedTypes {

public MethodDefinition EntryPoint {
get {
if (entry_point != null)
if (entry_point_set)
return entry_point;

if (HasImage)
return Read (ref entry_point, this, (_, reader) => reader.ReadEntryPoint ());
Read (ref entry_point, this, (_, reader) => reader.ReadEntryPoint ());
else
entry_point = null;

return entry_point = null;
entry_point_set = true;
return entry_point;
}
set {
entry_point = value;
entry_point_set = true;
}
set { entry_point = value; }
}

public bool HasCustomDebugInformations {
Expand Down
6 changes: 6 additions & 0 deletions Test/Mono.Cecil.Tests/ModuleTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ public void EntryPoint ()
Assert.IsNotNull (entry_point);

Assert.AreEqual ("System.Void Program::Main()", entry_point.ToString ());

module.EntryPoint = null;
Assert.IsNull (module.EntryPoint);

module.EntryPoint = entry_point;
Assert.IsNotNull (module.EntryPoint);
});
}

Expand Down