Skip to content

Commit

Permalink
update deps; test against net6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
fakefeik committed Dec 1, 2021
1 parent e8f79a6 commit 48da86d
Show file tree
Hide file tree
Showing 14 changed files with 122 additions and 88 deletions.
12 changes: 12 additions & 0 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": 1,
"isRoot": true,
"tools": {
"jetbrains.resharper.globaltools": {
"version": "2021.2.2",
"commands": [
"jb"
]
}
}
}
73 changes: 40 additions & 33 deletions Common.DotSettings

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
<PackageReference Include="Nerdbank.GitVersioning" Version="3.3.37" PrivateAssets="All" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
<PackageReference Include="Nerdbank.GitVersioning" Version="3.4.244" PrivateAssets="All" />
</ItemGroup>

</Project>
12 changes: 6 additions & 6 deletions Excel.TemplateEngine.Tests/Excel.TemplateEngine.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net48;net5.0</TargetFrameworks>
<TargetFrameworks>net48;net6.0</TargetFrameworks>
<IsPackable>false</IsPackable>
<AssemblyName>SkbKontur.Excel.TemplateEngine.Tests</AssemblyName>
<RootNamespace>SkbKontur.Excel.TemplateEngine.Tests</RootNamespace>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="5.10.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />
<PackageReference Include="NUnit" Version="3.13.1" />
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
<PackageReference Include="Vostok.Logging.Console" Version="1.0.5" />
<PackageReference Include="FluentAssertions" Version="6.2.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="NUnit" Version="3.13.2" />
<PackageReference Include="NUnit3TestAdapter" Version="4.1.0" />
<PackageReference Include="Vostok.Logging.Console" Version="1.0.6" />
</ItemGroup>

<ItemGroup>
Expand Down
31 changes: 20 additions & 11 deletions Excel.TemplateEngine.Tests/ObjectPrintingTests/ExcelParsingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using SkbKontur.Excel.TemplateEngine.ObjectPrinting.TableNavigator;
using SkbKontur.Excel.TemplateEngine.ObjectPrinting.TableParser;

using Vostok.Logging.Abstractions;
using Vostok.Logging.Console;

namespace SkbKontur.Excel.TemplateEngine.Tests.ObjectPrintingTests
Expand All @@ -32,6 +33,12 @@ internal class SingleStringContainer
[TestFixture]
public class ExcelParsingTests : FileBasedTestBase
{
[Test]
public void Create()
{
ExcelDocumentFactory.TryCreateFromTemplate(File.ReadAllBytes(@"C:\Users\p.vostretsov\Downloads\ДМ_2010.xlsx"), new ConsoleLog());
}

[Test]
public void TestStringsWithManyFormattedFragments()
{
Expand Down Expand Up @@ -79,14 +86,16 @@ public void TestEnumerableWithPrimaryKey()
}

model.Type.Should().Be("Основной");
model.Items.Should().BeEquivalentTo(
new Item {Id = "2311129000009", Name = "СЫР ГОЛЛАНДСКИЙ МОЖГА 1КГ", BuyerProductId = "000074467", Articul = "123456"},
new Item {Id = "2311131000004", Name = "СЫР РОССИЙСКИЙ МОЖГА 1КГ", BuyerProductId = "000074468", Articul = "123457"},
new Item {Id = null, Name = "Товар 3"},
new Item {Id = "123", Articul = "3123123"},
new Item {Id = "111", Articul = "111111"},
new Item {Name = "Товар 6"},
new Item {Id = "222", Name = "Товар 7", Articul = "123"}
model.Items.Should().BeEquivalentTo(new[]
{
new Item {Id = "2311129000009", Name = "СЫР ГОЛЛАНДСКИЙ МОЖГА 1КГ", BuyerProductId = "000074467", Articul = "123456"},
new Item {Id = "2311131000004", Name = "СЫР РОССИЙСКИЙ МОЖГА 1КГ", BuyerProductId = "000074468", Articul = "123457"},
new Item {Id = null, Name = "Товар 3"},
new Item {Id = "123", Articul = "3123123"},
new Item {Id = "111", Articul = "111111"},
new Item {Name = "Товар 6"},
new Item {Id = "222", Name = "Товар 7", Articul = "123"}
}
);
}

Expand Down Expand Up @@ -186,7 +195,7 @@ public void TestImportAfterCreate(string extension)
using (var targetDocument = ExcelDocumentFactory.CreateFromTemplate(File.ReadAllBytes(GetFilePath($"empty.{extension}")), logger))
{
var template = new ExcelTable(templateDocument.GetWorksheet(0));
var templateEngine = new SkbKontur.Excel.TemplateEngine.TemplateEngine(template, logger);
var templateEngine = new TemplateEngine(template, logger);

var target = new ExcelTable(targetDocument.GetWorksheet(0));
var tableNavigator = new TableNavigator(new CellPosition("A1"), logger);
Expand Down Expand Up @@ -219,7 +228,7 @@ public void TestImportAfterCreate(string extension)
using (var targetDocument = ExcelDocumentFactory.CreateFromTemplate(targetBytes, logger))
{
var template = new ExcelTable(templateDocument.GetWorksheet(0));
var templateEngine = new SkbKontur.Excel.TemplateEngine.TemplateEngine(template, logger);
var templateEngine = new TemplateEngine(template, logger);

var target = new ExcelTable(targetDocument.GetWorksheet(0));
var tableNavigator = new TableNavigator(new CellPosition("A1"), logger);
Expand Down Expand Up @@ -255,7 +264,7 @@ public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
if (obj.GetType() != GetType()) return false;
return Equals((Item)obj);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public void TestPrintingComments()
}

/// <summary>
/// output file must contain the same comments, but one author
/// output file must contain the same comments, but one author
/// </summary>
[Test]
public void TestPrintingCommentsWithSeveralAuthors()
Expand All @@ -223,7 +223,7 @@ public void TestPrintingCommentsWithSeveralAuthors()
Assert.Fail($"Please manually open file:\n{path}\nand check that cells has same comments as in\n{templatePath}\n");
}
}

