forked from peopleworks/XAFLogicExplainer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExtractedEntity.cs
More file actions
311 lines (261 loc) · 9.37 KB
/
Copy pathExtractedEntity.cs
File metadata and controls
311 lines (261 loc) · 9.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
namespace XafLogicExplainer.Core.Models;
/// <summary>
/// Describes one extracted business entity and its structural metadata.
/// </summary>
public class ExtractedEntity
{
/// <summary>
/// Entity class name.
/// </summary>
public string ClassName { get; set; } = string.Empty;
/// <summary>
/// Declared namespace.
/// </summary>
public string Namespace { get; set; } = string.Empty;
/// <summary>
/// Source file path for the entity declaration.
/// </summary>
public string FilePath { get; set; } = string.Empty;
/// <summary>
/// Name of the project this entity was extracted from (e.g. "Module", "Blazor.Server").
/// </summary>
public string? SourceProject { get; set; }
/// <summary>
/// Description text read from attributes when available.
/// </summary>
public string? Description { get; set; }
/// <summary>
/// Navigation group name associated with this entity.
/// </summary>
public string? NavigationGroup { get; set; }
/// <summary>
/// Display/default property name used by XAF.
/// </summary>
public string? DefaultProperty { get; set; }
/// <summary>
/// Base type string from inheritance chain.
/// </summary>
public string BaseType { get; set; } = string.Empty;
/// <summary>
/// Everything the class declares after the colon: its base class and its interfaces.
/// </summary>
/// <remarks>
/// XAF's controller test is <c>Type.IsAssignableFrom</c>, which an interface satisfies — and
/// DevExpress uses that: <c>ChangePasswordController</c> targets
/// <c>IAuthenticationStandardUser</c>, not a class. Following the base class alone made every
/// interface-targeted controller match no view at all, silently.
/// <para>
/// Not split into "base class" and "interfaces" because syntax alone cannot tell them apart,
/// and for an assignability test the distinction does not matter: everything listed here is
/// truthfully an ancestor.
/// </para>
/// </remarks>
public List<string> BaseTypes { get; set; } = [];
/// <summary>
/// Indicates whether <c>DefaultClassOptions</c> is present.
/// </summary>
public bool IsDefaultClassOptions { get; set; }
/// <summary>
/// Indicates whether this entity is persistent.
/// </summary>
public bool IsPersistent { get; set; } = true;
/// <summary>
/// Whether the class is declared <c>abstract</c>.
/// </summary>
/// <remarks>
/// An abstract base appears in the inventory because its descendants are found through it, but
/// it is not itself something a user opens. Once its properties are folded into every
/// descendant, a renderer needs this to say which heading is a table and which is a convention.
/// </remarks>
public bool IsAbstract { get; set; }
/// <summary>
/// Scalar and collection properties discovered in source.
/// </summary>
public List<ExtractedProperty> Properties { get; set; } = [];
/// <summary>
/// Relationships inferred from attributes and navigation properties.
/// </summary>
public List<ExtractedRelationship> Relationships { get; set; } = [];
/// <summary>
/// Validation rules declared at class or property level.
/// </summary>
public List<ExtractedValidationRule> ValidationRules { get; set; } = [];
/// <summary>
/// Appearance/customization rules declared via attributes.
/// </summary>
public List<ExtractedAppearanceRule> AppearanceRules { get; set; } = [];
/// <summary>
/// Additional inferred business logic rules.
/// </summary>
public List<ExtractedBusinessRule> InferredBusinessRules { get; set; } = [];
/// <summary>
/// Source comments found around the class declaration.
/// </summary>
public List<string> SourceComments { get; set; } = [];
/// <summary>
/// Caption value extracted from Model Editor metadata.
/// </summary>
public string? ModelCaption { get; set; }
/// <summary>
/// Indicates whether class is marked cloneable in model metadata.
/// </summary>
public bool IsCloneable { get; set; }
}
/// <summary>
/// Describes one extracted entity property.
/// </summary>
public class ExtractedProperty
{
/// <summary>
/// Property name.
/// </summary>
public string Name { get; set; } = string.Empty;
/// <summary>
/// The class that declared this property, when it is not the entity listing it.
/// </summary>
/// <remarks>
/// <c>null</c> for a property the entity declares itself. Knowing <c>ChangedOn</c> comes from
/// a shared audit base and not from the entity is worth something to a reader — it is usually
/// how they learn the property is not theirs to set.
/// </remarks>
public string? InheritedFrom { get; set; }
/// <summary>
/// A copy this property's declarer does not share.
/// </summary>
/// <remarks>
/// Folding lists the same declared property under every descendant, and each listing carries
/// its own <see cref="InheritedFrom"/>. Stamping that on a shared instance would rewrite the
/// declaring entity's own listing.
/// </remarks>
public ExtractedProperty Clone()
{
var copy = (ExtractedProperty)MemberwiseClone();
copy.CustomAttributes = [.. CustomAttributes];
return copy;
}
/// <summary>
/// Declared CLR type text.
/// </summary>
public string TypeName { get; set; } = string.Empty;
/// <summary>
/// User-facing description from attributes.
/// </summary>
public string? Description { get; set; }
/// <summary>
/// Size constraint when defined.
/// </summary>
public int? Size { get; set; }
/// <summary>
/// Indicates whether property is part of the key.
/// </summary>
public bool IsKey { get; set; }
/// <summary>
/// Whether the database refuses a duplicate value, from <c>[Indexed(Unique = true)]</c>.
/// </summary>
/// <remarks>
/// A constraint the user meets as a save that fails, and the only one enforced below the
/// application. It was captured nowhere — so an import, an integration or a seed method could
/// be written against documentation that promised to hold every rule and never mentioned it.
/// </remarks>
public bool IsUnique { get; set; }
/// <summary>
/// Indicates whether property represents a collection relation.
/// </summary>
public bool IsCollection { get; set; }
/// <summary>
/// Indicates whether property is computed or non-persistent.
/// </summary>
public bool IsComputed { get; set; }
/// <summary>
/// Indicates whether value is required by rules or attributes.
/// </summary>
public bool IsRequired { get; set; }
/// <summary>
/// Display name override.
/// </summary>
public string? DisplayName { get; set; }
/// <summary>
/// Tooltip metadata.
/// </summary>
public string? ToolTip { get; set; }
/// <summary>
/// Display format metadata.
/// </summary>
public string? DisplayFormat { get; set; }
/// <summary>
/// Editor alias metadata.
/// </summary>
public string? EditorAlias { get; set; }
/// <summary>
/// Indicates list view visibility.
/// </summary>
public bool VisibleInListView { get; set; } = true;
/// <summary>
/// Indicates detail view visibility.
/// </summary>
public bool VisibleInDetailView { get; set; } = true;
/// <summary>
/// Persistent alias expression (XPO).
/// </summary>
public string? PersistentAlias { get; set; }
/// <summary>
/// Data source criteria expression.
/// </summary>
public string? DataSourceCriteria { get; set; }
/// <summary>
/// Indicates whether ImmediatePostData is enabled.
/// </summary>
public bool ImmediatePostData { get; set; }
/// <summary>
/// Default value metadata from model defaults or initializer.
/// </summary>
public string? DefaultValue { get; set; }
/// <summary>
/// Attribute expressions not mapped to common fields.
/// </summary>
public List<string> CustomAttributes { get; set; } = [];
}
/// <summary>
/// Describes a relationship between entities inferred from one property.
/// </summary>
public class ExtractedRelationship
{
/// <summary>
/// Relationship source property name.
/// </summary>
public string PropertyName { get; set; } = string.Empty;
/// <summary>
/// Related target entity type.
/// </summary>
public string RelatedEntity { get; set; } = string.Empty;
/// <summary>
/// XAF association identifier when declared.
/// </summary>
public string? AssociationName { get; set; }
/// <summary>
/// Relationship direction/cardinality category.
/// </summary>
public RelationshipType Type { get; set; }
/// <summary>
/// Indicates aggregate composition semantics.
/// </summary>
public bool IsAggregated { get; set; }
}
/// <summary>
/// Relationship cardinality model.
/// </summary>
public enum RelationshipType
{
/// <summary>
/// Many source items can reference one target item.
/// </summary>
ManyToOne,
/// <summary>
/// One source item can reference many target items.
/// </summary>
OneToMany,
/// <summary>
/// Many source items can reference many target items.
/// </summary>
ManyToMany
}