From d50e141958b75154bf6739b5bead38c0bec130d8 Mon Sep 17 00:00:00 2001 From: Marko Lahma Date: Thu, 6 Mar 2025 14:02:58 +0200 Subject: [PATCH] Add readonly modifier for suitable fields --- main/DDF/DefaultEscherRecordFactory.cs | 4 +- main/DDF/EscherContainerRecord.cs | 4 +- main/HPSF/Array.cs | 2 +- main/HPSF/Blob.cs | 2 +- main/HPSF/ClipboardData.cs | 4 +- main/HPSF/Filetime.cs | 4 +- main/HPSF/IndirectPropertyName.cs | 2 +- main/HPSF/UnicodeString.cs | 2 +- main/HPSF/Vector.cs | 2 +- main/HPSF/VersionedStream.cs | 2 +- main/HSSF/EventModel/EventRecordFactory.cs | 4 +- main/HSSF/Extractor/ExcelExtractor.cs | 4 +- main/HSSF/Model/InternalSheet.cs | 6 +- main/HSSF/Model/LinkTable.cs | 14 ++-- main/HSSF/Model/ParseNode.cs | 10 +-- main/HSSF/Model/RecordStream.cs | 4 +- main/HSSF/Model/RowBlocksReader.cs | 6 +- .../Aggregates/Chart/ChartSheetAggregate.cs | 10 +-- .../ChartSubstreamRecordAggregate.cs | 6 +- .../Aggregates/ConditionalFormattingTable.cs | 2 +- .../CustomViewSettingsRecordAggregate.cs | 8 +-- .../Record/Aggregates/DataValidityTable.cs | 4 +- .../Record/Aggregates/MergedCellsTable.cs | 2 +- main/HSSF/Record/Aggregates/PLSAggregate.cs | 6 +- .../Record/Aggregates/PageSettingsBlock.cs | 12 ++-- .../HSSF/Record/Aggregates/RecordAggregate.cs | 6 +- .../Record/Aggregates/RowRecordsAggregate.cs | 10 +-- .../Record/Aggregates/SharedValueManager.cs | 6 +- main/HSSF/Record/ArrayRecord.cs | 2 +- main/HSSF/Record/CF/FontFormatting.cs | 18 ++--- main/HSSF/Record/Common/UnicodeString.cs | 8 +-- .../Record/Cont/ContinuableRecordInput.cs | 2 +- .../Record/Cont/ContinuableRecordOutput.cs | 4 +- .../Record/Cont/UnknownLengthRecordOutput.cs | 6 +- .../Record/Crypto/Biff8DecryptingStream.cs | 4 +- main/HSSF/Record/Crypto/Biff8EncryptionKey.cs | 2 +- main/HSSF/Record/Crypto/Biff8RC4.cs | 2 +- main/HSSF/Record/Crypto/RC4.cs | 2 +- main/HSSF/Record/DConRefRecord.cs | 32 +++++++-- main/HSSF/Record/DSFRecord.cs | 4 +- main/HSSF/Record/DVRecord.cs | 32 ++++----- main/HSSF/Record/Drawing/OfficeArtFOPT.cs | 6 +- main/HSSF/Record/EscherAggregate.cs | 10 +-- main/HSSF/Record/ExtendedFormatRecord.cs | 68 +++++++++---------- main/HSSF/Record/ExternSheetRecord.cs | 4 +- main/HSSF/Record/ExternalNameRecord.cs | 10 +-- main/HSSF/Record/FilePassRecord.cs | 4 +- main/HSSF/Record/FormulaRecord.cs | 2 +- main/HSSF/Record/HeaderFooterRecord.cs | 4 +- main/HSSF/Record/InterfaceHdrRecord.cs | 2 +- main/HSSF/Record/LbsDataSubRecord.cs | 20 +++--- main/HSSF/Record/MergeCellsRecord.cs | 6 +- main/HSSF/Record/MulBlankRecord.cs | 8 +-- main/HSSF/Record/ObjRecord.cs | 6 +- main/HSSF/Record/PageBreakRecord.cs | 4 +- main/HSSF/Record/PivotTable/PageItemRecord.cs | 8 +-- .../Record/PivotTable/ViewFieldsRecord.cs | 10 +-- main/HSSF/Record/RecalcIdRecord.cs | 2 +- main/HSSF/Record/RecordFactory.cs | 10 +-- main/HSSF/Record/RecordFactoryInputStream.cs | 10 +-- main/HSSF/Record/RecordInputStream.cs | 6 +- main/HSSF/Record/RowDataRecord.cs | 2 +- main/HSSF/Record/SSTSerializer.cs | 10 +-- main/HSSF/Record/SharedValueRecordBase.cs | 2 +- main/HSSF/Record/SubRecord/SubRecord.cs | 4 +- main/HSSF/Record/SupBookRecord.cs | 6 +- main/HSSF/Record/UncalcedRecord.cs | 2 +- main/HSSF/Record/UnknownRecord.cs | 4 +- main/HSSF/Record/UseSelFSRecord.cs | 4 +- main/HSSF/Record/UserSViewBegin.cs | 2 +- main/HSSF/Record/UserSViewEnd.cs | 2 +- main/HSSF/UserModel/DVConstraint.cs | 6 +- .../HSSF/UserModel/EvaluationCycleDetector.cs | 10 +-- main/HSSF/UserModel/HSSFCellStyle.cs | 6 +- main/HSSF/UserModel/HSSFDataValidation.cs | 4 +- main/HSSF/UserModel/HSSFEvaluationCell.cs | 4 +- main/HSSF/UserModel/HSSFEvaluationSheet.cs | 2 +- main/HSSF/UserModel/HSSFEvaluationWorkbook.cs | 8 +-- main/HSSF/UserModel/HSSFFooter.cs | 2 +- main/HSSF/UserModel/HSSFHeader.cs | 2 +- main/HSSF/UserModel/HSSFName.cs | 6 +- main/HSSF/UserModel/HSSFObjectData.cs | 2 +- main/HSSF/UserModel/HSSFPatriarch.cs | 10 +-- main/HSSF/UserModel/HSSFShapeGroup.cs | 4 +- main/HSSF/UserModel/HSSFSheet.cs | 4 +- .../HSSFSheetConditionalFormatting.cs | 4 +- main/HSSF/UserModel/HSSFWorkbook.cs | 2 +- main/HSSF/UserModel/HeaderFooter.cs | 32 ++++----- .../UserModel/OperationEvaluatorFactory.cs | 4 +- main/HSSF/Util/GUID.cs | 8 +-- main/HSSF/Util/HSSFColor.cs | 2 +- main/HSSF/Util/HSSFRegionUtil.cs | 6 +- main/POIFS/Crypt/ChunkedCipherOutputStream.cs | 8 +-- main/POIFS/Crypt/EncryptionInfo.cs | 14 ++-- .../FileSystem/CloseIgnoringInputStream.cs | 2 +- main/POIFS/FileSystem/DocumentNode.cs | 2 +- main/POIFS/FileSystem/DocumentOutputStream.cs | 4 +- .../POIFS/FileSystem/NDocumentOutputStream.cs | 4 +- main/POIFS/FileSystem/NPOIFSDocument.cs | 4 +- main/POIFS/FileSystem/NPOIFSFileSystem.cs | 6 +- main/POIFS/FileSystem/NPOIFSMiniStore.cs | 8 +-- main/POIFS/FileSystem/ODocumentInputStream.cs | 4 +- main/POIFS/FileSystem/OPOIFSDocument.cs | 34 +++++----- main/POIFS/FileSystem/POIFSDocumentReader.cs | 4 +- main/POIFS/Storage/BATBlock.cs | 18 ++--- .../Storage/BlockAllocationTableReader.cs | 6 +- .../Storage/BlockAllocationTableWriter.cs | 6 +- main/POIFS/Storage/DataInputBlock.cs | 4 +- main/POIFS/Storage/DocumentBlock.cs | 6 +- main/POIFS/Storage/HeaderBlockReader.cs | 14 ++-- main/POIFS/Storage/PropertyBlock.cs | 2 +- main/POIFS/Storage/RawDataBlock.cs | 8 +-- main/POIFS/Storage/SmallBlockTableWriter.cs | 8 +-- main/POIFS/Storage/SmallDocumentBlock.cs | 4 +- main/POIFS/property/DirectoryProperty.cs | 4 +- main/POIFS/property/NPropertyTable.cs | 2 +- main/POIFS/property/Property.cs | 24 +++---- main/POIFS/property/PropertyTable.cs | 2 +- main/SS/Format/CellDateFormatter.cs | 4 +- main/SS/Format/CellElapsedFormatter.cs | 14 ++-- main/SS/Format/CellFormat.cs | 14 ++-- main/SS/Format/CellFormatCondition.cs | 14 ++-- main/SS/Format/CellFormatPart.cs | 10 +-- main/SS/Formula/Atp/AnalysisToolPak.cs | 4 +- main/SS/Formula/Atp/ParityFunction.cs | 2 +- main/SS/Formula/Atp/RandBetween.cs | 2 +- main/SS/Formula/Atp/WorkdayCalculator.cs | 2 +- main/SS/Formula/Atp/XLookupFunction.cs | 4 +- main/SS/Formula/CacheAreaEval.cs | 2 +- main/SS/Formula/CellCacheEntry.cs | 2 +- main/SS/Formula/CellEvaluationFrame.cs | 4 +- .../CollaboratingWorkbooksEnvironment.cs | 4 +- main/SS/Formula/Constant/ErrorConstant.cs | 2 +- main/SS/Formula/Eval/AreaEvalBase.cs | 16 ++--- main/SS/Formula/Eval/ErrorEval.cs | 4 +- main/SS/Formula/Eval/ExternalNameEval.cs | 2 +- .../Eval/Forked/ForkedEvaluationCell.cs | 4 +- .../Eval/Forked/ForkedEvaluationSheet.cs | 8 +-- .../Eval/Forked/ForkedEvaluationWorkbook.cs | 4 +- .../SS/Formula/Eval/Forked/ForkedEvaluator.cs | 4 +- main/SS/Formula/Eval/FunctionNameEval.cs | 2 +- main/SS/Formula/Eval/NumberEval.cs | 2 +- main/SS/Formula/Eval/RefEvalBase.cs | 8 +-- .../TwoOperandNumericOperation.cs | 4 +- main/SS/Formula/EvaluationCache.cs | 13 ++-- .../EvaluationConditionalFormatRule.cs | 40 +++++------ main/SS/Formula/EvaluationTracker.cs | 6 +- main/SS/Formula/EvaluationWorkbook.cs | 12 ++-- main/SS/Formula/Formula.cs | 4 +- main/SS/Formula/FormulaCellCache.cs | 2 +- main/SS/Formula/FormulaParser.cs | 24 +++---- main/SS/Formula/FormulaType.cs | 2 +- main/SS/Formula/FormulaUsedBlankCellSet.cs | 14 ++-- .../Formula/Function/FunctionDataBuilder.cs | 6 +- main/SS/Formula/Function/FunctionMetadata.cs | 12 ++-- .../Function/FunctionMetadataRegistry.cs | 4 +- .../SS/Formula/Functions/AggregateFunction.cs | 8 +-- .../Functions/CalendarFieldFunction.cs | 2 +- main/SS/Formula/Functions/Count.cs | 8 +-- main/SS/Formula/Functions/Counta.cs | 8 +-- main/SS/Formula/Functions/Countif.cs | 18 ++--- main/SS/Formula/Functions/FactDouble.cs | 2 +- .../Functions/LinearRegressionFunction.cs | 12 ++-- main/SS/Formula/Functions/Lookup.cs | 2 +- main/SS/Formula/Functions/LookupUtils.cs | 42 ++++++------ main/SS/Formula/Functions/Match.cs | 2 +- .../Functions/MultiOperandNumericFunction.cs | 6 +- .../Functions/NotImplementedFunction.cs | 2 +- main/SS/Formula/Functions/Offset.cs | 16 ++--- main/SS/Formula/Functions/Text/LeftRight.cs | 4 +- main/SS/Formula/Functions/Text/SearchFind.cs | 2 +- .../SS/Formula/Functions/XYNumericFunction.cs | 16 ++--- main/SS/Formula/LazyAreaEval.cs | 2 +- main/SS/Formula/LazyRefEval.cs | 2 +- main/SS/Formula/NameIdentifier.cs | 4 +- main/SS/Formula/OperandClassTransformer.cs | 2 +- main/SS/Formula/OperationEvaluationContext.cs | 14 ++-- main/SS/Formula/OperationEvaluatorFactory.cs | 2 +- main/SS/Formula/PTG/AreaI.cs | 8 +-- main/SS/Formula/PTG/ArrayPtg.cs | 18 ++--- main/SS/Formula/PTG/AttrPtg.cs | 18 ++--- main/SS/Formula/ParseNode.cs | 10 +-- main/SS/Formula/PlainCellCache.cs | 6 +- main/SS/Formula/SharedFormula.cs | 4 +- main/SS/Formula/SheetRangeEvaluator.cs | 6 +- main/SS/Formula/SheetRefEvaluator.cs | 6 +- main/SS/Formula/Udf/AggregatingUDFFinder.cs | 2 +- main/SS/Formula/Udf/DefaultUDFFinder.cs | 2 +- main/SS/Formula/Udf/IndexedUDFFinder.cs | 2 +- main/SS/Formula/WorkbookEvaluator.cs | 14 ++-- main/SS/HtmlDocumentFacade.cs | 4 +- main/SS/SpreadsheetVersion.cs | 16 ++--- main/SS/UserModel/BorderStyle.cs | 2 +- main/SS/UserModel/BuiltinFormats.cs | 2 +- main/SS/UserModel/CellValue.cs | 10 +-- .../UserModel/Drawing/OfficeArtProperties.cs | 2 +- main/SS/UserModel/FontCharset.cs | 4 +- main/SS/UserModel/FontUnderline.cs | 4 +- main/SS/UserModel/FormulaError.cs | 14 ++-- main/SS/UserModel/IndexedColors.cs | 8 +-- main/SS/UserModel/PageOrder.cs | 4 +- main/SS/UserModel/PrintCellComments.cs | 4 +- main/SS/UserModel/PrintOrientation.cs | 4 +- main/SS/Util/AreaReference.cs | 10 +-- main/SS/Util/CellAddress.cs | 4 +- main/SS/Util/CellRangeAddressList.cs | 2 +- main/SS/Util/CellReference.cs | 12 ++-- main/SS/Util/DateFormatConverter.cs | 8 +-- main/SS/Util/ExpandedDouble.cs | 4 +- main/SS/Util/Format.cs | 14 ++-- main/SS/Util/MutableFPNumber.cs | 12 ++-- main/SS/Util/NormalisedDecimal.cs | 6 +- main/SS/Util/PropertyTemplate.cs | 2 +- main/SS/Util/RegionUtil.cs | 4 +- main/SS/Util/SSCellRange.cs | 12 ++-- main/Util/BigInteger.cs | 6 +- main/Util/ByteField.cs | 2 +- main/Util/CloseIgnoringInputStream.cs | 2 +- main/Util/Collections/Properties.cs | 2 +- main/Util/IntMapper.cs | 6 +- main/Util/IntegerField.cs | 2 +- main/Util/LittleEndianByteArrayInputStream.cs | 4 +- .../Util/LittleEndianByteArrayOutputStream.cs | 4 +- main/Util/LongField.cs | 2 +- main/Util/ObjectExtensions.cs | 2 +- main/Util/POILogFactory.cs | 4 +- main/Util/ShortField.cs | 2 +- main/Util/ULongField.cs | 2 +- ooxml/POIXMLDocumentPart.cs | 8 +-- ooxml/POIXMLRelation.cs | 8 +-- ooxml/POIXMLTextExtractor.cs | 2 +- ooxml/SS/Converter/ExcelToHtmlConverter.cs | 10 +-- ooxml/XSSF/Extractor/XSSFExportToXml.cs | 2 +- ooxml/XSSF/Model/ParagraphPropertyFetcher.cs | 2 +- ooxml/XSSF/Model/SharedStringsTable.cs | 4 +- ooxml/XSSF/Model/StylesTable.cs | 24 +++---- ooxml/XSSF/Streaming/AutoSizeColumnTracker.cs | 8 +-- ooxml/XSSF/Streaming/SXSSFCell.cs | 4 +- ooxml/XSSF/Streaming/SXSSFDrawing.cs | 4 +- ooxml/XSSF/Streaming/SXSSFEvaluationCell.cs | 4 +- ooxml/XSSF/Streaming/SXSSFEvaluationSheet.cs | 2 +- .../XSSF/Streaming/SXSSFEvaluationWorkbook.cs | 2 +- ooxml/XSSF/Streaming/SXSSFPicture.cs | 8 +-- ooxml/XSSF/Streaming/SXSSFRow.cs | 10 +-- ooxml/XSSF/Streaming/SXSSFSheet.cs | 8 +-- ooxml/XSSF/Streaming/SXSSFWorkbook.cs | 12 ++-- .../UserModel/BaseXSSFEvaluationWorkbook.cs | 8 +-- .../XSSF/UserModel/Extensions/XSSFCellFill.cs | 2 +- .../UserModel/Helpers/XSSFFormulaUtils.cs | 4 +- ooxml/XSSF/UserModel/XSSFBorderFormatting.cs | 2 +- ooxml/XSSF/UserModel/XSSFCell.cs | 12 ++-- ooxml/XSSF/UserModel/XSSFCellStyle.cs | 6 +- .../UserModel/XSSFColorScaleFormatting.cs | 2 +- ooxml/XSSF/UserModel/XSSFComment.cs | 6 +- .../XSSF/UserModel/XSSFConditionFilterData.cs | 2 +- .../UserModel/XSSFConditionalFormatting.cs | 4 +- .../XSSFConditionalFormattingRule.cs | 8 +-- ooxml/XSSF/UserModel/XSSFDataBarFormatting.cs | 2 +- ooxml/XSSF/UserModel/XSSFEvaluationCell.cs | 4 +- ooxml/XSSF/UserModel/XSSFEvaluationSheet.cs | 6 +- ooxml/XSSF/UserModel/XSSFFont.cs | 2 +- ooxml/XSSF/UserModel/XSSFFormulaEvaluator.cs | 2 +- ooxml/XSSF/UserModel/XSSFHyperlink.cs | 6 +- .../UserModel/XSSFIconMultiStateFormatting.cs | 2 +- ooxml/XSSF/UserModel/XSSFLineBreak.cs | 2 +- ooxml/XSSF/UserModel/XSSFName.cs | 4 +- ooxml/XSSF/UserModel/XSSFPatternFormatting.cs | 2 +- ooxml/XSSF/UserModel/XSSFRelation.cs | 2 +- .../XSSFSheetConditionalFormatting.cs | 2 +- ooxml/XSSF/UserModel/XSSFSimpleShape.cs | 8 +-- ooxml/XSSF/UserModel/XSSFTextParagraph.cs | 8 +-- ooxml/XSSF/UserModel/XSSFTextRun.cs | 4 +- ooxml/XSSF/UserModel/XSSFWorkbook.cs | 8 +-- ooxml/XSSF/UserModel/XSSFWorkbookType.cs | 4 +- ooxml/XSSF/Util/XmlEnumParser.cs | 2 +- ooxml/XWPF/Usermodel/XWPFDocument.cs | 2 +- ooxml/XWPF/Usermodel/XWPFRelation.cs | 2 +- .../OPC/Internal/ContentTypeManager.cs | 2 +- .../Internal/MemoryPackagePartOutputStream.cs | 4 +- openxml4Net/OPC/OPCPackage.cs | 4 +- openxml4Net/OPC/PackagePart.cs | 2 +- .../OPC/PackageRelationshipCollection.cs | 14 ++-- openxml4Net/OPC/ZipPackage.cs | 8 +-- 283 files changed, 952 insertions(+), 929 deletions(-) diff --git a/main/DDF/DefaultEscherRecordFactory.cs b/main/DDF/DefaultEscherRecordFactory.cs index dfce54d46..9c4a4750a 100644 --- a/main/DDF/DefaultEscherRecordFactory.cs +++ b/main/DDF/DefaultEscherRecordFactory.cs @@ -30,7 +30,7 @@ namespace NPOI.DDF /// public class DefaultEscherRecordFactory : IEscherRecordFactory { - private static Type[] escherRecordClasses = { + private static readonly Type[] escherRecordClasses = { typeof(EscherBSERecord), typeof(EscherOptRecord), typeof(EscherTertiaryOptRecord), typeof(EscherClientAnchorRecord), @@ -38,7 +38,7 @@ public class DefaultEscherRecordFactory : IEscherRecordFactory typeof(EscherClientDataRecord), typeof(EscherDggRecord), typeof(EscherSplitMenuColorsRecord), typeof(EscherChildAnchorRecord), typeof(EscherTextboxRecord) }; - private static Dictionary recordsMap = RecordsToMap(escherRecordClasses); + private static readonly Dictionary recordsMap = RecordsToMap(escherRecordClasses); /// /// Initializes a new instance of the class. diff --git a/main/DDF/EscherContainerRecord.cs b/main/DDF/EscherContainerRecord.cs index 77ceb472f..83b9cc267 100644 --- a/main/DDF/EscherContainerRecord.cs +++ b/main/DDF/EscherContainerRecord.cs @@ -40,7 +40,7 @@ public class EscherContainerRecord : EscherRecord public const short SPGR_CONTAINER = unchecked((short)0xF003); public const short SP_CONTAINER = unchecked((short)0xF004); public const short SOLVER_CONTAINER = unchecked((short)0xF005); - private static POILogger log = POILogFactory.GetLogger(typeof(EscherContainerRecord)); + private static readonly POILogger log = POILogFactory.GetLogger(typeof(EscherContainerRecord)); /** * in case if document contains any charts we have such document structure: @@ -65,7 +65,7 @@ public class EscherContainerRecord : EscherRecord * and add it to container size when we serialize it */ private int _remainingLength; - private List _childRecords = new List(); + private readonly List _childRecords = new List(); /// /// The contract of this method is to deSerialize an escher record including diff --git a/main/HPSF/Array.cs b/main/HPSF/Array.cs index ef78b5ae0..0820cb01a 100644 --- a/main/HPSF/Array.cs +++ b/main/HPSF/Array.cs @@ -39,7 +39,7 @@ public ArrayDimension( byte[] data, int offset ) internal class ArrayHeader { - private ArrayDimension[] _dimensions; + private readonly ArrayDimension[] _dimensions; internal int _type; public ArrayHeader( byte[] data, int startOffset ) diff --git a/main/HPSF/Blob.cs b/main/HPSF/Blob.cs index f255d15b1..b2f736bba 100644 --- a/main/HPSF/Blob.cs +++ b/main/HPSF/Blob.cs @@ -4,7 +4,7 @@ namespace NPOI.HPSF { internal class Blob { - private byte[] _value; + private readonly byte[] _value; public Blob(byte[] data, int offset) { diff --git a/main/HPSF/ClipboardData.cs b/main/HPSF/ClipboardData.cs index 41f770f32..0c04a663c 100644 --- a/main/HPSF/ClipboardData.cs +++ b/main/HPSF/ClipboardData.cs @@ -8,8 +8,8 @@ public class ClipboardData //private static final POILogger logger = POILogFactory // .getLogger( ClipboardData.class ); - private int _format; - private byte[] _value; + private readonly int _format; + private readonly byte[] _value; public ClipboardData(byte[] data, int offset) { diff --git a/main/HPSF/Filetime.cs b/main/HPSF/Filetime.cs index 8d9c6ed37..8cf6536d7 100644 --- a/main/HPSF/Filetime.cs +++ b/main/HPSF/Filetime.cs @@ -7,8 +7,8 @@ public class Filetime { public const int SIZE = LittleEndian.INT_SIZE * 2; - private int _dwHighDateTime; - private int _dwLowDateTime; + private readonly int _dwHighDateTime; + private readonly int _dwLowDateTime; public Filetime(byte[] data, int offset) { diff --git a/main/HPSF/IndirectPropertyName.cs b/main/HPSF/IndirectPropertyName.cs index 2526a8dad..1ea332423 100644 --- a/main/HPSF/IndirectPropertyName.cs +++ b/main/HPSF/IndirectPropertyName.cs @@ -2,7 +2,7 @@ { public class IndirectPropertyName { - private CodePageString _value; + private readonly CodePageString _value; public IndirectPropertyName(byte[] data, int offset) { diff --git a/main/HPSF/UnicodeString.cs b/main/HPSF/UnicodeString.cs index ce383be5e..34359632d 100644 --- a/main/HPSF/UnicodeString.cs +++ b/main/HPSF/UnicodeString.cs @@ -25,7 +25,7 @@ public class UnicodeString //private final static POILogger logger = POILogFactory // .getLogger( UnicodeString.class ); - private byte[] _value; + private readonly byte[] _value; public UnicodeString(byte[] data, int offset) { diff --git a/main/HPSF/Vector.cs b/main/HPSF/Vector.cs index 4d760db33..439b190d2 100644 --- a/main/HPSF/Vector.cs +++ b/main/HPSF/Vector.cs @@ -22,7 +22,7 @@ namespace NPOI.HPSF { public class Vector { - private short _type; + private readonly short _type; private TypedPropertyValue[] _values; diff --git a/main/HPSF/VersionedStream.cs b/main/HPSF/VersionedStream.cs index f509498ce..a80ce5925 100644 --- a/main/HPSF/VersionedStream.cs +++ b/main/HPSF/VersionedStream.cs @@ -19,7 +19,7 @@ namespace NPOI.HPSF public class VersionedStream { private GUID _versionGuid; - private IndirectPropertyName _streamName; + private readonly IndirectPropertyName _streamName; public VersionedStream(byte[] data, int offset) { diff --git a/main/HSSF/EventModel/EventRecordFactory.cs b/main/HSSF/EventModel/EventRecordFactory.cs index 99740ede0..7a4f9aff4 100644 --- a/main/HSSF/EventModel/EventRecordFactory.cs +++ b/main/HSSF/EventModel/EventRecordFactory.cs @@ -36,8 +36,8 @@ namespace NPOI.HSSF.EventModel public class EventRecordFactory { - private IERFListener _listener; - private ArrayList _sids; + private readonly IERFListener _listener; + private readonly ArrayList _sids; /** * Create an EventRecordFactory diff --git a/main/HSSF/Extractor/ExcelExtractor.cs b/main/HSSF/Extractor/ExcelExtractor.cs index ec4b22910..c3bb333fa 100644 --- a/main/HSSF/Extractor/ExcelExtractor.cs +++ b/main/HSSF/Extractor/ExcelExtractor.cs @@ -35,8 +35,8 @@ namespace NPOI.HSSF.Extractor /// public class ExcelExtractor : POIOLE2TextExtractor, IExcelExtractor { - private HSSFWorkbook wb; - private HSSFDataFormatter _formatter; + private readonly HSSFWorkbook wb; + private readonly HSSFDataFormatter _formatter; private bool includeSheetNames = true; private bool formulasNotResults = false; private bool includeCellComments = false; diff --git a/main/HSSF/Model/InternalSheet.cs b/main/HSSF/Model/InternalSheet.cs index d05ad67a2..749db03d6 100644 --- a/main/HSSF/Model/InternalSheet.cs +++ b/main/HSSF/Model/InternalSheet.cs @@ -179,7 +179,7 @@ public static InternalSheet CreateSheet(RecordStream rs) private class RecordCloner : RecordVisitor { - private IList _destList; + private readonly IList _destList; public RecordCloner(IList destList) { @@ -452,7 +452,7 @@ private InternalSheet(RecordStream rs) } private class RecordVisitor1:RecordVisitor { - List _records; + readonly List _records; public RecordVisitor1(List recs) { _records=recs; @@ -2339,7 +2339,7 @@ public int GetColumnOutlineLevel(int columnIndex) public class UnsupportedBOFType : RecordFormatException { - private BOFRecordType type; + private readonly BOFRecordType type; public UnsupportedBOFType(BOFRecordType type) : base("BOF not of a supported type, found " + type) { diff --git a/main/HSSF/Model/LinkTable.cs b/main/HSSF/Model/LinkTable.cs index 065c021d4..f398c38f7 100644 --- a/main/HSSF/Model/LinkTable.cs +++ b/main/HSSF/Model/LinkTable.cs @@ -91,8 +91,8 @@ private static ExternSheetRecord ReadExtSheetRecord(RecordStream rs) private class CRNBlock { - private CRNCountRecord _countRecord; - private CRNRecord[] _crns; + private readonly CRNCountRecord _countRecord; + private readonly CRNRecord[] _crns; public CRNBlock(RecordStream rs) { @@ -113,7 +113,7 @@ public CRNRecord[] GetCrns() private class ExternalBookBlock { - private SupBookRecord _externalBookRecord; + private readonly SupBookRecord _externalBookRecord; internal ExternalNameRecord[] _externalNameRecords; private CRNBlock[] _crnBlocks; /** @@ -217,10 +217,10 @@ public int GetNameIx(int definedNameIndex) } private ExternalBookBlock[] _externalBookBlocks; - private ExternSheetRecord _externSheetRecord; - private List _definedNames; - private int _recordCount; - private WorkbookRecordList _workbookRecordList; // TODO - would be nice to Remove this + private readonly ExternSheetRecord _externSheetRecord; + private readonly List _definedNames; + private readonly int _recordCount; + private readonly WorkbookRecordList _workbookRecordList; // TODO - would be nice to Remove this public LinkTable(List inputList, int startIndex, WorkbookRecordList workbookRecordList, Dictionary commentRecords) { diff --git a/main/HSSF/Model/ParseNode.cs b/main/HSSF/Model/ParseNode.cs index 66e19183c..ee7a3f4e8 100644 --- a/main/HSSF/Model/ParseNode.cs +++ b/main/HSSF/Model/ParseNode.cs @@ -32,10 +32,10 @@ class ParseNode { public static ParseNode[] EMPTY_ARRAY = { }; - private Ptg _token; - private ParseNode[] _children; - private bool _isIf; - private int _tokenCount; + private readonly Ptg _token; + private readonly ParseNode[] _children; + private readonly bool _isIf; + private readonly int _tokenCount; public ParseNode(Ptg token, ParseNode[] children) { @@ -178,7 +178,7 @@ public ParseNode[] Children private class TokenCollector { - private Ptg[] _ptgs; + private readonly Ptg[] _ptgs; private int _offset; public TokenCollector(int tokenCount) diff --git a/main/HSSF/Model/RecordStream.cs b/main/HSSF/Model/RecordStream.cs index e799e15d4..8893cd466 100644 --- a/main/HSSF/Model/RecordStream.cs +++ b/main/HSSF/Model/RecordStream.cs @@ -29,9 +29,9 @@ namespace NPOI.HSSF.Model public class RecordStream { - private IList _list; + private readonly IList _list; private int _nextIndex; - private int _endIx; + private readonly int _endIx; private int _countRead; public RecordStream(IList inputList, int startIndex, int endIx) diff --git a/main/HSSF/Model/RowBlocksReader.cs b/main/HSSF/Model/RowBlocksReader.cs index acb5dd859..94182a984 100644 --- a/main/HSSF/Model/RowBlocksReader.cs +++ b/main/HSSF/Model/RowBlocksReader.cs @@ -34,9 +34,9 @@ namespace NPOI.HSSF.Model public class RowBlocksReader { - private ArrayList _plainRecords; - private SharedValueManager _sfm; - private MergeCellsRecord[] _mergedCellsRecords; + private readonly ArrayList _plainRecords; + private readonly SharedValueManager _sfm; + private readonly MergeCellsRecord[] _mergedCellsRecords; /** * Also collects any loose MergeCellRecords and puts them in the supplied diff --git a/main/HSSF/Record/Aggregates/Chart/ChartSheetAggregate.cs b/main/HSSF/Record/Aggregates/Chart/ChartSheetAggregate.cs index 3becd1796..32a9fd02f 100644 --- a/main/HSSF/Record/Aggregates/Chart/ChartSheetAggregate.cs +++ b/main/HSSF/Record/Aggregates/Chart/ChartSheetAggregate.cs @@ -31,15 +31,15 @@ namespace NPOI.HSSF.Record.Aggregates.Chart /// public class ChartSheetAggregate : ChartRecordAggregate { - private BOFRecord _bofRec; + private readonly BOFRecord _bofRec; /** * All the records between BOF and EOF */ - private List _recs; - private PageSettingsBlock _psBlock; + private readonly List _recs; + private readonly PageSettingsBlock _psBlock; - private ChartFormatsAggregate chartFormats; - private SeriesDataAggregate seriesData; + private readonly ChartFormatsAggregate chartFormats; + private readonly SeriesDataAggregate seriesData; public ChartSheetAggregate(RecordStream rs, ChartRecordAggregate container) : base(RuleName_CHARTSHEET, container) diff --git a/main/HSSF/Record/Aggregates/ChartSubstreamRecordAggregate.cs b/main/HSSF/Record/Aggregates/ChartSubstreamRecordAggregate.cs index 6b762d7c8..b0c8234f1 100644 --- a/main/HSSF/Record/Aggregates/ChartSubstreamRecordAggregate.cs +++ b/main/HSSF/Record/Aggregates/ChartSubstreamRecordAggregate.cs @@ -33,12 +33,12 @@ namespace NPOI.HSSF.Record.Aggregates public class ChartSubstreamRecordAggregate : RecordAggregate { - private BOFRecord _bofRec; + private readonly BOFRecord _bofRec; /** * All the records between BOF and EOF */ - private List _recs; - private PageSettingsBlock _psBlock; + private readonly List _recs; + private readonly PageSettingsBlock _psBlock; public ChartSubstreamRecordAggregate(RecordStream rs) { diff --git a/main/HSSF/Record/Aggregates/ConditionalFormattingTable.cs b/main/HSSF/Record/Aggregates/ConditionalFormattingTable.cs index b85dbebd0..5cc18b757 100644 --- a/main/HSSF/Record/Aggregates/ConditionalFormattingTable.cs +++ b/main/HSSF/Record/Aggregates/ConditionalFormattingTable.cs @@ -36,7 +36,7 @@ namespace NPOI.HSSF.Record.Aggregates public class ConditionalFormattingTable : RecordAggregate { - private IList _cfHeaders; + private readonly IList _cfHeaders; /** * Creates an empty ConditionalFormattingTable diff --git a/main/HSSF/Record/Aggregates/CustomViewSettingsRecordAggregate.cs b/main/HSSF/Record/Aggregates/CustomViewSettingsRecordAggregate.cs index 041a431fa..69309894b 100644 --- a/main/HSSF/Record/Aggregates/CustomViewSettingsRecordAggregate.cs +++ b/main/HSSF/Record/Aggregates/CustomViewSettingsRecordAggregate.cs @@ -31,13 +31,13 @@ namespace NPOI.HSSF.Record.Aggregates public class CustomViewSettingsRecordAggregate : RecordAggregate { - private Record _begin; - private Record _end; + private readonly Record _begin; + private readonly Record _end; /** * All the records between BOF and EOF */ - private List _recs; - private PageSettingsBlock _psBlock; + private readonly List _recs; + private readonly PageSettingsBlock _psBlock; public CustomViewSettingsRecordAggregate(RecordStream rs) { diff --git a/main/HSSF/Record/Aggregates/DataValidityTable.cs b/main/HSSF/Record/Aggregates/DataValidityTable.cs index 935d6dcd3..19ce4e701 100644 --- a/main/HSSF/Record/Aggregates/DataValidityTable.cs +++ b/main/HSSF/Record/Aggregates/DataValidityTable.cs @@ -30,12 +30,12 @@ namespace NPOI.HSSF.Record.Aggregates public class DataValidityTable : RecordAggregate { - private DVALRecord _headerRec; + private readonly DVALRecord _headerRec; /** * The list of data validations for the current sheet. * Note - this may be empty (contrary to OOO documentation) */ - private IList _validationList; + private readonly IList _validationList; public DataValidityTable(RecordStream rs) { diff --git a/main/HSSF/Record/Aggregates/MergedCellsTable.cs b/main/HSSF/Record/Aggregates/MergedCellsTable.cs index fb936828e..544e7eb4a 100644 --- a/main/HSSF/Record/Aggregates/MergedCellsTable.cs +++ b/main/HSSF/Record/Aggregates/MergedCellsTable.cs @@ -32,7 +32,7 @@ public class MergedCellsTable : RecordAggregate { private const int MAX_MERGED_REGIONS = 1027; // enforced by the 8224 byte limit - private List _mergedRegions; + private readonly List _mergedRegions; /// /// Creates an empty aggregate diff --git a/main/HSSF/Record/Aggregates/PLSAggregate.cs b/main/HSSF/Record/Aggregates/PLSAggregate.cs index 67d50ed4c..5718f8384 100644 --- a/main/HSSF/Record/Aggregates/PLSAggregate.cs +++ b/main/HSSF/Record/Aggregates/PLSAggregate.cs @@ -5,15 +5,15 @@ namespace NPOI.HSSF.Record.Aggregates { internal class PLSAggregate : RecordAggregate { - private static ContinueRecord[] EMPTY_CONTINUE_RECORD_ARRAY = { }; - private Record _pls; + private static readonly ContinueRecord[] EMPTY_CONTINUE_RECORD_ARRAY = { }; + private readonly Record _pls; /** * holds any continue records found after the PLS record.
* This would not be required if PLS was properly interpreted. * Currently, PLS is an {@link UnknownRecord} and does not automatically * include any trailing {@link ContinueRecord}s. */ - private ContinueRecord[] _plsContinues; + private readonly ContinueRecord[] _plsContinues; public PLSAggregate(RecordStream rs) { diff --git a/main/HSSF/Record/Aggregates/PageSettingsBlock.cs b/main/HSSF/Record/Aggregates/PageSettingsBlock.cs index 73b264e30..6657f78f2 100644 --- a/main/HSSF/Record/Aggregates/PageSettingsBlock.cs +++ b/main/HSSF/Record/Aggregates/PageSettingsBlock.cs @@ -51,8 +51,8 @@ public class PageSettingsBlock : RecordAggregate private Record _bitmap; private HeaderFooterRecord _headerFooter; - private List _sviewHeaderFooters = new List(); - private List _plsRecords; + private readonly List _sviewHeaderFooters = new List(); + private readonly List _plsRecords; private Record _printSize; @@ -671,10 +671,10 @@ public void PositionRecords(List sheetRecords) } private class CustomRecordVisitor1 : RecordVisitor { - CustomViewSettingsRecordAggregate _cv; - HeaderFooterRecord _hf; - List _sviewHeaderFooters; - Dictionary _hfGuidMap; + readonly CustomViewSettingsRecordAggregate _cv; + readonly HeaderFooterRecord _hf; + readonly List _sviewHeaderFooters; + readonly Dictionary _hfGuidMap; public CustomRecordVisitor1(CustomViewSettingsRecordAggregate cv, HeaderFooterRecord hf, List sviewHeaderFooter, Dictionary hfGuidMap) { diff --git a/main/HSSF/Record/Aggregates/RecordAggregate.cs b/main/HSSF/Record/Aggregates/RecordAggregate.cs index 1e40d47cd..641b18e26 100644 --- a/main/HSSF/Record/Aggregates/RecordAggregate.cs +++ b/main/HSSF/Record/Aggregates/RecordAggregate.cs @@ -77,8 +77,8 @@ public override int RecordSize private class SerializingRecordVisitor : RecordVisitor { - private byte[] _data; - private int _startOffset; + private readonly byte[] _data; + private readonly int _startOffset; private int _countBytesWritten; public SerializingRecordVisitor(byte[] data, int startOffset) @@ -129,7 +129,7 @@ public virtual Record CloneViaReserialise() */ public class PositionTrackingVisitor : RecordVisitor { - private RecordVisitor _rv; + private readonly RecordVisitor _rv; private int _position; public PositionTrackingVisitor(RecordVisitor rv, int initialPosition) diff --git a/main/HSSF/Record/Aggregates/RowRecordsAggregate.cs b/main/HSSF/Record/Aggregates/RowRecordsAggregate.cs index cfd926e42..1b44e725e 100644 --- a/main/HSSF/Record/Aggregates/RowRecordsAggregate.cs +++ b/main/HSSF/Record/Aggregates/RowRecordsAggregate.cs @@ -38,12 +38,12 @@ public class RowRecordsAggregate : RecordAggregate { private int firstrow = -1; private int lastrow = -1; - private SortedList _rowRecords; + private readonly SortedList _rowRecords; //private int size = 0; - private ValueRecordsAggregate _valuesAgg; - private List _hyperlinkRecordRecords; - private List _unknownRecords; - private SharedValueManager _sharedValueManager; + private readonly ValueRecordsAggregate _valuesAgg; + private readonly List _hyperlinkRecordRecords; + private readonly List _unknownRecords; + private readonly SharedValueManager _sharedValueManager; // Cache values to speed up performance of // getStartRowNumberForBlock / getEndRowNumberForBlock, see Bugzilla 47405 diff --git a/main/HSSF/Record/Aggregates/SharedValueManager.cs b/main/HSSF/Record/Aggregates/SharedValueManager.cs index 43dea3022..47ee6f5c3 100644 --- a/main/HSSF/Record/Aggregates/SharedValueManager.cs +++ b/main/HSSF/Record/Aggregates/SharedValueManager.cs @@ -36,15 +36,15 @@ public class SharedValueManager private class SharedFormulaGroup { - private SharedFormulaRecord _sfr; - private FormulaRecordAggregate[] _frAggs; + private readonly SharedFormulaRecord _sfr; + private readonly FormulaRecordAggregate[] _frAggs; private int _numberOfFormulas; /** * Coordinates of the first cell having a formula that uses this shared formula. * This is often but not always the top left cell in the range covered by * {@link #_sfr} */ - private CellReference _firstCell; + private readonly CellReference _firstCell; internal CellReference FirstCell { get { return _firstCell; } diff --git a/main/HSSF/Record/ArrayRecord.cs b/main/HSSF/Record/ArrayRecord.cs index 78a5cb6a4..0fc378b14 100644 --- a/main/HSSF/Record/ArrayRecord.cs +++ b/main/HSSF/Record/ArrayRecord.cs @@ -40,7 +40,7 @@ public class ArrayRecord : SharedValueRecordBase, ICloneable private int _options; private int _field3notUsed; - private NPOI.SS.Formula.Formula _formula; + private readonly NPOI.SS.Formula.Formula _formula; public ArrayRecord(RecordInputStream in1) : base(in1) diff --git a/main/HSSF/Record/CF/FontFormatting.cs b/main/HSSF/Record/CF/FontFormatting.cs index 4c3999f96..528034ef4 100644 --- a/main/HSSF/Record/CF/FontFormatting.cs +++ b/main/HSSF/Record/CF/FontFormatting.cs @@ -31,7 +31,7 @@ namespace NPOI.HSSF.Record.CF */ public class FontFormatting : ICloneable { - private byte[] _rawData = new byte[RAW_DATA_SIZE]; + private readonly byte[] _rawData = new byte[RAW_DATA_SIZE]; private const int OFFSET_FONT_NAME = 0; private const int OFFSET_FONT_HEIGHT = 64; @@ -54,17 +54,17 @@ public class FontFormatting : ICloneable public const int FONT_CELL_HEIGHT_PRESERVED = unchecked((int)0xFFFFFFFF); // FONT OPTIONS MASKS - private static BitField posture = BitFieldFactory.GetInstance(0x00000002); - private static BitField outline = BitFieldFactory.GetInstance(0x00000008); - private static BitField shadow = BitFieldFactory.GetInstance(0x00000010); - private static BitField cancellation = BitFieldFactory.GetInstance(0x00000080); + private static readonly BitField posture = BitFieldFactory.GetInstance(0x00000002); + private static readonly BitField outline = BitFieldFactory.GetInstance(0x00000008); + private static readonly BitField shadow = BitFieldFactory.GetInstance(0x00000010); + private static readonly BitField cancellation = BitFieldFactory.GetInstance(0x00000080); // OPTION FLAGS MASKS - private static BitField styleModified = BitFieldFactory.GetInstance(0x00000002); - private static BitField outlineModified = BitFieldFactory.GetInstance(0x00000008); - private static BitField shadowModified = BitFieldFactory.GetInstance(0x00000010); - private static BitField cancellationModified = BitFieldFactory.GetInstance(0x00000080); + private static readonly BitField styleModified = BitFieldFactory.GetInstance(0x00000002); + private static readonly BitField outlineModified = BitFieldFactory.GetInstance(0x00000008); + private static readonly BitField shadowModified = BitFieldFactory.GetInstance(0x00000010); + private static readonly BitField cancellationModified = BitFieldFactory.GetInstance(0x00000080); /** Normal boldness (not bold) */ private const short FONT_WEIGHT_NORMAL = 0x190; diff --git a/main/HSSF/Record/Common/UnicodeString.cs b/main/HSSF/Record/Common/UnicodeString.cs index ad5a0827c..b17745f34 100644 --- a/main/HSSF/Record/Common/UnicodeString.cs +++ b/main/HSSF/Record/Common/UnicodeString.cs @@ -33,17 +33,17 @@ namespace NPOI.HSSF.Record */ public class UnicodeString : IComparable { // TODO - make this when the compatibility version is Removed - private static POILogger _logger = POILogFactory.GetLogger(typeof(UnicodeString)); + private static readonly POILogger _logger = POILogFactory.GetLogger(typeof(UnicodeString)); private short field_1_charCount; private byte field_2_optionflags; private String field_3_string; private List field_4_format_runs; private ExtRst field_5_ext_rst; - private static BitField highByte = BitFieldFactory.GetInstance(0x1); + private static readonly BitField highByte = BitFieldFactory.GetInstance(0x1); // 0x2 is reserved - private static BitField extBit = BitFieldFactory.GetInstance(0x4); - private static BitField richText = BitFieldFactory.GetInstance(0x8); + private static readonly BitField extBit = BitFieldFactory.GetInstance(0x4); + private static readonly BitField richText = BitFieldFactory.GetInstance(0x8); public class FormatRun : IComparable { diff --git a/main/HSSF/Record/Cont/ContinuableRecordInput.cs b/main/HSSF/Record/Cont/ContinuableRecordInput.cs index 0af9436ff..bb1bbdbc9 100644 --- a/main/HSSF/Record/Cont/ContinuableRecordInput.cs +++ b/main/HSSF/Record/Cont/ContinuableRecordInput.cs @@ -52,7 +52,7 @@ namespace NPOI.HSSF.Record.Cont */ public class ContinuableRecordInput : ILittleEndianInput { - private RecordInputStream _in; + private readonly RecordInputStream _in; public ContinuableRecordInput(RecordInputStream in1) { diff --git a/main/HSSF/Record/Cont/ContinuableRecordOutput.cs b/main/HSSF/Record/Cont/ContinuableRecordOutput.cs index 5fc431f5b..2cedeebe8 100644 --- a/main/HSSF/Record/Cont/ContinuableRecordOutput.cs +++ b/main/HSSF/Record/Cont/ContinuableRecordOutput.cs @@ -32,7 +32,7 @@ namespace NPOI.HSSF.Record.Cont public class ContinuableRecordOutput : ILittleEndianOutput { - private ILittleEndianOutput _out; + private readonly ILittleEndianOutput _out; private UnknownLengthRecordOutput _ulrOutput; private int _totalPreviousRecordsSize; @@ -281,7 +281,7 @@ public void WriteShort(int v) ///** // * Allows optimised usage of {@link ContinuableRecordOutput} for sizing purposes only. // */ - private static ILittleEndianOutput NOPOutput = new DelayableLittleEndianOutput1(); + private static readonly ILittleEndianOutput NOPOutput = new DelayableLittleEndianOutput1(); class DelayableLittleEndianOutput1 : IDelayableLittleEndianOutput { diff --git a/main/HSSF/Record/Cont/UnknownLengthRecordOutput.cs b/main/HSSF/Record/Cont/UnknownLengthRecordOutput.cs index 3df3c1977..a3efbd90f 100644 --- a/main/HSSF/Record/Cont/UnknownLengthRecordOutput.cs +++ b/main/HSSF/Record/Cont/UnknownLengthRecordOutput.cs @@ -31,10 +31,10 @@ class UnknownLengthRecordOutput : ILittleEndianOutput { private const int MAX_DATA_SIZE = RecordInputStream.MAX_RECORD_DATA_SIZE; - private ILittleEndianOutput _originalOut; + private readonly ILittleEndianOutput _originalOut; /** for writing the 'ushort size' field once its value is known */ - private ILittleEndianOutput _dataSizeOutput; - private byte[] _byteBuffer; + private readonly ILittleEndianOutput _dataSizeOutput; + private readonly byte[] _byteBuffer; private ILittleEndianOutput _out; private int _size; diff --git a/main/HSSF/Record/Crypto/Biff8DecryptingStream.cs b/main/HSSF/Record/Crypto/Biff8DecryptingStream.cs index 02b92f0e6..c7c2f4bc8 100644 --- a/main/HSSF/Record/Crypto/Biff8DecryptingStream.cs +++ b/main/HSSF/Record/Crypto/Biff8DecryptingStream.cs @@ -30,8 +30,8 @@ namespace NPOI.HSSF.Record.Crypto public class Biff8DecryptingStream : BiffHeaderInput, ILittleEndianInput { - private ILittleEndianInput _le; - private Biff8RC4 _rc4; + private readonly ILittleEndianInput _le; + private readonly Biff8RC4 _rc4; public Biff8DecryptingStream(Stream in1, int InitialOffSet, Biff8EncryptionKey key) { diff --git a/main/HSSF/Record/Crypto/Biff8EncryptionKey.cs b/main/HSSF/Record/Crypto/Biff8EncryptionKey.cs index 45fc9fb03..b87c625df 100644 --- a/main/HSSF/Record/Crypto/Biff8EncryptionKey.cs +++ b/main/HSSF/Record/Crypto/Biff8EncryptionKey.cs @@ -14,7 +14,7 @@ public class Biff8EncryptionKey private const int KEY_DIGEST_LENGTH = 5; private const int PASSWORD_HASH_NUMBER_OF_BYTES_USED = 5; - private byte[] _keyDigest; + private readonly byte[] _keyDigest; /** * Create using the default password and a specified docId diff --git a/main/HSSF/Record/Crypto/Biff8RC4.cs b/main/HSSF/Record/Crypto/Biff8RC4.cs index cef767f29..c887df2c0 100644 --- a/main/HSSF/Record/Crypto/Biff8RC4.cs +++ b/main/HSSF/Record/Crypto/Biff8RC4.cs @@ -42,7 +42,7 @@ public class Biff8RC4 private int _currentKeyIndex; private bool _shouldSkipEncryptionOnCurrentRecord; - private Biff8EncryptionKey _key; + private readonly Biff8EncryptionKey _key; public Biff8RC4(int InitialOffset, Biff8EncryptionKey key) { diff --git a/main/HSSF/Record/Crypto/RC4.cs b/main/HSSF/Record/Crypto/RC4.cs index 9e5be79d7..3103e433f 100644 --- a/main/HSSF/Record/Crypto/RC4.cs +++ b/main/HSSF/Record/Crypto/RC4.cs @@ -32,7 +32,7 @@ internal class RC4 { private int _i, _j; - private byte[] _s = new byte[256]; + private readonly byte[] _s = new byte[256]; public RC4(byte[] key) { diff --git a/main/HSSF/Record/DConRefRecord.cs b/main/HSSF/Record/DConRefRecord.cs index 142f8a52a..468f77c44 100644 --- a/main/HSSF/Record/DConRefRecord.cs +++ b/main/HSSF/Record/DConRefRecord.cs @@ -78,15 +78,37 @@ public class DConRefRecord : StandardRecord * * [MS XLS s.2.5.211] */ - private int firstRow, lastRow, firstCol, lastCol; + private readonly int firstRow; + + /** + * A RefU structure specifying the range of cells if this record is part of an SXTBL. + * + * [MS XLS s.2.5.211] + */ + private readonly int lastRow; + + /** + * A RefU structure specifying the range of cells if this record is part of an SXTBL. + * + * [MS XLS s.2.5.211] + */ + private readonly int firstCol; + + /** + * A RefU structure specifying the range of cells if this record is part of an SXTBL. + * + * [MS XLS s.2.5.211] + */ + private readonly int lastCol; + /** * the number of chars in the link */ - private int charCount; + private readonly int charCount; /** * the type of characters (single or double byte) */ - private int charType; + private readonly int charType; /** * The link's path string. This is the rgb field of a * XLUnicodeStringNoCch. Therefore it will contain at least one leading special @@ -97,11 +119,11 @@ public class DConRefRecord : StandardRecord * VirtualPath [MS-XLS s. 2.5.69] *

*/ - private byte[] path; + private readonly byte[] path; /** * unused bits at the end, must be set to 0. */ - private byte[] _unused; + private readonly byte[] _unused; /** * Read constructor. diff --git a/main/HSSF/Record/DSFRecord.cs b/main/HSSF/Record/DSFRecord.cs index dcf046977..ffe4974e0 100644 --- a/main/HSSF/Record/DSFRecord.cs +++ b/main/HSSF/Record/DSFRecord.cs @@ -37,8 +37,8 @@ namespace NPOI.HSSF.Record public class DSFRecord: StandardRecord { public const short sid = 0x161; - private int _options; - private static BitField biff5BookStreamFlag = BitFieldFactory.GetInstance(0x0001); + private readonly int _options; + private static readonly BitField biff5BookStreamFlag = BitFieldFactory.GetInstance(0x0001); private DSFRecord(int options) { diff --git a/main/HSSF/Record/DVRecord.cs b/main/HSSF/Record/DVRecord.cs index f0342919d..c115de31b 100644 --- a/main/HSSF/Record/DVRecord.cs +++ b/main/HSSF/Record/DVRecord.cs @@ -46,21 +46,21 @@ public class DVRecord : StandardRecord, ICloneable /** Option flags */ private int _option_flags; /** Title of the prompt box, cannot be longer than 32 chars */ - private UnicodeString _promptTitle; + private readonly UnicodeString _promptTitle; /** Title of the error box, cannot be longer than 32 chars */ - private UnicodeString _errorTitle; + private readonly UnicodeString _errorTitle; /** Text of the prompt box, cannot be longer than 255 chars */ - private UnicodeString _promptText; + private readonly UnicodeString _promptText; /** Text of the error box, cannot be longer than 255 chars */ - private UnicodeString _errorText; + private readonly UnicodeString _errorText; /** Not used - Excel seems to always write 0x3FE0 */ - private short _not_used_1 = 0x3FE0; + private readonly short _not_used_1 = 0x3FE0; /** Formula data for first condition (RPN token array without size field) */ - private NPOI.SS.Formula.Formula _formula1; + private readonly NPOI.SS.Formula.Formula _formula1; /** Not used - Excel seems to always write 0x0000 */ - private short _not_used_2 = 0x0000; + private readonly short _not_used_2 = 0x0000; /** Formula data for second condition (RPN token array without size field) */ - private NPOI.SS.Formula.Formula _formula2; + private readonly NPOI.SS.Formula.Formula _formula2; /** Cell range address list with all affected ranges */ private CellRangeAddressList _regions; @@ -74,14 +74,14 @@ public class DVRecord : StandardRecord, ICloneable * Option flags field * @see org.apache.poi.hssf.util.HSSFDataValidation utility class */ - private BitField opt_data_type = new BitField(0x0000000F); - private BitField opt_error_style = new BitField(0x00000070); - private BitField opt_string_list_formula = new BitField(0x00000080); - private BitField opt_empty_cell_allowed = new BitField(0x00000100); - private BitField opt_suppress_dropdown_arrow = new BitField(0x00000200); - private BitField opt_show_prompt_on_cell_selected = new BitField(0x00040000); - private BitField opt_show_error_on_invalid_value = new BitField(0x00080000); - private BitField opt_condition_operator = new BitField(0x00F00000); + private readonly BitField opt_data_type = new BitField(0x0000000F); + private readonly BitField opt_error_style = new BitField(0x00000070); + private readonly BitField opt_string_list_formula = new BitField(0x00000080); + private readonly BitField opt_empty_cell_allowed = new BitField(0x00000100); + private readonly BitField opt_suppress_dropdown_arrow = new BitField(0x00000200); + private readonly BitField opt_show_prompt_on_cell_selected = new BitField(0x00040000); + private readonly BitField opt_show_error_on_invalid_value = new BitField(0x00080000); + private readonly BitField opt_condition_operator = new BitField(0x00F00000); public DVRecord() { diff --git a/main/HSSF/Record/Drawing/OfficeArtFOPT.cs b/main/HSSF/Record/Drawing/OfficeArtFOPT.cs index 9b9ce2e27..e89726b55 100644 --- a/main/HSSF/Record/Drawing/OfficeArtFOPT.cs +++ b/main/HSSF/Record/Drawing/OfficeArtFOPT.cs @@ -7,9 +7,9 @@ namespace NPOI.HSSF.Record.Drawing { public class OfficeArtFOPT { - private OfficeArtRecordHeader _rh; - private List _fopt; - private Dictionary dictOptions = new Dictionary(); + private readonly OfficeArtRecordHeader _rh; + private readonly List _fopt; + private readonly Dictionary dictOptions = new Dictionary(); //private byte[] complexData = new byte[0]; public OfficeArtFOPT(RecordInputStream ris) diff --git a/main/HSSF/Record/EscherAggregate.cs b/main/HSSF/Record/EscherAggregate.cs index 201b22f5d..1fcc387e4 100644 --- a/main/HSSF/Record/EscherAggregate.cs +++ b/main/HSSF/Record/EscherAggregate.cs @@ -29,8 +29,8 @@ namespace NPOI.HSSF.Record internal class SerializationListener : EscherSerializationListener { - IList spEndingOffsets; - IList records; + readonly IList spEndingOffsets; + readonly IList records; EscherRecord record; public SerializationListener(IList spEndingOffsets, IList records, EscherRecord e) @@ -60,7 +60,7 @@ void EscherSerializationListener.AfterRecordSerialize(int offset, short recordId } internal class RecordSizeListener : EscherSerializationListener { - IList spEndingOffsets; + readonly IList spEndingOffsets; EscherRecord record; public RecordSizeListener(IList spEndingOffsets, EscherRecord e) @@ -343,7 +343,7 @@ public class EscherAggregate : AbstractEscherHolderRecord protected HSSFPatriarch patriarch; /** Maps shape container objects to their OBJ records */ - private Dictionary shapeToObj = new Dictionary(); + private readonly Dictionary shapeToObj = new Dictionary(); private DrawingManager2 drawingManager; //private short drawingGroupId; @@ -805,7 +805,7 @@ public System.Collections.IList Children(byte[] data, short size, int offset) internal class CustomEscherRecordFactory : DefaultEscherRecordFactory { - List shapeRecords; + readonly List shapeRecords; public CustomEscherRecordFactory(List shapeRecords) { this.shapeRecords = shapeRecords; diff --git a/main/HSSF/Record/ExtendedFormatRecord.cs b/main/HSSF/Record/ExtendedFormatRecord.cs index ecd4fb5f9..193997b45 100644 --- a/main/HSSF/Record/ExtendedFormatRecord.cs +++ b/main/HSSF/Record/ExtendedFormatRecord.cs @@ -105,82 +105,82 @@ public class ExtendedFormatRecord : StandardRecord private short field_2_format_index; // not bit-mapped // field_3_cell_options bit map - static private BitField _locked = BitFieldFactory.GetInstance(0x0001); - static private BitField _hidden = BitFieldFactory.GetInstance(0x0002); - static private BitField _xf_type = BitFieldFactory.GetInstance(0x0004); - static private BitField _123_prefix = BitFieldFactory.GetInstance(0x0008); - static private BitField _parent_index = BitFieldFactory.GetInstance(0xFFF0); + static private readonly BitField _locked = BitFieldFactory.GetInstance(0x0001); + static private readonly BitField _hidden = BitFieldFactory.GetInstance(0x0002); + static private readonly BitField _xf_type = BitFieldFactory.GetInstance(0x0004); + static private readonly BitField _123_prefix = BitFieldFactory.GetInstance(0x0008); + static private readonly BitField _parent_index = BitFieldFactory.GetInstance(0xFFF0); private short field_3_cell_options; // field_4_alignment_options bit map - static private BitField _alignment = BitFieldFactory.GetInstance(0x0007); - static private BitField _wrap_text = BitFieldFactory.GetInstance(0x0008); - static private BitField _vertical_alignment = BitFieldFactory.GetInstance(0x0070); - static private BitField _justify_last = BitFieldFactory.GetInstance(0x0080); - static private BitField _rotation = BitFieldFactory.GetInstance(0xFF00); + static private readonly BitField _alignment = BitFieldFactory.GetInstance(0x0007); + static private readonly BitField _wrap_text = BitFieldFactory.GetInstance(0x0008); + static private readonly BitField _vertical_alignment = BitFieldFactory.GetInstance(0x0070); + static private readonly BitField _justify_last = BitFieldFactory.GetInstance(0x0080); + static private readonly BitField _rotation = BitFieldFactory.GetInstance(0xFF00); private short field_4_alignment_options; // field_5_indention_options - static private BitField _indent = + static private readonly BitField _indent = BitFieldFactory.GetInstance(0x000F); - static private BitField _shrink_to_fit = + static private readonly BitField _shrink_to_fit = BitFieldFactory.GetInstance(0x0010); - static private BitField _merge_cells = + static private readonly BitField _merge_cells = BitFieldFactory.GetInstance(0x0020); - static private BitField _Reading_order = + static private readonly BitField _Reading_order = BitFieldFactory.GetInstance(0x00C0); // apparently bits 8 and 9 are Unused - static private BitField _indent_not_parent_format = + static private readonly BitField _indent_not_parent_format = BitFieldFactory.GetInstance(0x0400); - static private BitField _indent_not_parent_font = + static private readonly BitField _indent_not_parent_font = BitFieldFactory.GetInstance(0x0800); - static private BitField _indent_not_parent_alignment = + static private readonly BitField _indent_not_parent_alignment = BitFieldFactory.GetInstance(0x1000); - static private BitField _indent_not_parent_border = + static private readonly BitField _indent_not_parent_border = BitFieldFactory.GetInstance(0x2000); - static private BitField _indent_not_parent_pattern = + static private readonly BitField _indent_not_parent_pattern = BitFieldFactory.GetInstance(0x4000); - static private BitField _indent_not_parent_cell_options = + static private readonly BitField _indent_not_parent_cell_options = BitFieldFactory.GetInstance(0x8000); private short field_5_indention_options; // field_6_border_options bit map - static private BitField _border_left = BitFieldFactory.GetInstance(0x000F); - static private BitField _border_right = BitFieldFactory.GetInstance(0x00F0); - static private BitField _border_top = BitFieldFactory.GetInstance(0x0F00); - static private BitField _border_bottom = BitFieldFactory.GetInstance(0xF000); + static private readonly BitField _border_left = BitFieldFactory.GetInstance(0x000F); + static private readonly BitField _border_right = BitFieldFactory.GetInstance(0x00F0); + static private readonly BitField _border_top = BitFieldFactory.GetInstance(0x0F00); + static private readonly BitField _border_bottom = BitFieldFactory.GetInstance(0xF000); private short field_6_border_options; // all three of the following attributes are palette options // field_7_palette_options bit map - static private BitField _left_border_palette_idx = + static private readonly BitField _left_border_palette_idx = BitFieldFactory.GetInstance(0x007F); - static private BitField _right_border_palette_idx = + static private readonly BitField _right_border_palette_idx = BitFieldFactory.GetInstance(0x3F80); - static private BitField _diag = + static private readonly BitField _diag = BitFieldFactory.GetInstance(0xC000); private short field_7_palette_options; // field_8_adtl_palette_options bit map - static private BitField _top_border_palette_idx = + static private readonly BitField _top_border_palette_idx = BitFieldFactory.GetInstance(0x0000007F); - static private BitField _bottom_border_palette_idx = + static private readonly BitField _bottom_border_palette_idx = BitFieldFactory.GetInstance(0x00003F80); //is this used for diagional border color? - static private BitField _adtl_diag_border_palette_idx = + static private readonly BitField _adtl_diag_border_palette_idx = BitFieldFactory.GetInstance(0x001fc000); - static private BitField _adtl_diag_line_style = + static private readonly BitField _adtl_diag_line_style = BitFieldFactory.GetInstance(0x01e00000); // apparently bit 25 Is Unused - static private BitField _adtl_fill_pattern = + static private readonly BitField _adtl_fill_pattern = BitFieldFactory.GetInstance(unchecked((int)0xfc000000)); private int field_8_adtl_palette_options; // Additional to avoid 2 // field_9_fill_palette_options bit map - static private BitField _fill_foreground = BitFieldFactory.GetInstance(0x007F); - static private BitField _fill_background = BitFieldFactory.GetInstance(0x3f80); + static private readonly BitField _fill_foreground = BitFieldFactory.GetInstance(0x007F); + static private readonly BitField _fill_background = BitFieldFactory.GetInstance(0x3f80); // apparently bits 15 and 14 are Unused private short field_9_fill_palette_options; diff --git a/main/HSSF/Record/ExternSheetRecord.cs b/main/HSSF/Record/ExternSheetRecord.cs index 9f23701b1..1e332b685 100644 --- a/main/HSSF/Record/ExternSheetRecord.cs +++ b/main/HSSF/Record/ExternSheetRecord.cs @@ -32,7 +32,7 @@ public class RefSubRecord public const int ENCODED_SIZE = 6; /** index to External Book Block (which starts with a EXTERNALBOOK record) */ - private int _extBookIndex; + private readonly int _extBookIndex; private int _firstSheetIndex; // may be -1 (0xFFFF) private int _lastSheetIndex; // may be -1 (0xFFFF) @@ -114,7 +114,7 @@ public void Serialize(ILittleEndianOutput out1) public class ExternSheetRecord : StandardRecord { public const short sid = 0x17; - private IList _list; + private readonly IList _list; diff --git a/main/HSSF/Record/ExternalNameRecord.cs b/main/HSSF/Record/ExternalNameRecord.cs index 86a13a7f4..64c580c2d 100644 --- a/main/HSSF/Record/ExternalNameRecord.cs +++ b/main/HSSF/Record/ExternalNameRecord.cs @@ -46,9 +46,9 @@ public class ExternalNameRecord : StandardRecord private const int OPT_ICONIFIED_PICTURE_LINK = 0x8000; - private short field_1_option_flag; + private readonly short field_1_option_flag; private short field_2_ixals; - private short field_3_not_used; + private readonly short field_3_not_used; private String field_4_name; private Formula field_5_name_definition; @@ -57,15 +57,15 @@ public class ExternalNameRecord : StandardRecord * (seems to be only applicable to DDE links)
* Logically this is a 2-D array, which has been flattened into 1-D array here. */ - private Object[] _ddeValues; + private readonly Object[] _ddeValues; /** * (logical) number of columns in the {@link #_ddeValues} array */ - private int _nColumns; + private readonly int _nColumns; /** * (logical) number of rows in the {@link #_ddeValues} array */ - private int _nRows; + private readonly int _nRows; public ExternalNameRecord() { field_2_ixals = 0; diff --git a/main/HSSF/Record/FilePassRecord.cs b/main/HSSF/Record/FilePassRecord.cs index 3fd8a4d85..76901c0c7 100644 --- a/main/HSSF/Record/FilePassRecord.cs +++ b/main/HSSF/Record/FilePassRecord.cs @@ -33,8 +33,8 @@ public class FilePassRecord : StandardRecord, ICloneable private const int ENCRYPTION_XOR = 0; private const int ENCRYPTION_OTHER = 1; - private int _encryptionType; - private KeyData _keyData; + private readonly int _encryptionType; + private readonly KeyData _keyData; private interface KeyData : ICloneable { diff --git a/main/HSSF/Record/FormulaRecord.cs b/main/HSSF/Record/FormulaRecord.cs index ba74708ef..8da743c84 100644 --- a/main/HSSF/Record/FormulaRecord.cs +++ b/main/HSSF/Record/FormulaRecord.cs @@ -49,7 +49,7 @@ internal class SpecialCachedValue public const int ERROR_CODE = 2; public const int EMPTY = 3; - private byte[] _variableData; + private readonly byte[] _variableData; private SpecialCachedValue(byte[] data) { diff --git a/main/HSSF/Record/HeaderFooterRecord.cs b/main/HSSF/Record/HeaderFooterRecord.cs index 8c25687e8..9adb7ba47 100644 --- a/main/HSSF/Record/HeaderFooterRecord.cs +++ b/main/HSSF/Record/HeaderFooterRecord.cs @@ -30,10 +30,10 @@ namespace NPOI.HSSF.Record public class HeaderFooterRecord : StandardRecord, ICloneable { - private static byte[] BLANK_GUID = new byte[16]; + private static readonly byte[] BLANK_GUID = new byte[16]; public const short sid = 0x089C; - private byte[] _rawData; + private readonly byte[] _rawData; public HeaderFooterRecord(byte[] data) { diff --git a/main/HSSF/Record/InterfaceHdrRecord.cs b/main/HSSF/Record/InterfaceHdrRecord.cs index 369e22ef9..f9095e5f4 100644 --- a/main/HSSF/Record/InterfaceHdrRecord.cs +++ b/main/HSSF/Record/InterfaceHdrRecord.cs @@ -35,7 +35,7 @@ public class InterfaceHdrRecord : StandardRecord { public const short sid = 0xe1; - private int _codepage; // = 0; + private readonly int _codepage; // = 0; /** * suggested (and probably correct) default diff --git a/main/HSSF/Record/LbsDataSubRecord.cs b/main/HSSF/Record/LbsDataSubRecord.cs index aa133db30..5379bbd1b 100644 --- a/main/HSSF/Record/LbsDataSubRecord.cs +++ b/main/HSSF/Record/LbsDataSubRecord.cs @@ -25,14 +25,14 @@ public class LbsDataSubRecord : SubRecord, ICloneable /** * a formula that specifies the range of cell values that are the items in this list. */ - private int _unknownPreFormulaInt; - private Ptg _linkPtg; - private Byte? _unknownPostFormulaByte; + private readonly int _unknownPreFormulaInt; + private readonly Ptg _linkPtg; + private readonly Byte? _unknownPostFormulaByte; /** * An unsigned integer that specifies the number of items in the list. */ - private int _cLines; + private readonly int _cLines; /** * An unsigned integer that specifies the one-based index of the first selected item in this list. @@ -49,7 +49,7 @@ public class LbsDataSubRecord : SubRecord, ICloneable * An ObjId that specifies the edit box associated with this list. * A value of 0x00 specifies that there is no edit box associated with this list. */ - private int _idEdit; + private readonly int _idEdit; /** * An optional LbsDropData that specifies properties for this dropdown control. @@ -61,13 +61,13 @@ public class LbsDataSubRecord : SubRecord, ICloneable * An optional array of strings where each string specifies an item in the list. * The number of elements in this array, if it exists, MUST be {@link #_cLines} */ - private String[] _rgLines; + private readonly String[] _rgLines; /** * An optional array of bools that specifies * which items in the list are part of a multiple selection */ - private bool[] _bsels; + private readonly bool[] _bsels; LbsDataSubRecord() { @@ -353,18 +353,18 @@ public class LbsDropData { /** * An unsigned integer that specifies the smallest width in pixels allowed for the dropdown window */ - private int _dxMin; + private readonly int _dxMin; /** * a string that specifies the current string value in the dropdown */ - private String _str; + private readonly String _str; /** * Optional, undefined and MUST be ignored. * This field MUST exist if and only if the size of str in bytes is an odd number */ - private Byte _unused; + private readonly Byte _unused; public LbsDropData() { diff --git a/main/HSSF/Record/MergeCellsRecord.cs b/main/HSSF/Record/MergeCellsRecord.cs index 1a99b3471..527c449f3 100644 --- a/main/HSSF/Record/MergeCellsRecord.cs +++ b/main/HSSF/Record/MergeCellsRecord.cs @@ -41,9 +41,9 @@ public class MergeCellsRecord : StandardRecord, ICloneable public const short sid = 0xe5; /** sometimes the regions array is shared with other MergedCellsRecords */ - private CellRangeAddress[] _regions; - private int _startIndex; - private int _numberOfRegions; + private readonly CellRangeAddress[] _regions; + private readonly int _startIndex; + private readonly int _numberOfRegions; public MergeCellsRecord(CellRangeAddress[] regions, int startIndex, int numberOfRegions) diff --git a/main/HSSF/Record/MulBlankRecord.cs b/main/HSSF/Record/MulBlankRecord.cs index d6c9861cf..15bc86892 100644 --- a/main/HSSF/Record/MulBlankRecord.cs +++ b/main/HSSF/Record/MulBlankRecord.cs @@ -44,10 +44,10 @@ public class MulBlankRecord : StandardRecord, ICloneable { public const short sid = 0xbe; //private short field_1_row; - private int _row; - private int _first_col; - private short[] _xfs; - private int _last_col; + private readonly int _row; + private readonly int _first_col; + private readonly short[] _xfs; + private readonly int _last_col; /** Creates new MulBlankRecord */ diff --git a/main/HSSF/Record/ObjRecord.cs b/main/HSSF/Record/ObjRecord.cs index 34ce4070e..9f41489e6 100644 --- a/main/HSSF/Record/ObjRecord.cs +++ b/main/HSSF/Record/ObjRecord.cs @@ -36,13 +36,13 @@ public class ObjRecord : Record, ICloneable private const int MAX_PAD_ALIGNMENT = 4; public const short sid = 0x5D; - private List subrecords; + private readonly List subrecords; /** used when POI has no idea what is going on */ - private byte[] _uninterpretedData; + private readonly byte[] _uninterpretedData; /** * Excel seems to tolerate padding to quad or double byte length */ - private bool _isPaddedToQuadByteMultiple; + private readonly bool _isPaddedToQuadByteMultiple; //00000000 15 00 12 00 01 00 01 00 11 60 00 00 00 00 00 0D .........`...... //00000010 26 01 00 00 00 00 00 00 00 00 &......... diff --git a/main/HSSF/Record/PageBreakRecord.cs b/main/HSSF/Record/PageBreakRecord.cs index 507ae2e3d..7727dbf0e 100644 --- a/main/HSSF/Record/PageBreakRecord.cs +++ b/main/HSSF/Record/PageBreakRecord.cs @@ -43,8 +43,8 @@ public class PageBreakRecord : StandardRecord public short sid; // fix warning CS0169 "never used": private short numBreaks; - private IList _breaks; - private Hashtable _breakMap; + private readonly IList _breaks; + private readonly Hashtable _breakMap; /** * Since both records store 2byte integers (short), no point in diff --git a/main/HSSF/Record/PivotTable/PageItemRecord.cs b/main/HSSF/Record/PivotTable/PageItemRecord.cs index 93333114c..c50b6ec40 100644 --- a/main/HSSF/Record/PivotTable/PageItemRecord.cs +++ b/main/HSSF/Record/PivotTable/PageItemRecord.cs @@ -32,11 +32,11 @@ private class FieldInfo { public const int ENCODED_SIZE = 6; /** Index to the View Item SXVI(0x00B2) record */ - private int _isxvi; + private readonly int _isxvi; /** Index to the {@link ViewFieldsRecord} SXVD(0x00B1) record */ - private int _isxvd; + private readonly int _isxvd; /** Object ID for the drop-down arrow */ - private int _idObj; + private readonly int _idObj; public FieldInfo(RecordInputStream in1) { @@ -62,7 +62,7 @@ public void AppendDebugInfo(StringBuilder sb) } } - private FieldInfo[] _fieldInfos; + private readonly FieldInfo[] _fieldInfos; public PageItemRecord(RecordInputStream in1) { diff --git a/main/HSSF/Record/PivotTable/ViewFieldsRecord.cs b/main/HSSF/Record/PivotTable/ViewFieldsRecord.cs index 7b1a676a0..bc1de098b 100644 --- a/main/HSSF/Record/PivotTable/ViewFieldsRecord.cs +++ b/main/HSSF/Record/PivotTable/ViewFieldsRecord.cs @@ -48,12 +48,12 @@ private enum Axis private const int STRING_NOT_PRESENT_LEN = 0xFFFF; /** 5 shorts */ private const int BASE_SIZE = 10; - private int sxaxis; - private int cSub; - private int grbitSub; - private int cItm; + private readonly int sxaxis; + private readonly int cSub; + private readonly int grbitSub; + private readonly int cItm; - private String _name = null; + private readonly String _name = null; public ViewFieldsRecord(RecordInputStream in1) { diff --git a/main/HSSF/Record/RecalcIdRecord.cs b/main/HSSF/Record/RecalcIdRecord.cs index 4e440b92a..a1e368f55 100644 --- a/main/HSSF/Record/RecalcIdRecord.cs +++ b/main/HSSF/Record/RecalcIdRecord.cs @@ -48,7 +48,7 @@ public class RecalcIdRecord //public short[] field_1_recalcids; //private bool isNeeded = true; - private int _reserved0; + private readonly int _reserved0; //private bool isNeeded = true; /** * An unsigned integer that specifies the recalculation engine identifier diff --git a/main/HSSF/Record/RecordFactory.cs b/main/HSSF/Record/RecordFactory.cs index b72edaf5e..18a532ae8 100644 --- a/main/HSSF/Record/RecordFactory.cs +++ b/main/HSSF/Record/RecordFactory.cs @@ -50,7 +50,7 @@ namespace NPOI.HSSF.Record public class RecordFactory { private static int NUM_RECORDS = 512; - private static Type[] recordClasses; + private static readonly Type[] recordClasses; #region inner Record Creater private interface I_RecordCreator { @@ -61,7 +61,7 @@ private interface I_RecordCreator private class ReflectionConstructorRecordCreator : I_RecordCreator { - private ConstructorInfo _c; + private readonly ConstructorInfo _c; public ReflectionConstructorRecordCreator(ConstructorInfo c) { _c = c; @@ -90,7 +90,7 @@ public Type GetRecordClass() private class ReflectionMethodRecordCreator : I_RecordCreator { - private MethodInfo _m; + private readonly MethodInfo _m; public ReflectionMethodRecordCreator(MethodInfo m) { _m = m; @@ -114,7 +114,7 @@ public Type GetRecordClass() } #endregion - private static Type[] CONSTRUCTOR_ARGS = new Type[] { typeof(RecordInputStream), }; + private static readonly Type[] CONSTRUCTOR_ARGS = new Type[] { typeof(RecordInputStream), }; static RecordFactory() @@ -409,7 +409,7 @@ static RecordFactory() /** * cache of the recordsToMap(); */ - private static Dictionary _recordCreatorsById = null;//RecordsToMap(recordClasses); + private static readonly Dictionary _recordCreatorsById = null;//RecordsToMap(recordClasses); private static short[] _allKnownRecordSIDs; /** diff --git a/main/HSSF/Record/RecordFactoryInputStream.cs b/main/HSSF/Record/RecordFactoryInputStream.cs index 6b27fdb23..975ad1bae 100644 --- a/main/HSSF/Record/RecordFactoryInputStream.cs +++ b/main/HSSF/Record/RecordFactoryInputStream.cs @@ -46,9 +46,9 @@ public class RecordFactoryInputStream private class StreamEncryptionInfo { private int _InitialRecordsSize; - private FilePassRecord _filePassRec; - private Record _lastRecord; - private bool _hasBOFRecord; + private readonly FilePassRecord _filePassRec; + private readonly Record _lastRecord; + private readonly bool _hasBOFRecord; public StreamEncryptionInfo(RecordInputStream rs, List outputRecs) { @@ -158,8 +158,8 @@ public bool HasBOFRecord } - private RecordInputStream _recStream; - private bool _shouldIncludeContinueRecords; + private readonly RecordInputStream _recStream; + private readonly bool _shouldIncludeContinueRecords; /** * Temporarily stores a group of {@link Record}s, for future return by {@link #nextRecord()}. diff --git a/main/HSSF/Record/RecordInputStream.cs b/main/HSSF/Record/RecordInputStream.cs index 02c36d912..0597f8b65 100644 --- a/main/HSSF/Record/RecordInputStream.cs +++ b/main/HSSF/Record/RecordInputStream.cs @@ -52,7 +52,7 @@ private static String getRecordName(int sid) internal class SimpleHeaderInput : BiffHeaderInput { - private ILittleEndianInput _lei; + private readonly ILittleEndianInput _lei; internal static ILittleEndianInput GetLEI(Stream in1) { @@ -107,9 +107,9 @@ public class RecordInputStream : Stream, ILittleEndianInput private long pos = 0; /** Header {@link LittleEndianInput} facet of the wrapped {@link InputStream} */ - private BiffHeaderInput _bhi; + private readonly BiffHeaderInput _bhi; /** Data {@link LittleEndianInput} facet of the wrapped {@link InputStream} */ - private ILittleEndianInput _dataInput; + private readonly ILittleEndianInput _dataInput; /** the record identifier of the BIFF record currently being read */ //protected byte[] data = new byte[MAX_RECORD_DATA_SIZE]; diff --git a/main/HSSF/Record/RowDataRecord.cs b/main/HSSF/Record/RowDataRecord.cs index dacae1a62..484d3d4fb 100644 --- a/main/HSSF/Record/RowDataRecord.cs +++ b/main/HSSF/Record/RowDataRecord.cs @@ -7,7 +7,7 @@ namespace NPOI.HSSF.Record ///

public abstract class RowDataRecord : StandardRecord { - private byte[] _rawData = null; + private readonly byte[] _rawData = null; public RowDataRecord(RecordInputStream in1) { _rawData = in1.ReadRemainder(); diff --git a/main/HSSF/Record/SSTSerializer.cs b/main/HSSF/Record/SSTSerializer.cs index c831d788d..543614d35 100644 --- a/main/HSSF/Record/SSTSerializer.cs +++ b/main/HSSF/Record/SSTSerializer.cs @@ -29,15 +29,15 @@ namespace NPOI.HSSF.Record public class SSTSerializer { - private int _numStrings; - private int _numUniqueStrings; + private readonly int _numStrings; + private readonly int _numUniqueStrings; - private IntMapper strings; + private readonly IntMapper strings; /** OffSets from the beginning of the SST record (even across continuations) */ - private int[] bucketAbsoluteOffsets; + private readonly int[] bucketAbsoluteOffsets; /** OffSets relative the start of the current SST or continue record */ - private int[] bucketRelativeOffsets; + private readonly int[] bucketRelativeOffsets; // fix warning CS0169 "never used": int startOfSST, startOfRecord; public SSTSerializer(IntMapper strings, int numStrings, int numUniqueStrings) diff --git a/main/HSSF/Record/SharedValueRecordBase.cs b/main/HSSF/Record/SharedValueRecordBase.cs index ce44b67d8..b90e9bbed 100644 --- a/main/HSSF/Record/SharedValueRecordBase.cs +++ b/main/HSSF/Record/SharedValueRecordBase.cs @@ -30,7 +30,7 @@ namespace NPOI.HSSF.Record public abstract class SharedValueRecordBase : StandardRecord { - private CellRangeAddress8Bit _range; + private readonly CellRangeAddress8Bit _range; protected SharedValueRecordBase(CellRangeAddress8Bit range) { diff --git a/main/HSSF/Record/SubRecord/SubRecord.cs b/main/HSSF/Record/SubRecord/SubRecord.cs index b524e5650..0f55dcab3 100644 --- a/main/HSSF/Record/SubRecord/SubRecord.cs +++ b/main/HSSF/Record/SubRecord/SubRecord.cs @@ -97,8 +97,8 @@ public virtual bool IsTerminating public class UnknownSubRecord : SubRecord { - private int _sid; - private byte[] _data; + private readonly int _sid; + private readonly byte[] _data; public UnknownSubRecord(ILittleEndianInput in1, int sid, int size) { diff --git a/main/HSSF/Record/SupBookRecord.cs b/main/HSSF/Record/SupBookRecord.cs index 07d1963c1..dd5a49fbe 100644 --- a/main/HSSF/Record/SupBookRecord.cs +++ b/main/HSSF/Record/SupBookRecord.cs @@ -33,7 +33,7 @@ namespace NPOI.HSSF.Record */ public class SupBookRecord : StandardRecord { - private static POILogger logger = POILogFactory.GetLogger(typeof(SupBookRecord)); + private static readonly POILogger logger = POILogFactory.GetLogger(typeof(SupBookRecord)); public const short sid = 0x1AE; private const short SMALL_RECORD_SIZE = 4; @@ -42,8 +42,8 @@ public class SupBookRecord : StandardRecord private short field_1_number_of_sheets; private String field_2_encoded_url; - private String[] field_3_sheet_names; - private bool _isAddInFunctions; + private readonly String[] field_3_sheet_names; + private readonly bool _isAddInFunctions; public const char CH_VOLUME = (char)1; public const char CH_SAME_VOLUME = (char)2; diff --git a/main/HSSF/Record/UncalcedRecord.cs b/main/HSSF/Record/UncalcedRecord.cs index ee7faed58..d68273046 100644 --- a/main/HSSF/Record/UncalcedRecord.cs +++ b/main/HSSF/Record/UncalcedRecord.cs @@ -33,7 +33,7 @@ namespace NPOI.HSSF.Record public class UncalcedRecord : StandardRecord { public const short sid = 0x5E; - private short _reserved; + private readonly short _reserved; /** * Default constructor */ diff --git a/main/HSSF/Record/UnknownRecord.cs b/main/HSSF/Record/UnknownRecord.cs index 293ff9dfb..21d7ff349 100644 --- a/main/HSSF/Record/UnknownRecord.cs +++ b/main/HSSF/Record/UnknownRecord.cs @@ -58,8 +58,8 @@ public class UnknownRecord : StandardRecord public const int HEADER_FOOTER_089C = 0x089C; public const int CODENAME_1BA = 0x01BA; public const int PLV_MAC = 0x08C8; - private int _sid = 0; - private byte[] _rawData = null; + private readonly int _sid = 0; + private readonly byte[] _rawData = null; //public UnknownRecord() //{ diff --git a/main/HSSF/Record/UseSelFSRecord.cs b/main/HSSF/Record/UseSelFSRecord.cs index a72417069..5b30edb75 100644 --- a/main/HSSF/Record/UseSelFSRecord.cs +++ b/main/HSSF/Record/UseSelFSRecord.cs @@ -38,8 +38,8 @@ public class UseSelFSRecord { public const short sid = 0x160; - private static BitField useNaturalLanguageFormulasFlag = BitFieldFactory.GetInstance(0x0001); - private int _options; + private static readonly BitField useNaturalLanguageFormulasFlag = BitFieldFactory.GetInstance(0x0001); + private readonly int _options; public UseSelFSRecord(int options) { diff --git a/main/HSSF/Record/UserSViewBegin.cs b/main/HSSF/Record/UserSViewBegin.cs index 0c1124e45..d33335b25 100644 --- a/main/HSSF/Record/UserSViewBegin.cs +++ b/main/HSSF/Record/UserSViewBegin.cs @@ -34,7 +34,7 @@ public class UserSViewBegin : StandardRecord { public const short sid = 0x01AA; - private byte[] _rawData; + private readonly byte[] _rawData; public UserSViewBegin(byte[] data) { diff --git a/main/HSSF/Record/UserSViewEnd.cs b/main/HSSF/Record/UserSViewEnd.cs index 1e6c94958..08d6bf8e7 100644 --- a/main/HSSF/Record/UserSViewEnd.cs +++ b/main/HSSF/Record/UserSViewEnd.cs @@ -31,7 +31,7 @@ public class UserSViewEnd : StandardRecord { public const short sid = 0x01AB; - private byte[] _rawData; + private readonly byte[] _rawData; public UserSViewEnd(byte[] data) { diff --git a/main/HSSF/UserModel/DVConstraint.cs b/main/HSSF/UserModel/DVConstraint.cs index d76a33e4f..fb315b577 100644 --- a/main/HSSF/UserModel/DVConstraint.cs +++ b/main/HSSF/UserModel/DVConstraint.cs @@ -37,8 +37,8 @@ public class DVConstraint : IDataValidationConstraint public class FormulaPair { - private Ptg[] _formula1; - private Ptg[] _formula2; + private readonly Ptg[] _formula1; + private readonly Ptg[] _formula2; public FormulaPair(Ptg[] formula1, Ptg[] formula2) { @@ -66,7 +66,7 @@ public Ptg[] Formula2 //private static ValidationType VT = null; - private int _validationType; + private readonly int _validationType; private int _operator; private String[] _explicitListValues; diff --git a/main/HSSF/UserModel/EvaluationCycleDetector.cs b/main/HSSF/UserModel/EvaluationCycleDetector.cs index f560ed16d..e73e48d7e 100644 --- a/main/HSSF/UserModel/EvaluationCycleDetector.cs +++ b/main/HSSF/UserModel/EvaluationCycleDetector.cs @@ -39,10 +39,10 @@ class EvaluationCycleDetector private class CellEvaluationFrame { - private HSSFWorkbook _workbook; - private HSSFSheet _sheet; - private int _srcRowNum; - private int _srcColNum; + private readonly HSSFWorkbook _workbook; + private readonly HSSFSheet _sheet; + private readonly int _srcRowNum; + private readonly int _srcColNum; public CellEvaluationFrame(HSSFWorkbook workbook, HSSFSheet sheet, int srcRowNum, int srcColNum) { @@ -106,7 +106,7 @@ public override String ToString() } } - private IList _evaluationFrames; + private readonly IList _evaluationFrames; public EvaluationCycleDetector() { diff --git a/main/HSSF/UserModel/HSSFCellStyle.cs b/main/HSSF/UserModel/HSSFCellStyle.cs index 9f3a20f4b..210a4f860 100644 --- a/main/HSSF/UserModel/HSSFCellStyle.cs +++ b/main/HSSF/UserModel/HSSFCellStyle.cs @@ -32,9 +32,9 @@ namespace NPOI.HSSF.UserModel /// public class HSSFCellStyle : ICellStyle { - private ExtendedFormatRecord _format = null; - private short index = 0; - private NPOI.HSSF.Model.InternalWorkbook _workbook = null; + private readonly ExtendedFormatRecord _format = null; + private readonly short index = 0; + private readonly NPOI.HSSF.Model.InternalWorkbook _workbook = null; /// diff --git a/main/HSSF/UserModel/HSSFDataValidation.cs b/main/HSSF/UserModel/HSSFDataValidation.cs index aeacc8c89..ed714086d 100644 --- a/main/HSSF/UserModel/HSSFDataValidation.cs +++ b/main/HSSF/UserModel/HSSFDataValidation.cs @@ -41,8 +41,8 @@ public class HSSFDataValidation : IDataValidation private bool _suppress_dropdown_arrow = false; private bool _ShowPromptBox = true; private bool _ShowErrorBox = true; - private CellRangeAddressList _regions; - private DVConstraint _constraint; + private readonly CellRangeAddressList _regions; + private readonly DVConstraint _constraint; /** * Constructor which Initializes the cell range on which this object will be diff --git a/main/HSSF/UserModel/HSSFEvaluationCell.cs b/main/HSSF/UserModel/HSSFEvaluationCell.cs index 58083d1a6..f5113eeea 100644 --- a/main/HSSF/UserModel/HSSFEvaluationCell.cs +++ b/main/HSSF/UserModel/HSSFEvaluationCell.cs @@ -30,8 +30,8 @@ namespace NPOI.HSSF.UserModel public class HSSFEvaluationCell : IEvaluationCell { - private IEvaluationSheet _evalSheet; - private NPOI.SS.UserModel.ICell _cell; + private readonly IEvaluationSheet _evalSheet; + private readonly NPOI.SS.UserModel.ICell _cell; public HSSFEvaluationCell(NPOI.SS.UserModel.ICell cell, IEvaluationSheet evalSheet) { diff --git a/main/HSSF/UserModel/HSSFEvaluationSheet.cs b/main/HSSF/UserModel/HSSFEvaluationSheet.cs index 7c972fefe..ed298f9a0 100644 --- a/main/HSSF/UserModel/HSSFEvaluationSheet.cs +++ b/main/HSSF/UserModel/HSSFEvaluationSheet.cs @@ -28,7 +28,7 @@ namespace NPOI.HSSF.UserModel public class HSSFEvaluationSheet : IEvaluationSheet { - private HSSFSheet _hs; + private readonly HSSFSheet _hs; public HSSFEvaluationSheet(HSSFSheet hs) { diff --git a/main/HSSF/UserModel/HSSFEvaluationWorkbook.cs b/main/HSSF/UserModel/HSSFEvaluationWorkbook.cs index 8159b9ae2..fa584c9f3 100644 --- a/main/HSSF/UserModel/HSSFEvaluationWorkbook.cs +++ b/main/HSSF/UserModel/HSSFEvaluationWorkbook.cs @@ -37,8 +37,8 @@ namespace NPOI.HSSF.UserModel public class HSSFEvaluationWorkbook : IFormulaRenderingWorkbook, IEvaluationWorkbook, IFormulaParsingWorkbook { private static POILogger logger = POILogFactory.GetLogger(typeof(HSSFEvaluationWorkbook)); - private HSSFWorkbook _uBook; - private NPOI.HSSF.Model.InternalWorkbook _iBook; + private readonly HSSFWorkbook _uBook; + private readonly NPOI.HSSF.Model.InternalWorkbook _iBook; public static HSSFEvaluationWorkbook Create(NPOI.SS.UserModel.IWorkbook book) { @@ -241,8 +241,8 @@ public UDFFinder GetUDFFinder() private class Name : IEvaluationName { - private NameRecord _nameRecord; - private int _index; + private readonly NameRecord _nameRecord; + private readonly int _index; public Name(NameRecord nameRecord, int index) { diff --git a/main/HSSF/UserModel/HSSFFooter.cs b/main/HSSF/UserModel/HSSFFooter.cs index 54e38834b..3fc80ff91 100644 --- a/main/HSSF/UserModel/HSSFFooter.cs +++ b/main/HSSF/UserModel/HSSFFooter.cs @@ -35,7 +35,7 @@ namespace NPOI.HSSF.UserModel /// public class HSSFFooter : HeaderFooter,IFooter { - private PageSettingsBlock _psb; + private readonly PageSettingsBlock _psb; /// /// Initializes a new instance of the class. diff --git a/main/HSSF/UserModel/HSSFHeader.cs b/main/HSSF/UserModel/HSSFHeader.cs index 43b809471..1d8f49845 100644 --- a/main/HSSF/UserModel/HSSFHeader.cs +++ b/main/HSSF/UserModel/HSSFHeader.cs @@ -34,7 +34,7 @@ namespace NPOI.HSSF.UserModel /// public class HSSFHeader : HeaderFooter,IHeader { - private PageSettingsBlock _psb; + private readonly PageSettingsBlock _psb; /// /// Initializes a new instance of the class. diff --git a/main/HSSF/UserModel/HSSFName.cs b/main/HSSF/UserModel/HSSFName.cs index 4206f8326..666c4bab9 100644 --- a/main/HSSF/UserModel/HSSFName.cs +++ b/main/HSSF/UserModel/HSSFName.cs @@ -38,9 +38,9 @@ public class HSSFName:NPOI.SS.UserModel.IName // "[\\p{IsAlphabetic}_\\\\]" + // "[\\p{IsAlphabetic}0-9_.\\\\]*", // RegexOptions.IgnoreCase); - private HSSFWorkbook book; - private NameRecord _definedNameRec; - private NameCommentRecord _commentRec; + private readonly HSSFWorkbook book; + private readonly NameRecord _definedNameRec; + private readonly NameCommentRecord _commentRec; /* package */ internal HSSFName(HSSFWorkbook book, NameRecord name):this(book, name, null) { diff --git a/main/HSSF/UserModel/HSSFObjectData.cs b/main/HSSF/UserModel/HSSFObjectData.cs index e153b2038..1714a57dd 100644 --- a/main/HSSF/UserModel/HSSFObjectData.cs +++ b/main/HSSF/UserModel/HSSFObjectData.cs @@ -38,7 +38,7 @@ public class HSSFObjectData : HSSFPicture /** * Reference to the filesystem root, required for retrieving the object data. */ - private DirectoryEntry _root; + private readonly DirectoryEntry _root; public HSSFObjectData(EscherContainerRecord spContainer, ObjRecord objRecord, DirectoryEntry _root) diff --git a/main/HSSF/UserModel/HSSFPatriarch.cs b/main/HSSF/UserModel/HSSFPatriarch.cs index 4678c65aa..3b739378f 100644 --- a/main/HSSF/UserModel/HSSFPatriarch.cs +++ b/main/HSSF/UserModel/HSSFPatriarch.cs @@ -37,17 +37,17 @@ namespace NPOI.HSSF.UserModel public class HSSFPatriarch : HSSFShapeContainer, IDrawing, IDrawing { //private static POILogger log = POILogFactory.GetLogger(typeof(HSSFPatriarch)); - List _shapes = new List(); - private HSSFSheet _sheet; - private EscherSpgrRecord _spgrRecord; - private EscherContainerRecord _mainSpgrContainer; + readonly List _shapes = new List(); + private readonly HSSFSheet _sheet; + private readonly EscherSpgrRecord _spgrRecord; + private readonly EscherContainerRecord _mainSpgrContainer; /** * The EscherAggregate we have been bound to. * (This will handle writing us out into records, * and building up our shapes from the records) */ - private EscherAggregate _boundAggregate; + private readonly EscherAggregate _boundAggregate; /// /// Creates the patriarch. diff --git a/main/HSSF/UserModel/HSSFShapeGroup.cs b/main/HSSF/UserModel/HSSFShapeGroup.cs index 15b77b5e6..80795e080 100644 --- a/main/HSSF/UserModel/HSSFShapeGroup.cs +++ b/main/HSSF/UserModel/HSSFShapeGroup.cs @@ -31,8 +31,8 @@ namespace NPOI.HSSF.UserModel /// public class HSSFShapeGroup : HSSFShape, HSSFShapeContainer { - private List shapes = new List(); - private EscherSpgrRecord _spgrRecord; + private readonly List shapes = new List(); + private readonly EscherSpgrRecord _spgrRecord; public HSSFShapeGroup(EscherContainerRecord spgrContainer, ObjRecord objRecord) : base(spgrContainer, objRecord) diff --git a/main/HSSF/UserModel/HSSFSheet.cs b/main/HSSF/UserModel/HSSFSheet.cs index e5f94bf9a..c1b16ce61 100644 --- a/main/HSSF/UserModel/HSSFSheet.cs +++ b/main/HSSF/UserModel/HSSFSheet.cs @@ -491,7 +491,7 @@ public int LastRowNum private class RecordVisitor1 : RecordVisitor { - private List hssfValidations; + private readonly List hssfValidations; private IWorkbook workbook; public RecordVisitor1(List hssfValidations, IWorkbook workbook) { @@ -499,7 +499,7 @@ public RecordVisitor1(List hssfValidations, IWorkbook workbook) this.workbook = workbook; this.book = HSSFEvaluationWorkbook.Create(workbook); } - private HSSFEvaluationWorkbook book; + private readonly HSSFEvaluationWorkbook book; public void VisitRecord(Record r) { if (!(r is DVRecord)) diff --git a/main/HSSF/UserModel/HSSFSheetConditionalFormatting.cs b/main/HSSF/UserModel/HSSFSheetConditionalFormatting.cs index 82a9001d3..96f2e2cd1 100644 --- a/main/HSSF/UserModel/HSSFSheetConditionalFormatting.cs +++ b/main/HSSF/UserModel/HSSFSheetConditionalFormatting.cs @@ -33,8 +33,8 @@ public class HSSFSheetConditionalFormatting : ISheetConditionalFormatting { //private HSSFWorkbook _workbook; - private HSSFSheet _sheet; - private ConditionalFormattingTable _conditionalFormattingTable; + private readonly HSSFSheet _sheet; + private readonly ConditionalFormattingTable _conditionalFormattingTable; /* package */ //public HSSFSheetConditionalFormatting(HSSFWorkbook workbook, InternalSheet sheet) diff --git a/main/HSSF/UserModel/HSSFWorkbook.cs b/main/HSSF/UserModel/HSSFWorkbook.cs index dd4857e44..61b0774c8 100644 --- a/main/HSSF/UserModel/HSSFWorkbook.cs +++ b/main/HSSF/UserModel/HSSFWorkbook.cs @@ -124,7 +124,7 @@ public NPOI.SS.UserModel.ICreationHelper GetCreationHelper() private class SheetRecordCollector : NPOI.HSSF.Record.Aggregates.RecordVisitor,IDisposable { - private ArrayList _list; + private readonly ArrayList _list; private int _totalSize; public SheetRecordCollector() diff --git a/main/HSSF/UserModel/HeaderFooter.cs b/main/HSSF/UserModel/HeaderFooter.cs index 52d385a1b..24054081d 100644 --- a/main/HSSF/UserModel/HeaderFooter.cs +++ b/main/HSSF/UserModel/HeaderFooter.cs @@ -469,23 +469,23 @@ public PairField(Fields fields, String sequence) public class Fields { - private List allFields = new List(); + private readonly List allFields = new List(); public static ReadOnlyCollection AllFields { get { return Instance.allFields.AsReadOnly(); } } - private Field _sheetnamefield; - private Field _filefield; - private Field _fullfilefield; - private Field _pagefield; - private Field _datefield; - private Field _timefield; - private Field _numpagesfield; - private Field _picturefield; - private PairField _boldfield; - private PairField _italicfield; - private PairField _strikethroughfield; - private PairField _subscriptfield; - private PairField _superscriptfield; - private PairField _underlinefield; - private PairField _doubleunderlinefield; + private readonly Field _sheetnamefield; + private readonly Field _filefield; + private readonly Field _fullfilefield; + private readonly Field _pagefield; + private readonly Field _datefield; + private readonly Field _timefield; + private readonly Field _numpagesfield; + private readonly Field _picturefield; + private readonly PairField _boldfield; + private readonly PairField _italicfield; + private readonly PairField _strikethroughfield; + private readonly PairField _subscriptfield; + private readonly PairField _superscriptfield; + private readonly PairField _underlinefield; + private readonly PairField _doubleunderlinefield; public Field SHEET_NAME_FIELD { get{return _sheetnamefield;} diff --git a/main/HSSF/UserModel/OperationEvaluatorFactory.cs b/main/HSSF/UserModel/OperationEvaluatorFactory.cs index 4f6aef695..1a0ca5ad4 100644 --- a/main/HSSF/UserModel/OperationEvaluatorFactory.cs +++ b/main/HSSF/UserModel/OperationEvaluatorFactory.cs @@ -33,9 +33,9 @@ namespace NPOI.HSSF.UserModel */ class OperationEvaluatorFactory { - private static Type[] OPERATION_CONSTRUCTOR_CLASS_ARRAY = new Type[] { typeof(Ptg) }; + private static readonly Type[] OPERATION_CONSTRUCTOR_CLASS_ARRAY = new Type[] { typeof(Ptg) }; - private static Hashtable _constructorsByPtgClass = InitialiseConstructorsMap(); + private static readonly Hashtable _constructorsByPtgClass = InitialiseConstructorsMap(); private OperationEvaluatorFactory() { diff --git a/main/HSSF/Util/GUID.cs b/main/HSSF/Util/GUID.cs index ac8b4abf7..a90a11f86 100644 --- a/main/HSSF/Util/GUID.cs +++ b/main/HSSF/Util/GUID.cs @@ -15,15 +15,15 @@ public class GUID { public const int ENCODED_SIZE = 16; /** 4 bytes - little endian */ - private int _d1; + private readonly int _d1; /** 2 bytes - little endian */ - private int _d2; + private readonly int _d2; /** 2 bytes - little endian */ - private int _d3; + private readonly int _d3; /** * 8 bytes - serialized as big endian, stored with inverted endianness here */ - private long _d4; + private readonly long _d4; public GUID(ILittleEndianInput in1) :this(in1.ReadInt(), in1.ReadUShort(), in1.ReadUShort(), in1.ReadLong()) diff --git a/main/HSSF/Util/HSSFColor.cs b/main/HSSF/Util/HSSFColor.cs index 092a8600f..eeef0f96f 100644 --- a/main/HSSF/Util/HSSFColor.cs +++ b/main/HSSF/Util/HSSFColor.cs @@ -1463,7 +1463,7 @@ public override String GetHexString() */ public class Automatic : HSSFColor { - private static HSSFColor instance = new Automatic(); + private static readonly HSSFColor instance = new Automatic(); public const short Index = 0x40; diff --git a/main/HSSF/Util/HSSFRegionUtil.cs b/main/HSSF/Util/HSSFRegionUtil.cs index af0623f91..60b90c697 100644 --- a/main/HSSF/Util/HSSFRegionUtil.cs +++ b/main/HSSF/Util/HSSFRegionUtil.cs @@ -39,9 +39,9 @@ private HSSFRegionUtil() private class CellPropertySetter { - private HSSFWorkbook _workbook; - private String _propertyName; - private short _propertyValue; + private readonly HSSFWorkbook _workbook; + private readonly String _propertyName; + private readonly short _propertyValue; public CellPropertySetter(HSSFWorkbook workbook, String propertyName, int value) { diff --git a/main/POIFS/Crypt/ChunkedCipherOutputStream.cs b/main/POIFS/Crypt/ChunkedCipherOutputStream.cs index bc76d66e1..ee746a895 100644 --- a/main/POIFS/Crypt/ChunkedCipherOutputStream.cs +++ b/main/POIFS/Crypt/ChunkedCipherOutputStream.cs @@ -28,9 +28,9 @@ public abstract class ChunkedCipherOutputStream : LittleEndianOutputStream { protected int chunkMask; protected int chunkBits; - private byte[] _chunk; - private FileInfo fileOut; - private DirectoryNode dir; + private readonly byte[] _chunk; + private readonly FileInfo fileOut; + private readonly DirectoryNode dir; private long _pos = 0; private Cipher _cipher; @@ -133,7 +133,7 @@ protected void WriteChunk() { } private class EncryptedPackageWriter : POIFSWriterListener { - ChunkedCipherOutputStream stream; + readonly ChunkedCipherOutputStream stream; public EncryptedPackageWriter(ChunkedCipherOutputStream stream) { this.stream = stream; diff --git a/main/POIFS/Crypt/EncryptionInfo.cs b/main/POIFS/Crypt/EncryptionInfo.cs index 3b243594d..3aae8029e 100644 --- a/main/POIFS/Crypt/EncryptionInfo.cs +++ b/main/POIFS/Crypt/EncryptionInfo.cs @@ -311,39 +311,39 @@ protected static IEncryptionInfoBuilder GetBuilder(EncryptionMode encryptionMode return eib; } - private int _versionMajor; + private readonly int _versionMajor; public int VersionMajor { get { return _versionMajor; } } - private int _versionMinor; + private readonly int _versionMinor; public int VersionMinor { get { return _versionMinor; } } - private int _encryptionFlags; + private readonly int _encryptionFlags; public int EncryptionFlags { get { return _encryptionFlags; } } - private EncryptionHeader _header; + private readonly EncryptionHeader _header; public EncryptionHeader Header { get { return _header; } } - private EncryptionVerifier _verifier; + private readonly EncryptionVerifier _verifier; public EncryptionVerifier Verifier { get { return _verifier; } } - private Decryptor _decryptor; + private readonly Decryptor _decryptor; public Decryptor Decryptor { get { return _decryptor; } } - private Encryptor _encryptor; + private readonly Encryptor _encryptor; public Encryptor Encryptor { get { return _encryptor; } diff --git a/main/POIFS/FileSystem/CloseIgnoringInputStream.cs b/main/POIFS/FileSystem/CloseIgnoringInputStream.cs index aef1af597..c7784f90b 100644 --- a/main/POIFS/FileSystem/CloseIgnoringInputStream.cs +++ b/main/POIFS/FileSystem/CloseIgnoringInputStream.cs @@ -33,7 +33,7 @@ namespace NPOI.POIFS.FileSystem internal class CloseIgnoringInputStream : Stream { - private Stream _is; + private readonly Stream _is; public CloseIgnoringInputStream(Stream stream) { diff --git a/main/POIFS/FileSystem/DocumentNode.cs b/main/POIFS/FileSystem/DocumentNode.cs index 46ac43984..fbb334092 100644 --- a/main/POIFS/FileSystem/DocumentNode.cs +++ b/main/POIFS/FileSystem/DocumentNode.cs @@ -31,7 +31,7 @@ namespace NPOI.POIFS.FileSystem public class DocumentNode : EntryNode, POIFSViewable, DocumentEntry { // underlying POIFSDocument instance - private OPOIFSDocument _document; + private readonly OPOIFSDocument _document; /** * create a DocumentNode. This method Is not public by design; it diff --git a/main/POIFS/FileSystem/DocumentOutputStream.cs b/main/POIFS/FileSystem/DocumentOutputStream.cs index bd22ccfd7..007bce471 100644 --- a/main/POIFS/FileSystem/DocumentOutputStream.cs +++ b/main/POIFS/FileSystem/DocumentOutputStream.cs @@ -29,8 +29,8 @@ namespace NPOI.POIFS.FileSystem public class DocumentOutputStream : MemoryStream { - private Stream _stream; - private int _limit; + private readonly Stream _stream; + private readonly int _limit; private int _written; /** diff --git a/main/POIFS/FileSystem/NDocumentOutputStream.cs b/main/POIFS/FileSystem/NDocumentOutputStream.cs index e718d1125..b3259969b 100644 --- a/main/POIFS/FileSystem/NDocumentOutputStream.cs +++ b/main/POIFS/FileSystem/NDocumentOutputStream.cs @@ -35,10 +35,10 @@ public class NDocumentOutputStream : MemoryStream private bool _closed; /** the actual Document */ - private NPOIFSDocument _document; + private readonly NPOIFSDocument _document; /** and its Property */ - private DocumentProperty _property; + private readonly DocumentProperty _property; /** our buffer, when null we're into normal blocks */ private MemoryStream _buffer = diff --git a/main/POIFS/FileSystem/NPOIFSDocument.cs b/main/POIFS/FileSystem/NPOIFSDocument.cs index d2f095ce7..7aee75d9e 100644 --- a/main/POIFS/FileSystem/NPOIFSDocument.cs +++ b/main/POIFS/FileSystem/NPOIFSDocument.cs @@ -35,9 +35,9 @@ namespace NPOI.POIFS.FileSystem */ public class NPOIFSDocument : POIFSViewable { - private DocumentProperty _property; + private readonly DocumentProperty _property; - private NPOIFSFileSystem _filesystem; + private readonly NPOIFSFileSystem _filesystem; private NPOIFSStream _stream; private int _block_size; diff --git a/main/POIFS/FileSystem/NPOIFSFileSystem.cs b/main/POIFS/FileSystem/NPOIFSFileSystem.cs index 00bbaf725..68cfee494 100644 --- a/main/POIFS/FileSystem/NPOIFSFileSystem.cs +++ b/main/POIFS/FileSystem/NPOIFSFileSystem.cs @@ -54,9 +54,9 @@ public static Stream CreateNonClosingInputStream(Stream stream) private NPOIFSMiniStore _mini_store; private NPropertyTable _property_table; - private List _xbat_blocks; - private List _bat_blocks; - private HeaderBlock _header; + private readonly List _xbat_blocks; + private readonly List _bat_blocks; + private readonly HeaderBlock _header; private DirectoryNode _root; private DataSource _data; diff --git a/main/POIFS/FileSystem/NPOIFSMiniStore.cs b/main/POIFS/FileSystem/NPOIFSMiniStore.cs index b270db8dc..6e8945cf7 100644 --- a/main/POIFS/FileSystem/NPOIFSMiniStore.cs +++ b/main/POIFS/FileSystem/NPOIFSMiniStore.cs @@ -33,11 +33,11 @@ namespace NPOI.POIFS.FileSystem */ public class NPOIFSMiniStore : BlockStore { - private NPOIFSFileSystem _filesystem; + private readonly NPOIFSFileSystem _filesystem; private NPOIFSStream _mini_stream; - private List _sbat_blocks; - private HeaderBlock _header; - private RootProperty _root; + private readonly List _sbat_blocks; + private readonly HeaderBlock _header; + private readonly RootProperty _root; public NPOIFSMiniStore(NPOIFSFileSystem filesystem, RootProperty root, List sbats, HeaderBlock header) diff --git a/main/POIFS/FileSystem/ODocumentInputStream.cs b/main/POIFS/FileSystem/ODocumentInputStream.cs index 21c90170d..bb5998d8a 100644 --- a/main/POIFS/FileSystem/ODocumentInputStream.cs +++ b/main/POIFS/FileSystem/ODocumentInputStream.cs @@ -37,13 +37,13 @@ public class ODocumentInputStream : DocumentInputStream//DocumentReader private long _marked_offset; /** the Document's size */ - private int _document_size; + private readonly int _document_size; /** have we been closed? */ private bool _closed; /** the actual Document */ - private OPOIFSDocument _document; + private readonly OPOIFSDocument _document; /** the data block Containing the current stream pointer */ private DataInputBlock _currentBlock; diff --git a/main/POIFS/FileSystem/OPOIFSDocument.cs b/main/POIFS/FileSystem/OPOIFSDocument.cs index 33baa3402..825180530 100644 --- a/main/POIFS/FileSystem/OPOIFSDocument.cs +++ b/main/POIFS/FileSystem/OPOIFSDocument.cs @@ -47,16 +47,16 @@ namespace NPOI.POIFS.FileSystem /// public class OPOIFSDocument : BATManaged, BlockWritable, POIFSViewable { - private static DocumentBlock[] EMPTY_BIG_BLOCK_ARRAY = { }; - private static SmallDocumentBlock[] EMPTY_SMALL_BLOCK_ARRAY = { }; + private static readonly DocumentBlock[] EMPTY_BIG_BLOCK_ARRAY = { }; + private static readonly SmallDocumentBlock[] EMPTY_SMALL_BLOCK_ARRAY = { }; - private DocumentProperty _property; - private int _size; + private readonly DocumentProperty _property; + private readonly int _size; - private POIFSBigBlockSize _bigBigBlockSize; - private SmallBlockStore _small_store; + private readonly POIFSBigBlockSize _bigBigBlockSize; + private readonly SmallBlockStore _small_store; - private BigBlockStore _big_store; + private readonly BigBlockStore _big_store; public OPOIFSDocument(string name, RawDataBlock[] blocks, int length) { @@ -456,11 +456,11 @@ protected virtual void OnBeforeWriting(POIFSWriterEventArgs e) internal class SmallBlockStore { private SmallDocumentBlock[] smallBlocks; - private POIFSDocumentPath path; - private string name; - private int size; - private POIFSWriterListener writer; - private POIFSBigBlockSize bigBlockSize; + private readonly POIFSDocumentPath path; + private readonly string name; + private readonly int size; + private readonly POIFSWriterListener writer; + private readonly POIFSBigBlockSize bigBlockSize; internal SmallBlockStore(POIFSBigBlockSize bigBlockSize, SmallDocumentBlock[] blocks) { @@ -513,11 +513,11 @@ internal virtual bool Valid internal class BigBlockStore { private DocumentBlock[] bigBlocks; - private POIFSDocumentPath path; - private string name; - private int size; - private POIFSWriterListener writer; - private POIFSBigBlockSize bigBlockSize; + private readonly POIFSDocumentPath path; + private readonly string name; + private readonly int size; + private readonly POIFSWriterListener writer; + private readonly POIFSBigBlockSize bigBlockSize; internal BigBlockStore(POIFSBigBlockSize bigBlockSize, DocumentBlock[] blocks) { diff --git a/main/POIFS/FileSystem/POIFSDocumentReader.cs b/main/POIFS/FileSystem/POIFSDocumentReader.cs index bc35f94c7..35789d184 100644 --- a/main/POIFS/FileSystem/POIFSDocumentReader.cs +++ b/main/POIFS/FileSystem/POIFSDocumentReader.cs @@ -40,8 +40,8 @@ public class POIFSDocumentReader:Stream { private bool _closed; private int _current_offset; - private OPOIFSDocument _document; - private int _document_size; + private readonly OPOIFSDocument _document; + private readonly int _document_size; private byte[] _tiny_buffer; private const int _EOD = 0; diff --git a/main/POIFS/Storage/BATBlock.cs b/main/POIFS/Storage/BATBlock.cs index da499c290..ea18a31b2 100644 --- a/main/POIFS/Storage/BATBlock.cs +++ b/main/POIFS/Storage/BATBlock.cs @@ -42,21 +42,21 @@ namespace NPOI.POIFS.Storage /// public class BATBlock : BigBlock { - private static int _entries_per_block = + private static readonly int _entries_per_block = POIFSConstants.BIG_BLOCK_SIZE / LittleEndianConsts.INT_SIZE; - private static int _entries_per_xbat_block = _entries_per_block - 1; - private static int _xbat_chain_offset = + private static readonly int _entries_per_xbat_block = _entries_per_block - 1; + private static readonly int _xbat_chain_offset = _entries_per_xbat_block * LittleEndianConsts.INT_SIZE; - private static byte _default_value = (byte)0xFF; - private IntegerField[] _fields; - private byte[] _data; + private static readonly byte _default_value = (byte)0xFF; + private readonly IntegerField[] _fields; + private readonly byte[] _data; /** * For a regular fat block, these are 128 / 1024 * next sector values. * For a XFat (DIFat) block, these are 127 / 1023 * next sector values, then a chaining value. */ - private int[] _values; + private readonly int[] _values; /** * Does this BATBlock have any free sectors in it? @@ -515,8 +515,8 @@ private byte[] Serialize() } public class BATBlockAndIndex { - private int index; - private BATBlock block; + private readonly int index; + private readonly BATBlock block; public BATBlockAndIndex(int index, BATBlock block) { diff --git a/main/POIFS/Storage/BlockAllocationTableReader.cs b/main/POIFS/Storage/BlockAllocationTableReader.cs index fa1ee1c94..e135bc0a7 100644 --- a/main/POIFS/Storage/BlockAllocationTableReader.cs +++ b/main/POIFS/Storage/BlockAllocationTableReader.cs @@ -50,13 +50,13 @@ namespace NPOI.POIFS.Storage public class BlockAllocationTableReader { - private static POILogger _logger = POILogFactory.GetLogger(typeof(BlockAllocationTableReader)); + private static readonly POILogger _logger = POILogFactory.GetLogger(typeof(BlockAllocationTableReader)); private const int MAX_BLOCK_COUNT = 65535; - private List _entries; + private readonly List _entries; - private POIFSBigBlockSize bigBlockSize; + private readonly POIFSBigBlockSize bigBlockSize; /// /// create a BlockAllocationTableReader for an existing filesystem. Side /// effect: when this method finishes, the BAT blocks will have diff --git a/main/POIFS/Storage/BlockAllocationTableWriter.cs b/main/POIFS/Storage/BlockAllocationTableWriter.cs index 8585d7b96..3f7c75747 100644 --- a/main/POIFS/Storage/BlockAllocationTableWriter.cs +++ b/main/POIFS/Storage/BlockAllocationTableWriter.cs @@ -50,12 +50,12 @@ namespace NPOI.POIFS.Storage /// public class BlockAllocationTableWriter : BlockWritable, BATManaged { - private List _entries; + private readonly List _entries; private BATBlock[] _blocks; private int _start_block; - private POIFSBigBlockSize _bigBlockSize; + private readonly POIFSBigBlockSize _bigBlockSize; - private static int _default_size = 128; + private static readonly int _default_size = 128; /// /// Initializes a new instance of the class. diff --git a/main/POIFS/Storage/DataInputBlock.cs b/main/POIFS/Storage/DataInputBlock.cs index a3c5a7843..14a96ca6e 100644 --- a/main/POIFS/Storage/DataInputBlock.cs +++ b/main/POIFS/Storage/DataInputBlock.cs @@ -46,9 +46,9 @@ public class DataInputBlock * Possibly any size (usually 512K or 64K). Assumed to be at least 8 bytes for all blocks * before the end of the stream. The last block in the stream can be any size except zero. */ - private byte[] _buf; + private readonly byte[] _buf; private int _readIndex; - private int _maxIndex; + private readonly int _maxIndex; internal DataInputBlock(byte[] data, int startOffset) { diff --git a/main/POIFS/Storage/DocumentBlock.cs b/main/POIFS/Storage/DocumentBlock.cs index 0444ecd0e..ecf74546e 100644 --- a/main/POIFS/Storage/DocumentBlock.cs +++ b/main/POIFS/Storage/DocumentBlock.cs @@ -37,9 +37,9 @@ namespace NPOI.POIFS.Storage { public class DocumentBlock : BigBlock { - private static byte _default_value = (byte)0xFF; - private byte[] _data; - private int _bytes_Read; + private static readonly byte _default_value = (byte)0xFF; + private readonly byte[] _data; + private readonly int _bytes_Read; /// /// create a document block from a raw data block diff --git a/main/POIFS/Storage/HeaderBlockReader.cs b/main/POIFS/Storage/HeaderBlockReader.cs index a1227058b..102451f48 100644 --- a/main/POIFS/Storage/HeaderBlockReader.cs +++ b/main/POIFS/Storage/HeaderBlockReader.cs @@ -48,27 +48,27 @@ public class HeaderBlockReader * What big block Size the file uses. Most files * use 512 bytes, but a few use 4096 */ - private POIFSBigBlockSize bigBlockSize; + private readonly POIFSBigBlockSize bigBlockSize; // number of big block allocation table blocks (int) - private int _bat_count; + private readonly int _bat_count; // start of the property Set block (int index of the property Set // chain's first big block) - private int _property_start; + private readonly int _property_start; // start of the small block allocation table (int index of small // block allocation table's first big block) - private int _sbat_start; + private readonly int _sbat_start; /** * Number of small block allocation table blocks (int) * (Number of MiniFAT Sectors in Microsoft parlance) */ private int _sbat_count; // big block index for extension to the big block allocation table - private int _xbat_start; - private int _xbat_count; - private byte[] _data; + private readonly int _xbat_start; + private readonly int _xbat_count; + private readonly byte[] _data; /// /// create a new HeaderBlockReader from an Stream diff --git a/main/POIFS/Storage/PropertyBlock.cs b/main/POIFS/Storage/PropertyBlock.cs index f2b77b422..e8d44bb7d 100644 --- a/main/POIFS/Storage/PropertyBlock.cs +++ b/main/POIFS/Storage/PropertyBlock.cs @@ -56,7 +56,7 @@ public override bool IsDirectory - private Property[] _properties; + private readonly Property[] _properties; /// /// Create a single instance initialized with default values diff --git a/main/POIFS/Storage/RawDataBlock.cs b/main/POIFS/Storage/RawDataBlock.cs index 2db341539..3af9cbc22 100644 --- a/main/POIFS/Storage/RawDataBlock.cs +++ b/main/POIFS/Storage/RawDataBlock.cs @@ -40,10 +40,10 @@ namespace NPOI.POIFS.Storage /// public class RawDataBlock : ListManagedBlock { - private byte[] _data; - private bool _eof; - private bool _hasData; - private static POILogger log = POILogFactory.GetLogger(typeof(RawDataBlock)); + private readonly byte[] _data; + private readonly bool _eof; + private readonly bool _hasData; + private static readonly POILogger log = POILogFactory.GetLogger(typeof(RawDataBlock)); /// /// Constructor RawDataBlock diff --git a/main/POIFS/Storage/SmallBlockTableWriter.cs b/main/POIFS/Storage/SmallBlockTableWriter.cs index 195c6126f..17c58ddc9 100644 --- a/main/POIFS/Storage/SmallBlockTableWriter.cs +++ b/main/POIFS/Storage/SmallBlockTableWriter.cs @@ -42,10 +42,10 @@ namespace NPOI.POIFS.Storage /// public class SmallBlockTableWriter : BlockWritable, BATManaged { - private BlockAllocationTableWriter _sbat; - private IList _small_blocks; - private int _big_block_count; - private RootProperty _root; + private readonly BlockAllocationTableWriter _sbat; + private readonly IList _small_blocks; + private readonly int _big_block_count; + private readonly RootProperty _root; /// /// Initializes a new instance of the class. diff --git a/main/POIFS/Storage/SmallDocumentBlock.cs b/main/POIFS/Storage/SmallDocumentBlock.cs index 71137ced2..78ad51732 100644 --- a/main/POIFS/Storage/SmallDocumentBlock.cs +++ b/main/POIFS/Storage/SmallDocumentBlock.cs @@ -45,13 +45,13 @@ public class SmallDocumentBlock : BlockWritable, ListManagedBlock private const int BLOCK_SHIFT = 6; - private byte[] _data; + private readonly byte[] _data; private const byte _default_fill = ( byte ) 0xff; private const int _block_size = 1 << BLOCK_SHIFT; private const int BLOCK_MASK = _block_size - 1; private static int _blocks_per_big_block = POIFSConstants.BIG_BLOCK_SIZE / _block_size; - private POIFSBigBlockSize _bigBlockSize; + private readonly POIFSBigBlockSize _bigBlockSize; public SmallDocumentBlock(POIFSBigBlockSize bigBlockSize, byte[] data, int index) { diff --git a/main/POIFS/property/DirectoryProperty.cs b/main/POIFS/property/DirectoryProperty.cs index dc05882fb..22bb134b3 100644 --- a/main/POIFS/property/DirectoryProperty.cs +++ b/main/POIFS/property/DirectoryProperty.cs @@ -39,10 +39,10 @@ namespace NPOI.POIFS.Properties public class DirectoryProperty: Property, Parent, IEnumerable { // List of Property instances - private List _children; + private readonly List _children; // Set of children's names - private List _children_names; + private readonly List _children_names; /// /// Initializes a new instance of the class. diff --git a/main/POIFS/property/NPropertyTable.cs b/main/POIFS/property/NPropertyTable.cs index f316ca7c7..396f84fba 100644 --- a/main/POIFS/property/NPropertyTable.cs +++ b/main/POIFS/property/NPropertyTable.cs @@ -29,7 +29,7 @@ namespace NPOI.POIFS.Properties { public class NPropertyTable : PropertyTableBase { - private POIFSBigBlockSize _bigBigBlockSize; + private readonly POIFSBigBlockSize _bigBigBlockSize; public NPropertyTable(HeaderBlock headerBlock) : base(headerBlock) { diff --git a/main/POIFS/property/Property.cs b/main/POIFS/property/Property.cs index aea252f77..53696f5bd 100644 --- a/main/POIFS/property/Property.cs +++ b/main/POIFS/property/Property.cs @@ -71,20 +71,20 @@ public abstract class Property:Child, POIFSViewable // documents must be at least this size to be stored in big blocks private const int _big_block_minimum_bytes = POIFSConstants.BIG_BLOCK_MINIMUM_DOCUMENT_SIZE; //4096; private String _name; - private ShortField _name_size; - private ByteField _property_type; - private ByteField _node_color; - private IntegerField _previous_property; - private IntegerField _next_property; - private IntegerField _child_property; + private readonly ShortField _name_size; + private readonly ByteField _property_type; + private readonly ByteField _node_color; + private readonly IntegerField _previous_property; + private readonly IntegerField _next_property; + private readonly IntegerField _child_property; private ClassID _storage_clsid; private IntegerField _user_flags; - private IntegerField _seconds_1; - private IntegerField _days_1; - private IntegerField _seconds_2; - private IntegerField _days_2; - private IntegerField _start_block; - private IntegerField _size; + private readonly IntegerField _seconds_1; + private readonly IntegerField _days_1; + private readonly IntegerField _seconds_2; + private readonly IntegerField _days_2; + private readonly IntegerField _start_block; + private readonly IntegerField _size; private byte[] _raw_data; private int _index; private Child _next_child; diff --git a/main/POIFS/property/PropertyTable.cs b/main/POIFS/property/PropertyTable.cs index e836d7434..5ca23bc1f 100644 --- a/main/POIFS/property/PropertyTable.cs +++ b/main/POIFS/property/PropertyTable.cs @@ -36,7 +36,7 @@ namespace NPOI.POIFS.Properties public class PropertyTable : PropertyTableBase, BlockWritable { - private POIFSBigBlockSize _bigBigBlockSize; + private readonly POIFSBigBlockSize _bigBigBlockSize; private BlockWritable[] _blocks; /** * Default constructor diff --git a/main/SS/Format/CellDateFormatter.cs b/main/SS/Format/CellDateFormatter.cs index 480dc6497..fe4900f6a 100644 --- a/main/SS/Format/CellDateFormatter.cs +++ b/main/SS/Format/CellDateFormatter.cs @@ -33,7 +33,7 @@ public class CellDateFormatter : CellFormatter private bool amPmUpper; private bool ShowM; private bool ShowAmPm; - private FormatBase dateFmt; + private readonly FormatBase dateFmt; private String sFmt; private int millisecondPartLength = 0; @@ -52,7 +52,7 @@ static CellDateFormatter() private class DatePartHandler : CellFormatPart.IPartHandler { - private CellDateFormatter _formatter; + private readonly CellDateFormatter _formatter; private int mStart = -1; private int mLen; private int hStart = -1; diff --git a/main/SS/Format/CellElapsedFormatter.cs b/main/SS/Format/CellElapsedFormatter.cs index c07815f92..44135e01a 100644 --- a/main/SS/Format/CellElapsedFormatter.cs +++ b/main/SS/Format/CellElapsedFormatter.cs @@ -27,9 +27,9 @@ namespace NPOI.SS.Format */ public class CellElapsedFormatter : CellFormatter { - private List specs; + private readonly List specs; private TimeSpec topmost; - private String printfFmt; + private readonly String printfFmt; private static readonly Regex PERCENTS = new Regex("%", RegexOptions.Compiled); @@ -39,10 +39,10 @@ public class CellElapsedFormatter : CellFormatter private class TimeSpec { - internal char type; - internal int pos; - internal int len; - internal double factor; + internal readonly char type; + internal readonly int pos; + internal readonly int len; + internal readonly double factor; internal double modBy; public TimeSpec(char type, int pos, int len, double factor) @@ -78,7 +78,7 @@ public ElapsedPartHandler(CellElapsedFormatter formatter) // the default handling for quoted strings and special characters. The // only special character for this is '%', so we have to handle all the // quoting in this method ourselves. - private CellElapsedFormatter _formatter; + private readonly CellElapsedFormatter _formatter; public String HandlePart(Match m, String part, CellFormatType type, StringBuilder desc) { diff --git a/main/SS/Format/CellFormat.cs b/main/SS/Format/CellFormat.cs index c01396752..0a1d6b2f9 100644 --- a/main/SS/Format/CellFormat.cs +++ b/main/SS/Format/CellFormat.cs @@ -72,12 +72,12 @@ namespace NPOI.SS.Format */ public class CellFormat { - private String format; - private CellFormatPart posNumFmt; - private CellFormatPart zeroNumFmt; - private CellFormatPart negNumFmt; - private CellFormatPart textFmt; - private int formatPartCount; + private readonly String format; + private readonly CellFormatPart posNumFmt; + private readonly CellFormatPart zeroNumFmt; + private readonly CellFormatPart negNumFmt; + private readonly CellFormatPart textFmt; + private readonly int formatPartCount; private static readonly Regex ONE_PART = new Regex(CellFormatPart.FORMAT_PAT.ToString() + "(;|$)", RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace | RegexOptions.Compiled); @@ -117,7 +117,7 @@ public override CellFormatResult Apply(Object value) } /** Maps a format string to its Parsed version for efficiencies sake. */ - private static Dictionary formatCache = + private static readonly Dictionary formatCache = new Dictionary(); /** diff --git a/main/SS/Format/CellFormatCondition.cs b/main/SS/Format/CellFormatCondition.cs index b9415cc79..a1abc00e5 100644 --- a/main/SS/Format/CellFormatCondition.cs +++ b/main/SS/Format/CellFormatCondition.cs @@ -37,7 +37,7 @@ public abstract class CellFormatCondition private const int EQ = 4; private const int NE = 5; - private static Dictionary TESTS; + private static readonly Dictionary TESTS; static CellFormatCondition() { @@ -53,7 +53,7 @@ static CellFormatCondition() } private class LT_CellFormatCondition : CellFormatCondition { - double _c; + readonly double _c; public LT_CellFormatCondition(double c) { _c = c; @@ -65,7 +65,7 @@ public override bool Pass(double value) } private class LE_CellFormatCondition : CellFormatCondition { - double _c; + readonly double _c; public LE_CellFormatCondition(double c) { _c = c; @@ -77,7 +77,7 @@ public override bool Pass(double value) } private class GT_CellFormatCondition : CellFormatCondition { - double _c; + readonly double _c; public GT_CellFormatCondition(double c) { _c = c; @@ -89,7 +89,7 @@ public override bool Pass(double value) } private class GE_CellFormatCondition : CellFormatCondition { - double _c; + readonly double _c; public GE_CellFormatCondition(double c) { _c = c; @@ -101,7 +101,7 @@ public override bool Pass(double value) } private class EQ_CellFormatCondition : CellFormatCondition { - double _c; + readonly double _c; public EQ_CellFormatCondition(double c) { _c = c; @@ -113,7 +113,7 @@ public override bool Pass(double value) } private class NE_CellFormatCondition : CellFormatCondition { - double _c; + readonly double _c; public NE_CellFormatCondition(double c) { _c = c; diff --git a/main/SS/Format/CellFormatPart.cs b/main/SS/Format/CellFormatPart.cs index 386747844..7740c6590 100644 --- a/main/SS/Format/CellFormatPart.cs +++ b/main/SS/Format/CellFormatPart.cs @@ -44,11 +44,11 @@ namespace NPOI.SS.Format */ public class CellFormatPart { - private Color color; - private CellFormatCondition condition; - private CellFormatter format; - private CellFormatType type; - private static Dictionary NAMED_COLORS; + private readonly Color color; + private readonly CellFormatCondition condition; + private readonly CellFormatter format; + private readonly CellFormatType type; + private static readonly Dictionary NAMED_COLORS; public static IEqualityComparer CASE_INSENSITIVE_ORDER = new CaseInsensitiveComparator(); private class CaseInsensitiveComparator : IEqualityComparer diff --git a/main/SS/Formula/Atp/AnalysisToolPak.cs b/main/SS/Formula/Atp/AnalysisToolPak.cs index b5b1fcc49..9c04865bb 100644 --- a/main/SS/Formula/Atp/AnalysisToolPak.cs +++ b/main/SS/Formula/Atp/AnalysisToolPak.cs @@ -30,7 +30,7 @@ namespace NPOI.SS.Formula.Atp public class NotImplemented : FreeRefFunction { - private String _functionName; + private readonly String _functionName; public NotImplemented(String functionName) { @@ -47,7 +47,7 @@ public class AnalysisToolPak : UDFFinder { public static UDFFinder instance = new AnalysisToolPak(); - private static Dictionary _functionsByName = CreateFunctionsMap(); + private static readonly Dictionary _functionsByName = CreateFunctionsMap(); private AnalysisToolPak() { diff --git a/main/SS/Formula/Atp/ParityFunction.cs b/main/SS/Formula/Atp/ParityFunction.cs index 9e2fc92fc..3b3b26856 100644 --- a/main/SS/Formula/Atp/ParityFunction.cs +++ b/main/SS/Formula/Atp/ParityFunction.cs @@ -31,7 +31,7 @@ public class ParityFunction : FreeRefFunction public static readonly FreeRefFunction IS_EVEN = new ParityFunction(0); public static readonly FreeRefFunction IS_ODD = new ParityFunction(1); - private int _desiredParity; + private readonly int _desiredParity; private ParityFunction(int desiredParity) { diff --git a/main/SS/Formula/Atp/RandBetween.cs b/main/SS/Formula/Atp/RandBetween.cs index c61d0bee3..672e7e7d2 100644 --- a/main/SS/Formula/Atp/RandBetween.cs +++ b/main/SS/Formula/Atp/RandBetween.cs @@ -36,7 +36,7 @@ namespace NPOI.SS.Formula.Atp */ class RandBetween : FreeRefFunction { - private Random _rnd; + private readonly Random _rnd; public static FreeRefFunction Instance = new RandBetween(); diff --git a/main/SS/Formula/Atp/WorkdayCalculator.cs b/main/SS/Formula/Atp/WorkdayCalculator.cs index 0fe7a33d8..ea176ce53 100644 --- a/main/SS/Formula/Atp/WorkdayCalculator.cs +++ b/main/SS/Formula/Atp/WorkdayCalculator.cs @@ -28,7 +28,7 @@ public class WorkdayCalculator { public static WorkdayCalculator instance = new WorkdayCalculator(); - private static Dictionary> weekendTypeMap = new Dictionary>(); + private static readonly Dictionary> weekendTypeMap = new Dictionary>(); /** * Constructor. */ diff --git a/main/SS/Formula/Atp/XLookupFunction.cs b/main/SS/Formula/Atp/XLookupFunction.cs index ec83fb2db..1ede95059 100644 --- a/main/SS/Formula/Atp/XLookupFunction.cs +++ b/main/SS/Formula/Atp/XLookupFunction.cs @@ -157,8 +157,8 @@ private ValueEval evaluate(int srcRowIndex, int srcColumnIndex, ValueEval lookup class NotFoundAreaEval : AreaEval { - private int _width; - private string _notFound; + private readonly int _width; + private readonly string _notFound; public NotFoundAreaEval(string notFound, int width) { _width = width; diff --git a/main/SS/Formula/CacheAreaEval.cs b/main/SS/Formula/CacheAreaEval.cs index c043e3ab6..7adca315f 100644 --- a/main/SS/Formula/CacheAreaEval.cs +++ b/main/SS/Formula/CacheAreaEval.cs @@ -9,7 +9,7 @@ namespace NPOI.SS.Formula { public class CacheAreaEval:AreaEvalBase { - ValueEval[] _values; + readonly ValueEval[] _values; public CacheAreaEval(AreaI ptg, ValueEval[] values):base(ptg) { _values = values; diff --git a/main/SS/Formula/CellCacheEntry.cs b/main/SS/Formula/CellCacheEntry.cs index eb630989f..0ab18f15a 100644 --- a/main/SS/Formula/CellCacheEntry.cs +++ b/main/SS/Formula/CellCacheEntry.cs @@ -27,7 +27,7 @@ public abstract class CellCacheEntry : ICacheEntry { public static CellCacheEntry[] EMPTY_ARRAY = { }; - private FormulaCellCacheEntrySet _consumingCells; + private readonly FormulaCellCacheEntrySet _consumingCells; private ValueEval _value; diff --git a/main/SS/Formula/CellEvaluationFrame.cs b/main/SS/Formula/CellEvaluationFrame.cs index 75119364a..2d2c0387d 100644 --- a/main/SS/Formula/CellEvaluationFrame.cs +++ b/main/SS/Formula/CellEvaluationFrame.cs @@ -31,8 +31,8 @@ namespace NPOI.SS.Formula class CellEvaluationFrame { - private FormulaCellCacheEntry _cce; - private ISet _sensitiveInputCells; + private readonly FormulaCellCacheEntry _cce; + private readonly ISet _sensitiveInputCells; private FormulaUsedBlankCellSet _usedBlankCellGroup; public CellEvaluationFrame(FormulaCellCacheEntry cce) diff --git a/main/SS/Formula/CollaboratingWorkbooksEnvironment.cs b/main/SS/Formula/CollaboratingWorkbooksEnvironment.cs index 3c80d8611..176f68baf 100644 --- a/main/SS/Formula/CollaboratingWorkbooksEnvironment.cs +++ b/main/SS/Formula/CollaboratingWorkbooksEnvironment.cs @@ -43,8 +43,8 @@ public class CollaboratingWorkbooksEnvironment { public static readonly CollaboratingWorkbooksEnvironment EMPTY = new CollaboratingWorkbooksEnvironment(); - private Dictionary _evaluatorsByName; - private WorkbookEvaluator[] _evaluators; + private readonly Dictionary _evaluatorsByName; + private readonly WorkbookEvaluator[] _evaluators; private bool _unhooked; private CollaboratingWorkbooksEnvironment() diff --git a/main/SS/Formula/Constant/ErrorConstant.cs b/main/SS/Formula/Constant/ErrorConstant.cs index 8ed253b2b..2f32faba2 100644 --- a/main/SS/Formula/Constant/ErrorConstant.cs +++ b/main/SS/Formula/Constant/ErrorConstant.cs @@ -38,7 +38,7 @@ public class ErrorConstant private static readonly ErrorConstant NUM = new ErrorConstant(FormulaError.NUM.Code); private static readonly ErrorConstant NA = new ErrorConstant(FormulaError.NA.Code); - private int _errorCode; + private readonly int _errorCode; /// /// Initializes a new instance of the class. diff --git a/main/SS/Formula/Eval/AreaEvalBase.cs b/main/SS/Formula/Eval/AreaEvalBase.cs index e9dfc57e1..788e07ca3 100644 --- a/main/SS/Formula/Eval/AreaEvalBase.cs +++ b/main/SS/Formula/Eval/AreaEvalBase.cs @@ -27,14 +27,14 @@ namespace NPOI.SS.Formula.Eval */ public abstract class AreaEvalBase : AreaEval { - private int _firstSheet; - private int _firstColumn; - private int _firstRow; - private int _lastSheet; - private int _lastColumn; - private int _lastRow; - private int _nColumns; - private int _nRows; + private readonly int _firstSheet; + private readonly int _firstColumn; + private readonly int _firstRow; + private readonly int _lastSheet; + private readonly int _lastColumn; + private readonly int _lastRow; + private readonly int _nColumns; + private readonly int _nRows; protected AreaEvalBase(ISheetRange sheets, int firstRow, int firstColumn, int lastRow, int lastColumn) { diff --git a/main/SS/Formula/Eval/ErrorEval.cs b/main/SS/Formula/Eval/ErrorEval.cs index fbd760ac9..cc0193fc2 100644 --- a/main/SS/Formula/Eval/ErrorEval.cs +++ b/main/SS/Formula/Eval/ErrorEval.cs @@ -30,7 +30,7 @@ namespace NPOI.SS.Formula.Eval */ public class ErrorEval : ValueEval { - private static Dictionary evals = new Dictionary(); + private static readonly Dictionary evals = new Dictionary(); /** #NULL! - Intersection of two cell ranges is empty */ public static readonly ErrorEval NULL_INTERSECTION = new ErrorEval(FormulaError.NULL); @@ -83,7 +83,7 @@ public static String GetText(int errorCode) return "~non~std~err(" + errorCode + ")~"; } - private FormulaError _error; + private readonly FormulaError _error; private ErrorEval(FormulaError error) { diff --git a/main/SS/Formula/Eval/ExternalNameEval.cs b/main/SS/Formula/Eval/ExternalNameEval.cs index 706727221..51ca7136c 100644 --- a/main/SS/Formula/Eval/ExternalNameEval.cs +++ b/main/SS/Formula/Eval/ExternalNameEval.cs @@ -27,7 +27,7 @@ namespace NPOI.SS.Formula.Eval */ public class ExternalNameEval : ValueEval { - private IEvaluationName _name; + private readonly IEvaluationName _name; public ExternalNameEval(IEvaluationName name) { diff --git a/main/SS/Formula/Eval/Forked/ForkedEvaluationCell.cs b/main/SS/Formula/Eval/Forked/ForkedEvaluationCell.cs index 6b3594c39..759c039c4 100644 --- a/main/SS/Formula/Eval/Forked/ForkedEvaluationCell.cs +++ b/main/SS/Formula/Eval/Forked/ForkedEvaluationCell.cs @@ -33,9 +33,9 @@ namespace NPOI.SS.Formula.Eval.Forked class ForkedEvaluationCell : IEvaluationCell { - private IEvaluationSheet _sheet; + private readonly IEvaluationSheet _sheet; /** corresponding cell from master workbook */ - private IEvaluationCell _masterCell; + private readonly IEvaluationCell _masterCell; private bool _boolValue; private CellType _cellType; private int _errorValue; diff --git a/main/SS/Formula/Eval/Forked/ForkedEvaluationSheet.cs b/main/SS/Formula/Eval/Forked/ForkedEvaluationSheet.cs index 93c829dc5..cdc73209b 100644 --- a/main/SS/Formula/Eval/Forked/ForkedEvaluationSheet.cs +++ b/main/SS/Formula/Eval/Forked/ForkedEvaluationSheet.cs @@ -35,11 +35,11 @@ namespace NPOI.SS.Formula.Eval.Forked class ForkedEvaluationSheet : IEvaluationSheet { - private IEvaluationSheet _masterSheet; + private readonly IEvaluationSheet _masterSheet; /** * Only cells which have been split are Put in this map. (This has been done to conserve memory). */ - private Dictionary _sharedCellsByRowCol; + private readonly Dictionary _sharedCellsByRowCol; public ForkedEvaluationSheet(IEvaluationSheet masterSheet) { @@ -127,8 +127,8 @@ public void ClearAllCachedResultValues() private class RowColKey : IComparable { - private int _rowIndex; - private int _columnIndex; + private readonly int _rowIndex; + private readonly int _columnIndex; public RowColKey(int rowIndex, int columnIndex) { diff --git a/main/SS/Formula/Eval/Forked/ForkedEvaluationWorkbook.cs b/main/SS/Formula/Eval/Forked/ForkedEvaluationWorkbook.cs index 66ca6d976..54be7b599 100644 --- a/main/SS/Formula/Eval/Forked/ForkedEvaluationWorkbook.cs +++ b/main/SS/Formula/Eval/Forked/ForkedEvaluationWorkbook.cs @@ -33,8 +33,8 @@ namespace NPOI.SS.Formula.Eval.Forked class ForkedEvaluationWorkbook : IEvaluationWorkbook { - private IEvaluationWorkbook _masterBook; - private Dictionary _sharedSheetsByName; + private readonly IEvaluationWorkbook _masterBook; + private readonly Dictionary _sharedSheetsByName; public ForkedEvaluationWorkbook(IEvaluationWorkbook master) { diff --git a/main/SS/Formula/Eval/Forked/ForkedEvaluator.cs b/main/SS/Formula/Eval/Forked/ForkedEvaluator.cs index a1b8e41c0..ac6dfbc38 100644 --- a/main/SS/Formula/Eval/Forked/ForkedEvaluator.cs +++ b/main/SS/Formula/Eval/Forked/ForkedEvaluator.cs @@ -39,8 +39,8 @@ namespace NPOI.SS.Formula.Eval.Forked public class ForkedEvaluator { - private WorkbookEvaluator _evaluator; - private ForkedEvaluationWorkbook _sewb; + private readonly WorkbookEvaluator _evaluator; + private readonly ForkedEvaluationWorkbook _sewb; private ForkedEvaluator(IEvaluationWorkbook masterWorkbook, IStabilityClassifier stabilityClassifier, UDFFinder udfFinder) { diff --git a/main/SS/Formula/Eval/FunctionNameEval.cs b/main/SS/Formula/Eval/FunctionNameEval.cs index e3e6e07c3..69b5c8410 100644 --- a/main/SS/Formula/Eval/FunctionNameEval.cs +++ b/main/SS/Formula/Eval/FunctionNameEval.cs @@ -25,7 +25,7 @@ namespace NPOI.SS.Formula.Eval public class FunctionNameEval : ValueEval { - private String _functionName; + private readonly String _functionName; /** * Creates a NameEval representing a function name diff --git a/main/SS/Formula/Eval/NumberEval.cs b/main/SS/Formula/Eval/NumberEval.cs index c7ed4c635..df7513cc7 100644 --- a/main/SS/Formula/Eval/NumberEval.cs +++ b/main/SS/Formula/Eval/NumberEval.cs @@ -35,7 +35,7 @@ public class NumberEval : NumericValueEval, StringValueEval public static readonly NumberEval ZERO = new NumberEval(0); - private double _value; + private readonly double _value; private String _stringValue; diff --git a/main/SS/Formula/Eval/RefEvalBase.cs b/main/SS/Formula/Eval/RefEvalBase.cs index 07d91fde7..e2a874144 100644 --- a/main/SS/Formula/Eval/RefEvalBase.cs +++ b/main/SS/Formula/Eval/RefEvalBase.cs @@ -4,10 +4,10 @@ namespace NPOI.SS.Formula.Eval { public abstract class RefEvalBase : RefEval { - private int _firstSheetIndex; - private int _lastSheetIndex; - private int _rowIndex; - private int _columnIndex; + private readonly int _firstSheetIndex; + private readonly int _lastSheetIndex; + private readonly int _rowIndex; + private readonly int _columnIndex; protected RefEvalBase(ISheetRange sheetRange, int rowIndex, int columnIndex) { diff --git a/main/SS/Formula/Eval/TwoOperandNumeric/TwoOperandNumericOperation.cs b/main/SS/Formula/Eval/TwoOperandNumeric/TwoOperandNumericOperation.cs index 7f68604cc..fedf01791 100644 --- a/main/SS/Formula/Eval/TwoOperandNumeric/TwoOperandNumericOperation.cs +++ b/main/SS/Formula/Eval/TwoOperandNumeric/TwoOperandNumericOperation.cs @@ -59,13 +59,13 @@ public override ValueEval Evaluate(int srcRowIndex, int srcColumnIndex, ValueEva private class ArrayEval : MatrixFunction.TwoArrayArg { - Func _evaluateFunc = null; + readonly Func _evaluateFunc = null; public ArrayEval(Func evalFunc) { _evaluateFunc = evalFunc; } - private MatrixFunction.MutableValueCollector instance = new MatrixFunction.MutableValueCollector(false, true); + private readonly MatrixFunction.MutableValueCollector instance = new MatrixFunction.MutableValueCollector(false, true); protected override double[] CollectValues(ValueEval arg) { diff --git a/main/SS/Formula/EvaluationCache.cs b/main/SS/Formula/EvaluationCache.cs index 40469be44..e3692f7b4 100644 --- a/main/SS/Formula/EvaluationCache.cs +++ b/main/SS/Formula/EvaluationCache.cs @@ -34,10 +34,10 @@ namespace NPOI.SS.Formula public class EvaluationCache { - private PlainCellCache _plainCellCache; - private FormulaCellCache _formulaCellCache; + private readonly PlainCellCache _plainCellCache; + private readonly FormulaCellCache _formulaCellCache; /** only used for testing. null otherwise */ - IEvaluationListener _evaluationListener; + readonly IEvaluationListener _evaluationListener; /* package */ public EvaluationCache(IEvaluationListener evaluationListener) @@ -136,9 +136,10 @@ public void NotifyUpdateCell(int bookIndex, int sheetIndex, IEvaluationCell cell public class EntryOperation : IEntryOperation { - BookSheetKey bsk; - int rowIndex, columnIndex; - IEvaluationListener evaluationListener; + readonly BookSheetKey bsk; + readonly int rowIndex; + readonly int columnIndex; + readonly IEvaluationListener evaluationListener; public EntryOperation(BookSheetKey bsk, int rowIndex, int columnIndex, IEvaluationListener evaluationListener) diff --git a/main/SS/Formula/EvaluationConditionalFormatRule.cs b/main/SS/Formula/EvaluationConditionalFormatRule.cs index d46dc2664..3b6da6aac 100644 --- a/main/SS/Formula/EvaluationConditionalFormatRule.cs +++ b/main/SS/Formula/EvaluationConditionalFormatRule.cs @@ -181,9 +181,9 @@ public class EvaluationConditionalFormatRule: IComparable { private double? value; - private String str; - private String format; - private DecimalFormat decimalTextFormat; + private readonly String str; + private readonly String format; + private readonly DecimalFormat decimalTextFormat; public ValueAndFormat(Double value, String format, DecimalFormat df) { @@ -310,32 +310,32 @@ public override int GetHashCode() } } - private WorkbookEvaluator workbookEvaluator; - private ISheet sheet; - private IConditionalFormatting formatting; - private IConditionalFormattingRule rule; + private readonly WorkbookEvaluator workbookEvaluator; + private readonly ISheet sheet; + private readonly IConditionalFormatting formatting; + private readonly IConditionalFormattingRule rule; /* cached values */ - private CellRangeAddress[] regions; + private readonly CellRangeAddress[] regions; /** * Depending on the rule type, it may want to know about certain values in the region when evaluating {@link #matches(CellReference)}, * such as top 10, unique, duplicate, average, etc. This collection stores those if needed so they are not repeatedly calculated */ - private Dictionary> meaningfulRegionValues = new Dictionary>(); - - private int priority; - private int formattingIndex; - private int ruleIndex; - private String formula1; - private String formula2; - private String text; + private readonly Dictionary> meaningfulRegionValues = new Dictionary>(); + + private readonly int priority; + private readonly int formattingIndex; + private readonly int ruleIndex; + private readonly String formula1; + private readonly String formula2; + private readonly String text; // cached for performance, used with cell text comparisons, which are case insensitive and need to be Locale aware (contains, starts with, etc.) - private String lowerText; + private readonly String lowerText; - private OperatorEnum @operator; - private ConditionType type; + private readonly OperatorEnum @operator; + private readonly ConditionType type; // cached for performance, to avoid reading the XMLBean every time a conditionally formatted cell is rendered - private ExcelNumberFormat numberFormat; + private readonly ExcelNumberFormat numberFormat; // cached for performance, used to format numeric cells for string comparisons. See Bug #61764 for explanation private DecimalFormat decimalTextFormat; public EvaluationConditionalFormatRule(WorkbookEvaluator workbookEvaluator, ISheet sheet, IConditionalFormatting formatting, int formattingIndex, IConditionalFormattingRule rule, int ruleIndex, CellRangeAddress[] regions) diff --git a/main/SS/Formula/EvaluationTracker.cs b/main/SS/Formula/EvaluationTracker.cs index d58d1c00e..1b13f7843 100644 --- a/main/SS/Formula/EvaluationTracker.cs +++ b/main/SS/Formula/EvaluationTracker.cs @@ -37,9 +37,9 @@ namespace NPOI.SS.Formula public class EvaluationTracker { // TODO - consider deleting this class and letting CellEvaluationFrame take care of itself - private IList _evaluationFrames; - private ISet _currentlyEvaluatingCells; - private EvaluationCache _cache; + private readonly IList _evaluationFrames; + private readonly ISet _currentlyEvaluatingCells; + private readonly EvaluationCache _cache; public EvaluationTracker(EvaluationCache cache) { diff --git a/main/SS/Formula/EvaluationWorkbook.cs b/main/SS/Formula/EvaluationWorkbook.cs index 08bb4e833..f20ab18fa 100644 --- a/main/SS/Formula/EvaluationWorkbook.cs +++ b/main/SS/Formula/EvaluationWorkbook.cs @@ -25,8 +25,8 @@ namespace NPOI.SS.Formula public class ExternalSheet { - private String _workbookName; - private String _sheetName; + private readonly String _workbookName; + private readonly String _sheetName; public ExternalSheet(String workbookName, String sheetName) { @@ -51,7 +51,7 @@ public String SheetName public class ExternalSheetRange : ExternalSheet { - private String _lastSheetName; + private readonly String _lastSheetName; public ExternalSheetRange(String workbookName, String firstSheetName, String lastSheetName) : base(workbookName, firstSheetName) { @@ -134,9 +134,9 @@ public interface IEvaluationWorkbook public class ExternalName { - private String _nameName; - private int _nameNumber; - private int _ix; + private readonly String _nameName; + private readonly int _nameNumber; + private readonly int _ix; public ExternalName(String nameName, int nameNumber, int ix) { diff --git a/main/SS/Formula/Formula.cs b/main/SS/Formula/Formula.cs index 875245e1a..cd28124e1 100644 --- a/main/SS/Formula/Formula.cs +++ b/main/SS/Formula/Formula.cs @@ -34,8 +34,8 @@ public class Formula private static readonly Formula EMPTY = new Formula(new byte[0], 0); /** immutable */ - private byte[] _byteEncoding; - private int _encodedTokenLen; + private readonly byte[] _byteEncoding; + private readonly int _encodedTokenLen; private Formula(byte[] byteEncoding, int encodedTokenLen) { diff --git a/main/SS/Formula/FormulaCellCache.cs b/main/SS/Formula/FormulaCellCache.cs index 806cf8a56..ed9ce780b 100644 --- a/main/SS/Formula/FormulaCellCache.cs +++ b/main/SS/Formula/FormulaCellCache.cs @@ -31,7 +31,7 @@ public interface IEntryOperation public class FormulaCellCache { - private Hashtable _formulaEntriesByCell; + private readonly Hashtable _formulaEntriesByCell; public FormulaCellCache() { diff --git a/main/SS/Formula/FormulaParser.cs b/main/SS/Formula/FormulaParser.cs index 0903c45f3..4a2f1eb27 100644 --- a/main/SS/Formula/FormulaParser.cs +++ b/main/SS/Formula/FormulaParser.cs @@ -62,8 +62,8 @@ public FormulaParseException(String msg) */ public class FormulaParser { - private String _formulaString; - private int _formulaLength; + private readonly String _formulaString; + private readonly int _formulaLength; /** points at the next character to be read (after the {@link #look} codepoint) */ private int _pointer; @@ -85,11 +85,11 @@ public class FormulaParser */ private bool _inIntersection; - private IFormulaParsingWorkbook _book; + private readonly IFormulaParsingWorkbook _book; private static SpreadsheetVersion _ssVersion; - private int _sheetIndex; - private int _rowIndex; // 0-based + private readonly int _sheetIndex; + private readonly int _rowIndex; // 0-based /** * Create the formula Parser, with the string that is To be @@ -664,11 +664,11 @@ private ParseNode ParseRangeable() return ParseNonRange(savePointer); } - private static String specHeaders = "Headers"; - private static String specAll = "All"; - private static String specData = "Data"; - private static String specTotals = "Totals"; - private static String specThisRow = "This Row"; + private static readonly String specHeaders = "Headers"; + private static readonly String specAll = "All"; + private static readonly String specData = "Data"; + private static readonly String specTotals = "Totals"; + private static readonly String specThisRow = "This Row"; /** * Parses a structured reference, returns it as area reference. @@ -1331,8 +1331,8 @@ public static PartType Get(bool hasLetters, bool hasDigits) return PartType.Row; } - private PartType _type; - private String _rep; + private readonly PartType _type; + private readonly String _rep; public SimpleRangePart(String rep, bool hasLetters, bool hasNumbers) { diff --git a/main/SS/Formula/FormulaType.cs b/main/SS/Formula/FormulaType.cs index eccd2bc7f..3c6021c16 100644 --- a/main/SS/Formula/FormulaType.cs +++ b/main/SS/Formula/FormulaType.cs @@ -21,7 +21,7 @@ namespace NPOI.SS.Formula { internal class SingleValueAttribute : Attribute { - private bool _isSingleValue=false; + private readonly bool _isSingleValue=false; public SingleValueAttribute(bool isSingleValue) { this._isSingleValue = isSingleValue; diff --git a/main/SS/Formula/FormulaUsedBlankCellSet.cs b/main/SS/Formula/FormulaUsedBlankCellSet.cs index 5d920db05..d41d9118d 100644 --- a/main/SS/Formula/FormulaUsedBlankCellSet.cs +++ b/main/SS/Formula/FormulaUsedBlankCellSet.cs @@ -26,8 +26,8 @@ namespace NPOI.SS.Formula public class BookSheetKey { - private int _bookIndex; - private int _sheetIndex; + private readonly int _bookIndex; + private readonly int _sheetIndex; public BookSheetKey(int bookIndex, int sheetIndex) { @@ -55,7 +55,7 @@ public class FormulaUsedBlankCellSet private class BlankCellSheetGroup { - private IList _rectangleGroups; + private readonly IList _rectangleGroups; private int _currentRowIndex; private int _firstColumnIndex; private int _lastColumnIndex; @@ -132,9 +132,9 @@ public bool ContainsCell(int rowIndex, int columnIndex) private class BlankCellRectangleGroup { - private int _firstRowIndex; - private int _firstColumnIndex; - private int _lastColumnIndex; + private readonly int _firstRowIndex; + private readonly int _firstColumnIndex; + private readonly int _lastColumnIndex; private int _lastRowIndex; public BlankCellRectangleGroup(int firstRowIndex, int firstColumnIndex, int lastColumnIndex) @@ -194,7 +194,7 @@ public override String ToString() } } - private Hashtable _sheetGroupsByBookSheet; + private readonly Hashtable _sheetGroupsByBookSheet; public FormulaUsedBlankCellSet() { diff --git a/main/SS/Formula/Function/FunctionDataBuilder.cs b/main/SS/Formula/Function/FunctionDataBuilder.cs index 89a04c962..e58c4bb31 100644 --- a/main/SS/Formula/Function/FunctionDataBuilder.cs +++ b/main/SS/Formula/Function/FunctionDataBuilder.cs @@ -31,10 +31,10 @@ class FunctionDataBuilder { private int _maxFunctionIndex; - private Dictionary _functionDataByName; - private Dictionary _functionDataByIndex; + private readonly Dictionary _functionDataByName; + private readonly Dictionary _functionDataByIndex; /** stores indexes of all functions with footnotes (i.e. whose definitions might Change) */ - private HashSet _mutatingFunctionIndexes; + private readonly HashSet _mutatingFunctionIndexes; public FunctionDataBuilder(int sizeEstimate) { diff --git a/main/SS/Formula/Function/FunctionMetadata.cs b/main/SS/Formula/Function/FunctionMetadata.cs index e62521fc4..d9da75b71 100644 --- a/main/SS/Formula/Function/FunctionMetadata.cs +++ b/main/SS/Formula/Function/FunctionMetadata.cs @@ -27,12 +27,12 @@ namespace NPOI.SS.Formula.Function public class FunctionMetadata { - private int _index; - private String _name; - private int _minParams; - private int _maxParams; - private byte _returnClassCode; - private byte[] _parameterClassCodes; + private readonly int _index; + private readonly String _name; + private readonly int _minParams; + private readonly int _maxParams; + private readonly byte _returnClassCode; + private readonly byte[] _parameterClassCodes; private const short FUNCTION_MAX_PARAMS = 30; /* package */ internal FunctionMetadata(int index, String name, int minParams, int maxParams, diff --git a/main/SS/Formula/Function/FunctionMetadataRegistry.cs b/main/SS/Formula/Function/FunctionMetadataRegistry.cs index e5f90a3a0..55ab22f15 100644 --- a/main/SS/Formula/Function/FunctionMetadataRegistry.cs +++ b/main/SS/Formula/Function/FunctionMetadataRegistry.cs @@ -40,8 +40,8 @@ public class FunctionMetadataRegistry public const short FUNCTION_INDEX_EXTERNAL = 255; private static FunctionMetadataRegistry _instance; - private FunctionMetadata[] _functionDataByIndex; - private Dictionary _functionDataByName; + private readonly FunctionMetadata[] _functionDataByIndex; + private readonly Dictionary _functionDataByName; private static FunctionMetadataRegistry GetInstance() { diff --git a/main/SS/Formula/Functions/AggregateFunction.cs b/main/SS/Formula/Functions/AggregateFunction.cs index 5a66628ab..6c4776361 100644 --- a/main/SS/Formula/Functions/AggregateFunction.cs +++ b/main/SS/Formula/Functions/AggregateFunction.cs @@ -165,8 +165,8 @@ protected internal override double Evaluate(double[] values) public class SubtotalInstance : AggregateFunction { - private AggregateFunction _func; - private bool _countHiddenRows; + private readonly AggregateFunction _func; + private readonly bool _countHiddenRows; public SubtotalInstance(AggregateFunction func, bool countHiddenRows) { _func = func; @@ -200,7 +200,7 @@ public bool IsHiddenRowCounted public class LargeSmall : Fixed2ArgFunction { - private bool _isLarge; + private readonly bool _isLarge; protected LargeSmall(bool isLarge) { _isLarge = isLarge; @@ -339,7 +339,7 @@ internal static Function SubtotalInstance(Function func, bool countHiddenRows) } internal class ValueCollector : MultiOperandNumericFunction { - private static ValueCollector instance = new ValueCollector(); + private static readonly ValueCollector instance = new ValueCollector(); public ValueCollector() : base(false, false) { diff --git a/main/SS/Formula/Functions/CalendarFieldFunction.cs b/main/SS/Formula/Functions/CalendarFieldFunction.cs index a012b819d..f49f43900 100644 --- a/main/SS/Formula/Functions/CalendarFieldFunction.cs +++ b/main/SS/Formula/Functions/CalendarFieldFunction.cs @@ -45,7 +45,7 @@ public class CalendarFieldFunction : Fixed1ArgFunction public static readonly Function MINUTE = new CalendarFieldFunction(MINUTE_ID); public static readonly Function SECOND = new CalendarFieldFunction(SECOND_ID); - private int _dateFieldId; + private readonly int _dateFieldId; private CalendarFieldFunction(int dateFieldId) { diff --git a/main/SS/Formula/Functions/Count.cs b/main/SS/Formula/Functions/Count.cs index ccf28256b..751b0cfac 100644 --- a/main/SS/Formula/Functions/Count.cs +++ b/main/SS/Formula/Functions/Count.cs @@ -36,7 +36,7 @@ namespace NPOI.SS.Formula.Functions */ public class Count : Function { - private IMatchPredicate _predicate; + private readonly IMatchPredicate _predicate; public Count() { @@ -92,7 +92,7 @@ public bool Matches(ValueEval valueEval) return false; } } - private static IMatchPredicate defaultPredicate = new DefaultPredicate(); + private static readonly IMatchPredicate defaultPredicate = new DefaultPredicate(); /// /// matches hidden rows but not subtotals @@ -135,8 +135,8 @@ public bool Matches(TwoDEval areEval, int rowIndex, int columnIndex) } } - private static IMatchPredicate subtotalPredicate = new SubtotalPredicate(); - private static I_MatchAreaPredicate subtotalVisibleOnlyPredicate = new SubtotalVisibleOnlyPredicate(); + private static readonly IMatchPredicate subtotalPredicate = new SubtotalPredicate(); + private static readonly I_MatchAreaPredicate subtotalVisibleOnlyPredicate = new SubtotalVisibleOnlyPredicate(); /** * Create an instance of Count to use in {@link Subtotal} *

diff --git a/main/SS/Formula/Functions/Counta.cs b/main/SS/Formula/Functions/Counta.cs index 555f495ea..e996d49dd 100644 --- a/main/SS/Formula/Functions/Counta.cs +++ b/main/SS/Formula/Functions/Counta.cs @@ -32,7 +32,7 @@ namespace NPOI.SS.Formula.Functions */ public class Counta : Function { - private IMatchPredicate _predicate; + private readonly IMatchPredicate _predicate; public Counta() { @@ -71,7 +71,7 @@ public ValueEval Evaluate(ValueEval[] args, int srcCellRow, int srcCellCol) return new NumberEval(temp); } - private static IMatchPredicate defaultPredicate = new DefaultPredicate(); + private static readonly IMatchPredicate defaultPredicate = new DefaultPredicate(); public class DefaultPredicate : IMatchPredicate { public bool Matches(ValueEval valueEval) @@ -88,7 +88,7 @@ public bool Matches(ValueEval valueEval) return true; } } - private static IMatchPredicate subtotalPredicate = new SubtotalPredicate(); + private static readonly IMatchPredicate subtotalPredicate = new SubtotalPredicate(); public class SubtotalPredicate : I_MatchAreaPredicate { public bool Matches(ValueEval valueEval) @@ -105,7 +105,7 @@ public bool Matches(TwoDEval areEval, int rowIndex, int columnIndex) } } - private static IMatchPredicate subtotalVisibleOnlyPredicate = new SubtotalVisibleOnlyPredicate(); + private static readonly IMatchPredicate subtotalVisibleOnlyPredicate = new SubtotalVisibleOnlyPredicate(); public class SubtotalVisibleOnlyPredicate : I_MatchAreaPredicate { public bool Matches(ValueEval valueEval) diff --git a/main/SS/Formula/Functions/Countif.cs b/main/SS/Formula/Functions/Countif.cs index 11fd049da..7eb8a1706 100644 --- a/main/SS/Formula/Functions/Countif.cs +++ b/main/SS/Formula/Functions/Countif.cs @@ -56,8 +56,8 @@ public class CmpOp public static readonly CmpOp OP_LT = op("<", LT); public static readonly CmpOp OP_GT = op(">", GT); public static readonly CmpOp OP_GE = op(">=", GE); - private String _representation; - private int _code; + private readonly String _representation; + private readonly int _code; private static CmpOp op(String rep, int code) { @@ -175,7 +175,7 @@ public String Representation } public abstract class MatcherBase : IMatchPredicate { - private CmpOp _operator; + private readonly CmpOp _operator; public MatcherBase(CmpOp operator1) { @@ -213,7 +213,7 @@ public override String ToString() public class ErrorMatcher : MatcherBase { - private int _value; + private readonly int _value; public ErrorMatcher(int errorCode, CmpOp operator1) : base(operator1) @@ -249,7 +249,7 @@ public int Value private class NumberMatcher : MatcherBase { - private double _value; + private readonly double _value; public NumberMatcher(double value, CmpOp optr) : base(optr) @@ -318,7 +318,7 @@ protected override string ValueText private class BooleanMatcher : MatcherBase { - private int _value; + private readonly int _value; public BooleanMatcher(bool value, CmpOp optr) : base(optr) @@ -390,9 +390,9 @@ protected override string ValueText internal class StringMatcher : MatcherBase { - private String _value; - private CmpOp _operator; - private Regex _pattern; + private readonly String _value; + private readonly CmpOp _operator; + private readonly Regex _pattern; public StringMatcher(String value, CmpOp optr) : base(optr) { diff --git a/main/SS/Formula/Functions/FactDouble.cs b/main/SS/Formula/Functions/FactDouble.cs index 87df85e52..2c82cae43 100644 --- a/main/SS/Formula/Functions/FactDouble.cs +++ b/main/SS/Formula/Functions/FactDouble.cs @@ -49,7 +49,7 @@ public class FactDouble : Fixed1ArgFunction, FreeRefFunction public static FreeRefFunction instance = new FactDouble(); //Caching of previously calculated factorial for speed - static Dictionary cache = new Dictionary(); + static readonly Dictionary cache = new Dictionary(); public override ValueEval Evaluate(int srcRowIndex, int srcColumnIndex, ValueEval numberVE) { diff --git a/main/SS/Formula/Functions/LinearRegressionFunction.cs b/main/SS/Formula/Functions/LinearRegressionFunction.cs index 50df58503..0e92eee62 100644 --- a/main/SS/Formula/Functions/LinearRegressionFunction.cs +++ b/main/SS/Formula/Functions/LinearRegressionFunction.cs @@ -42,7 +42,7 @@ public class LinearRegressionFunction : Fixed2ArgFunction private abstract class ValueArray : ValueVector { - private int _size; + private readonly int _size; protected ValueArray(int size) { _size = size; @@ -70,7 +70,7 @@ public int Size private class SingleCellValueArray : ValueArray { - private ValueEval _value; + private readonly ValueEval _value; public SingleCellValueArray(ValueEval value) : base(1) { @@ -85,8 +85,8 @@ protected override ValueEval GetItemInternal(int index) private class RefValueArray : ValueArray { - private RefEval _ref; - private int _width; + private readonly RefEval _ref; + private readonly int _width; public RefValueArray(RefEval ref1) : base(ref1.NumberOfSheets) { @@ -103,8 +103,8 @@ protected override ValueEval GetItemInternal(int index) private class AreaValueArray : ValueArray { - private TwoDEval _ae; - private int _width; + private readonly TwoDEval _ae; + private readonly int _width; public AreaValueArray(TwoDEval ae) : base(ae.Width * ae.Height) diff --git a/main/SS/Formula/Functions/Lookup.cs b/main/SS/Formula/Functions/Lookup.cs index f21e9bd5f..17fb81967 100644 --- a/main/SS/Formula/Functions/Lookup.cs +++ b/main/SS/Formula/Functions/Lookup.cs @@ -23,7 +23,7 @@ namespace NPOI.SS.Formula.Functions public class SimpleValueVector : ValueVector { - private ValueEval[] _values; + private readonly ValueEval[] _values; public SimpleValueVector(ValueEval[] values) { diff --git a/main/SS/Formula/Functions/LookupUtils.cs b/main/SS/Formula/Functions/LookupUtils.cs index 1e1717180..03cf24649 100644 --- a/main/SS/Formula/Functions/LookupUtils.cs +++ b/main/SS/Formula/Functions/LookupUtils.cs @@ -33,8 +33,8 @@ namespace NPOI.SS.Formula.Functions */ internal class LookupUtils { - private static Dictionary matchModeMap = new Dictionary(); - private static Dictionary searchModeMap = new Dictionary(); + private static readonly Dictionary matchModeMap = new Dictionary(); + private static readonly Dictionary searchModeMap = new Dictionary(); static LookupUtils() { @@ -80,9 +80,9 @@ public enum SearchMode internal class RowVector : ValueVector { - private AreaEval _tableArray; - private int _size; - private int _rowIndex; + private readonly AreaEval _tableArray; + private readonly int _size; + private readonly int _rowIndex; public RowVector(AreaEval tableArray, int rowIndex) { @@ -118,9 +118,9 @@ public int Size internal class ColumnVector : ValueVector { - private AreaEval _tableArray; - private int _size; - private int _columnIndex; + private readonly AreaEval _tableArray; + private readonly int _size; + private readonly int _columnIndex; public ColumnVector(AreaEval tableArray, int columnIndex) { @@ -156,8 +156,8 @@ public int Size private class SheetVector : ValueVector { - private RefEval _re; - private int _size; + private readonly RefEval _re; + private readonly int _size; public SheetVector(RefEval re) { @@ -216,10 +216,10 @@ public static ValueVector CreateVector(RefEval re) private class StringLookupComparer : LookupValueComparerBase { - protected String _value; - protected Regex _wildCardPattern; - protected bool _matchExact; - protected bool _isMatchFunction; + protected readonly String _value; + protected readonly Regex _wildCardPattern; + protected readonly bool _matchExact; + protected readonly bool _isMatchFunction; public StringLookupComparer(StringEval se, bool matchExact, bool isMatchFunction) : base(se) @@ -278,7 +278,7 @@ protected override String ConvertToString(ValueEval other) private class NumberLookupComparer : LookupValueComparerBase { - private double _value; + private readonly double _value; public NumberLookupComparer(NumberEval ne) : base(ne) @@ -766,10 +766,10 @@ private static LookupValueComparer CreateTolerantLookupComparer(ValueEval lookup */ public class CompareResult { - private bool _isTypeMismatch; - private bool _isLessThan; - private bool _isEqual; - private bool _isGreaterThan; + private readonly bool _isTypeMismatch; + private readonly bool _isLessThan; + private readonly bool _isEqual; + private readonly bool _isGreaterThan; private CompareResult(bool IsTypeMismatch, int simpleCompareResult) { @@ -915,7 +915,7 @@ public void NarrowSearch(int midIx, bool isLessThan) } internal class BooleanLookupComparer : LookupValueComparerBase { - private bool _value; + private readonly bool _value; public BooleanLookupComparer(BoolEval be) : base(be) @@ -967,7 +967,7 @@ public interface LookupValueComparer internal abstract class LookupValueComparerBase : LookupValueComparer { - private Type _targetType; + private readonly Type _targetType; protected LookupValueComparerBase(ValueEval targetValue) { if (targetValue == null) diff --git a/main/SS/Formula/Functions/Match.cs b/main/SS/Formula/Functions/Match.cs index aca296e89..346365fc6 100644 --- a/main/SS/Formula/Functions/Match.cs +++ b/main/SS/Formula/Functions/Match.cs @@ -27,7 +27,7 @@ namespace NPOI.SS.Formula.Functions public class SingleValueVector : ValueVector { - private ValueEval _value; + private readonly ValueEval _value; public SingleValueVector(ValueEval value) { diff --git a/main/SS/Formula/Functions/MultiOperandNumericFunction.cs b/main/SS/Formula/Functions/MultiOperandNumericFunction.cs index 93ffa5514..89138f4c9 100644 --- a/main/SS/Formula/Functions/MultiOperandNumericFunction.cs +++ b/main/SS/Formula/Functions/MultiOperandNumericFunction.cs @@ -29,9 +29,9 @@ namespace NPOI.SS.Formula.Functions */ public abstract class MultiOperandNumericFunction : Function { - static double[] EMPTY_DOUBLE_ARRAY = { }; - private bool _isReferenceBoolCounted; - private bool _isBlankCounted; + static readonly double[] EMPTY_DOUBLE_ARRAY = { }; + private readonly bool _isReferenceBoolCounted; + private readonly bool _isBlankCounted; protected MultiOperandNumericFunction(bool isReferenceBoolCounted, bool isBlankCounted) { diff --git a/main/SS/Formula/Functions/NotImplementedFunction.cs b/main/SS/Formula/Functions/NotImplementedFunction.cs index f586febfd..ff61964c8 100644 --- a/main/SS/Formula/Functions/NotImplementedFunction.cs +++ b/main/SS/Formula/Functions/NotImplementedFunction.cs @@ -36,7 +36,7 @@ namespace NPOI.SS.Formula.Functions public class NotImplementedFunction : Function { - private String _functionName; + private readonly String _functionName; internal NotImplementedFunction() { _functionName = GetType().Name; diff --git a/main/SS/Formula/Functions/Offset.cs b/main/SS/Formula/Functions/Offset.cs index b21b37dfc..867b1d7cf 100644 --- a/main/SS/Formula/Functions/Offset.cs +++ b/main/SS/Formula/Functions/Offset.cs @@ -72,8 +72,8 @@ public ErrorEval GetError() public class LinearOffsetRange { - private int _offset; - private int _Length; + private readonly int _offset; + private readonly int _Length; public LinearOffsetRange(int offset, int length) { @@ -154,12 +154,12 @@ public override String ToString() private class BaseRef { private const int INVALID_SHEET_INDEX = -1; - private int _firstRowIndex; - private int _firstColumnIndex; - private int _width; - private int _height; - private RefEval _refEval; - private AreaEval _areaEval; + private readonly int _firstRowIndex; + private readonly int _firstColumnIndex; + private readonly int _width; + private readonly int _height; + private readonly RefEval _refEval; + private readonly AreaEval _areaEval; public BaseRef(RefEval re) { diff --git a/main/SS/Formula/Functions/Text/LeftRight.cs b/main/SS/Formula/Functions/Text/LeftRight.cs index 58890f22b..ab2cb907c 100644 --- a/main/SS/Formula/Functions/Text/LeftRight.cs +++ b/main/SS/Formula/Functions/Text/LeftRight.cs @@ -29,8 +29,8 @@ namespace NPOI.SS.Formula.Functions */ public class LeftRight : Var1or2ArgFunction { - private static ValueEval DEFAULT_ARG1 = new NumberEval(1.0); - private bool _isLeft; + private static readonly ValueEval DEFAULT_ARG1 = new NumberEval(1.0); + private readonly bool _isLeft; public LeftRight(bool isLeft) { _isLeft = isLeft; diff --git a/main/SS/Formula/Functions/Text/SearchFind.cs b/main/SS/Formula/Functions/Text/SearchFind.cs index 7f4845361..3e4660492 100644 --- a/main/SS/Formula/Functions/Text/SearchFind.cs +++ b/main/SS/Formula/Functions/Text/SearchFind.cs @@ -6,7 +6,7 @@ namespace NPOI.SS.Formula.Functions public class SearchFind : Var2or3ArgFunction { - private bool _isCaseSensitive; + private readonly bool _isCaseSensitive; public SearchFind(bool isCaseSensitive) { diff --git a/main/SS/Formula/Functions/XYNumericFunction.cs b/main/SS/Formula/Functions/XYNumericFunction.cs index 50fa17964..b70f31287 100644 --- a/main/SS/Formula/Functions/XYNumericFunction.cs +++ b/main/SS/Formula/Functions/XYNumericFunction.cs @@ -36,7 +36,7 @@ public abstract class XYNumericFunction : Fixed2ArgFunction private abstract class ValueArray : ValueVector { - private int _size; + private readonly int _size; protected ValueArray(int size) { _size = size; @@ -62,7 +62,7 @@ public int Size private class SingleCellValueArray : ValueArray { - private ValueEval _value; + private readonly ValueEval _value; public SingleCellValueArray(ValueEval value) : base(1) { @@ -76,8 +76,8 @@ protected override ValueEval GetItemInternal(int index) } private class RefValueArray : ValueArray { - private RefEval _ref; - private int _width; + private readonly RefEval _ref; + private readonly int _width; public RefValueArray(RefEval ref1) : base(ref1.NumberOfSheets) @@ -93,8 +93,8 @@ protected override ValueEval GetItemInternal(int index) } private class AreaValueArray : ValueArray { - private TwoDEval _ae; - private int _width; + private readonly TwoDEval _ae; + private readonly int _width; public AreaValueArray(TwoDEval ae) : base(ae.Width * ae.Height) @@ -112,8 +112,8 @@ protected override ValueEval GetItemInternal(int index) protected class DoubleArrayPair { - private double[] _xArray; - private double[] _yArray; + private readonly double[] _xArray; + private readonly double[] _yArray; public DoubleArrayPair(double[] xArray, double[] yArray) { diff --git a/main/SS/Formula/LazyAreaEval.cs b/main/SS/Formula/LazyAreaEval.cs index a8ce6e353..0e4bc7250 100644 --- a/main/SS/Formula/LazyAreaEval.cs +++ b/main/SS/Formula/LazyAreaEval.cs @@ -30,7 +30,7 @@ namespace NPOI.SS.Formula public class LazyAreaEval : AreaEvalBase { - private SheetRangeEvaluator _evaluator; + private readonly SheetRangeEvaluator _evaluator; public LazyAreaEval(AreaI ptg, SheetRangeEvaluator evaluator) : base(ptg, evaluator) diff --git a/main/SS/Formula/LazyRefEval.cs b/main/SS/Formula/LazyRefEval.cs index 50d1ed639..7704c7182 100644 --- a/main/SS/Formula/LazyRefEval.cs +++ b/main/SS/Formula/LazyRefEval.cs @@ -33,7 +33,7 @@ namespace NPOI.SS.Formula public class LazyRefEval : RefEvalBase { - private SheetRangeEvaluator _evaluator; + private readonly SheetRangeEvaluator _evaluator; public LazyRefEval(int rowIndex, int columnIndex, SheetRangeEvaluator sre) :base(sre, rowIndex, columnIndex) diff --git a/main/SS/Formula/NameIdentifier.cs b/main/SS/Formula/NameIdentifier.cs index 59613bb43..dd25b68d1 100644 --- a/main/SS/Formula/NameIdentifier.cs +++ b/main/SS/Formula/NameIdentifier.cs @@ -22,8 +22,8 @@ namespace NPOI.SS.Formula public class NameIdentifier { - private String _name; - private bool _isQuoted; + private readonly String _name; + private readonly bool _isQuoted; public NameIdentifier(String name, bool isQuoted) { diff --git a/main/SS/Formula/OperandClassTransformer.cs b/main/SS/Formula/OperandClassTransformer.cs index cf3623ab3..27f9f79bd 100644 --- a/main/SS/Formula/OperandClassTransformer.cs +++ b/main/SS/Formula/OperandClassTransformer.cs @@ -51,7 +51,7 @@ namespace NPOI.SS.Formula class OperandClassTransformer { - private FormulaType _formulaType; + private readonly FormulaType _formulaType; public OperandClassTransformer(FormulaType formulaType) { diff --git a/main/SS/Formula/OperationEvaluationContext.cs b/main/SS/Formula/OperationEvaluationContext.cs index 5736ca6db..a66622b6b 100644 --- a/main/SS/Formula/OperationEvaluationContext.cs +++ b/main/SS/Formula/OperationEvaluationContext.cs @@ -20,13 +20,13 @@ namespace NPOI.SS.Formula public class OperationEvaluationContext { public static readonly FreeRefFunction UDF = UserDefinedFunction.instance; - private IEvaluationWorkbook _workbook; - private int _sheetIndex; - private int _rowIndex; - private int _columnIndex; - private EvaluationTracker _tracker; - private bool _isSingleValue; - private WorkbookEvaluator _bookEvaluator; + private readonly IEvaluationWorkbook _workbook; + private readonly int _sheetIndex; + private readonly int _rowIndex; + private readonly int _columnIndex; + private readonly EvaluationTracker _tracker; + private readonly bool _isSingleValue; + private readonly WorkbookEvaluator _bookEvaluator; private bool _isInArrayContext; public OperationEvaluationContext(WorkbookEvaluator bookEvaluator, IEvaluationWorkbook workbook, int sheetIndex, int srcRowNum, diff --git a/main/SS/Formula/OperationEvaluatorFactory.cs b/main/SS/Formula/OperationEvaluatorFactory.cs index 41df31acf..80d9397c0 100644 --- a/main/SS/Formula/OperationEvaluatorFactory.cs +++ b/main/SS/Formula/OperationEvaluatorFactory.cs @@ -36,7 +36,7 @@ class OperationEvaluatorFactory { private static Type[] OPERATION_CONSTRUCTOR_CLASS_ARRAY = new Type[] { typeof(Ptg) }; - private static Hashtable _instancesByPtgClass = InitialiseInstancesMap(); + private static readonly Hashtable _instancesByPtgClass = InitialiseInstancesMap(); private OperationEvaluatorFactory() { diff --git a/main/SS/Formula/PTG/AreaI.cs b/main/SS/Formula/PTG/AreaI.cs index 2059b5a0b..36e262d71 100644 --- a/main/SS/Formula/PTG/AreaI.cs +++ b/main/SS/Formula/PTG/AreaI.cs @@ -46,10 +46,10 @@ public interface AreaI public class OffsetArea: AreaI { - private int _firstColumn; - private int _firstRow; - private int _lastColumn; - private int _lastRow; + private readonly int _firstColumn; + private readonly int _firstRow; + private readonly int _lastColumn; + private readonly int _lastRow; public OffsetArea(int baseRow, int baseColumn, int relFirstRowIx, int relLastRowIx, int relFirstColIx, int relLastColIx) { diff --git a/main/SS/Formula/PTG/ArrayPtg.cs b/main/SS/Formula/PTG/ArrayPtg.cs index d3feaadaf..752281c26 100644 --- a/main/SS/Formula/PTG/ArrayPtg.cs +++ b/main/SS/Formula/PTG/ArrayPtg.cs @@ -51,14 +51,14 @@ public class ArrayPtg : Ptg //private static byte[] DEFAULT_RESERVED_DATA = new byte[RESERVED_FIELD_LEN]; // 7 bytes of data (stored as an int, short and byte here) - private int _reserved0Int; - private int _reserved1Short; - private int _reserved2Byte; + private readonly int _reserved0Int; + private readonly int _reserved1Short; + private readonly int _reserved2Byte; // data from these fields comes after the Ptg data of all tokens in current formula - private int _nColumns; - private int _nRows; - private object[] _arrayValues; + private readonly int _nColumns; + private readonly int _nRows; + private readonly object[] _arrayValues; ArrayPtg(int reserved0, int reserved1, int reserved2, int nColumns, int nRows, object[] arrayValues) { @@ -263,9 +263,9 @@ public override byte DefaultOperandClass */ public class Initial : Ptg { - private int _reserved0; - private int _reserved1; - private int _reserved2; + private readonly int _reserved0; + private readonly int _reserved1; + private readonly int _reserved2; public Initial(ILittleEndianInput in1) { diff --git a/main/SS/Formula/PTG/AttrPtg.cs b/main/SS/Formula/PTG/AttrPtg.cs index e08da45f7..6f6be3a49 100644 --- a/main/SS/Formula/PTG/AttrPtg.cs +++ b/main/SS/Formula/PTG/AttrPtg.cs @@ -38,19 +38,19 @@ public class AttrPtg : ControlPtg private short field_2_data; /** only used for tAttrChoose: table of offsets to starts of args */ - private int[] _jumpTable; + private readonly int[] _jumpTable; /** only used for tAttrChoose: offset to the tFuncVar for CHOOSE() */ - private int _chooseFuncOffset; + private readonly int _chooseFuncOffset; // flags 'volatile' and 'space', can be combined. // OOO spec says other combinations are theoretically possible but not likely to occur. - private static BitField semiVolatile = BitFieldFactory.GetInstance(0x01); - private static BitField optiIf = BitFieldFactory.GetInstance(0x02); - private static BitField optiChoose = BitFieldFactory.GetInstance(0x04); - private static BitField optiSkip = BitFieldFactory.GetInstance(0x08); // skip - private static BitField optiSum = BitFieldFactory.GetInstance(0x10); - private static BitField baxcel = BitFieldFactory.GetInstance(0x20); // 'assignment-style formula in a macro sheet' - private static BitField space = BitFieldFactory.GetInstance(0x40); + private static readonly BitField semiVolatile = BitFieldFactory.GetInstance(0x01); + private static readonly BitField optiIf = BitFieldFactory.GetInstance(0x02); + private static readonly BitField optiChoose = BitFieldFactory.GetInstance(0x04); + private static readonly BitField optiSkip = BitFieldFactory.GetInstance(0x08); // skip + private static readonly BitField optiSum = BitFieldFactory.GetInstance(0x10); + private static readonly BitField baxcel = BitFieldFactory.GetInstance(0x20); // 'assignment-style formula in a macro sheet' + private static readonly BitField space = BitFieldFactory.GetInstance(0x40); public static readonly AttrPtg SUM = new AttrPtg(0x0010, 0, null, -1); diff --git a/main/SS/Formula/ParseNode.cs b/main/SS/Formula/ParseNode.cs index d95c719cc..5ff2d8487 100644 --- a/main/SS/Formula/ParseNode.cs +++ b/main/SS/Formula/ParseNode.cs @@ -30,10 +30,10 @@ class ParseNode { public static ParseNode[] EMPTY_ARRAY = { }; - private Ptg _token; - private ParseNode[] _children; - private bool _isIf; - private int _tokenCount; + private readonly Ptg _token; + private readonly ParseNode[] _children; + private readonly bool _isIf; + private readonly int _tokenCount; public ParseNode(Ptg token, ParseNode[] children) { @@ -195,7 +195,7 @@ public ParseNode[] GetChildren() private class TokenCollector { - private Ptg[] _ptgs; + private readonly Ptg[] _ptgs; private int _offset; public TokenCollector(int tokenCount) diff --git a/main/SS/Formula/PlainCellCache.cs b/main/SS/Formula/PlainCellCache.cs index ef0e398e9..e09052d55 100644 --- a/main/SS/Formula/PlainCellCache.cs +++ b/main/SS/Formula/PlainCellCache.cs @@ -25,9 +25,9 @@ namespace NPOI.SS.Formula public class Loc { - private long _bookSheetColumn; + private readonly long _bookSheetColumn; - private int _rowIndex; + private readonly int _rowIndex; public Loc(int bookIndex, int sheetIndex, int rowIndex, int columnIndex) { @@ -93,7 +93,7 @@ public int BookIndex public class PlainCellCache { - private Hashtable _plainValueEntriesByLoc; + private readonly Hashtable _plainValueEntriesByLoc; public PlainCellCache() { diff --git a/main/SS/Formula/SharedFormula.cs b/main/SS/Formula/SharedFormula.cs index 11ae8e23e..e9fb68004 100644 --- a/main/SS/Formula/SharedFormula.cs +++ b/main/SS/Formula/SharedFormula.cs @@ -22,8 +22,8 @@ namespace NPOI.SS.Formula.PTG public class SharedFormula { - private int _columnWrappingMask; - private int _rowWrappingMask; + private readonly int _columnWrappingMask; + private readonly int _rowWrappingMask; public SharedFormula(SpreadsheetVersion ssVersion) { diff --git a/main/SS/Formula/SheetRangeEvaluator.cs b/main/SS/Formula/SheetRangeEvaluator.cs index fedd3d397..104854e84 100644 --- a/main/SS/Formula/SheetRangeEvaluator.cs +++ b/main/SS/Formula/SheetRangeEvaluator.cs @@ -27,9 +27,9 @@ namespace NPOI.SS.Formula */ public class SheetRangeEvaluator : ISheetRange { - private int _firstSheetIndex; - private int _lastSheetIndex; - private SheetRefEvaluator[] _sheetEvaluators; + private readonly int _firstSheetIndex; + private readonly int _lastSheetIndex; + private readonly SheetRefEvaluator[] _sheetEvaluators; public SheetRangeEvaluator(int firstSheetIndex, int lastSheetIndex, SheetRefEvaluator[] sheetEvaluators) { diff --git a/main/SS/Formula/SheetRefEvaluator.cs b/main/SS/Formula/SheetRefEvaluator.cs index e2b34c934..2d8cf28f1 100644 --- a/main/SS/Formula/SheetRefEvaluator.cs +++ b/main/SS/Formula/SheetRefEvaluator.cs @@ -31,10 +31,10 @@ namespace NPOI.SS.Formula public class SheetRefEvaluator { - private WorkbookEvaluator _bookEvaluator; - private EvaluationTracker _tracker; + private readonly WorkbookEvaluator _bookEvaluator; + private readonly EvaluationTracker _tracker; private IEvaluationSheet _sheet; - private int _sheetIndex; + private readonly int _sheetIndex; public SheetRefEvaluator(WorkbookEvaluator bookEvaluator, EvaluationTracker tracker, int sheetIndex) { diff --git a/main/SS/Formula/Udf/AggregatingUDFFinder.cs b/main/SS/Formula/Udf/AggregatingUDFFinder.cs index e471e163e..dec7b8daa 100644 --- a/main/SS/Formula/Udf/AggregatingUDFFinder.cs +++ b/main/SS/Formula/Udf/AggregatingUDFFinder.cs @@ -29,7 +29,7 @@ namespace NPOI.SS.Formula.UDF public class AggregatingUDFFinder : UDFFinder { - private List _usedToolPacks = new List(); + private readonly List _usedToolPacks = new List(); public AggregatingUDFFinder(params UDFFinder[] usedToolPacks) { diff --git a/main/SS/Formula/Udf/DefaultUDFFinder.cs b/main/SS/Formula/Udf/DefaultUDFFinder.cs index f457dbf99..a7ac4c448 100644 --- a/main/SS/Formula/Udf/DefaultUDFFinder.cs +++ b/main/SS/Formula/Udf/DefaultUDFFinder.cs @@ -29,7 +29,7 @@ namespace NPOI.SS.Formula.UDF */ public class DefaultUDFFinder : UDFFinder { - private Dictionary _functionsByName; + private readonly Dictionary _functionsByName; public DefaultUDFFinder(String[] functionNames, FreeRefFunction[] functionImpls) { diff --git a/main/SS/Formula/Udf/IndexedUDFFinder.cs b/main/SS/Formula/Udf/IndexedUDFFinder.cs index 94ba45a49..49f788ed5 100644 --- a/main/SS/Formula/Udf/IndexedUDFFinder.cs +++ b/main/SS/Formula/Udf/IndexedUDFFinder.cs @@ -27,7 +27,7 @@ namespace NPOI.SS.Formula.UDF */ public class IndexedUDFFinder : AggregatingUDFFinder { - private Dictionary _funcMap; + private readonly Dictionary _funcMap; public IndexedUDFFinder(params UDFFinder[] usedToolPacks) : base(usedToolPacks) diff --git a/main/SS/Formula/WorkbookEvaluator.cs b/main/SS/Formula/WorkbookEvaluator.cs index 9d8b9684e..c9f9a2420 100644 --- a/main/SS/Formula/WorkbookEvaluator.cs +++ b/main/SS/Formula/WorkbookEvaluator.cs @@ -48,16 +48,16 @@ namespace NPOI.SS.Formula public class WorkbookEvaluator { - private IEvaluationWorkbook _workbook; + private readonly IEvaluationWorkbook _workbook; private EvaluationCache _cache; private int _workbookIx; - private IEvaluationListener _evaluationListener; - private Dictionary _sheetIndexesBySheet; - private Dictionary _sheetIndexesByName; + private readonly IEvaluationListener _evaluationListener; + private readonly Dictionary _sheetIndexesBySheet; + private readonly Dictionary _sheetIndexesByName; private CollaboratingWorkbooksEnvironment _collaboratingWorkbookEnvironment; - private IStabilityClassifier _stabilityClassifier; - private UDFFinder _udfFinder; + private readonly IStabilityClassifier _stabilityClassifier; + private readonly UDFFinder _udfFinder; private bool _ignoreMissingWorkbooks = false; @@ -520,7 +520,7 @@ internal static ValueEval GetValueFromNonFormulaCell(IEvaluationCell cell) private bool dbgEvaluationOutputForNextEval = false; // special logger for formula evaluation output (because of possibly very large output) - private POILogger EVAL_LOG = POILogFactory.GetLogger("POI.FormulaEval"); + private readonly POILogger EVAL_LOG = POILogFactory.GetLogger("POI.FormulaEval"); // current indent level for evalution; negative value for no output private int dbgEvaluationOutputIndent = -1; diff --git a/main/SS/HtmlDocumentFacade.cs b/main/SS/HtmlDocumentFacade.cs index edfb6501e..87a03b54a 100644 --- a/main/SS/HtmlDocumentFacade.cs +++ b/main/SS/HtmlDocumentFacade.cs @@ -30,8 +30,8 @@ public class HtmlDocumentFacade protected XmlElement html; //Dictionary from tag name, to map linking known styles and css class names - private Dictionary> stylesheet = new Dictionary>(); - private XmlElement stylesheetElement; + private readonly Dictionary> stylesheet = new Dictionary>(); + private readonly XmlElement stylesheetElement; protected XmlElement title; protected XmlText titleText; diff --git a/main/SS/SpreadsheetVersion.cs b/main/SS/SpreadsheetVersion.cs index e366065d6..76e808739 100644 --- a/main/SS/SpreadsheetVersion.cs +++ b/main/SS/SpreadsheetVersion.cs @@ -41,14 +41,14 @@ public class SpreadsheetVersion */ public static SpreadsheetVersion EXCEL2007 = new SpreadsheetVersion("xlsx", 0x100000, 0x4000, 255, Int32.MaxValue, 64000, 32767, "EXCEL2007"); - private string _defaultExtension; - private int _maxRows; - private int _maxColumns; - private int _maxFunctionArgs; - private int _maxCondFormats; - private int _maxCellStyles; - private int _maxTextLength; - private string _name; + private readonly string _defaultExtension; + private readonly int _maxRows; + private readonly int _maxColumns; + private readonly int _maxFunctionArgs; + private readonly int _maxCondFormats; + private readonly int _maxCellStyles; + private readonly int _maxTextLength; + private readonly string _name; private SpreadsheetVersion(string defaultExtension, int maxRows, int maxColumns, int maxFunctionArgs, int maxCondFormats, int maxCellStyles, int maxText, string name) diff --git a/main/SS/UserModel/BorderStyle.cs b/main/SS/UserModel/BorderStyle.cs index a65fd1972..d7136f4f8 100644 --- a/main/SS/UserModel/BorderStyle.cs +++ b/main/SS/UserModel/BorderStyle.cs @@ -98,7 +98,7 @@ public enum BorderStyle : short public class BorderStyleEnum { - private static BorderStyle[] _table = new BorderStyle[0xD + 1]; + private static readonly BorderStyle[] _table = new BorderStyle[0xD + 1]; public static BorderStyle[] Values() { return _table; diff --git a/main/SS/UserModel/BuiltinFormats.cs b/main/SS/UserModel/BuiltinFormats.cs index 3a090ca73..af23166c0 100644 --- a/main/SS/UserModel/BuiltinFormats.cs +++ b/main/SS/UserModel/BuiltinFormats.cs @@ -82,7 +82,7 @@ public class BuiltinFormats */ public const int FIRST_USER_DEFINED_FORMAT_INDEX = 164; - private static String[] _formats = new string[]{ + private static readonly String[] _formats = new string[]{ "General", "0", "0.00", diff --git a/main/SS/UserModel/CellValue.cs b/main/SS/UserModel/CellValue.cs index 90da32285..724b3190d 100644 --- a/main/SS/UserModel/CellValue.cs +++ b/main/SS/UserModel/CellValue.cs @@ -34,11 +34,11 @@ public class CellValue public static readonly CellValue TRUE = new CellValue(CellType.Boolean, 0.0, true, null, 0); public static readonly CellValue FALSE = new CellValue(CellType.Boolean, 0.0, false, null, 0); - private CellType _cellType; - private double _numberValue; - private bool _boolValue; - private String _textValue; - private int _errorCode; + private readonly CellType _cellType; + private readonly double _numberValue; + private readonly bool _boolValue; + private readonly String _textValue; + private readonly int _errorCode; private CellValue(CellType cellType, double numberValue, bool boolValue, String textValue, int errorCode) diff --git a/main/SS/UserModel/Drawing/OfficeArtProperties.cs b/main/SS/UserModel/Drawing/OfficeArtProperties.cs index e1e6c6207..18a395cc9 100644 --- a/main/SS/UserModel/Drawing/OfficeArtProperties.cs +++ b/main/SS/UserModel/Drawing/OfficeArtProperties.cs @@ -49,7 +49,7 @@ public static class OfficeArtProperties public const int reserved423 = 0x1a7; public const int fillStyleBoolean = 0x1bf; - private static Dictionary fillStyle = new Dictionary(); + private static readonly Dictionary fillStyle = new Dictionary(); private static void InitFillStyle() { fillStyle.Add(0x180, "fillType"); diff --git a/main/SS/UserModel/FontCharset.cs b/main/SS/UserModel/FontCharset.cs index 286d3dd0e..1716e47c4 100644 --- a/main/SS/UserModel/FontCharset.cs +++ b/main/SS/UserModel/FontCharset.cs @@ -48,7 +48,7 @@ public class FontCharset public static readonly FontCharset OEM = new FontCharset(255); - private int charset; + private readonly int charset; private FontCharset(int value) { @@ -68,7 +68,7 @@ public int Value } } - private static FontCharset[] _table = null; + private static readonly FontCharset[] _table = null; static FontCharset() { diff --git a/main/SS/UserModel/FontUnderline.cs b/main/SS/UserModel/FontUnderline.cs index e7c1f42fd..c80cda47f 100644 --- a/main/SS/UserModel/FontUnderline.cs +++ b/main/SS/UserModel/FontUnderline.cs @@ -59,7 +59,7 @@ public class FontUnderline public static readonly FontUnderline NONE = new FontUnderline(0); - private int value; + private readonly int value; private FontUnderline(int val) @@ -106,7 +106,7 @@ public byte ByteValue } } - private static FontUnderline[] _table = null; + private static readonly FontUnderline[] _table = null; static FontUnderline() { diff --git a/main/SS/UserModel/FormulaError.cs b/main/SS/UserModel/FormulaError.cs index acb0518fe..574a56e9c 100644 --- a/main/SS/UserModel/FormulaError.cs +++ b/main/SS/UserModel/FormulaError.cs @@ -60,7 +60,7 @@ static FormulaError() smap.Add(error.String, error); } } - private static FormulaError[] _values; + private static readonly FormulaError[] _values; internal static readonly FormulaError _NO_ERROR = new FormulaError(-1, "(no error)", "_NO_ERROR"); /** @@ -149,9 +149,9 @@ static FormulaError() */ public static readonly FormulaError FUNCTION_NOT_IMPLEMENTED = new FormulaError(unchecked((int)0xFFFFFFE2), "~FUNCTION~NOT~IMPLEMENTED~", "FUNCTION_NOT_IMPLEMENTED"); - private byte type; - private int longType; - private String repr; + private readonly byte type; + private readonly int longType; + private readonly String repr; private FormulaError(int type, String repr, string name) { @@ -206,9 +206,9 @@ public String String } } - private static Dictionary smap = new Dictionary(); - private static Dictionary bmap = new Dictionary(); - private static Dictionary imap = new Dictionary(); + private static readonly Dictionary smap = new Dictionary(); + private static readonly Dictionary bmap = new Dictionary(); + private static readonly Dictionary imap = new Dictionary(); public static bool IsValidCode(int errorCode) { foreach (FormulaError error in _values) diff --git a/main/SS/UserModel/IndexedColors.cs b/main/SS/UserModel/IndexedColors.cs index 68bd47fe6..a5ff8cde0 100644 --- a/main/SS/UserModel/IndexedColors.cs +++ b/main/SS/UserModel/IndexedColors.cs @@ -85,8 +85,8 @@ public class IndexedColors public static readonly IndexedColors Grey80Percent; public static readonly IndexedColors Automatic; - private int index; - private HSSFColor hssfColor; + private readonly int index; + private readonly HSSFColor hssfColor; IndexedColors(int idx, HSSFColor color) @@ -94,8 +94,8 @@ public class IndexedColors index = idx; this.hssfColor = color; } - static Dictionary mappingName = null; - static Dictionary mappingIndex = null; + static readonly Dictionary mappingName = null; + static readonly Dictionary mappingIndex = null; static IndexedColors() { Black = new IndexedColors(8, new HSSFColor.Black()); diff --git a/main/SS/UserModel/PageOrder.cs b/main/SS/UserModel/PageOrder.cs index 5cf755f0a..0023c2508 100644 --- a/main/SS/UserModel/PageOrder.cs +++ b/main/SS/UserModel/PageOrder.cs @@ -35,7 +35,7 @@ public class PageOrder public static PageOrder OVER_THEN_DOWN; - private int order; + private readonly int order; static PageOrder() { @@ -58,7 +58,7 @@ public int Value } } - private static PageOrder[] _table; + private static readonly PageOrder[] _table; public static PageOrder ValueOf(int value) { diff --git a/main/SS/UserModel/PrintCellComments.cs b/main/SS/UserModel/PrintCellComments.cs index 12dbde3e1..6cc76598b 100644 --- a/main/SS/UserModel/PrintCellComments.cs +++ b/main/SS/UserModel/PrintCellComments.cs @@ -48,7 +48,7 @@ static PrintCellComments() AT_END = new PrintCellComments(3); } - private int comments; + private readonly int comments; private PrintCellComments(int comments) { @@ -64,7 +64,7 @@ public int Value } } - private static PrintCellComments[] _table; + private static readonly PrintCellComments[] _table; public static PrintCellComments ValueOf(int value) { diff --git a/main/SS/UserModel/PrintOrientation.cs b/main/SS/UserModel/PrintOrientation.cs index a2d988417..2e344d180 100644 --- a/main/SS/UserModel/PrintOrientation.cs +++ b/main/SS/UserModel/PrintOrientation.cs @@ -48,7 +48,7 @@ static PrintOrientation() LANDSCAPE = new PrintOrientation(3); } - private int orientation; + private readonly int orientation; private PrintOrientation(int orientation) { @@ -67,7 +67,7 @@ public int Value } - private static PrintOrientation[] _table; + private static readonly PrintOrientation[] _table; public static PrintOrientation ValueOf(int value) { diff --git a/main/SS/Util/AreaReference.cs b/main/SS/Util/AreaReference.cs index e45b2ac82..fa8f27b1f 100644 --- a/main/SS/Util/AreaReference.cs +++ b/main/SS/Util/AreaReference.cs @@ -31,12 +31,12 @@ public class AreaReference private const char CELL_DELIMITER = ':'; /** The Char (') used to quote sheet names when they contain special Chars */ private const char SPECIAL_NAME_DELIMITER = '\''; - private static SpreadsheetVersion DEFAULT_SPREADSHEET_VERSION = SpreadsheetVersion.EXCEL97; + private static readonly SpreadsheetVersion DEFAULT_SPREADSHEET_VERSION = SpreadsheetVersion.EXCEL97; - private CellReference _firstCell; - private CellReference _lastCell; - private bool _isSingleCell; - private SpreadsheetVersion _version; // never null + private readonly CellReference _firstCell; + private readonly CellReference _lastCell; + private readonly bool _isSingleCell; + private readonly SpreadsheetVersion _version; // never null [Obsolete("deprecated since NPOI 2.5.1 Prefer supplying a spreadsheet version.")] public AreaReference(String reference) diff --git a/main/SS/Util/CellAddress.cs b/main/SS/Util/CellAddress.cs index 869b01a70..327a64a07 100644 --- a/main/SS/Util/CellAddress.cs +++ b/main/SS/Util/CellAddress.cs @@ -39,8 +39,8 @@ public class CellAddress : IComparable /** A constant for references to the first cell in a sheet. */ public static CellAddress A1 = new CellAddress(0, 0); - private int _row; - private int _col; + private readonly int _row; + private readonly int _col; /** * Create a new CellAddress object. diff --git a/main/SS/Util/CellRangeAddressList.cs b/main/SS/Util/CellRangeAddressList.cs index 6f6f0f1dc..1b95d99d4 100644 --- a/main/SS/Util/CellRangeAddressList.cs +++ b/main/SS/Util/CellRangeAddressList.cs @@ -12,7 +12,7 @@ public class CellRangeAddressList /** * List of CellRangeAddresses. Each structure represents a cell range */ - private ArrayList _list; + private readonly ArrayList _list; public CellRangeAddressList() { diff --git a/main/SS/Util/CellReference.cs b/main/SS/Util/CellReference.cs index de0a2e145..0546e8255 100644 --- a/main/SS/Util/CellReference.cs +++ b/main/SS/Util/CellReference.cs @@ -63,7 +63,7 @@ public class CellReference private const char SPECIAL_NAME_DELIMITER = '\''; //private static final Pattern NAMED_RANGE_NAME_PATTERN = Pattern.compile("[_A-Z][_.A-Z0-9]*", Pattern.CASE_INSENSITIVE); - private static Regex NAMED_RANGE_NAME_PATTERN = new Regex("^[_A-Za-z][_.A-Za-z0-9]*$", RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.CultureInvariant); + private static readonly Regex NAMED_RANGE_NAME_PATTERN = new Regex("^[_A-Za-z][_.A-Za-z0-9]*$", RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.CultureInvariant); //private static string BIFF8_LAST_COLUMN = "IV"; //private static int BIFF8_LAST_COLUMN_TEXT_LEN = BIFF8_LAST_COLUMN.Length; //private static string BIFF8_LAST_ROW = (0x10000).ToString(); @@ -71,11 +71,11 @@ public class CellReference // FIXME: _sheetName may be null, depending on the entry point. // Perhaps it would be better to declare _sheetName is never null, using an empty string to represent a 2D reference. - private String _sheetName; - private int _rowIndex; - private int _colIndex; - private bool _isRowAbs; - private bool _isColAbs; + private readonly String _sheetName; + private readonly int _rowIndex; + private readonly int _colIndex; + private readonly bool _isRowAbs; + private readonly bool _isColAbs; /** * Create an cell ref from a string representation. Sheet names containing special characters should be diff --git a/main/SS/Util/DateFormatConverter.cs b/main/SS/Util/DateFormatConverter.cs index 94d00b4f6..f0f52261e 100644 --- a/main/SS/Util/DateFormatConverter.cs +++ b/main/SS/Util/DateFormatConverter.cs @@ -42,11 +42,11 @@ namespace NPOI.SS.Util /// public class DateFormatConverter { - private static POILogger logger = POILogFactory.GetLogger(typeof(DateFormatConverter)); + private static readonly POILogger logger = POILogFactory.GetLogger(typeof(DateFormatConverter)); public class DateFormatTokenizer { - string format; + readonly string format; int pos; public DateFormatTokenizer(string format) @@ -118,8 +118,8 @@ public override string ToString() } } - private static Dictionary tokenConversions = PrepareTokenConversions(); - private static Dictionary localePrefixes = PrepareLocalePrefixes(); + private static readonly Dictionary tokenConversions = PrepareTokenConversions(); + private static readonly Dictionary localePrefixes = PrepareLocalePrefixes(); private static Dictionary PrepareTokenConversions() { diff --git a/main/SS/Util/ExpandedDouble.cs b/main/SS/Util/ExpandedDouble.cs index 2961cc01c..aa2bbaffa 100644 --- a/main/SS/Util/ExpandedDouble.cs +++ b/main/SS/Util/ExpandedDouble.cs @@ -53,8 +53,8 @@ public static ExpandedDouble FromRawBitsAndExponent(long rawBits, int exp) /** * Always 64 bits long (MSB, bit-63 is '1') */ - private BigInteger _significand; - private int _binaryExponent; + private readonly BigInteger _significand; + private readonly int _binaryExponent; public ExpandedDouble(long rawBits) { diff --git a/main/SS/Util/Format.cs b/main/SS/Util/Format.cs index dd2875475..c4609441e 100644 --- a/main/SS/Util/Format.cs +++ b/main/SS/Util/Format.cs @@ -48,7 +48,7 @@ public TimeZoneInfo TimeZone public class SSNFormat : FormatBase { public static readonly FormatBase Instance = new SSNFormat(); - private static string df = "000000000"; + private static readonly string df = "000000000"; private SSNFormat() { // enforce singleton @@ -89,7 +89,7 @@ public override object ParseObject(string source, int pos) public class ZipPlusFourFormat : FormatBase { public static readonly FormatBase Instance = new ZipPlusFourFormat(); - private static string df = "000000000"; + private static readonly string df = "000000000"; private ZipPlusFourFormat() { // enforce singleton @@ -127,7 +127,7 @@ public override object ParseObject(string source, int pos) public class PhoneFormat : FormatBase { public static readonly FormatBase Instance = new PhoneFormat(); - private static string df = "##########"; + private static readonly string df = "##########"; private PhoneFormat() { // enforce singleton @@ -187,7 +187,7 @@ public DecimalFormat() } private string _pattern; - private NumberFormatInfo _formatInfo; + private readonly NumberFormatInfo _formatInfo; public DecimalFormat(string pattern) { @@ -302,7 +302,7 @@ public static string GetTimePattern(int timeStyle, CultureInfo locale) } public class SimpleDateFormat : DateFormat { - private string _pattern; + private readonly string _pattern; private DateTimeFormatInfo _formatData; private CultureInfo _culture; public SimpleDateFormat():this("", CultureInfo.CurrentCulture) @@ -392,8 +392,8 @@ public DateTime Parse(string source) */ public class ConstantStringFormat : FormatBase { - private static DecimalFormat df = new DecimalFormat("##########"); - private string str; + private static readonly DecimalFormat df = new DecimalFormat("##########"); + private readonly string str; public ConstantStringFormat(string s) { str = s; diff --git a/main/SS/Util/MutableFPNumber.cs b/main/SS/Util/MutableFPNumber.cs index 8fc91d35b..52032c771 100644 --- a/main/SS/Util/MutableFPNumber.cs +++ b/main/SS/Util/MutableFPNumber.cs @@ -154,7 +154,7 @@ private void mulShift(BigInteger multiplicand, int multiplierShift) private class Rounder { - private static BigInteger[] HALF_BITS; + private static readonly BigInteger[] HALF_BITS; static Rounder() { @@ -186,12 +186,12 @@ public static BigInteger Round(BigInteger bi, int nBits) private class TenPower { private static readonly BigInteger FIVE = new BigInteger(5L);// new BigInteger("5",10); - private static TenPower[] _cache = new TenPower[350]; + private static readonly TenPower[] _cache = new TenPower[350]; - public BigInteger _multiplicand; - public BigInteger _divisor; - public int _divisorShift; - public int _multiplierShift; + public readonly BigInteger _multiplicand; + public readonly BigInteger _divisor; + public readonly int _divisorShift; + public readonly int _multiplierShift; private TenPower(int index) { diff --git a/main/SS/Util/NormalisedDecimal.cs b/main/SS/Util/NormalisedDecimal.cs index d3da1a696..16fad1bca 100644 --- a/main/SS/Util/NormalisedDecimal.cs +++ b/main/SS/Util/NormalisedDecimal.cs @@ -157,19 +157,19 @@ public NormalisedDecimal RoundUnits() /** * The decimal exponent increased by one less than the digit count of {@link #_wholePart} */ - private int _relativeDecimalExponent; + private readonly int _relativeDecimalExponent; /** * The whole part of the significand (typically 15 digits). * * 47-50 bits long (MSB may be anywhere from bit 46 to 49) * LSB is units bit. */ - private long _wholePart; + private readonly long _wholePart; /** * The fractional part of the significand. * 24 bits (only top 14-17 bits significant): a value between 0x000000 and 0xFFFF80 */ - private int _fractionalPart; + private readonly int _fractionalPart; public NormalisedDecimal(long wholePart, int fracPart, int decimalExponent) diff --git a/main/SS/Util/PropertyTemplate.cs b/main/SS/Util/PropertyTemplate.cs index 869994db2..8b484c11f 100644 --- a/main/SS/Util/PropertyTemplate.cs +++ b/main/SS/Util/PropertyTemplate.cs @@ -56,7 +56,7 @@ public sealed class PropertyTemplate /// This is a list of cell properties for one shot application to a range of /// cells at a later time. ///

- private Dictionary> _propertyTemplate; + private readonly Dictionary> _propertyTemplate; /// /// Create a PropertyTemplate object diff --git a/main/SS/Util/RegionUtil.cs b/main/SS/Util/RegionUtil.cs index 644315f44..78f55b9a0 100644 --- a/main/SS/Util/RegionUtil.cs +++ b/main/SS/Util/RegionUtil.cs @@ -39,8 +39,8 @@ private RegionUtil() */ private class CellPropertySetter { - private String _propertyName; - private object _propertyValue; + private readonly String _propertyName; + private readonly object _propertyValue; public CellPropertySetter(String propertyName, int value) diff --git a/main/SS/Util/SSCellRange.cs b/main/SS/Util/SSCellRange.cs index 5c7286fae..d809da069 100644 --- a/main/SS/Util/SSCellRange.cs +++ b/main/SS/Util/SSCellRange.cs @@ -31,11 +31,11 @@ namespace NPOI.SS.Util public class SSCellRange : ICellRange where K:ICell { - private int _height; - private int _width; - private K[] _flattenedArray; - private int _firstRow; - private int _firstColumn; + private readonly int _height; + private readonly int _width; + private readonly K[] _flattenedArray; + private readonly int _firstRow; + private readonly int _firstColumn; private SSCellRange(int firstRow, int firstColumn, int height, int width, K[] flattenedArray) { @@ -79,7 +79,7 @@ public K GetCell(int relativeRowIndex, int relativeColumnIndex) internal class ArrayIterator :IEnumerator { - private D[] _array; + private readonly D[] _array; private int _index; public ArrayIterator(D[] array) diff --git a/main/Util/BigInteger.cs b/main/Util/BigInteger.cs index 8aca88bd6..4146d5a0d 100644 --- a/main/Util/BigInteger.cs +++ b/main/Util/BigInteger.cs @@ -15,7 +15,7 @@ public class BigInteger : IComparable * * @serial */ - private int _signum; + private readonly int _signum; /** * The magnitude of this BigInteger, in big-endian order: the @@ -91,8 +91,8 @@ public class BigInteger : IComparable public const long INFLATED = long.MinValue; public const int Min_RADIX = 2; public const int Max_RADIX = 36; - private static BigInteger[] posConst = new BigInteger[Max_CONSTANT + 1]; - private static BigInteger[] negConst = new BigInteger[Max_CONSTANT + 1]; + private static readonly BigInteger[] posConst = new BigInteger[Max_CONSTANT + 1]; + private static readonly BigInteger[] negConst = new BigInteger[Max_CONSTANT + 1]; private static readonly String[] zeros = new String[64]; //Constructors static BigInteger() diff --git a/main/Util/ByteField.cs b/main/Util/ByteField.cs index dfac626d3..a12952600 100644 --- a/main/Util/ByteField.cs +++ b/main/Util/ByteField.cs @@ -39,7 +39,7 @@ namespace NPOI.Util public class ByteField : FixedField { private const byte _default_value = 0; - private int _offset; + private readonly int _offset; private byte _value; /// diff --git a/main/Util/CloseIgnoringInputStream.cs b/main/Util/CloseIgnoringInputStream.cs index c52c575bb..89ba7a490 100644 --- a/main/Util/CloseIgnoringInputStream.cs +++ b/main/Util/CloseIgnoringInputStream.cs @@ -32,7 +32,7 @@ namespace NPOI.Util internal class CloseIgnoringInputStream : Stream { - private Stream _is; + private readonly Stream _is; public CloseIgnoringInputStream(Stream stream) { diff --git a/main/Util/Collections/Properties.cs b/main/Util/Collections/Properties.cs index 0b36f1e90..35d05963e 100644 --- a/main/Util/Collections/Properties.cs +++ b/main/Util/Collections/Properties.cs @@ -36,7 +36,7 @@ namespace NPOI.Util.Collections /// public class Properties { - private Hashtable _col; + private readonly Hashtable _col; private const string whiteSpaceChars = " \t\r\n\f"; private const string keyValueSeparators = "=: \t\r\n\f"; private const string strictKeyValueSeparators = "=:"; diff --git a/main/Util/IntMapper.cs b/main/Util/IntMapper.cs index b921e6b4d..3ac70fc3b 100644 --- a/main/Util/IntMapper.cs +++ b/main/Util/IntMapper.cs @@ -34,10 +34,10 @@ namespace NPOI.Util /// @author Jason Height public class IntMapper { - private List elements; - private Dictionary valueKeyMap; + private readonly List elements; + private readonly Dictionary valueKeyMap; - private static int _default_size = 10; + private static readonly int _default_size = 10; /// /// create an IntMapper of default size diff --git a/main/Util/IntegerField.cs b/main/Util/IntegerField.cs index 72bebd724..e1c4e8b86 100644 --- a/main/Util/IntegerField.cs +++ b/main/Util/IntegerField.cs @@ -35,7 +35,7 @@ namespace NPOI.Util public class IntegerField:FixedField { private int _value; - private int _offset; + private readonly int _offset; /// /// construct the with its offset into its containing byte array class. diff --git a/main/Util/LittleEndianByteArrayInputStream.cs b/main/Util/LittleEndianByteArrayInputStream.cs index 76f7fe750..0b1afcf3f 100644 --- a/main/Util/LittleEndianByteArrayInputStream.cs +++ b/main/Util/LittleEndianByteArrayInputStream.cs @@ -25,8 +25,8 @@ namespace NPOI.Util /// @author Josh Micich public class LittleEndianByteArrayInputStream : ILittleEndianInput { - private byte[] _buf; - private int _endIndex; + private readonly byte[] _buf; + private readonly int _endIndex; private int _ReadIndex; public LittleEndianByteArrayInputStream(byte[] buf, int startOffset, int maxReadLen) diff --git a/main/Util/LittleEndianByteArrayOutputStream.cs b/main/Util/LittleEndianByteArrayOutputStream.cs index eecb1701e..6e8775cec 100644 --- a/main/Util/LittleEndianByteArrayOutputStream.cs +++ b/main/Util/LittleEndianByteArrayOutputStream.cs @@ -26,8 +26,8 @@ namespace NPOI.Util /// @author Josh Micich public class LittleEndianByteArrayOutputStream : ILittleEndianOutput, IDelayableLittleEndianOutput { - private byte[] _buf; - private int _endIndex; + private readonly byte[] _buf; + private readonly int _endIndex; private int _writeIndex; public LittleEndianByteArrayOutputStream(byte[] buf, int startOffset, int maxWriteLen) diff --git a/main/Util/LongField.cs b/main/Util/LongField.cs index cb1abb624..80948f754 100644 --- a/main/Util/LongField.cs +++ b/main/Util/LongField.cs @@ -36,7 +36,7 @@ namespace NPOI.Util public class LongField { private long _value; - private int _offset; + private readonly int _offset; /// /// construct the with its offset into its containing byte array diff --git a/main/Util/ObjectExtensions.cs b/main/Util/ObjectExtensions.cs index 5a607573c..3aa527b5e 100644 --- a/main/Util/ObjectExtensions.cs +++ b/main/Util/ObjectExtensions.cs @@ -98,7 +98,7 @@ public static void ForEach(this Array array, Action action) internal class ArrayTraverse { public int[] Position; - private int[] maxLengths; + private readonly int[] maxLengths; public ArrayTraverse(Array array) { diff --git a/main/Util/POILogFactory.cs b/main/Util/POILogFactory.cs index c5fe33bd4..f247e02fa 100644 --- a/main/Util/POILogFactory.cs +++ b/main/Util/POILogFactory.cs @@ -38,13 +38,13 @@ public class POILogFactory /** * Map of POILogger instances, with classes as keys */ - private static Hashtable _loggers = new Hashtable(); + private static readonly Hashtable _loggers = new Hashtable(); /** * A common instance of NullLogger, as it does nothing * we only need the one */ - private static POILogger _nullLogger = new NullLogger(); + private static readonly POILogger _nullLogger = new NullLogger(); /** * The name of the class to use. Initialised the * first time we need it diff --git a/main/Util/ShortField.cs b/main/Util/ShortField.cs index 167e4fdd2..a38d224d2 100644 --- a/main/Util/ShortField.cs +++ b/main/Util/ShortField.cs @@ -34,7 +34,7 @@ namespace NPOI.Util public class ShortField { private short _value; - private int _offset; + private readonly int _offset; /// /// construct the ShortField with its offset into its containing diff --git a/main/Util/ULongField.cs b/main/Util/ULongField.cs index 81c0c184c..63543aa57 100644 --- a/main/Util/ULongField.cs +++ b/main/Util/ULongField.cs @@ -38,7 +38,7 @@ namespace NPOI.Util public class ULongField { private ulong _value; - private int _offset; + private readonly int _offset; /// /// construct the with its offset into its containing byte array diff --git a/ooxml/POIXMLDocumentPart.cs b/ooxml/POIXMLDocumentPart.cs index ff2721b6e..0357f62ae 100644 --- a/ooxml/POIXMLDocumentPart.cs +++ b/ooxml/POIXMLDocumentPart.cs @@ -41,10 +41,10 @@ public class POIXMLDocumentPart { private static POILogger logger = POILogFactory.GetLogger(typeof(POIXMLDocumentPart)); - private String coreDocumentRel = PackageRelationshipTypes.CORE_DOCUMENT; + private readonly String coreDocumentRel = PackageRelationshipTypes.CORE_DOCUMENT; private PackagePart packagePart; private POIXMLDocumentPart parent; - private Dictionary relations = new Dictionary(); + private readonly Dictionary relations = new Dictionary(); /** * The RelationPart is a cached relationship between the document, which contains the RelationPart, @@ -55,8 +55,8 @@ public class POIXMLDocumentPart public class RelationPart { - private PackageRelationship relationship; - private POIXMLDocumentPart documentPart; + private readonly PackageRelationship relationship; + private readonly POIXMLDocumentPart documentPart; internal RelationPart(PackageRelationship relationship, POIXMLDocumentPart documentPart) { diff --git a/ooxml/POIXMLRelation.cs b/ooxml/POIXMLRelation.cs index 8c6739e21..e606a1e2e 100644 --- a/ooxml/POIXMLRelation.cs +++ b/ooxml/POIXMLRelation.cs @@ -31,22 +31,22 @@ public abstract class POIXMLRelation /** * Describes the content stored in a part. */ - private String _type; + private readonly String _type; /** * The kind of connection between a source part and a target part in a namespace. */ - private String _relation; + private readonly String _relation; /** * The path component of a pack URI. */ - private String _defaultName; + private readonly String _defaultName; /** * Defines what object is used to construct instances of this relationship */ - private Type _cls; + private readonly Type _cls; /** * Instantiates a POIXMLRelation. diff --git a/ooxml/POIXMLTextExtractor.cs b/ooxml/POIXMLTextExtractor.cs index 97d1c8d54..835344357 100644 --- a/ooxml/POIXMLTextExtractor.cs +++ b/ooxml/POIXMLTextExtractor.cs @@ -23,7 +23,7 @@ namespace NPOI public abstract class POIXMLTextExtractor : POITextExtractor { /** The POIXMLDocument that's open */ - private POIXMLDocument _document; + private readonly POIXMLDocument _document; /** * Creates a new text extractor for the given document diff --git a/ooxml/SS/Converter/ExcelToHtmlConverter.cs b/ooxml/SS/Converter/ExcelToHtmlConverter.cs index 0d3c842bc..c3f8bc6c1 100644 --- a/ooxml/SS/Converter/ExcelToHtmlConverter.cs +++ b/ooxml/SS/Converter/ExcelToHtmlConverter.cs @@ -34,7 +34,7 @@ namespace NPOI.SS.Converter public class ExcelToHtmlConverter { - POILogger logger = POILogFactory.GetLogger(typeof(ExcelToHtmlConverter)); + readonly POILogger logger = POILogFactory.GetLogger(typeof(ExcelToHtmlConverter)); public ExcelToHtmlConverter() { XmlDocument doc = new XmlDocument(); @@ -47,16 +47,16 @@ protected static double GetColumnWidth(ISheet sheet, int columnIndex) return ExcelToHtmlUtils.GetColumnWidthInPx(sheet.GetColumnWidth(columnIndex)); } //private HSSFDataFormatter _formatter = new HSSFDataFormatter(); - private DataFormatter _formatter = new DataFormatter(); + private readonly DataFormatter _formatter = new DataFormatter(); private string cssClassContainerCell = null; private string cssClassContainerDiv = null; - private string cssClassTable; + private readonly string cssClassTable; - private Dictionary excelStyleToClass = new Dictionary(); + private readonly Dictionary excelStyleToClass = new Dictionary(); - private HtmlDocumentFacade htmlDocumentFacade; + private readonly HtmlDocumentFacade htmlDocumentFacade; private bool outputColumnHeaders = true; /// diff --git a/ooxml/XSSF/Extractor/XSSFExportToXml.cs b/ooxml/XSSF/Extractor/XSSFExportToXml.cs index e752a3ec2..69385ebd0 100644 --- a/ooxml/XSSF/Extractor/XSSFExportToXml.cs +++ b/ooxml/XSSF/Extractor/XSSFExportToXml.cs @@ -51,7 +51,7 @@ namespace NPOI.XSSF.Extractor public class XSSFExportToXml : IComparer { - private XSSFMap map; + private readonly XSSFMap map; /** * Creates a new exporter and Sets the mapping to be used when generating the XML output document diff --git a/ooxml/XSSF/Model/ParagraphPropertyFetcher.cs b/ooxml/XSSF/Model/ParagraphPropertyFetcher.cs index 59784910c..313d7074c 100644 --- a/ooxml/XSSF/Model/ParagraphPropertyFetcher.cs +++ b/ooxml/XSSF/Model/ParagraphPropertyFetcher.cs @@ -33,7 +33,7 @@ public abstract class ParagraphPropertyFetcher : ParagraphPropertyFetcher { private T _value; - private int _level; + private readonly int _level; public T GetValue() { diff --git a/ooxml/XSSF/Model/SharedStringsTable.cs b/ooxml/XSSF/Model/SharedStringsTable.cs index a36694bd1..e96203941 100644 --- a/ooxml/XSSF/Model/SharedStringsTable.cs +++ b/ooxml/XSSF/Model/SharedStringsTable.cs @@ -58,12 +58,12 @@ public class SharedStringsTable : POIXMLDocumentPart /** * Array of individual string items in the Shared String table. */ - private List strings = new List(); + private readonly List strings = new List(); /** * Maps strings and their indexes in the strings arrays */ - private Dictionary stmap = new Dictionary(); + private readonly Dictionary stmap = new Dictionary(); /** * An integer representing the total count of strings in the workbook. This count does not diff --git a/ooxml/XSSF/Model/StylesTable.cs b/ooxml/XSSF/Model/StylesTable.cs index 53c564247..054f07fb2 100644 --- a/ooxml/XSSF/Model/StylesTable.cs +++ b/ooxml/XSSF/Model/StylesTable.cs @@ -40,24 +40,24 @@ namespace NPOI.XSSF.Model */ public class StylesTable : POIXMLDocumentPart { - private SortedDictionary numberFormats = new SortedDictionary(); - private List fonts = new List(); - private List fills = new List(); - private List borders = new List(); - private List styleXfs = new List(); - private List xfs = new List(); - - private List dxfs = new List(); - private Dictionary tableStyles = new Dictionary(); - private IIndexedColorMap indexedColors = new DefaultIndexedColorMap(); + private readonly SortedDictionary numberFormats = new SortedDictionary(); + private readonly List fonts = new List(); + private readonly List fills = new List(); + private readonly List borders = new List(); + private readonly List styleXfs = new List(); + private readonly List xfs = new List(); + + private readonly List dxfs = new List(); + private readonly Dictionary tableStyles = new Dictionary(); + private readonly IIndexedColorMap indexedColors = new DefaultIndexedColorMap(); /** * The first style id available for use as a custom style */ public static int FIRST_CUSTOM_STYLE_ID = BuiltinFormats.FIRST_USER_DEFINED_FORMAT_INDEX + 1; // Is this right? Number formats (XSSFDataFormat) and cell styles (XSSFCellStyle) are different. What's up with the plus 1? - private static int MAXIMUM_STYLE_ID = SpreadsheetVersion.EXCEL2007.MaxCellStyles; + private static readonly int MAXIMUM_STYLE_ID = SpreadsheetVersion.EXCEL2007.MaxCellStyles; - private static short FIRST_USER_DEFINED_NUMBER_FORMAT_ID = BuiltinFormats.FIRST_USER_DEFINED_FORMAT_INDEX; + private static readonly short FIRST_USER_DEFINED_NUMBER_FORMAT_ID = BuiltinFormats.FIRST_USER_DEFINED_FORMAT_INDEX; /** * Depending on the version of Excel, the maximum number of number formats in a workbook is between 200 and 250 * See https://support.office.com/en-us/article/excel-specifications-and-limits-1672b34d-7043-467e-8e27-269d656771c3 diff --git a/ooxml/XSSF/Streaming/AutoSizeColumnTracker.cs b/ooxml/XSSF/Streaming/AutoSizeColumnTracker.cs index f6ea80efb..37c89e86e 100644 --- a/ooxml/XSSF/Streaming/AutoSizeColumnTracker.cs +++ b/ooxml/XSSF/Streaming/AutoSizeColumnTracker.cs @@ -24,8 +24,8 @@ namespace NPOI.XSSF.Streaming { public class AutoSizeColumnTracker { - private int defaultCharWidth; - private DataFormatter dataFormatter = new DataFormatter(); + private readonly int defaultCharWidth; + private readonly DataFormatter dataFormatter = new DataFormatter(); /// @@ -35,12 +35,12 @@ public class AutoSizeColumnTracker /// outweigh the infrequent O(n*log n) cost of sorting getTrackedColumns(). /// Memory consumption for a HashMap and TreeMap is about the same /// - private Dictionary maxColumnWidths = new Dictionary(); + private readonly Dictionary maxColumnWidths = new Dictionary(); // untrackedColumns stores columns have been explicitly untracked so they aren't implicitly re-tracked by trackAllColumns // Using a HashSet instead of a TreeSet because we don't care about order. - private HashSet untrackedColumns = new HashSet(); + private readonly HashSet untrackedColumns = new HashSet(); private bool trackAllColumns = false; private class ColumnWidthPair diff --git a/ooxml/XSSF/Streaming/SXSSFCell.cs b/ooxml/XSSF/Streaming/SXSSFCell.cs index 36f9d22bd..7ad952a67 100644 --- a/ooxml/XSSF/Streaming/SXSSFCell.cs +++ b/ooxml/XSSF/Streaming/SXSSFCell.cs @@ -30,9 +30,9 @@ namespace NPOI.XSSF.Streaming { public class SXSSFCell : ICell { - private static POILogger logger = POILogFactory.GetLogger(typeof(SXSSFCell)); + private static readonly POILogger logger = POILogFactory.GetLogger(typeof(SXSSFCell)); - private SXSSFRow _row; + private readonly SXSSFRow _row; private Value _value; private ICellStyle _style; private Property _firstProperty; diff --git a/ooxml/XSSF/Streaming/SXSSFDrawing.cs b/ooxml/XSSF/Streaming/SXSSFDrawing.cs index 7cfbf9471..9a9fd3a8b 100644 --- a/ooxml/XSSF/Streaming/SXSSFDrawing.cs +++ b/ooxml/XSSF/Streaming/SXSSFDrawing.cs @@ -29,8 +29,8 @@ namespace NPOI.XSSF.Streaming /// public class SXSSFDrawing : IDrawing, IDrawing { - private SXSSFWorkbook _wb; - private XSSFDrawing _drawing; + private readonly SXSSFWorkbook _wb; + private readonly XSSFDrawing _drawing; public SXSSFDrawing(SXSSFWorkbook workbook, XSSFDrawing Drawing) { diff --git a/ooxml/XSSF/Streaming/SXSSFEvaluationCell.cs b/ooxml/XSSF/Streaming/SXSSFEvaluationCell.cs index 0ba4277cd..69835e7b9 100644 --- a/ooxml/XSSF/Streaming/SXSSFEvaluationCell.cs +++ b/ooxml/XSSF/Streaming/SXSSFEvaluationCell.cs @@ -24,8 +24,8 @@ namespace NPOI.XSSF.Streaming { public class SXSSFEvaluationCell : IEvaluationCell { - private SXSSFEvaluationSheet _evalSheet; - private SXSSFCell _cell; + private readonly SXSSFEvaluationSheet _evalSheet; + private readonly SXSSFCell _cell; public SXSSFEvaluationCell(SXSSFCell cell, SXSSFEvaluationSheet evaluationSheet) { diff --git a/ooxml/XSSF/Streaming/SXSSFEvaluationSheet.cs b/ooxml/XSSF/Streaming/SXSSFEvaluationSheet.cs index d55dd0536..96ddc1450 100644 --- a/ooxml/XSSF/Streaming/SXSSFEvaluationSheet.cs +++ b/ooxml/XSSF/Streaming/SXSSFEvaluationSheet.cs @@ -21,7 +21,7 @@ namespace NPOI.XSSF.Streaming { public class SXSSFEvaluationSheet : IEvaluationSheet //XSSFEvaluationSheet { - private SXSSFSheet _xs; + private readonly SXSSFSheet _xs; public SXSSFEvaluationSheet(SXSSFSheet sheet) { diff --git a/ooxml/XSSF/Streaming/SXSSFEvaluationWorkbook.cs b/ooxml/XSSF/Streaming/SXSSFEvaluationWorkbook.cs index 65ab7525a..5bae7eefc 100644 --- a/ooxml/XSSF/Streaming/SXSSFEvaluationWorkbook.cs +++ b/ooxml/XSSF/Streaming/SXSSFEvaluationWorkbook.cs @@ -23,7 +23,7 @@ namespace NPOI.XSSF.Streaming { public class SXSSFEvaluationWorkbook : BaseXSSFEvaluationWorkbook { - private SXSSFWorkbook _xBook; + private readonly SXSSFWorkbook _xBook; public static SXSSFEvaluationWorkbook Create(SXSSFWorkbook book) { diff --git a/ooxml/XSSF/Streaming/SXSSFPicture.cs b/ooxml/XSSF/Streaming/SXSSFPicture.cs index b2e822f78..efa03e320 100644 --- a/ooxml/XSSF/Streaming/SXSSFPicture.cs +++ b/ooxml/XSSF/Streaming/SXSSFPicture.cs @@ -40,7 +40,7 @@ namespace NPOI.XSSF.Streaming /// public class SXSSFPicture : IPicture { - private static POILogger logger = POILogFactory.GetLogger(typeof(SXSSFPicture)); + private static readonly POILogger logger = POILogFactory.GetLogger(typeof(SXSSFPicture)); /// /// /// Column width measured as the number of characters of the maximum digit width of the @@ -51,10 +51,10 @@ public class SXSSFPicture : IPicture /// This value is the same for default font in Office 2007 (Calibry) and Office 2003 and earlier (Arial) /// /// - private static float DEFAULT_COLUMN_WIDTH = 9.140625f; + private static readonly float DEFAULT_COLUMN_WIDTH = 9.140625f; - private SXSSFWorkbook _wb; - private XSSFPicture _picture; + private readonly SXSSFWorkbook _wb; + private readonly XSSFPicture _picture; public SXSSFPicture(SXSSFWorkbook _wb, XSSFPicture _picture) { diff --git a/ooxml/XSSF/Streaming/SXSSFRow.cs b/ooxml/XSSF/Streaming/SXSSFRow.cs index d654b5b9c..311864d2f 100644 --- a/ooxml/XSSF/Streaming/SXSSFRow.cs +++ b/ooxml/XSSF/Streaming/SXSSFRow.cs @@ -25,8 +25,8 @@ namespace NPOI.XSSF.Streaming { public class SXSSFRow : IRow, IComparable { - private SXSSFSheet _sheet; // parent sheet - private IDictionary _cells = new Dictionary(); + private readonly SXSSFSheet _sheet; // parent sheet + private readonly IDictionary _cells = new Dictionary(); private short _style = -1; // index of cell style in style table private bool _zHeight; // row zero-height (this is somehow different than being hidden) private float _height = -1; @@ -385,7 +385,7 @@ IEnumerator IEnumerable.GetEnumerator() public class FilledCellIterator : IEnumerator { //private SortedDictionary _cells; - private IEnumerator enumerator; + private readonly IEnumerator enumerator; public FilledCellIterator(SortedDictionary cells) { //_cells = cells; @@ -427,8 +427,8 @@ public void Reset() public class CellIterator : IEnumerator { - private IDictionary _cells; - private int maxColumn; + private readonly IDictionary _cells; + private readonly int maxColumn; private int pos; public CellIterator(int lastCellNum, IDictionary cells) { diff --git a/ooxml/XSSF/Streaming/SXSSFSheet.cs b/ooxml/XSSF/Streaming/SXSSFSheet.cs index df7ec5dbc..d692fddf1 100644 --- a/ooxml/XSSF/Streaming/SXSSFSheet.cs +++ b/ooxml/XSSF/Streaming/SXSSFSheet.cs @@ -32,12 +32,12 @@ public class SXSSFSheet : ISheet { // TODO: fields should be private and use public property internal XSSFSheet _sh; - private SXSSFWorkbook _workbook; + private readonly SXSSFWorkbook _workbook; //private TreeMap _rows = new TreeMap(); - private IDictionary _rows = new Dictionary(); - private SheetDataWriter _writer; + private readonly IDictionary _rows = new Dictionary(); + private readonly SheetDataWriter _writer; private int _randomAccessWindowSize = SXSSFWorkbook.DEFAULT_WINDOW_SIZE; - private Lazy _autoSizeColumnTracker; + private readonly Lazy _autoSizeColumnTracker; private int outlineLevelRow = 0; private int lastFlushedRowNumber = -1; private bool allFlushed = false; diff --git a/ooxml/XSSF/Streaming/SXSSFWorkbook.cs b/ooxml/XSSF/Streaming/SXSSFWorkbook.cs index cb3ca8555..aa6138c65 100644 --- a/ooxml/XSSF/Streaming/SXSSFWorkbook.cs +++ b/ooxml/XSSF/Streaming/SXSSFWorkbook.cs @@ -66,14 +66,14 @@ public class SXSSFWorkbook : IWorkbook private static readonly POILogger logger = POILogFactory.GetLogger(typeof(SXSSFWorkbook)); public const int DEFAULT_WINDOW_SIZE = 100; - private XSSFWorkbook _wb; + private readonly XSSFWorkbook _wb; public XSSFWorkbook XssfWorkbook { get { return _wb; } } - private Dictionary _sxFromXHash = new Dictionary(); - private Dictionary _xFromSxHash = new Dictionary(); + private readonly Dictionary _sxFromXHash = new Dictionary(); + private readonly Dictionary _xFromSxHash = new Dictionary(); private int _randomAccessWindowSize = DEFAULT_WINDOW_SIZE; @@ -110,7 +110,7 @@ public int RandomAccessWindowSize /// /// shared string table - a cache of strings in this workbook. /// - private SharedStringsTable _sharedStringSource; + private readonly SharedStringsTable _sharedStringSource; public int ActiveSheetIndex { @@ -1005,8 +1005,8 @@ void IDisposable.Dispose() private class SheetEnumerator : IEnumerator where T : class, ISheet { private XSSFWorkbook _wb; - private SXSSFWorkbook _xwb; - private IEnumerator it; + private readonly SXSSFWorkbook _xwb; + private readonly IEnumerator it; public SheetEnumerator(XSSFWorkbook wb, SXSSFWorkbook xwb) { this._wb = wb; diff --git a/ooxml/XSSF/UserModel/BaseXSSFEvaluationWorkbook.cs b/ooxml/XSSF/UserModel/BaseXSSFEvaluationWorkbook.cs index ce507904f..e03719888 100644 --- a/ooxml/XSSF/UserModel/BaseXSSFEvaluationWorkbook.cs +++ b/ooxml/XSSF/UserModel/BaseXSSFEvaluationWorkbook.cs @@ -134,7 +134,7 @@ private int FindExternalLinkIndex(String bookName, List tabl } private class FakeExternalLinksTable : ExternalLinksTable { - private String fileName; + private readonly String fileName; internal FakeExternalLinksTable(string fileName) { this.fileName = fileName; @@ -429,9 +429,9 @@ public UDFFinder GetUDFFinder() private class Name : IEvaluationName { - private XSSFName _nameRecord; - private int _index; - private IFormulaParsingWorkbook _fpBook; + private readonly XSSFName _nameRecord; + private readonly int _index; + private readonly IFormulaParsingWorkbook _fpBook; public Name(XSSFName name, int index, IFormulaParsingWorkbook fpBook) { diff --git a/ooxml/XSSF/UserModel/Extensions/XSSFCellFill.cs b/ooxml/XSSF/UserModel/Extensions/XSSFCellFill.cs index b21365972..83f531773 100644 --- a/ooxml/XSSF/UserModel/Extensions/XSSFCellFill.cs +++ b/ooxml/XSSF/UserModel/Extensions/XSSFCellFill.cs @@ -26,7 +26,7 @@ namespace NPOI.XSSF.UserModel.Extensions public class XSSFCellFill { - private CT_Fill _fill; + private readonly CT_Fill _fill; /** * Creates a CellFill from the supplied parts diff --git a/ooxml/XSSF/UserModel/Helpers/XSSFFormulaUtils.cs b/ooxml/XSSF/UserModel/Helpers/XSSFFormulaUtils.cs index d308d5da7..02d58caec 100644 --- a/ooxml/XSSF/UserModel/Helpers/XSSFFormulaUtils.cs +++ b/ooxml/XSSF/UserModel/Helpers/XSSFFormulaUtils.cs @@ -79,8 +79,8 @@ namespace NPOI.XSSF.UserModel.Helpers */ public class XSSFFormulaUtils { - private XSSFWorkbook _wb; - private XSSFEvaluationWorkbook _fpwb; + private readonly XSSFWorkbook _wb; + private readonly XSSFEvaluationWorkbook _fpwb; public XSSFFormulaUtils(XSSFWorkbook wb) { diff --git a/ooxml/XSSF/UserModel/XSSFBorderFormatting.cs b/ooxml/XSSF/UserModel/XSSFBorderFormatting.cs index 8382f939b..b74956dbc 100644 --- a/ooxml/XSSF/UserModel/XSSFBorderFormatting.cs +++ b/ooxml/XSSF/UserModel/XSSFBorderFormatting.cs @@ -24,7 +24,7 @@ namespace NPOI.XSSF.UserModel */ public class XSSFBorderFormatting : IBorderFormatting { - CT_Border _border; + readonly CT_Border _border; /*package*/ internal XSSFBorderFormatting(CT_Border border) diff --git a/ooxml/XSSF/UserModel/XSSFCell.cs b/ooxml/XSSF/UserModel/XSSFCell.cs index 54ac540a7..ae8b5f8bd 100644 --- a/ooxml/XSSF/UserModel/XSSFCell.cs +++ b/ooxml/XSSF/UserModel/XSSFCell.cs @@ -48,19 +48,19 @@ namespace NPOI.XSSF.UserModel public class XSSFCell : ICell { - private static String FALSE_AS_STRING = "0"; - private static String TRUE_AS_STRING = "1"; + private static readonly String FALSE_AS_STRING = "0"; + private static readonly String TRUE_AS_STRING = "1"; /** * the xml bean Containing information about the cell's location, value, * data type, formatting, and formula */ - private CT_Cell _cell; + private readonly CT_Cell _cell; /** * the XSSFRow this cell belongs to */ - private XSSFRow _row; + private readonly XSSFRow _row; /** * 0-based column index @@ -71,12 +71,12 @@ public class XSSFCell : ICell * Table of strings shared across this workbook. * If two cells contain the same string, then the cell value is the same index into SharedStringsTable */ - private SharedStringsTable _sharedStringSource; + private readonly SharedStringsTable _sharedStringSource; /** * Table of cell styles shared across all cells in a workbook. */ - private StylesTable _stylesSource; + private readonly StylesTable _stylesSource; /** * Construct a XSSFCell. diff --git a/ooxml/XSSF/UserModel/XSSFCellStyle.cs b/ooxml/XSSF/UserModel/XSSFCellStyle.cs index 947be17d5..849bcf6fc 100644 --- a/ooxml/XSSF/UserModel/XSSFCellStyle.cs +++ b/ooxml/XSSF/UserModel/XSSFCellStyle.cs @@ -37,13 +37,13 @@ namespace NPOI.XSSF.UserModel public class XSSFCellStyle : ICellStyle { - private int _cellXfId; - private StylesTable _stylesSource; + private readonly int _cellXfId; + private readonly StylesTable _stylesSource; private CT_Xf _cellXf; private CT_Xf _cellStyleXf; private XSSFFont _font; private XSSFCellAlignment _cellAlignment; - private ThemesTable _theme; + private readonly ThemesTable _theme; /** * Creates a Cell Style from the supplied parts diff --git a/ooxml/XSSF/UserModel/XSSFColorScaleFormatting.cs b/ooxml/XSSF/UserModel/XSSFColorScaleFormatting.cs index 3e7696cde..a26a764ec 100644 --- a/ooxml/XSSF/UserModel/XSSFColorScaleFormatting.cs +++ b/ooxml/XSSF/UserModel/XSSFColorScaleFormatting.cs @@ -28,7 +28,7 @@ namespace NPOI.XSSF.UserModel * component of Conditional Formatting Settings */ public class XSSFColorScaleFormatting : IColorScaleFormatting { - CT_ColorScale _scale; + readonly CT_ColorScale _scale; /*package*/ public XSSFColorScaleFormatting(CT_ColorScale scale) { diff --git a/ooxml/XSSF/UserModel/XSSFComment.cs b/ooxml/XSSF/UserModel/XSSFComment.cs index c14c28174..eb4129c0e 100644 --- a/ooxml/XSSF/UserModel/XSSFComment.cs +++ b/ooxml/XSSF/UserModel/XSSFComment.cs @@ -30,9 +30,9 @@ namespace NPOI.XSSF.UserModel public class XSSFComment : IComment { - private CT_Comment _comment; - private CommentsTable _comments; - private CT_Shape _vmlShape; + private readonly CT_Comment _comment; + private readonly CommentsTable _comments; + private readonly CT_Shape _vmlShape; /** * cached reference to the string with the comment text diff --git a/ooxml/XSSF/UserModel/XSSFConditionFilterData.cs b/ooxml/XSSF/UserModel/XSSFConditionFilterData.cs index 082375eb2..34ec9f4f4 100644 --- a/ooxml/XSSF/UserModel/XSSFConditionFilterData.cs +++ b/ooxml/XSSF/UserModel/XSSFConditionFilterData.cs @@ -6,7 +6,7 @@ namespace NPOI.OOXML.XSSF.UserModel { public class XSSFConditionFilterData:IConditionFilterData { - private CT_CfRule _cfRule; + private readonly CT_CfRule _cfRule; public XSSFConditionFilterData(CT_CfRule cfRule) { _cfRule = cfRule; diff --git a/ooxml/XSSF/UserModel/XSSFConditionalFormatting.cs b/ooxml/XSSF/UserModel/XSSFConditionalFormatting.cs index 00f535ee3..b0966b9f1 100644 --- a/ooxml/XSSF/UserModel/XSSFConditionalFormatting.cs +++ b/ooxml/XSSF/UserModel/XSSFConditionalFormatting.cs @@ -34,8 +34,8 @@ namespace NPOI.XSSF.UserModel */ public class XSSFConditionalFormatting : IConditionalFormatting { - private CT_ConditionalFormatting _cf; - private XSSFSheet _sh; + private readonly CT_ConditionalFormatting _cf; + private readonly XSSFSheet _sh; /*package*/ internal XSSFConditionalFormatting(XSSFSheet sh) diff --git a/ooxml/XSSF/UserModel/XSSFConditionalFormattingRule.cs b/ooxml/XSSF/UserModel/XSSFConditionalFormattingRule.cs index 06d2b9fdf..885f05d6e 100644 --- a/ooxml/XSSF/UserModel/XSSFConditionalFormattingRule.cs +++ b/ooxml/XSSF/UserModel/XSSFConditionalFormattingRule.cs @@ -36,11 +36,11 @@ namespace NPOI.XSSF.UserModel */ public class XSSFConditionalFormattingRule : IConditionalFormattingRule { - private CT_CfRule _cfRule; - private XSSFSheet _sh; + private readonly CT_CfRule _cfRule; + private readonly XSSFSheet _sh; - private static Dictionary typeLookup = new Dictionary(); - private static Dictionary filterTypeLookup = new Dictionary(); + private static readonly Dictionary typeLookup = new Dictionary(); + private static readonly Dictionary filterTypeLookup = new Dictionary(); static XSSFConditionalFormattingRule() { typeLookup.Add(ST_CfType.cellIs, ConditionTypeClass.CellValueIs); diff --git a/ooxml/XSSF/UserModel/XSSFDataBarFormatting.cs b/ooxml/XSSF/UserModel/XSSFDataBarFormatting.cs index e8f0bb8c4..c23ee43bd 100644 --- a/ooxml/XSSF/UserModel/XSSFDataBarFormatting.cs +++ b/ooxml/XSSF/UserModel/XSSFDataBarFormatting.cs @@ -28,7 +28,7 @@ namespace NPOI.XSSF.UserModel */ public class XSSFDataBarFormatting : IDataBarFormatting { - CT_DataBar _databar; + readonly CT_DataBar _databar; /*package*/ public XSSFDataBarFormatting(CT_DataBar databar) diff --git a/ooxml/XSSF/UserModel/XSSFEvaluationCell.cs b/ooxml/XSSF/UserModel/XSSFEvaluationCell.cs index 717e09716..abbe0de27 100644 --- a/ooxml/XSSF/UserModel/XSSFEvaluationCell.cs +++ b/ooxml/XSSF/UserModel/XSSFEvaluationCell.cs @@ -32,8 +32,8 @@ namespace NPOI.XSSF.UserModel public class XSSFEvaluationCell : IEvaluationCell { - private IEvaluationSheet _evalSheet; - private XSSFCell _cell; + private readonly IEvaluationSheet _evalSheet; + private readonly XSSFCell _cell; public XSSFEvaluationCell(ICell cell, XSSFEvaluationSheet EvaluationSheet) { diff --git a/ooxml/XSSF/UserModel/XSSFEvaluationSheet.cs b/ooxml/XSSF/UserModel/XSSFEvaluationSheet.cs index 9a568a3cc..7e2a609ac 100644 --- a/ooxml/XSSF/UserModel/XSSFEvaluationSheet.cs +++ b/ooxml/XSSF/UserModel/XSSFEvaluationSheet.cs @@ -31,7 +31,7 @@ namespace NPOI.XSSF.UserModel public class XSSFEvaluationSheet : IEvaluationSheet { - private XSSFSheet _xs; + private readonly XSSFSheet _xs; private Dictionary _cellCache; public XSSFEvaluationSheet(ISheet sheet) @@ -104,8 +104,8 @@ public IEvaluationCell GetCell(int rowIndex, int columnIndex) private class CellKey { - private int _row; - private int _col; + private readonly int _row; + private readonly int _col; private int _hash = -1; //lazily computed protected internal CellKey(int row, int col) diff --git a/ooxml/XSSF/UserModel/XSSFFont.cs b/ooxml/XSSF/UserModel/XSSFFont.cs index dbbe0b215..5bfcc57b5 100644 --- a/ooxml/XSSF/UserModel/XSSFFont.cs +++ b/ooxml/XSSF/UserModel/XSSFFont.cs @@ -50,7 +50,7 @@ public class XSSFFont : IFont public static short DEFAULT_FONT_COLOR = IndexedColors.Black.Index; private ThemesTable _themes; - private CT_Font _ctFont; + private readonly CT_Font _ctFont; private short _index; /** diff --git a/ooxml/XSSF/UserModel/XSSFFormulaEvaluator.cs b/ooxml/XSSF/UserModel/XSSFFormulaEvaluator.cs index 6da1c3c47..bd70fb5af 100644 --- a/ooxml/XSSF/UserModel/XSSFFormulaEvaluator.cs +++ b/ooxml/XSSF/UserModel/XSSFFormulaEvaluator.cs @@ -39,7 +39,7 @@ namespace NPOI.XSSF.UserModel public class XSSFFormulaEvaluator : BaseXSSFFormulaEvaluator { - private XSSFWorkbook _book; + private readonly XSSFWorkbook _book; public XSSFFormulaEvaluator(IWorkbook workbook) : this(workbook as XSSFWorkbook, null, null) diff --git a/ooxml/XSSF/UserModel/XSSFHyperlink.cs b/ooxml/XSSF/UserModel/XSSFHyperlink.cs index ca99cec9c..95a7f914c 100644 --- a/ooxml/XSSF/UserModel/XSSFHyperlink.cs +++ b/ooxml/XSSF/UserModel/XSSFHyperlink.cs @@ -30,9 +30,9 @@ namespace NPOI.XSSF.UserModel */ public class XSSFHyperlink : IHyperlink { - private HyperlinkType _type; - private PackageRelationship _externalRel; - private CT_Hyperlink _ctHyperlink; //contains a reference to the cell where the hyperlink is anchored, getRef() + private readonly HyperlinkType _type; + private readonly PackageRelationship _externalRel; + private readonly CT_Hyperlink _ctHyperlink; //contains a reference to the cell where the hyperlink is anchored, getRef() private String _location; //what the hyperlink refers to /** diff --git a/ooxml/XSSF/UserModel/XSSFIconMultiStateFormatting.cs b/ooxml/XSSF/UserModel/XSSFIconMultiStateFormatting.cs index e4e8f0f5c..7164df228 100644 --- a/ooxml/XSSF/UserModel/XSSFIconMultiStateFormatting.cs +++ b/ooxml/XSSF/UserModel/XSSFIconMultiStateFormatting.cs @@ -30,7 +30,7 @@ namespace NPOI.XSSF.UserModel */ public class XSSFIconMultiStateFormatting : IIconMultiStateFormatting { - CT_IconSet _iconset; + readonly CT_IconSet _iconset; /*package*/ internal XSSFIconMultiStateFormatting(CT_IconSet iconset) diff --git a/ooxml/XSSF/UserModel/XSSFLineBreak.cs b/ooxml/XSSF/UserModel/XSSFLineBreak.cs index b7fb725d8..a6f4c05a8 100644 --- a/ooxml/XSSF/UserModel/XSSFLineBreak.cs +++ b/ooxml/XSSF/UserModel/XSSFLineBreak.cs @@ -24,7 +24,7 @@ namespace NPOI.XSSF.UserModel public class XSSFLineBreak : XSSFTextRun { - private CT_TextCharacterProperties _brProps; + private readonly CT_TextCharacterProperties _brProps; public XSSFLineBreak(CT_RegularTextRun r, XSSFTextParagraph p, CT_TextCharacterProperties brProps) : base(r, p) diff --git a/ooxml/XSSF/UserModel/XSSFName.cs b/ooxml/XSSF/UserModel/XSSFName.cs index c5b621fb5..8f22d3094 100644 --- a/ooxml/XSSF/UserModel/XSSFName.cs +++ b/ooxml/XSSF/UserModel/XSSFName.cs @@ -109,8 +109,8 @@ public class XSSFName : IName */ public static String BUILTIN_SHEET_TITLE = "_xlnm.Sheet_Title"; - private XSSFWorkbook _workbook; - private CT_DefinedName _ctName; + private readonly XSSFWorkbook _workbook; + private readonly CT_DefinedName _ctName; /** * Creates an XSSFName object - called internally by XSSFWorkbook. diff --git a/ooxml/XSSF/UserModel/XSSFPatternFormatting.cs b/ooxml/XSSF/UserModel/XSSFPatternFormatting.cs index 3fb945cd6..f46990604 100644 --- a/ooxml/XSSF/UserModel/XSSFPatternFormatting.cs +++ b/ooxml/XSSF/UserModel/XSSFPatternFormatting.cs @@ -27,7 +27,7 @@ namespace NPOI.XSSF.UserModel */ public class XSSFPatternFormatting : IPatternFormatting { - CT_Fill _fill; + readonly CT_Fill _fill; public XSSFPatternFormatting(CT_Fill fill) { diff --git a/ooxml/XSSF/UserModel/XSSFRelation.cs b/ooxml/XSSF/UserModel/XSSFRelation.cs index a84e47299..95c425ab2 100644 --- a/ooxml/XSSF/UserModel/XSSFRelation.cs +++ b/ooxml/XSSF/UserModel/XSSFRelation.cs @@ -30,7 +30,7 @@ namespace NPOI.XSSF.UserModel public class XSSFRelation : POIXMLRelation { - private static POILogger log = POILogFactory.GetLogger(typeof(XSSFRelation)); + private static readonly POILogger log = POILogFactory.GetLogger(typeof(XSSFRelation)); /** * A map to lookup POIXMLRelation by its relation type diff --git a/ooxml/XSSF/UserModel/XSSFSheetConditionalFormatting.cs b/ooxml/XSSF/UserModel/XSSFSheetConditionalFormatting.cs index 5a6014dd1..bd63a688b 100644 --- a/ooxml/XSSF/UserModel/XSSFSheetConditionalFormatting.cs +++ b/ooxml/XSSF/UserModel/XSSFSheetConditionalFormatting.cs @@ -38,7 +38,7 @@ public class XSSFSheetConditionalFormatting : ISheetConditionalFormatting { /** Office 2010 Conditional Formatting extensions namespace */ protected static string CF_EXT_2009_NS_X14 = "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main"; - private XSSFSheet _sheet; + private readonly XSSFSheet _sheet; /* namespace */ internal XSSFSheetConditionalFormatting(XSSFSheet sheet) diff --git a/ooxml/XSSF/UserModel/XSSFSimpleShape.cs b/ooxml/XSSF/UserModel/XSSFSimpleShape.cs index c623db709..2cf5bf075 100644 --- a/ooxml/XSSF/UserModel/XSSFSimpleShape.cs +++ b/ooxml/XSSF/UserModel/XSSFSimpleShape.cs @@ -37,7 +37,7 @@ public class XSSFSimpleShape : XSSFShape, IEnumerable, ISimpl /** * List of the paragraphs that make up the text in this shape */ - private List _paragraphs; + private readonly List _paragraphs; /** * A default instance of CTShape used for creating new shapes. */ @@ -46,7 +46,7 @@ public class XSSFSimpleShape : XSSFShape, IEnumerable, ISimpl /** * Xml bean that stores properties of this shape */ - private CT_Shape ctShape; + private readonly CT_Shape ctShape; protected internal XSSFSimpleShape(XSSFDrawing Drawing, CT_Shape ctShape) { @@ -399,8 +399,8 @@ private String valueToAlpha(int value) return alpha; } - private static String[] _romanChars = new String[] { "M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I" }; - private static int[] _romanAlphaValues = new int[] { 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1 }; + private static readonly String[] _romanChars = new String[] { "M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I" }; + private static readonly int[] _romanAlphaValues = new int[] { 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1 }; /** * Convert an integer to its roman equivalent e.g. 1 = I, 9 = IX etc diff --git a/ooxml/XSSF/UserModel/XSSFTextParagraph.cs b/ooxml/XSSF/UserModel/XSSFTextParagraph.cs index 23fff1786..ffaa950e4 100644 --- a/ooxml/XSSF/UserModel/XSSFTextParagraph.cs +++ b/ooxml/XSSF/UserModel/XSSFTextParagraph.cs @@ -31,9 +31,9 @@ namespace NPOI.XSSF.UserModel */ public class XSSFTextParagraph : IEnumerator, IEnumerable { - private CT_TextParagraph _p; - private CT_Shape _shape; - private List _Runs; + private readonly CT_TextParagraph _p; + private readonly CT_Shape _shape; + private readonly List _Runs; public XSSFTextParagraph(CT_TextParagraph p, CT_Shape ctShape) { @@ -674,7 +674,7 @@ public double GetTabStop(int idx) class ParagraphPropertyFetcherTabStop : ParagraphPropertyFetcher { - private int idx; + private readonly int idx; public ParagraphPropertyFetcherTabStop(int level, int idx) : base(level) { this.idx = idx; } public override bool Fetch(CT_TextParagraphProperties props) { diff --git a/ooxml/XSSF/UserModel/XSSFTextRun.cs b/ooxml/XSSF/UserModel/XSSFTextRun.cs index 0b7c48665..75b1a7828 100644 --- a/ooxml/XSSF/UserModel/XSSFTextRun.cs +++ b/ooxml/XSSF/UserModel/XSSFTextRun.cs @@ -28,8 +28,8 @@ namespace NPOI.XSSF.UserModel */ public class XSSFTextRun { - private CT_RegularTextRun _r; - private XSSFTextParagraph _p; + private readonly CT_RegularTextRun _r; + private readonly XSSFTextParagraph _p; public XSSFTextRun(CT_RegularTextRun r, XSSFTextParagraph p) { diff --git a/ooxml/XSSF/UserModel/XSSFWorkbook.cs b/ooxml/XSSF/UserModel/XSSFWorkbook.cs index 535fbeff1..38a26c0d0 100644 --- a/ooxml/XSSF/UserModel/XSSFWorkbook.cs +++ b/ooxml/XSSF/UserModel/XSSFWorkbook.cs @@ -46,7 +46,7 @@ namespace NPOI.XSSF.UserModel */ public class XSSFWorkbook : POIXMLDocument, IWorkbook { - private static Regex COMMA_PATTERN = new Regex(",", RegexOptions.Compiled); + private static readonly Regex COMMA_PATTERN = new Regex(",", RegexOptions.Compiled); /** * Width of one character of the default font in pixels. Same for Calibry and Arial. @@ -57,7 +57,7 @@ public class XSSFWorkbook : POIXMLDocument, IWorkbook * Excel silently tRuncates long sheet names to 31 chars. * This constant is used to ensure uniqueness in the first 31 chars */ - private static int Max_SENSITIVE_SHEET_NAME_LEN = 31; + private static readonly int Max_SENSITIVE_SHEET_NAME_LEN = 31; /** Extended windows meta file */ public static int PICTURE_TYPE_EMF = 2; @@ -118,7 +118,7 @@ public class XSSFWorkbook : POIXMLDocument, IWorkbook * The locator of user-defined functions. * By default includes functions from the Excel Analysis Toolpack */ - private IndexedUDFFinder _udfFinder = new IndexedUDFFinder(UDFFinder.GetDefault()); + private readonly IndexedUDFFinder _udfFinder = new IndexedUDFFinder(UDFFinder.GetDefault()); /** * TODO @@ -155,7 +155,7 @@ public class XSSFWorkbook : POIXMLDocument, IWorkbook */ private List pictures; - private static POILogger logger = POILogFactory.GetLogger(typeof(XSSFWorkbook)); + private static readonly POILogger logger = POILogFactory.GetLogger(typeof(XSSFWorkbook)); /** * cached instance of XSSFCreationHelper for this workbook diff --git a/ooxml/XSSF/UserModel/XSSFWorkbookType.cs b/ooxml/XSSF/UserModel/XSSFWorkbookType.cs index cf7251a66..9e33e38c7 100644 --- a/ooxml/XSSF/UserModel/XSSFWorkbookType.cs +++ b/ooxml/XSSF/UserModel/XSSFWorkbookType.cs @@ -11,8 +11,8 @@ public class XSSFWorkbookType public static XSSFWorkbookType XLSX = new XSSFWorkbookType(XSSFRelation.WORKBOOK.ContentType, "xlsx"); public static XSSFWorkbookType XLSM = new XSSFWorkbookType(XSSFRelation.MACROS_WORKBOOK.ContentType, "xlsm"); - private string _contentType; - private string _extension; + private readonly string _contentType; + private readonly string _extension; private XSSFWorkbookType(string contentType, string extension) { diff --git a/ooxml/XSSF/Util/XmlEnumParser.cs b/ooxml/XSSF/Util/XmlEnumParser.cs index ddc582d8d..32dd566fe 100644 --- a/ooxml/XSSF/Util/XmlEnumParser.cs +++ b/ooxml/XSSF/Util/XmlEnumParser.cs @@ -11,7 +11,7 @@ namespace NPOI.XSSF.Util [Obsolete] public class XmlEnumParser { - private static Dictionary values; + private static readonly Dictionary values; static XmlEnumParser() { Type type = typeof(TReturn); diff --git a/ooxml/XWPF/Usermodel/XWPFDocument.cs b/ooxml/XWPF/Usermodel/XWPFDocument.cs index ab1760848..1f8ee942b 100644 --- a/ooxml/XWPF/Usermodel/XWPFDocument.cs +++ b/ooxml/XWPF/Usermodel/XWPFDocument.cs @@ -53,7 +53,7 @@ public class XWPFDocument : POIXMLDocument, Document, IBody, IDisposable /** * Keeps track on all id-values used in this document and included parts, like headers, footers, etc. */ - private IdentifierManager drawingIdManager = new IdentifierManager(0L, 4294967295L); + private readonly IdentifierManager drawingIdManager = new IdentifierManager(0L, 4294967295L); protected List footers = new List(); protected List headers = new List(); protected List hyperlinks = new List(); diff --git a/ooxml/XWPF/Usermodel/XWPFRelation.cs b/ooxml/XWPF/Usermodel/XWPFRelation.cs index 8529edf7e..da00ab65e 100644 --- a/ooxml/XWPF/Usermodel/XWPFRelation.cs +++ b/ooxml/XWPF/Usermodel/XWPFRelation.cs @@ -28,7 +28,7 @@ public class XWPFRelation : POIXMLRelation /** * A map to lookup POIXMLRelation by its relation type */ - private static Dictionary _table = new Dictionary(); + private static readonly Dictionary _table = new Dictionary(); public static XWPFRelation DOCUMENT = new XWPFRelation( diff --git a/openxml4Net/OPC/Internal/ContentTypeManager.cs b/openxml4Net/OPC/Internal/ContentTypeManager.cs index 93bf535c9..55e69b621 100644 --- a/openxml4Net/OPC/Internal/ContentTypeManager.cs +++ b/openxml4Net/OPC/Internal/ContentTypeManager.cs @@ -50,7 +50,7 @@ public abstract class ContentTypeManager /** * Default content type tree. */ - private SortedList defaultContentType; + private readonly SortedList defaultContentType; /** * Override content type tree. diff --git a/openxml4Net/OPC/Internal/MemoryPackagePartOutputStream.cs b/openxml4Net/OPC/Internal/MemoryPackagePartOutputStream.cs index aaf158bf9..5a191a045 100644 --- a/openxml4Net/OPC/Internal/MemoryPackagePartOutputStream.cs +++ b/openxml4Net/OPC/Internal/MemoryPackagePartOutputStream.cs @@ -7,9 +7,9 @@ namespace NPOI.OpenXml4Net.OPC.Internal { public class MemoryPackagePartOutputStream : Stream { - private MemoryPackagePart _part; + private readonly MemoryPackagePart _part; - private MemoryStream _buff; + private readonly MemoryStream _buff; public MemoryPackagePartOutputStream(MemoryPackagePart part) { diff --git a/openxml4Net/OPC/OPCPackage.cs b/openxml4Net/OPC/OPCPackage.cs index f71e59b70..b03e56c11 100644 --- a/openxml4Net/OPC/OPCPackage.cs +++ b/openxml4Net/OPC/OPCPackage.cs @@ -24,7 +24,7 @@ public abstract class OPCPackage : RelationshipSource, ICloseable /** * Logger. */ - private static POILogger logger = POILogFactory.GetLogger(typeof(OPCPackage)); + private static readonly POILogger logger = POILogFactory.GetLogger(typeof(OPCPackage)); /** * Default package access. @@ -34,7 +34,7 @@ public abstract class OPCPackage : RelationshipSource, ICloseable /** * Package access. */ - private PackageAccess packageAccess; + private readonly PackageAccess packageAccess; /** * Package parts collection. diff --git a/openxml4Net/OPC/PackagePart.cs b/openxml4Net/OPC/PackagePart.cs index 9941ea20d..20d2ded8f 100644 --- a/openxml4Net/OPC/PackagePart.cs +++ b/openxml4Net/OPC/PackagePart.cs @@ -35,7 +35,7 @@ public abstract class PackagePart : RelationshipSource, IComparable /** * Flag to know if this part is a relationship. */ - private bool _isRelationshipPart; + private readonly bool _isRelationshipPart; /** * Flag to know if this part has been logically deleted. diff --git a/openxml4Net/OPC/PackageRelationshipCollection.cs b/openxml4Net/OPC/PackageRelationshipCollection.cs index 2447b4ae7..bea9520a6 100644 --- a/openxml4Net/OPC/PackageRelationshipCollection.cs +++ b/openxml4Net/OPC/PackageRelationshipCollection.cs @@ -20,37 +20,37 @@ namespace NPOI.OpenXml4Net.OPC public class PackageRelationshipCollection : IEnumerator { - private static POILogger logger = POILogFactory.GetLogger(typeof(PackageRelationshipCollection)); + private static readonly POILogger logger = POILogFactory.GetLogger(typeof(PackageRelationshipCollection)); /** * Package relationships ordered by ID. */ - private SortedList relationshipsByID; + private readonly SortedList relationshipsByID; /** * A lookup of internal relationships to avoid */ - private SortedList internalRelationshipsByTargetName; + private readonly SortedList internalRelationshipsByTargetName; /** * This relationshipPart. */ - private PackagePart relationshipPart; + private readonly PackagePart relationshipPart; /** * Source part. */ - private PackagePart sourcePart; + private readonly PackagePart sourcePart; /** * This part name. */ - private PackagePartName partName; + private readonly PackagePartName partName; /** * Reference to the package. */ - private OPCPackage container; + private readonly OPCPackage container; /** * The ID number of the next rID# to generate, or -1 * if that is still to be determined. diff --git a/openxml4Net/OPC/ZipPackage.cs b/openxml4Net/OPC/ZipPackage.cs index 595e550ca..abd1c89e7 100644 --- a/openxml4Net/OPC/ZipPackage.cs +++ b/openxml4Net/OPC/ZipPackage.cs @@ -18,15 +18,15 @@ namespace NPOI.OpenXml4Net.OPC */ public class ZipPackage : OPCPackage { - private static String MIMETYPE = "mimetype"; - private static String SETTINGS_XML = "settings.xml"; - private static POILogger logger = POILogFactory.GetLogger(typeof(ZipPackage)); + private static readonly String MIMETYPE = "mimetype"; + private static readonly String SETTINGS_XML = "settings.xml"; + private static readonly POILogger logger = POILogFactory.GetLogger(typeof(ZipPackage)); /** * Zip archive, as either a file on disk, * or a stream */ - private Util.ZipEntrySource zipArchive; + private readonly Util.ZipEntrySource zipArchive; bool isStream = false; // whether the file is passed in with stream, no means passed in with string path public bool IsExternalStream { get { return isStream; } set { isStream = value; } }