Repository navigation
Fix missing facade types preventing seamless transition from v1.x #1069
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| // ReSharper disable once CheckNamespace | ||
| namespace MiniExcelLibs.Csv; | ||
|
|
||
| public sealed class CsvConfiguration : MiniExcelLib.Csv.CsvConfiguration, IConfiguration | ||
| { | ||
| public bool ReadEmptyStringAsNull | ||
| { | ||
| get => ReadEmptyFieldsAsDefault; | ||
| set => ReadEmptyFieldsAsDefault = value; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| using MiniExcelLib.Core; | ||
|
|
||
| // ReSharper disable once CheckNamespace | ||
| namespace MiniExcelLibs; | ||
|
|
||
| public interface IConfiguration : IMiniExcelConfiguration; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| // ReSharper disable once CheckNamespace | ||
| namespace MiniExcelLibs.OpenXml; | ||
|
|
||
| public sealed class OpenXmlConfiguration : MiniExcelLib.OpenXml.OpenXmlConfiguration, IConfiguration | ||
| { | ||
| public new TableStyles TableStyles | ||
| { | ||
| get => base.TableStyles switch | ||
| { | ||
| MiniExcelLib.OpenXml.TableStyles.Default => TableStyles.Default, | ||
| _ => TableStyles.None | ||
| }; | ||
| set => base.TableStyles = value switch | ||
| { | ||
| TableStyles.Default => MiniExcelLib.OpenXml.TableStyles.Default, | ||
| _ => MiniExcelLib.OpenXml.TableStyles.None | ||
| }; | ||
| } | ||
| } | ||
|
|
||
| public sealed class OpenXmlStyleOptions : MiniExcelLib.OpenXml.Styles.OpenXmlStyleOptions | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Expose Even after assigning Add a separate facade-typed This leaves the header-style migration incomplete under the PR objectives.
|
||
| { | ||
| public new HorizontalCellAlignment HorizontalAlignment | ||
| { | ||
| get => base.HorizontalAlignment switch | ||
| { | ||
| MiniExcelLib.Core.Enums.HorizontalCellAlignment.Right => HorizontalCellAlignment.Right, | ||
| MiniExcelLib.Core.Enums.HorizontalCellAlignment.Center => HorizontalCellAlignment.Center, | ||
| _ => HorizontalCellAlignment.Left, | ||
| }; | ||
| set => base.HorizontalAlignment = value switch | ||
| { | ||
| HorizontalCellAlignment.Right => MiniExcelLib.Core.Enums.HorizontalCellAlignment.Right, | ||
| HorizontalCellAlignment.Center => MiniExcelLib.Core.Enums.HorizontalCellAlignment.Center, | ||
| _ => MiniExcelLib.Core.Enums.HorizontalCellAlignment.Left | ||
| }; | ||
| } | ||
|
|
||
| public new VerticalCellAlignment VerticalAlignment | ||
| { | ||
| get => base.VerticalAlignment switch | ||
| { | ||
| MiniExcelLib.Core.Enums.VerticalCellAlignment.Top => VerticalCellAlignment.Top, | ||
| MiniExcelLib.Core.Enums.VerticalCellAlignment.Center => VerticalCellAlignment.Center, | ||
| _ => VerticalCellAlignment.Bottom | ||
| }; | ||
| set => base.VerticalAlignment = value switch | ||
| { | ||
| VerticalCellAlignment.Top => MiniExcelLib.Core.Enums.VerticalCellAlignment.Top, | ||
| VerticalCellAlignment.Center => MiniExcelLib.Core.Enums.VerticalCellAlignment.Center, | ||
| _ => MiniExcelLib.Core.Enums.VerticalCellAlignment.Bottom | ||
| }; | ||
| } | ||
| } | ||
|
|
||
| public sealed class OpenXmlHeaderStyle : MiniExcelLib.OpenXml.Styles.OpenXmlHeaderStyle | ||
| { | ||
| public new HorizontalCellAlignment HorizontalAlignment | ||
| { | ||
| get => base.HorizontalAlignment switch | ||
| { | ||
| MiniExcelLib.Core.Enums.HorizontalCellAlignment.Right => HorizontalCellAlignment.Right, | ||
| MiniExcelLib.Core.Enums.HorizontalCellAlignment.Center => HorizontalCellAlignment.Center, | ||
| _ => HorizontalCellAlignment.Left | ||
| }; | ||
| set => base.HorizontalAlignment = value switch | ||
| { | ||
| HorizontalCellAlignment.Right => MiniExcelLib.Core.Enums.HorizontalCellAlignment.Right, | ||
| HorizontalCellAlignment.Center => MiniExcelLib.Core.Enums.HorizontalCellAlignment.Center, | ||
| _ => MiniExcelLib.Core.Enums.HorizontalCellAlignment.Left | ||
| }; | ||
| } | ||
|
|
||
| public new VerticalCellAlignment VerticalAlignment | ||
| { | ||
| get => base.VerticalAlignment switch | ||
| { | ||
| MiniExcelLib.Core.Enums.VerticalCellAlignment.Top => VerticalCellAlignment.Top, | ||
| MiniExcelLib.Core.Enums.VerticalCellAlignment.Center => VerticalCellAlignment.Center, | ||
| _ => VerticalCellAlignment.Bottom | ||
| }; | ||
| set => base.VerticalAlignment = value switch | ||
| { | ||
| VerticalCellAlignment.Top => MiniExcelLib.Core.Enums.VerticalCellAlignment.Top, | ||
| VerticalCellAlignment.Center => MiniExcelLib.Core.Enums.VerticalCellAlignment.Center, | ||
| _ => MiniExcelLib.Core.Enums.VerticalCellAlignment.Bottom | ||
| }; | ||
| } | ||
| } | ||
|
|
||
| public enum TableStyles { None, Default } | ||
| public enum HorizontalCellAlignment { Left, Center, Right } | ||
| public enum VerticalCellAlignment { Bottom, Center, Top } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a facade-typed
StyleOptionsproperty so the new alignment enums are usable through the configuration.OpenXmlConfigurationdeclares noStyleOptionsmember. Its inherited property is typed as the baseOpenXmlStyleOptions, whose alignment properties use the core enums. As a result,new OpenXmlConfiguration().StyleOptions.HorizontalAlignment = HorizontalCellAlignment.Centerdoes not compile with the facade enum. The same failure occurs in target-typedStyleOptions = new() { ... }initializers. The facadeOpenXmlStyleOptionsalignment mappings therefore cannot be reached through the configuration.TableStylesalready has a facade-typed bridge, andStyleOptionsshould follow the same pattern.Add a facade-typed
StyleOptionsproperty that reads and writes the inherited base storage. Initialize that storage with a facadeOpenXmlStyleOptionsso the facade getter returns a usable object by default. Explicitly assigned facade styles must still reach the exporter through the base property.