Skip to content

Commit 3b5f650

Browse files
Optimizations
1 parent e3357ae commit 3b5f650

Some content is hidden

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

53 files changed

+1369
-1026
lines changed

Docs.IndexGenerator/Program.cs

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@
1212

1313
namespace Docs.IndexGenerator
1414
{
15-
internal record DocEntry(string id, string title, string path, string? description);
16-
internal record RootConfig(string projectName, string baseDescription, string rootDescription);
17-
internal record MetaPackageConfig(string packageName, string version, string? description);
18-
internal record PluginConfig(DocEntry[] entries);
15+
#nullable enable
16+
internal record DocEntry(string Id, string Title, string Path, string? Description);
17+
internal record RootConfig(string ProjectName, string BaseDescription, string RootDescription);
18+
internal record MetaPackageConfig(string PackageName, string Version, string? Desrciption);
19+
internal record PluginConfig(DocEntry[] Entries);
20+
#nullable disable
1921

2022
public class Program
2123
{
@@ -91,7 +93,7 @@ static int Main(string[] args)
9193
<head>
9294
<meta charset=""utf-8"">
9395
<meta name=""viewport"" content=""width=device-width,initial-scale=1"">
94-
<title>{EscapeHtml(rootConfig.projectName)} — Documentation</title>
96+
<title>{EscapeHtml(rootConfig.ProjectName)} — Documentation</title>
9597
<link rel=""stylesheet"" href=""style.css"">
9698
</head>
9799
<body>
@@ -101,7 +103,7 @@ static int Main(string[] args)
101103
<img src=""NanoXLSX.png""
102104
alt=""NanoXLSX""
103105
style=""height:48px; vertical-align:middle; margin-right:10px;"">
104-
{EscapeHtml(rootConfig.projectName)} v2.x
106+
{EscapeHtml(rootConfig.ProjectName)} v2.x
105107
</h1>
106108
107109
<h2>API Documentation</h2>
@@ -121,23 +123,23 @@ static int Main(string[] args)
121123
<img src=""NanoXLSX.png""
122124
alt=""NanoXLSX""
123125
style=""height:48px; vertical-align:middle; margin-right:10px;"">
124-
{EscapeHtml(rootConfig.projectName)} v3.x
126+
{EscapeHtml(rootConfig.ProjectName)} v3.x
125127
</h1>
126128
127129
<p>
128-
{EscapeHtml(rootConfig.baseDescription)}<br>
129-
{EscapeHtml(rootConfig.rootDescription)}
130+
{EscapeHtml(rootConfig.BaseDescription)}<br>
131+
{EscapeHtml(rootConfig.RootDescription)}
130132
<p>
131133
132134
<hr>
133135
134-
<h2>Meta Package v{EscapeHtml(metaPackageConfig.version)}</h2>
136+
<h2>Meta Package v{EscapeHtml(metaPackageConfig.Version)}</h2>
135137
<section>
136138
{GenerateMetaPackageItem(metaPackageConfig, rootConfig)}
137139
<p>There is no documentation for the meta package. Please see the section <b>Dependency Package Documentation</b> for the complete API documentation.</p>
138140
</section>
139141
140-
<p class=""version"">Version {EscapeHtml(metaPackageConfig.version)}</p>
142+
<p class=""version"">Version {EscapeHtml(metaPackageConfig.Version)}</p>
141143
</header>
142144
143145
<hr>
@@ -191,10 +193,10 @@ static int Main(string[] args)
191193
static string GenerateListItems(PluginConfig cfg)
192194
{
193195
var sb = new System.Text.StringBuilder();
194-
foreach (var e in cfg.entries)
196+
foreach (var e in cfg.Entries)
195197
{
196-
string href = $"{Uri.EscapeUriString(e.path)}/index.html";
197-
sb.AppendLine($" <li><a href=\"{href}\"><strong>{EscapeHtml(e.title)}</strong></a> — {EscapeHtml(e.description ?? "")}</li>");
198+
string href = $"{Uri.EscapeUriString(e.Path)}/index.html";
199+
sb.AppendLine($" <li><a href=\"{href}\"><strong>{EscapeHtml(e.Title)}</strong></a> — {EscapeHtml(e.Description ?? "")}</li>");
198200
}
199201
return sb.ToString();
200202
}
@@ -203,8 +205,8 @@ static string GenerateMetaPackageItem(MetaPackageConfig metaPackageConfig, RootC
203205
{
204206
var sb = new System.Text.StringBuilder();
205207
sb.AppendLine("<ul class=\"list\">");
206-
string description = CreatePrefix(rootConfig, metaPackageConfig.description);
207-
sb.AppendLine($" <li><strong>{EscapeHtml(metaPackageConfig.packageName)}</strong> — {EscapeHtml(description ?? "")}</li>");
208+
string description = CreatePrefix(rootConfig, metaPackageConfig.Desrciption);
209+
sb.AppendLine($" <li><strong>{EscapeHtml(metaPackageConfig.PackageName)}</strong> — {EscapeHtml(description ?? "")}</li>");
208210
sb.AppendLine("</ul>");
209211
return sb.ToString();
210212
}
@@ -215,9 +217,9 @@ static string CreatePrefix(RootConfig config, string input)
215217
{
216218
return input;
217219
}
218-
if (input.StartsWith(config.baseDescription))
220+
if (input.StartsWith(config.BaseDescription))
219221
{
220-
return input.Substring(config.baseDescription.Length);
222+
return input[config.BaseDescription.Length..];
221223
}
222224
return input;
223225
}

NanoXLSX.Core/Column.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -141,13 +141,15 @@ public Column(string columnAddress) : this()
141141
/// <returns>Copy of this column</returns>
142142
internal Column Copy()
143143
{
144-
Column copy = new Column();
145-
copy.IsHidden = this.IsHidden;
146-
copy.Width = this.width;
147-
copy.HasAutoFilter = this.HasAutoFilter;
148-
copy.columnAddress = this.columnAddress;
149-
copy.number = this.number;
150-
copy.defaultColumnStyle = this.defaultColumnStyle;
144+
Column copy = new Column
145+
{
146+
IsHidden = this.IsHidden,
147+
Width = this.width,
148+
HasAutoFilter = this.HasAutoFilter,
149+
columnAddress = this.columnAddress,
150+
number = this.number,
151+
defaultColumnStyle = this.defaultColumnStyle
152+
};
151153
return copy;
152154
}
153155

NanoXLSX.Core/Interfaces/Plugin/IInlinePlugInReader.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
namespace NanoXLSX.Interfaces.Reader
44
{
5+
/// <summary>
6+
/// Interface, used by in-line (queue) plug-ins in XML reader classes
7+
/// </summary>
58
internal interface IInlinePlugInReader : IPlugIn
69
{
710
/// <summary>

NanoXLSX.Core/Interfaces/Plugin/IPluginWriter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ internal interface IPlugInWriter : IPlugIn
2020
Workbook Workbook { get; set; }
2121

2222
/// <summary>
23-
/// Gets the main XML element, that is gerenated by <see cref="IPlugIn.Execute"/>
23+
/// Gets the main XML element, that is generated by <see cref="IPlugIn.Execute"/>
2424
/// </summary>
2525
XmlElement XmlElement { get; }
2626

NanoXLSX.Core/LegacyPassword.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public void CopyFrom(IPassword passwordInstance)
127127
/// Method to generate a legacy (Excel internal) password hash, to protect workbooks or worksheets<br />This method is derived from the c++ implementation by Kohei Yoshida (<a href="http://kohei.us/2008/01/18/excel-sheet-protection-password-hash/">http://kohei.us/2008/01/18/excel-sheet-protection-password-hash/</a>)
128128
/// </summary>
129129
/// \remark <remarks>WARNING! Do not use this method to encrypt 'real' passwords or data outside from NanoXLSX. This is only a minor security feature. Use a proper cryptography method instead.</remarks>
130-
/// <param name="password">Password string in UTF-8 to encrypt. Null or an empty string (even technical valid) are not allwd, since they cannot be inserted in a password field in Excel</param>
130+
/// <param name="password">Password string in UTF-8 to encrypt. Null or an empty string (even technical valid) are not allowed, since they cannot be inserted in a password field in Excel</param>
131131
/// <returns>16 bit hash as hex string. If the passed plain text password is null or empty, the returned hash will be empty</returns>
132132
public static string GenerateLegacyPasswordHash(string password)
133133
{
@@ -157,7 +157,7 @@ private static SecureString GetSecureString(string plaintextPassword)
157157
char[] chars;
158158
if (string.IsNullOrEmpty(plaintextPassword))
159159
{
160-
#pragma warning disable CA1825 // Suppress: 0-length array allocation (sugeston is not .Net 5.0 compatible)
160+
#pragma warning disable CA1825 // Suppress: 0-length array allocation (suggestion is not .Net 5.0 compatible)
161161
chars = new char[0];
162162
#pragma warning restore CA1825 // Suppress: 0-length array allocation
163163
}

NanoXLSX.Core/Registry/PluginLoader.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,9 @@ private static void RegisterPlugIns(Assembly assembly)
131131
/// </summary>
132132
/// <param name="assembly">Assembly to analyze</param>
133133
/// <param name="attributeType">Plug-in attribute type, declared on classes of the assembly</param>
134-
/// <returns>IEnumerable of class types, matching the criteria</returns>
134+
/// <returns>List of class types, matching the criteria</returns>
135135
[ExcludeFromCodeCoverage] // Indirectly tested by InjectPlugins
136-
private static IEnumerable<Type> GetAssemblyPlugInsByType(Assembly assembly, Type attributeType)
136+
private static List<Type> GetAssemblyPlugInsByType(Assembly assembly, Type attributeType)
137137
{
138138
List<Type> plugInTypes = new List<Type>();
139139
Type plugInInterface = typeof(IPlugIn);

NanoXLSX.Core/Styles/Style.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -209,12 +209,14 @@ public override AbstractStyle Copy()
209209
{
210210
throw new StyleException("The style could not be copied because one or more components are missing as references");
211211
}
212-
Style copy = new Style();
213-
copy.CurrentBorder = CurrentBorder.CopyBorder();
214-
copy.CurrentCellXf = CurrentCellXf.CopyCellXf();
215-
copy.CurrentFill = CurrentFill.CopyFill();
216-
copy.CurrentFont = CurrentFont.CopyFont();
217-
copy.CurrentNumberFormat = CurrentNumberFormat.CopyNumberFormat();
212+
Style copy = new Style
213+
{
214+
CurrentBorder = CurrentBorder.CopyBorder(),
215+
CurrentCellXf = CurrentCellXf.CopyCellXf(),
216+
CurrentFill = CurrentFill.CopyFill(),
217+
CurrentFont = CurrentFont.CopyFont(),
218+
CurrentNumberFormat = CurrentNumberFormat.CopyNumberFormat()
219+
};
218220
return copy;
219221
}
220222

NanoXLSX.Core/Styles/StyleManager.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,11 @@ internal static StyleManager GetManagedStyles(Workbook workbook)
267267
{
268268
StyleManager styleManager = new StyleManager();
269269
styleManager.AddStyle(new Style("default", 0, true));
270-
Style borderStyle = new Style("default_border_style", 1, true);
271-
borderStyle.CurrentBorder = BasicStyles.DottedFill_0_125.CurrentBorder;
272-
borderStyle.CurrentFill = BasicStyles.DottedFill_0_125.CurrentFill;
270+
Style borderStyle = new Style("default_border_style", 1, true)
271+
{
272+
CurrentBorder = BasicStyles.DottedFill_0_125.CurrentBorder,
273+
CurrentFill = BasicStyles.DottedFill_0_125.CurrentFill
274+
};
273275
styleManager.AddStyle(borderStyle);
274276

275277
for (int i = 0; i < workbook.Worksheets.Count; i++)

NanoXLSX.Core/Themes/Theme.cs

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,10 @@ public Theme(string name)
9292
/// <returns>Theme with default values according to the default theme of Office 2019 (may be deviating)</returns>
9393
internal static Theme GetDefaultTheme()
9494
{
95-
Theme theme = new Theme("default");
96-
theme.DefaultTheme = true;
95+
Theme theme = new Theme("default")
96+
{
97+
DefaultTheme = true
98+
};
9799
ColorScheme colors = GetDefaultColorScheme();
98100
theme.Colors = colors;
99101
return theme;
@@ -105,20 +107,22 @@ internal static Theme GetDefaultTheme()
105107
/// <returns>Color scheme with default values according to the default color scheme of Office 2019 (may be deviating)</returns>
106108
internal static ColorScheme GetDefaultColorScheme()
107109
{
108-
ColorScheme colors = new ColorScheme();
109-
colors.Name = "default";
110-
colors.Dark1 = new SystemColor(SystemColor.Value.WindowText);
111-
colors.Light1 = new SystemColor(SystemColor.Value.Window, "FFFFFF");
112-
colors.Dark2 = new SrgbColor("44546A");
113-
colors.Light2 = new SrgbColor("E7E6E6");
114-
colors.Accent1 = new SrgbColor("4472C4");
115-
colors.Accent2 = new SrgbColor("ED7D31");
116-
colors.Accent3 = new SrgbColor("A5A5A5");
117-
colors.Accent4 = new SrgbColor("FFC000");
118-
colors.Accent5 = new SrgbColor("5B9BD5");
119-
colors.Accent6 = new SrgbColor("70AD47");
120-
colors.Hyperlink = new SrgbColor("0563C1");
121-
colors.FollowedHyperlink = new SrgbColor("954F72");
110+
ColorScheme colors = new ColorScheme
111+
{
112+
Name = "default",
113+
Dark1 = new SystemColor(SystemColor.Value.WindowText),
114+
Light1 = new SystemColor(SystemColor.Value.Window, "FFFFFF"),
115+
Dark2 = new SrgbColor("44546A"),
116+
Light2 = new SrgbColor("E7E6E6"),
117+
Accent1 = new SrgbColor("4472C4"),
118+
Accent2 = new SrgbColor("ED7D31"),
119+
Accent3 = new SrgbColor("A5A5A5"),
120+
Accent4 = new SrgbColor("FFC000"),
121+
Accent5 = new SrgbColor("5B9BD5"),
122+
Accent6 = new SrgbColor("70AD47"),
123+
Hyperlink = new SrgbColor("0563C1"),
124+
FollowedHyperlink = new SrgbColor("954F72")
125+
};
122126
return colors;
123127
}
124128

NanoXLSX.Core/Utils/Xml/XmlAttribute.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public static XmlAttribute CreateEmptyAttribute(string name, string prefix = "")
7575
/// </summary>
7676
/// <param name="name">Attribute name</param>
7777
/// <param name="attributes">List of attributes</param>
78-
/// <returns>Attribute that matche sthe name, or null if no attribute was found</returns>
78+
/// <returns>Attribute that matches the name, or null if no attribute was found</returns>
7979
public static XmlAttribute? FindAttribute(string name, HashSet<XmlAttribute> attributes)
8080
{
8181
if (attributes == null || attributes.Count == 0)

0 commit comments

Comments
 (0)