Skip to content

Commit 60becc7

Browse files
authored
Merge pull request #24 from synercoder/features/general-environment-refactors
Features/general environment refactors
2 parents 3c2ca9d + 202927a commit 60becc7

16 files changed

+185
-84
lines changed

.github/workflows/dotnet-core.yml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: .NET Core
2+
on:
3+
push:
4+
branches:
5+
- develop
6+
pull_request:
7+
release:
8+
types:
9+
- published
10+
env:
11+
# Stop wasting time caching packages
12+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
13+
# Disable sending usage data to Microsoft
14+
DOTNET_CLI_TELEMETRY_OPTOUT: true
15+
# Project name to pack and publish
16+
PROJECT_NAME: Synercoding.FileFormats.Pdf
17+
# GitHub Packages Feed settings
18+
GITHUB_FEED: https://nuget.pkg.github.com/synercoder/index.json
19+
GITHUB_USER: synercoder
20+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21+
# Official NuGet Feed settings
22+
NUGET_FEED: https://api.nuget.org/v3/index.json
23+
NUGET_KEY: ${{ secrets.NUGET_KEY }}
24+
jobs:
25+
build:
26+
runs-on: ${{ matrix.os }}
27+
strategy:
28+
matrix:
29+
os: [ ubuntu-latest, windows-latest, macos-latest ]
30+
steps:
31+
- name: Checkout
32+
uses: actions/checkout@v2
33+
- name: Setup .NET Core
34+
uses: actions/setup-dotnet@v1
35+
with:
36+
dotnet-version: 3.1.x
37+
- name: Restore
38+
run: dotnet restore
39+
- name: Build
40+
run: dotnet build -c Release --no-restore
41+
- name: Test
42+
run: dotnet test -c Release
43+
- name: Pack
44+
if: matrix.os == 'ubuntu-latest'
45+
run: dotnet pack -v normal -c Release --no-restore --include-symbols --include-source -p:SymbolPackageFormat=snupkg -p:PackageVersion=$GITHUB_RUN_ID src/$PROJECT_NAME/$PROJECT_NAME.*proj
46+
- name: Upload Artifact
47+
if: matrix.os == 'ubuntu-latest'
48+
uses: actions/upload-artifact@v2
49+
with:
50+
name: nupkg
51+
path: ./artifacts/pkg/Release/${{ env.PROJECT_NAME }}.*.nupkg
52+
prerelease:
53+
needs: build
54+
if: github.ref == 'refs/heads/develop'
55+
runs-on: ubuntu-latest
56+
steps:
57+
- name: Download Artifact
58+
uses: actions/download-artifact@v1
59+
with:
60+
name: nupkg
61+
- name: Push to GitHub Feed
62+
run: |
63+
for f in ./nupkg/*.nupkg
64+
do
65+
curl -vX PUT -u "$GITHUB_USER:$GITHUB_TOKEN" -F package=@$f $GITHUB_FEED
66+
done
67+
deploy:
68+
needs: build
69+
if: github.event_name == 'release'
70+
runs-on: ubuntu-latest
71+
steps:
72+
- uses: actions/checkout@v2
73+
- name: Setup .NET Core
74+
uses: actions/setup-dotnet@v1
75+
with:
76+
dotnet-version: 3.1.x
77+
- name: Create Release NuGet package
78+
run: |
79+
arrTag=(${GITHUB_REF//\// })
80+
VERSION="${arrTag[2]}"
81+
echo Version: $VERSION
82+
VERSION="${VERSION//v}"
83+
echo Clean Version: $VERSION
84+
dotnet pack -v normal -c Release --include-symbols --include-source -p:SymbolPackageFormat=snupkg -p:PackageVersion=$VERSION -o nupkg src/$PROJECT_NAME/$PROJECT_NAME.*proj
85+
- name: Push to GitHub Feed
86+
run: |
87+
for f in ./nupkg/*.nupkg
88+
do
89+
curl -vX PUT -u "$GITHUB_USER:$GITHUB_TOKEN" -F package=@$f $GITHUB_FEED
90+
done
91+
- name: Push to NuGet Feed
92+
if: ${{ env.NUGET_FEED }} != ''
93+
run: dotnet nuget push ./nupkg/*.nupkg --source $NUGET_FEED --skip-duplicate --api-key $NUGET_KEY

Directory.Build.props

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,38 +6,33 @@
66
<BaseArtifactsPathSuffix>$(SynercodingProjectCategory)/$(MSBuildProjectName)</BaseArtifactsPathSuffix>
77
<BaseIntermediateOutputPath>$(BaseArtifactsPath)obj/$(BaseArtifactsPathSuffix)/</BaseIntermediateOutputPath>
88
<BaseOutputPath>$(BaseArtifactsPath)bin/$(BaseArtifactsPathSuffix)/</BaseOutputPath>
9-
<PackageOutputPath>$(BaseArtifactsPath)pkg/$(BaseArtifactsPathSuffix)/$(Configuration)/</PackageOutputPath>
9+
<PackageOutputPath>$(BaseArtifactsPath)pkg/$(Configuration)/</PackageOutputPath>
1010
</PropertyGroup>
1111

1212
<PropertyGroup>
1313
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
1414
<DebugType>portable</DebugType>
1515
<DebugType Condition="'$(codecov)' != ''">full</DebugType>
16-
<Nullable>enable</Nullable>
17-
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
1816
<SignAssembly>false</SignAssembly>
1917
<SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
20-
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
21-
<Features>strict</Features>
18+
</PropertyGroup>
19+
20+
<PropertyGroup>
21+
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
22+
<PackageLicenseExpression>MIT</PackageLicenseExpression>
2223
</PropertyGroup>
2324

2425
<PropertyGroup>
2526
<Authors>Gerard Gunnewijk</Authors>
2627
<Company>Synercoding</Company>
27-
<Product>Synercoding.FileFormats.Pdf</Product>
2828
<Copyright>Copyright © $(Company)</Copyright>
2929
</PropertyGroup>
3030

31-
<PropertyGroup>
32-
<VersionPrefix>0.0.1</VersionPrefix>
33-
<VersionPrefix Condition="'$(packageversion)' != ''">$(PackageVersion)</VersionPrefix>
34-
<VersionSuffix></VersionSuffix>
35-
</PropertyGroup>
36-
3731
<PropertyGroup>
3832
<NeutralLanguage>en</NeutralLanguage>
3933
<OverwriteReadOnlyFiles>true</OverwriteReadOnlyFiles>
4034
<RepositoryType>git</RepositoryType>
35+
<RepositoryUrl>https://github.com/synercoder/FileFormats.Pdf/</RepositoryUrl>
4136
<RestoreSources>
4237
https://api.nuget.org/v3/index.json;
4338
https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json;
@@ -47,6 +42,19 @@
4742

4843
<PropertyGroup>
4944
<LangVersion>8.0</LangVersion>
45+
<Nullable>enable</Nullable>
46+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
47+
<Features>strict</Features>
48+
</PropertyGroup>
49+
50+
<PropertyGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
51+
<DefineConstants>$(DefineConstants);SUPPORTS_HASHCODE</DefineConstants>
52+
</PropertyGroup>
53+
<PropertyGroup Condition="'$(TargetFramework)' == 'netcoreapp2.1'">
54+
<DefineConstants>$(DefineConstants);SUPPORTS_HASHCODE</DefineConstants>
55+
</PropertyGroup>
56+
<PropertyGroup Condition="'$(TargetFramework)' == 'netstandard2.1'">
57+
<DefineConstants>$(DefineConstants);SUPPORTS_HASHCODE</DefineConstants>
5058
</PropertyGroup>
5159

5260
</Project>

Directory.Build.targets

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,4 @@
66
<DefineConstants>$(DefineConstants);$(OS)</DefineConstants>
77
</PropertyGroup>
88

9-
<ItemGroup>
10-
<PackageReference Update="Aspose.PDF" Version="20.1.0" />
11-
<PackageReference Update="iTextSharp" Version="5.5.13.1" NoWarn="NU1701" />
12-
<PackageReference Update="SixLabors.ImageSharp.Drawing" Version="1.0.0-beta0007" />
13-
<PackageReference Update="xunit.assert" Version="2.4.1" />
14-
</ItemGroup>
15-
169
</Project>

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2019 Gerard Gunnewijk
3+
Copyright (c) 2020 Gerard Gunnewijk
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ The sample project called *Synercoding.FileFormats.Pdf.ConsoleTester* uses multi
3434
<pre><code>using (var fs = File.OpenWrite(fileName))
3535
using (var writer = new PdfWriter(fs))
3636
{
37-
double _mmToPts(double mm) => mm / 25.4d * 72;
38-
3937
writer
4038
.AddPage(page =&gt;
4139
{

Synercoding.FileFormats.Pdf.sln

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "root", "root", "{6AAE343B-2
3131
README.md = README.md
3232
EndProjectSection
3333
EndProject
34+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{67FFC819-02FC-4D51-8D02-4588713DE0AB}"
35+
EndProject
36+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{B1B3DE7C-7961-4FA6-BABD-06B3979D1ABF}"
37+
ProjectSection(SolutionItems) = preProject
38+
.github\workflows\dotnet-core.yml = .github\workflows\dotnet-core.yml
39+
EndProjectSection
40+
EndProject
3441
Global
3542
GlobalSection(SolutionConfigurationPlatforms) = preSolution
3643
Debug|Any CPU = Debug|Any CPU
@@ -55,6 +62,8 @@ Global
5562
{4FA81463-B64F-40F2-A3F1-226179796E09} = {6AAE343B-2D3D-4F7F-BC6D-6481428BECB2}
5663
{E11AEF6A-6977-4D76-83E2-D5BDB84F3872} = {76970674-A4D1-4439-8EA6-8832E4A24FF1}
5764
{90A3DC19-7312-4649-8B1E-9455D664C074} = {BE969D07-4BE6-4293-BBC6-C496F7D4A81C}
65+
{67FFC819-02FC-4D51-8D02-4588713DE0AB} = {6AAE343B-2D3D-4F7F-BC6D-6481428BECB2}
66+
{B1B3DE7C-7961-4FA6-BABD-06B3979D1ABF} = {67FFC819-02FC-4D51-8D02-4588713DE0AB}
5867
EndGlobalSection
5968
GlobalSection(ExtensibilityGlobals) = postSolution
6069
SolutionGuid = {8DB7E905-EFFC-44B7-A5B5-3CC08E3F5AD9}

samples/Synercoding.FileFormats.Pdf.ConsoleTester/Synercoding.FileFormats.Pdf.ConsoleTester.csproj

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,7 @@
1010
</ItemGroup>
1111

1212
<ItemGroup>
13-
<None Update="Pexels_com\4k-wallpaper-blur-bokeh-1484253.jpg">
14-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
15-
</None>
16-
<None Update="Pexels_com\adult-blue-blue-eyes-865711.jpg">
17-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
18-
</None>
19-
<None Update="Pexels_com\android-wallpaper-art-backlit-1114897.jpg">
20-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
21-
</None>
22-
<None Update="Pexels_com\arid-barren-desert-1975514.jpg">
13+
<None Update="Pexels_com\*.jpg">
2314
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
2415
</None>
2516
</ItemGroup>

src/Directory.Build.props

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<Project>
33

44
<PropertyGroup>
5+
<TargetFrameworks>netcoreapp3.1;netcoreapp2.1;netstandard2.1;netstandard2.0;netstandard1.6</TargetFrameworks>
56
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileDirectory)..\Directory.Build.props</MSBuildAllProjects>
67
<SynercodingProjectCategory>src</SynercodingProjectCategory>
78
</PropertyGroup>
@@ -15,9 +16,5 @@
1516
<PropertyGroup>
1617
<WarningsNotAsErrors>CS1591</WarningsNotAsErrors>
1718
</PropertyGroup>
18-
19-
<PropertyGroup>
20-
<TargetFramework>netcoreapp3.1</TargetFramework>
21-
</PropertyGroup>
2219

2320
</Project>

src/Directory.Build.targets

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -7,38 +7,6 @@
77

88
<Import Project="$(MSBuildThisFileDirectory)..\Directory.Build.targets" />
99

10-
<PropertyGroup>
11-
<GeneratedInternalsVisibleToFile Condition="'$(GeneratedInternalsVisibleToFile)' == ''">$(IntermediateOutputPath)$(MSBuildProjectName).InternalsVisibleTo$(DefaultLanguageSourceExtension)</GeneratedInternalsVisibleToFile>
12-
</PropertyGroup>
13-
14-
<ItemDefinitionGroup>
15-
<InternalsVisibleTo>
16-
<Visible>false</Visible>
17-
</InternalsVisibleTo>
18-
</ItemDefinitionGroup>
19-
20-
<Target Name="GenerateInternalsVisibleTo"
21-
BeforeTargets="CoreCompile"
22-
DependsOnTargets="PrepareForBuild;CoreGenerateInternalsVisibleTo"
23-
Condition="'@(InternalsVisibleTo)' != ''" />
24-
25-
<Target Name="CoreGenerateInternalsVisibleTo"
26-
Condition="'$(Language)' == 'VB' or '$(Language)' == 'C#'"
27-
Inputs="$(MSBuildAllProjects)"
28-
Outputs="$(GeneratedInternalsVisibleToFile)">
29-
<CreateItem Include="System.Runtime.CompilerServices.InternalsVisibleToAttribute" AdditionalMetadata="_Parameter1=%(InternalsVisibleTo.Identity)" Condition="'%(InternalsVisibleTo.PublicKey)' == ''">
30-
<Output TaskParameter="Include" ItemName="InternalsVisibleToAttribute" />
31-
</CreateItem>
32-
<CreateItem Include="System.Runtime.CompilerServices.InternalsVisibleToAttribute" AdditionalMetadata="_Parameter1=%(InternalsVisibleTo.Identity), PublicKey=%(InternalsVisibleTo.PublicKey)" Condition="'%(InternalsVisibleTo.PublicKey)' != ''">
33-
<Output TaskParameter="Include" ItemName="InternalsVisibleToAttribute" />
34-
</CreateItem>
35-
36-
<WriteCodeFragment AssemblyAttributes="@(InternalsVisibleToAttribute)" Language="$(Language)" OutputFile="$(GeneratedInternalsVisibleToFile)">
37-
<Output TaskParameter="OutputFile" ItemName="Compile" />
38-
<Output TaskParameter="OutputFile" ItemName="FileWrites" />
39-
</WriteCodeFragment>
40-
</Target>
41-
4210
<!-- Empty target so that `dotnet test` will work on the solution -->
4311
<!-- https://github.com/Microsoft/vstest/issues/411 -->
4412
<Target Name="VSTest" />
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project>
3+
4+
<PropertyGroup>
5+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
6+
</PropertyGroup>
7+
8+
<PropertyGroup>
9+
<PackageTags>PDF</PackageTags>
10+
<Product>Synercoding.FileFormats.Pdf</Product>
11+
<Title>Synercoding.FileFormats.Pdf</Title>
12+
<Description>Contains classes which makes it easy to quickly create a pdf file.</Description>
13+
<PackageReleaseNotes>Started using Synercoding.Primitives &amp; updated SixLabors.ImageSharp.</PackageReleaseNotes>
14+
</PropertyGroup>
15+
16+
</Project>

src/Synercoding.FileFormats.Pdf/PdfInternals/Objects/IPdfObject.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,18 @@
33

44
namespace Synercoding.FileFormats.Pdf.PdfInternals.Objects
55
{
6+
/// <summary>
7+
/// Interface representing a pdf object
8+
/// </summary>
69
public interface IPdfObject : IStreamWriteable, IDisposable
710
{
11+
/// <summary>
12+
/// A pdf reference object that can be used to reference to this object
13+
/// </summary>
814
PdfReference Reference { get; }
15+
/// <summary>
16+
/// Indicator to check whether this object has been written to the PDF stream
17+
/// </summary>
918
bool IsWritten { get; }
1019
}
1120
}

src/Synercoding.FileFormats.Pdf/PdfInternals/Objects/Image.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55

66
namespace Synercoding.FileFormats.Pdf.PdfInternals.Objects
77
{
8+
/// <summary>
9+
/// A class representing an image
10+
/// </summary>
811
public class Image : IPdfObject, IDisposable
912
{
1013
private readonly SixLabors.ImageSharp.Image _image;
@@ -16,10 +19,13 @@ internal Image(PdfReference id, SixLabors.ImageSharp.Image image)
1619
_image = image;
1720
}
1821

22+
/// <inheritdoc />
1923
public PdfReference Reference { get; private set; }
2024

25+
/// <inheritdoc />
2126
public bool IsWritten { get; private set; }
2227

28+
/// <inheritdoc />
2329
public void Dispose()
2430
{
2531
if(!_disposed)
@@ -29,6 +35,7 @@ public void Dispose()
2935
}
3036
}
3137

38+
/// <inheritdoc />
3239
public uint WriteToStream(Stream stream)
3340
{
3441
if(_disposed)
Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,36 @@
11
namespace Synercoding.FileFormats.Pdf.PdfInternals
22
{
3-
public struct PdfReference
3+
/// <summary>
4+
/// A struct representing a reference
5+
/// </summary>
6+
public readonly struct PdfReference
47
{
8+
/// <summary>
9+
/// Constructor for <see cref="PdfReference"/> that uses generation 0
10+
/// </summary>
11+
/// <param name="objectId">The id of the reference</param>
512
public PdfReference(int objectId)
613
: this(objectId, 0)
714
{ }
815

16+
/// <summary>
17+
/// Constructor for <see cref="PdfReference"/>
18+
/// </summary>
19+
/// <param name="objectId">The id of the reference</param>
20+
/// <param name="generation">The generation of the reference</param>
921
public PdfReference(int objectId, int generation)
1022
{
1123
ObjectId = objectId;
1224
Generation = generation;
1325
}
1426

27+
/// <summary>
28+
/// The object id of this reference
29+
/// </summary>
1530
public int ObjectId { get; }
31+
/// <summary>
32+
/// The generation of this reference
33+
/// </summary>
1634
public int Generation { get; }
1735
}
1836
}

0 commit comments

Comments
 (0)