Skip to content

Commit 175ca20

Browse files
Removing some advanced syntax for strings
1 parent 1634293 commit 175ca20

File tree

5 files changed

+36
-15
lines changed

5 files changed

+36
-15
lines changed

B9PartSwitch/CustomPartModule.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ public override void OnLoad(ConfigNode node)
8484
}
8585
catch (Exception ex)
8686
{
87-
Exception ex2 = new Exception($"Fatal exception while loading fields on module {this}", ex);
87+
Exception ex2 = new Exception("Fatal exception while loading fields on module " + ex);
88+
//Exception ex2 = new Exception($"Fatal exception while loading fields on module {this}", ex);
8889
FatalErrorHandler.HandleFatalError(ex2);
8990
throw ex2;
9091
}
@@ -114,7 +115,8 @@ public override void OnSave(ConfigNode node)
114115
}
115116
catch (Exception ex)
116117
{
117-
Exception ex2 = new Exception($"Fatal exception while saving fields on module {this}", ex);
118+
Exception ex2 = new Exception("Fatal exception while saving fields on module " + ex);
119+
// Exception ex2 = new Exception($"Fatal exception while saving fields on module {this}", ex);
118120
FatalErrorHandler.HandleFatalError(ex2);
119121
throw ex2;
120122
}

B9PartSwitch/Extensions/ObjectExtensions.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ public static void ThrowIfNullArgument(this object o, string paramName)
2121

2222
public static void EnsureArgumentType(this object o, Type type, string paramName)
2323
{
24-
if (o.IsNotNull() && !o.GetType().Implements(type)) throw new ArgumentException($"Expected parameter of type {type} but got {o.GetType()}", paramName);
24+
if (o.IsNotNull() && !o.GetType().Implements(type))
25+
throw new ArgumentException("Expected parameter of type " + paramName + " but got {o.GetType()}");
26+
// throw new ArgumentException($"Expected parameter of type {type} but got {o.GetType()}", paramName);
2527
}
2628

2729
public static void EnsureArgumentType<T>(this object o, string paramName) => o.EnsureArgumentType(typeof(T), paramName);

B9PartSwitch/Extensions/PartExtensions.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,14 @@ public static PartResource AddOrCreateResource(this Part part, PartResourceDefin
4040
{
4141
if (amount > maxAmount)
4242
{
43-
part.LogWarning($"Cannot add resource '{info.name}' with amount > maxAmount, will use maxAmount (amount = {amount}, maxAmount = {maxAmount})");
43+
part.LogWarning("Cannot add resource '" + info.name + "' with amount > maxAmount, will use maxAmount (amount = " + amount + ", maxAmount = " + maxAmount+ ")");
44+
// part.LogWarning($"Cannot add resource '{info.name}' with amount > maxAmount, will use maxAmount (amount = {amount}, maxAmount = {maxAmount})");
4445
amount = maxAmount;
4546
}
4647
else if (amount < 0f)
4748
{
48-
part.LogWarning($"Cannot add resource '{info.name}' with amount < 0, will use 0 (amount = {amount})");
49+
part.LogWarning("Cannot add resource '" + info.name + "' with amount < 0, will use 0 (amount = " + amount + ")");
50+
//part.LogWarning($"Cannot add resource '{info.name}' with amount < 0, will use 0 (amount = {amount})");
4951
amount = 0f;
5052
}
5153

@@ -145,8 +147,12 @@ public static void FixModuleJettison(this Part part)
145147
}
146148
}
147149

148-
public static void LogInfo(this Part part, object message) => Debug.Log($"[Part {part.name}] {message}");
149-
public static void LogWarning(this Part part, object message) => Debug.LogWarning($"[WARNING] [Part {part.name}] {message}");
150-
public static void LogError(this Part part, object message) => Debug.LogError($"[ERROR] [Part {part.name}] {message}");
150+
public static void LogInfo(this Part part, object message) => Debug.Log("[Part " + part.name+ "] " +message);
151+
public static void LogWarning(this Part part, object message) => Debug.LogWarning("[WARNING] [Part " + part.name + "] " + message);
152+
public static void LogError(this Part part, object message) => Debug.LogError("[ERROR] [Part " + part.name + "] " + message);
153+
154+
// public static void LogInfo(this Part part, object message) => Debug.Log($"[Part {part.name}] {message}");
155+
// public static void LogWarning(this Part part, object message) => Debug.LogWarning($"[WARNING] [Part {part.name}] {message}");
156+
// public static void LogError(this Part part, object message) => Debug.LogError($"[ERROR] [Part {part.name}] {message}");
151157
}
152158
}

B9PartSwitch/Extensions/PartModuleExtensions.cs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,25 @@ public static void SetUiGroups(this PartModule module, string uiGroupName, strin
2828

2929
#region Logging
3030

31-
public static void LogInfo(this PartModule module, object message) => module.part.LogInfo($"{module.LogTagString()} {message}");
32-
public static void LogWarning(this PartModule module, object message) => module.part.LogWarning($"{module.LogTagString()} {message}");
33-
public static void LogError(this PartModule module, object message) => module.part.LogError($"{module.LogTagString()} {message}");
31+
32+
public static void LogInfo(this PartModule module, object message) => module.part.LogInfo(module.LogTagString()+ " " + message);
33+
public static void LogWarning(this PartModule module, object message) => module.part.LogWarning(module.LogTagString() + " " +message);
34+
public static void LogError(this PartModule module, object message) => module.part.LogError(module.LogTagString() + " " + message);
35+
36+
// public static void LogInfo(this PartModule module, object message) => module.part.LogInfo($"{module.LogTagString()} {message}");
37+
// public static void LogWarning(this PartModule module, object message) => module.part.LogWarning($"{module.LogTagString()} {message}");
38+
// public static void LogError(this PartModule module, object message) => module.part.LogError($"{module.LogTagString()} {message}");
3439

3540
public static string LogTagString(this PartModule module)
3641
{
3742
string info = module.GetType().Name;
3843

3944
if (module is CustomPartModule utilModule && !utilModule.moduleID.IsNullOrEmpty())
40-
info += $" '{utilModule.moduleID}'";
45+
info += " '" + utilModule.moduleID + "'";
46+
// info += $" '{utilModule.moduleID}'";
4147

42-
return $"[{info}]";
48+
return "[" + info + "]";
49+
// return $"[{info}]";
4350
}
4451

4552
#endregion

B9PartSwitch/ModuleMatcher.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,12 @@ public PartModule FindModule(Part part)
6464

6565
public ConfigNode FindPrefabNode(PartModule module)
6666
{
67-
if (module.part.partInfo is not AvailablePart partInfo) throw new InvalidOperationException($"partInfo is null on part {module.part.name}");
68-
if (partInfo.partConfig is not ConfigNode partConfig) throw new InvalidOperationException($"partInfo.partConfig is null on part {partInfo.name}");
67+
if (module.part.partInfo is not AvailablePart partInfo)
68+
throw new InvalidOperationException("partInfo is null on part " + module.part.name);
69+
// throw new InvalidOperationException($"partInfo is null on part {module.part.name}");
70+
if (partInfo.partConfig is not ConfigNode partConfig)
71+
throw new InvalidOperationException("partInfo.partConfig is null on part " + partInfo.name);
72+
// throw new InvalidOperationException($"partInfo.partConfig is null on part {partInfo.name}");
6973

7074
ConfigNode matchedNode = null;
7175

0 commit comments

Comments
 (0)