Skip to content

Commit

Permalink
resolve merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
tomjebo committed Jun 27, 2023
2 parents 42f10b5 + 3439cfc commit 0617c3b
Show file tree
Hide file tree
Showing 33 changed files with 720 additions and 1,921 deletions.
84 changes: 84 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,87 @@ dotnet_diagnostic.CA1065.severity = suggestion

# CA1054: URI-like parameters should not be strings
dotnet_diagnostic.CA1054.severity = suggestion
csharp_using_directive_placement = outside_namespace:silent
csharp_prefer_simple_using_statement = true:suggestion
csharp_prefer_braces = true:silent
csharp_style_namespace_declarations = block_scoped:silent
csharp_style_prefer_method_group_conversion = true:silent
csharp_style_prefer_top_level_statements = true:silent
csharp_style_expression_bodied_methods = false:silent
csharp_style_expression_bodied_constructors = false:silent
csharp_style_expression_bodied_operators = false:silent
csharp_style_expression_bodied_properties = true:silent
csharp_style_expression_bodied_indexers = true:silent
csharp_style_expression_bodied_accessors = true:silent
csharp_style_expression_bodied_lambdas = true:silent
csharp_style_expression_bodied_local_functions = false:silent
csharp_indent_labels = one_less_than_current
csharp_style_throw_expression = true:suggestion

[*.{cs,vb}]
#### Naming styles ####

# Naming rules

dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion
dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface
dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i

dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.types_should_be_pascal_case.symbols = types
dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case

dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case

# Symbol specifications

dotnet_naming_symbols.interface.applicable_kinds = interface
dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.interface.required_modifiers =

dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.types.required_modifiers =

dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.non_field_members.required_modifiers =

# Naming styles

dotnet_naming_style.begins_with_i.required_prefix = I
dotnet_naming_style.begins_with_i.required_suffix =
dotnet_naming_style.begins_with_i.word_separator =
dotnet_naming_style.begins_with_i.capitalization = pascal_case

dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.capitalization = pascal_case

dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.capitalization = pascal_case
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_null_propagation = true:suggestion
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
dotnet_style_prefer_auto_properties = true:warning
dotnet_style_object_initializer = true:suggestion
dotnet_style_collection_initializer = true:suggestion
dotnet_style_prefer_simplified_boolean_expressions = true:suggestion
dotnet_style_prefer_conditional_expression_over_assignment = true:silent
dotnet_style_prefer_conditional_expression_over_return = true:suggestion
dotnet_style_explicit_tuple_names = true:suggestion
dotnet_style_prefer_inferred_tuple_names = true:suggestion
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
dotnet_style_prefer_compound_assignment = true:suggestion
dotnet_style_prefer_simplified_interpolation = true:suggestion
dotnet_style_namespace_match_folder = true:suggestion
dotnet_style_operator_placement_when_wrapping = beginning_of_line
tab_width = 4
indent_size = 4
end_of_line = crlf
dotnet_diagnostic.CA1043.severity = suggestion
82 changes: 82 additions & 0 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Benchmarks
on:
push:
branches:
- master
pull_request:
branches:
- master

permissions:
contents: write
deployments: write

jobs:
benchmark:
name: Run benchmarks
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-dotnet@v1
- name: Build benchmarks
run: cd test/DocumentFormat.OpenXml.Benchmarks; dotnet build -c RELEASE
shell: pwsh
- name: Run benchmarks
run: cd test/DocumentFormat.OpenXml.Benchmarks; dotnet run -c RELEASE -- results --exporters json --filter '*'
shell: pwsh
- name: List folders
shell: pwsh
run: cd test/DocumentFormat.OpenXml.Benchmarks; ls -recurse
- name: Store Validation
uses: rhysd/github-action-benchmark@v1
with:
name: Validation
tool: 'benchmarkdotnet'
output-file-path: test/DocumentFormat.OpenXml.Benchmarks/results/results/DocumentFormat.OpenXml.Benchmarks.ValidationTests-report-full-compressed.json
github-token: ${{ secrets.GITHUB_TOKEN }}
auto-push: true
# Show alert with commit comment on detecting possible performance regression
alert-threshold: '200%'
comment-on-alert: true
fail-on-alert: true
alert-comment-cc-users: '@twsouthwick'
- name: Store CompiledParticle
uses: rhysd/github-action-benchmark@v1
with:
name: CompiledParticle
tool: 'benchmarkdotnet'
output-file-path: test/DocumentFormat.OpenXml.Benchmarks/results/results/DocumentFormat.OpenXml.Benchmarks.CompiledParticle-report-full-compressed.json
github-token: ${{ secrets.GITHUB_TOKEN }}
auto-push: true
# Show alert with commit comment on detecting possible performance regression
alert-threshold: '200%'
comment-on-alert: true
fail-on-alert: true
alert-comment-cc-users: '@twsouthwick'
- name: Store Documents
uses: rhysd/github-action-benchmark@v1
with:
name: Documents
tool: 'benchmarkdotnet'
output-file-path: test/DocumentFormat.OpenXml.Benchmarks/results/results/DocumentFormat.OpenXml.Benchmarks.Documents-report-full-compressed.json
github-token: ${{ secrets.GITHUB_TOKEN }}
auto-push: true
# Show alert with commit comment on detecting possible performance regression
alert-threshold: '200%'
comment-on-alert: true
fail-on-alert: true
alert-comment-cc-users: '@twsouthwick'
- name: Store ElementMetadataTests
uses: rhysd/github-action-benchmark@v1
with:
name: ElementMetadataTests
tool: 'benchmarkdotnet'
output-file-path: test/DocumentFormat.OpenXml.Benchmarks/results/results/DocumentFormat.OpenXml.Benchmarks.ElementMetadataTests-report-full-compressed.json
github-token: ${{ secrets.GITHUB_TOKEN }}
auto-push: true
# Show alert with commit comment on detecting possible performance regression
alert-threshold: '200%'
comment-on-alert: true
fail-on-alert: true
alert-comment-cc-users: '@twsouthwick'

