Skip to content

Implement Migration Tool #774

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

Open
wants to merge 68 commits into
base: develop
Choose a base branch
from

Conversation

MahBoiDeveloper
Copy link
Contributor

@MahBoiDeveloper MahBoiDeveloper commented Jul 5, 2025

Closes #750

To Do List

  • Write patches for each release with major config changes
  • Add embedded missing images and copy them if they are absent in Resource folder
  • Fix Migration-INI.md wrong Edit GlobalThemeSettings.ini section
  • Test migration tool on Mental Omega config
  • Test migration tool on Twisted Insurrection config

@MahBoiDeveloper MahBoiDeveloper changed the title Migration Tool Implement Migration Tool Jul 5, 2025
Copy link

github-actions bot commented Jul 5, 2025

Nightly build for this pull request:

  • artifacts.zip
    This comment is automatic and is meant to allow guests to get latest automatic builds without registering. It is updated on every successful build.

@MahBoiDeveloper MahBoiDeveloper force-pushed the feature/migration-tool branch from 7f8f3ff to 028f8de Compare July 5, 2025 13:03
@MahBoiDeveloper MahBoiDeveloper force-pushed the feature/migration-tool branch from b5f5f57 to 0122a2f Compare July 5, 2025 16:11
@MahBoiDeveloper MahBoiDeveloper force-pushed the feature/migration-tool branch from ee55039 to e3f72ba Compare July 6, 2025 12:02
Copy link
Member

@SadPencil SadPencil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remaining tasks:

  • Assist Rampastring.Tools to allow editing the ini files without writing the parent ini to the child Rampastring/Rampastring.Tools#15
  • Don't remove the comments in an ini file
  • Investigate why the message box border (not the border in DrawBorders!) in Mental Omega disappears with @SadPencil, perhaps in Auguest
  • Cliam this tool is experimental and might have potential bugs even if it gets included in a stable release in xna-cncnet-client. Show a prompt that modders must backup their files and test in through after applying this migration tool and we have absolutely no warrently.
  • Address the wrong usage of string.Replace() method that triggers a CA1806 warning

@Metadorius
Copy link
Member

  • Don't remove the comments in an ini file

that one would be hard

@MahBoiDeveloper
Copy link
Contributor Author

  • Don't remove the comments in an ini file

Impossible to implement with current state of Rampastring.Tools

@SadPencil
Copy link
Member

  • Don't remove the comments in an ini file

Impossible to implement with current state of Rampastring.Tools

All right. Let's deal with the rest ones first.

@MahBoiDeveloper
Copy link
Contributor Author

Note that this null reference issue was fixed via changing patch = new Patch_v2_11_0(arg).Apply(); to patch = new Patch_v2_11_0(arg); patch.Apply();. And therefore, the return type of Apply() method has been changed to void in de40f80

Check new implementation that removes needs to manually add every new patch in apply list.

@SadPencil
Copy link
Member

SadPencil commented Jul 16, 2025

Just letting you know that I just merged the develop branch into this PR. You should encounter a compile error about the wrong string.Replace() usage. It could be easily fixed so I'll leave this fix to you.

@SadPencil
Copy link
Member

SadPencil commented Jul 16, 2025

Note that this null reference issue was fixed via changing patch = new Patch_v2_11_0(arg).Apply(); to patch = new Patch_v2_11_0(arg); patch.Apply();. And therefore, the return type of Apply() method has been changed to void in de40f80

Check new implementation that removes needs to manually add every new patch in apply list.

                        .OrderBy(type => type.FullName) // Used to order patches by their names

What if we released 2.12.10? Would the string be placed before 2.12.9? Also consider something like 2.12.9-rc.1

Therefore, I suggest you use a list of string to store these patch class names, instead of finding and sorting them. Activator.CreateInstance lines can be preserved in my opinion.

@MahBoiDeveloper
Copy link
Contributor Author

What if we released 2.12.10?

It would be applied after 2.12.9 and before 2.12.11 and before latest patch. Latest patch closes the list.

@SadPencil
Copy link
Member

SadPencil commented Jul 16, 2025

@SadPencil What if we released 2.12.10?

@MahBoiDeveloper It would be applied after 2.12.9 and before 2.12.11 and before latest patch. Latest patch closes the list.

It wouldn't be applied after 2.12.9 and before 2.12.11.

List<string> names = ["2.12.9-rc1", "2.12.9", "2.12.10"];
names=names.OrderBy(name=>name).ToList();
Console.Write(string.Join(", ", names));

Output:

2.12.10, 2.12.9, 2.12.9-rc1

That's why I suggest using a list of strings

.ToList()
.ForEach(type =>
{
var patch = (Patch)Activator.CreateInstance(type, arg);
Copy link
Member

@SadPencil SadPencil Jul 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that you need to save the patch variable outside of the try-catch scope. patch is always null in the catch block now.

var newPatch = CreateInstance();
patch = newPatch;
patch.Apply();

@MahBoiDeveloper
Copy link
Contributor Author

That's why I suggest using a list of strings

Set this list manually is a mistake. But I have found another way to organize this list. We can just use enum extension to get all values of Version enum.

image

@SadPencil
Copy link
Member

That's why I suggest using a list of strings

Set this list manually is a mistake. But I have found another way to organize this list. We can just use enum extension to get all values of Version enum.

image

seems good

@SadPencil
Copy link
Member

Including clientcore? What if polyfill requires a lot of dll files (like the updater in 2.12.0)

@MahBoiDeveloper
Copy link
Contributor Author

Including clientcore? What if polyfill requires a lot of dll files (like the updater in 2.12.0)

It is a good question how to include already existed enums into migration tool.

@SadPencil
Copy link
Member

Including clientcore? What if polyfill requires a lot of dll files (like the updater in 2.12.0)

It is a good question how to include already existed enums into migration tool.

Just repeat the definition for now? I don't have a better way

@MahBoiDeveloper
Copy link
Contributor Author

image

This doesn't feel right

@SadPencil
Copy link
Member

image

This doesn't feel right

yeah. Let's just repeat the definition.

@MahBoiDeveloper
Copy link
Contributor Author

yeah. Let's just repeat the definition.

@Metadorius what do you think? I agree with @SadPencil to reduce numbers of libs by repeating the definitions.

@Metadorius
Copy link
Member

Why can't you reuse the same libs the client uses?

BTW, this is one of the reasons I proposed for it to be a part of the client invoked as a command line parameter.

@MahBoiDeveloper
Copy link
Contributor Author

BTW, this is one of the reasons I proposed for it to be a part of the client invoked as a command line parameter.

Client assembly differences with libraries between different versions (like Rampastring.Tools.dll near to clientdx.exe that crash client on start) should not affect the migration tool. That's why I decided to make it as cli-tool in executable file.

@Metadorius
Copy link
Member

Client assembly differences with libraries between different versions (like Rampastring.Tools.dll near to clientdx.exe that crash client on start) should not affect the migration tool. That's why I decided to make it as cli-tool in executable file.

Do we really need to inconvenience ourselves that much because of issues of wrong binaries? IMO we would save a lot of hassle by not handling the problems with binaries. The migration tool doesn't apply 100% of the needed changes anyway, so it's not like we will lose a lot by not handling this.

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

Successfully merging this pull request may close these issues.

Migration tool
4 participants