{"record":{"id":"b03efe403df1e9be","repo":"dotnet/wpf","slug":"xml-file-not-found-simplegenerator","errorCode":null,"errorMessage":"XML file not found","messagePattern":"XML file not found","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/WpfGfx/codegen/mcg/main/SimpleGenerator.cs","lineNumber":185,"sourceCode":"            //\n            // Handle \"-h\" option.\n            //\n\n            if (parsedArgs.help)\n            {\n                Usage();\n                data = null;\n                return;\n            }\n\n\n            //\n            // Check that files exist\n            //\n\n            if (!File.Exists(parsedArgs.xmlFile))\n            {\n                throw new FileNotFoundException(\"XML file not found\", parsedArgs.xmlFile);\n            }\n\n            //\n            // Load the XML file and create the resource model from it\n            //\n\n            // Create an instance of the XmlSerializer specifying type and namespace.\n            XmlSerializer serializer = new XmlSerializer(Type.GetType(parsedArgs.dataType));\n\n            // A FileStream is needed to read the XML document.\n            using (FileStream fs = new FileStream(parsedArgs.xmlFile, FileMode.Open, FileAccess.Read))\n            using (XmlReader reader = new XmlTextReader(fs))\n            {\n                data = (CG) serializer.Deserialize(reader);\n            }\n\n            data.OutputDirectory = parsedArgs.outputDirectory;\n        }","sourceCodeStart":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/WpfGfx/codegen/mcg/main/SimpleGenerator.cs#L167-L203","documentation":"SimpleGenerator.ProcessArgs validates its inputs and throws FileNotFoundException when the XML data file supplied via parsedArgs.xmlFile does not exist. As with ResourceGenerator, this is a fail-fast existence check performed before the resource model is loaded.","triggerScenarios":"Running the SimpleGenerator tool with an XML path that does not exist: typo, wrong working directory, relative path resolved differently than expected, or the file was removed before the run.","commonSituations":"Build/automation scripts invoking the generator from a different cwd; missing file in CI checkout; renaming or moving the XML data file without updating the invocation.","solutions":["Verify the exact XML path exists from the tool's working directory.","Pass an absolute path in the invoking script.","Restore or check out the missing XML file before running the generator."],"exampleFix":"// before\ncsp SimpleGenerator data.xml\n// after\ncsp SimpleGenerator C:\\src\\gen\\data.xml","handlingStrategy":"validation","validationCode":"if (!File.Exists(xmlPath))\n    throw new FileNotFoundException($\"XML data file missing: {Path.GetFullPath(xmlPath)}\");","typeGuard":null,"tryCatchPattern":"try { generator.ProcessArgs(args); }\ncatch (FileNotFoundException ex) when (ex.FileName == xmlPath) { Console.Error.WriteLine($\"XML file not found: {ex.FileName}\"); return 2; }","preventionTips":["Invoke the generator with absolute file paths.","Verify input existence in the invoking script before running.","Ensure the XML data file is present in CI checkouts."],"tags":["filenotfound","cli","codegen","input-validation"],"backgroundTag":"file-not-found","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"}