|
| 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 | + |
| 4 | +using System; |
| 5 | +using System.Reflection; |
| 6 | +using Microsoft.Build.Execution; |
| 7 | +using Microsoft.Build.Graph; |
| 8 | +using Shouldly; |
| 9 | +using Xunit; |
| 10 | + |
| 11 | +namespace Microsoft.Build.Engine.UnitTests.BackEnd |
| 12 | +{ |
| 13 | + public class BuildOMCompatibility_Tests |
| 14 | + { |
| 15 | + [Theory] |
| 16 | + [InlineData("ProjectInstance")] |
| 17 | + [InlineData("ProjectFullPath")] |
| 18 | + [InlineData("TargetNames")] |
| 19 | + [InlineData("Flags")] |
| 20 | + [InlineData("GlobalProperties")] |
| 21 | + [InlineData("ExplicitlySpecifiedToolsVersion")] |
| 22 | + [InlineData("HostServices")] |
| 23 | + [InlineData("PropertiesToTransfer")] |
| 24 | + [InlineData("RequestedProjectState")] |
| 25 | + public void BuildRequestDataPropertyCompatTest(string propertyName) |
| 26 | + => VerifyPropertyExists(typeof(BuildRequestData), propertyName); |
| 27 | + |
| 28 | + [Theory] |
| 29 | + [InlineData("ProjectGraph")] |
| 30 | + [InlineData("ProjectGraphEntryPoints")] |
| 31 | + [InlineData("TargetNames")] |
| 32 | + [InlineData("Flags")] |
| 33 | + [InlineData("GraphBuildOptions")] |
| 34 | + [InlineData("HostServices")] |
| 35 | + public void GraphBuildRequestDataPropertyCompatTest(string propertyName) |
| 36 | + => VerifyPropertyExists(typeof(GraphBuildRequestData), propertyName); |
| 37 | + |
| 38 | + [Theory] |
| 39 | + [InlineData("BuildManager")] |
| 40 | + [InlineData("SubmissionId")] |
| 41 | + [InlineData("AsyncContext")] |
| 42 | + [InlineData("WaitHandle")] |
| 43 | + [InlineData("IsCompleted")] |
| 44 | + [InlineData("BuildResult")] |
| 45 | + public void BuildSubmissionDataPropertyCompatTest(string propertyName) |
| 46 | + => VerifyPropertyExists(typeof(BuildSubmission), propertyName); |
| 47 | + |
| 48 | + [Theory] |
| 49 | + [InlineData("Execute")] |
| 50 | + [InlineData("ExecuteAsync")] |
| 51 | + public void BuildSubmissionDataMethodCompatTest(string methodName) |
| 52 | + => VerifyMethodExists(typeof(BuildSubmission), methodName); |
| 53 | + |
| 54 | + [Theory] |
| 55 | + [InlineData("BuildManager")] |
| 56 | + [InlineData("SubmissionId")] |
| 57 | + [InlineData("AsyncContext")] |
| 58 | + [InlineData("WaitHandle")] |
| 59 | + [InlineData("IsCompleted")] |
| 60 | + [InlineData("BuildResult")] |
| 61 | + public void GraphBuildSubmissionDataPropertyCompatTest(string propertyName) |
| 62 | + => VerifyPropertyExists(typeof(BuildSubmission), propertyName); |
| 63 | + |
| 64 | + [Theory] |
| 65 | + [InlineData("Execute")] |
| 66 | + [InlineData("ExecuteAsync")] |
| 67 | + public void GraphBuildSubmissionDataMethodCompatTest(string methodName) |
| 68 | + => VerifyMethodExists(typeof(BuildSubmission), methodName); |
| 69 | + |
| 70 | + [Theory] |
| 71 | + [InlineData("SubmissionId")] |
| 72 | + [InlineData("ConfigurationId")] |
| 73 | + [InlineData("GlobalRequestId")] |
| 74 | + [InlineData("ParentGlobalRequestId")] |
| 75 | + [InlineData("NodeRequestId")] |
| 76 | + [InlineData("Exception")] |
| 77 | + [InlineData("CircularDependency")] |
| 78 | + [InlineData("OverallResult")] |
| 79 | + [InlineData("ResultsByTarget")] |
| 80 | + [InlineData("ProjectStateAfterBuild")] |
| 81 | + [InlineData("BuildRequestDataFlags")] |
| 82 | + public void BuildResultPropertyCompatTest(string propertyName) |
| 83 | + => VerifyPropertyExists(typeof(BuildResult), propertyName); |
| 84 | + |
| 85 | + [Theory] |
| 86 | + [InlineData("AddResultsForTarget")] |
| 87 | + [InlineData("MergeResults")] |
| 88 | + [InlineData("HasResultsForTarget")] |
| 89 | + public void BuildResultMethodCompatTest(string methodName) |
| 90 | + => VerifyMethodExists(typeof(BuildResult), methodName); |
| 91 | + |
| 92 | + [Theory] |
| 93 | + [InlineData("SubmissionId")] |
| 94 | + [InlineData("Exception")] |
| 95 | + [InlineData("CircularDependency")] |
| 96 | + [InlineData("OverallResult")] |
| 97 | + [InlineData("ResultsByNode")] |
| 98 | + public void GraphBuildResultPropertyCompatTest(string propertyName) |
| 99 | + => VerifyPropertyExists(typeof(GraphBuildResult), propertyName); |
| 100 | + |
| 101 | + private void VerifyPropertyExists(Type type, string propertyName) |
| 102 | + { |
| 103 | + type.GetProperty( |
| 104 | + propertyName, |
| 105 | + BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly) |
| 106 | + .ShouldNotBeNull(); |
| 107 | + } |
| 108 | + |
| 109 | + private void VerifyMethodExists(Type type, string propertyName) |
| 110 | + { |
| 111 | + type.GetMethod( |
| 112 | + propertyName, |
| 113 | + BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly) |
| 114 | + .ShouldNotBeNull(); |
| 115 | + } |
| 116 | + } |
| 117 | +} |
0 commit comments