Fixes string interpolation

This commit is contained in:
Kamron Batman 2018-09-14 13:07:43 -07:00
parent 42d0b6271f
commit 7d3a0ca265
233 changed files with 758 additions and 690 deletions

View file

@ -173,7 +173,7 @@ namespace Server
public override string ToString()
{
return string.Format( "0x{0:X}", m_BodyID );
return $"0x{m_BodyID:X}";
}
public override int GetHashCode()

View file

@ -99,7 +99,7 @@ namespace Server.Diagnostics {
}
public PacketReceiveProfile( int packetId )
: base( String.Format( "0x{0:X2}", packetId ) ) {
: base($"0x{packetId:X2}") {
}
}
}

View file

@ -56,7 +56,7 @@ namespace Server
public override string ToString()
{
return String.Format( "({0}, {1})", m_X, m_Y );
return $"({m_X}, {m_Y})";
}
public static Point2D Parse( string value )
@ -256,7 +256,7 @@ namespace Server
public override string ToString()
{
return String.Format( "({0}, {1}, {2})", m_X, m_Y, m_Z );
return $"({m_X}, {m_Y}, {m_Z})";
}
public override bool Equals( object o )
@ -473,7 +473,7 @@ namespace Server
public override string ToString()
{
return String.Format( "({0}, {1})+({2}, {3})", X, Y, Width, Height );
return $"({X}, {Y})+({Width}, {Height})";
}
}

View file

@ -127,7 +127,7 @@ namespace Server.Guilds
public override string ToString()
{
return String.Format( "0x{0:X} \"{1} [{2}]\"", m_Id, Name, Abbreviation );
return $"0x{m_Id:X} \"{Name} [{Abbreviation}]\"";
}
}
}

View file

@ -62,7 +62,7 @@ namespace Server.Gumps
public override string Compile( NetState ns )
{
return String.Format( "{{ checkertrans {0} {1} {2} {3} }}", m_X, m_Y, m_Width, m_Height );
return $"{{ checkertrans {m_X} {m_Y} {m_Width} {m_Height} }}";
}
private static byte[] m_LayoutName = Gump.StringToBuffer( "checkertrans" );

View file

@ -70,7 +70,7 @@ namespace Server.Gumps
public override string Compile( NetState ns )
{
return String.Format( "{{ resizepic {0} {1} {2} {3} {4} }}", m_X, m_Y, m_GumpID, m_Width, m_Height );
return $"{{ resizepic {m_X} {m_Y} {m_GumpID} {m_Width} {m_Height} }}";
}
private static byte[] m_LayoutName = Gump.StringToBuffer( "resizepic" );

View file

@ -105,7 +105,7 @@ namespace Server.Gumps
public override string Compile( NetState ns )
{
return String.Format( "{{ button {0} {1} {2} {3} {4} {5} {6} }}", m_X, m_Y, m_ID1, m_ID2, (int)m_Type, m_Param, m_ButtonID );
return $"{{ button {m_X} {m_Y} {m_ID1} {m_ID2} {(int) m_Type} {m_Param} {m_ButtonID} }}";
}
private static byte[] m_LayoutName = Gump.StringToBuffer( "button" );

View file

@ -78,7 +78,7 @@ namespace Server.Gumps
public override string Compile( NetState ns )
{
return String.Format( "{{ checkbox {0} {1} {2} {3} {4} {5} }}", m_X, m_Y, m_ID1, m_ID2, m_InitialState ? 1 : 0, m_SwitchID );
return $"{{ checkbox {m_X} {m_Y} {m_ID1} {m_ID2} {(m_InitialState ? 1 : 0)} {m_SwitchID} }}";
}
private static byte[] m_LayoutName = Gump.StringToBuffer( "checkbox" );

View file

@ -40,7 +40,7 @@ namespace Server.Gumps
public override string Compile( NetState ns )
{
return String.Format( "{{ group {0} }}", m_Group );
return $"{{ group {m_Group} }}";
}
private static byte[] m_LayoutName = Gump.StringToBuffer( "group" );

View file

