Skip to content

Commit 0bec7b2

Browse files
committed
Updated targeted C# models to include a ModelSourceFile property. This will contain the fully qualified path of the file that was used to load the source code model.
1 parent d72d28b commit 0bec7b2

File tree

17 files changed

+451
-31
lines changed

17 files changed

+451
-31
lines changed

src/CodeFactoryVisualStudio/CodeFactory.DotNet/CSharp/CsAttribute.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public abstract class CsAttribute:CsModel,ICsAttribute
3232
/// <param name="hasErrors">Flag that determine if errors were found creating the model.</param>
3333
/// <param name="loadedFromSource">Flag that determines if the model was loaded from source code or from an existing library.</param>
3434
/// <param name="language">The target language the model was generated from.</param>
35+
/// <param name="modelSourceFile">The soure code file for the model.</param>
3536
/// <param name="type">The target type of the attribute.</param>
3637
/// <param name="sourceDocument">The source document that was used to build this model. This is optional parameter and can be null.</param>
3738
/// <param name="modelStore">Optional the lookup storage for models created during the compile or lookup of the model.</param>
@@ -40,11 +41,12 @@ public abstract class CsAttribute:CsModel,ICsAttribute
4041
/// <param name="hasParameters">Flag that determines if the attribute has parameters.</param>
4142
/// <param name="parentPath">The fully qualified lookup path to the parent model for this attribute.</param>
4243
/// <param name="parameters">The list of parameters assigned to the attribute.</param>
43-
protected CsAttribute(bool isLoaded, bool hasErrors, bool loadedFromSource, SourceCodeType language,
44+
protected CsAttribute(bool isLoaded, bool hasErrors, bool loadedFromSource, SourceCodeType language, string modelSourceFile,
4445
IReadOnlyList<string> sourceFiles, bool hasParameters, string parentPath, IReadOnlyList<CsAttributeParameter> parameters,
4546
CsType type, string sourceDocument = null, ModelStore<ICsModel> modelStore = null, IReadOnlyList<ModelLoadException> modelErrors = null)
4647
: base(isLoaded, hasErrors, loadedFromSource, language, CsModelType.Attribute, sourceDocument, modelStore, modelErrors)
4748
{
49+
_modelSourceFile = modelSourceFile;
4850
_sourceFiles = sourceFiles ?? ImmutableList<string>.Empty;
4951
_hasParameters = hasParameters;
5052
_parentPath = parentPath;
@@ -179,5 +181,12 @@ protected CsAttribute(bool isLoaded, bool hasErrors, bool loadedFromSource, Sour
179181
/// </summary>
180182
public CsModel Parent => GetModel(_parentPath);
181183

184+
/// <summary>
185+
/// Backing field for <see cref="ModelSourceFile"/>
186+
/// </summary>
187+
private readonly string _modelSourceFile;
188+
189+
/// <inheritdoc/>
190+
public string ModelSourceFile => _modelSourceFile;
182191
}
183192
}

src/CodeFactoryVisualStudio/CodeFactory.DotNet/CSharp/CsClass.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public abstract class CsClass:CsContainer,ICsClass
3939
/// <param name="hasStrongTypesInGenerics">Flag that determines if the generics use strong type definitions.</param>
4040
/// <param name="genericParameters">Generic parameters assigned to the container.</param>
4141
/// <param name="genericTypes">Target types for the generic parameters assigned to the container.</param>
42+
/// <param name="modelSourceFile">The source code file the model was generated from.</param>
4243
/// <param name="sourceFiles">List of the fully qualified paths to the source code files this model is defined in.</param>
4344
/// <param name="hasDocumentation">Flag that determines if the model has XML documentation assigned to it.</param>
4445
/// <param name="documentation">The xml documentation assigned to the model.</param>
@@ -53,13 +54,13 @@ public abstract class CsClass:CsContainer,ICsClass
5354
/// <param name="isSealed">Flag that determines if the model is sealed.</param>
5455
protected CsClass(bool isLoaded, bool hasErrors, bool loadedFromSource, SourceCodeType language,
5556
IReadOnlyList<CsAttribute> attributes, bool isGeneric, bool hasStrongTypesInGenerics,
56-
IReadOnlyList<CsGenericParameter> genericParameters, IReadOnlyList<CsType> genericTypes, IReadOnlyList<string> sourceFiles,
57+
IReadOnlyList<CsGenericParameter> genericParameters, IReadOnlyList<CsType> genericTypes, string modelSourceFile, IReadOnlyList<string> sourceFiles,
5758
bool hasDocumentation, string documentation, string lookupPath, string name, string ns, string parentPath,
5859
CsSecurity security, IReadOnlyList<CsInterface> inheritedInterfaces, IReadOnlyList<CsMember> members,
5960
bool isStatic, bool isAbstract, bool isSealed, CsClass baseClass, string sourceDocument = null,
6061
ModelStore<ICsModel> modelStore = null, IReadOnlyList<ModelLoadException> modelErrors = null)
6162
: base(isLoaded, hasErrors, loadedFromSource, language, CsModelType.Class, attributes,
62-
isGeneric, hasStrongTypesInGenerics, genericParameters, genericTypes, sourceFiles, hasDocumentation,
63+
isGeneric, hasStrongTypesInGenerics, genericParameters, genericTypes, modelSourceFile, sourceFiles, hasDocumentation,
6364
documentation, lookupPath, name, ns, parentPath, CsContainerType.Class, security, inheritedInterfaces,
6465
members, sourceDocument, modelStore, modelErrors)
6566
{

src/CodeFactoryVisualStudio/CodeFactory.DotNet/CSharp/CsContainer.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public abstract class CsContainer:CsModel,ICsContainer
5454
/// <param name="hasStrongTypesInGenerics">Flag that determines if the generics use strong type definitions.</param>
5555
/// <param name="genericParameters">Generic parameters assigned to the container.</param>
5656
/// <param name="genericTypes">Target types for the generic parameters assigned to the container.</param>
57+
/// <param name="modelSourceFile">The source file the model was loaded from.</param>
5758
/// <param name="sourceFiles">List of the fully qualified paths to the source code files this model is defined in.</param>
5859
/// <param name="hasDocumentation">Flag that determines if the model has XML documentation assigned to it.</param>
5960
/// <param name="documentation">The xml documentation assigned to the model.</param>
@@ -66,7 +67,7 @@ public abstract class CsContainer:CsModel,ICsContainer
6667
/// <param name="inheritedInterfaces">The interfaces that are inherited by this container.</param>
6768
protected CsContainer(bool isLoaded, bool hasErrors, bool loadedFromSource, SourceCodeType language, CsModelType modelType,
6869
IReadOnlyList<CsAttribute> attributes, bool isGeneric, bool hasStrongTypesInGenerics,
69-
IReadOnlyList<CsGenericParameter> genericParameters, IReadOnlyList<CsType> genericTypes,
70+
IReadOnlyList<CsGenericParameter> genericParameters, IReadOnlyList<CsType> genericTypes, string modelSourceFile,
7071
IReadOnlyList<string> sourceFiles, bool hasDocumentation, string documentation, string lookupPath,
7172
string name, string ns, string parentPath, CsContainerType containerType, CsSecurity security,
7273
IReadOnlyList<CsInterface> inheritedInterfaces, IReadOnlyList<CsMember> members,
@@ -78,6 +79,7 @@ protected CsContainer(bool isLoaded, bool hasErrors, bool loadedFromSource, Sour
7879
_hasStrongTypesInGenerics = hasStrongTypesInGenerics;
7980
_genericParameters = genericParameters ?? ImmutableList<CsGenericParameter>.Empty;
8081
_genericTypes = genericTypes ?? ImmutableList<CsType>.Empty;
82+
_modelSourceFile = modelSourceFile;
8183
_sourceFiles = sourceFiles ?? ImmutableList<string>.Empty;
8284
_hasDocumentation = hasDocumentation;
8385
_documentation = documentation;
@@ -393,5 +395,13 @@ protected CsContainer(bool isLoaded, bool hasErrors, bool loadedFromSource, Sour
393395
/// The parent to the current model. This will return null if there is no parent for this model, or the parent could not be located.
394396
/// </summary>
395397
public CsModel Parent => GetModel(_parentPath);
398+
399+
/// <summary>
400+
/// Backing field for <see cref="ModelSourceFile"/>
401+
/// </summary>
402+
private readonly string _modelSourceFile;
403+
404+
/// <inheritdoc/>
405+
public string ModelSourceFile => _modelSourceFile;
396406
}
397407
}

src/CodeFactoryVisualStudio/CodeFactory.DotNet/CSharp/CsDelegate.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public abstract class CsDelegate:CsModel,ICsDelegate
5555
/// <param name="hasDocumentation">Flag that determines if the model has XML documentation assigned to it.</param>
5656
/// <param name="documentation">The xml documentation assigned to the model.</param>
5757
/// <param name="lookupPath">The fully qualified model lookup path for this model.</param>
58+
/// <param name="modelSourceFile">The source code file the model was created from.</param>
5859
/// <param name="sourceFiles">List of the fully qualified paths to the source code files this member is defined in.</param>
5960
/// <param name="name">The name of the model.</param>
6061
/// <param name="ns">The namespace this delegate is assigned to.</param>
@@ -72,7 +73,7 @@ public abstract class CsDelegate:CsModel,ICsDelegate
7273
/// <param name="modelErrors">Optional the error that occured while creating the model.</param>
7374
protected CsDelegate(bool isLoaded, bool hasErrors, bool loadedFromSource, SourceCodeType language,
7475
IReadOnlyList<CsAttribute> attributes, bool isGeneric, bool hasStrongTypesInGenerics, IReadOnlyList<CsGenericParameter> genericParameters,
75-
IReadOnlyList<CsType> genericTypes, bool hasDocumentation, string documentation, string lookupPath,
76+
IReadOnlyList<CsType> genericTypes, bool hasDocumentation, string documentation, string lookupPath, string modelSourceFile,
7677
IReadOnlyList<string> sourceFiles, string name, string ns, bool hasParameters, bool isVoid, string parentPath,
7778
CsSecurity security, CsType returnType, IReadOnlyList<CsParameter> parameters, CsMethod invokeMethod,
7879
CsMethod beginInvokeMethod, CsMethod endInvokeMethod, string sourceDocument = null, ModelStore<ICsModel> modelStore = null, IReadOnlyList<ModelLoadException> modelErrors = null)
@@ -86,6 +87,7 @@ protected CsDelegate(bool isLoaded, bool hasErrors, bool loadedFromSource, Sourc
8687
_hasDocumentation = hasDocumentation;
8788
_documentation = documentation;
8889
_lookupPath = lookupPath;
90+
_modelSourceFile = modelSourceFile;
8991
_sourceFiles = sourceFiles ?? ImmutableList<string>.Empty;
9092
_name = name;
9193
_ns = ns;
@@ -348,6 +350,14 @@ protected CsDelegate(bool isLoaded, bool hasErrors, bool loadedFromSource, Sourc
348350
/// <summary>
349351
/// The parent to the current model. This will return null if there is no parent for this model, or the parent could not be located.
350352
/// </summary>
351-
public CsModel Parent => LookupModel(_parentPath);
353+
public CsModel Parent => GetModel(_parentPath);
354+
355+
/// <summary>
356+
/// Backing field for <see cref="ModelSourceFile"/>
357+
/// </summary>
358+
private readonly string _modelSourceFile;
359+
360+
/// <inheritdoc/>
361+
public string ModelSourceFile => _modelSourceFile;
352362
}
353363
}

src/CodeFactoryVisualStudio/CodeFactory.DotNet/CSharp/CsEnum.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,13 @@ public abstract class CsEnum:CsModel,ICsEnum
4747
/// <param name="hasDocumentation">Flag that determines if the model has XML documentation assigned to it.</param>
4848
/// <param name="documentation">The xml documentation assigned to the model.</param>
4949
/// <param name="lookupPath">The fully qualified model lookup path for this model.</param>
50+
/// <param name="modelSourceFile">The source code file the model was generated from.</param>
5051
/// <param name="name">The name of the model.</param>
52+
/// <param name="ns"></param>
5153
/// <param name="parentPath">The fully qualified lookup path for the parent model to this one.</param>
5254
/// <param name="security">The security scope assigned to this model.</param>
5355
protected CsEnum(bool isLoaded, bool hasErrors, bool loadedFromSource, SourceCodeType language,
54-
IReadOnlyList<CsAttribute> attributes, string parentPath, bool hasDocumentation, string documentation, string lookupPath,
56+
IReadOnlyList<CsAttribute> attributes, string parentPath, bool hasDocumentation, string documentation, string lookupPath,string modelSourceFile,
5557
IReadOnlyList<string> sourceFiles, string name, string ns, CsSecurity security, IReadOnlyList<CsEnumValue> values,
5658
string sourceDocument = null, ModelStore<ICsModel> modelStore = null, IReadOnlyList<ModelLoadException> modelErrors = null): base(isLoaded, hasErrors, loadedFromSource, language, CsModelType.Enum, sourceDocument, modelStore, modelErrors)
5759
{
@@ -60,6 +62,7 @@ protected CsEnum(bool isLoaded, bool hasErrors, bool loadedFromSource, SourceCod
6062
_hasDocumentation = hasDocumentation;
6163
_documentation = documentation;
6264
_lookupPath = lookupPath;
65+
_modelSourceFile = modelSourceFile;
6366
_sourceFiles = sourceFiles ?? ImmutableList<string>.Empty;
6467
_name = name;
6568
_ns = ns;
@@ -90,7 +93,7 @@ protected CsEnum(bool isLoaded, bool hasErrors, bool loadedFromSource, SourceCod
9093
/// <summary>
9194
/// The parent to the current model. This will return null if there is no parent for this model, or the parent could not be located.
9295
/// </summary>
93-
public CsModel Parent => LookupModel(_parentPath);
96+
public CsModel Parent => GetModel(_parentPath);
9497

9598
/// <summary>
9699
/// Flag that determines if the model has code level documentation assigned to it.
@@ -231,5 +234,13 @@ protected CsEnum(bool isLoaded, bool hasErrors, bool loadedFromSource, SourceCod
231234
/// List of the enumeration values implemented in this enumeration.
232235
/// </summary>
233236
IReadOnlyList<IDotNetEnumValue> IDotNetEnum.Values => Values;
237+
238+
/// <summary>
239+
/// Backing field for <see cref="ModelSourceFile"/>
240+
/// </summary>
241+
private readonly string _modelSourceFile;
242+
243+
/// <inheritdoc/>
244+
public string ModelSourceFile => _modelSourceFile;
234245
}
235246
}

src/CodeFactoryVisualStudio/CodeFactory.DotNet/CSharp/CsEnumValue.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,13 @@ public abstract class CsEnumValue:CsModel,ICsEnumValue
4545
/// <param name="hasDocumentation">Flag that determines if the model has XML documentation assigned to it.</param>
4646
/// <param name="documentation">The xml documentation assigned to the model.</param>
4747
/// <param name="lookupPath">The fully qualified model lookup path for this model.</param>
48+
/// <param name="modelSourceFile">The source code file the model was generated from.</param>
4849
/// <param name="name">The name of the model.</param>
4950
/// <param name="parentPath">The fully qualified lookup path for the parent model to this one.</param>
5051
/// <param name="value">The value assigned to the enumeration value.</param>
5152
/// <param name="security">The security scope assigned to this model.</param>
5253
protected CsEnumValue(bool isLoaded, bool hasErrors, bool loadedFromSource, SourceCodeType language,
53-
IReadOnlyList<CsAttribute> attributes, string parentPath, bool hasDocumentation, string documentation, string lookupPath,
54+
IReadOnlyList<CsAttribute> attributes, string parentPath, bool hasDocumentation, string documentation, string lookupPath, string modelSourceFile,
5455
IReadOnlyList<string> sourceFiles, string name,
5556
string value, CsSecurity security, string sourceDocument = null, ModelStore<ICsModel> modelStore = null, IReadOnlyList<ModelLoadException> modelErrors = null)
5657
: base(isLoaded, hasErrors, loadedFromSource, language, CsModelType.EnumValue, sourceDocument, modelStore, modelErrors)
@@ -61,6 +62,7 @@ protected CsEnumValue(bool isLoaded, bool hasErrors, bool loadedFromSource, Sour
6162
_hasDocumentation = hasDocumentation;
6263
_documentation = documentation;
6364
_lookupPath = lookupPath;
65+
_modelSourceFile = modelSourceFile;
6466
_sourceFiles = sourceFiles ?? ImmutableList<string>.Empty;
6567
_name = name;
6668
_value = value;
@@ -217,5 +219,13 @@ protected CsEnumValue(bool isLoaded, bool hasErrors, bool loadedFromSource, Sour
217219
/// The value that has been assigned to the enumeration value.
218220
/// </summary>
219221
public string Value => _value;
222+
223+
/// <summary>
224+
/// Backing field for <see cref="ModelSourceFile"/>
225+
/// </summary>
226+
private readonly string _modelSourceFile;
227+
228+
/// <inheritdoc/>
229+
public string ModelSourceFile => _modelSourceFile;
220230
}
221231
}

src/CodeFactoryVisualStudio/CodeFactory.DotNet/CSharp/CsEvent.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public abstract class CsEvent:CsMember,ICsEvent
3838
/// <param name="modelStore">Optional the lookup storage for models created during the compile or lookup of the model.</param>
3939
/// <param name="modelErrors">Optional the error that occured while creating the model.</param>
4040
/// <param name="attributes">List of the attributes assigned to this model.</param>
41+
/// <param name="modelSourceFile">The source file the model was generated from.</param>
4142
/// <param name="sourceFiles">List of the fully qualified paths to the source code files this member is defined in.</param>
4243
/// <param name="hasDocumentation">Flag that determines if the model has XML documentation assigned to it.</param>
4344
/// <param name="documentation">The xml documentation assigned to the model.</param>
@@ -55,11 +56,11 @@ public abstract class CsEvent:CsMember,ICsEvent
5556
/// <param name="addMethod">Model for the add method for this event.</param>
5657
/// <param name="removeMethod">Model for the remove method for this event.</param>
5758
protected CsEvent(bool isLoaded, bool hasErrors, bool loadedFromSource, SourceCodeType language,
58-
IReadOnlyList<CsAttribute> attributes, IReadOnlyList<string> sourceFiles, bool hasDocumentation, string documentation,
59+
IReadOnlyList<CsAttribute> attributes, string modelSourceFile, IReadOnlyList<string> sourceFiles, bool hasDocumentation, string documentation,
5960
string lookupPath, string name, string parentPath, CsSecurity security, bool isAbstract, bool isVirtual, bool isOverride,
6061
bool isSealed, bool isStatic, CsDelegate eventHandlerDelegate, CsMethod raiseMethod, CsMethod addMethod, CsMethod removeMethod,
6162
CsType eventType, string sourceDocument = null, ModelStore<ICsModel> modelStore = null, IReadOnlyList<ModelLoadException> modelErrors = null): base(isLoaded, hasErrors, loadedFromSource,
62-
language, CsModelType.Event, attributes, sourceFiles, hasDocumentation, documentation,
63+
language, CsModelType.Event, attributes, modelSourceFile, sourceFiles, hasDocumentation, documentation,
6364
lookupPath, name, parentPath, security, CsMemberType.Event, sourceDocument, modelStore, modelErrors)
6465
{
6566
_isAbstract = isAbstract;

0 commit comments

Comments
 (0)