FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Apply initial StyleCop fixes by jeremy-visionaid · Pull Request #359 · openmcdf/openmcdf · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .cs  (58) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
2 changes: 1 addition & 1 deletion OpenMcdf.Benchmarks/FileStreamRead.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace OpenMcdf.Benchmark;
[MarkdownExporter]
public class FileStreamRead : IDisposable
{
private string readFileName = "";
private string readFileName = string.Empty;
private byte[] buffer = Array.Empty<byte>();

[Params(Version.V3, Version.V4)]
Expand Down
2 changes: 1 addition & 1 deletion OpenMcdf.Benchmarks/FileStreamTransactedWrite.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace OpenMcdf.Benchmark;
[MarkdownExporter]
public class FileStreamTransactedWrite : IDisposable
{
private string writeFileName = "";
private string writeFileName = string.Empty;
private byte[] buffer = Array.Empty<byte>();

[Params(Version.V3, Version.V4)]
Expand Down
2 changes: 1 addition & 1 deletion OpenMcdf.Benchmarks/FileStreamWrite.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace OpenMcdf.Benchmark;
[MarkdownExporter]
public class FileStreamWrite : IDisposable
{
private string writeFileName = "";
private string writeFileName = string.Empty;
private byte[] buffer = Array.Empty<byte>();

[Params(Version.V3, Version.V4)]
Expand Down
24 changes: 12 additions & 12 deletions OpenMcdf.Ole.Tests/OlePropertiesExtensionsTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace OpenMcdf.Ole.Tests;

/// <summary>
/// Summary description for UnitTest1
/// Summary description for UnitTest1.
/// </summary>
[TestClass]
public class OlePropertiesExtensionsTests
Expand Down Expand Up @@ -61,7 +61,7 @@ public void ModifyDocumentSummaryInformation()

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

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

authorProperty.Value = "ABC";
keyWordsProperty.Value = "";
keyWordsProperty.Value = string.Empty;
co.Save(dsiStream);
}

Expand All @@ -197,7 +197,7 @@ public void SummaryInformationModifyLpwstring()

OleProperty keyWordsProperty = co.Properties.First(prop => prop.PropertyName == "PIDSI_KEYWORDS");
Assert.AreEqual(VTPropertyType.VT_LPWSTR, keyWordsProperty.VTType);
Assert.AreEqual("", keyWordsProperty.Value);
Assert.AreEqual(string.Empty, keyWordsProperty.Value);
}
}

Expand Down Expand Up @@ -230,7 +230,7 @@ public void TestReadUnicodeUserPropertiesDictionary()

// String properties
Assert.AreEqual("A", propArray[1].PropertyName);
Assert.AreEqual("", propArray[1].Value);
Assert.AreEqual(string.Empty, propArray[1].Value);
Assert.AreEqual("AB", propArray[2].PropertyName);
Assert.AreEqual("X", propArray[2].Value);
Assert.AreEqual("ABC", propArray[3].PropertyName);
Expand Down Expand Up @@ -321,7 +321,7 @@ public void AddDocumentSummaryInformationCustomInfo()
}
}

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

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

OleProperty? docPartsProperty = co.Properties.FirstOrDefault(property => property.PropertyIdentifier == 13); //13 == PIDDSI_DOCPARTS
OleProperty? docPartsProperty = co.Properties.FirstOrDefault(property => property.PropertyIdentifier == 13); // 13 == PIDDSI_DOCPARTS
Assert.IsNotNull(docPartsProperty);

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

OleProperty CreateProperty = co.CreateProperty(VTPropertyType.VT_LPSTR, 2);
CreateProperty.Value = "Testing";
newUserDefinedProperties.Add(CreateProperty);
OleProperty createProperty = co.CreateProperty(VTPropertyType.VT_LPSTR, 2);
createProperty.Value = "Testing";
newUserDefinedProperties.Add(createProperty);

co.Save(dsiStream);
}
Expand Down Expand Up @@ -492,7 +492,7 @@ public void TestRetainDictionaryPropertyInAppSpecificStreams()
{
[2] = "Document Number",
[3] = "Revision",
[4] = "Project Name"
[4] = "Project Name",
};

Guid expectedFmtid0 = Guid.Parse("f0d6d0b1-a0d8-11ce-8aa2-08003601e988");
Expand Down
3 changes: 1 addition & 2 deletions OpenMcdf.Ole/DictionaryProperty.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private void ReadEntry(BinaryReader br)
/// Write the dictionary and all its values into the specified <see cref="BinaryWriter"/>.
/// </summary>
/// <remarks>
/// Based on the Microsoft specifications at https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-oleps/99127b7f-c440-4697-91a4-c853086d6b33
/// Based on the Microsoft specifications at https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-oleps/99127b7f-c440-4697-91a4-c853086d6b33.
/// </remarks>
/// <param name="bw">A writer to write the dictionary into.</param>
public void Write(BinaryWriter bw)
Expand Down Expand Up @@ -136,4 +136,3 @@ private static void WritePaddingIfNeeded(BinaryWriter bw, int fieldLength)
}
}
}

