Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 6 additions & 2 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,18 @@ 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 ());
Comment thread
jbevain marked this conversation as resolved.
Resolved

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

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