Skip to content

Commit e148c40

Browse files
committed
Updates to the SDK to support property access to get and set. Updated support for enum and fixed missing functionality in enumvalue.
1 parent 848ea0d commit e148c40

File tree

18 files changed

+1108
-13
lines changed

18 files changed

+1108
-13
lines changed

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,27 @@ protected CsEnum(bool isLoaded, bool hasErrors, bool loadedFromSource, SourceCod
248248
/// <exception cref="DocumentException">Error is raised when errors occur updating the source document.</exception>
249249
public abstract Task<CsSource> ReplaceAsync(string sourceCode);
250250

251+
/// <summary>
252+
/// Gets the starting and ending locations of the body located in the enum.
253+
/// </summary>
254+
/// <returns>The source location in the enum.</returns>
255+
/// <exception cref="DocumentException">Raised when an error occurs getting the location from the document.</exception>
256+
public abstract Task<ISourceLocation> GetBodySourceLocationAsync();
257+
258+
/// <summary>
259+
/// Adds the source code inside of the enumeration at the beginning of where members are defined in the enumeration.
260+
/// </summary>
261+
/// <param name="sourceCode">The source code that is to be added to the document.</param>
262+
/// <returns>A newly loaded copy of the <see cref="ICsSource"/> model after the changes have been applied.</returns>
263+
public abstract Task<CsSource> AddToBeginningAsync(string sourceCode);
264+
265+
/// <summary>
266+
/// Adds the source code inside of the enumeration at the end of where members are defined in the enumeration.
267+
/// </summary>
268+
/// <param name="sourceCode">The source code that is to be added to the document.</param>
269+
/// <returns>A newly loaded copy of the <see cref="ICsSource"/> model after the changes have been applied.</returns>
270+
public abstract Task<CsSource> AddToEndAsync(string sourceCode);
271+
251272
/// <inheritdoc/>
252273
public abstract Task<CsSource> AddBeforeAsync(string sourceCode, bool ignoreLeadingModelsAndDocs);
253274

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,15 @@ protected CsEnumValue(bool isLoaded, bool hasErrors, bool loadedFromSource, Sour
169169
/// <exception cref="DocumentException">Error is raised when errors occur updating the source document.</exception>
170170
public abstract Task<CsSource> AddBeforeAsync(string sourceCode);
171171

172+
/// <summary>
173+
/// Adds the source code directly before the definition of the <see cref="ICsEnumValue"/>in the target document.
174+
/// </summary>
175+
/// <param name="sourceCode">The source code that is to be added to the document.</param>
176+
/// <param name="ignoreLeadingModelsAndDocs">Changes the before entry point to the start of the member definition not before the documentation or attributes that are assigned to the member.</param>
177+
/// <returns>A newly loaded copy of the <see cref="ICsSource"/> model after the changes have been applied.</returns>
178+
/// <exception cref="DocumentException">Error is raised when errors occur updating the source document.</exception>
179+
public abstract Task<CsSource> AddBeforeAsync(string sourceCode, bool ignoreLeadingModelsAndDocs);
180+
172181
/// <summary>
173182
/// Adds the source code directly after the definition of the <see cref="ICsEnumValue"/>in the target document.
174183
/// </summary>

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

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
//* Copyright (c) 2020 CodeFactory, LLC
44
//*****************************************************************************
55

6+
using System;
67
using System.Collections.Generic;
78
using System.Threading.Tasks;
89
using CodeFactory.SourceCode;
@@ -25,6 +26,8 @@ public abstract class CsProperty:CsMember,ICsProperty
2526
private readonly CsType _propertyType;
2627
private readonly CsSecurity _getSecurity;
2728
private readonly CsSecurity _setSecurity;
29+
private readonly CsMethod _getMethod;
30+
private readonly CsMethod _setMethod;
2831
#endregion
2932

3033
/// <summary>
@@ -48,7 +51,9 @@ public abstract class CsProperty:CsMember,ICsProperty
4851
/// <param name="parentPath">THe fully qualified lookup path for the parent model to this one.</param>
4952
/// <param name="security">The security scope assigned to this model.</param>
5053
/// <param name="hasGet">Flag that determines if the property implements a getter.</param>
54+
/// <param name="getMethod">The get accessor method assigned to the property</param>
5155
/// <param name="hasSet">Flag that determines if the property implements a setter.</param>
56+
/// <param name="setMethod">The set accessor method assigned to the property.</param>
5257
/// <param name="isAbstract">Flag that determines if the model is abstract.</param>
5358
/// <param name="isVirtual">Flag that determines if the model is virtual.</param>
5459
/// <param name="isSealed">Flag that determines if the model is sealed.</param>
@@ -59,7 +64,7 @@ public abstract class CsProperty:CsMember,ICsProperty
5964
protected CsProperty(bool isLoaded, bool hasErrors, bool loadedFromSource, SourceCodeType language,
6065
IReadOnlyList<CsAttribute> attributes, string modelSourceFile, IReadOnlyList<string> sourceFiles, bool hasDocumentation, string documentation,
6166
string lookupPath, string name, string parentPath, CsSecurity security,
62-
bool hasGet, bool hasSet, bool isAbstract, bool isVirtual, bool isSealed, bool isOverride, bool isStatic,
67+
bool hasGet, CsMethod getMethod, bool hasSet, CsMethod setMethod, bool isAbstract, bool isVirtual, bool isSealed, bool isOverride, bool isStatic,
6368
CsType propertyType, CsSecurity getSecurity, CsSecurity setSecurity,
6469
string sourceDocument = null, ModelStore<ICsModel> modelStore = null, IReadOnlyList<ModelLoadException> modelErrors = null)
6570
: base(isLoaded, hasErrors, loadedFromSource, language, CsModelType.Property,attributes, modelSourceFile, sourceFiles,
@@ -74,7 +79,9 @@ protected CsProperty(bool isLoaded, bool hasErrors, bool loadedFromSource, Sourc
7479
_isStatic = isStatic;
7580
_propertyType = propertyType;
7681
_getSecurity = getSecurity;
82+
_getMethod = getMethod;
7783
_setSecurity = setSecurity;
84+
_setMethod = setMethod;
7885
}
7986

8087
/// <summary>
@@ -142,14 +149,36 @@ protected CsProperty(bool isLoaded, bool hasErrors, bool loadedFromSource, Sourc
142149
/// </summary>
143150
public bool IsStatic => _isStatic;
144151

152+
/// <summary>
153+
/// Provides access to the get method statement in the property. This will be null the property does not have a get statement.
154+
/// </summary>
155+
public CsMethod GetMethod => _getMethod;
156+
157+
/// <summary>
158+
/// Provides access to the set method statement in the property. This will be null the property does not have a set statement.
159+
/// </summary>
160+
public CsMethod SetMethod => _setMethod;
161+
162+
/// <summary>
163+
/// Provides access to the get method statement in the property. This will be null the property does not have a get statement.
164+
/// </summary>
165+
IDotNetMethod IDotNetProperty.GetMethod => _getMethod;
166+
167+
/// <summary>
168+
/// Provides access to the set method statement in the property. This will be null the property does not have a set statement.
169+
/// </summary>
170+
IDotNetMethod IDotNetProperty.SetMethod => _setMethod;
171+
145172
/// <summary>
146173
/// The source code syntax that is stored in the body of the property get. This will be null if was not loaded from source code.
147174
/// </summary>
175+
[Obsolete("This will be removed in later editions of the SDK. Use the GetMethod property to access the get method details.",false)]
148176
public abstract Task<string> LoadGetBodySyntaxAsync();
149177

150178
/// <summary>
151179
/// The source code syntax that is stored in the body of the property get. This will be null if was not loaded from source code.
152180
/// </summary>
181+
[Obsolete("This will be removed in later editions of the SDK. Use the SetMethod property to access the set method details.",false)]
153182
public abstract Task<string> LoadSetBodySyntaxAsync();
154183
}
155184
}

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,5 +120,26 @@ public interface ICsEnum : ICsModel, ICsAttributes,IParent, IDotNetEnum
120120
/// <exception cref="DocumentException">Error is raised when errors occur updating the source document.</exception>
121121
Task<CsSource> ReplaceAsync(string sourceCode);
122122

123+
/// <summary>
124+
/// Gets the starting and ending locations of the body located in the enum.
125+
/// </summary>
126+
/// <returns>The source location in the enum.</returns>
127+
/// <exception cref="DocumentException">Raised when an error occurs getting the location from the document.</exception>
128+
Task<ISourceLocation> GetBodySourceLocationAsync();
129+
130+
/// <summary>
131+
/// Adds the source code inside of the enumeration at the beginning of where members are defined in the enumeration.
132+
/// </summary>
133+
/// <param name="sourceCode">The source code that is to be added to the document.</param>
134+
/// <returns>A newly loaded copy of the <see cref="ICsSource"/> model after the changes have been applied.</returns>
135+
Task<CsSource> AddToBeginningAsync(string sourceCode);
136+
137+
/// <summary>
138+
/// Adds the source code inside of the enumeration at the end of where members are defined in the enumeration.
139+
/// </summary>
140+
/// <param name="sourceCode">The source code that is to be added to the document.</param>
141+
/// <returns>A newly loaded copy of the <see cref="ICsSource"/> model after the changes have been applied.</returns>
142+
Task<CsSource> AddToEndAsync(string sourceCode);
143+
123144
}
124145
}

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,15 @@ public interface ICsEnumValue : ICsModel, ICsAttributes, IParent, IDotNetEnumVal
3838
/// <exception cref="DocumentException">Error is raised when errors occur updating the source document.</exception>
3939
Task<CsSource> AddBeforeAsync(string sourceCode);
4040