@ -85,7 +85,8 @@ namespace Server.Gumps
public override string Compile( NetState ns )
{
return String.Format( "{{ htmlgump {0} {1} {2} {3} {4} {5} {6} }}", m_X, m_Y, m_Width, m_Height, Parent.Intern( m_Text ), m_Background ? 1 : 0, m_Scrollbar ? 1 : 0 );
return
$"{{ htmlgump {m_X} {m_Y} {m_Width} {m_Height} {Parent.Intern(m_Text)} {(m_Background ? 1 : 0)} {(m_Scrollbar ? 1 : 0)} }}";
}
private static byte[] m_LayoutName = Gump.StringToBuffer( "htmlgump" );

View file

@ -159,13 +159,16 @@ namespace Server.Gumps
switch ( m_Type )
{
case GumpHtmlLocalizedType.Plain:
return String.Format( "{{ xmfhtmlgump {0} {1} {2} {3} {4} {5} {6} }}", m_X, m_Y, m_Width, m_Height, m_Number, m_Background ? 1 : 0, m_Scrollbar ? 1 : 0 );
return
$"{{ xmfhtmlgump {m_X} {m_Y} {m_Width} {m_Height} {m_Number} {(m_Background ? 1 : 0)} {(m_Scrollbar ? 1 : 0)} }}";
case GumpHtmlLocalizedType.Color:
return String.Format( "{{ xmfhtmlgumpcolor {0} {1} {2} {3} {4} {5} {6} {7} }}", m_X, m_Y, m_Width, m_Height, m_Number, m_Background ? 1 : 0, m_Scrollbar ? 1 : 0, m_Color );
return
$"{{ xmfhtmlgumpcolor {m_X} {m_Y} {m_Width} {m_Height} {m_Number} {(m_Background ? 1 : 0)} {(m_Scrollbar ? 1 : 0)} {m_Color} }}";
default: // GumpHtmlLocalizedType.Args
return String.Format( "{{ xmfhtmltok {0} {1} {2} {3} {4} {5} {6} {7} @{8}@ }}", m_X, m_Y, m_Width, m_Height, m_Background ? 1 : 0, m_Scrollbar ? 1 : 0, m_Color, m_Number, m_Args );
return
$"{{ xmfhtmltok {m_X} {m_Y} {m_Width} {m_Height} {(m_Background ? 1 : 0)} {(m_Scrollbar ? 1 : 0)} {m_Color} {m_Number} @{m_Args}@ }}";
}
}

View file

@ -68,9 +68,9 @@ namespace Server.Gumps
public override string Compile( NetState ns )
{
if ( m_Hue == 0 )
return String.Format( "{{ gumppic {0} {1} {2} }}", m_X, m_Y, m_GumpID );
return $"{{ gumppic {m_X} {m_Y} {m_GumpID} }}";
else
return String.Format( "{{ gumppic {0} {1} {2} hue={3} }}", m_X, m_Y, m_GumpID, m_Hue );
return $"{{ gumppic {m_X} {m_Y} {m_GumpID} hue={m_Hue} }}";
}
private static byte[] m_LayoutName = Gump.StringToBuffer( "gumppic" );

View file

@ -148,9 +148,11 @@ namespace Server.Gumps
public override string Compile( NetState ns )
{
if ( m_LocalizedTooltip > 0 )
return String.Format( "{{ buttontileart {0} {1} {2} {3} {4} {5} {6} {7} {8} {9} {10} }}{{ tooltip {11} }}", m_X, m_Y, m_ID1, m_ID2, (int)m_Type, m_Param, m_ButtonID, m_ItemID, m_Hue, m_Width, m_Height, m_LocalizedTooltip );
return
$"{{ buttontileart {m_X} {m_Y} {m_ID1} {m_ID2} {(int) m_Type} {m_Param} {m_ButtonID} {m_ItemID} {m_Hue} {m_Width} {m_Height} }}{{ tooltip {m_LocalizedTooltip} }}";
else
return String.Format( "{{ buttontileart {0} {1} {2} {3} {4} {5} {6} {7} {8} {9} {10} }}", m_X, m_Y, m_ID1, m_ID2, (int)m_Type, m_Param, m_ButtonID, m_ItemID, m_Hue, m_Width, m_Height );
return
$"{{ buttontileart {m_X} {m_Y} {m_ID1} {m_ID2} {(int) m_Type} {m_Param} {m_ButtonID} {m_ItemID} {m_Hue} {m_Width} {m_Height} }}";
}
private static byte[] m_LayoutName = Gump.StringToBuffer( "buttontileart" );

View file

