Skip to content
Permalink
Browse files

housekeeping: .NET Core App 2.0 tests & Tests Cleanups (#1926)

* housekeeping: .NET Core App 2.0 tests & Tests Cleanups

* Now compiling for .net core app 2.0, .net 4.6.1, uwp (not yet being run --next pass)
* Turned on most of the analyzers for the test project. Cleaned up approriately
* Updated the cake build script to do coverage tests on platforms where they are supported
* Updated open cover version.
* Approval tests now include the framework version.
  • Loading branch information...
glennawatson committed Jan 24, 2019
1 parent a7adc91 commit 8eb0c1dc7f4052f4b0478219e53c507e7cddfe3a
Showing with 7,195 additions and 5,224 deletions.
  1. +1 −1 .gitignore
  2. +5 −0 azure-pipelines-tests.yml
  3. +5 −0 azure-pipelines.yml
  4. +61 −40 build.cake
  5. +4 −4 src/ApiGeneratorGlobalSuppressions.cs
  6. +1 −4 src/Directory.build.props
  7. 0 ...iApprovalTests.ReactiveUIFody.approved.txt → ApiApprovalTests.ReactiveUIFody.net461.approved.txt}
  8. +31 −0 src/ReactiveUI.Fody.Tests/API/ApiApprovalTests.ReactiveUIFody.netcoreapp2.0.approved.txt
  9. +2 −16 src/ReactiveUI.Fody.Tests/API/ApiApprovalTests.cs
  10. +70 −0 src/ReactiveUI.Fody.Tests/ApiApprovalBase.cs
  11. +1 −15 src/ReactiveUI.Fody.Tests/Issues/Issue11Tests.cs
  12. +29 −0 src/ReactiveUI.Fody.Tests/Issues/Mocks/Issue11TestModel.cs
  13. +20 −0 src/ReactiveUI.Fody.Tests/Mocks/BaseModel.cs
  14. +53 −0 src/ReactiveUI.Fody.Tests/Mocks/DecoratorModel.cs
  15. +43 −0 src/ReactiveUI.Fody.Tests/Mocks/FacadeModel.cs
  16. +26 −0 src/ReactiveUI.Fody.Tests/Mocks/ObservableAsTestModel.cs
  17. +1 −12 src/ReactiveUI.Fody.Tests/ObservableAsPropertyTests.cs
  18. +0 −75 src/ReactiveUI.Fody.Tests/ReactiveDependencyTests.cs
  19. +1 −10 src/ReactiveUI.Fody.Tests/ReactiveUI.Fody.Tests.csproj
  20. +1,005 −0 src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.net461.approved.txt
  21. +999 −0 src/ReactiveUI.Tests/API/ApiApprovalTests.ReactiveUI.netcoreapp2.0.approved.txt
  22. +1 −1 ....Tests/API/{ApiApprovalTests.Testing.approved.txt → ApiApprovalTests.Testing.net461.approved.txt}
  23. +25 −0 src/ReactiveUI.Tests/API/ApiApprovalTests.Testing.netcoreapp2.0.approved.txt
  24. +3 −34 src/ReactiveUI.Tests/API/ApiApprovalTests.cs
  25. +4 −3 src/ReactiveUI.Tests/Activation/ActivatingView.cs
  26. +1 −133 src/ReactiveUI.Tests/{AutoPersistHelperTest.cs → AutoPersist/AutoPersistCollectionTests.cs}
  27. +148 −0 src/ReactiveUI.Tests/AutoPersist/AutoPersistHelperTest.cs
  28. +0 −437 src/ReactiveUI.Tests/CommandBindingTests.cs
  29. +187 −0 src/ReactiveUI.Tests/Commands/CombinedReactiveCommandTest.cs
  30. +38 −0 src/ReactiveUI.Tests/Commands/CreatesCommandBindingTests.cs
  31. +35 −0 src/ReactiveUI.Tests/Commands/Mocks/FakeCommand.cs
  32. +20 −0 src/ReactiveUI.Tests/Commands/Mocks/ICommandHolder.cs
  33. +20 −0 src/ReactiveUI.Tests/Commands/Mocks/ReactiveCommandHolder.cs
  34. +208 −415 src/ReactiveUI.Tests/{ → Commands}/ReactiveCommandTest.cs
  35. +6 −4 src/ReactiveUI.Tests/{ → Comparers}/OrderedComparerTests.cs
  36. +0 −272 src/ReactiveUI.Tests/DependencyResolverTests.cs
  37. +1 −1 src/ReactiveUI.Tests/InteractionsTest.cs
  38. +0 −103 src/ReactiveUI.Tests/{ViewLocatorTests.cs → Locator/DefaultViewLocatorTests.cs}
  39. +18 −0 src/ReactiveUI.Tests/Locator/Mocks/BarView.cs
  40. +11 −0 src/ReactiveUI.Tests/Locator/Mocks/BarViewModel.cs
  41. +25 −0 src/ReactiveUI.Tests/Locator/Mocks/FooThatThrowsView.cs
  42. +18 −0 src/ReactiveUI.Tests/Locator/Mocks/FooView.cs
  43. +11 −0 src/ReactiveUI.Tests/Locator/Mocks/FooViewModel.cs
  44. +11 −0 src/ReactiveUI.Tests/Locator/Mocks/FooViewModelWithWeirdName.cs
  45. +18 −0 src/ReactiveUI.Tests/Locator/Mocks/FooWithWeirdConvention.cs
  46. +14 −0 src/ReactiveUI.Tests/Locator/Mocks/IBarViewModel.cs
  47. +11 −0 src/ReactiveUI.Tests/Locator/Mocks/IFooView.cs
  48. +14 −0 src/ReactiveUI.Tests/Locator/Mocks/IFooViewModel.cs
  49. +11 −0 src/ReactiveUI.Tests/Locator/Mocks/IRoutableFooViewModel.cs
  50. +14 −0 src/ReactiveUI.Tests/Locator/Mocks/IStrangeInterfaceNotFollowingConvention.cs
  51. +18 −0 src/ReactiveUI.Tests/Locator/Mocks/RoutableFooView.cs
  52. +14 −0 src/ReactiveUI.Tests/Locator/Mocks/RoutableFooViewModel.cs
  53. +11 −0 src/ReactiveUI.Tests/Locator/Mocks/StrangeClassNotFollowingConvention.cs
  54. +11 −0 src/ReactiveUI.Tests/Mocks/AnotherViewModel.cs
  55. +48 −0 src/ReactiveUI.Tests/Mocks/CommandBindViewModel.cs
  56. +11 −0 src/ReactiveUI.Tests/Mocks/ExampleViewModel.cs
  57. +11 −0 src/ReactiveUI.Tests/Mocks/ExampleWindowViewModel.cs
  58. +32 −0 src/ReactiveUI.Tests/Mocks/FakeCollectionModel.cs
  59. +29 −0 src/ReactiveUI.Tests/Mocks/FakeCollectionViewModel.cs
  60. +24 −0 src/ReactiveUI.Tests/Mocks/FakeNestedViewModel.cs
  61. +24 −0 src/ReactiveUI.Tests/Mocks/FakeViewModel.cs
  62. +11 −0 src/ReactiveUI.Tests/Mocks/NeverUsedViewModel.cs
  63. +20 −0 src/ReactiveUI.Tests/Mocks/PropertyBindModel.cs
  64. +75 −0 src/ReactiveUI.Tests/Mocks/PropertyBindViewModel.cs
  65. +1 −6 src/ReactiveUI.Tests/{TestUtilsTest.cs → Mocks/SingleInstanceExampleViewModel.cs}
  66. +11 −0 src/ReactiveUI.Tests/Mocks/ViewModelWithWeirdName.cs
  67. +27 −0 src/ReactiveUI.Tests/ObservableAsPropertyHelper/Mocks/OAPHIndexerTestFixture.cs
  68. +0 −122 src/ReactiveUI.Tests/{ → ObservableAsPropertyHelper}/ObservableAsPropertyHelperTest.cs
  69. +67 −0 src/ReactiveUI.Tests/ObservedChanged/Mocks/NewGameViewModel.cs
  70. +32 −0 src/ReactiveUI.Tests/ObservedChanged/NewGameViewModelTests.cs
  71. +0 −79 src/ReactiveUI.Tests/{ → ObservedChanged}/ObservedChangedMixinTest.cs
  72. +31 −0 src/ReactiveUI.Tests/Platforms/common-gui/Mocks/RaceConditionFixture.cs
  73. +31 −0 src/ReactiveUI.Tests/Platforms/common-gui/Mocks/RaceConditionNameOfFixture.cs
  74. +53 −0 src/ReactiveUI.Tests/Platforms/common-gui/ObservableAsPropertyHelperModeTests.cs
  75. +30 −0 src/ReactiveUI.Tests/Platforms/common-gui/ProductionMode.cs
  76. +26 −0 src/ReactiveUI.Tests/Platforms/uwp/API/UwpApiApprovalTests.cs
  77. +7 −0 src/ReactiveUI.Tests/Platforms/uwp/App.xaml
  78. +41 −0 src/ReactiveUI.Tests/Platforms/uwp/App.xaml.cs
  79. +1 −1 ...Tests.Blend.approved.txt → Platforms/windows-xaml/Api/ApiApprovalTests.Blend.net461.approved.txt}
  80. +27 −0 src/ReactiveUI.Tests/Platforms/windows-xaml/Api/XamlApiApprovalTests.cs
  81. +213 −0 src/ReactiveUI.Tests/Platforms/windows-xaml/CommandBindingImplementationTests.cs
  82. +14 −30 src/ReactiveUI.Tests/Platforms/{xaml → windows-xaml}/DependencyObjectObservableForPropertyTest.cs
  83. +97 −0 src/ReactiveUI.Tests/Platforms/windows-xaml/Legacy/ControlsReactiveCollectionTest.cs
  84. +55 −0 src/ReactiveUI.Tests/Platforms/windows-xaml/Legacy/Mocks/LegacyPropertyBindView.cs
  85. +87 −0 src/ReactiveUI.Tests/Platforms/windows-xaml/Legacy/Mocks/LegacyPropertyBindViewModel.cs
  86. +42 −0 src/ReactiveUI.Tests/Platforms/windows-xaml/Mocks/CommandBindView.cs
  87. +29 −0 src/ReactiveUI.Tests/Platforms/windows-xaml/Mocks/CustomClickButton.cs
  88. +33 −0 src/ReactiveUI.Tests/Platforms/windows-xaml/Mocks/DepObjFixture.cs
  89. +30 −0 src/ReactiveUI.Tests/Platforms/windows-xaml/Mocks/DerivedDepObjFixture.cs
  90. +39 −0 src/ReactiveUI.Tests/Platforms/windows-xaml/Mocks/FakeView.cs
  91. +32 −0 src/ReactiveUI.Tests/Platforms/windows-xaml/Mocks/HostTestView.cs
  92. +8 −36 ...ests/Platforms/{xaml/PropertyBindingTestViews.cs → windows-xaml/Mocks/PropertyBindFakeControl.cs}
  93. +55 −0 src/ReactiveUI.Tests/Platforms/windows-xaml/Mocks/PropertyBindView.cs
  94. +48 −0 src/ReactiveUI.Tests/Platforms/windows-xaml/Mocks/ReactiveObjectCommandBindView.cs
  95. +30 −98 src/ReactiveUI.Tests/{ → Platforms/windows-xaml}/PropertyBindingTest.cs
  96. +27 −0 src/ReactiveUI.Tests/Platforms/windows-xaml/RxAppDependencyObjectTests.cs
  97. +39 −0 src/ReactiveUI.Tests/Platforms/windows-xaml/Utilities/DispatcherUtilities.cs
  98. +13 −3 src/ReactiveUI.Tests/{ → Platforms/windows-xaml}/WeakEventManagerTest.cs
  99. +49 −0 src/ReactiveUI.Tests/Platforms/windows-xaml/WhenAnyThroughDependencyObjectTests.cs
  100. +70 −0 src/ReactiveUI.Tests/Platforms/windows-xaml/XamlViewCommandTests.cs
  101. +65 −0 src/ReactiveUI.Tests/Platforms/windows-xaml/XamlViewDependencyResolverTests.cs
  102. +8 −8 ...sts.Winforms.approved.txt → Platforms/winforms/API/ApiApprovalTests.Winforms.net461.approved.txt}
  103. +27 −0 src/ReactiveUI.Tests/Platforms/winforms/API/WinformsApiApprovalTests.cs
  104. +0 −8 src/ReactiveUI.Tests/Platforms/winforms/ActivationTests.cs
  105. +59 −0 src/ReactiveUI.Tests/Platforms/winforms/CommandBindingImplementationTests.cs
  106. +0 −153 src/ReactiveUI.Tests/Platforms/winforms/CommandBindingTests.cs
  107. +0 −130 src/ReactiveUI.Tests/Platforms/winforms/DefaultPropertyBindingTests.cs
  108. +11 −0 src/ReactiveUI.Tests/Platforms/winforms/Mocks/AnotherView.cs
  109. +12 −0 src/ReactiveUI.Tests/Platforms/winforms/Mocks/ContractExampleView.cs
  110. +20 −0 src/ReactiveUI.Tests/Platforms/winforms/Mocks/CustomClickableComponent.cs
  111. +28 −0 src/ReactiveUI.Tests/Platforms/winforms/Mocks/CustomClickableControl.cs
  112. +17 −0 src/ReactiveUI.Tests/Platforms/winforms/Mocks/ExampleView.cs
  113. +28 −0 src/ReactiveUI.Tests/Platforms/winforms/Mocks/FakeView.cs
  114. +20 −0 src/ReactiveUI.Tests/Platforms/winforms/Mocks/FakeViewLocator.cs
  115. +19 −0 src/ReactiveUI.Tests/Platforms/winforms/Mocks/FakeViewModel.cs
  116. +76 −0 src/ReactiveUI.Tests/Platforms/winforms/Mocks/FakeWinformViewModel.cs
  117. +42 −0 src/ReactiveUI.Tests/Platforms/winforms/Mocks/FakeWinformsView.cs
  118. +18 −0 src/ReactiveUI.Tests/Platforms/winforms/Mocks/NeverUsedView.cs
  119. +18 −0 src/ReactiveUI.Tests/Platforms/winforms/Mocks/SingleInstanceExampleView.cs
  120. +19 −0 src/ReactiveUI.Tests/Platforms/winforms/Mocks/SingleInstanceWithContractExampleView.cs
  121. +13 −0 src/ReactiveUI.Tests/Platforms/winforms/Mocks/TestControl.cs
  122. +13 −0 src/ReactiveUI.Tests/Platforms/winforms/Mocks/TestForm.cs
  123. +35 −0 src/ReactiveUI.Tests/Platforms/winforms/Mocks/ThirdPartyControl.cs
  124. +11 −0 src/ReactiveUI.Tests/Platforms/winforms/Mocks/ViewWithoutMatchingName.cs
  125. +30 −0 src/ReactiveUI.Tests/Platforms/winforms/Mocks/WinformCommandBindView.cs
  126. +35 −0 src/ReactiveUI.Tests/Platforms/winforms/Mocks/WinformCommandBindViewModel.cs
  127. 0 src/ReactiveUI.Tests/Platforms/winforms/{RoutedViewHostTests.cs → WinFormsRoutedViewHostTests.cs}
  128. +108 −0 src/ReactiveUI.Tests/Platforms/winforms/WinFormsViewDependencyResolverTests.cs
  129. +0 −12 ...activeUI.Tests/Platforms/winforms/{ViewModelViewHostTests.cs → WinFormsViewModelViewHostTests.cs}
  130. +124 −0 src/ReactiveUI.Tests/Platforms/wpf/API/ApiApprovalTests.Wpf.net461.approved.txt
  131. +25 −0 src/ReactiveUI.Tests/Platforms/wpf/API/WpfApiApprovalTests.cs
  132. +36 −0 src/ReactiveUI.Tests/Platforms/wpf/Mocks/CommandBindingView.cs
  133. +49 −0 src/ReactiveUI.Tests/Platforms/wpf/Mocks/CommandBindingViewModel.cs
  134. +17 −0 src/ReactiveUI.Tests/Platforms/wpf/Mocks/ExampleWindowView.cs
  135. +19 −0 src/ReactiveUI.Tests/Platforms/wpf/Mocks/WpfTestUserControl.cs
  136. +13 −21 ...I.Tests/Platforms/{xaml/ActivationForViewFetcherTest.cs → wpf/WpfActivationForViewFetcherTest.cs}
  137. +41 −0 src/ReactiveUI.Tests/Platforms/wpf/WpfCommandBindingImplementationTests.cs
  138. +44 −0 src/ReactiveUI.Tests/Platforms/wpf/WpfViewDependencyResolverTests.cs
  139. +0 −2,289 src/ReactiveUI.Tests/ReactiveCollectionTest.cs
  140. +32 −0 src/ReactiveUI.Tests/ReactiveObject/Mocks/OaphNameOfTestFixture.cs
  141. +24 −0 src/ReactiveUI.Tests/ReactiveObject/Mocks/OaphTestFixture.cs
  142. +92 −0 src/ReactiveUI.Tests/ReactiveObject/Mocks/TestFixture.cs
  143. +1 −122 src/ReactiveUI.Tests/{ReactiveObjectTest.cs → ReactiveObject/ReactiveObjectTests.cs}
  144. +31 −9 src/ReactiveUI.Tests/ReactiveUI.Tests.csproj
  145. +109 −0 src/ReactiveUI.Tests/Resolvers/DependencyResolverTests.cs
  146. 0 src/ReactiveUI.Tests/{ → Resolvers}/INPCObservableForPropertyTests.cs
  147. 0 src/ReactiveUI.Tests/{ → Resolvers}/PocoObservableForPropertyTests.cs
  148. +24 −0 src/ReactiveUI.Tests/Routing/Mocks/TestScreen.cs
  149. +28 −0 src/ReactiveUI.Tests/Routing/Mocks/TestViewModel.cs
  150. +17 −23 src/ReactiveUI.Tests/{ → Routing}/RoutableViewModelMixinTests.cs
  151. +1 −27 src/ReactiveUI.Tests/{RoutingState.cs → Routing/RoutingStateTests.cs}
  152. +0 −11 src/ReactiveUI.Tests/RxAppTest.cs
  153. +70 −0 src/ReactiveUI.Tests/Utilities/ApiApprovalBase.cs
  154. +29 −0 src/ReactiveUI.Tests/Utilities/CompatMixins.cs
  155. +47 −0 src/ReactiveUI.Tests/Utilities/CountingTestScheduler.cs
  156. +63 −0 src/ReactiveUI.Tests/Utilities/EnumerableTestMixin.cs
  157. 0 src/ReactiveUI.Tests/{ → Utilities}/JsonHelper.cs
  158. 0 src/ReactiveUI.Tests/{ → Utilities}/TestLogger.cs
  159. +34 −0 src/ReactiveUI.Tests/Utilities/UseInvariantCulture.cs
  160. +0 −132 src/ReactiveUI.Tests/Utility.cs
  161. +34 −0 src/ReactiveUI.Tests/WhenAny/Mockups/HostTestFixture.cs
  162. +12 −0 src/ReactiveUI.Tests/WhenAny/Mockups/NonObservableTestFixture.cs
  163. +32 −0 src/ReactiveUI.Tests/WhenAny/Mockups/NonReactiveINPCObject.cs
  164. +18 −0 src/ReactiveUI.Tests/WhenAny/Mockups/ObjChain1.cs
  165. +18 −0 src/ReactiveUI.Tests/WhenAny/Mockups/ObjChain2.cs
  166. +18 −0 src/ReactiveUI.Tests/WhenAny/Mockups/ObjChain3.cs
  167. +68 −304 src/ReactiveUI.Tests/{ → WhenAny}/ReactiveNotifyPropertyChangedMixinTest.cs
  168. +50 −0 src/ReactiveUI.Tests/WhenAny/TestWhenAnyObsViewModel.cs
  169. +130 −0 src/ReactiveUI.Tests/WhenAny/WhenAnyObservableTests.cs
  170. +1 −1 src/ReactiveUI.Winforms/IReactiveDerivedBindingList.cs
  171. +2 −2 src/ReactiveUI.sln
  172. +2 −7 src/ReactiveUI/{ → Legacy}/CollectionDebugView.cs
  173. +1 −1 src/ReactiveUI/{Registration → Legacy}/RefcountDisposeWrapper.cs
  174. +142 −9 src/analyzers.tests.ruleset