41+
/// <summary>
42+
/// Adds the source code directly before the definition of the <see cref="ICsEnumValue"/>in the target document.
43+
/// </summary>
44+
/// <param name="sourceCode">The source code that is to be added to the document.</param>
45+
/// <param name="ignoreLeadingModelsAndDocs">Changes the before entry point to the start of the member definition not before the documentation or attributes that are assigned to the member.</param>
46+
/// <returns>A newly loaded copy of the <see cref="ICsSource"/> model after the changes have been applied.</returns>
47+
/// <exception cref="DocumentException">Error is raised when errors occur updating the source document.</exception>
48+
Task<CsSource> AddBeforeAsync(string sourceCode,bool ignoreLeadingModelsAndDocs);
49+
4150
/// <summary>
4251
/// Adds the source code directly after the definition of the <see cref="ICsEnumValue"/>in the target document.
4352
/// </summary>

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
//* Copyright (c) 2020 CodeFactory, LLC
44
//*****************************************************************************
55

6+
using System;
7+
68
namespace CodeFactory.DotNet.CSharp
79
{
810
/// <summary>
@@ -18,11 +20,13 @@ public interface ICsProperty:ICsMember,IDotNetProperty
1820
/// <summary>
1921
/// The security scope that is assigned to the get accessor. Make sure you check the HasGet to determine if the property supports get operations.
2022
/// </summary>
23+
[Obsolete("This will be removed in later editions of the SDK. Use the GetMethod property to access the get method details.",false)]
2124
new CsSecurity GetSecurity { get; }
2225

2326
/// <summary>
2427
/// The security scope that is assigned to the set accessor. Make sure you check the HasSet to determine if the property supports set operations.
2528
/// </summary>
29+
[Obsolete("This will be removed in later editions of the SDK. Use the SetMethod property to access the set method details.",false)]
2630
new CsSecurity SetSecurity { get; }
2731
}
2832
}

