Skip to content

Commit f3b594c

Browse files
committed
Enable Roslyn analysis - Test Applicatiosn - part I
1 parent b538ed1 commit f3b594c

File tree

90 files changed

+657
-309
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+657
-309
lines changed

test/OpenTelemetry.AutoInstrumentation.Native.Tests/clr_helper_test.cpp

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,10 @@ TEST_F(CLRHelperTest, GetsTypeInfoFromTypeDefs)
106106

107107
TEST_F(CLRHelperTest, GetsTypeInfoFromTypeRefs)
108108
{
109-
std::set<std::wstring> expected = {L"DebuggingModes",
109+
std::set<std::wstring> expected = {L"ConfiguredTaskAwaiter",
110+
L"DebuggingModes",
110111
L"Enumerator",
112+
L"System.ArgumentNullException",
111113
L"System.Array",
112114
L"System.Attribute",
113115
L"System.AttributeTargets",
@@ -139,12 +141,12 @@ TEST_F(CLRHelperTest, GetsTypeInfoFromTypeRefs)
139141
L"System.Reflection.AssemblyTitleAttribute",
140142
L"System.Runtime.CompilerServices.AsyncStateMachineAttribute",
141143
L"System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1",
144+
L"System.Runtime.CompilerServices.ConfiguredTaskAwaitable",
145+
L"System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1",
142146
L"System.Runtime.CompilerServices.CompilationRelaxationsAttribute",
143147
L"System.Runtime.CompilerServices.CompilerGeneratedAttribute",
144148
L"System.Runtime.CompilerServices.IAsyncStateMachine",
145149
L"System.Runtime.CompilerServices.RuntimeCompatibilityAttribute",
146-
L"System.Runtime.CompilerServices.TaskAwaiter",
147-
L"System.Runtime.CompilerServices.TaskAwaiter`1",
148150
L"System.Runtime.Versioning.TargetFrameworkAttribute",
149151
L"System.RuntimeTypeHandle",
150152
L"System.String",
@@ -161,6 +163,23 @@ TEST_F(CLRHelperTest, GetsTypeInfoFromTypeRefs)
161163
if (type_info.IsValid())
162164
{
163165
actual.insert(type_info.name);
166+
std::cout << "Found TypeRef: " << ToString(type_info.name) << std::endl;
167+
}
168+
}
169+
170+
for (const auto& name : expected)
171+
{
172+
if (actual.find(name) == actual.end())
173+
{
174+
std::cout << "Missing TypeRef: " << ToString(name) << std::endl;
175+
}
176+
}
177+
178+
for (const auto& name : actual)
179+
{
180+
if (expected.find(name) == expected.end())
181+
{
182+
std::cout << "Unexpected TypeRef: " << ToString(name) << std::endl;
164183
}
165184
}
166185
EXPECT_EQ(expected, actual);

test/test-applications/integrations/Directory.Build.props

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,9 @@
1212
<ItemGroup>
1313
<Compile Include="$(MSBuildThisFileDirectory)GlobalSuppressions.cs" Link="GlobalSuppressions.integrations.cs" />
1414
</ItemGroup>
15+
<PropertyGroup>
16+
<!-- CA1031: Do not catch general exception types -->
17+
<!-- CA1303: Do not pass literals as localized parameters -->
18+
<NoWarn>$(NoWarn);CA1031;CA1303</NoWarn>
19+
</PropertyGroup>
1520
</Project>

test/test-applications/integrations/TestApplication.Azure/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
var containerClient = blobServiceClient.GetBlobContainerClient(containerName);
2222

2323
// Create the container if it does not exist
24-
await containerClient.CreateIfNotExistsAsync();
24+
await containerClient.CreateIfNotExistsAsync().ConfigureAwait(false);
2525

26-
var exists = await containerClient.ExistsAsync();
26+
var exists = await containerClient.ExistsAsync().ConfigureAwait(false);
2727

2828
Console.WriteLine(exists);
2929

test/test-applications/integrations/TestApplication.ContinuousProfiler.ContextTracking/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public static async Task Main(string[] args)
1616
// and verify that trace context flows properly between threads that carry out parts of the async operation.
1717
using var activity = Source.StartActivity();
1818

19-
await DoSomethingAsync();
19+
await DoSomethingAsync().ConfigureAwait(false);
2020
}
2121

2222
private static async Task DoSomethingAsync()

test/test-applications/integrations/TestApplication.ContinuousProfiler/ClassA.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,21 +110,22 @@ public static void MethodAOthers<T>(
110110
static void Action(int s) => InternalClassB<string, int>.DoubleInternalClassB.TripleInternalClassB<int>.MethodB(s, [3], TimeSpan.Zero, 0, ["a"], []);
111111
}
112112

113+
[DefaultDllImportSearchPaths(DllImportSearchPath.SafeDirectories)]
113114
#if NET
114115
[DllImport("TestApplication.ContinuousProfiler.NativeDep")]
115116
#else
116117
[DllImport("TestApplication.ContinuousProfiler.NativeDep.dll")]
117118
#endif
118119
private static extern int OTelAutoCallbackTest(Callback fp, int n);
119120

120-
internal static class InternalClassB<TA, TD>
121+
internal static class InternalClassB<T1, T4>
121122
{
122123
internal static class DoubleInternalClassB
123124
{
124-
internal static class TripleInternalClassB<TC>
125+
internal static class TripleInternalClassB<T3>
125126
{
126127
[MethodImpl(MethodImplOptions.NoInlining)]
127-
public static void MethodB<TB>(int testArg, TC[] a, TB b, TD t, IList<TA> c, IList<string> d)
128+
public static void MethodB<T2>(int testArg, T3[] a, T2 b, T4 t, IList<T1> c, IList<string> d)
128129
{
129130
OTelAutoCallbackTest(TestCallback, testArg);
130131
}

test/test-applications/integrations/TestApplication.ContinuousProfiler/Exporter/AllocationSample.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
namespace TestApplication.ContinuousProfiler;
55

6-
internal class AllocationSample
6+
internal sealed class AllocationSample
77
{
88
public AllocationSample(long allocationSizeBytes, string allocationTypeName, ThreadSample threadSample)
99
{

test/test-applications/integrations/TestApplication.ContinuousProfiler/Exporter/ExtendedPprofBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
namespace TestApplication.ContinuousProfiler;
1111

12-
internal class ExtendedPprofBuilder
12+
internal sealed class ExtendedPprofBuilder
1313
{
1414
private readonly LocationCache _locationCache;
1515
private readonly LinkCache _linkCache;

test/test-applications/integrations/TestApplication.ContinuousProfiler/Exporter/OtlpOverHttpExporter.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
namespace TestApplication.ContinuousProfiler;
1616

17-
public class OtlpOverHttpExporter
17+
internal class OtlpOverHttpExporter
1818
{
1919
private const string MediaContentType = "application/x-protobuf";
2020

@@ -257,6 +257,11 @@ private static ScopeProfiles CreateScopeProfiles()
257257
return scopeProfiles;
258258
}
259259

260+
private static ExportRequestContent CreateHttpContent(ExportProfilesServiceRequest exportRequest)
261+
{
262+
return new ExportRequestContent(exportRequest);
263+
}
264+
260265
private HttpResponseMessage SendHttpRequest(HttpRequestMessage request, CancellationToken cancellationToken)
261266
{
262267
#if NET
@@ -266,11 +271,6 @@ private HttpResponseMessage SendHttpRequest(HttpRequestMessage request, Cancella
266271
#endif
267272
}
268273

269-
private HttpContent CreateHttpContent(ExportProfilesServiceRequest exportRequest)
270-
{
271-
return new ExportRequestContent(exportRequest);
272-
}
273-
274274
private HttpRequestMessage CreateHttpRequest(ExportProfilesServiceRequest exportRequest)
275275
{
276276
var request = new HttpRequestMessage(HttpMethod.Post, _endpoint);

test/test-applications/integrations/TestApplication.ContinuousProfiler/Exporter/ResourcesProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace TestApplication.ContinuousProfiler;
77

8-
internal class ResourcesProvider
8+
internal sealed class ResourcesProvider
99
{
1010
public static Resource Resource { get; private set; } = Resource.Empty;
1111

test/test-applications/integrations/TestApplication.ContinuousProfiler/Exporter/SampleBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace TestApplication.ContinuousProfiler;
77

8-
internal class SampleBuilder
8+
internal sealed class SampleBuilder
99
{
1010
private readonly Sample _sample = new();
1111
private long? _value;

0 commit comments

Comments
 (0)