@@ -246,7 +246,7 @@ src/ReactiveUI.Events*/Events_*.cs
# macOS
.DS_Store

src/*.Tests/API/*.received.txt
src/*.Tests/**/ApiApprovalTests*.received.txt
.idea/

# Fody Weavers (for tests)
@@ -12,6 +12,11 @@ pool:
vmImage: vs2017-win2016

steps:
- task: DotNetCoreInstaller@0
displayName: Install Dot Net Core v2.2.1
inputs:
version: '2.2.103'

- task: BatchScript@1
inputs:
filename: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Enterprise\\Common7\\Tools\\VsDevCmd.bat"
@@ -12,6 +12,11 @@ pool:
vmImage: vs2017-win2016

steps:
- task: DotNetCoreInstaller@0
displayName: Install Dot Net Core v2.2.1
inputs:
version: '2.2.103'

- task: BatchScript@1
inputs:
filename: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Enterprise\\Common7\\Tools\\VsDevCmd.bat"
@@ -7,7 +7,7 @@
//////////////////////////////////////////////////////////////////////

#addin "nuget:?package=Cake.FileHelpers&version=3.1.0"
#addin "nuget:?package=Cake.Coveralls&version=0.9.0"
#addin "nuget:?package=Cake.Coverlet&version=2.2.1"
#addin "nuget:?package=Cake.PinNuGetDependency&loaddependencies=true&version=3.2.3"
#addin "nuget:?package=Cake.Powershell&version=0.4.7"
#addin "nuget:?package=Cake.Codecov&version=0.5.0"
@@ -22,11 +22,11 @@
// TOOLS
//////////////////////////////////////////////////////////////////////