@ -70,7 +70,7 @@ namespace Server.Gumps
public override string Compile( NetState ns )
{
return String.Format( "{{ gumppictiled {0} {1} {2} {3} {4} }}", m_X, m_Y, m_Width, m_Height, m_GumpID );
return $"{{ gumppictiled {m_X} {m_Y} {m_Width} {m_Height} {m_GumpID} }}";
}
private static byte[] m_LayoutName = Gump.StringToBuffer( "gumppictiled" );

View file

@ -68,9 +68,9 @@ namespace Server.Gumps
public override string Compile( NetState ns )
{
if ( m_Hue == 0 )
return String.Format( "{{ tilepic {0} {1} {2} }}", m_X, m_Y, m_ItemID );
return $"{{ tilepic {m_X} {m_Y} {m_ItemID} }}";
else
return String.Format( "{{ tilepichue {0} {1} {2} {3} }}", m_X, m_Y, m_ItemID, m_Hue );
return $"{{ tilepichue {m_X} {m_Y} {m_ItemID} {m_Hue} }}";
}
private static byte[] m_LayoutName = Gump.StringToBuffer( "tilepic" );

View file

@ -40,7 +40,7 @@ namespace Server.Gumps
public override string Compile( NetState ns )
{
return String.Format( "{{ itemproperty {0} }}", m_Serial );
return $"{{ itemproperty {m_Serial} }}";
}
private static byte[] m_LayoutName = Gump.StringToBuffer( "itemproperty" );

View file

@ -63,7 +63,7 @@ namespace Server.Gumps
public override string Compile( NetState ns )
{
return String.Format( "{{ text {0} {1} {2} {3} }}", m_X, m_Y, m_Hue, Parent.Intern( m_Text ) );
return $"{{ text {m_X} {m_Y} {m_Hue} {Parent.Intern(m_Text)} }}";
}
private static byte[] m_LayoutName = Gump.StringToBuffer( "text" );

View file

@ -78,7 +78,7 @@ namespace Server.Gumps
public override string Compile( NetState ns )
{
return String.Format( "{{ croppedtext {0} {1} {2} {3} {4} {5} }}", m_X, m_Y, m_Width, m_Height, m_Hue, Parent.Intern( m_Text ) );
return $"{{ croppedtext {m_X} {m_Y} {m_Width} {m_Height} {m_Hue} {Parent.Intern(m_Text)} }}";
}
private static byte[] m_LayoutName = Gump.StringToBuffer( "croppedtext" );

View file

@ -40,7 +40,7 @@ namespace Server.Gumps
public override string Compile( NetState ns )
{
return String.Format( "{{ page {0} }}", m_Page );
return $"{{ page {m_Page} }}";
}
private static byte[] m_LayoutName = Gump.StringToBuffer( "page" );

View file

@ -78,7 +78,7 @@ namespace Server.Gumps
public override string Compile( NetState ns )
{
return String.Format( "{{ radio {0} {1} {2} {3} {4} {5} }}", m_X, m_Y, m_ID1, m_ID2, m_InitialState ? 1 : 0, m_SwitchID );
return $"{{ radio {m_X} {m_Y} {m_ID1} {m_ID2} {(m_InitialState ? 1 : 0)} {m_SwitchID} }}";
}
private static byte[] m_LayoutName = Gump.StringToBuffer( "radio" );

View file

@ -86,7 +86,8 @@ namespace Server.Gumps
public override string Compile( NetState ns )
{
return String.Format( "{{ textentry {0} {1} {2} {3} {4} {5} {6} }}", m_X, m_Y, m_Width, m_Height, m_Hue, m_EntryID, Parent.Intern( m_InitialText ) );
return
$"{{ textentry {m_X} {m_Y} {m_Width} {m_Height} {m_Hue} {m_EntryID} {Parent.Intern(m_InitialText)} }}";
}
private static byte[] m_LayoutName = Gump.StringToBuffer( "textentry" );

View file

@ -82,7 +82,8 @@ namespace Server.Gumps {
}
public override string Compile( NetState ns ) {
return String.Format( "{{ textentrylimited {0} {1} {2} {3} {4} {5} {6} {7} }}", m_X, m_Y, m_Width, m_Height, m_Hue, m_EntryID, Parent.Intern( m_InitialText ), m_Size );
return
$"{{ textentrylimited {m_X} {m_Y} {m_Width} {m_Height} {m_Hue} {m_EntryID} {Parent.Intern(m_InitialText)} {m_Size} }}";
}
private static byte[] m_LayoutName = Gump.StringToBuffer( "textentrylimited" );