src/CodeFactoryVisualStudio/CodeFactory.DotNet/IDotNetProperty.cs

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

6+
using System;
67
using System.Threading.Tasks;
78

89
namespace CodeFactory.DotNet
@@ -62,14 +63,26 @@ public interface IDotNetProperty:IDotNetMember
6263
/// </summary>
6364
bool IsStatic { get; }
6465

66+
/// <summary>
67+
/// Provides access to the get method statement in the property. This will be null the property does not have a get statement.
68+
/// </summary>
69+
IDotNetMethod GetMethod { get; }
70+
71+
/// <summary>
72+
/// Provides access to the set method statement in the property. This will be null the property does not have a set statement.
73+
/// </summary>
74+
IDotNetMethod SetMethod { get; }
75+
6576
/// <summary>
6677
/// The source code syntax that is stored in the body of the property get. This will be null if was not loaded from source code.
6778
/// </summary>
79+
[Obsolete("This will be removed in later editions of the SDK. Use the GetMethod property to access the get method details.",false)]
6880
Task<string> LoadGetBodySyntaxAsync();
6981

7082
/// <summary>
7183
/// The source code syntax that is stored in the body of the property get. This will be null if was not loaded from source code.
7284
/// </summary>
85+
[Obsolete("This will be removed in later editions of the SDK. Use the SetMethod property to access the set method details.",false)]
7386
Task<string> LoadSetBodySyntaxAsync();
7487
}
7588
}

src/CodeFactoryVisualStudio/CodeFactory.DotNet/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
3535
[assembly: AssemblyVersion("1.0.0.0")]
36-
[assembly: AssemblyFileVersion("1.22301.01")]
36+
[assembly: AssemblyFileVersion("1.22303.01")]

src/CodeFactoryVisualStudio/CodeFactory.Formatting.CSharp/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
3535
[assembly: AssemblyVersion("1.0.0.0")]
36-
[assembly: AssemblyFileVersion("1.22301.01")]
36+
[assembly: AssemblyFileVersion("1.22303.01")]

src/CodeFactoryVisualStudio/CodeFactory.Logging/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
3535
[assembly: AssemblyVersion("1.0.0.0")]
36-
[assembly: AssemblyFileVersion("1.22301.01")]
36+
[assembly: AssemblyFileVersion("1.22303.01")]

0 commit comments

Comments
 (0)