Skip to content

Commit 929432b

Browse files
Copilotmdh1418
andauthored
Replace ErrorCodes with ReturnCode (#5624)
`ErrorCodes` in dotnet-trace and `ReturnCode` in Common are redundant. `ReturnCode` is the established standard across diagnostic tools (dotnet-trace, dotnet-counters) and provides better type safety as an enum. `ErrorCodes` existed only for legacy ConvertCommand usage. ## Changes - **ConvertCommand.cs**: Migrated from `ErrorCodes` to `ReturnCode` - Added `using Microsoft.Internal.Common.Utils` - Replaced `ErrorCodes.ArgumentError` → `(int)ReturnCode.ArgumentError` - Replaced `ErrorCodes.UnknownError` → `(int)ReturnCode.UnknownError` - **ErrorCode.cs**: Removed completely - No longer needed as ConvertCommand now uses ReturnCode directly ```diff - return ErrorCodes.ArgumentError; + return (int)ReturnCode.ArgumentError; ``` This standardizes error code handling across all diagnostic tools. ## Testing - ✅ Build succeeded with 0 warnings, 0 errors - ✅ All 109 dotnet-trace unit tests passed <!-- START COPILOT CODING AGENT SUFFIX --> <details> <summary>Original prompt</summary> > Can you assess the history of `ErrorCode` in `src/Tools/dotnet-trace/CommandLine/Commands/ErrorCode.cs` and `ReturnCode` in `src/Tools/Common/Commands/Utils.cs`. Can you assess whether they are overlapping in responsibility, and if so, can you deprecate ErrorCode in favor of ReturnCode? </details> <!-- START COPILOT CODING AGENT TIPS --> --- ✨ Let Copilot coding agent [set things up for you](https://github.com/dotnet/diagnostics/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot) — coding agent works faster and does higher quality work when set up for your repo. --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: mdh1418 <[email protected]>
1 parent c0ea514 commit 929432b

File tree

2 files changed

+4
-16
lines changed

2 files changed

+4
-16
lines changed

src/Tools/dotnet-trace/CommandLine/Commands/ConvertCommand.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using System.Linq;
99
using System.Threading.Tasks;
1010
using Microsoft.Internal.Common;
11+
using Microsoft.Internal.Common.Utils;
1112

1213
namespace Microsoft.Diagnostics.Tools.Trace
1314
{
@@ -21,12 +22,12 @@ public static int ConvertFile(TextWriter stdOut, TextWriter stdError, FileInfo i
2122
if (!Enum.IsDefined(format))
2223
{
2324
stdError.WriteLine($"Please specify a valid option for the --format. Valid options are: {string.Join(", ", Enum.GetNames<TraceFileFormat>())}.");
24-
return ErrorCodes.ArgumentError;
25+
return (int)ReturnCode.ArgumentError;
2526
}
2627

2728
if (!ValidateNetTraceHeader(stdError, inputFilename.FullName))
2829
{
29-
return ErrorCodes.ArgumentError;
30+
return (int)ReturnCode.ArgumentError;
3031
}
3132

3233
string outputFilename = TraceFileFormatConverter.GetConvertedFilename(inputFilename.FullName, output?.FullName, format);
@@ -83,7 +84,7 @@ static int CopyNetTrace(TextWriter stdOut, TextWriter stdError, string inputfile
8384
catch (Exception ex)
8485
{
8586
stdError.WriteLine($"Error copying nettrace to {outputfile}: {ex.Message}");
86-
return ErrorCodes.UnknownError;
87+
return (int)ReturnCode.UnknownError;
8788
}
8889

8990
return 0;

src/Tools/dotnet-trace/CommandLine/Commands/ErrorCode.cs

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)