1 change: 1 addition & 0 deletions OpenMcdf.Ole/IBinarySerializable.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
internal interface IBinarySerializable
{
void Write(BinaryWriter bw);

void Read(BinaryReader br);
}
2 changes: 1 addition & 1 deletion OpenMcdf.Ole/IProperty.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
internal enum PropertyType
{
TypedPropertyValue = 0,
DictionaryProperty = 1
DictionaryProperty = 1,
}

internal interface IProperty : IBinarySerializable
Expand Down
2 changes: 1 addition & 1 deletion OpenMcdf.Ole/ITypedPropertyValue.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ internal enum PropertyDimensions
{
IsScalar,
IsVector,
IsArray
IsArray,
}

internal interface ITypedPropertyValue : IProperty
Expand Down
31 changes: 15 additions & 16 deletions OpenMcdf.Ole/OlePropertiesContainer.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public enum ContainerType
UserDefinedProperties = 3,
GlobalInfo = 4,
ImageContents = 5,
ImageInfo = 6
ImageInfo = 6,
}

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

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

ContainerType = containerType;
Expand All @@ -69,16 +69,15 @@ public OlePropertiesContainer(CfbStream cfStream)
{
PropertyIdentifierAndOffset propertyIdentifierAndOffset = pStream.PropertySet0.PropertyIdentifierAndOffsets[i];
if (propertyIdentifierAndOffset.PropertyIdentifier == SpecialPropertyIdentifiers.Dictionary) continue;
//if (propertyIdentifierAndOffset.PropertyIdentifier == 1) continue;
//if (propertyIdentifierAndOffset.PropertyIdentifier == 0x80000000) continue;

// if (propertyIdentifierAndOffset.PropertyIdentifier == 1) continue;
// if (propertyIdentifierAndOffset.PropertyIdentifier == 0x80000000) continue;
var p = (ITypedPropertyValue)pStream.PropertySet0.Properties[i];

OleProperty op = new(this)
{
VTType = p.VTType,
PropertyIdentifier = propertyIdentifierAndOffset.PropertyIdentifier,
Value = p.Value
Value = p.Value,
};

properties.Add(op);
Expand All @@ -101,7 +100,7 @@ public OlePropertiesContainer(CfbStream cfStream)
{
VTType = p.VTType,
PropertyIdentifier = propertyIdentifierAndOffset.PropertyIdentifier,
Value = p.Value
Value = p.Value,
};

UserDefinedProperties.properties.Add(op);
Expand All @@ -121,7 +120,7 @@ public OleProperty CreateProperty(VTPropertyType vtPropertyType, uint propertyId
OleProperty op = new(this)
{
VTType = vtPropertyType,
PropertyIdentifier = propertyIdentifier
PropertyIdentifier = propertyIdentifier,
};

return op;
Expand All @@ -136,7 +135,7 @@ public OleProperty CreateProperty(VTPropertyType vtPropertyType, uint propertyId
/// <param name="name">The name of the new property.</param>
/// <returns>The new property.</returns>
/// <exception cref="InvalidOperationException">If UserDefinedProperties aren't allowed for this container.</exception>
/// <exception cref="ArgumentException">If a property with the name <paramref name="name"/> already exists."/></exception>
/// <exception cref="ArgumentException">If a property with the name <paramref name="name"/> already exists."/>.</exception>
public OleProperty AddUserDefinedProperty(VTPropertyType vtPropertyType, string name)
{
if (this.ContainerType != ContainerType.UserDefinedProperties)
Expand Down Expand Up @@ -166,7 +165,7 @@ public OleProperty AddUserDefinedProperty(VTPropertyType vtPropertyType, string
var op = new OleProperty(this)
{
VTType = vtPropertyType,
PropertyIdentifier = identifier
PropertyIdentifier = identifier,
};

properties.Add(op);
Expand Down Expand Up @@ -200,14 +199,14 @@ public OlePropertiesContainer CreateUserDefinedProperties(int codePage)
// Create the container, and add the code page to the initial set of properties
UserDefinedProperties = new OlePropertiesContainer(codePage, ContainerType.UserDefinedProperties)
{
PropertyNames = new Dictionary<uint, string>()
PropertyNames = new Dictionary<uint, string>(),
};

var op = new OleProperty(UserDefinedProperties)
{
VTType = VTPropertyType.VT_I2,
PropertyIdentifier = 1,
Value = (short)codePage
Value = (short)codePage,
};

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

PropertySet0 = new PropertySet
{
PropertyContext = Context
}
PropertyContext = Context,
},
};

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

ps.PropertySet1 = new PropertySet
{
PropertyContext = UserDefinedProperties.Context
PropertyContext = UserDefinedProperties.Context,
};

ps.FMTID1 = FormatIdentifiers.UserDefinedProperties;
Expand Down
4 changes: 3 additions & 1 deletion OpenMcdf.Ole/PropertyContext.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
public enum Behavior
{
CaseSensitive,
CaseInsensitive
CaseInsensitive,
}

public sealed class PropertyContext
{
public int CodePage { get; set; }

public Behavior Behavior { get; set; }

public uint Locale { get; set; }
}
Loading
Loading

Back | FazBrowse Home | New Git URL