Skip to content

Commit

Permalink
Merge branch 'migate/net/9' into dependabot/nuget/src/dev/Microsoft.N…
Browse files Browse the repository at this point in the history
…ET.Test.Sdk-17.12.0
  • Loading branch information
michaelmairegger authored Dec 16, 2024
2 parents 740c20f + 1fa11e8 commit 93bd2f3
Show file tree
Hide file tree
Showing 23 changed files with 162 additions and 153 deletions.
5 changes: 5 additions & 0 deletions .gitbugtraq
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[bugtraq "CVE"]
url = https://nvd.nist.gov/vuln/detail/%BUGID%
logfilterregex = "CVE-\\d{4}-\\d+"
loglinkregex = "CVE-\\d{4}-\\d+"
logregex = "CVE-\\d{4}-\\d+"
17 changes: 5 additions & 12 deletions src/Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
<Project>
<Import Project="Versions.props" />

<PropertyGroup Label="Target Frameworks">
<NetCoreAppCurrent Condition="'$(CurrentNetVersion)' != ''">net$(CurrentNetVersion.Substring(0,3))</NetCoreAppCurrent>
<NetCoreAppPrevious Condition="'$(PreviousNetVersion)' != ''">net$(PreviousNetVersion.Substring(0,3))</NetCoreAppPrevious>
<NetCoreAppMinimum Condition="'$(MinimumNetVersion)' != ''">net$(MinimumNetVersion.Substring(0,3))</NetCoreAppMinimum>

<NetCoreWpfCurrent Condition="'$(CurrentNetVersion)' != ''">$(NetCoreAppCurrent)-windows$(WindowsSdkVersion)</NetCoreWpfCurrent>
<NetCoreWpfPrevious Condition="'$(PreviousNetVersion)' != ''">$(NetCoreAppPrevious)-windows$(WindowsSdkVersion)</NetCoreWpfPrevious>
<NetCoreWpfMinimum Condition="'$(MinimumNetVersion)' != ''">$(NetCoreAppMinimum)-windows$(WindowsSdkVersion)</NetCoreWpfMinimum>

<AspNetCoreVersion Condition="'$(CurrentNetVersion)' != '' and $(TargetFramework.StartsWith($(NetCoreAppCurrent)))">$(CurrentNetVersion)</AspNetCoreVersion>
<AspNetCoreVersion Condition="'$(PreviousNetVersion)' != '' and $(TargetFramework.StartsWith($(NetCoreAppPrevious)))">$(PreviousNetVersion)</AspNetCoreVersion>
<AspNetCoreVersion Condition="'$(MinimumNetVersion)' != '' and $(TargetFramework.StartsWith($(NetCoreAppMinimum)))">$(MinimumNetVersion)</AspNetCoreVersion>
</PropertyGroup>

<PropertyGroup Label="Set WPF properties">
<TargetFrameworks>$(NetCoreWpfCurrent);$(NetCoreWpfPrevious);$(NetCoreWpfMinimum);$(NetFrameworkMinimum)</TargetFrameworks>
<UseWPF>true</UseWPF>
</PropertyGroup>

<PropertyGroup Label="NuGet settings">
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<EnablePackageVersionOverride>false</EnablePackageVersionOverride>
Expand All @@ -29,27 +24,25 @@
<!-- Duplicate 'PackageVersion' items found -->
<!--<WarningsAsErrors>$(WarningsAsErrors);NU1507</WarningsAsErrors> -->
<!-- Multiple package source defined in config file -->

<!-- A package restored for your project has a known vulnerability. -->
<WarningsAsErrors Label="Package X has a known low severity vulnerability">$(WarningsAsErrors);NU1901</WarningsAsErrors>
<WarningsAsErrors Label="Package X has a known moderate severity vulnerability">$(WarningsAsErrors);NU1902</WarningsAsErrors>
<WarningsAsErrors Label="Package X has a known high severity vulnerability">$(WarningsAsErrors);NU1903</WarningsAsErrors>
<WarningsAsErrors Label="Package X has a known critical severity vulnerability">$(WarningsAsErrors);NU1904</WarningsAsErrors>
</PropertyGroup>

<PropertyGroup Label="Source commit tagging" Condition="'$(Configuration)' != 'Release'">
<!-- Note: This prevents rebuilding all projects because of a commit, since build steps injects version information into projects. -->
<NBGV_GitEngine>Disabled</NBGV_GitEngine>
<EnableSourceLink>false</EnableSourceLink> <!-- prevents generation of $(ProjectName).sourcelink.json -->
<EnableSourceLink>false</EnableSourceLink>
<!-- prevents generation of $(ProjectName).sourcelink.json -->
</PropertyGroup>

