{"record":{"id":"37aecbb736645a59","repo":"dotnet/wpf","slug":"commitcountpolicy-must-be-greater-than-zero","errorCode":null,"errorMessage":"CommitCountPolicy must be greater than zero.","messagePattern":"CommitCountPolicy must be greater than zero\\.","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/XpsFontSubsetter.cs","lineNumber":363,"sourceCode":"          _commitPolicy = policy;\n        }\n\n        /// <summary> \n        /// Determines the number of signals subsets will be commited on\n        ///</summary> \n        public\n        void\n        SetSubsetCommitCountPolicy( int commitCount )\n        {\n            if( _commitPolicy == FontSubsetterCommitPolicies.CommitEntireSequence &&\n                commitCount != 1 )\n            {\n                throw new ArgumentOutOfRangeException(SR.ReachPackaging_SequenceCntMustBe1);\n            }\n            else\n            if( commitCount < 1 )\n            {\n                throw new ArgumentOutOfRangeException(SR.ReachPackaging_CommitCountPolicyLessThan1);\n            }\n            _commitCountPolicy = commitCount;\n        }\n        #endregion Public methods\n        \n        #region Private data\n\n        private IDictionary<Uri, FEMCacheItem>  _fontEmbeddingManagerCache;\n        private BasePackagingPolicy             _packagingPolicy;\n        private FontSubsetterCommitPolicies     _commitPolicy = FontSubsetterCommitPolicies.CommitEntireSequence;\n        private int                             _commitCountPolicy = 1;\n        private int                             _currentCommitCnt = 0;\n        #endregion Private data\n\n        #region Private methods\n\n        /// <summary>\n        /// Acquires a cache item for the specified font.  If one","sourceCodeStart":345,"sourceCodeEnd":381,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/ReachFramework/Serialization/XpsFontSubsetter.cs#L345-L381","documentation":"The subsetter requires a positive commit count. Passing commitCount < 1 (zero or negative) throws ArgumentOutOfRangeException with ReachPackaging_CommitCountPolicyLessThan1. A count of 0 or less has no meaning for font subsetting batches.","triggerScenarios":"Calling SetFontSubsettingCountPolicy with 0 or a negative value, often from a misparsed configuration value or an uninitialized int defaulting through a decrement.","commonSituations":"Reading the subsetting count from app config where the value is 0/empty, or computing the count dynamically and getting a non-positive result.","solutions":["Pass a commit count >= 1","Clamp or validate the configured value before calling","Fix the configuration source that yields a non-positive count"],"exampleFix":"// before\nint count = int.Parse(config[\"SubsetCount\"]); // could be 0\nfontSubsetter.SetFontSubsettingCountPolicy(count);\n// after\nint count = Math.Max(1, int.Parse(config[\"SubsetCount\"] ?? \"1\"));\nfontSubsetter.SetFontSubsettingCountPolicy(count);","handlingStrategy":"validation","validationCode":"if (count < 1) throw new ArgumentOutOfRangeException(nameof(count));\nfontSubsetter.SetFontSubsettingCountPolicy(count);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Clamp configured values with Math.Max(1, value)","Validate config values at startup"],"tags":["wpf","xps","argument-out-of-range","font-subsetting"],"backgroundTag":"value-out-of-range","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-21T21:30:21.729Z"}