Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions its/projects/CSharp.SDK.9/CSharp.SDK.9.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.4.33015.44
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Main", "Main\Main.csproj", "{FC4653F8-668E-4C37-BDE3-AF03814B716E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UTs", "UTs\UTs.csproj", "{E96549B1-F7A1-421B-A81C-8547BB101407}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{FC4653F8-668E-4C37-BDE3-AF03814B716E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FC4653F8-668E-4C37-BDE3-AF03814B716E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FC4653F8-668E-4C37-BDE3-AF03814B716E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FC4653F8-668E-4C37-BDE3-AF03814B716E}.Release|Any CPU.Build.0 = Release|Any CPU
{E96549B1-F7A1-421B-A81C-8547BB101407}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E96549B1-F7A1-421B-A81C-8547BB101407}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E96549B1-F7A1-421B-A81C-8547BB101407}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E96549B1-F7A1-421B-A81C-8547BB101407}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {4B548A8F-F688-4D3A-ACA4-B440513094F3}
EndGlobalSection
EndGlobal
8 changes: 8 additions & 0 deletions its/projects/CSharp.SDK.9/Main/Common.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace CSharp.SDKs
Copy link
Contributor

@martin-strecker-sonarsource martin-strecker-sonarsource Nov 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The files in

  • its/projects/CSharp.SDK.8
  • its/projects/CSharp.SDK.9
  • its/projects/CSharp.SDK.Latest

are completely identical with these exceptions

  • global.json
  • TargetFramework in the csprojs
  • PackageReferences in the UT projects

I would use only a single project (propably its/projects/CSharp.SDK.Latest) and

  • Create a global.json with the SDK (or no global.json) inside the UT
  • Run the build with a /p:TargetFramework={0} argument inside the UT
  • Use the PackageReferences as defined in CSharp.SDK.Latest
  • Make the sdk8(), sdk9(), sdkLatest() a single parameterized test

What do you think?

{
public static class Common
{
// FIXME: This line contains S1134 warning
public static bool IsGreaterThanZero(int value) => value > 0;
}
}
8 changes: 8 additions & 0 deletions its/projects/CSharp.SDK.9/Main/Main.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>

<!-- This should be overwritten by targets file to get results -->
<RunAnalyzersDuringBuild>false</RunAnalyzersDuringBuild>
</PropertyGroup>
</Project>
16 changes: 16 additions & 0 deletions its/projects/CSharp.SDK.9/UTs/CommonTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace CSharp.SDKs.Test
{
[TestClass]
public class CommonTest
{
// FIXME: This line contains S1134 warning in SL, but not in S4NET context due to current test-code support

[TestMethod]
public void TestMethodWithNoAssertion() // S2699: Add at least one assertion to this test case. This rule has test-only scope.
{
Common.IsGreaterThanZero(1);
}
}
}
23 changes: 23 additions & 0 deletions its/projects/CSharp.SDK.9/UTs/UTs.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>

<!-- This should be overwritten by targets file to get results -->
<RunAnalyzersDuringBuild>false</RunAnalyzersDuringBuild>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="MSTest.TestAdapter" Version="3.6.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.6.1" />
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Main\Main.csproj" />
</ItemGroup>

</Project>
6 changes: 6 additions & 0 deletions its/projects/CSharp.SDK.9/global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"sdk": {
"version": "9.0.0",
"rollForward": "latestFeature"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,13 @@ void sdk8() {
@Test
// dotnet sdk tests should run only on VS 2022 and above
@MSBuildMinVersion(17)
void sdk9() {
validateCSharpSdk("CSharp.SDK.9");
}

@Test
// dotnet sdk tests should run only on VS 2022
@MSBuildMinVersion(17)
void net8_NoAnalysisWarnings() {
var context = AnalysisContext.forServer("CSharp.SDK.8");
var result = context.runAnalysis();
Expand Down
Loading