Skip to content

Commit ed0b417

Browse files
committed
Release 1.23050.0.2
1 parent b5f5d2b commit ed0b417

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+887
-188
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace CodeFactory.DotNet.CSharp
1313
/// <summary>
1414
/// Data model that represents a class implementation.
1515
/// </summary>
16-
public abstract class CsClass:CsContainer,ICsClass
16+
public abstract class CsClass:CsContainerWithNestedContainers,ICsClass
1717
{
1818
#region Property backing fields
1919
private readonly bool _isStatic;

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

Lines changed: 3 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace CodeFactory.DotNet.CSharp
1616
/// <summary>
1717
/// Data model that implements the base implement for all models that support members.
1818
/// </summary>
19-
public abstract class CsContainer:CsModel,ICsContainer,ICsNestedModel
19+
public abstract class CsContainer:CsModel,ICsContainer
2020
{
2121
#region Property backing fields
2222
private readonly IReadOnlyList<CsAttribute> _attributes;
@@ -35,9 +35,6 @@ public abstract class CsContainer:CsModel,ICsContainer,ICsNestedModel
3535
private readonly CsSecurity _security;
3636
private readonly IReadOnlyList<CsInterface> _inheritedInterfaces;
3737
private readonly IReadOnlyList<CsMember> _members;
38-
private readonly bool _isNested;
39-
private readonly CsNestedType _nestedType;
40-
private readonly IReadOnlyList<ICsNestedModel> _nestedModels;
4138

4239
#endregion
4340

@@ -50,9 +47,6 @@ public abstract class CsContainer:CsModel,ICsContainer,ICsNestedModel
5047
/// <param name="language">The target language the model was generated from.</param>
5148
/// <param name="modelType">The type of code model created.</param>
5249
/// <param name="members">The members assigned to this container.</param>
53-
/// <param name="isNested">Flag that determines if the container type is nested in another type definition.</param>
54-
/// <param name="nestedType">Enumeration of the type of nesting the container is.</param>
55-
/// <param name="nestedModels">List of nested models assigned to this container. This is an optional parameter and can be null</param>
5650
/// <param name="sourceDocument">The source document that was used to build this model. This is optional parameter and can be null.</param>
5751
/// <param name="modelStore">Optional the lookup storage for models created during the compile or lookup of the model.</param>
5852
/// <param name="modelErrors">Optional the error that occurred while creating the model.</param>
@@ -77,9 +71,8 @@ protected CsContainer(bool isLoaded, bool hasErrors, bool loadedFromSource, Sour
7771
IReadOnlyList<CsGenericParameter> genericParameters, IReadOnlyList<CsType> genericTypes, string modelSourceFile,
7872
IReadOnlyList<string> sourceFiles, bool hasDocumentation, string documentation, string lookupPath,
7973
string name, string ns, string parentPath, CsContainerType containerType, CsSecurity security,
80-
IReadOnlyList<CsInterface> inheritedInterfaces, IReadOnlyList<CsMember> members, bool isNested, CsNestedType nestedType, IReadOnlyList<ICsNestedModel> nestedModels = null,
81-
82-
string sourceDocument = null, ModelStore<ICsModel> modelStore = null, IReadOnlyList<ModelLoadException> modelErrors = null)
74+
IReadOnlyList<CsInterface> inheritedInterfaces, IReadOnlyList<CsMember> members,
75+
string sourceDocument = null, ModelStore<ICsModel> modelStore = null, IReadOnlyList<ModelLoadException> modelErrors = null)
8376
: base(isLoaded, hasErrors, loadedFromSource, language, modelType, sourceDocument, modelStore, modelErrors)
8477
{
8578
_attributes = attributes ?? ImmutableList<CsAttribute>.Empty;
@@ -99,9 +92,6 @@ protected CsContainer(bool isLoaded, bool hasErrors, bool loadedFromSource, Sour
9992
_security = security;
10093
_inheritedInterfaces = inheritedInterfaces ?? ImmutableList<CsInterface>.Empty;
10194
_members = members ?? ImmutableList<CsMember>.Empty;
102-
_isNested = isNested;
103-
_nestedType = nestedType;
104-
_nestedModels = nestedModels ?? ImmutableList<ICsNestedModel>.Empty;
10595
}
10696

10797
/// <summary>
@@ -241,60 +231,6 @@ protected CsContainer(bool isLoaded, bool hasErrors, bool loadedFromSource, Sour
241231
public IReadOnlyList<CsEvent> Events => _members.Where(m => m.MemberType == CsMemberType.Event).Cast<CsEvent>()
242232
.ToImmutableList() ?? ImmutableList<CsEvent>.Empty;
243233

244-
/// <summary>
245-
/// Models that are nested in the implementation of this container.
246-
/// </summary>
247-
public IReadOnlyList<ICsNestedModel> NestedModels => _nestedModels;
248-
249-
/// <summary>
250-
/// Classes that are nested in this container.
251-
/// </summary>
252-
public IReadOnlyList<CsClass> NestedClasses =>
253-
_nestedModels.Where(n => n.NestedType == CsNestedType.Class).Cast<CsClass>().ToImmutableList();
254-
255-
/// <summary>
256-
/// Interfaces that are nested in this container.
257-
/// </summary>
258-
public IReadOnlyList<CsInterface> NestedInterfaces =>
259-
_nestedModels.Where(n => n.NestedType == CsNestedType.Interface).Cast<CsInterface>().ToImmutableList();
260-
261-
/// <summary>
262-
/// Structures that are nested in this container.
263-
/// </summary>
264-
public IReadOnlyList<CsStructure> NestedStructures =>
265-
_nestedModels.Where(n => n.NestedType == CsNestedType.Structure).Cast<CsStructure>().ToImmutableList();
266-
267-
/// <summary>
268-
/// Enums that are nested in this container.
269-
/// </summary>
270-
public IReadOnlyList<CsEnum> NestedEnums =>
271-
_nestedModels.Where(n => n.NestedType == CsNestedType.Enum).Cast<CsEnum>().ToImmutableList();
272-
273-
/// <summary>
274-
/// Models that are nested in the implementation of this container.
275-
/// </summary>
276-
IReadOnlyList<IDotNetNestedModel> IDotNetContainer.NestedModels => NestedModels;
277-
278-
/// <summary>
279-
/// Classes that are nested in this container.
280-
/// </summary>
281-
IReadOnlyList<IDotNetClass> IDotNetContainer.NestedClasses => NestedClasses;
282-
283-
/// <summary>
284-
/// Interfaces that are nested in this container.
285-
/// </summary>
286-
IReadOnlyList<IDotNetInterface> IDotNetContainer.NestedInterfaces => NestedInterfaces;
287-
288-
/// <summary>
289-
/// Structures that are nested in this container.
290-
/// </summary>
291-
IReadOnlyList<IDotNetStructure> IDotNetContainer.NestedStructures => NestedStructures;
292-
293-
/// <summary>
294-
/// Enums that are nested in this container.
295-
/// </summary>
296-
IReadOnlyList<IDotNetEnum> IDotNetContainer.NestedEnums => NestedEnums;
297-
298234
/// <summary>
299235
/// The source code syntax that is stored in the body of the container model. This will be null if the container was not loaded from source code.
300236
/// </summary>
@@ -496,19 +432,5 @@ protected CsContainer(bool isLoaded, bool hasErrors, bool loadedFromSource, Sour
496432
/// <inheritdoc/>
497433
public string ModelSourceFile => _modelSourceFile;
498434

499-
/// <summary>
500-
/// Identifies the type of model that has been nested.
501-
/// </summary>
502-
DotNetNestedType IDotNetNestedModel.NestedType => (DotNetNestedType) _nestedType ;
503-
504-
/// <summary>
505-
/// Identifies the type of model that has been nested.
506-
/// </summary>
507-
public CsNestedType NestedType => _nestedType;
508-
509-
/// <summary>
510-
/// Flag that determines if this model is nested in a parent model.
511-
/// </summary>
512-
public bool IsNested => _isNested;
513435
}
514436
}

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//*****************************************************************************
22
//* Code Factory SDK
3-
//* Copyright (c) 2020 CodeFactory, LLC
3+
//* Copyright (c) 2020-2023 CodeFactory, LLC
44
//*****************************************************************************
55

66
namespace CodeFactory.DotNet.CSharp
@@ -25,6 +25,16 @@ public enum CsContainerType
2525
/// </summary>
2626
Structure = DotNetContainerType.Structure,
2727

28+
/// <summary>
29+
/// The container implements a record model.
30+
/// </summary>
31+
Record = DotNetContainerType.Record,
32+
33+
/// <summary>
34+
/// The container implements a record structure model.
35+
/// </summary>
36+
RecordStructure = DotNetContainerType.RecordStructure,
37+
2838
/// <summary>
2939
/// The container is of an unknown type.
3040
/// </summary>
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
//*****************************************************************************
2+
//* Code Factory SDK
3+
//* Copyright (c) 2023 CodeFactory, LLC
4+
//*****************************************************************************
5+
6+
using System.Collections.Generic;
7+
using System.Collections.Immutable;
8+
using System.Linq;
9+
using CodeFactory.SourceCode;
10+
11+
namespace CodeFactory.DotNet.CSharp
12+
{
13+
/// <summary>
14+
/// Data model that implements the base implement for all models that support members.
15+
/// </summary>
16+
public abstract class CsContainerWithNestedContainers:CsContainer,ICsNestedContainers,ICsNestedModel
17+
{
18+
#region Property backing fields
19+
private readonly bool _isNested;
20+
private readonly CsNestedType _nestedType;
21+
private readonly IReadOnlyList<ICsNestedModel> _nestedModels;
22+
23+
#endregion
24+
25+
/// <summary>
26+
/// Constructor for the <see cref="CsContainerWithNestedContainers"/>
27+
/// </summary>
28+
/// <param name="isLoaded">Flag that determines if the model was loaded.</param>
29+
/// <param name="hasErrors">Flag that determine if errors were found creating the model.</param>
30+
/// <param name="loadedFromSource">Flag that determines if the model was loaded from source code or from an existing library.</param>
31+
/// <param name="language">The target language the model was generated from.</param>
32+
/// <param name="modelType">The type of code model created.</param>
33+
/// <param name="members">The members assigned to this container.</param>
34+
/// <param name="isNested">Flag that determines if the container type is nested in another type definition.</param>
35+
/// <param name="nestedType">Enumeration of the type of nesting the container is.</param>
36+
/// <param name="nestedModels">List of nested models assigned to this container. This is an optional parameter and can be null</param>
37+
/// <param name="sourceDocument">The source document that was used to build this model. This is optional parameter and can be null.</param>
38+
/// <param name="modelStore">Optional the lookup storage for models created during the compile or lookup of the model.</param>
39+
/// <param name="modelErrors">Optional the error that occurred while creating the model.</param>
40+
/// <param name="attributes">List of the attributes assigned to this model.</param>
41+
/// <param name="isGeneric">Flag that determines if the container is a generic definition.</param>
42+
/// <param name="hasStrongTypesInGenerics">Flag that determines if the generics use strong type definitions.</param>
43+
/// <param name="genericParameters">Generic parameters assigned to the container.</param>
44+
/// <param name="genericTypes">Target types for the generic parameters assigned to the container.</param>
45+
/// <param name="modelSourceFile">The source file the model was loaded from.</param>
46+
/// <param name="sourceFiles">List of the fully qualified paths to the source code files this model is defined in.</param>
47+
/// <param name="hasDocumentation">Flag that determines if the model has XML documentation assigned to it.</param>
48+
/// <param name="documentation">The xml documentation assigned to the model.</param>
49+
/// <param name="lookupPath">The fully qualified model lookup path for this model.</param>
50+
/// <param name="name">The name of the model.</param>
51+
/// <param name="ns">The namespace the container belongs to.</param>
52+
/// <param name="parentPath">The fully qualified lookup path for the parent model to this one.</param>
53+
/// <param name="containerType">The type of container this model represents.</param>
54+
/// <param name="security">The security scope assigned to this model.</param>
55+
/// <param name="inheritedInterfaces">The interfaces that are inherited by this container.</param>
56+
protected CsContainerWithNestedContainers(bool isLoaded, bool hasErrors, bool loadedFromSource, SourceCodeType language, CsModelType modelType,
57+
IReadOnlyList<CsAttribute> attributes, bool isGeneric, bool hasStrongTypesInGenerics,
58+
IReadOnlyList<CsGenericParameter> genericParameters, IReadOnlyList<CsType> genericTypes, string modelSourceFile,
59+
IReadOnlyList<string> sourceFiles, bool hasDocumentation, string documentation, string lookupPath,
60+
string name, string ns, string parentPath, CsContainerType containerType, CsSecurity security,
61+
IReadOnlyList<CsInterface> inheritedInterfaces, IReadOnlyList<CsMember> members, bool isNested, CsNestedType nestedType, IReadOnlyList<ICsNestedModel> nestedModels = null,
62+
string sourceDocument = null, ModelStore<ICsModel> modelStore = null, IReadOnlyList<ModelLoadException> modelErrors = null)
63+
:base(isLoaded, hasErrors, loadedFromSource, language, modelType, attributes, isGeneric, hasStrongTypesInGenerics, genericParameters,
64+
genericTypes, modelSourceFile, sourceFiles, hasDocumentation, documentation, lookupPath, name, ns, parentPath, containerType, security,
65+
inheritedInterfaces, members, sourceDocument, modelStore, modelErrors)
66+
{
67+
_isNested = isNested;
68+
_nestedType = nestedType;
69+
_nestedModels = nestedModels ?? ImmutableList<ICsNestedModel>.Empty;
70+
}
71+
72+
/// <summary>
73+
/// Models that are nested in the implementation of this container.
74+
/// </summary>
75+
public IReadOnlyList<ICsNestedModel> NestedModels => _nestedModels;
76+
77+
/// <summary>
78+
/// Classes that are nested in this container.
79+
/// </summary>
80+
public IReadOnlyList<CsClass> NestedClasses =>
81+
_nestedModels.Where(n => n.NestedType == CsNestedType.Class).Cast<CsClass>().ToImmutableList();
82+
83+
/// <summary>
84+
/// Interfaces that are nested in this container.
85+
/// </summary>
86+
public IReadOnlyList<CsInterface> NestedInterfaces =>
87+
_nestedModels.Where(n => n.NestedType == CsNestedType.Interface).Cast<CsInterface>().ToImmutableList();
88+
89+
/// <summary>
90+
/// Structures that are nested in this container.
91+
/// </summary>
92+
public IReadOnlyList<CsStructure> NestedStructures =>
93+
_nestedModels.Where(n => n.NestedType == CsNestedType.Structure).Cast<CsStructure>().ToImmutableList();
94+
95+
/// <summary>
96+
/// Enums that are nested in this container.
97+
/// </summary>
98+
public IReadOnlyList<CsEnum> NestedEnums =>
99+
_nestedModels.Where(n => n.NestedType == CsNestedType.Enum).Cast<CsEnum>().ToImmutableList();
100+
101+
/// <summary>
102+
/// Models that are nested in the implementation of this container.
103+
/// </summary>
104+
IReadOnlyList<IDotNetNestedModel> IDotNetNestedContainers.NestedModels => NestedModels;
105+
106+
/// <summary>
107+
/// Classes that are nested in this container.
108+
/// </summary>
109+
IReadOnlyList<IDotNetClass> IDotNetNestedContainers.NestedClasses => NestedClasses;
110+
111+
/// <summary>
112+
/// Interfaces that are nested in this container.
113+
/// </summary>
114+
IReadOnlyList<IDotNetInterface> IDotNetNestedContainers.NestedInterfaces => NestedInterfaces;
115+
116+
/// <summary>
117+
/// Structures that are nested in this container.
118+
/// </summary>
119+
IReadOnlyList<IDotNetStructure> IDotNetNestedContainers.NestedStructures => NestedStructures;
120+
121+
/// <summary>
122+
/// Enums that are nested in this container.
123+
/// </summary>
124+
IReadOnlyList<IDotNetEnum> IDotNetNestedContainers.NestedEnums => NestedEnums;
125+
126+
/// <summary>
127+
/// Identifies the type of model that has been nested.
128+
/// </summary>
129+
DotNetNestedType IDotNetNestedModel.NestedType => (DotNetNestedType)_nestedType;
130+
131+
/// <summary>
132+
/// Identifies the type of model that has been nested.
133+
/// </summary>
134+
public CsNestedType NestedType => _nestedType;
135+
136+
/// <summary>
137+
/// Flag that determines if this model is nested in a parent model.
138+
/// </summary>
139+
public bool IsNested => _isNested;
140+
141+
}
142+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace CodeFactory.DotNet.CSharp
1111
/// <summary>
1212
/// Data model that represents in definition of an interface.
1313
/// </summary>
14-
public abstract class CsInterface:CsContainer,ICsInterface
14+
public abstract class CsInterface:CsContainerWithNestedContainers,ICsInterface
1515
{
1616
/// <summary>
1717
/// Constructor for the <see cref="CsInterface"/>

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,22 @@ protected CsMember(bool isLoaded, bool hasErrors, bool loadedFromSource, SourceC
252252
/// <exception cref="DocumentException">Error is raised when errors occur updating the source document.</exception>
253253
public abstract Task<CsSource> ReplaceAsync(string sourceCode);
254254

255+
/// <summary>
256+
/// Comments out the member hosting syntax.
257+
/// </summary>
258+
/// <param name="commentSyntax">Optional parameter that sets the syntax used to comment out the member defaults to '//'</param>
259+
/// <returns>A newly loaded copy of the <see cref="CsSource"/> model after the member has been commented out.
260+
/// This will return the current instance if the model was not loaded from source.</returns>
261+
/// <exception cref="DocumentException">Error is raised when errors occur updating the source document.</exception>
262+
public abstract Task<CsSource> CommentOutSyntaxAsync(string commentSyntax = "//");
263+
264+
/// <summary>
265+
/// Gets the syntax that defined the member model.
266+
/// </summary>
267+
/// <returns>The syntax that makes up the member or null if the syntax cannot be loaded. This will be null if the model was not loaded from source code.</returns>
268+
public abstract Task<string> GetMemberSyntaxAsync();
269+
255270

256-
257271
/// <summary>
258272
/// The security scope that has been assigned to the member.
259273
/// </summary>

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//*****************************************************************************
22
//* Code Factory SDK
3-
//* Copyright (c) 2020 CodeFactory, LLC
3+
//* Copyright (c) 2023 CodeFactory, LLC
44
//*****************************************************************************
55

66
namespace CodeFactory.DotNet.CSharp
@@ -70,6 +70,11 @@ public enum CsMethodType
7070
/// </summary>
7171
PartialImplementation = DotNetMethodType.PartialImplementation,
7272

73+
/// <summary>
74+
/// The method supports the init functionality from a property or an indexer.
75+
/// </summary>
76+
Init = DotNetMethodType.Init,
77+
7378
/// <summary>
7479
/// The type of method is unknown
7580
/// </summary>

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//*****************************************************************************
22
//* Code Factory SDK
3-
//* Copyright (c) 2020 CodeFactory, LLC
3+
//* Copyright (c) 2020-2023 CodeFactory, LLC
44
//*****************************************************************************
55

66
namespace CodeFactory.DotNet.CSharp
@@ -125,6 +125,16 @@ public enum CsModelType
125125
/// </summary>
126126
TupleTypeParameter = DotNetModelType.TupleTypeParameter,
127127

128+
/// <summary>
129+
/// Model stores a record implementation.
130+
/// </summary>
131+
Record = DotNetModelType.Record,
132+
133+
/// <summary>
134+
/// Model stores a record structure implementation.
135+
/// </summary>
136+
RecordStructure = DotNetModelType.RecordStructure,
137+
128138
/// <summary>
129139
/// The model is currently not know by the C# source type.
130140
/// </summary>

0 commit comments

Comments
 (0)