View file

@ -40,7 +40,7 @@ namespace Server.Gumps
public override string Compile( NetState ns )
{
return String.Format( "{{ tooltip {0} }}", m_Number );
return $"{{ tooltip {m_Number} }}";
}
private static byte[] m_LayoutName = Gump.StringToBuffer( "tooltip" );

View file

@ -4375,7 +4375,8 @@ namespace Server
if ( m_Amount <= 1 )
ns.Send( new MessageLocalized( m_Serial, m_ItemID, MessageType.Label, 0x3B2, 3, LabelNumber, "", "" ) );
else
ns.Send( new MessageLocalizedAffix( m_Serial, m_ItemID, MessageType.Label, 0x3B2, 3, LabelNumber, "", AffixType.Append, String.Format( " : {0}", m_Amount ), "" ) );
ns.Send( new MessageLocalizedAffix( m_Serial, m_ItemID, MessageType.Label, 0x3B2, 3, LabelNumber, "", AffixType.Append,
$" : {m_Amount}", "" ) );
}
else
{
@ -4538,7 +4539,7 @@ namespace Server
public override string ToString()
{
return String.Format( "0x{0:X} \"{1}\"", m_Serial.Value, GetType().Name );
return $"0x{m_Serial.Value:X} \"{GetType().Name}\"";
}
internal int m_TypeRef;

View file

@ -48,7 +48,8 @@ namespace Server.Items
if ( m_Owner != null )
{
m_Owner.PrivateOverheadMessage( MessageType.Regular, 0x3B2, true, String.Format( "Bank container has {0} items, {1} stones", TotalItems, TotalWeight ), m_Owner.NetState );
m_Owner.PrivateOverheadMessage( MessageType.Regular, 0x3B2, true,
$"Bank container has {TotalItems} items, {TotalWeight} stones", m_Owner.NetState );
m_Owner.Send( new EquipUpdate( this ) );
DisplayTo( m_Owner );
}

View file

@ -118,7 +118,7 @@ namespace Server
{
base.GetProperties(list);
list.Add(1060738, String.Format("{0:#,0} platinum, {1:#,0} gold", Plat, Gold)); // value: ~1_val~
list.Add(1060738, $"{Plat:#,0} platinum, {Gold:#,0} gold"); // value: ~1_val~
}
public void UpdateTrade(Mobile user)
@ -268,10 +268,8 @@ namespace Server
AddImage(10, 8, 113);
AddImage(360, 8, 113);
var title = String.Format(
"<BASEFONT COLOR=#{0:X}><CENTER>BANK OF {1}</CENTER>",
Color.DarkSlateGray.ToArgb(),
User.RawName.ToUpper());
var title =
$"<BASEFONT COLOR=#{Color.DarkSlateGray.ToArgb():X}><CENTER>BANK OF {User.RawName.ToUpper()}</CENTER>";
AddHtml(40, 15, 320, 20, title, false, false);

View file

@ -225,7 +225,7 @@ namespace Server
if (Core.Unix)
{
parms.CompilerOptions = String.Format("{0} /nowarn:169,219,414 /recurse:Scripts/*.cs", parms.CompilerOptions);
parms.CompilerOptions = $"{parms.CompilerOptions} /nowarn:169,219,414 /recurse:Scripts/*.cs";
files = new string[0];
}
@ -366,7 +366,7 @@ namespace Server
if (Core.Unix)
{
parms.CompilerOptions = String.Format("{0} /nowarn:169,219,414 /recurse:Scripts/*.vb", parms.CompilerOptions);
parms.CompilerOptions = $"{parms.CompilerOptions} /nowarn:169,219,414 /recurse:Scripts/*.vb";
files = new string[0];
}
@ -510,10 +510,10 @@ namespace Server
public static string GetUnusedPath( string name )
{
string path = Path.Combine( Core.BaseDirectory, String.Format( "Scripts/Output/{0}.dll", name ) );
string path = Path.Combine( Core.BaseDirectory, $"Scripts/Output/{name}.dll");
for( int i = 2; File.Exists( path ) && i <= 1000; ++i )
path = Path.Combine( Core.BaseDirectory, String.Format( "Scripts/Output/{0}.{1}.dll", name, i ) );
path = Path.Combine( Core.BaseDirectory, $"Scripts/Output/{name}.{i}.dll");
return path;
}

View file

@ -134,7 +134,7 @@ namespace Server
public override string ToString()
{
return String.Format( "0x{0:X8}", m_Serial );
return $"0x{m_Serial:X8}";
}
public static implicit operator int( Serial a )

View file

@ -109,7 +109,7 @@ namespace Server
public override string ToString()
{
return String.Format( "[{0}: {1}]", Name, Base );
return $"[{Name}: {Base}]";
}
public Skill( Skills owner, SkillInfo info, GenericReader reader )

View file

@ -349,7 +349,7 @@ namespace Server
Console.WriteLine( "Make sure your Scripts/Misc/DataPath.cs is properly configured" );
Console.WriteLine( "After pressing return an exception will be thrown and the server will terminate" );
throw new Exception( String.Format( "TileData: {0} not found", filePath ) );
throw new Exception($"TileData: {filePath} not found");
}
}
}

