Skip to content

Commit 1d7e873

Browse files
authored
Merge pull request #23 from ful-stackz/task/update-packages
Update packages
2 parents 5828534 + 4cdd445 commit 1d7e873

12 files changed

Lines changed: 66 additions & 272 deletions

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1717
### Changed
1818

1919
- `Code.cs`, the entry point for creating a structure, has been modified to use the fluent APIs of each structure instead of using overridden constructors; this reduces duplicated validation code
20+
- The Roslyn packages were updated which results in a slightly different formatting in some places
21+
- `constructor() : base()` instead of `constructor(): base()`
22+
- `Property { get; set; }` and `Property { get => _value; set => _value = value; }` instead of the old multi-line version
2023

2124
### Fixed
2225

README.md

Lines changed: 7 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,9 @@ namespace Data
3232
{
3333
public class User
3434
{
35-
public int Id
36-
{
37-
get;
38-
set;
39-
}
35+
public int Id { get; set; }
4036

41-
public string Username
42-
{
43-
get;
44-
set;
45-
}
37+
public string Username { get; set; }
4638
}
4739
}
4840
```
@@ -98,15 +90,9 @@ namespace Data
9890
_username = username;
9991
}
10092

101-
public int Id
102-
{
103-
get => _id;
104-
}
93+
public int Id { get => _id; }
10594

106-
public string Username
107-
{
108-
get => _username;
109-
}
95+
public string Username { get => _username; }
11096
}
11197

11298
public class User
@@ -116,10 +102,7 @@ namespace Data
116102
Details = details;
117103
}
118104

119-
public UserDetails Details
120-
{
121-
get;
122-
}
105+
public UserDetails Details { get; }
123106
}
124107
}
125108
```
@@ -211,11 +194,7 @@ public class Data : DataBase, IHasData
211194
/// <summary>
212195
/// Docs!
213196
/// </summary>
214-
public int Count
215-
{
216-
get => _count;
217-
set => _count = value;
218-
}
197+
public int Count { get => _count; set => _count = value; }
219198

