Skip to content

Commit 082ac01

Browse files
committed
Merge remote-tracking branch 'origin/main' into element-non-generic
2 parents 9763549 + 7452a11 commit 082ac01

File tree

77 files changed

+774
-761
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+774
-761
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,10 @@ jobs:
9696
- name: Build
9797
run: dotnet build --no-restore --verbosity normal
9898
- name: Test
99-
run: dotnet test --no-restore --verbosity normal --logger trx --results-directory test-results/
99+
run: dotnet test --no-restore -- --results-directory ${{ github.workspace }}/test-results/ --report-xunit-trx
100100
- name: Upload Test Results
101101
if: always()
102102
uses: actions/upload-artifact@v4
103103
with:
104104
name: Test Results (${{ matrix.os }} ${{ matrix.configuration }} ${{ matrix.projectloadstyle }})
105-
path: test-results/*
105+
path: ${{ github.workspace }}/test-results/*

.github/workflows/code-coverage.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ on:
2020

2121
jobs:
2222
build_and_test:
23+
if: false # Disable for now while getting XUnit v3 working
2324
name: Run
2425

2526
env:
@@ -47,7 +48,7 @@ jobs:
4748
run: dotnet test --no-restore --verbosity normal --collect:"XPlat Code Coverage" --results-directory coverage
4849

4950
- name: ReportGenerator
50-
uses: danielpalme/[email protected].1
51+
uses: danielpalme/[email protected].4
5152
with:
5253
reports: coverage/**/coverage.cobertura.xml
5354
targetdir: coveragereport

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
if: github.event.workflow_run.conclusion == 'success'
1818
steps:
1919
- name: Download Release Info
20-
uses: dawidd6/action-download-artifact@v8
20+
uses: dawidd6/action-download-artifact@v9
2121
with:
2222
run_id: ${{ github.event.workflow_run.id }}
2323
name: release-info
@@ -39,7 +39,7 @@ jobs:
3939
runs-on: ubuntu-latest
4040
steps:
4141
- name: Download and Extract Artifacts from build
42-
uses: dawidd6/action-download-artifact@v8
42+
uses: dawidd6/action-download-artifact@v9
4343
with:
4444
run_id: ${{ github.event.workflow_run.id }}
4545
name: Signed

.github/workflows/test-results.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
steps:
2323
# Need to download from the associated workflow
2424
- name: Download and Extract Artifacts from build
25-
uses: dawidd6/action-download-artifact@v8
25+
uses: dawidd6/action-download-artifact@v9
2626
with:
2727
run_id: ${{ github.event.workflow_run.id }}
2828
path: artifacts

