Change Environment.Version to return product version (#22664)
[platform/upstream/coreclr.git] / tests / src / CoreMangLib / system / environment / environment_version.cs
1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
4
5 using System;
6
7 class enviroment_version
8 {
9     static int Main()
10     {
11         Version ver = Environment.Version;
12         Console.WriteLine($"Environment.Version = {ver}");
13
14         if (ver < new Version("3.0"))
15         {
16             Console.WriteLine("ERROR: Version less than 3.0.");
17             return -1;
18         }
19
20         // Verify that we are not returning hardcoded version from .NET Framework.
21         if (ver == new Version("4.0.30319.42000"))
22         {
23             Console.WriteLine("ERROR: Version is hardcoded .NET Framework version.");
24             return -1;
25         }
26
27         // .NET Core assemblies use 4.6+ as file version. Verify that we have not used
28         // the file version as product version by accident.
29         if (ver.Major == 4 && (ver.Minor >= 6))
30         {
31             Console.WriteLine("ERROR: Version is 4.6+.");
32             return -1;
33         }
34
35         Console.WriteLine("PASSED");
36         return 100;
37     }
38 }