220199
// ✔ Define auto-implemented properties
221200
public string Name { get; set; }
@@ -256,11 +235,7 @@ public struct DataPoint : IHasData
256235
/// <summary>
257236
/// Docs!
258237
/// </summary>
259-
public int Count
260-
{
261-
get => _count;
262-
set => _count = value;
263-
}
238+
public int Count { get => _count; set => _count = value; }
264239
}
265240
```
266241
</details>

samples/JsonToNet/JsonToNet.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
</ItemGroup>
1313

1414
<ItemGroup>
15-
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
15+
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
1616
</ItemGroup>
1717

1818
<ItemGroup>

src/SharpCode.Test/ClassBuilderTests.cs

Lines changed: 11 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -90,17 +90,9 @@ public class Triangle
9090
private double _hypotenuse;
9191
private double _adjacent;
9292
private double _opposite;
93-
public double Hypotenuse
94-
{
95-
get => _hypotenuse;
96-
set => _hypotenuse = value;
97-
}
93+
public double Hypotenuse { get => _hypotenuse; set => _hypotenuse = value; }
9894
99-
public double Adjacent
100-
{
101-
get => _adjacent;
102-
set => _adjacent = value;
103-
}
95+
public double Adjacent { get => _adjacent; set => _adjacent = value; }
10496
10597
public double Opposite
10698
{
@@ -150,7 +142,7 @@ public void CreateClass_WithInheritance_AndBaseCall()
150142
var expectedCode = @"
151143
public class UserCredentials : Credentials, IAuthorizationDetails, IMadeThisUp
152144
{
153-
public UserCredentials(string username, string password): base(username, password, ""basic"")
145+
public UserCredentials(string username, string password) : base(username, password, ""basic"")
154146
{
155147
}
156148
}
@@ -176,15 +168,15 @@ public void CreateClass_WithInheritance_AndMultipleConstructors()
176168
var expectedCode = @"
177169
public class BasicCredentials : AuthorizationDetails
178170
{
179-
public BasicCredentials(): base(string.Empty, string.Empty, ""basic"")
171+
public BasicCredentials() : base(string.Empty, string.Empty, ""basic"")
180172
{
181173
}
182174
183-
public BasicCredentials(string username): base(username, string.Empty, ""basic"")
175+
public BasicCredentials(string username) : base(username, string.Empty, ""basic"")
184176
{
185177
}
186178
187-
public BasicCredentials(string username, string password): base(username, password, ""basic"")
179+
public BasicCredentials(string username, string password) : base(username, password, ""basic"")
188180
{
189181
}
190182
}
@@ -243,18 +235,8 @@ public void CreatingStaticClass_WithStaticProperties_Works()
243235
var expectedCode = @"
244236
public static class Config
245237
{
246-
public static string Name
247-
{
248-
get;
249-
}
250-
251-
= ""SharpCode"";
252-
public static System.Version Version
253-
{
254-
get;
255-
}
256-
257-
= new System.Version(0, 0, 1);
238+
public static string Name { get; } = ""SharpCode"";
239+
public static System.Version Version { get; } = new System.Version(0, 0, 1);
258240
}
259241
".Trim().WithUnixEOL();
260242

@@ -426,11 +408,7 @@ public void CreateClass_WithTypeParameters_WithProperty_Works()
426408
public class Dict<TKey, TValue>
427409
where TKey : IEquatable<TKey> where TValue : notnull
428410
{
429-
public Dictionary<TKey, TValue> Store
430-
{
431-
get;
432-
set;
433-
}
411+
public Dictionary<TKey, TValue> Store { get; set; }
434412
}
435413
".Trim().WithUnixEOL();
436414

@@ -455,11 +433,7 @@ public void CreateClass_WithTypeParameters_Params_WithProperty_Works()
455433
var expectedCode = @"
456434
public class Dict<K, V>
457435
{
458-
public Dictionary<K, V> Store
459-
{
460-
get;
461-
set;
462-
}
436+
public Dictionary<K, V> Store { get; set; }
463437
}
464438
".Trim().WithUnixEOL();
465439

@@ -486,11 +460,7 @@ public void CreateClass_WithTypeParameters_IEnumerable_WithProperty_Works()
486460
var expectedCode = @"
487461
public class Dict<K, V>
488462
{
489-
public Dictionary<K, V> Store
490-
{
491-
get;
492-
set;
493-
}
463+
public Dictionary<K, V> Store { get; set; }
494464
}
495465
".Trim().WithUnixEOL();
496466

src/SharpCode.Test/CodeTests.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -274,13 +274,7 @@ public void CreateField_WithInvalidType_Throws()
274274
[Test]
275275
public void CreateProperty_Works()
276276
{
277-
var expected = @"
278-
public Action DoWork
279-
{
280-
get;
281-
set;
282-
}
283-
".Trim().WithUnixEOL();
277+
var expected = "public Action DoWork { get; set; }";
284278

285279
// CreateProperty()
286280
Assert.AreEqual(

src/SharpCode.Test/InterfaceBuilderTests.cs

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -127,23 +127,11 @@ public void CreatingInterface_WithProperties_Works()
127127
var expectedCode = @"
128128
public interface ITest
129129
{
130-
int Number
131-
{
132-
get;
133-
set;
134-
}
130+
int Number { get; set; }
135131
136-
string Stringy
137-
{
138-
get;
139-
set;
140-
}
132+
string Stringy { get; set; }
141133
142-
bool Booly
143-
{
144-
get;
145-
set;
146-
}
134+
bool Booly { get; set; }
147135
}
148136
".Trim().WithUnixEOL();
149137

@@ -249,11 +237,7 @@ public void CreateInterface_WithTypeParameters_WithProperty_Works()
249237
public interface Dict<TKey, TValue>
250238
where TKey : IEquatable<TKey> where TValue : notnull
251239
{
252-
Dictionary<TKey, TValue> Store
253-
{
254-
get;
255-
set;
256-
}
240+
Dictionary<TKey, TValue> Store { get; set; }
257241
}
258242
".Trim().WithUnixEOL();
259243

@@ -278,11 +262,7 @@ public void CreateInterface_WithTypeParameters_Params_WithProperty_Works()
278262
var expectedCode = @"
279263
public interface Dict<K, V>
280264
{
281-
Dictionary<K, V> Store
282-
{
283-
get;
284-
set;
285-
}
265+
Dictionary<K, V> Store { get; set; }
286266
}
287267
".Trim().WithUnixEOL();
288268

@@ -309,11 +289,7 @@ public void CreateInterface_WithTypeParameters_IEnumerable_WithProperty_Works()
309289
var expectedCode = @"
310290
public interface Dict<K, V>
311291
{
312-
Dictionary<K, V> Store
313-
{
314-
get;
315-
set;
316-
}
292+
Dictionary<K, V> Store { get; set; }
317293
}
318294
".Trim().WithUnixEOL();
319295

src/SharpCode.Test/NamespaceBuilderTests.cs

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -95,29 +95,23 @@ public int Wheels
9595
public class Car : Vehicle
9696
{
9797
private readonly int _maxSpeed;
98-
public Car(int maxSpeed): base(4)
98+
public Car(int maxSpeed) : base(4)
9999
{
100100
_maxSpeed = maxSpeed;
101101
}
102102
103-
public int MaxSpeed
104-
{
105-
get => _maxSpeed;
106-
}
103+
public int MaxSpeed { get => _maxSpeed; }
107104
}
108105
109106
public class Motorbike : Vehicle
110107
{
111108
private readonly int _maxSpeed;
112-
public Motorbike(int maxSpeed): base(2)
109+
public Motorbike(int maxSpeed) : base(2)
113110
{
114111
_maxSpeed = maxSpeed;
115112
}
116113
117-
public int MaxSpeed
118-
{
119-
get => _maxSpeed;
120-
}
114+
public int MaxSpeed { get => _maxSpeed; }
121115
}
122116
}
123117
".Trim().WithUnixEOL();
@@ -353,20 +347,12 @@ namespace GeneratedGoodies
353347
{
354348
public interface IHaveGoodies
355349
{
356-
int Count
357-
{
358-
get;
359-
set;
360-
}
350+
int Count { get; set; }
361351
}
362352
363353
internal interface IHaveHiddenGoodies : IHaveGoodies
364354
{
365-
int HiddenCount
366-
{
367-
get;
368-
set;
369-
}
355+
int HiddenCount { get; set; }
370356
}
371357
}
372358
".Trim().WithUnixEOL();
@@ -398,11 +384,7 @@ public struct Cube
398384
/// <summary>
399385
/// Gets or sets the length of the cube side.
400386
/// </summary>
401-
public int Side
402-
{
403-
get;
404-
set;
405-
}
387+
public int Side { get; set; }
406388
}
407389
}
408390
".Trim().WithUnixEOL();

0 commit comments

Comments
 (0)