Directory.Build.props

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,11 @@
4141
<NoWarn>$(NoWarn);CS1685</NoWarn>
4242
<ProductTargetFrameworks>net35</ProductTargetFrameworks>
4343
<FrameworkTargetFrameworks>net35</FrameworkTargetFrameworks>
44-
<TestTargetFrameworks>net462</TestTargetFrameworks>
45-
<AssetsTargetFrameworks>net462</AssetsTargetFrameworks>
46-
<LatestTargetFramework>net462</LatestTargetFramework>
44+
<TestTargetFrameworks>net472</TestTargetFrameworks>
45+
<AssetsTargetFrameworks>net472</AssetsTargetFrameworks>
46+
<LatestTargetFramework>net472</LatestTargetFramework>
4747
<SamplesFrameworks>net472</SamplesFrameworks>
48+
<DefineConstants>$(DefineConstants);FEATURE_NO_VALIDATOR_CANCELLATIONTOKEN</DefineConstants>
4849
</PropertyGroup>
4950
</When>
5051
<When Condition=" '$(ProjectLoadStyle)' == 'net40' ">
@@ -53,22 +54,22 @@
5354
<NoWarn>$(NoWarn);CS1685</NoWarn>
5455
<ProductTargetFrameworks>net40</ProductTargetFrameworks>
5556
<FrameworkTargetFrameworks>net40</FrameworkTargetFrameworks>
56-
<TestTargetFrameworks>net462</TestTargetFrameworks>
57-
<AssetsTargetFrameworks>net462</AssetsTargetFrameworks>
58-
<LatestTargetFramework>net462</LatestTargetFramework>
57+
<TestTargetFrameworks>net472</TestTargetFrameworks>
58+
<AssetsTargetFrameworks>net472</AssetsTargetFrameworks>
59+
<LatestTargetFramework>net472</LatestTargetFramework>
5960
<SamplesFrameworks>net472</SamplesFrameworks>
6061
</PropertyGroup>
6162
</When>
6263
<Otherwise>
6364
<PropertyGroup>
6465
<ProductTargetFrameworks>netstandard2.0;net8.0;net35;net40;net46</ProductTargetFrameworks>
6566
<FrameworkTargetFrameworks>netstandard2.0;net6.0;net8.0;net35;net40;net46</FrameworkTargetFrameworks>
66-
<AssetsTargetFrameworks>netstandard2.0;net462</AssetsTargetFrameworks>
67+
<AssetsTargetFrameworks>netstandard2.0;net472</AssetsTargetFrameworks>
6768
<TestTargetFrameworks>net8.0</TestTargetFrameworks>
68-
<TestTargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">$(TestTargetFrameworks);net462</TestTargetFrameworks>
69+
<TestTargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">$(TestTargetFrameworks);net472</TestTargetFrameworks>
6970
<LatestTargetFramework>net8.0</LatestTargetFramework>
7071
<SamplesFrameworks>net8.0</SamplesFrameworks>
71-
<SamplesFrameworks Condition=" '$(OS)' == 'Windows_NT' ">$(TestTargetFrameworks);net472</SamplesFrameworks>
72+
<SamplesFrameworks Condition=" '$(OS)' == 'Windows_NT' ">$(SamplesFrameworks);net472</SamplesFrameworks>
7273
</PropertyGroup>
7374
</Otherwise>
7475
</Choose>

Directory.Packages.props

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<ItemGroup>
44
<PackageVersion Include="BenchmarkDotNet" Version="0.14.0" />
55
<PackageVersion Include="BenchmarkDotNet.Diagnostics.Windows" Version="0.14.0" />
6-
<PackageVersion Include="coverlet.collector" Version="6.0.2" />
6+
<PackageVersion Include="coverlet.collector" Version="6.0.4" />
77
<PackageVersion Include="Microsoft.Bcl.Memory" Version="9.0.0" />
88
<PackageVersion Include="Microsoft.DotNet.BuildTools.GenAPI" Version="3.0.0-preview4-06015-01" />
99
<PackageVersion Include="Microsoft.CodeAnalysis" Version="4.11.0" />
@@ -14,24 +14,24 @@
1414
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
1515
<PackageVersion Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" />
1616
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
17+
<PackageVersion Include="Microsoft.Testing.Extensions.CodeCoverage" Version="17.13.1" />
1718
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
1819
<PackageVersion Include="NSubstitute" Version="5.3.0" />
19-
<PackageVersion Include="NuGet.Common" Version="6.12.1" />
20-
<PackageVersion Include="NuGet.Packaging" Version="6.12.1" />
20+
<PackageVersion Include="NuGet.Common" Version="6.13.2" />
21+
<PackageVersion Include="NuGet.Packaging" Version="6.13.2" />
2122
<PackageVersion Include="NuGet.Protocol" Version="6.12.1" />
2223
<PackageVersion Include="NuGet.Resolver" Version="6.12.1" />
2324
<PackageVersion Include="ObjectLayoutInspector" Version="0.1.4" />
2425
<PackageVersion Include="StyleCop.Analyzers" Version="1.2.0-beta.556" />
2526
<PackageVersion Include="Svg" Version="3.4.7" />
2627
<PackageVersion Include="System.CodeDom" Version="8.0.0" />
2728
<PackageVersion Include="System.IO.Packaging" Version="8.0.1" />
28-
<PackageVersion Include="System.Collections.Immutable" Version="7.0.0" />
29+
<PackageVersion Include="System.Collections.Immutable" Version="8.0.0" />
2930
<PackageVersion Include="System.Net.Http" Version="4.3.4" />
3031
<PackageVersion Include="System.Security.Cryptography.Algorithms" Version="4.3.1" />
3132
<PackageVersion Include="System.Text.Json" Version="9.0.0" />
3233
<PackageVersion Include="System.Xml.ReaderWriter" Version="4.3.1" />
3334
<PackageVersion Include="System.ValueTuple" Version="4.5.0" />
34-
<PackageVersion Include="xunit" Version="2.9.2" />
35-
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2" />
35+
<PackageVersion Include="xunit.v3" Version="1.0.0" />
3636
</ItemGroup>
3737
</Project>