1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Added
- Packages can now be saved on .NET Core and .NET 5+ if constructed with a path or stream (#1307).
- Packages can now support malformed URIs (such as relationships with a URI such as `mailto:person@`)
- `IFeatureCollection` can now be enumerated and has a helpful debug view to see what features are registered (#1452)

### Changed
- When validation finds incorrect part, it will now include the relationship type rather than a class name
Expand Down
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<PackageVersion Include="NuGet.Packaging.Core" Version="6.4.0" />
<PackageVersion Include="NuGet.Protocol" Version="6.4.0" />
<PackageVersion Include="NuGet.Resolver" Version="6.4.0" />
<PackageVersion Include="StyleCop.Analyzers" Version="1.2.0-beta.321" />
<PackageVersion Include="StyleCop.Analyzers" Version="1.2.0-beta.507" />
<PackageVersion Include="Svg" Version="3.4.4" />
<PackageVersion Include="System.CodeDom" Version="7.0.0" />
<PackageVersion Include="System.Collections.Immutable" Version="5.0.0" />
Expand Down
48 changes: 26 additions & 22 deletions docs/Features.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,33 @@

Features are a new concept in v2.14 and later that allows for behavior and state to be contained within the document or part. This is accessed via `Features` property on packages, parts, and elements. Elements inherit part features, and parts inherit package features.

This is inspired by the pattern ASP.NET Core uses to modify behavior of HttpContext: https://learn.microsoft.com/aspnet/core/fundamentals/request-features
This is inspired by the pattern ASP.NET Core uses to modify behavior of HttpContext: https://learn.microsoft.com/aspnet/core/fundamentals/request-features. This is an implementation of the [strategy pattern](https://refactoring.guru/design-patterns/strategy) that makes it easy to replace behavior on the fly.

As of v3.0, the `IFeatureCollection` includes the ability to enumerate registered features.

## Visualizing Registered Features

The in-box implementations of the `IFeatureCollection` provide a helpful debug view so you can see what features are available and what their properties/fields are:

![Features Debug View](feature-debug-view.png)

## Current Features

The features that are currently available are described below and at what scope they are available. This is important, because and element by itself will not have any features available, while an element in one part may have different features than another part.
The features that are currently available are described below and at what scope they are available:

### IDisposableFeature

This feature allows for registering actions that need to run when a package or a part is destroyed or disposed:

```csharp
OpenXmlPackage package = GetSomePackage();
package.Features.Get<IDisposableFeature>().Register(() => /* Some action that is called when the package is disposed */);

OpenXmlPart part = GetSomePart();
part.Features.Get<IDisposableFeature>().Register(() => /* Some action that is called when the part is removed or closed */);
```

Packages and parts will have their own implementations of this feature. Elements will retrieve the feature for their containing part if available.

### IPackageEventsFeature

Expand Down Expand Up @@ -51,28 +73,10 @@ Generally, assume that there may be a singleton implementation for the events an

> Note: There may be times when the part root is changed but an event is not fired. Not all areas have been identified where it would make sense to raise an event. Please file an issue if you find one.
## DocumentFormat.OpenXml.Features - unreleased
## DocumentFormat.OpenXml.Features

This library contains additional (non-core) features that build on top of built-in features and functionality.

### IDisposableFeature

This feature allows for registering features that need to be disposed at the same time as the feature goes out of scope. This allows a feature to be created, but its lifetime managed concurrently with the collection it is added to. The recommended way to use it is simply to call the following method:

```csharp
OpenXmlPackage package = GetSomePackage();
package.TryAddDisposableFeature();

OpenXmlPart part = GetSomePart();
part.SetDisposable(new ExampleFeature());

public class ExampleFeature : IDisposable
{
}
```

This will add `ExampleFeature` to the part feature, and register it to be disposed when the part is disposed.

### IRandomNumberGeneratorFeature
This feature allows for a shared service to generate random numbers and fill an array.

Expand Down Expand Up @@ -121,7 +125,7 @@ Assert.NotEqual(p1.ParagraphId, p2.ParagraphId);
Assert.Equal(2, shared.Count);
```

## DocumentFormat.OpenXml.Linq - unreleased
## DocumentFormat.OpenXml.Linq

### IPartRootXElementFeature

Expand Down
Binary file added docs/feature-debug-view.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 0617c3b

Please sign in to comment.