#tool "nuget:?package=OpenCover&version=4.6.519"
#tool "nuget:?package=ReportGenerator&version=4.0.4"
#tool "nuget:?package=vswhere&version=2.5.2"
#tool "nuget:?package=xunit.runner.console&version=2.4.1"
#tool "nuget:?package=Codecov&version=1.1.0"
#tool "nuget:?package=OpenCover&version=4.7.906-rc"

//////////////////////////////////////////////////////////////////////
// DOTNET TOOLS
@@ -45,6 +45,12 @@ if (string.IsNullOrWhiteSpace(target))
target = "Default";
}

var configuration = Argument("configuration", "Release");
if (string.IsNullOrWhiteSpace(configuration))
{
configuration = "Release";
}

var includePrerelease = Argument("includePrerelease", false);
var vsLocationString = Argument("vsLocation", string.Empty);
var msBuildPathString = Argument("msBuildPath", string.Empty);
@@ -98,10 +104,16 @@ var packageWhitelist = new[]
"ReactiveUI.LeakTests"
};

var packageTestWhitelist = new[]
(string projectName, bool performCoverageTesting)[] packageTestWhitelist = new[]
{
"ReactiveUI.Tests",
"ReactiveUI.Fody.Tests"
("ReactiveUI.Tests", true),
("ReactiveUI.Fody.Tests", true),
};

