Skip to content

Commit dc6b7c1

Browse files
authored
Minor fixes for build warnings in samples (#6491)
## Summary of changes Fixes some build warnings coming from the samples ## Reason for change Warnings are annoying ## Implementation details Tries to fix the following warnings: `##[warning]D:\a\1\s\tracer\test\test-applications\integrations\Samples.AspNetCoreMvc21\Controllers\ApiController.cs(35,17): warning ASP0019: Use IHeaderDictionary.Append or the indexer to append or set headers. IDictionary.Add will throw an ArgumentException when attempting to add a duplicate key. (https://aka.ms/aspnet/analyzers)` `##[warning]D:\a\_tool\dotnet\sdk\9.0.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(322,5): warning NETSDK1206: Found version-specific or distribution-specific runtime identifier(s): alpine-x64. Affected libraries: SQLitePCLRaw.lib.e_sqlite3. In .NET 8.0 and higher, assets for version-specific and distribution-specific runtime identifiers will not be found by default. See https://aka.ms/dotnet/rid-usage for details. [D:\a\1\s\tracer\test\test-applications\integrations\Samples.Microsoft.Data.Sqlite\Samples.Microsoft.Data.Sqlite.csproj::TargetFramework=net8.0]` `##[warning]D:\a\1\s\tracer\test\test-applications\debugger\dependency-libs\Samples.Probes.TestRuns\ExceptionReplay\ExceptionWithNonSupportedFramesTest.cs(30,27): warning CS0649: Field 'ExceptionWithNonSupportedFramesTest.MeRefStruct.Field' is never assigned to, and will always have its default value null` `##[warning]D:\a\1\s\tracer\test\test-applications\security\Samples.Security.AspNetCore5\Controllers\IastController.cs(77,38): warning CS0414: The field 'IastController._dbConnectionSystemDataSqlClient' is assigned but its value is never used` `##[warning]D:\a\1\s\tracer\test\test-applications\debugger\Samples.Debugger.AspNetCore5\Controllers\HomeController.cs(32,13): warning ASP0019: Use IHeaderDictionary.Append or the indexer to append or set headers. IDictionary.Add will throw an ArgumentException when attempting to add a duplicate key. (https://aka.ms/aspnet/analyzers)` ## Test coverage This PR is the test
1 parent 602a928 commit dc6b7c1

File tree

5 files changed

+8
-3
lines changed

5 files changed

+8
-3
lines changed

tracer/test/test-applications/debugger/Samples.Debugger.AspNetCore5/Controllers/HomeController.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public IActionResult Index()
2929

3030
public IActionResult LangHeader()
3131
{
32-
Response.Headers.Add("content-language", "krypton");
32+
Response.Headers["content-language"] = "krypton";
3333
return Content("Setting content-language");
3434
}
3535

tracer/test/test-applications/debugger/dependency-libs/Samples.Probes.TestRuns/ExceptionReplay/ExceptionWithNonSupportedFramesTest.cs

+2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ void SupportedFrame(string str)
2727

2828
ref struct MeRefStruct
2929
{
30+
#pragma warning disable CS0649 // Field 'ExceptionWithNonSupportedFramesTest.MeRefStruct.Field' is never assigned to, and will always have its default value null
3031
public string Field;
32+
#pragma warning restore CS0649
3133
}
3234
}
3335
}

tracer/test/test-applications/integrations/Samples.AspNetCoreMvc21/Controllers/ApiController.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ private void AddCorrelationIdentifierToResponse()
3232
{
3333
if (Request.Headers.ContainsKey(CorrelationIdentifierHeaderName))
3434
{
35-
Response.Headers.Add(CorrelationIdentifierHeaderName, Request.Headers[CorrelationIdentifierHeaderName]);
35+
Response.Headers[CorrelationIdentifierHeaderName] = Request.Headers[CorrelationIdentifierHeaderName];
3636
}
3737
}
3838
}

tracer/test/test-applications/integrations/Samples.Microsoft.Data.Sqlite/Samples.Microsoft.Data.Sqlite.csproj

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
<!-- Required to build multiple projects with the same Configuration|Platform -->
77
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
88
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
9+
<!-- Ignore unnecessary warning: Found version-specific or distribution-specific runtime
10+
identifier(s): alpine-x64. Affected libraries: SQLitePCLRaw.lib.e_sqlite3. In .NET 8.0 and higher,
11+
assets for version-specific and distribution-specific runtime identifiers will not be found by default. -->
12+
<NoWarn>$(NoWarn);NETSDK1206</NoWarn>
913

1014
</PropertyGroup>
1115

tracer/test/test-applications/security/Samples.Security.AspNetCore5/Controllers/IastController.cs

-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ public class IastController : Controller
7979
{
8080
private static SQLiteConnection _dbConnectionSystemData = null;
8181
private static SqliteConnection _dbConnectionSystemDataMicrosoftData = null;
82-
private static SqlConnection _dbConnectionSystemDataSqlClient = null;
8382
private static IMongoDatabase _mongoDb = null;
8483
#if NETCOREAPP3_0_OR_GREATER
8584
private static NpgsqlConnection _dbConnectionNpgsql = null;

0 commit comments

Comments
 (0)