Skip to content
This repository was archived by the owner on Aug 26, 2022. It is now read-only.

Add support for C# 9.0 record types #42

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"version": 1,
"isRoot": true,
"tools": {
"dotnet-validate": {
"version": "0.0.1-preview.537",
"commands": [
"dotnet-validate"
],
"rollForward": true
}
}
}
68 changes: 0 additions & 68 deletions .github/workflows/cibuild.yml

This file was deleted.

97 changes: 97 additions & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: Continuous Integration

on: push

env:
Configuration: Release
ContinuousIntegrationBuild: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_NOLOGO: true
DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION: true
TERM: xterm

jobs:
package:
strategy:
matrix:
os: [ macos-latest, ubuntu-latest, windows-latest ]
fail-fast: false
runs-on: ${{ matrix.os }}
name: 🛠 Build, test and pack
steps:
- name: 🧑‍💻 Checkout git repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: 🏎 Optimize Windows runner
if: matrix.os == 'windows-latest'
run: |
echo "DOTNET_INSTALL_DIR=D:\dotnet" >> $env:GITHUB_ENV
echo "NUGET_PACKAGES=D:\nuget" >> $env:GITHUB_ENV
- name: 🧑‍🔧 Install .NET SDK
uses: actions/setup-dotnet@v4
- name: ℹ️ Show .NET info
run: dotnet --info
- name: 💾 Retrieve cached NuGet packages
uses: actions/cache@v4
with:
path: ${{ env.NUGET_PACKAGES || '~/.nuget/packages' }}
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: ⚙️ Restore NuGet packages
run: dotnet restore
- name: 🏗 Build solution
run: dotnet build --no-restore
- name: 🧪 Run tests
run: dotnet test --no-build
- name: 📤 Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: TestResults-${{ runner.os }}.trx
path: "*.trx"
- name: 📦 Create NuGet package
run: dotnet pack --no-build --output .
- name: 📤 Upload NuGet package artifact
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v4
with:
name: NuGet package
path: "*.nupkg"
- name: 📝 Retrieve release notes from tag
if: matrix.os == 'ubuntu-latest' && startsWith(github.ref, 'refs/tags/')
run: |
git fetch --tags --force
git tag --list ${{ github.ref_name }} --format='%(contents)' > ReleaseNotes.md
- name: 📤 Upload release notes
if: matrix.os == 'ubuntu-latest' && startsWith(github.ref, 'refs/tags/')
uses: actions/upload-artifact@v4
with:
name: Release Notes
path: ReleaseNotes.md
publish:
runs-on: macos-latest
needs: package
if: startsWith(github.ref, 'refs/tags/')
permissions:
contents: write
name: 🐿 Publish
steps:
- name: 📥 Download NuGet package artifact
uses: actions/download-artifact@v4
with:
name: NuGet package
- name: 📥 Download release notes artifact
uses: actions/download-artifact@v4
with:
name: Release Notes
- name: 🚢 Create GitHub Release
uses: softprops/action-gh-release@v2
with:
name: Version ${{ github.ref_name }}
body_path: ReleaseNotes.md
prerelease: ${{ contains(github.ref_name, '-') }}
files: "*.nupkg"
- name: 🚀 Publish NuGet package on nuget.org
run: dotnet nuget push "*.nupkg" --source https://api.nuget.org/v3/index.json --api-key "${{ secrets.NUGET_API_KEY }}"
25 changes: 25 additions & 0 deletions .github/workflows/test-report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Test Report

on:
workflow_run:
workflows: ['Continuous Integration']
types:
- completed

permissions:
checks: write

jobs:
report:
runs-on: ubuntu-latest
strategy:
matrix:
os: [ Linux, macOS, Windows ]
fail-fast: false
steps:
- uses: dorny/test-reporter@v1
with:
artifact: TestResults-${{ matrix.os }}.trx
name: 🚦 Test Results (${{ matrix.os }})
path: '*.trx'
reporter: dotnet-trx
92 changes: 92 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased
* Drop support for .NET Framework 4.5 whose support ended on January 12th, 2016. Replaced by support for .NET Framework 4.6.2.