(string name, bool performCoverageTesting)[] testFrameworks = new[]
{
("net461", true),
("netcoreapp2.0", false),
};

(string targetName, string destination)[] eventGenerators = new[]
@@ -152,9 +164,9 @@ Teardown(context =>
//////////////////////////////////////////////////////////////////////
// HELPER METHODS
//////////////////////////////////////////////////////////////////////
Action<string, string, bool, bool> Build = (solution, packageOutputPath, createPackage, forceUseFullDebugType) =>
Action<string, string> Build = (solution, packageOutputPath) =>
{
Information("Building {0} using {1}, createPackage = {2}, forceUseFullDebugType = {3}", solution, msBuildPath, createPackage, forceUseFullDebugType);
Information("Building {0} using {1}", solution, msBuildPath);

var msBuildSettings = new MSBuildSettings() {
ToolPath = msBuildPath,
@@ -163,26 +175,13 @@ Action<string, string, bool, bool> Build = (solution, packageOutputPath, createP
Restore = true
}
.WithProperty("TreatWarningsAsErrors", treatWarningsAsErrors.ToString())
.SetConfiguration("Release")
.SetConfiguration(configuration)
.WithTarget("build;pack")
.SetVerbosity(Verbosity.Minimal);

if (forceUseFullDebugType)
{
msBuildSettings = msBuildSettings.WithProperty("DebugType", "full");
}

if (createPackage)
{
if (!string.IsNullOrWhiteSpace(packageOutputPath))
{
msBuildSettings = msBuildSettings.WithProperty("PackageOutputPath", MakeAbsolute(Directory(packageOutputPath)).ToString().Quote());
}

msBuildSettings = msBuildSettings.WithTarget("build;pack");
}
else
if (!string.IsNullOrWhiteSpace(packageOutputPath))
{
msBuildSettings = msBuildSettings.WithTarget("build");
msBuildSettings = msBuildSettings.WithProperty("PackageOutputPath", MakeAbsolute(Directory(packageOutputPath)).ToString().Quote());
}

MSBuild(solution, msBuildSettings);
@@ -195,7 +194,7 @@ Action<string, string, bool, bool> Build = (solution, packageOutputPath, createP
Task("BuildEventBuilder")
.Does(() =>
{
Build("./src/EventBuilder.sln", artifactDirectory + "eventbuilder", false, false);
Build("./src/EventBuilder.sln", artifactDirectory + "eventbuilder");
});

Task("GenerateEvents")
@@ -243,9 +242,9 @@ Task("BuildReactiveUIPackages")
CleanDirectories("./src/**/obj/Release");
CleanDirectories("./src/**/bin/Release");

foreach(var package in packageWhitelist)
foreach(var packageName in packageWhitelist)
{
Build("./src/" + package + "/" + package + ".csproj", packagesArtifactDirectory, true, false);
Build($"./src/{packageName}/{packageName}.csproj", packagesArtifactDirectory);
}

CopyFiles(GetFiles("./src/**/bin/Release/**/*"), Directory(binariesArtifactDirectory), true);
@@ -265,20 +264,21 @@ Task("RunUnitTests")
CleanDirectories("./src/**/obj/Release");
CleanDirectories("./src/**/bin/Release");

foreach (var package in fodyPackages)
foreach (var packageName in fodyPackages)
{
Build("./src/" + package + "/" + package + ".csproj", null, true, true);
Build($"./src/{packageName}/{packageName}.csproj", null);
}

var openCoverSettings = new OpenCoverSettings {
ReturnTargetCodeOffset = 0,
MergeOutput = true,
}
.WithFilter("+[*]*")
.WithFilter("+[ReactiveUI*]*")
.WithFilter("-[*.Testing]*")
.WithFilter("-[*.Tests*]*")
.WithFilter("-[ReactiveUI.Events]*")
.WithFilter("-[Splat*]*")
.WithFilter("-[ReactiveUI.Events*]*")
.WithFilter("-[ReactiveUI*]ReactiveUI.*Legacy*")
.WithFilter("-[ReactiveUI*]ThisAssembly*")
.ExcludeByAttribute("*.ExcludeFromCodeCoverage*")
.ExcludeByFile("*/*Designer.cs")
.ExcludeByFile("*/*.g.cs")
@@ -292,16 +292,37 @@ Task("RunUnitTests")
NoAppDomain = true
};

foreach (var projectName in packageTestWhitelist)
foreach (var packageDetails in packageTestWhitelist)
{
OpenCover(tool =>
{
Build("./src/" + projectName + "/" + projectName + ".csproj", null, true, true);
var packageName = packageDetails.projectName;
var projectName = $"./src/{packageName}/{packageName}.csproj";
Build(projectName, null);

tool.XUnit2("./src/" + projectName + "/bin/" + "**/*.Tests.dll", xunitSettings);
},
testCoverageOutputFile,
openCoverSettings);
foreach (var testFramework in testFrameworks)
{
if (testFramework.performCoverageTesting && packageDetails.performCoverageTesting)
{
Information($"Generate OpenCover information for {packageName} {testFramework.name}");
OpenCover(
tool => tool.XUnit2($"./src/{packageName}/bin/{configuration}/{testFramework.name}/**/*.Tests.dll", xunitSettings),
testCoverageOutputFile,
openCoverSettings);
}
else
{
Information($"Running unit tests only for {packageName} {testFramework.name}");
var testSettings = new DotNetCoreTestSettings {
NoBuild = true,
Framework = testFramework.name,
Configuration = configuration,
ResultsDirectory = testsArtifactDirectory,
Logger = $"trx;LogFileName=testresults-{packageName}-{testFramework.name}.trx",
TestAdapterPath = GetDirectories("./tools/xunit.runner.console*/**/netcoreapp2.0").FirstOrDefault(),
};

DotNetCoreTest(projectName, testSettings);
}
}
}

ReportGenerator(testCoverageOutputFile, testsArtifactDirectory + "Report/");
@@ -1,7 +1,7 @@
// This file is used by Code Analysis to maintain SuppressMessage
// attributes that are applied to this project.
// Project-level suppressions either have no target or are given
// a specific target and scoped to a namespace, type, member, etc.
// Copyright (c) 2019 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.

[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.LayoutRules", "SA1503:Braces should not be omitted", Justification = "NuGet Inclusion", Scope = "member", Target = "~M:PublicApiGenerator.ApiGenerator.AddCtorToTypeDeclaration(System.CodeDom.CodeTypeDeclaration,Mono.Cecil.MethodDefinition,System.Collections.Generic.HashSet{System.String})")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.LayoutRules", "SA1503:Braces should not be omitted", Justification = "NuGet Inclusion", Scope = "member", Target = "~M:PublicApiGenerator.ApiGenerator.AddFieldToTypeDeclaration(System.CodeDom.CodeTypeDeclaration,Mono.Cecil.FieldDefinition,System.Collections.Generic.HashSet{System.String})")]
@@ -14,10 +14,7 @@
<!-- Embed source files that are not tracked by the source control manager in the PDB -->
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<!-- Include PDB in the built .nupkg -->
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
</PropertyGroup>

<PropertyGroup Condition="!$(IsTestProject)">
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)analyzers.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>

@@ -0,0 +1,31 @@
[assembly: System.Runtime.CompilerServices.InternalsVisibleToAttribute("ReactiveUI.AndroidSupport")]
[assembly: System.Runtime.CompilerServices.InternalsVisibleToAttribute("ReactiveUI.Tests")]
[assembly: System.Runtime.CompilerServices.InternalsVisibleToAttribute("ReactiveUI.Winforms")]
[assembly: System.Runtime.CompilerServices.InternalsVisibleToAttribute("ReactiveUI.Wpf")]
[assembly: System.Runtime.CompilerServices.InternalsVisibleToAttribute("ReactiveUI.XamForms")]
[assembly: System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v2.0", FrameworkDisplayName="")]
namespace ReactiveUI.Fody.Helpers
{
[System.AttributeUsageAttribute(System.AttributeTargets.Method | System.AttributeTargets.Property | System.AttributeTargets.All)]
public class ObservableAsPropertyAttribute : System.Attribute
{
public ObservableAsPropertyAttribute() { }
}
public class static ObservableAsPropertyExtensions
{
public static ReactiveUI.ObservableAsPropertyHelper<TRet> ToPropertyEx<TObj, TRet>(this System.IObservable<TRet> @this, TObj source, System.Linq.Expressions.Expression<System.Func<TObj, TRet>> property, TRet initialValue = null, bool deferSubscription = False, System.Reactive.Concurrency.IScheduler scheduler = null)
where TObj : ReactiveUI.ReactiveObject { }
}
[System.AttributeUsageAttribute(System.AttributeTargets.Property | System.AttributeTargets.All)]
public class ReactiveAttribute : System.Attribute
{
public ReactiveAttribute() { }
}
[System.AttributeUsageAttribute(System.AttributeTargets.Property | System.AttributeTargets.All)]
public class ReactiveDependencyAttribute : System.Attribute
{
public ReactiveDependencyAttribute(string targetName) { }
public string Target { get; }
public string TargetProperty { get; set; }
}
}
@@ -14,26 +14,12 @@
namespace ReactiveUI.Fody.Tests.API
{
[ExcludeFromCodeCoverage]
public class ApiApprovalTests
public class ApiApprovalTests : ApiApprovalBase
{
[Fact]
public void ReactiveUIFody()
{
var publicApi = Filter(ApiGenerator.GeneratePublicApi(typeof(ReactiveAttribute).Assembly));
publicApi.ShouldMatchApproved();
}

private static string Filter(string text)
{
return string.Join(Environment.NewLine, text.Split(
new[]
{
Environment.NewLine
}, StringSplitOptions.RemoveEmptyEntries)
.Where(l => !l.StartsWith("[assembly: AssemblyVersion("))
.Where(l => !l.StartsWith("[assembly: AssemblyFileVersion("))
.Where(l => !l.StartsWith("[assembly: AssemblyInformationalVersion("))
.Where(l => !string.IsNullOrWhiteSpace(l)));
CheckApproval(typeof(ReactiveAttribute).Assembly);
}
}
}
@@ -0,0 +1,70 @@
// Copyright (c) 2019 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.

using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using PublicApiGenerator;
using Shouldly;
using Splat;
using Xunit;

namespace ReactiveUI.Fody.Tests
{
[ExcludeFromCodeCoverage]
public abstract class ApiApprovalBase
{
private static readonly Regex _removeCoverletSectionRegex = new Regex(@"^namespace Coverlet\.Core\.Instrumentation\.Tracker.*?^}", RegexOptions.Singleline | RegexOptions.Multiline | RegexOptions.Compiled);

protected static void CheckApproval(Assembly assembly, [CallerMemberName]string memberName = null, [CallerFilePath]string filePath = null)
{
var targetFrameworkName = Assembly.GetExecutingAssembly().GetTargetFrameworkName();

var sourceDirectory = Path.GetDirectoryName(filePath);

var approvedFileName = Path.Combine(sourceDirectory, $"ApiApprovalTests.{memberName}.{targetFrameworkName}.approved.txt");
var receivedFileName = Path.Combine(sourceDirectory, $"ApiApprovalTests.{memberName}.{targetFrameworkName}.received.txt");

string approvedPublicApi = string.Empty;

if (File.Exists(approvedFileName))
{
approvedPublicApi = File.ReadAllText(approvedFileName);
}

var receivedPublicApi = Filter(ApiGenerator.GeneratePublicApi(assembly));

if (!string.Equals(receivedPublicApi, approvedPublicApi, StringComparison.InvariantCulture))
{
File.WriteAllText(receivedFileName, receivedPublicApi);
ShouldlyConfiguration.DiffTools.GetDiffTool().Open(receivedFileName, approvedFileName, true);
}

Assert.Equal(approvedPublicApi, receivedPublicApi);
}

private static string Filter(string text)
{
text = _removeCoverletSectionRegex.Replace(text, string.Empty);
return string.Join(Environment.NewLine, text.Split(
new[]
{
Environment.NewLine
}, StringSplitOptions.RemoveEmptyEntries)
.Where(l =>
!l.StartsWith("[assembly: AssemblyVersion(", StringComparison.InvariantCulture) &&
!l.StartsWith("[assembly: AssemblyFileVersion(", StringComparison.InvariantCulture) &&
!l.StartsWith("[assembly: AssemblyInformationalVersion(", StringComparison.InvariantCulture) &&
!string.IsNullOrWhiteSpace(l)));
}
}
}
Oops, something went wrong.

0 comments on commit 8eb0c1d

Please sign in to comment.
You can’t perform that action at this time.