Fixed Csharp/Shared path resolution in ModConfigService.

This commit is contained in:
MapleWheels
2026-03-04 14:51:31 -05:00
parent d0969cc723
commit ce8b984542
@@ -266,7 +266,7 @@ public sealed class ModConfigService : IModConfigService
LuaScripts = GetLuaScriptsLegacy(src) LuaScripts = GetLuaScriptsLegacy(src)
}; };
ImmutableArray<IAssemblyResourceInfo> GetAssembliesLegacy(ContentPackage src) ImmutableArray<IAssemblyResourceInfo> GetAssembliesLegacy(ContentPackage srcPackage)
{ {
var binSearchInd = new (string SubFolder, Target Targets, Platform Platforms)[] var binSearchInd = new (string SubFolder, Target Targets, Platform Platforms)[]
{ {
@@ -282,19 +282,19 @@ public sealed class ModConfigService : IModConfigService
foreach (var searchPathways in binSearchInd) foreach (var searchPathways in binSearchInd)
{ {
if (_storageService.FindFilesInPackage(src, searchPathways.SubFolder, "*.dll", if (_storageService.FindFilesInPackage(srcPackage, searchPathways.SubFolder, "*.dll",
true) is { IsSuccess: true, Value.IsDefaultOrEmpty: false } result) true) is { IsSuccess: true, Value.IsDefaultOrEmpty: false } result)
{ {
builder.Add(new AssemblyResourceInfo() builder.Add(new AssemblyResourceInfo()
{ {
OwnerPackage = src, OwnerPackage = srcPackage,
InternalName = searchPathways.SubFolder, InternalName = searchPathways.SubFolder,
SupportedPlatforms = searchPathways.Platforms, SupportedPlatforms = searchPathways.Platforms,
SupportedTargets = searchPathways.Targets, SupportedTargets = searchPathways.Targets,
LoadPriority = 0, LoadPriority = 0,
FilePaths = result.Value.Select(fp => ContentPath.FromRaw(src, $"%ModDir%/{Path.GetRelativePath(src.Dir, fp)}".CleanUpPathCrossPlatform())) FilePaths = result.Value.Select(fp => ContentPath.FromRaw(srcPackage, $"%ModDir%/{Path.GetRelativePath(srcPackage.Dir, fp)}".CleanUpPathCrossPlatform()))
.ToImmutableArray(), .ToImmutableArray(),
FriendlyName = $"{src.Name}.{searchPathways.SubFolder.Replace('/','.')}", FriendlyName = $"{srcPackage.Name}.{searchPathways.SubFolder.Replace('/','.')}",
IncompatiblePackages = ImmutableArray<Identifier>.Empty, IncompatiblePackages = ImmutableArray<Identifier>.Empty,
RequiredPackages = ImmutableArray<Identifier>.Empty, RequiredPackages = ImmutableArray<Identifier>.Empty,
IsScript = false, IsScript = false,
@@ -303,12 +303,12 @@ public sealed class ModConfigService : IModConfigService
} }
} }
var sharedResult = _storageService.FindFilesInPackage(src, var sharedResult = _storageService.FindFilesInPackage(srcPackage,
Path.Combine(src.Dir, "CSharp/Shared"), Path.Combine("CSharp/Shared"),
"*.cs", true); "*.cs", true);
var sharedFiles = sharedResult.IsSuccess && !sharedResult.Value.IsDefaultOrEmpty var sharedFiles = sharedResult.IsSuccess && !sharedResult.Value.IsDefaultOrEmpty
? sharedResult.Value.Select(fp => ? sharedResult.Value.Select(fp =>
ContentPath.FromRaw(src, $"%ModDir%/{Path.GetRelativePath(src.Dir, fp)}".CleanUpPathCrossPlatform())) ContentPath.FromRaw(srcPackage, $"%ModDir%/{Path.GetRelativePath(srcPackage.Dir, fp)}".CleanUpPathCrossPlatform()))
.ToImmutableArray() .ToImmutableArray()
: ImmutableArray<ContentPath>.Empty; : ImmutableArray<ContentPath>.Empty;
@@ -320,19 +320,19 @@ public sealed class ModConfigService : IModConfigService
foreach (var searchPathways in srcSearchInd) foreach (var searchPathways in srcSearchInd)
{ {
if (_storageService.FindFilesInPackage(src, searchPathways.SubFolder, "*.cs", if (_storageService.FindFilesInPackage(srcPackage, searchPathways.SubFolder, "*.cs",
true) is { IsSuccess: true, Value.IsDefaultOrEmpty: false } result) true) is { IsSuccess: true, Value.IsDefaultOrEmpty: false } result)
{ {
builder.Add(new AssemblyResourceInfo() builder.Add(new AssemblyResourceInfo()
{ {
OwnerPackage = src, OwnerPackage = srcPackage,
InternalName = searchPathways.SubFolder, InternalName = searchPathways.SubFolder,
SupportedPlatforms = searchPathways.Platforms, SupportedPlatforms = searchPathways.Platforms,
SupportedTargets = searchPathways.Targets, SupportedTargets = searchPathways.Targets,
LoadPriority = 0, LoadPriority = 0,
FilePaths = result.Value FilePaths = result.Value
.Select(fp => ContentPath.FromRaw(src, .Select(fp => ContentPath.FromRaw(srcPackage,
$"%ModDir%/{Path.GetRelativePath(src.Dir, fp)}".CleanUpPathCrossPlatform())) $"%ModDir%/{Path.GetRelativePath(srcPackage.Dir, fp)}".CleanUpPathCrossPlatform()))
.Concat(sharedFiles).ToImmutableArray(), .Concat(sharedFiles).ToImmutableArray(),
FriendlyName = IAssemblyLoaderService.InternalsAwareAssemblyName, FriendlyName = IAssemblyLoaderService.InternalsAwareAssemblyName,
IncompatiblePackages = ImmutableArray<Identifier>.Empty, IncompatiblePackages = ImmutableArray<Identifier>.Empty,