-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ConditionalCompliationSampleClass.cs
- Loading branch information
Showing
4 changed files
with
154 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net9.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
|
||
<PropertyGroup Condition="'$(Configuration)' == 'Debug'"> | ||
<DefineConstants>USE_PREVIEW_FEATURES</DefineConstants> | ||
<LangVersion>preview</LangVersion> | ||
<EnablePreviewFeatures>true</EnablePreviewFeatures> | ||
</PropertyGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
| ||
|
||
namespace CSharp13.X | ||
{ | ||
namespace Y | ||
{ | ||
public static class ConditionalCompliationSampleClass | ||
{ | ||
public static C1 Create0() => C1.Create0; | ||
public static C1 Create0O() => C1.Create0; | ||
|
||
public partial class C1 | ||
{ | ||
public const double P1 = Math.PI; | ||
public static double P10 => Math.PI; | ||
public static double P11() => Math.PI; | ||
|
||
public static C1 Create0 => new C1(2, 3, 4); | ||
public static C1 Create00() => new C1(2, 3, 4); | ||
public static C1 Create00O() => new C1(2, 3, 4); | ||
public static C1 Create000() => new C1(2, 3, 4); | ||
} | ||
#if NET8_0_OR_GREATER | ||
public partial class C1(int P2, int P3, int P4) | ||
{ | ||
#if NET9_0_OR_GREATER | ||
#if DEBUG | ||
//Field-backed property | ||
public int P2 | ||
{ | ||
get | ||
{ | ||
if (field == 0) | ||
{ | ||
//field = 1; | ||
return field; | ||
} | ||
return 1; | ||
} | ||
} = P2; | ||
|
||
public int P3 { get => field; set; } = P3; | ||
public int P4 { get => field; set => field = value; } = P4; | ||
#elif NET9_0_OR_GREATER | ||
|
||
private int _P2 = P2; | ||
private int _P3 = P3; | ||
private int _P4 = P4; | ||
public int P2 | ||
{ | ||
get | ||
{ | ||
if (_P2 == 0) | ||
{ | ||
//_P2 = 1; | ||
return _P2; | ||
} | ||
return _P2; | ||
} | ||
} | ||
public int P3 { get; set; } = P3; | ||
public int P4 { get; set; } = P4; | ||
|
||
#endif | ||
#elif NET8_0_OR_GREATER | ||
private int _P2 = P2; | ||
private int _P3 = P3; | ||
private int _P4 = P4; | ||
public int P2 | ||
{ | ||
get | ||
{ | ||
if (_P2 == 0) | ||
{ | ||
//_P2 = 1; | ||
return _P2; | ||
} | ||
return _P2; | ||
} | ||
} | ||
public int P3 { get => _P3; set => _P3 = value; } | ||
public int P4 { get => _P4; set => _P4 = value; } | ||
#endif | ||
} | ||
#elif NET7_0_OR_GREATER | ||
public partial class C1 | ||
{ | ||
private int _P2; | ||
private int _P3; | ||
private int _P4; | ||
|
||
public C1(int P2, int P3, int P4) | ||
{ | ||
_P2 = P2; | ||
_P3 = P3; | ||
_P4 = P4; | ||
} | ||
|
||
public int P2 | ||
{ | ||
get | ||
{ | ||
if (_P2 == 0) | ||
{ | ||
//_P2 = 1; | ||
return _P2; | ||
} | ||
return _P2; | ||
} | ||
set => _P2 = value; | ||
} | ||
public int P3 { get => _P3; set => _P3 = value; } | ||
public int P4 { get => _P4; set => _P4 = value; } | ||
} | ||
#endif | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters