Skip to content

Commit 158ae4c

Browse files
Apply initial StyleCop fixes (#359)
* Fix SA1122 * Fix SA1005 * Fix SA1629 * Fix SA1119 * Fix SA1413 * Fix SA1309 * Fix SA1206 * Fix SA1128 * Fix SA1012 * Fix SA1626 * Fix SA1139 * Fix SA1413 * Fix SA1501 * Fix SA1312 * Fix SA1507 * Fix SA1512 * Fix SA1508 * Fix SA1516 * Fix SA1518 * Fix SA1642 * Fix SA1648 * Fix SA1623 * Fix SA1201 * Fix SA1306 * Fix SA1506 * Fix SA1311
1 parent ac8df46 commit 158ae4c

58 files changed

Lines changed: 327 additions & 290 deletions

Some content is hidden

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

OpenMcdf.Benchmarks/FileStreamRead.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace OpenMcdf.Benchmark;
1010
[MarkdownExporter]
1111
public class FileStreamRead : IDisposable
1212
{
13-
private string readFileName = "";
13+
private string readFileName = string.Empty;
1414
private byte[] buffer = Array.Empty<byte>();
1515

1616
[Params(Version.V3, Version.V4)]

OpenMcdf.Benchmarks/FileStreamTransactedWrite.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace OpenMcdf.Benchmark;
1010
[MarkdownExporter]
1111
public class FileStreamTransactedWrite : IDisposable
1212
{
13-
private string writeFileName = "";
13+
private string writeFileName = string.Empty;
1414
private byte[] buffer = Array.Empty<byte>();
1515

1616
[Params(Version.V3, Version.V4)]

OpenMcdf.Benchmarks/FileStreamWrite.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace OpenMcdf.Benchmark;
1010
[MarkdownExporter]
1111
public class FileStreamWrite : IDisposable
1212
{
13-
private string writeFileName = "";
13+
private string writeFileName = string.Empty;
1414
private byte[] buffer = Array.Empty<byte>();
1515

1616
[Params(Version.V3, Version.V4)]

OpenMcdf.Ole.Tests/OlePropertiesExtensionsTests.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
namespace OpenMcdf.Ole.Tests;
55

66
/// <summary>
7-
/// Summary description for UnitTest1
7+
/// Summary description for UnitTest1.
88
/// </summary>
99
[TestClass]
1010
public class OlePropertiesExtensionsTests
@@ -61,7 +61,7 @@ public void ModifyDocumentSummaryInformation()
6161

6262
// The company property should exist but be empty
6363
OleProperty companyProperty = co.Properties.First(prop => prop.PropertyName == "PIDDSI_COMPANY");
64-
Assert.AreEqual("", companyProperty.Value);
64+
Assert.AreEqual(string.Empty, companyProperty.Value);
6565

6666
// As a sanity check, check that the value of a property that we don't change remains the same
6767
OleProperty formatProperty = co.Properties.First(prop => prop.PropertyName == "PIDDSI_PRESFORMAT");
@@ -181,7 +181,7 @@ public void SummaryInformationModifyLpwstring()
181181
Assert.AreEqual("abcdefghijk", keyWordsProperty.Value);
182182

183183
authorProperty.Value = "ABC";
184-
keyWordsProperty.Value = "";
184+
keyWordsProperty.Value = string.Empty;
185185
co.Save(dsiStream);
186186
}
187187

@@ -197,7 +197,7 @@ public void SummaryInformationModifyLpwstring()
197197

198198
OleProperty keyWordsProperty = co.Properties.First(prop => prop.PropertyName == "PIDSI_KEYWORDS");
199199
Assert.AreEqual(VTPropertyType.VT_LPWSTR, keyWordsProperty.VTType);
200-
Assert.AreEqual("", keyWordsProperty.Value);
200+
Assert.AreEqual(string.Empty, keyWordsProperty.Value);
201201
}
202202
}
203203

@@ -230,7 +230,7 @@ public void TestReadUnicodeUserPropertiesDictionary()
230230

231231
// String properties
232232
Assert.AreEqual("A", propArray[1].PropertyName);
233-
Assert.AreEqual("", propArray[1].Value);
233+
Assert.AreEqual(string.Empty, propArray[1].Value);
234234
Assert.AreEqual("AB", propArray[2].PropertyName);
235235
Assert.AreEqual("X", propArray[2].Value);
236236
Assert.AreEqual("ABC", propArray[3].PropertyName);
@@ -321,7 +321,7 @@ public void AddDocumentSummaryInformationCustomInfo()
321321
}
322322
}
323323

324-
/// As Test_DOCUMENT_SUMMARY_INFO_ADD_CUSTOM, but adding user defined properties with the AddUserDefinedProperty function
324+
// As Test_DOCUMENT_SUMMARY_INFO_ADD_CUSTOM, but adding user defined properties with the AddUserDefinedProperty function
325325
[TestMethod]
326326
public void TestAddUserDefinedProperty()
327327
{
@@ -380,7 +380,7 @@ private static void ValidateAddedUserDefinedProperties(MemoryStream stream, Date
380380
Assert.AreEqual(VTPropertyType.VT_R8, propArray[5].VTType);
381381
}
382382

383-
/// The names of user defined properties must be unique - adding a duplicate should throw.
383+
// The names of user defined properties must be unique - adding a duplicate should throw.
384384
[TestMethod]
385385
public void TestAddUserDefinedPropertyShouldPreventDuplicates()
386386
{
@@ -407,7 +407,7 @@ public void ReadLpwstringVector()
407407
using CfbStream stream = cf.OpenStream(PropertySetNames.DocSummaryInformation);
408408
OlePropertiesContainer co = new(stream);
409409

410-
OleProperty? docPartsProperty = co.Properties.FirstOrDefault(property => property.PropertyIdentifier == 13); //13 == PIDDSI_DOCPARTS
410+
OleProperty? docPartsProperty = co.Properties.FirstOrDefault(property => property.PropertyIdentifier == 13); // 13 == PIDDSI_DOCPARTS
411411
Assert.IsNotNull(docPartsProperty);
412412

413413
var docPartsValues = docPartsProperty.Value as IList<string>;
@@ -449,9 +449,9 @@ public void AddUserDefinedPropertiesSection()
449449
Assert.IsNotNull(newUserDefinedProperties.PropertyNames);
450450
newUserDefinedProperties.PropertyNames[2] = "MyCustomProperty";
451451

452-
OleProperty CreateProperty = co.CreateProperty(VTPropertyType.VT_LPSTR, 2);
453-
CreateProperty.Value = "Testing";
454-
newUserDefinedProperties.Add(CreateProperty);
452+
OleProperty createProperty = co.CreateProperty(VTPropertyType.VT_LPSTR, 2);
453+
createProperty.Value = "Testing";
454+
newUserDefinedProperties.Add(createProperty);
455455

456456
co.Save(dsiStream);
457457
}
@@ -492,7 +492,7 @@ public void TestRetainDictionaryPropertyInAppSpecificStreams()
492492
{
493493
[2] = "Document Number",
494494
[3] = "Revision",
495-
[4] = "Project Name"
495+
[4] = "Project Name",
496496
};
497497

498498
Guid expectedFmtid0 = Guid.Parse("f0d6d0b1-a0d8-11ce-8aa2-08003601e988");

OpenMcdf.Ole/DictionaryProperty.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ private void ReadEntry(BinaryReader br)
7171
/// Write the dictionary and all its values into the specified <see cref="BinaryWriter"/>.
7272
/// </summary>
7373
/// <remarks>
74-
/// Based on the Microsoft specifications at https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-oleps/99127b7f-c440-4697-91a4-c853086d6b33
74+
/// Based on the Microsoft specifications at https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-oleps/99127b7f-c440-4697-91a4-c853086d6b33.
7575
/// </remarks>
7676
/// <param name="bw">A writer to write the dictionary into.</param>
7777
public void Write(BinaryWriter bw)
@@ -136,4 +136,3 @@ private static void WritePaddingIfNeeded(BinaryWriter bw, int fieldLength)
136136
}
137137
}
138138
}
139-

OpenMcdf.Ole/IBinarySerializable.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
internal interface IBinarySerializable
44
{
55
void Write(BinaryWriter bw);
6+
67
void Read(BinaryReader br);
78
}

OpenMcdf.Ole/IProperty.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
internal enum PropertyType
44
{
55
TypedPropertyValue = 0,
6-
DictionaryProperty = 1
6+
DictionaryProperty = 1,
77
}
88

99
internal interface IProperty : IBinarySerializable

OpenMcdf.Ole/ITypedPropertyValue.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ internal enum PropertyDimensions
44
{
55
IsScalar,
66
IsVector,
7-
IsArray
7+
IsArray,
88
}
99

1010
internal interface ITypedPropertyValue : IProperty

OpenMcdf.Ole/OlePropertiesContainer.cs

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public enum ContainerType
1010
UserDefinedProperties = 3,
1111
GlobalInfo = 4,
1212
ImageContents = 5,
13-
ImageInfo = 6
13+
ImageInfo = 6,
1414
}
1515

1616
public class OlePropertiesContainer
@@ -34,7 +34,7 @@ public class OlePropertiesContainer
3434
private readonly List<OleProperty> properties = new();
3535

3636
/// <summary>
37-
/// Create a new instance of <see cref="OlePropertiesContainer"/> with the specified code page and container type.
37+
/// Initializes a new instance of the <see cref="OlePropertiesContainer"/> class.
3838
/// </summary>
3939
/// <param name="codePage">The code page to use for the new container.</param>
4040
/// <param name="containerType">The type of the new container.</param>
@@ -43,7 +43,7 @@ public OlePropertiesContainer(int codePage, ContainerType containerType)
4343
Context = new PropertyContext
4444
{
4545
CodePage = codePage,
46-
Behavior = Behavior.CaseInsensitive
46+
Behavior = Behavior.CaseInsensitive,
4747
};
4848

4949
ContainerType = containerType;
@@ -69,16 +69,15 @@ public OlePropertiesContainer(CfbStream cfStream)
6969
{
7070
PropertyIdentifierAndOffset propertyIdentifierAndOffset = pStream.PropertySet0.PropertyIdentifierAndOffsets[i];
7171
if (propertyIdentifierAndOffset.PropertyIdentifier == SpecialPropertyIdentifiers.Dictionary) continue;
72-
//if (propertyIdentifierAndOffset.PropertyIdentifier == 1) continue;
73-
//if (propertyIdentifierAndOffset.PropertyIdentifier == 0x80000000) continue;
74-
72+
// if (propertyIdentifierAndOffset.PropertyIdentifier == 1) continue;
73+
// if (propertyIdentifierAndOffset.PropertyIdentifier == 0x80000000) continue;
7574
var p = (ITypedPropertyValue)pStream.PropertySet0.Properties[i];
7675

7776
OleProperty op = new(this)
7877
{
7978
VTType = p.VTType,
8079
PropertyIdentifier = propertyIdentifierAndOffset.PropertyIdentifier,
81-
Value = p.Value
80+
Value = p.Value,
8281
};
8382

8483
properties.Add(op);
@@ -101,7 +100,7 @@ public OlePropertiesContainer(CfbStream cfStream)
101100
{
102101
VTType = p.VTType,
103102
PropertyIdentifier = propertyIdentifierAndOffset.PropertyIdentifier,
104-
Value = p.Value
103+
Value = p.Value,
105104
};
106105

107106
UserDefinedProperties.properties.Add(op);
@@ -121,7 +120,7 @@ public OleProperty CreateProperty(VTPropertyType vtPropertyType, uint propertyId
121120
OleProperty op = new(this)
122121
{
123122
VTType = vtPropertyType,
124-
PropertyIdentifier = propertyIdentifier
123+
PropertyIdentifier = propertyIdentifier,
125124
};
126125

127126
return op;
@@ -136,7 +135,7 @@ public OleProperty CreateProperty(VTPropertyType vtPropertyType, uint propertyId
136135
/// <param name="name">The name of the new property.</param>
137136
/// <returns>The new property.</returns>
138137
/// <exception cref="InvalidOperationException">If UserDefinedProperties aren't allowed for this container.</exception>
139-
/// <exception cref="ArgumentException">If a property with the name <paramref name="name"/> already exists."/></exception>
138+
/// <exception cref="ArgumentException">If a property with the name <paramref name="name"/> already exists."/>.</exception>
140139
public OleProperty AddUserDefinedProperty(VTPropertyType vtPropertyType, string name)
141140
{
142141
if (this.ContainerType != ContainerType.UserDefinedProperties)
@@ -166,7 +165,7 @@ public OleProperty AddUserDefinedProperty(VTPropertyType vtPropertyType, string
166165
var op = new OleProperty(this)
167166
{
168167
VTType = vtPropertyType,
169-
PropertyIdentifier = identifier
168+
PropertyIdentifier = identifier,
170169
};
171170

172171
properties.Add(op);
@@ -200,14 +199,14 @@ public OlePropertiesContainer CreateUserDefinedProperties(int codePage)
200199
// Create the container, and add the code page to the initial set of properties
201200
UserDefinedProperties = new OlePropertiesContainer(codePage, ContainerType.UserDefinedProperties)
202201
{
203-
PropertyNames = new Dictionary<uint, string>()
202+
PropertyNames = new Dictionary<uint, string>(),
204203
};
205204

206205
var op = new OleProperty(UserDefinedProperties)
207206
{
208207
VTType = VTPropertyType.VT_I2,
209208
PropertyIdentifier = 1,
210-
Value = (short)codePage
209+
Value = (short)codePage,
211210
};
212211

213212
UserDefinedProperties.properties.Add(op);
@@ -236,8 +235,8 @@ public void Save(Stream cfStream)
236235

237236
PropertySet0 = new PropertySet
238237
{
239-
PropertyContext = Context
240-
}
238+
PropertyContext = Context,
239+
},
241240
};
242241

243242
// If we're writing an AppSpecific property set and have property names, then add a dictionary property
@@ -263,7 +262,7 @@ public void Save(Stream cfStream)
263262

264263
ps.PropertySet1 = new PropertySet
265264
{
266-
PropertyContext = UserDefinedProperties.Context
265+
PropertyContext = UserDefinedProperties.Context,
267266
};
268267

269268
ps.FMTID1 = FormatIdentifiers.UserDefinedProperties;

OpenMcdf.Ole/PropertyContext.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
public enum Behavior
44
{
55
CaseSensitive,
6-
CaseInsensitive
6+
CaseInsensitive,
77
}
88

99
public sealed class PropertyContext
1010
{
1111
public int CodePage { get; set; }
12+
1213
public Behavior Behavior { get; set; }
14+
1315
public uint Locale { get; set; }
1416
}

0 commit comments

Comments
 (0)