GitVersion.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
mode: ContinuousDeployment
2-
next-version: 3.1.0
2+
next-version: 3.4.0
33
branches: {}
44
ignore:
55
sha: []

Open-XML-SDK.sln

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "gen", "gen", "{3653266D-2C8
6767
EndProject
6868
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DocumentFormat.OpenXml.Generator", "gen\DocumentFormat.OpenXml.Generator\DocumentFormat.OpenXml.Generator.csproj", "{E04F2FB4-DBC6-46DC-857C-F0E89B42F385}"
6969
EndProject
70-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DocumentFormat.OpenXml.Generator.Tests", "test\DocumentFormat.OpenXml.Generator.Tests\DocumentFormat.OpenXml.Generator.Tests.csproj", "{BAC36A8F-AA8E-4097-B2BA-2EFE559BEE62}"
71-
EndProject
7270
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Linq", "Linq", "{C5AE39F0-A152-471A-B90E-B8F4E94AA6C2}"
7371
EndProject
7472
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SvgExampleLinq", "samples\Linq\SvgExample\SvgExampleLinq.csproj", "{DE06FC2B-EABB-4535-BC73-C51A32B5AC01}"
@@ -149,10 +147,6 @@ Global
149147
{E04F2FB4-DBC6-46DC-857C-F0E89B42F385}.Debug|Any CPU.Build.0 = Debug|Any CPU
150148
{E04F2FB4-DBC6-46DC-857C-F0E89B42F385}.Release|Any CPU.ActiveCfg = Release|Any CPU
151149
{E04F2FB4-DBC6-46DC-857C-F0E89B42F385}.Release|Any CPU.Build.0 = Release|Any CPU
152-
{BAC36A8F-AA8E-4097-B2BA-2EFE559BEE62}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
153-
{BAC36A8F-AA8E-4097-B2BA-2EFE559BEE62}.Debug|Any CPU.Build.0 = Debug|Any CPU
154-
{BAC36A8F-AA8E-4097-B2BA-2EFE559BEE62}.Release|Any CPU.ActiveCfg = Release|Any CPU
155-
{BAC36A8F-AA8E-4097-B2BA-2EFE559BEE62}.Release|Any CPU.Build.0 = Release|Any CPU
156150
{DE06FC2B-EABB-4535-BC73-C51A32B5AC01}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
157151
{DE06FC2B-EABB-4535-BC73-C51A32B5AC01}.Debug|Any CPU.Build.0 = Debug|Any CPU
158152
{DE06FC2B-EABB-4535-BC73-C51A32B5AC01}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -211,7 +205,6 @@ Global
211205
{E157C5F1-D70B-4939-A199-0B758FED8541} = {0782A132-968D-4BDD-911A-2C3074EAF886}
212206
{3B82C340-3B10-42BF-9A2C-2E2327A9CFD4} = {0782A132-968D-4BDD-911A-2C3074EAF886}
213207
{E04F2FB4-DBC6-46DC-857C-F0E89B42F385} = {3653266D-2C88-4487-8977-839CB3E78A0A}
214-
{BAC36A8F-AA8E-4097-B2BA-2EFE559BEE62} = {0782A132-968D-4BDD-911A-2C3074EAF886}
215208
{C5AE39F0-A152-471A-B90E-B8F4E94AA6C2} = {7DAF7304-40CC-4180-88A5-9A89DD13C565}
216209
{DE06FC2B-EABB-4535-BC73-C51A32B5AC01} = {7DAF7304-40CC-4180-88A5-9A89DD13C565}
217210
{890B74DD-6316-4D56-B42A-5D66F10F88C6} = {C5AE39F0-A152-471A-B90E-B8F4E94AA6C2}

