diff --git a/OpenXmlFormats/Wordprocessing/Document.cs b/OpenXmlFormats/Wordprocessing/Document.cs index 9ddac8a97..3a02611db 100644 --- a/OpenXmlFormats/Wordprocessing/Document.cs +++ b/OpenXmlFormats/Wordprocessing/Document.cs @@ -854,8 +854,8 @@ public class CT_DocPartPr public CT_DocPartPr() { - this.itemsElementNameField = new ItemsChoiceType11[0]; - this.itemsField = new object[0]; + this.itemsElementNameField = Array.Empty(); + this.itemsField = Array.Empty(); } [XmlElement("behaviors", typeof(CT_DocPartBehaviors), Order = 0)] diff --git a/OpenXmlFormats/Wordprocessing/Frame.cs b/OpenXmlFormats/Wordprocessing/Frame.cs index d5d044198..cdb901b86 100644 --- a/OpenXmlFormats/Wordprocessing/Frame.cs +++ b/OpenXmlFormats/Wordprocessing/Frame.cs @@ -23,7 +23,7 @@ public class CT_Frameset public CT_Frameset() { - this.itemsField = new object[0]; + this.itemsField = Array.Empty(); this.frameLayoutField = new CT_FrameLayout(); this.framesetSplitbarField = new CT_FramesetSplitbar(); this.szField = new CT_String(); diff --git a/OpenXmlFormats/Wordprocessing/wml.cs b/OpenXmlFormats/Wordprocessing/wml.cs index e501c19df..b9d087f80 100644 --- a/OpenXmlFormats/Wordprocessing/wml.cs +++ b/OpenXmlFormats/Wordprocessing/wml.cs @@ -129,8 +129,8 @@ public class CT_TxbxContent public CT_TxbxContent() { - this.itemsElementNameField = new ItemsChoiceType[0]; - this.itemsField = new object[0]; + this.itemsElementNameField = Array.Empty(); + this.itemsField = Array.Empty(); } [XmlElement("oMath", typeof(CT_OMath), Namespace = "http://schemas.openxmlformats.org/officeDocument/2006/math", Order = 0)] diff --git a/main/DDF/DefaultEscherRecordFactory.cs b/main/DDF/DefaultEscherRecordFactory.cs index dfce54d46..e4df8249e 100644 --- a/main/DDF/DefaultEscherRecordFactory.cs +++ b/main/DDF/DefaultEscherRecordFactory.cs @@ -133,7 +133,7 @@ private static Dictionary RecordsToMap(Type[] records) { Dictionary result = new Dictionary(); //ConstructorInfo constructor; - Type[] EMPTY_CLASS_ARRAY = new Type[0]; + Type[] EMPTY_CLASS_ARRAY = Array.Empty(); for (int i = 0; i < records.Length; i++) { Type recordType = records[i]; diff --git a/main/DDF/EscherBSERecord.cs b/main/DDF/EscherBSERecord.cs index da30605e5..2b731d343 100644 --- a/main/DDF/EscherBSERecord.cs +++ b/main/DDF/EscherBSERecord.cs @@ -58,7 +58,7 @@ public class EscherBSERecord : EscherRecord private byte field_11_unused3; private EscherBlipRecord field_12_blipRecord; - private byte[] _remainingData = new byte[0]; + private byte[] _remainingData = Array.Empty(); /// /// This method deSerializes the record from a byte array. @@ -114,7 +114,7 @@ public override int Serialize(int offset, byte[] data, EscherSerializationListen listener.BeforeRecordSerialize(offset, RecordId, this); if (_remainingData == null) - _remainingData = new byte[0]; + _remainingData = Array.Empty(); LittleEndian.PutShort(data, offset, Options); LittleEndian.PutShort(data, offset + 2, RecordId); @@ -322,7 +322,7 @@ public byte[] RemainingData { if (value == null) { - _remainingData = new byte[0]; + _remainingData = Array.Empty(); } else { diff --git a/main/DDF/EscherClientAnchorRecord.cs b/main/DDF/EscherClientAnchorRecord.cs index 364e471e6..b22ab61cb 100644 --- a/main/DDF/EscherClientAnchorRecord.cs +++ b/main/DDF/EscherClientAnchorRecord.cs @@ -52,7 +52,7 @@ public class EscherClientAnchorRecord : EscherRecord private short field_7_dx2; private short field_8_row2; private short field_9_dy2; - private byte[] remainingData = new byte[0]; + private byte[] remainingData = Array.Empty(); private bool shortRecord = false; /// @@ -110,7 +110,7 @@ public override int Serialize(int offset, byte[] data, EscherSerializationListen { listener.BeforeRecordSerialize(offset, RecordId, this); - if (remainingData == null) remainingData = new byte[0]; + if (remainingData == null) remainingData = Array.Empty(); LittleEndian.PutShort(data, offset, Options); LittleEndian.PutShort(data, offset + 2, RecordId); int remainingBytes = remainingData.Length + (shortRecord ? 8 : 18); @@ -329,7 +329,7 @@ public byte[] RemainingData { if (value == null) { - this.remainingData = new byte[0]; + this.remainingData = Array.Empty(); } else { diff --git a/main/DDF/EscherClientDataRecord.cs b/main/DDF/EscherClientDataRecord.cs index 47bac62b4..3ae18c1ea 100644 --- a/main/DDF/EscherClientDataRecord.cs +++ b/main/DDF/EscherClientDataRecord.cs @@ -65,7 +65,7 @@ public override int Serialize(int offset, byte[] data, EscherSerializationListen { listener.BeforeRecordSerialize(offset, RecordId, this); - if (remainingData == null) remainingData = new byte[0]; + if (remainingData == null) remainingData = Array.Empty(); LittleEndian.PutShort(data, offset, Options); LittleEndian.PutShort(data, offset + 2, RecordId); LittleEndian.PutInt(data, offset + 4, remainingData.Length); @@ -137,7 +137,7 @@ public byte[] RemainingData get { return remainingData; } set { - this.remainingData = (value == null) ? new byte[0] : (byte[])value.Clone(); + this.remainingData = (value == null) ? Array.Empty() : (byte[])value.Clone(); } } } diff --git a/main/DDF/EscherComplexProperty.cs b/main/DDF/EscherComplexProperty.cs index 75f520e55..748af1fe9 100644 --- a/main/DDF/EscherComplexProperty.cs +++ b/main/DDF/EscherComplexProperty.cs @@ -32,7 +32,7 @@ namespace NPOI.DDF /// public class EscherComplexProperty : EscherProperty { - private byte[] _complexData = new byte[0]; + private byte[] _complexData = Array.Empty(); /// /// Create a complex property using the property id and a byte array containing the complex diff --git a/main/DDF/EscherTextboxRecord.cs b/main/DDF/EscherTextboxRecord.cs index c5285a972..194f87764 100644 --- a/main/DDF/EscherTextboxRecord.cs +++ b/main/DDF/EscherTextboxRecord.cs @@ -37,7 +37,7 @@ public class EscherTextboxRecord : EscherRecord, ICloneable public const short RECORD_ID = unchecked((short)0xF00D); public const string RECORD_DESCRIPTION = "msofbtClientTextbox"; - private static readonly byte[] NO_BYTES = new byte[0]; + private static readonly byte[] NO_BYTES = Array.Empty(); /** The data for this record not including the the 8 byte header */ private byte[] _thedata = NO_BYTES; diff --git a/main/DDF/UnknownEscherRecord.cs b/main/DDF/UnknownEscherRecord.cs index 25012cb77..201f3b686 100644 --- a/main/DDF/UnknownEscherRecord.cs +++ b/main/DDF/UnknownEscherRecord.cs @@ -31,7 +31,7 @@ namespace NPOI.DDF /// public class UnknownEscherRecord : EscherRecord, ICloneable { - private static byte[] NO_BYTES = new byte[0]; + private static byte[] NO_BYTES = Array.Empty(); /** The data for this record not including the the 8 byte header */ private byte[] _thedata = NO_BYTES; @@ -65,7 +65,7 @@ public override int FillFields(byte[] data, int offset, IEscherRecordFactory rec if (IsContainerRecord) { int bytesWritten = 0; - _thedata = new byte[0]; + _thedata = Array.Empty(); offset += 8; bytesWritten += 8; while (bytesRemaining > 0) diff --git a/main/HPSF/Blob.cs b/main/HPSF/Blob.cs index f255d15b1..fe19f19a2 100644 --- a/main/HPSF/Blob.cs +++ b/main/HPSF/Blob.cs @@ -12,7 +12,7 @@ public Blob(byte[] data, int offset) if (size == 0) { - _value = new byte[0]; + _value = System.Array.Empty(); return; } diff --git a/main/HPSF/ClipboardData.cs b/main/HPSF/ClipboardData.cs index 41f770f32..2e8a2f0b0 100644 --- a/main/HPSF/ClipboardData.cs +++ b/main/HPSF/ClipboardData.cs @@ -22,7 +22,7 @@ public ClipboardData(byte[] data, int offset) // + "(doesn't even have format field!). " // + "Setting to format == 0 and hope for the best" ); _format = 0; - _value = new byte[0]; + _value = System.Array.Empty(); return; } diff --git a/main/HPSF/UnicodeString.cs b/main/HPSF/UnicodeString.cs index ce383be5e..38be464d9 100644 --- a/main/HPSF/UnicodeString.cs +++ b/main/HPSF/UnicodeString.cs @@ -58,7 +58,7 @@ public UnicodeString(byte[] data, int offset) if (length == 0) { - _value = new byte[0]; + _value = System.Array.Empty(); return; } diff --git a/main/HSSF/Model/LinkTable.cs b/main/HSSF/Model/LinkTable.cs index 065c021d4..52c08d41f 100644 --- a/main/HSSF/Model/LinkTable.cs +++ b/main/HSSF/Model/LinkTable.cs @@ -124,8 +124,8 @@ private class ExternalBookBlock public ExternalBookBlock() { _externalBookRecord = SupBookRecord.CreateAddInFunctions(); - _externalNameRecords = new ExternalNameRecord[0]; - _crnBlocks = new CRNBlock[0]; + _externalNameRecords = Array.Empty(); + _crnBlocks = Array.Empty(); } public ExternalBookBlock(RecordStream rs) { @@ -152,7 +152,7 @@ public ExternalBookBlock(RecordStream rs) public ExternalBookBlock(String url, String[] sheetNames) { _externalBookRecord = SupBookRecord.CreateExternalReferences(url, sheetNames); - _crnBlocks = new CRNBlock[0]; + _crnBlocks = Array.Empty(); } /** @@ -163,8 +163,8 @@ public ExternalBookBlock(String url, String[] sheetNames) public ExternalBookBlock(int numberOfSheets) { _externalBookRecord = SupBookRecord.CreateInternalReferences((short)numberOfSheets); - _externalNameRecords = new ExternalNameRecord[0]; - _crnBlocks = new CRNBlock[0]; + _externalNameRecords = Array.Empty(); + _crnBlocks = Array.Empty(); } public int NumberOfNames diff --git a/main/HSSF/Record/Aggregates/SharedValueManager.cs b/main/HSSF/Record/Aggregates/SharedValueManager.cs index 43dea3022..eec31755e 100644 --- a/main/HSSF/Record/Aggregates/SharedValueManager.cs +++ b/main/HSSF/Record/Aggregates/SharedValueManager.cs @@ -118,7 +118,7 @@ public bool IsFirstCell(int row, int column) } public static readonly SharedValueManager EMPTY = new SharedValueManager( - new SharedFormulaRecord[0], new CellReference[0], new List(), new List()); + Array.Empty(), Array.Empty(), new List(), new List()); private List _arrayRecords; private List _tableRecords; private Dictionary _groupsBySharedFormulaRecord; @@ -149,7 +149,7 @@ public static SharedValueManager CreateEmpty() { // Note - must create distinct instances because they are assumed to be mutable. return new SharedValueManager( - new SharedFormulaRecord[0], new CellReference[0], new List(), new List()); + Array.Empty(), Array.Empty(), new List(), new List()); } /** * @param firstCells diff --git a/main/HSSF/Record/CFRule12Record.cs b/main/HSSF/Record/CFRule12Record.cs index b50fa10dd..2935fc61e 100644 --- a/main/HSSF/Record/CFRule12Record.cs +++ b/main/HSSF/Record/CFRule12Record.cs @@ -193,7 +193,7 @@ public CFRule12Record(RecordInputStream in1) { int field_4_formula2_len = in1.ReadUShort(); ext_formatting_length = in1.ReadInt(); - ext_formatting_data = new byte[0]; + ext_formatting_data = Array.Empty(); if (ext_formatting_length == 0) { // 2 bytes reserved in1.ReadUShort(); diff --git a/main/HSSF/Record/Chart/ChartEndBlockRecord.cs b/main/HSSF/Record/Chart/ChartEndBlockRecord.cs index 0abde89c2..3d2b70ec3 100644 --- a/main/HSSF/Record/Chart/ChartEndBlockRecord.cs +++ b/main/HSSF/Record/Chart/ChartEndBlockRecord.cs @@ -50,7 +50,7 @@ public ChartEndBlockRecord(RecordInputStream in1) iObjectKind = in1.ReadShort(); // Often, but not always has 6 unused bytes at the end if(in1.Available() == 0) { - unused = new byte[0]; + unused = Array.Empty(); } else { unused = new byte[6]; in1.ReadFully(unused); diff --git a/main/HSSF/Record/Chart/EndBlockRecord.cs b/main/HSSF/Record/Chart/EndBlockRecord.cs index 3d50c062e..814815207 100644 --- a/main/HSSF/Record/Chart/EndBlockRecord.cs +++ b/main/HSSF/Record/Chart/EndBlockRecord.cs @@ -55,7 +55,7 @@ public EndBlockRecord(RecordInputStream in1) ObjectKind = (ObjectKind) in1.ReadShort(); // Often, but not always has 6 unused bytes at the end if(in1.Available() == 0) { - unused = new byte[0]; + unused = Array.Empty(); } else { unused = new byte[6]; in1.ReadFully(unused); diff --git a/main/HSSF/Record/Common/FeatProtection.cs b/main/HSSF/Record/Common/FeatProtection.cs index a191be041..4c603436a 100644 --- a/main/HSSF/Record/Common/FeatProtection.cs +++ b/main/HSSF/Record/Common/FeatProtection.cs @@ -50,7 +50,7 @@ public class FeatProtection : SharedFeature public FeatProtection() { - securityDescriptor = new byte[0]; + securityDescriptor = Array.Empty(); } public FeatProtection(RecordInputStream in1) diff --git a/main/HSSF/Record/Common/FeatSmartTag.cs b/main/HSSF/Record/Common/FeatSmartTag.cs index 5d1b23c6b..01685e06a 100644 --- a/main/HSSF/Record/Common/FeatSmartTag.cs +++ b/main/HSSF/Record/Common/FeatSmartTag.cs @@ -39,7 +39,7 @@ public class FeatSmartTag : SharedFeature public FeatSmartTag() { - data = new byte[0]; + data = Array.Empty(); } public FeatSmartTag(RecordInputStream in1) diff --git a/main/HSSF/Record/Common/UnicodeString.cs b/main/HSSF/Record/Common/UnicodeString.cs index ad5a0827c..18cdf71a1 100644 --- a/main/HSSF/Record/Common/UnicodeString.cs +++ b/main/HSSF/Record/Common/UnicodeString.cs @@ -138,8 +138,8 @@ private void populateEmpty() { reserved = 1; phoneticText = ""; - phRuns = new PhRun[0]; - extraData = new byte[0]; + phRuns = Array.Empty(); + extraData = Array.Empty(); } public override int GetHashCode() { diff --git a/main/HSSF/Record/DBCellRecord.cs b/main/HSSF/Record/DBCellRecord.cs index d30eb6518..4aeeea2bd 100644 --- a/main/HSSF/Record/DBCellRecord.cs +++ b/main/HSSF/Record/DBCellRecord.cs @@ -38,7 +38,7 @@ public class DBCellRecord : StandardRecord, ICloneable public DBCellRecord() { - field_2_cell_offsets = new short[0]; + field_2_cell_offsets = Array.Empty(); } /** diff --git a/main/HSSF/Record/Drawing/OfficeArtFOPT.cs b/main/HSSF/Record/Drawing/OfficeArtFOPT.cs index 9b9ce2e27..11bdb4d58 100644 --- a/main/HSSF/Record/Drawing/OfficeArtFOPT.cs +++ b/main/HSSF/Record/Drawing/OfficeArtFOPT.cs @@ -10,7 +10,7 @@ public class OfficeArtFOPT private OfficeArtRecordHeader _rh; private List _fopt; private Dictionary dictOptions = new Dictionary(); - //private byte[] complexData = new byte[0]; + //private byte[] complexData = Array.Empty(); public OfficeArtFOPT(RecordInputStream ris) { diff --git a/main/HSSF/Record/Drawing/OfficeArtFOPTE.cs b/main/HSSF/Record/Drawing/OfficeArtFOPTE.cs index 8e2066799..dd106fcc9 100644 --- a/main/HSSF/Record/Drawing/OfficeArtFOPTE.cs +++ b/main/HSSF/Record/Drawing/OfficeArtFOPTE.cs @@ -10,7 +10,7 @@ public class OfficeArtFOPTE { //private OfficeArtFOPTEOPID field_1_opid; //private int field_2_op; - private byte[] complexData = new byte[0]; + private byte[] complexData = Array.Empty(); public OfficeArtFOPTE(RecordInputStream ris) { diff --git a/main/HSSF/Record/ExtSSTRecord.cs b/main/HSSF/Record/ExtSSTRecord.cs index a49f0ec6f..c6cbb3111 100644 --- a/main/HSSF/Record/ExtSSTRecord.cs +++ b/main/HSSF/Record/ExtSSTRecord.cs @@ -53,7 +53,7 @@ public class ExtSSTRecord : ContinuableRecord public ExtSSTRecord() { - _sstInfos = new InfoSubRecord[0]; + _sstInfos = Array.Empty(); } /** diff --git a/main/HSSF/Record/RecordInputStream.cs b/main/HSSF/Record/RecordInputStream.cs index 02c36d912..bf6b67542 100644 --- a/main/HSSF/Record/RecordInputStream.cs +++ b/main/HSSF/Record/RecordInputStream.cs @@ -526,7 +526,7 @@ public byte[] ReadRemainder() int size = Remaining; if (size == 0) { - return new byte[0]; + return Array.Empty(); } byte[] result = new byte[size]; ReadFully(result); diff --git a/main/HSSF/UserModel/HSSFPolygon.cs b/main/HSSF/UserModel/HSSFPolygon.cs index e5095cebe..4121642c1 100644 --- a/main/HSSF/UserModel/HSSFPolygon.cs +++ b/main/HSSF/UserModel/HSSFPolygon.cs @@ -191,7 +191,7 @@ public void SetPoints(int[] xPoints, int[] yPoints) { logger.Log(POILogger.ERROR, "HSSFPolygon must have at least one point"); } - EscherArrayProperty verticesProp = new EscherArrayProperty(EscherProperties.GEOMETRY__VERTICES, false, new byte[0]); + EscherArrayProperty verticesProp = new EscherArrayProperty(EscherProperties.GEOMETRY__VERTICES, false, System.Array.Empty()); verticesProp.NumberOfElementsInArray = (xPoints.Length + 1); verticesProp.NumberOfElementsInMemory = (xPoints.Length + 1); verticesProp.SizeOfElements = unchecked((short)(0xFFF0)); diff --git a/main/POIFS/Crypt/Standard/StandardDecryptor.cs b/main/POIFS/Crypt/Standard/StandardDecryptor.cs index bcd4434df..cc39afcef 100644 --- a/main/POIFS/Crypt/Standard/StandardDecryptor.cs +++ b/main/POIFS/Crypt/Standard/StandardDecryptor.cs @@ -317,17 +317,17 @@ public string AlgorithmName public byte[] DoFinal() { - return new byte[0]; + return Array.Empty(); } public byte[] DoFinal(byte[] input) { - return new byte[0]; + return Array.Empty(); } public byte[] DoFinal(byte[] input, int inOff, int length) { - return new byte[0]; + return Array.Empty(); } public int DoFinal(byte[] output, int outOff) @@ -367,7 +367,7 @@ public void Init(bool forEncryption, ICipherParameters parameters) public byte[] ProcessByte(byte input) { - return new byte[0]; + return Array.Empty(); } public int ProcessByte(byte input, byte[] output, int outOff) @@ -377,12 +377,12 @@ public int ProcessByte(byte input, byte[] output, int outOff) public byte[] ProcessBytes(byte[] input) { - return new byte[0]; + return Array.Empty(); } public byte[] ProcessBytes(byte[] input, int inOff, int length) { - return new byte[0]; + return Array.Empty(); } public int ProcessBytes(byte[] input, byte[] output, int outOff) diff --git a/main/POIFS/FileSystem/DirectoryNode.cs b/main/POIFS/FileSystem/DirectoryNode.cs index e64ba8cc6..7bf9cbf91 100644 --- a/main/POIFS/FileSystem/DirectoryNode.cs +++ b/main/POIFS/FileSystem/DirectoryNode.cs @@ -554,7 +554,7 @@ public Object[] ViewableArray { get { - return new Object[0]; + return Array.Empty(); } } diff --git a/main/POIFS/FileSystem/DocumentNode.cs b/main/POIFS/FileSystem/DocumentNode.cs index 46ac43984..aafa6a23b 100644 --- a/main/POIFS/FileSystem/DocumentNode.cs +++ b/main/POIFS/FileSystem/DocumentNode.cs @@ -105,7 +105,7 @@ protected override bool IsDeleteOK public Object[] ViewableArray { - get { return new Object[0]; } + get { return Array.Empty(); } } /** diff --git a/main/POIFS/FileSystem/NDocumentOutputStream.cs b/main/POIFS/FileSystem/NDocumentOutputStream.cs index e718d1125..848d93974 100644 --- a/main/POIFS/FileSystem/NDocumentOutputStream.cs +++ b/main/POIFS/FileSystem/NDocumentOutputStream.cs @@ -84,7 +84,7 @@ public NDocumentOutputStream(DirectoryEntry parent, String name) _closed = false; // Have an empty one Created for now - DocumentEntry doc = parent.CreateDocument(name, new MemoryStream(new byte[0])); + DocumentEntry doc = parent.CreateDocument(name, new MemoryStream(Array.Empty())); _property = (DocumentProperty)((DocumentNode)doc).Property; _document = new NPOIFSDocument((DocumentNode)doc); } diff --git a/main/POIFS/FileSystem/NPOIFSFileSystem.cs b/main/POIFS/FileSystem/NPOIFSFileSystem.cs index 00bbaf725..8fb870ca8 100644 --- a/main/POIFS/FileSystem/NPOIFSFileSystem.cs +++ b/main/POIFS/FileSystem/NPOIFSFileSystem.cs @@ -954,7 +954,7 @@ protected Object[] GetViewableArray() return rval; } - return new Object[0]; + return Array.Empty(); } /** diff --git a/main/POIFS/FileSystem/OPOIFSDocument.cs b/main/POIFS/FileSystem/OPOIFSDocument.cs index 33baa3402..aad67815f 100644 --- a/main/POIFS/FileSystem/OPOIFSDocument.cs +++ b/main/POIFS/FileSystem/OPOIFSDocument.cs @@ -153,7 +153,7 @@ public OPOIFSDocument(string name, POIFSBigBlockSize bigBlockSize, Stream stream if (_property.ShouldUseSmallBlocks) { _small_store = new SmallBlockStore(bigBlockSize, SmallDocumentBlock.Convert(bigBlockSize, bigBlocks, _size)); - _big_store = new BigBlockStore(bigBlockSize, new DocumentBlock[0]); + _big_store = new BigBlockStore(bigBlockSize, Array.Empty()); } else { @@ -475,7 +475,7 @@ internal SmallBlockStore(POIFSBigBlockSize bigBlockSize, SmallDocumentBlock[] bl internal SmallBlockStore(POIFSBigBlockSize bigBlockSize, POIFSDocumentPath path, string name, int size, POIFSWriterListener writer) { this.bigBlockSize = bigBlockSize; - this.smallBlocks = new SmallDocumentBlock[0]; + this.smallBlocks = Array.Empty(); this.path = path; this.name = name; this.size = size; @@ -532,7 +532,7 @@ internal BigBlockStore(POIFSBigBlockSize bigBlockSize, DocumentBlock[] blocks) internal BigBlockStore(POIFSBigBlockSize bigBlockSize, POIFSDocumentPath path, string name, int size, POIFSWriterListener writer) { this.bigBlockSize = bigBlockSize; - this.bigBlocks = new DocumentBlock[0]; + this.bigBlocks = Array.Empty(); this.path = path; this.name = name; this.size = size; diff --git a/main/POIFS/FileSystem/OPOIFSFileSystem.cs b/main/POIFS/FileSystem/OPOIFSFileSystem.cs index 389dee369..3012e364f 100644 --- a/main/POIFS/FileSystem/OPOIFSFileSystem.cs +++ b/main/POIFS/FileSystem/OPOIFSFileSystem.cs @@ -480,7 +480,7 @@ public Object[] ViewableArray } else { - return new Object[0]; + return Array.Empty(); } } } diff --git a/main/POIFS/FileSystem/POIFSDocumentPath.cs b/main/POIFS/FileSystem/POIFSDocumentPath.cs index a593cb108..24821cc62 100644 --- a/main/POIFS/FileSystem/POIFSDocumentPath.cs +++ b/main/POIFS/FileSystem/POIFSDocumentPath.cs @@ -49,7 +49,7 @@ public class POIFSDocumentPath /// public POIFSDocumentPath() { - this.components = new string[0]; + this.components = Array.Empty(); } /// /// constructor for the path of a document that is not in the root @@ -71,7 +71,7 @@ public POIFSDocumentPath(string[] components) { if (components == null) { - this.components = new string[0]; + this.components = Array.Empty(); } else { diff --git a/main/POIFS/Storage/HeaderBlockWriter.cs b/main/POIFS/Storage/HeaderBlockWriter.cs index 4fe1e433f..762baa24e 100644 --- a/main/POIFS/Storage/HeaderBlockWriter.cs +++ b/main/POIFS/Storage/HeaderBlockWriter.cs @@ -92,7 +92,7 @@ public BATBlock[] SetBATBlocks(int blockCount, int startBlock) } else { - rvalue = BATBlock.CreateXBATBlocks(bigBlockSize, new int[0], 0); + rvalue = BATBlock.CreateXBATBlocks(bigBlockSize, Array.Empty(), 0); _header_block.XBATStart = POIFSConstants.END_OF_CHAIN; } diff --git a/main/SS/Formula/Atp/ArgumentsEvaluator.cs b/main/SS/Formula/Atp/ArgumentsEvaluator.cs index e534f8ddb..6e43b4c7d 100644 --- a/main/SS/Formula/Atp/ArgumentsEvaluator.cs +++ b/main/SS/Formula/Atp/ArgumentsEvaluator.cs @@ -76,7 +76,7 @@ public double[] EvaluateDatesArg(ValueEval arg, int srcCellRow, int srcCellCol) { if (arg == null) { - return new double[0]; + return Array.Empty(); } if (arg is StringEval) diff --git a/main/SS/Formula/CollaboratingWorkbooksEnvironment.cs b/main/SS/Formula/CollaboratingWorkbooksEnvironment.cs index 3c80d8611..fa313f232 100644 --- a/main/SS/Formula/CollaboratingWorkbooksEnvironment.cs +++ b/main/SS/Formula/CollaboratingWorkbooksEnvironment.cs @@ -50,7 +50,7 @@ public class CollaboratingWorkbooksEnvironment private CollaboratingWorkbooksEnvironment() { _evaluatorsByName = new Dictionary(); - _evaluators = new WorkbookEvaluator[0]; + _evaluators = Array.Empty(); } public static void Setup(String[] workbookNames, WorkbookEvaluator[] evaluators) { diff --git a/main/SS/Formula/Formula.cs b/main/SS/Formula/Formula.cs index 875245e1a..be1217afd 100644 --- a/main/SS/Formula/Formula.cs +++ b/main/SS/Formula/Formula.cs @@ -31,7 +31,7 @@ namespace NPOI.SS.Formula public class Formula { - private static readonly Formula EMPTY = new Formula(new byte[0], 0); + private static readonly Formula EMPTY = new Formula(System.Array.Empty(), 0); /** immutable */ private byte[] _byteEncoding; diff --git a/main/Util/BigInteger.cs b/main/Util/BigInteger.cs index 8aca88bd6..6e68fa479 100644 --- a/main/Util/BigInteger.cs +++ b/main/Util/BigInteger.cs @@ -400,7 +400,7 @@ public String ToString(int radix) * * @since 1.2 */ - public static readonly BigInteger ZERO = new BigInteger(new int[0], 0); + public static readonly BigInteger ZERO = new BigInteger(Array.Empty(), 0); /** * The BigInteger constant one. diff --git a/ooxml/XSSF/UserModel/Helpers/ColumnHelper.cs b/ooxml/XSSF/UserModel/Helpers/ColumnHelper.cs index 376ccf935..bf425fd6f 100644 --- a/ooxml/XSSF/UserModel/Helpers/ColumnHelper.cs +++ b/ooxml/XSSF/UserModel/Helpers/ColumnHelper.cs @@ -85,7 +85,7 @@ public CT_Cols AddCleanColIntoCols(CT_Cols cols, CT_Col newCol) new TreeSet(CTColComparator.BY_MIN_MAX); trackedCols.AddAll(cols.GetColList()); AddCleanColIntoCols(cols, newCol, trackedCols); - cols.SetColArray(trackedCols.ToArray(new CT_Col[0])); + cols.SetColArray(trackedCols.ToArray(Array.Empty())); return cols; } diff --git a/ooxml/XSSF/UserModel/XSSFFactory.cs b/ooxml/XSSF/UserModel/XSSFFactory.cs index 02d963f6c..3bc066cb4 100644 --- a/ooxml/XSSF/UserModel/XSSFFactory.cs +++ b/ooxml/XSSF/UserModel/XSSFFactory.cs @@ -58,7 +58,7 @@ protected override POIXMLDocumentPart CreateDocumentPart(Type cls, Type[] classe { if (classes == null) { - classes = new Type[0]; + classes = Array.Empty(); } ConstructorInfo constructor = cls.GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public, @@ -67,7 +67,7 @@ protected override POIXMLDocumentPart CreateDocumentPart(Type cls, Type[] classe throw new MissingMethodException(); if (values == null) { - values = new object[0]; + values = Array.Empty(); } return constructor.Invoke(values) as POIXMLDocumentPart; } diff --git a/ooxml/XSSF/UserModel/XSSFSheet.cs b/ooxml/XSSF/UserModel/XSSFSheet.cs index b4232c7a5..aeb232bd9 100644 --- a/ooxml/XSSF/UserModel/XSSFSheet.cs +++ b/ooxml/XSSF/UserModel/XSSFSheet.cs @@ -129,7 +129,7 @@ public int[] ColumnBreaks { if (!worksheet.IsSetColBreaks() || worksheet.colBreaks.sizeOfBrkArray() == 0) { - return new int[0]; + return Array.Empty(); } List brkArray = worksheet.colBreaks.brk; @@ -590,7 +590,7 @@ public int[] RowBreaks { if (!worksheet.IsSetRowBreaks() || worksheet.rowBreaks.sizeOfBrkArray() == 0) { - return new int[0]; + return Array.Empty(); } List brkArray = worksheet.rowBreaks.brk; @@ -1514,7 +1514,7 @@ CT_Hyperlink[] ctHls // For some reason, we have to remove the hyperlinks one by one from the CTHyperlinks array // before unsetting the hyperlink array. // Resetting the hyperlink array seems to break some XML nodes. - //worksheet.getHyperlinks().setHyperlinkArray(new CTHyperlink[0]); + //worksheet.getHyperlinks().setHyperlinkArray(Array.Empty()); worksheet.UnsetHyperlinks(); } else diff --git a/ooxml/XWPF/Usermodel/XWPFFactory.cs b/ooxml/XWPF/Usermodel/XWPFFactory.cs index 5c116197d..f4566bf10 100644 --- a/ooxml/XWPF/Usermodel/XWPFFactory.cs +++ b/ooxml/XWPF/Usermodel/XWPFFactory.cs @@ -57,7 +57,7 @@ protected override POIXMLDocumentPart CreateDocumentPart(Type cls, Type[] classe { if (classes == null) { - classes = new Type[0]; + classes = Array.Empty(); } ConstructorInfo constructor = cls.GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public, null, classes, null); @@ -65,7 +65,7 @@ protected override POIXMLDocumentPart CreateDocumentPart(Type cls, Type[] classe throw new MissingMethodException(); if (values == null) { - values = new object[0]; + values = Array.Empty(); } return constructor.Invoke(values) as POIXMLDocumentPart; } diff --git a/openxml4Net/OPC/Internal/ContentType.cs b/openxml4Net/OPC/Internal/ContentType.cs index ad5971c24..17beb64c9 100644 --- a/openxml4Net/OPC/Internal/ContentType.cs +++ b/openxml4Net/OPC/Internal/ContentType.cs @@ -257,7 +257,7 @@ public bool HasParameters() public String[] GetParameterKeys() { if (parameters == null) - return new String[0]; + return Array.Empty(); List keys = new List(); keys.AddRange(parameters.Keys); return keys.ToArray(); diff --git a/scratchpad/HSLF/Model/Polygon.cs b/scratchpad/HSLF/Model/Polygon.cs index b0d712466..6ecf02f7f 100644 --- a/scratchpad/HSLF/Model/Polygon.cs +++ b/scratchpad/HSLF/Model/Polygon.cs @@ -82,7 +82,7 @@ public void SetPoints(float[] xPoints, float[] yPoints) int numpoints = xPoints.Length; - EscherArrayProperty verticesProp = new EscherArrayProperty(EscherProperties.GEOMETRY__VERTICES, false, new byte[0] ); + EscherArrayProperty verticesProp = new EscherArrayProperty(EscherProperties.GEOMETRY__VERTICES, false, Array.Empty() ); verticesProp.SetNumberOfElementsInArray(numpoints+1); verticesProp.SetNumberOfElementsInMemory(numpoints+1); verticesProp.SetSizeOfElements(0xFFF0); diff --git a/scratchpad/HSLF/Model/Slide.cs b/scratchpad/HSLF/Model/Slide.cs index 0219c29e9..a0be12204 100644 --- a/scratchpad/HSLF/Model/Slide.cs +++ b/scratchpad/HSLF/Model/Slide.cs @@ -414,7 +414,7 @@ public Comment[] GetComments() { } // None found - return new Comment[0]; + return Array.Empty(); } public void Draw(Graphics2D graphics){ diff --git a/scratchpad/HSLF/Record/CString.cs b/scratchpad/HSLF/Record/CString.cs index e00014e39..289158cce 100644 --- a/scratchpad/HSLF/Record/CString.cs +++ b/scratchpad/HSLF/Record/CString.cs @@ -96,7 +96,7 @@ public CString() // 0 length header _header = new byte[] { 0, 0, unchecked((byte)(0xBA - 256)), 0x0f, 0, 0, 0, 0 }; // Empty text - _text = new byte[0]; + _text = Array.Empty(); } /** diff --git a/scratchpad/HSLF/Record/SoundData.cs b/scratchpad/HSLF/Record/SoundData.cs index 7ea657992..9a6eb84a4 100644 --- a/scratchpad/HSLF/Record/SoundData.cs +++ b/scratchpad/HSLF/Record/SoundData.cs @@ -46,7 +46,7 @@ public class SoundData : RecordAtom protected SoundData() { _header = new byte[8]; - _data = new byte[0]; + _data = Array.Empty(); LittleEndian.PutShort(_header, 2, (short)RecordType); LittleEndian.PutInt(_header, 4, _data.Length); diff --git a/scratchpad/HSLF/Record/StyleTextPropAtom.cs b/scratchpad/HSLF/Record/StyleTextPropAtom.cs index 9246f78ad..f5fd33284 100644 --- a/scratchpad/HSLF/Record/StyleTextPropAtom.cs +++ b/scratchpad/HSLF/Record/StyleTextPropAtom.cs @@ -195,7 +195,7 @@ public StyleTextPropAtom(byte[] source, int start, int len) // decode them (via a call to SetParentTextSize(int) rawContents = new byte[len - 8]; Array.Copy(source, start + 8, rawContents, 0, rawContents.Length); - reserved = new byte[0]; + reserved = Array.Empty(); // Set empty linked lists, Ready for when they call SetParentTextSize paragraphStyles = new List(); @@ -209,8 +209,8 @@ public StyleTextPropAtom(byte[] source, int start, int len) public StyleTextPropAtom(int parentTextSize) { _header = new byte[8]; - rawContents = new byte[0]; - reserved = new byte[0]; + rawContents = Array.Empty(); + reserved = Array.Empty(); // Set our type LittleEndian.PutInt(_header, 2, (short)_type); @@ -398,7 +398,7 @@ private void updateRawContents() public void SetRawContents(byte[] bytes) { rawContents = bytes; - reserved = new byte[0]; + reserved = Array.Empty(); Initialised = false; } diff --git a/scratchpad/HSLF/Record/TextCharsAtom.cs b/scratchpad/HSLF/Record/TextCharsAtom.cs index 2ca5a6236..ab8365735 100644 --- a/scratchpad/HSLF/Record/TextCharsAtom.cs +++ b/scratchpad/HSLF/Record/TextCharsAtom.cs @@ -80,7 +80,7 @@ public TextCharsAtom() // 0 length header _header = new byte[] { 0, 0, unchecked((byte)(0xA0 - 256)), 0x0f, 0, 0, 0, 0 }; // Empty text - _text = new byte[0]; + _text = Array.Empty(); } /** diff --git a/scratchpad/HSLF/Record/TextRulerAtom.cs b/scratchpad/HSLF/Record/TextRulerAtom.cs index 74a860f1b..d40c4544d 100644 --- a/scratchpad/HSLF/Record/TextRulerAtom.cs +++ b/scratchpad/HSLF/Record/TextRulerAtom.cs @@ -52,7 +52,7 @@ public class TextRulerAtom : RecordAtom public TextRulerAtom() { _header = new byte[8]; - _data = new byte[0]; + _data = Array.Empty(); LittleEndian.PutShort(_header, 2, (short)RecordType); LittleEndian.PutInt(_header, 4, _data.Length); diff --git a/scratchpad/HWPF/HWPFDocument.cs b/scratchpad/HWPF/HWPFDocument.cs index a65e9aafc..763453315 100644 --- a/scratchpad/HWPF/HWPFDocument.cs +++ b/scratchpad/HWPF/HWPFDocument.cs @@ -225,7 +225,7 @@ public HWPFDocument(DirectoryNode directory) } catch (FileNotFoundException) { - _dataStream = new byte[0]; + _dataStream = Array.Empty(); } // Get the cp of the start of text in the main stream diff --git a/scratchpad/HWPF/Model/BookmarksTables.cs b/scratchpad/HWPF/Model/BookmarksTables.cs index 7715b2356..a82cb7977 100644 --- a/scratchpad/HWPF/Model/BookmarksTables.cs +++ b/scratchpad/HWPF/Model/BookmarksTables.cs @@ -27,7 +27,7 @@ public class BookmarksTables private PlexOfCps descriptorsLim = new PlexOfCps(0); - private String[] names = new String[0]; + private String[] names = Array.Empty(); public BookmarksTables(byte[] tableStream, FileInformationBlock fib) { diff --git a/scratchpad/HWPF/Model/CHPFormattedDiskPage.cs b/scratchpad/HWPF/Model/CHPFormattedDiskPage.cs index daf8a4b9b..230dd123f 100644 --- a/scratchpad/HWPF/Model/CHPFormattedDiskPage.cs +++ b/scratchpad/HWPF/Model/CHPFormattedDiskPage.cs @@ -113,7 +113,7 @@ protected override byte[] GetGrpprl(int index) //optimization if offset == 0 use "Normal" style if (chpxOffset == 0) { - return new byte[0]; + return Array.Empty(); } int size = LittleEndian.GetUByte(_fkp, _offset + chpxOffset); diff --git a/scratchpad/HWPF/Model/ListFormatOverride.cs b/scratchpad/HWPF/Model/ListFormatOverride.cs index f5b7d7e41..b6f7fa427 100644 --- a/scratchpad/HWPF/Model/ListFormatOverride.cs +++ b/scratchpad/HWPF/Model/ListFormatOverride.cs @@ -32,7 +32,7 @@ public class ListFormatOverride public ListFormatOverride(int lsid) { _lsid = lsid; - _levelOverrides = new ListFormatOverrideLevel[0]; + _levelOverrides = Array.Empty(); } public ListFormatOverride(byte[] buf, int offset) diff --git a/scratchpad/HWPF/Model/ListLevel.cs b/scratchpad/HWPF/Model/ListLevel.cs index b00140b07..06ac1a8fa 100644 --- a/scratchpad/HWPF/Model/ListLevel.cs +++ b/scratchpad/HWPF/Model/ListLevel.cs @@ -62,9 +62,9 @@ public ListLevel(int startAt, int numberFormatCode, int alignment, public ListLevel(int level, bool numbered) { _iStartAt = 1; - _grpprlPapx = new byte[0]; - _grpprlChpx = new byte[0]; - _numberText = new char[0]; + _grpprlPapx = Array.Empty(); + _grpprlChpx = Array.Empty(); + _numberText = Array.Empty(); _rgbxchNums = new byte[RGBXCH_NUMS_SIZE]; if (numbered) diff --git a/scratchpad/HWPF/Model/NotesTables.cs b/scratchpad/HWPF/Model/NotesTables.cs index 88b884a24..8292703ea 100644 --- a/scratchpad/HWPF/Model/NotesTables.cs +++ b/scratchpad/HWPF/Model/NotesTables.cs @@ -39,7 +39,7 @@ public NotesTables(NoteType noteType) { this.noteType = noteType; textPositions - .AddProperty(new GenericPropertyNode(0, 1, new byte[0])); + .AddProperty(new GenericPropertyNode(0, 1, Array.Empty())); } public NotesTables(NoteType noteType, byte[] tableStream, diff --git a/scratchpad/HWPF/Model/OldSectionTable.cs b/scratchpad/HWPF/Model/OldSectionTable.cs index bc6a26ba7..e94b497d7 100644 --- a/scratchpad/HWPF/Model/OldSectionTable.cs +++ b/scratchpad/HWPF/Model/OldSectionTable.cs @@ -57,7 +57,7 @@ public OldSectionTable(byte[] documentStream, int offset, int size) // check for the optimization if (fileOffset == unchecked((int)0xffffffff)) { - sepx = new SEPX(sed, startAt, endAt, new byte[0]); + sepx = new SEPX(sed, startAt, endAt, Array.Empty()); } else { diff --git a/scratchpad/HWPF/Model/PAPFormattedDiskPage.cs b/scratchpad/HWPF/Model/PAPFormattedDiskPage.cs index 553b1384b..3e9fe2552 100644 --- a/scratchpad/HWPF/Model/PAPFormattedDiskPage.cs +++ b/scratchpad/HWPF/Model/PAPFormattedDiskPage.cs @@ -162,7 +162,7 @@ internal byte[] ToByteArray(HWPFStream dataStream, int grpprlOffset = 0; int bxOffset = 0; int fcOffset = 0; - byte[] lastGrpprl = new byte[0]; + byte[] lastGrpprl = Array.Empty(); // total size is currently the size of one FC int totalSize = FC_SIZE; @@ -227,7 +227,7 @@ internal byte[] ToByteArray(HWPFStream dataStream, grpprlOffset = 511; PAPX papx = null; - lastGrpprl = new byte[0]; + lastGrpprl = Array.Empty(); for (int x = 0; x < index; x++) { papx = _papxList[x]; diff --git a/scratchpad/HWPF/Model/PlexOfCps.cs b/scratchpad/HWPF/Model/PlexOfCps.cs index 73ac36216..74828ae19 100644 --- a/scratchpad/HWPF/Model/PlexOfCps.cs +++ b/scratchpad/HWPF/Model/PlexOfCps.cs @@ -136,7 +136,7 @@ public int Length internal GenericPropertyNode[] ToPropertiesArray() { if (_props == null || _props.Count==0) - return new GenericPropertyNode[0]; + return Array.Empty(); return (GenericPropertyNode[])_props.ToArray(typeof(GenericPropertyNode)); } diff --git a/scratchpad/HWPF/Model/SectionTable.cs b/scratchpad/HWPF/Model/SectionTable.cs index 9bf0cea4f..9d4bafe18 100644 --- a/scratchpad/HWPF/Model/SectionTable.cs +++ b/scratchpad/HWPF/Model/SectionTable.cs @@ -66,7 +66,7 @@ public SectionTable(byte[] documentStream, byte[] tableStream, int OffSet, // check for the optimization if (fileOffset == unchecked((int)0xffffffff)) { - _sections.Add(new SEPX(sed, startAt, endAt, new byte[0])); + _sections.Add(new SEPX(sed, startAt, endAt, Array.Empty())); } else { diff --git a/scratchpad/HWPF/Model/Types/PAPAbstractType.cs b/scratchpad/HWPF/Model/Types/PAPAbstractType.cs index 1f8f7bde8..1371f55cd 100644 --- a/scratchpad/HWPF/Model/Types/PAPAbstractType.cs +++ b/scratchpad/HWPF/Model/Types/PAPAbstractType.cs @@ -160,13 +160,13 @@ protected PAPAbstractType() this.field_65_brcBetween = new BorderCode(); this.field_66_brcBar = new BorderCode(); this.field_67_shd = new ShadingDescriptor(); - this.field_68_anld = new byte[0]; - this.field_69_phe = new byte[0]; + this.field_68_anld = Array.Empty(); + this.field_69_phe = Array.Empty(); this.field_72_dttmPropRMark = new DateAndTime(); - this.field_74_rgdxaTab = new int[0]; - this.field_75_rgtbd = new byte[0]; - this.field_76_numrm = new byte[0]; - this.field_77_ptap = new byte[0]; + this.field_74_rgdxaTab = Array.Empty(); + this.field_75_rgtbd = Array.Empty(); + this.field_76_numrm = Array.Empty(); + this.field_77_ptap = Array.Empty(); } diff --git a/scratchpad/HWPF/UserModel/PictureType.cs b/scratchpad/HWPF/UserModel/PictureType.cs index ebc4b6f27..6e11ad908 100644 --- a/scratchpad/HWPF/UserModel/PictureType.cs +++ b/scratchpad/HWPF/UserModel/PictureType.cs @@ -34,7 +34,7 @@ public class PictureType public static PictureType JPEG = new PictureType("image/jpeg", "jpg", new byte[][] { new byte[] { (byte)0xFF, (byte)0xD8 } }); - public static PictureType PICT = new PictureType("image/pict", ".pict", new byte[0][]); + public static PictureType PICT = new PictureType("image/pict", ".pict", Array.Empty()[]); public static PictureType PNG = new PictureType("image/png", "png", new byte[][] { new byte[]{ (byte) 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A } });