## 3.1.0 (2022-04-30)
* Support for Standard built-in number formats, which localize properly (PR [#36](https://github.com/mstum/Simplexcel/pull/36) and [#37](https://github.com/mstum/Simplexcel/pull/37))
* Support for [AutoFilter](https://support.microsoft.com/en-us/office/use-autofilter-to-filter-your-data-7d87d63e-ebd0-424b-8106-e2ab61133d92) (PR [#35](https://github.com/mstum/Simplexcel/pull/35))
* Thanks to [0xced](https://github.com/0xced) for these!

## 3.0.2 (2020-12-25)
* Add [`SourceLink`](https://docs.microsoft.com/en-us/dotnet/standard/library-guidance/sourcelink) support

## 3.0.1 (2019-11-20)
* Fix `TypeInitializationException` in SimplexcelVersion in some contexts (e.g., UWP, Xamarin) ([Issue #30](https://github.com/mstum/Simplexcel/issues/30))

## 3.0.0 (2019-11-08)
* Remove targeting netstandard1.3, add targeting for netstandard2.1
* The library is now signed and strongly named for improved compatibility
* The AssemblyVersion is `3.0.0.0` and will not change in the future
* The AssemblyFileVersion and AssemblyInformationalVersion will contain the actual version number
* The actual signing key is checked in as [`simplexcel_oss.snk`](src/simplexcel_oss.snk), and a dump of the public key and token is in [`simplexcel_oss.txt`](src/simplexcel_oss.txt)
* There is a static `SimplexcelVersion` class with some helpers:
* PublicKeyToken is the public key token for the assembly (e.g., 65e777c740a5d92a)
* PublicKey is the full public key token for the assembly (e.g., 0024000004800000940000000602000000240000525341310...)
* VersionString is the AssemblyInformationalVersion as a string, which may include a suffix if it's a development version (e.g., 2.3.0.177-v3-dev)
* Version is the AssemblyFileVersion as a Version object, which does include any suffix (e.g., 2.3.0.177)
* No functional changes, just making sure that this is independent of future changes

## 2.3.0 (2019-11-02)
* Add `Worksheet.FreezeTopLeft` method (by @bcopeland in PR #26) to freeze more than just the top row/left column
* Support for Formulas, for example: `sheet.Cells["B4"] = Cell.Formula("MEDIAN(A:A)");`. See [the test app](https://github.com/mstum/Simplexcel/blob/0e22dddfcb26b9672ba3ccab6d229da7535127e7/src/Simplexcel.TestApp/Program.cs#L167) for some examples

## 2.2.1 (2018-09-19)
* Fixed bug where Background Color wasn't correctly applied to a Fill. ([Issue 23](https://github.com/mstum/Simplexcel/issues/23))

## 2.2.0 (2018-02-24)
* Add `IgnoredErrors` to a `Cell`, to disable Excel warnings (like "Number stored as text").
* If `LargeNumberHandlingMode.StoreAsText` is set on a sheet, the "Number stored as Text" warning is automatically disabled for that cell.
* Add `Cell.Fill` property, which allows setting the Fill of the cell, including the background color, pattern type (diagonal, crosshatch, grid, etc.) and pattern color
* Add `netstandard2.0` version, on top of the existing `netstandard1.3` and `net45` versions.

## 2.1.0 (2017-09-25)
* **Functional Change:** Numbers with more than 11 digits are forced as Text by Default, because [of a limitation in Excel](https://support.microsoft.com/en-us/help/2643223/long-numbers-are-displayed-incorrectly-in-excel). To restore the previous functionality, you can set `Worksheet.LargeNumberHandlingMode` to `LargeNumberHandlingMode.None`. You can also use `Cell.IsLargeNumber` to check if a given number would be affected by this.
* **Functional Change:** `Worksheet.Populate`/`Worksheet.FromData` now also reads properties from base classes.
* `Worksheet.Populate`/`Worksheet.FromData` accept a new argument, `cacheTypeColumns` which defaults to false. If set to true, then Simplexcel will cache the Reflection-based lookup of object properties. This is useful for if you have a few types that you create sheets from a lot.
* You can add `[XlsxColumn]` to a Property so that `Worksheet.Populate`/`Worksheet.FromData` can set the column name and a given column order. *Caveat:* If you set `ColumnIndex` on some, but not all Properties, the properties without a `ColumnIndex` will be on the right of the last assigned column, even if that means gaps. I recommend that you either set `ColumnIndex` on all properties or none.
* You can add `[XlsxIgnoreColumn]` to a Property so that `Worksheet.Populate`/`Worksheet.FromData` ignores it.
* Added `Cell.HorizontalAlignment` and `Cell.VerticalAlignment` to allow setting the alignment of a cell (left/center/right/justify, top/middle/bottom/justify).
* Added XmlDoc to Nuget package, so you should get Intellisense with proper comments now.

## 2.0.5 (2017-09-23)
* Add support for manual page breaks. Call `Worksheet.InsertManualPageBreakAfterRow` or `Worksheet.InsertManualPageBreakAfterColumn` with either the zero-based index of the row/column after which to create the break, or with a cell address (e.g., B5) to create the break below or to the left of that cell.

## 2.0.4 (2017-09-17)
* Support for [freezing panes](https://support.office.com/en-us/article/Freeze-panes-to-lock-rows-and-columns-dab2ffc9-020d-4026-8121-67dd25f2508f). Right now, this is being kept simple: call either `Worksheet.FreezeTopRow` or `Worksheet.FreezeLeftColumn` to freeze either the first row (1) or the leftmost column (A).
* If a Stream is not seekable (e.g., HttpContext.Response.OutputStream), Simplexcel automatically creates a temporary MemoryStream as an intermediate.
* Add `Cell.FromObject` to make Cell creation easier by guessing the correct type.
* Support `DateTime` cells, thanks to @mguinness and PR #16.

## 2.0.3 (2017-09-08)
* Add `Worksheet.Populate<T>` method to fill a sheet with data. Caveats: Does not loot at inherited members, doesn't look at complex types.
* Also add static `Worksheet.FromData<T>` method to create and populate the sheet in one.

## 2.0.2 (2017-06-17)
* Add additional validation when saving to a Stream. The stream must be seekable (and of course writeable), otherwise an Exception is thrown.

## 2.0.1 (2017-05-18)
* Fix [Issue #12](https://github.com/mstum/Simplexcel/issues/12): Sanitizing Regex stripped out too many characters (like the Ampersand or Emojis). Note that certain Unicode characters only work on newer versions of Excel (e.g., Emojis work in Excel 2013 but not 2007 or 2010).

## 2.0.0 (2017-04-22)
* Re-target to .net Framework 4.5 and .NET Standard 1.3.
* No longer use `System.Drawing.Color` but new type `Simplexcel.Color` should work.
* Classes no longer use Data Contract serializer, hence no more `[DataContract]`, `[DataMember]`, etc. attributes.
* Remove `CompressionLevel` - the entire creation of the actual .xlsx file is re-done (no more dependency on `System.IO.Packaging`) and compression is now a simple bool.

## 1.0.5 (2014-01-30)
* SharedStrings are sanitized to avoid XML Errors when using Escape chars (like 0x1B).

## 1.0.4 (2014-01-21)
* Workbook.Save throws an InvalidOperationException if there are no sheets.

## 1.0.3 (2013-08-20)
* Added support for external hyperlinks.
* Made Workbooks serializable using the .net DataContractSerializer.

## 1.0.2 (2013-01-10)
* Initial Public Release.
4 changes: 2 additions & 2 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)
Copyright (c) 2013-2017 Michael Stum, http://www.Stum.de <opensource@stum.de>

Copyright (c) 2013-2025 Cédric Luthi & Michael Stum, http://www.stum.de <opensource@stum.de>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
28 changes: 28 additions & 0 deletions MAINTENANCE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
## Creating a release

**Simplexcel** uses [MinVer](https://github.com/adamralph/minver) for its versioning, so a tag must exist with the chosen semantic version number in order to create an official release.

1. Update the [CHANGELOG](CHANGELOG.md) *Unreleased* section to the chosen version and copy the release notes for step #2.

- Add the release date
- Update the link from `HEAD` to the chosen version

2. Create an **[annotated](https://stackoverflow.com/questions/11514075/what-is-the-difference-between-an-annotated-and-unannotated-tag/25996877#25996877)** tag, the (multi-line) message of the annotated tag will be the content of the GitHub release. Markdown (copied from step #1) should be used.

`git tag --annotate 1.0.0-rc.1`

3. Push the `main` branch and ensure that the [build is successful](https://github.com/0xced/simplexcel/actions).

`git push`

4. [Push the tag](https://stackoverflow.com/questions/5195859/how-do-you-push-a-tag-to-a-remote-repository-using-git/26438076#26438076)

`git push --follow-tags`

Once pushed, the GitHub [Continuous Integration](https://github.com/0xced/simplexcel/blob/main/.github/workflows/continuous-integration.yml) workflow takes care of building, running the tests, creating the NuGet package, creating the GitHub release and finally publishing the produced NuGet package.

After the NuGet package is successfully published:

4. Update the `PackageValidationBaselineVersion` element in the `Simplexcel.csproj` file to the newly released version.
5. Delete the `CompatibilitySuppressions.xml` file if there's one.

Loading