README.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ Open XML SDK
44

55
> [!NOTE]
66
>
7-
> [v3.0.0](https://www.nuget.org/packages/DocumentFormat.OpenXml/3.0.0) refactors and addresses some technical debt while retaining source compatibility as much as possible. You should be able to update your package and recompile with limited changes. However, binary compatibility was not a goal and will break that for some changes which are documented. PRs that introduced such changes are marked with a `breaking-change` label and were added to a list to help migrating to v3.0.0.
8-
>
9-
> Please see the [v3.0.0 milestone](https://github.com/OfficeDev/Open-XML-SDK/milestone/1) for issues and PRs that are included. For discussions, please join us at [this issue](https://github.com/OfficeDev/Open-XML-SDK/issues/1270).
7+
> 3.0.0 introduced breaking changes and you should be able to update your package and recompile with limited changes. Please see the [v3.0.0 milestone](https://github.com/OfficeDev/Open-XML-SDK/milestone/1) for issues and PRs that were included.
108
119

1210
> [!IMPORTANT]
@@ -16,14 +14,20 @@ Open XML SDK
1614
[![Build Status](https://office.visualstudio.com/OC/_apis/build/status/OpenXmlSdk/OfficeDev.Open-XML-SDK?branchName=main)](https://office.visualstudio.com/OC/_build/latest?definitionId=7420&branchName=main)
1715
[![Backend Status](https://ointprotocol.visualstudio.com/OInteropTools/_apis/build/status/OpenXML-Schemas?branchName=main)](https://ointprotocol.visualstudio.com/OInteropTools/_build/latest?definitionId=21&branchName=main)
1816

19-
The Open XML SDK provides tools for working with Office Word, Excel, and PowerPoint documents. It supports scenarios such as:
17+
The Open XML SDK is a framework for working with Microsoft Office Word, Excel, and PowerPoint documents. It includes APIs for low-level operations related to OPC packages, Flat OPC files, and Open XML markup in two forms (i.e., strongly-typed classes and LINQ to XML). It is designed to closely follow the Microsoft Office implementation of the ISO 29500 standard, but was not intended to directly provide higher-level abstractions or productivity tools.
18+
19+
These APIs enable scenarios such as:
2020

2121
- High-performance generation of word-processing documents, spreadsheets, and presentations.
2222
- Document modification, such as adding, updating, and removing content and metadata.
23-
- Search and replace content using regular expressions.
23+
- Searching and replacing content using regular expressions.
2424
- Splitting up (shredding) a file into multiple files, and combining multiple files into a single file.
2525
- Updating cached data and embedded spreadsheets for charts in Word/PowerPoint.
2626

27+
28+
Prerequisite for using the Open XML SDK: detailed knowledge of the relevant formats (https://learn.microsoft.com/en-us/openspecs/office_standards/ms-offstandlp) and standards (https://standards.iso.org/ittf/PubliclyAvailableStandards/index.html - search for 29500)
29+
30+
2731
<!-- omit in toc -->
2832
# Table of Contents
2933

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Copyright (c) Microsoft. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
using System;
5+
using System.Collections.Generic;
6+
using System.Linq;
7+
8+
namespace DocumentFormat.OpenXml;
9+
10+
internal static class EnumerableExtensions
11+
{
12+
/// <summary>
13+
/// Similar to <see cref="Enumerable.FirstOrDefault{TSource}(IEnumerable{TSource})"/> but will also verify that at most there is one.
14+
/// </summary>
15+
public static T? FirstOrDefaultAndMaxOne<T>(this IEnumerable<T> enumerable, Func<Exception>? exceptionFactory = null)
16+
{
17+
using var e = enumerable.GetEnumerator();
18+
19+
if (e.MoveNext())
20+
{
21+
var first = e.Current;
22+
23+
if (e.MoveNext())
24+
{
25+
throw exceptionFactory?.Invoke() ?? throw new InvalidOperationException(ExceptionMessages.FirstOrDefaultMaxOne);
26+
}
27+
28+
return first;
29+
}
30+
31+
return default;
32+
}
33+
}

0 commit comments

Comments
 (0)