{"record":{"id":"175223c1a4502e82","repo":"dotnet/wpf","slug":"sr-effect-shadereffectpadding","errorCode":null,"errorMessage":"SR.Effect_ShaderEffectPadding","messagePattern":"SR\\.Effect_ShaderEffectPadding","errorType":"validation","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Effects/ShaderEffect.cs","lineNumber":44,"sourceCode":"        }\n\n        /// <summary>\n        /// Padding is used to specify that an effect's output texture is larger than its input\n        /// texture in a specific direction, e.g. for a drop shadow effect.\n        /// </summary>\n        protected double PaddingTop\n        {\n            get\n            {\n                ReadPreamble();\n                return _topPadding;\n            }\n            set\n            {\n                WritePreamble();\n                if (value < 0.0)\n                {\n                    throw new ArgumentOutOfRangeException(nameof(value), value, SR.Effect_ShaderEffectPadding);\n                }\n                else\n                {\n                    _topPadding = value;\n                    RegisterForAsyncUpdateResource();\n                }\n                WritePostscript();\n            }\n        }\n\n        /// <summary>\n        /// Padding is used to specify that an effect's output texture is larger than its input\n        /// texture in a specific direction, e.g. for a drop shadow effect.\n        /// </summary>\n        protected double PaddingBottom\n        {\n            get\n            {","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Effects/ShaderEffect.cs#L26-L62","documentation":"The PaddingTop property setter of ShaderEffect rejects negative values with an ArgumentOutOfRangeException carrying Effect_ShaderEffectPadding. Padding expands the region the effect renders into and must be zero or positive.","triggerScenarios":"Assigning PaddingTop = -n (or a computed value that goes negative) on a ShaderEffect-derived class instance.","commonSituations":"Computing padding from a formula that can yield negative results (e.g. subtracting sizes); binding a negative value; copy/paste errors swapping signs.","solutions":["Set PaddingTop to a non-negative value (0 or greater).","Clamp before assigning: effect.PaddingTop = Math.Max(0, computedPadding);","If shrinking is intended, note that padding cannot be negative; restructure the effect instead."],"exampleFix":"// before\neffect.PaddingTop = extraSpace; // extraSpace may be negative\n// after\neffect.PaddingTop = Math.Max(0, extraSpace);","handlingStrategy":"validation","validationCode":"if (topPadding < 0) topPadding = 0;\neffect.PaddingTop = topPadding;","typeGuard":"static double ClampPadding(double v) => Math.Max(0.0, v);","tryCatchPattern":null,"preventionTips":["Clamp all padding values with Math.Max(0, value) before assignment.","Validate data-bound/user-supplied padding at the input boundary.","Remember ShaderEffect padding cannot be negative by design."],"tags":["wpf","shadereffect","argument-out-of-range"],"backgroundTag":"argument-out-of-range","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-22T01:17:13.364Z"}