1using System.Reflection;
2using System.Runtime.InteropServices;
41 public static string PlatformTag = RuntimeInformation.OSDescription;
50 public static string Version {
get;
set; }
59 AssemblyName assemblyName =
new(assembly.FullName!);
60 Version = $
"{assemblyName.Version!.Major}.{assemblyName.Version.Minor}.{assemblyName.Version.Build}.{assemblyName.Version.Revision}";
62#pragma warning disable IL2026
63 foreach (TypeInfo definedType
in assembly.DefinedTypes) {
64#pragma warning restore IL2026
65 if (!definedType.IsAbstract
66 && !definedType.IsInterface
68#pragma warning disable IL2072
70#pragma warning restore IL2072
86 ??
throw new InvalidOperationException(
87 $
"Cannot find conversion path from version \"{attributeValue}\" to version \"{SerializationVersion}\""
89 Log.
Information($
"Upgrading world version \"{item.SourceVersion}\" to \"{item.TargetVersion}\".");
94 throw new InvalidOperationException(
95 $
"Upgrade produced invalid project version. Expected \"{SerializationVersion}\", found \"{attributeValue2}\"."
103 if (worldInfo ==
null) {
104 throw new InvalidOperationException($
"Cannot determine version of world at \"{directoryName}\"");
109 ??
throw new InvalidOperationException(
110 $
"Cannot find conversion path from version \"{worldInfo.SerializationVersion}\" to version \"{SerializationVersion}\""
112 Log.
Information($
"Upgrading world version \"{item.SourceVersion}\" to \"{item.TargetVersion}\".");
117 throw new InvalidOperationException(
118 $
"Upgrade produced invalid project version. Expected \"{SerializationVersion}\", found \"{worldInfo2.SerializationVersion}\"."
125 string[] array = v1.Split(
'.');
126 string[] array2 = v2.Split(
'.');
127 for (
int i = 0; i <
MathUtils.
Min(array.Length, array2.Length); i++) {
128 int num = !
int.TryParse(array[i], out
int result) || !
int.TryParse(array2[i], out
int result2)
129 ?
string.CompareOrdinal(array[i], array2[i])
135 return array.Length - array2.Length;
139 string targetVersion,
140 IEnumerable<VersionConverter> converters,
143 throw new InvalidOperationException(
144 "Too deep recursion when searching for version converters. Check for possible loops in transforms."
147 if (sourceVersion == targetVersion) {
150 List<VersionConverter> result =
null;
151 int num = 2147483647;
152 IEnumerable<VersionConverter> versionConverters = converters as List<VersionConverter> ?? converters.ToList();
157 && list.Count < num) {
159 list.Insert(0, converter);
System.Environment Environment
static void Information(object message)
static int Min(int x1, int x2)
static void UpdateProgress(string operationName, float progress)
static string LastLaunchedVersion
virtual void ConvertProjectXml(XElement projectNode)
virtual void ConvertWorld(string directoryName)
static BuildConfiguration BuildConfiguration
static string SerializationVersion
static List< VersionConverter > FindTransform(string sourceVersion, string targetVersion, IEnumerable< VersionConverter > converters, int depth)
static Platform CurrentPlatform
static string PlatformTag
static List< VersionConverter > m_versionConverters
static int CompareVersions(string v1, string v2)
static string LastLaunchedVersion
static void UpgradeWorld(string directoryName)
static string PlatformString
static PlatformID PlatformID
Win32NT:Windows Unix:Linux
static void UpgradeProjectXml(XElement projectNode)
string SerializationVersion
static WorldInfo GetWorldInfo(string directoryName)
static object GetAttributeValue(XElement node, string attributeName, Type type)