<ItemGroup>
<PackageReference Include="JetBrains.Annotations" PrivateAssets="all" />
<GlobalPackageReference Include="Nerdbank.GitVersioning" PrivateAssets="all" Version="$(NerdbankGitVersioningVersion)" />
<GlobalPackageReference Include="WpfAnalyzers" Condition="'$(UseWpf)' == 'true'" Version="$(WpfAnalyzersVersion)" />
</ItemGroup>

<ItemGroup>
<PackageVersion Include="Enums.NET" Version="5.0.0" />
<PackageVersion Include="JetBrains.Annotations" Version="2024.3.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNETTestSdkVersion)" />
<PackageVersion Include="Moq" Version="$(MoqVersion)" />
Expand All @@ -59,7 +52,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageVersion>
<PackageVersion Include="NUnit3TestAdapter" Version="$(NUnit3TestAdapter)" />
<PackageVersion Include="System.Drawing.Common" Version="8.0.10" />
<PackageVersion Include="System.Drawing.Common" Version="9.0.0" />
<PackageVersion Include="coverlet.collector" Version="$(CoverletCollectorVersion)" />
</ItemGroup>
</Project>
</Project>
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Copyright 2016 Michael Mairegger
//
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//
// http://www.apache.org/licenses/LICENSE-2.0
//
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -28,20 +28,14 @@ public class CombinedPrintContentCollectionTests
[Apartment(ApartmentState.STA)]
public void Content()
{
Mock<IPrintContent>[] m1 =
{
new Mock<IPrintContent>(),
new Mock<IPrintContent>(),
new Mock<IPrintContent>(),
new Mock<IPrintContent>()
};
Mock<IPrintContent>[] m1 = [new (), new (), new (), new ()];

foreach (var mock in m1)
{
mock.SetupGet(i => i.Content).Returns(new UIElement());
}

CombinedPrintContentCollection collection = new CombinedPrintContentCollection(m1.Select(i => i.Object).ToArray());
var collection = new CombinedPrintContentCollection(m1.Select(i => i.Object).ToArray());

Assert.Multiple(() =>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Copyright 2016 Michael Mairegger
//
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//
// http://www.apache.org/licenses/LICENSE-2.0
//
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -30,13 +30,7 @@ public class PrintProcessorCollectionTests
[Test]
public void Ctor()
{
Mock<Printing.PrintProcessor.PrintProcessor>[] m1 =
{
new Mock<Printing.PrintProcessor.PrintProcessor>(),
new Mock<Printing.PrintProcessor.PrintProcessor>(),
new Mock<Printing.PrintProcessor.PrintProcessor>(),
new Mock<Printing.PrintProcessor.PrintProcessor>()
};
Mock<Printing.PrintProcessor.PrintProcessor>[] m1 = [new(), new(), new(), new()];
PrintProcessorCollection pp = new PrintProcessorCollection(m1.Select(i => i.Object), "FileName");
Assert.That(pp, Is.EqualTo(m1.Select(i => i.Object)).AsCollection);

Expand Down Expand Up @@ -86,18 +80,18 @@ public void PreviewDocument()

windowProvider.Verify(i => i.Show(It.IsNotNull<string>(), It.IsNotNull<DocumentViewer>()), Times.Never);
}

[Test]
[Apartment(ApartmentState.STA)]
public void PrintEverything()
{
var printDialog = new Mock<IPrintDialog>();
var printProcessor = new PrintEverything() { PrintDialog = printDialog.Object };

var windowProvider = new Mock<IWindowProvider>();
Assert.That(printProcessor.PrintDocument(), Is.True);
printProcessor.PreviewDocument(windowProvider.Object);

windowProvider.Verify(i => i.Show(It.IsNotNull<string>(), It.IsNotNull<DocumentViewer>()), Times.Once);
}

Expand Down
14 changes: 7 additions & 7 deletions src/Mairegger.Printing.Test/Content/PrintProcessorTests.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Copyright 2016 Michael Mairegger
//
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//
// http://www.apache.org/licenses/LICENSE-2.0
//
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand Down Expand Up @@ -70,7 +70,7 @@ public void Ctor()
[Test]
public void CustomAlternatingRowColors([Random(10, 20, 1)] int itemCount, [Random(3, 7, 1)] int differentColors)
{
IList<IPrintContent> retrievedContent = new List<IPrintContent>();
var retrievedContent = new List<IPrintContent>();
var pp = new PrintProcessorWithPrintOnAllPages(retrievedContent)
{
ItemCount = itemCount,
Expand Down Expand Up @@ -148,7 +148,7 @@ public void GetSummary_Throws_IfNotImplemented()
[Test]
public void IsAlternatingRowColor_False_NotColoring()
{
IList<IPrintContent> retrievedContent = new List<IPrintContent>();
var retrievedContent = new List<IPrintContent>();
var pp = new PrintProcessorWithPrintOnAllPages(retrievedContent)
{
ItemCount = 3,
Expand All @@ -172,7 +172,7 @@ public void IsAlternatingRowColor_False_NotColoring()
[Test]
public void IsAlternatingRowColor_True_Coloring()
{
IList<IPrintContent> retrievedContent = new List<IPrintContent>();
var retrievedContent = new List<IPrintContent>();
var pp = new PrintProcessorWithPrintOnAllPages(retrievedContent)
{
ItemCount = 10,
Expand Down Expand Up @@ -201,7 +201,7 @@ public void NoItemsOnPrintout()
{
PrintDialog = printDialog.Object
};

Assert.That(printProcessor.PrintDocument(), Is.True);
}

Expand Down
12 changes: 6 additions & 6 deletions src/Mairegger.Printing.Test/Content/TestPrintProcessor.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Copyright 2016 Michael Mairegger
//
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//
// http://www.apache.org/licenses/LICENSE-2.0
//
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand Down Expand Up @@ -69,7 +69,7 @@ protected override void PreparePrint()
PrintDimension.PageSize = new Size(500, 100);
}
}

[PrintOnPage(PrintAppendixes.PageNumbers, 2)]
public class TestPrintProcessor : PrintProcessor
{
Expand Down Expand Up @@ -114,7 +114,7 @@ public override UIElement GetTable(out double reserveHeightOf, out Brush borderB

public override IEnumerable<IPrintContent> ItemCollection()
{
return Enumerable.Empty<IPrintContent>();
return [];
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Copyright 2016 Michael Mairegger
//
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//
// http://www.apache.org/licenses/LICENSE-2.0
//
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -23,25 +23,13 @@ namespace Mairegger.Printing.Tests.Definition
[SuppressMessage("ReSharper", "ObjectCreationAsStatement", Justification = "OK")]
public class ColumnDimensionAttributeTests
{
private static readonly double[] Values =
{
2,
3,
4,
5,
6,
7,
8,
9,
10,
11
};
private static readonly double[] Values = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11];

[Test]
[TestCaseSource(nameof(Values))]
public void AbsoluteWidth_Test(double param)
{
double width = param * 100;
var width = param * 100;
var v = new ColumnDimensionAttribute(width, ColumnDimensionType.Pixels);
Assert.Multiple(() =>
{
Expand Down
12 changes: 8 additions & 4 deletions src/Mairegger.Printing/Content/BlankLine.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Copyright 2016 Michael Mairegger
//
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//
// http://www.apache.org/licenses/LICENSE-2.0
//
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand All @@ -23,13 +23,17 @@ internal class BlankLine : IPrintContent

internal BlankLine(double height)
{
#if NETFRAMEWORK
if (height <= 0)
{
throw new ArgumentOutOfRangeException(nameof(height));
}
#else
ArgumentOutOfRangeException.ThrowIfNegativeOrZero(height);
#endif
_height = height;
}

public UIElement Content => new FrameworkElement { Height = _height };
}
}
}
8 changes: 4 additions & 4 deletions src/Mairegger.Printing/Content/StringLineItem.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Copyright 2017 Michael Mairegger
//
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//
// http://www.apache.org/licenses/LICENSE-2.0
//
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand Down Expand Up @@ -83,7 +83,7 @@ public IEnumerable<UIElement> PageContents(double currentPageHeight, Size printa
{
var linesThatHaveSpace = (int)(printablePageHeight / lineHeight * .95); // remove 5% of the page height

var line = reflectionGetLine.Invoke(textBlock, new object[] { currentLine }) ?? throw new InvalidOperationException("Reception exception");
var line = reflectionGetLine.Invoke(textBlock, [currentLine]) ?? throw new InvalidOperationException("Reception exception");

if (reflectionLineLength == null)
{
Expand Down
Loading

0 comments on commit 93bd2f3

Please sign in to comment.