Skip to content

Commit 91b44c5

Browse files
committed
支持 .NET 6.0 并且只在 .NET8.0 上产生警告
1 parent 360594a commit 91b44c5

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/DotNetCampus.CommandLine/DotNetCampus.CommandLine.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
4+
<TargetFrameworks>net8.0;net6.0</TargetFrameworks>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<PackageId>dotnetCampus.CommandLine</PackageId>
77
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
@@ -11,6 +11,7 @@
1111
<GenerateDocumentationFile>true</GenerateDocumentationFile>
1212
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
1313
<EmbedAllSources Condition="'$(Configuration)' != 'debug'">true</EmbedAllSources>
14+
<WarningLevel Condition="'$(TargetFramework)' == 'net6.0'">0</WarningLevel>
1415
</PropertyGroup>
1516

1617
<ItemGroup>
@@ -22,6 +23,7 @@
2223
<PrivateAssets>all</PrivateAssets>
2324
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2425
</PackageReference>
26+
<PackageReference Condition="'$(TargetFramework)' == 'net6.0'" Include="System.Collections.Immutable" Version="8.0.0" />
2527
</ItemGroup>
2628

2729
<Target Name="_IncludeAllDependencies" BeforeTargets="_GetPackageFiles">

src/DotNetCampus.CommandLine/Utils/CommandLineValueConverter.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ internal static bool ArgumentStringsToBoolean(ImmutableArray<string>? arguments)
8282
}
8383
}
8484

85+
#if NET8_0_OR_GREATER
8586
private static T? ArgumentStringsToValue<T>(ImmutableArray<string>? arguments) where T : IParsable<T> => arguments switch
8687
{
8788
null or { Length: 0 } => default,
@@ -90,6 +91,7 @@ internal static bool ArgumentStringsToBoolean(ImmutableArray<string>? arguments)
9091
: throw new CommandLineParseValueException(
9192
$"Value [{values[0]}] is not a valid value for type {typeof(T).Name}."),
9293
};
94+
#endif
9395

9496
internal static byte ArgumentStringsToByte(ImmutableArray<string>? arguments) => arguments switch
9597
{

0 commit comments

Comments
 (0)