Skip to content

Commit 45a1381

Browse files
committedMay 26, 2024
Clean up common C# types
1 parent 932202f commit 45a1381

File tree

2 files changed

+24
-11
lines changed

2 files changed

+24
-11
lines changed
 

‎EventPipe.Test/SymbolCleanerTest.cs

+11-11
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ private static IEnumerable<TestCaseData> TestCaseSource()
1919
{
2020
TestName = "Generic method",
2121
ExpectedResult =
22-
"System.Collections.Concurrent.ConcurrentDictionary<T, T>.TryAddInternal(T, System.Nullable<int32>, T, bool, bool, T&)",
22+
"System.Collections.Concurrent.ConcurrentDictionary<T, T>.TryAddInternal(T, System.Nullable<int>, T, bool, bool, T&)",
2323
};
2424
yield return new TestCaseData(
2525
"System.Threading.ExecutionContext",
@@ -28,7 +28,7 @@ private static IEnumerable<TestCaseData> TestCaseSource()
2828
{
2929
TestName = "Normal method",
3030
ExpectedResult =
31-
"System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)",
31+
"System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, object)",
3232
};
3333
yield return new TestCaseData(
3434
"System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1+AsyncStateMachineBox`1[Contoso.Cookies.Cookies.EntryFetched,Contoso.Cookies.CookieSet+<GetEntryAsync>d__24]",
@@ -72,23 +72,23 @@ private static IEnumerable<TestCaseData> TestCaseSource()
7272
{
7373
TestName = "ref/in/ptr parameters",
7474
ExpectedResult =
75-
"System.Diagnostics.Tracing.EventPipeEventProvider.EventWriteTransfer(System.Diagnostics.Tracing.EventDescriptor&, int, System.Guid*, System.Guid*, int32, EventData*)",
75+
"System.Diagnostics.Tracing.EventPipeEventProvider.EventWriteTransfer(System.Diagnostics.Tracing.EventDescriptor&, int, System.Guid*, System.Guid*, int, EventData*)",
7676
};
7777
yield return new TestCaseData(
7878
"Contoso.Cookies.CookieEntry",
7979
"TryGet",
8080
"instance generic value class Contoso.Cookies.EntryGetResult (!!0&,class System.Exception&,int32,bool)")
8181
{
8282
TestName = "Generic method with !!0",
83-
ExpectedResult = "Contoso.Cookies.CookieEntry.TryGet(T&, System.Exception&, int32, bool)",
83+
ExpectedResult = "Contoso.Cookies.CookieEntry.TryGet(T&, System.Exception&, int, bool)",
8484
};
8585
yield return new TestCaseData(
8686
"System.Collections.Immutable.ImmutableDictionary`2[Contoso.Banners.Configuration.Inventory.Sources.InventoryAvailabilityKey,Contoso.Banners.Configuration.Inventory.Sources.AvailableBanner]",
8787
"Wrap",
8888
"class System.Collections.Immutable.ImmutableDictionary`2<!0,!1> (class System.Collections.Immutable.SortedInt32KeyNode`1<value class HashBucket<!0,!1>>,class Comparers<!0,!1>,int32)")
8989
{
9090
TestName = "Generic arguments using angle brackets and no tilde",
91-
ExpectedResult = "System.Collections.Immutable.ImmutableDictionary<Contoso.Banners.Configuration.Inventory.Sources.InventoryAvailabilityKey, Contoso.Banners.Configuration.Inventory.Sources.AvailableBanner>.Wrap(System.Collections.Immutable.SortedInt32KeyNode<HashBucket<T, T>>, Comparers<T, T>, int32)",
91+
ExpectedResult = "System.Collections.Immutable.ImmutableDictionary<Contoso.Banners.Configuration.Inventory.Sources.InventoryAvailabilityKey, Contoso.Banners.Configuration.Inventory.Sources.AvailableBanner>.Wrap(System.Collections.Immutable.SortedInt32KeyNode<HashBucket<T, T>>, Comparers<T, T>, int)",
9292
};
9393
yield return new TestCaseData(
9494
"Sdk.Connection.GhostClientBase`2+<Process>d__42[System.__Canon,System.__Canon]",
@@ -140,7 +140,7 @@ private static IEnumerable<TestCaseData> TestCaseSource()
140140
{
141141
TestName = "Value tuple argument",
142142
ExpectedResult =
143-
"Program.InstanceMethod(System.ValueTuple<int32, int16, float32, System.String, System.Guid>)",
143+
"Program.InstanceMethod(System.ValueTuple<int, short, float, string, System.Guid>)",
144144
};
145145
yield return new TestCaseData(
146146
"Program+<InstanceMethodAsync>d__3",
@@ -189,7 +189,7 @@ private static IEnumerable<TestCaseData> TestCaseSource()
189189
{
190190
TestName = "Lambda in constructor",
191191
ExpectedResult =
192-
"System.Threading.Tasks.Task+DelayPromiseWithCancellation.()=>{}.<.ctor>b__1_0(System.Object, System.Threading.CancellationToken)",
192+
"System.Threading.Tasks.Task+DelayPromiseWithCancellation.()=>{}.<.ctor>b__1_0(object, System.Threading.CancellationToken)",
193193
};
194194
yield return new TestCaseData(
195195
"System.Net.Http.HttpConnectionPool+<>c",
@@ -205,7 +205,7 @@ private static IEnumerable<TestCaseData> TestCaseSource()
205205
"instance void (class System.Object)")
206206
{
207207
TestName = "Generic lambda",
208-
ExpectedResult = "System.Threading.Tasks.ValueTask<T>+ValueTaskSourceAsTask.()=>{}<System.Int32>.<.cctor>b__4_0(System.Object)",
208+
ExpectedResult = "System.Threading.Tasks.ValueTask<T>+ValueTaskSourceAsTask.()=>{}<int>.<.cctor>b__4_0(object)",
209209
};
210210
yield return new TestCaseData(
211211
"Program",
@@ -237,15 +237,15 @@ private static IEnumerable<TestCaseData> TestCaseSource()
237237
"instance class System.Threading.Tasks.Task`1<bool> (class Microsoft.EntityFrameworkCore.DbContext,class AsyncEnumerator<!0>,value class System.Threading.CancellationToken)")
238238
{
239239
TestName = "Async enumerable method",
240-
ExpectedResult = "Microsoft.EntityFrameworkCore.Query.Internal.SplitQueryingEnumerable<T>+AsyncEnumerator.()=>{}<System.Int32>.<MoveNextAsync>b__19_0(Microsoft.EntityFrameworkCore.DbContext, AsyncEnumerator<T>, System.Threading.CancellationToken)",
240+
ExpectedResult = "Microsoft.EntityFrameworkCore.Query.Internal.SplitQueryingEnumerable<T>+AsyncEnumerator.()=>{}<int>.<MoveNextAsync>b__19_0(Microsoft.EntityFrameworkCore.DbContext, AsyncEnumerator<T>, System.Threading.CancellationToken)",
241241
};
242242
yield return new TestCaseData(
243243
"Program+<>c",
244244
"<Main>b__7_0",
245245
"instance void (int32,class System.Object)")
246246
{
247247
TestName = "Lambda",
248-
ExpectedResult = "Program.()=>{}.<Main>b__7_0(int32, System.Object)",
248+
ExpectedResult = "Program.()=>{}.<Main>b__7_0(int, object)",
249249
};
250250
yield return new TestCaseData(
251251
"Contoso.CookiesUpdater.PublisherCookiesUpdater+<>c__DisplayClass10_0+<<OnBidRequest>b__0>d",
@@ -261,7 +261,7 @@ private static IEnumerable<TestCaseData> TestCaseSource()
261261
"instance void (class System.String)")
262262
{
263263
TestName = "Closure",
264-
ExpectedResult = "Program.()=>{}.<Main>b__1(System.String)",
264+
ExpectedResult = "Program.()=>{}.<Main>b__1(string)",
265265
RunState = RunState.Ignored,
266266
};
267267
}

‎EventPipe/SymbolCleaner.cs

+13
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,19 @@ private static void AppendPrettifiedType(StringBuilder sb, ReadOnlySpan<char> st
305305
return;
306306
}
307307

308+
str = str switch
309+
{
310+
"int16" => "short",
311+
"int32" => "int",
312+
"unsigned int32" => "uint",
313+
"float32" => "float",
314+
"float64" => "double",
315+
"System.Int32" => "int",
316+
"System.Object" => "object",
317+
"System.String" => "string",
318+
_ => str,
319+
};
320+
308321
sb.Append(str);
309322
sb.Append(suffix);
310323
}

0 commit comments

Comments
 (0)
Please sign in to comment.