/// <summary>
/// output file must contain data validations AND rendered comment
/// </summary>
Expand Down Expand Up @@ -255,7 +255,7 @@ public void TestPrintingCommentsWithEnabledDataValidationByOtherSheetData()
- D4-D7 has data validation with values from the second worksheet and G4-G7 has data validation with values from K1:K6");
}
}

private void CopySecondaryWorksheets(IExcelDocument templateDocument, IExcelDocument targetDocument)
{
foreach (var index in Enumerable.Range(1, templateDocument.GetWorksheetCount() - 1))
Expand Down
8 changes: 4 additions & 4 deletions Excel.TemplateEngine/Excel.TemplateEngine.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
<ItemGroup>
<PackageReference Include="morelinq" Version="3.3.2" />
<PackageReference Include="C5" Version="2.5.3" />
<PackageReference Include="DocumentFormat.OpenXml" Version="2.12.3" />
<PackageReference Include="JetBrains.Annotations" Version="2020.3.0" />
<PackageReference Include="Vostok.Logging.Abstractions" Version="1.0.20" />
<PackageReference Include="DocumentFormat.OpenXml" Version="2.14.0" />
<PackageReference Include="JetBrains.Annotations" Version="2021.3.0" />
<PackageReference Include="Vostok.Logging.Abstractions" Version="1.0.21" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)'=='net471'">
<!-- we need to reference System.IO.Packaging directly since net46-targeted DocumentFormat.OpenXml package does not depend on it anymore (see https://github.com/OfficeDev/Open-XML-SDK/pull/783) -->
<PackageReference Include="System.IO.Packaging" Version="5.0.0" />
<PackageReference Include="System.IO.Packaging" Version="6.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ public ExcelCellIndex Subtract(ExcelCellIndex other)
public int RowIndex { get; }
public int ColumnIndex { get; }

private static string ToCellReference(int rowIndex, int columnIndex)
private static string ToCellReference(int rowIndex, int columnIndex)
=> $"{ToColumnName(columnIndex)}{rowIndex}";

private static string ToCellReference(uint rowIndex, int columnIndex)
private static string ToCellReference(uint rowIndex, int columnIndex)
=> ToCellReference((int)rowIndex, columnIndex);

private static int ToRowIndex(string cellReference)
private static int ToRowIndex(string cellReference)
=> int.Parse(new Regex("[A-Z]+").Replace(cellReference, ""));

private static int ToColumnIndex(string cellReference)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public ExcelCell(Cell cell, IExcelDocumentStyle documentStyle, IExcelSharedStrin
this.excelSharedStrings = excelSharedStrings;
}

public IExcelCell SetStringValue(string value)
public IExcelCell SetStringValue(string value)
=> SetFormattedStringValue(new FormattedStringValue
{
Blocks = new[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,5 @@ private static T InsertWorksheetChild<T>(Worksheet openXmlWorksheetNodesOrder, T
private readonly ILog logger;
private readonly Worksheet worksheet;
private readonly TreeDictionary<uint, Row> rowsCache;

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ public ExcelCell(IExcelCell excelCell)
internalCell = excelCell;
}

public string StringValue
{
get => internalCell.GetStringValue();
set => internalCell.SetStringValue(value);
}
public string StringValue { get => internalCell.GetStringValue(); set => internalCell.SetStringValue(value); }

public CellType CellType
{
Expand Down
22 changes: 11 additions & 11 deletions Excel.TemplateEngine/ObjectPrinting/Helpers/TypeCheckingHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ public static bool IsEnumerable(Type type)
=> type != typeof(string) &&
(IsEnumerableDirectly(type) || type.GetInterfaces().Any(IsEnumerableDirectly));

public static bool IsDictionary(Type type)
public static bool IsDictionary(Type type)
=> IsDictionaryDirectly(type) || type.GetInterfaces().Any(IsDictionaryDirectly);

public static bool IsIList(Type type)
public static bool IsIList(Type type)
=> type != typeof(string) && (IsIListDirectly(type) || type.GetInterfaces().Any(IsIListDirectly));

public static bool IsNullable(Type type)
public static bool IsNullable(Type type)
=> Nullable.GetUnderlyingType(type) != null;

public static Type GetEnumerableItemType(Type type)
public static Type GetEnumerableItemType(Type type)
=> GetImplementedEnumerableInterface(type).GetGenericArguments().SingleOrDefault() ?? typeof(object);

public static Type GetIListItemType(Type type)
public static Type GetIListItemType(Type type)
=> GetImplementedIListInterface(type).GetGenericArguments().SingleOrDefault() ?? typeof(object);

public static (Type keyType, Type valueType) GetDictionaryGenericTypeArguments(Type type)
Expand Down Expand Up @@ -61,22 +61,22 @@ private static Type GetImplementedIListInterface(Type type)
return type.GetInterfaces().FirstOrDefault(IsGenericIListDirectly) ?? type.GetInterfaces().FirstOrDefault(IsIListDirectly);
}

private static bool IsGenericEnumerableDirectly(Type type)
private static bool IsGenericEnumerableDirectly(Type type)
=> type.IsGenericType && type.GetGenericTypeDefinition() == typeof(IEnumerable<>);

private static bool IsGenericDictionaryDirectly(Type type)
private static bool IsGenericDictionaryDirectly(Type type)
=> type.IsGenericType && type.GetGenericTypeDefinition() == typeof(IDictionary<,>);

private static bool IsEnumerableDirectly(Type type)
private static bool IsEnumerableDirectly(Type type)
=> type == typeof(IEnumerable) || IsGenericEnumerableDirectly(type);

private static bool IsDictionaryDirectly(Type type)
private static bool IsDictionaryDirectly(Type type)
=> type == typeof(IDictionary) || IsGenericDictionaryDirectly(type);

private static bool IsIListDirectly(Type type)
private static bool IsIListDirectly(Type type)
=> type == typeof(IList) || IsGenericIListDirectly(type);

private static bool IsGenericIListDirectly(Type type)
private static bool IsGenericIListDirectly(Type type)
=> type.IsGenericType && type.GetGenericTypeDefinition() == typeof(IList<>);
}
}
24 changes: 17 additions & 7 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,46 @@ skip_commits:
files:
- '**/*.md'

image: Visual Studio 2019
image: Visual Studio 2022

init:
- cmd: git config --global core.autocrlf false

nuget:
disable_publish_on_pr: true

before_build:
- ps: |
$ErrorActionPreference = "Stop"
$tagName = $env:APPVEYOR_REPO_TAG_NAME
if ($tagName -match '^v\d+\.\d+') # tag name starts with 'vX.Y'
{
$version = $tagName.Substring(1)
$env:SHOULD_PUBLISH_NUGET_PACKAGE = "true"
Write-Host "Will publish nuget package for $tagName tag" -ForegroundColor "Green"
if ($tagName -match '^v\d+\.\d+-release') # tag name starts with 'vX.Y-release' (e.g. use 'v4.2-release.1' tag for the first patch for release v4.2)
{
$version = $version.Substring(0, $version.IndexOf("-release"))
$env:SHOULD_CREATE_RELEASE = "true"
Write-Host "Will create release for $tagName tag" -ForegroundColor "Green"
}
$matchVersion = Select-String -Path ./version.json -Pattern "`"version`": `"$version`""
if ($matchVersion -eq $null)
{
Write-Error "Version in tag ($version) does not match version in version.json"
}
}
nuget:
disable_publish_on_pr: true

before_build:
- cmd: dotnet --info
- cmd: dotnet restore ./Excel.TemplateEngine.sln --verbosity minimal
- cmd: dotnet tool restore

build_script:
- cmd: dotnet build --configuration Release ./Excel.TemplateEngine.sln
- cmd: dotnet pack --no-build --configuration Release ./Excel.TemplateEngine.sln

test_script:
- cmd: dotnet jb cleanupcode Excel.TemplateEngine.sln --profile=CatalogueCleanup --verbosity=WARN
- cmd: git diff --exit-code
- cmd: dotnet test --no-build --configuration Release ./Excel.TemplateEngine.Tests/Excel.TemplateEngine.Tests.csproj

artifacts:
Expand All @@ -43,7 +53,7 @@ deploy:
- provider: NuGet
server: https://nuget.org
api_key:
secure: y2RPf+gBBqffQVm8pg9qZcg99m7K8hsSa4z7VHvIE6t+kuO7r/oIqTVcryZzL93D
secure: 3Myenol+seNdEnkmH7tadxQLsmOE7VWQSp6vQii4vt2dX1S7XwjNV4T24HQTUsrr
skip_symbols: true
on:
SHOULD_PUBLISH_NUGET_PACKAGE: true
Expand Down
3 changes: 2 additions & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"sdk": {
"version": "5.0.103"
"version": "6.0.100",
"rollForward": "latestFeature"
}
}

0 comments on commit 48da86d

Please sign in to comment.