tModLoader / tModLoader

A mod to make and play Terraria mods. Supports Terraria 1.4 (and earlier) installations
https://www.tmodloader.net/
MIT License
4.18k stars 1.88k forks source link

Better source support. #2336

Open Chicken-Bones opened 2 years ago

Chicken-Bones commented 2 years ago

Do you intend to personally contribute/program this feature?

Yes

I would like to see this change made to improve my experience with

Mod capability as a Modder

Description

We need better instructions, and preferably better .csproj setup (via the .targets file) for modders working with tML source, either via git, or on preview/stable.

One option might be pdbs which include source.

What does this proposal attempt to solve or improve?

When building a mod, you need to have tML source open in a separate VS project. Creating a merged solution is difficult, and without one, navigation to tML types from mod source shows metadata, and you can't set breakpoints.

Which (other) solutions should be considered?

No response

JavidPack commented 2 years ago

Someone asked about this earlier this week on discord as well.

For me, I was able to add the following to my mods csproj:

<ItemGroup>
  <Reference Remove="$(tMLSteamPath)$(tMLPath)" />
  <ProjectReference Include="..\..\..\Modding\tModLoader14\src\tModLoader\Terraria\Terraria.csproj" />
</ItemGroup>

Then, I added the src\tModLoader\Terraria\Terraria.csproj project to my ModSouces.sln. I built tmodloader, then launched my mod in debug mode. I was able to set breakpoints in both my mod and tmodloader from the same VS instance. Edit and continue also worked in both as well.

So, for someone willing to generate the source, it seems to all work in my limited testing. Of course, a pdb that has source might be better, not sure how that all works out. Would we really be able to put breakpoints and debug with just a pdb? Maybe we can automate checking if the Terraria project exists and adjust project references automatically, or maybe automate every mod sources folder being populated with a decompiled tmod project. Just some thoughs.

Here is a google result that seemed similar to our situation Conditional project or library reference in Visual Studio

Chicken-Bones commented 2 years ago

For the workflow of "Install tML via steam. Go to Mod Sources menu. Create mod. Open in VS" there is:

The major option I'm looking into is source link, or embedded sources in PDBs, but there's also no reason why a simple button in Mod Sources couldn't clone the right commit from git and run the setup tool for you.