Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error message when nested type isn't matched #13

Open
fireundubh opened this issue Oct 21, 2018 · 2 comments
Open

Improve error message when nested type isn't matched #13

fireundubh opened this issue Oct 21, 2018 · 2 comments

Comments

@fireundubh
Copy link

Exception Details

System.NullReferenceException: Object reference not set to an instance of an object.
   at Patchwork.Engine.Utility.CecilOverloadResolver.GetField(TypeDefinition typeDef, String name) in E:\projects\PatchworkPathfinder\Patchwork.Engine\Utility\Reflections and Cecil\CecilOverloadResolver.cs:line 20
   at Patchwork.Engine.PatchingManifest.GetPatchedMember[T](TypeDefinition targetType, T yourMemberDef, MemberActionAttribute actionAttribute) in E:\projects\PatchworkPathfinder\Patchwork.Engine\PatchingManifest\PatchingManifest.cs:line 107
   at Patchwork.Engine.PatchingManifest.SpecializeMembers[T](SimpleTypeLookup`1 lookup, AssemblyDefinition toTargetAssembly) in E:\projects\PatchworkPathfinder\Patchwork.Engine\PatchingManifest\PatchingManifest.cs:line 135
   at Patchwork.Engine.PatchingManifest.Specialize(AssemblyDefinition assemblyDef) in E:\projects\PatchworkPathfinder\Patchwork.Engine\PatchingManifest\PatchingManifest.cs:line 166
   at Patchwork.Engine.AssemblyPatcher.PatchManifest(PatchingManifest manifest, IProgressMonitor o) in E:\projects\PatchworkPathfinder\Patchwork.Engine\AssemblyPatcher\AssemblyPatcher.cs:line 300
   at PatchworkLauncher.LaunchManager.ApplyInstructions(IEnumerable`1 patchGroups, ProgressObject po) in E:\projects\PatchworkPathfinder\PatchworkLauncher\GUI\LaunchManager.cs:line 747
   at PatchworkLauncher.LaunchManager.<>c__DisplayClass46_1.<Command_Patch>b__0() in E:\projects\PatchworkPathfinder\PatchworkLauncher\GUI\LaunchManager.cs:line 369
   at System.Threading.Tasks.Task.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at PatchworkLauncher.LaunchManager.<Command_Patch>d__46.MoveNext() in E:\projects\PatchworkPathfinder\PatchworkLauncher\GUI\LaunchManager.cs:line 369

Sample Code

namespace KingmakerMods.Mods.Game.Configurables.GoldPoints
{
	[ModifiesType]
	public class BuildingItemNew : Kingmaker.UI.Settlement.BuildingItem
	{
		[ModifiesType("Kingmaker.UI.Settlement.BuildingItem.RequiredStaff")]
		private class RequiredStaffNew
		{
			[ModifiesMember("Slots")]
			public Image source_Slots;
		}
	}
}
@fireundubh
Copy link
Author

Nevermind. I can't read, apparently.

In the IL and in Mono.Cecil, as well as in this framework, you use / to indicate nesting. E.g. Namespace.ContainerClass/Nested/NestedNested.

Would a clearer exception message be better, perhaps?

@GregRos GregRos reopened this Oct 27, 2018
@GregRos
Copy link
Owner

GregRos commented Oct 27, 2018

Would a clearer exception message be better, perhaps?

Yes, it would 😄

From your experience, I think the overall most important improvement that can be made to the library right now is error messages 😄 That's great! It gives me a direction of how to improve it.

@GregRos GregRos changed the title NullReferenceException when modifying members of private nested type Improve error message when nested type isn't matched Oct 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants