Skip to content

Commit 433d161

Browse files
authored
Merge pull request #966 from twpol/warning/cs0618
fix: Warning CS0618: 'string.Copy(string)' is obsolete
2 parents 1772685 + 6353e03 commit 433d161

25 files changed

+135
-135
lines changed

Source/ORTS.Menu/ORTimetables.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ protected TimetableInfo(string filePath)
4848
try
4949
{
5050
ORTTList.Add(new TimetableFileLite(filePath));
51-
Description = String.Copy(ORTTList[0].Description);
52-
fileName = String.Copy(filePath);
51+
Description = ORTTList[0].Description;
52+
fileName = filePath;
5353
}
5454
catch
5555
{
@@ -70,8 +70,8 @@ protected TimetableInfo(String filePath, String directory)
7070
{
7171
TimetableGroupFileLite multiInfo = new TimetableGroupFileLite(filePath, directory);
7272
ORTTList = multiInfo.ORTTInfo;
73-
Description = String.Copy(multiInfo.Description);
74-
fileName = String.Copy(filePath);
73+
Description = multiInfo.Description;
74+
fileName = filePath;
7575
}
7676
catch
7777
{

Source/Orts.Formats.Msts/SignalConfigurationFile.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,7 @@ static IDictionary<string, SignalDrawState> ReadDrawStates(STFReader stf)
750750
SignalDrawState drawState = new SignalDrawState(stf);
751751
if (drawStates.ContainsKey(drawState.Name))
752752
{
753-
string TempNew = String.Copy("DST");
753+
string TempNew = "DST";
754754
TempNew = String.Concat(TempNew,drawStates.Count.ToString());
755755
drawStates.Add(TempNew, drawState);
756756
STFException.TraceInformation(stf, "Duplicate SignalDrawState name \'"+drawState.Name+"\', using name \'"+TempNew+"\' instead");
@@ -956,7 +956,7 @@ public class SignalDrawState
956956
public SignalDrawState(string reqName, int reqIndex)
957957
{
958958
Index = reqIndex;
959-
Name = String.Copy(reqName);
959+
Name = reqName;
960960
DrawLights = null;
961961
}
962962

@@ -1065,7 +1065,7 @@ public class SignalAspect
10651065
public SignalAspect(MstsSignalAspect reqAspect, string reqName)
10661066
{
10671067
Aspect = reqAspect;
1068-
DrawStateName = String.Copy(reqName);
1068+
DrawStateName = reqName;
10691069
SpeedMpS = -1;
10701070
Asap = false;
10711071
NoSpeedReduction = false;

Source/Orts.Formats.Msts/SignalScripts.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ public class scrReadInfo
5353

5454
public scrReadInfo(string thisString, int thisInt, string thisScript)
5555
{
56-
Readline = String.Copy(thisString);
56+
Readline = thisString;
5757
Linenumber = thisInt;
58-
Scriptname = String.Copy(thisScript);
58+
Scriptname = thisScript;
5959
}
6060
}// class scrReadInfo
6161

@@ -389,7 +389,7 @@ public void sigscrRead(string scrFileName, StreamReader scrStream, IDictionary<s
389389

390390
else
391391
{
392-
readInfo.Scriptname = String.Copy(scriptname);
392+
readInfo.Scriptname = scriptname;
393393
ScriptLines.Add(readInfo);
394394

395395
if (readInfo.Linenumber % 1000 == 1)
@@ -715,7 +715,7 @@ public static scrReadInfo scrReadLine(StreamReader scrStream, int lastline)
715715
}
716716
else
717717
{
718-
readLine = String.Copy(keepLine);
718+
readLine = keepLine;
719719
keepLine = String.Empty;
720720
#if DEBUG_PRINT_IN
721721
File.AppendAllText(din_fileLoc + @"sigfile.txt", "From store : " + readLine + "\n");
@@ -1505,7 +1505,7 @@ public static int FindEndCondition(List<scrReadInfo> FECScriptLines, int index)
15051505
Trace.TraceWarning("sigscr-file line {1} : Missing ) in IF statement ; starting with {0}",
15061506
presentstring, thisinfo.Linenumber.ToString());
15071507

1508-
string reportString = String.Copy(presentstring);
1508+
string reportString = presentstring;
15091509
if (possibleEnd > 0)
15101510
{
15111511
reportString = presentstring.Substring(0, possibleEnd);
@@ -2174,7 +2174,7 @@ public void SCRProcess_TermPartLine(string TermLinePart, ref int sublevel, int i
21742174
IDictionary<string, uint> LocalFloats, IDictionary<string, SignalFunction> signalFunctions, IList<string> ORNormalSubtypes, int linenumber)
21752175
{
21762176

2177-
string keepString = String.Copy(TermLinePart);
2177+
string keepString = TermLinePart;
21782178
string procString;
21792179
string operString;
21802180
bool syntaxerror = false;
@@ -2287,7 +2287,7 @@ public void SCRProcess_TermPartLine(string TermLinePart, ref int sublevel, int i
22872287
}
22882288
else
22892289
{
2290-
procString = String.Copy(keepString);
2290+
procString = keepString;
22912291
keepString = String.Empty;
22922292
}
22932293

Source/Orts.Formats.Msts/TrackDatabaseFile.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1449,7 +1449,7 @@ public PlatformItem(SidingItem thisSiding)
14491449
ItemName = thisSiding.ItemName;
14501450
Flags1 = thisSiding.Flags1;
14511451
LinkedPlatformItemId = thisSiding.LinkedSidingId;
1452-
Station = String.Copy(ItemName);
1452+
Station = ItemName;
14531453
}
14541454
}
14551455

Source/Orts.Formats.OR/AESignals.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2021,7 +2021,7 @@ public AESignalWorldObject(SignalObj SignalWorldItem, SignalConfigurationFile si
20212021

20222022
public AESignalWorldObject(AESignalWorldObject copy)
20232023
{
2024-
SFileName = String.Copy(copy.SFileName);
2024+
SFileName = copy.SFileName;
20252025
Backfacing = copy.Backfacing;
20262026

20272027
HeadsSet = new bool[copy.HeadsSet.Length];

Source/Orts.Formats.OR/TimetableFile.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public void TTFilePreliminaryRead(String filePath, StreamReader scrStream, Strin
118118
// process comment row - cell at first comment row and column is description
119119
// process path and consist row
120120

121-
Description = String.Copy(filePath);
121+
Description = filePath;
122122

123123
bool descFound = false;
124124
bool pathFound = false;
@@ -136,7 +136,7 @@ public void TTFilePreliminaryRead(String filePath, StreamReader scrStream, Strin
136136
{
137137
if (String.Compare(Parts[0], "#comment", true) == 0)
138138
{
139-
Description = String.Copy(Parts[firstCommentColumn]);
139+
Description = Parts[firstCommentColumn];
140140
descFound = true;
141141
}
142142
}
@@ -146,7 +146,7 @@ public void TTFilePreliminaryRead(String filePath, StreamReader scrStream, Strin
146146
{
147147
pathFound = true;
148148
foreach (TrainInformation train in Trains)
149-
train.Path = String.Copy(Parts[train.Column]);
149+
train.Path = Parts[train.Column];
150150
}
151151
}
152152
if (!consistFound)
@@ -156,7 +156,7 @@ public void TTFilePreliminaryRead(String filePath, StreamReader scrStream, Strin
156156
consistFound = true;
157157
foreach (TrainInformation train in Trains)
158158
{
159-
train.Consist = String.Copy(Parts[train.Column]);
159+
train.Consist = Parts[train.Column];
160160
train.LeadingConsist = ExtractConsist(train.Consist, out train.ReverseConsist);
161161
}
162162
}
@@ -167,7 +167,7 @@ public void TTFilePreliminaryRead(String filePath, StreamReader scrStream, Strin
167167
{
168168
startFound = true;
169169
foreach (TrainInformation train in Trains)
170-
train.StartTime = String.Copy(Parts[train.Column]);
170+
train.StartTime = Parts[train.Column];
171171
}
172172
}
173173
if (!briefingFound)
@@ -177,9 +177,9 @@ public void TTFilePreliminaryRead(String filePath, StreamReader scrStream, Strin
177177
briefingFound = true;
178178

179179
// Newlines "\n" cannot be emdedded in CSV files, so HTML breaks "<br>" are used instead.
180-
Briefing = String.Copy(Parts[1].Replace("<br>", "\n"));
180+
Briefing = Parts[1].Replace("<br>", "\n");
181181
foreach (TrainInformation train in Trains)
182-
train.Briefing = String.Copy(Parts[train.Column]).Replace("<br>", "\n");
182+
train.Briefing = Parts[train.Column].Replace("<br>", "\n");
183183
}
184184
}
185185

@@ -192,8 +192,8 @@ private string ExtractConsist(string consistDef, out bool reverse)
192192
{
193193
bool isReverse = false;
194194

195-
string reqString = String.Copy(consistDef);
196-
string consistProc = String.Copy(consistDef).Trim();
195+
string reqString = consistDef;
196+
string consistProc = consistDef.Trim();
197197

198198
if (consistProc.Substring(0, 1).Equals("<"))
199199
{
@@ -228,7 +228,7 @@ private string ExtractConsist(string consistDef, out bool reverse)
228228
}
229229
else
230230
{
231-
reqString = String.Copy(consistDef);
231+
reqString = consistDef;
232232

233233
int sepIndex = consistDef.IndexOf('$');
234234
if (sepIndex > 0)
@@ -272,7 +272,7 @@ public class TrainInformation : IComparable<TrainInformation>
272272
public TrainInformation(int column, string train)
273273
{
274274
Column = column;
275-
Train = string.Copy(train);
275+
Train = train;
276276
Consist = string.Empty;
277277
LeadingConsist = string.Empty;
278278
Path = string.Empty;

Source/Orts.Formats.OR/TimetableGroupFile.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public TimetableGroupFileLite(String filePath, String directory)
4141
using (StreamReader scrStream = new StreamReader(filePath, true))
4242
{
4343
MultiTTFilePreliminaryRead(filePath, directory, scrStream);
44-
if (String.IsNullOrEmpty(Description)) Description = String.Copy(filePath);
44+
if (String.IsNullOrEmpty(Description)) Description = filePath;
4545
}
4646
}
4747
catch (Exception)
@@ -57,7 +57,7 @@ public TimetableGroupFileLite(String filePath, String directory)
5757

5858
public TimetableGroupFileLite(TimetableFileLite SingleTTInfo)
5959
{
60-
Description = String.Copy(SingleTTInfo.Description);
60+
Description = SingleTTInfo.Description;
6161
ORTTInfo.Add(SingleTTInfo);
6262
}
6363

@@ -102,7 +102,7 @@ public TimetableGroupFile(String filePath, String directory)
102102
using (StreamReader scrStream = new StreamReader(filePath, true))
103103
{
104104
MultiTTFileRead(filePath, directory, scrStream);
105-
if (String.IsNullOrEmpty(Description)) Description = String.Copy(filePath);
105+
if (String.IsNullOrEmpty(Description)) Description = filePath;
106106
}
107107
}
108108
catch (Exception)

Source/Orts.Simulation/MultiPlayer/Message.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2756,7 +2756,7 @@ public override void HandleMsg()
27562756
}
27572757
if (tmpcars2.Count == 0) return;
27582758
train2.Cars = tmpcars2;
2759-
train2.Name = String.Concat(String.Copy(train.Name), Train.TotalNumber.ToString());
2759+
train2.Name = String.Concat(train.Name, Train.TotalNumber.ToString());
27602760
train2.LeadLocomotive = null;
27612761
train2.LeadNextLocomotive();
27622762
train2.CheckFreight();
@@ -2840,7 +2840,7 @@ public override void HandleMsg()
28402840
train2.TrainType = Train.TRAINTYPE.STATIC;
28412841
this.oldTrainNumber = train.Number;
28422842
train2.LastReportedSpeed = 1;
2843-
if (train2.Name.Length < 4) train2.Name = String.Concat("STATIC-", String.Copy(train2.Name));
2843+
if (train2.Name.Length < 4) train2.Name = String.Concat("STATIC-", train2.Name);
28442844
MPManager.Simulator.AI.aiListChanged = true;
28452845
MPManager.Instance().AddOrRemoveLocomotives(user, train, true);
28462846
MPManager.Instance().AddOrRemoveLocomotives(user, train2, true);

Source/Orts.Simulation/Simulation/AIs/AIPath.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public AIPath(AIPath otherPath)
161161
FirstNode.NextSidingNode = Nodes[otherPath.FirstNode.NextSidingNode.Index];
162162
}
163163

164-
pathName = String.Copy(otherPath.pathName);
164+
pathName = otherPath.pathName;
165165
}
166166

167167
/// <summary>

Source/Orts.Simulation/Simulation/AIs/AITrain.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public AITrain(Simulator simulator, Service_Definition sd, AI ai, AIPath path, f
159159
{
160160
RandomizeEfficiency(ref Efficiency);
161161
}
162-
Name = String.Copy(name);
162+
Name = name;
163163
TrafficService = trafficService;
164164
MaxVelocityA = maxVelocityA;
165165
// <CSComment> TODO: as Cars.Count is always = 0 at this point, activityClearingDistanceM is set to the short distance also for long trains
@@ -6149,15 +6149,15 @@ public virtual String[] AddMovementState(String[] stateString, bool metric)
61496149
break;
61506150
}
61516151

6152-
retString[7] = String.Copy(actString);
6152+
retString[7] = actString;
61536153
retString[8] = FormatStrings.FormatDistance(
61546154
nextActionInfo.ActivateDistanceM - PresentPosition[0].DistanceTravelledM, metric);
61556155

61566156
}
61576157

6158-
retString[4] = String.Copy(movString);
6159-
retString[5] = String.Copy(abString);
6160-
retString[11] = String.Copy(nameString);
6158+
retString[4] = movString;
6159+
retString[5] = abString;
6160+
retString[11] = nameString;
61616161

61626162
return retString;
61636163
}

0 commit comments

Comments
 (0)