You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.Errors.cs
+33-5Lines changed: 33 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -7,8 +7,36 @@
7
7
8
8
namespaceUno.UI.SourceGenerators.XamlGenerator;
9
9
10
+
/*
11
+
* About error handling in XamlFileGenerator:
12
+
*
13
+
* *** We should raise/generate only XamlGenerationException from code generation logic. ***
14
+
*
15
+
* This allows to properly capture location information and context about the error and proper reporting to the user.
16
+
* Other kind of exception should strictly be reserved to internal logic errors that should never happen during normal operation (including with invalid XAML file).
17
+
*
18
+
* Messages:
19
+
* ** Error messages are reported to the end-user. **
20
+
* - They must not explain internal implementation details (e.g. Value of member is null),
21
+
* but rather focus on what the user did wrong and how to fix it (e.g. The 'TargetType' is not set on 'Style').
22
+
* (Reminder: errors are reported with location in the XAML file, prefer simple error message avoiding fullname/namespace of types for instance).
23
+
* - Variables are expected to be surrounded by simple quotes (e.g. 'MyElement') to improve readability (_follows MS logic_).
24
+
* - They must not end with a dot ('.'), as the dot is added when generating the error comment in the generated code (_follows MS logic_).
25
+
*
26
+
* When it's possible to continue to generate valid C# code, prefer to use AddError(), GenerateError() instead of throwing.
27
+
* This allows the user to get all errors of a XAML file in a single build instead of fixing them one by one.
28
+
*
29
+
* The Safely methods allow to properly handle errors in code generation blocks.
30
+
* They should be used to wrap any code generation block that can raise exceptions.
31
+
* Like for the AddError and GenerateError, they give the ability to the user to get all errors in a single build by continuing generation of the end of the XAML file.
0 commit comments