View file

@ -58,7 +58,7 @@ namespace Server
if ( callback == null )
return "null";
return String.Format( "{0}.{1}", callback.Method.DeclaringType.FullName, callback.Method.Name );
return $"{callback.Method.DeclaringType.FullName}.{callback.Method.Name}";
}
public static void DumpInfo( TextWriter tw )
@ -575,7 +575,7 @@ namespace Server
public override string ToString()
{
return String.Format( "DelayCallTimer[{0}]", FormatDelegate( m_Callback ) );
return $"DelayCallTimer[{FormatDelegate(m_Callback)}]";
}
}
@ -604,7 +604,7 @@ namespace Server
public override string ToString()
{
return String.Format( "DelayStateCall[{0}]", FormatDelegate( m_Callback ) );
return $"DelayStateCall[{FormatDelegate(m_Callback)}]";
}
}
@ -634,7 +634,7 @@ namespace Server
public override string ToString()
{
return String.Format( "DelayStateCall[{0}]", FormatDelegate( m_Callback ) );
return $"DelayStateCall[{FormatDelegate(m_Callback)}]";
}
}
#endregion

View file

@ -238,7 +238,7 @@ namespace Server {
Console.WriteLine("Error: Type '{0}' was not found.", typeName);
}
throw new Exception(String.Format("Bad type '{0}'", typeName));
throw new Exception($"Bad type '{typeName}'");
}
ConstructorInfo ctor = t.GetConstructor(m_SerialTypeArray);
@ -249,7 +249,7 @@ namespace Server {
}
else
{
throw new Exception(String.Format("Type '{0}' does not have a serialization constructor", t));
throw new Exception($"Type '{t}' does not have a serialization constructor");
}
}
@ -424,7 +424,7 @@ namespace Server {
m.Deserialize( reader );
if ( reader.Position != ( entry.Position + entry.Length ) )
throw new Exception( String.Format( "***** Bad serialize on {0} *****", m.GetType() ) );
throw new Exception($"***** Bad serialize on {m.GetType()} *****");
} catch ( Exception e ) {
mobiles.RemoveAt( i );
@ -459,7 +459,7 @@ namespace Server {
item.Deserialize( reader );
if ( reader.Position != ( entry.Position + entry.Length ) )
throw new Exception( String.Format( "***** Bad serialize on {0} *****", item.GetType() ) );
throw new Exception($"***** Bad serialize on {item.GetType()} *****");
} catch ( Exception e ) {
items.RemoveAt( i );
@ -495,7 +495,7 @@ namespace Server {
g.Deserialize( reader );
if ( reader.Position != ( entry.Position + entry.Length ) )
throw new Exception( String.Format( "***** Bad serialize on Guild {0} *****", g.Id ) );
throw new Exception($"***** Bad serialize on Guild {g.Id} *****");
} catch ( Exception e ) {
guilds.RemoveAt( i );
@ -557,7 +557,8 @@ namespace Server {
Console.WriteLine( "An exception will be thrown and the server will terminate." );
}
throw new Exception( String.Format( "Load failed (items={0}, mobiles={1}, guilds={2}, type={3}, serial={4})", failedItems, failedMobiles, failedGuilds, failedType, failedSerial ), failed );
throw new Exception(
$"Load failed (items={failedItems}, mobiles={failedMobiles}, guilds={failedGuilds}, type={failedType}, serial={failedSerial})", failed );
}
EventSink.InvokeWorldLoad();