Skip to content

Commit

Permalink
Test cleanup and release prep
Browse files Browse the repository at this point in the history
  • Loading branch information
daveaglick committed May 26, 2021
1 parent d2d64fc commit 4626e1b
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 10 deletions.
2 changes: 2 additions & 0 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# 3.2.2

- Fixed a bug with WPF custom control libraries (#178, #179, thanks @markrendle)

# 3.2.1

- Sets SolutionFilePath in the Workspace Solution when it's available (#177, thanks @markrendle)
Expand Down
6 changes: 3 additions & 3 deletions src/Buildalyzer/Logging/EventProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,15 @@ private void ProjectStarted(object sender, ProjectStartedEventArgs e)
_currentResult.Push(result);
return;
}

// Push a null result so the stack is balanced on project finish
_currentResult.Push(null);
}

// Push a null result so the stack is balanced on project finish
// _currentResult.Push(null);
}

private void ProjectFinished(object sender, ProjectFinishedEventArgs e)
{
// Make sure this is the same project, nested MSBuild tasks may have spawned additional builds of other projects
if (AnalyzerManager.NormalizePath(e.ProjectFile) == _projectFilePath)
{
AnalyzerResult result = _currentResult.Pop();
Expand Down
33 changes: 26 additions & 7 deletions tests/Buildalyzer.Tests/Integration/SimpleProjectsFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public class SimpleProjectsFixture
@"SdkNetCoreProjectImport\SdkNetCoreProjectImport.csproj",
@"SdkNetCoreProjectWithReference\SdkNetCoreProjectWithReference.csproj",
@"SdkNetCoreProjectWithImportedProps\SdkNetCoreProjectWithImportedProps.csproj",
@"SdkNetCoreProjectWithAnalyzer\SdkNetCoreProjectWithAnalyzer.csproj",
@"SdkNetStandardProject\SdkNetStandardProject.csproj",
@"SdkNetStandardProjectImport\SdkNetStandardProjectImport.csproj",
@"SdkNetStandardProjectWithPackageReference\SdkNetStandardProjectWithPackageReference.csproj",
Expand Down Expand Up @@ -196,6 +197,29 @@ public void GetsSourceFilesFromBinaryLog(
}

#if Is_Windows
[Test]
public void WpfControlLibraryGetsSourceFiles()
{
// Given
StringWriter log = new StringWriter();
IProjectAnalyzer analyzer = GetProjectAnalyzer(@"WpfCustomControlLibrary1\WpfCustomControlLibrary1.csproj", log);

// When
IAnalyzerResults results = analyzer.Build();

// Then
IReadOnlyList<string> sourceFiles = results.SingleOrDefault()?.SourceFiles;
sourceFiles.ShouldNotBeNull(log.ToString());
new[]
{
"CustomControl1.cs",
"AssemblyInfo.cs",
"Resources.Designer.cs",
"Settings.Designer.cs",
"GeneratedInternalTypeHelper.g.cs"
}.ShouldBeSubsetOf(sourceFiles.Select(x => Path.GetFileName(x)), log.ToString());
}

[Test]
public void MultiTargetingBuildAllTargetFrameworksGetsSourceFiles()
{
Expand All @@ -211,19 +235,15 @@ public void MultiTargetingBuildAllTargetFrameworksGetsSourceFiles()
results.TargetFrameworks.ShouldBe(new[] { "net462", "netstandard2.0" }, true, log.ToString());
new[]
{
#if Is_Windows
// Linux and Mac builds appear to omit the AssemblyAttributes.cs file
"AssemblyAttributes",
#endif
"Class1",
"AssemblyInfo"
}.ShouldBeSubsetOf(results["net462"].SourceFiles.Select(x => Path.GetFileName(x).Split('.').TakeLast(2).First()), log.ToString());
new[]
{
#if Is_Windows
// Linux and Mac builds appear to omit the AssemblyAttributes.cs file
"AssemblyAttributes",
#endif
"Class2",
"AssemblyInfo"
}.ShouldBeSubsetOf(results["netstandard2.0"].SourceFiles.Select(x => Path.GetFileName(x).Split('.').TakeLast(2).First()), log.ToString());
Expand Down Expand Up @@ -254,10 +274,8 @@ public void MultiTargetingBuildFrameworkTargetFrameworkGetsSourceFiles()
sourceFiles.ShouldNotBeNull(log.ToString());
new[]
{
#if Is_Windows
// Linux and Mac builds appear to omit the AssemblyAttributes.cs file
"AssemblyAttributes",
#endif
"Class1",
"AssemblyInfo"
}.ShouldBeSubsetOf(sourceFiles.Select(x => Path.GetFileName(x).Split('.').TakeLast(2).First()), log.ToString());
Expand Down Expand Up @@ -469,8 +487,9 @@ public void GetsProjectGuidFromProject([ValueSource(nameof(Preferences))] Enviro

// Then
// The generated GUIDs are based on subpath, so they'll be different from Windows to Linux
// They can also change between MSBuild versions, so this may need to be updated periodically
#if Is_Windows
results.First().ProjectGuid.ToString().ShouldBe("646a532e-8943-5a4b-b106-e1341b4d3535");
results.First().ProjectGuid.ToString().ShouldBe("432bfde1-4768-5837-8e20-8bb49c9d4734");
#else
results.First().ProjectGuid.ToString().ShouldBe("c9df4376-d954-5554-bd10-b9976b7afa9d");
#endif
Expand Down
24 changes: 24 additions & 0 deletions tests/projects/TestProjects.sln
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SdkNetStandardProjectWithCo
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SdkNetCore31Project", "SdkNetCore31Project\SdkNetCore31Project.csproj", "{B232D064-749F-4AA3-A70A-692694887388}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfCustomControlLibrary1", "WpfCustomControlLibrary1\WpfCustomControlLibrary1.csproj", "{AED0D0E7-7312-49A9-A439-083F34286286}"
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharpProject", "FSharpProject\FSharpProject.fsproj", "{E35A6E4B-9E1F-495B-A61D-9285AE8A8777}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SdkNetCoreProjectWithAnalyzer", "SdkNetCoreProjectWithAnalyzer\SdkNetCoreProjectWithAnalyzer.csproj", "{3A1FE1AA-5C24-409F-94D1-3D387F0E26DB}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TransitiveProjectReference", "TransitiveProjectReference\TransitiveProjectReference.csproj", "{786A9A41-7629-4457-BC9D-67AC055533A0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -94,6 +102,22 @@ Global
{B232D064-749F-4AA3-A70A-692694887388}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B232D064-749F-4AA3-A70A-692694887388}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B232D064-749F-4AA3-A70A-692694887388}.Release|Any CPU.Build.0 = Release|Any CPU
{AED0D0E7-7312-49A9-A439-083F34286286}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AED0D0E7-7312-49A9-A439-083F34286286}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AED0D0E7-7312-49A9-A439-083F34286286}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AED0D0E7-7312-49A9-A439-083F34286286}.Release|Any CPU.Build.0 = Release|Any CPU
{E35A6E4B-9E1F-495B-A61D-9285AE8A8777}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E35A6E4B-9E1F-495B-A61D-9285AE8A8777}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E35A6E4B-9E1F-495B-A61D-9285AE8A8777}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E35A6E4B-9E1F-495B-A61D-9285AE8A8777}.Release|Any CPU.Build.0 = Release|Any CPU
{3A1FE1AA-5C24-409F-94D1-3D387F0E26DB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3A1FE1AA-5C24-409F-94D1-3D387F0E26DB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3A1FE1AA-5C24-409F-94D1-3D387F0E26DB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3A1FE1AA-5C24-409F-94D1-3D387F0E26DB}.Release|Any CPU.Build.0 = Release|Any CPU
{786A9A41-7629-4457-BC9D-67AC055533A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{786A9A41-7629-4457-BC9D-67AC055533A0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{786A9A41-7629-4457-BC9D-67AC055533A0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{786A9A41-7629-4457-BC9D-67AC055533A0}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down

0 comments on commit 4626e1b

Please sign in to comment.