Skip to content

Commit 4ff6cd2

Browse files
authored
Merge pull request #171 from stefanedwards/fix-github-warnings
fix: Misc. .NET/github action warnings
2 parents d79faae + c1f8ac5 commit 4ff6cd2

File tree

7 files changed

+21
-14
lines changed

7 files changed

+21
-14
lines changed

.github/workflows/validate.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- name: Build project
1818
run: dotnet build
1919
- name: Run unit tests
20-
run: dotnet test --logger "console;verbosity=detailed"
20+
run: dotnet test --logger "console;verbosity=detailed" -graphBuild:True
2121
- name: Code Coverage Report
2222
uses: irongut/CodeCoverageSummary@v1.3.0
2323
with:

Core/Cosmos.DataTransfer.Core.UnitTests/SettingsCommandTests.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ namespace Cosmos.DataTransfer.Core.UnitTests
1717
[TestClass]
1818
public class SettingsCommandTests
1919
{
20+
// TODO: What is the purpose of this test?
21+
// It seems to be a very elaborate method to assert parsing null.
2022
[TestMethod]
2123
public void Invoke_ForTestExtension_ProducesValidSettingsJson()
2224
{
@@ -65,8 +67,10 @@ public void Invoke_ForTestExtension_ProducesValidSettingsJson()
6567
WriteIndented = true
6668
};
6769
var fullJson = stringBuilder.ToString().Trim();
70+
Assert.AreEqual("null", fullJson);
6871
var parsed = JsonSerializer.Deserialize<List<ExtensionSettingProperty>>(fullJson, options);
69-
var parsedJson = JsonSerializer.Serialize<List<ExtensionSettingProperty>>(parsed, options);
72+
Assert.IsNull(parsed);
73+
var parsedJson = JsonSerializer.Serialize<List<ExtensionSettingProperty>>(parsed!, options);
7074

7175
Assert.AreEqual(fullJson, parsedJson);
7276
}

Extensions/PostgreSQL/PostgreDataCol.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,11 @@ public PostgreDataCol(string colname, string postgredatatye)
3535
ColumnType = Convert(PostgreType);
3636
}
3737

38-
public PostgreDataCol()
38+
public PostgreDataCol(string colname, Type coltype, NpgsqlTypes.NpgsqlDbType postgredatatye)
3939
{
40+
ColumnName = colname;
41+
PostgreType = postgredatatye;
42+
ColumnType = coltype;
4043
}
4144

4245
public Dictionary<long, object> SparseColumnData { get; } = new Dictionary<long, object>();

Extensions/PostgreSQL/PostgresqlDataSinkExtension.cs

+3-8
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ private async Task<List<PostgreDataCol>> FindPostgreDataTypes(IAsyncEnumerable<I
8686
{
8787
if (current.PostgreType == NpgsqlTypes.NpgsqlDbType.Unknown && coltype?.Name != "Missing")
8888
{
89-
var newcol = new PostgreDataCol(col, coltype);
89+
var newcol = new PostgreDataCol(col, coltype!);
9090
postgreDataCols[row] = newcol;
9191
}
9292
}
@@ -106,12 +106,7 @@ private List<PostgreDataCol> MapDataTypes(List<PostgreDataCol> dest, List<Postgr
106106
{
107107
if (item.ColumnName.ToLower() == col.ColumnName.ToLower())
108108
{
109-
temp.Add(new PostgreDataCol()
110-
{
111-
ColumnName = col.ColumnName,
112-
ColumnType = item.ColumnType,
113-
PostgreType = item.PostgreType
114-
});
109+
temp.Add(new PostgreDataCol(col.ColumnName, item.ColumnType, item.PostgreType));
115110
found = true;
116111
break;
117112
}
@@ -169,7 +164,7 @@ private static List<PostgreDataCol> LoadTableSchema(NpgsqlConnection con, string
169164
{
170165
if (row != null)
171166
{
172-
var newcol = new PostgreDataCol(row["column_name"]?.ToString(), row["udt_name"]?.ToString());
167+
var newcol = new PostgreDataCol(row["column_name"]?.ToString()!, row["udt_name"]?.ToString()!);
173168
temp.Add(newcol);
174169
}
175170
}

Extensions/PostgreSQL/Settings/PostgreSinkSettings.cs

+2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ namespace Cosmos.DataTransfer.PostgresqlExtension.Settings
66
public class PostgreSinkSettings : PostgreBaseSettings
77
{
88
[Required]
9+
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring as nullable.
910
public string TableName { get; set; }
11+
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring as nullable.
1012
public bool? AppendDataToTable { get; set; }
1113
public bool? DropAndCreateTable { get; set; }
1214

Extensions/PostgreSQL/Settings/PostgreSourceSettings.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public class PostgreSourceSettings:PostgreBaseSettings
77
{
88
[Required]
99
[SensitiveValue]
10-
public string? ConnectionString { get; set; }
10+
public new string? ConnectionString { get; set; }
1111

1212
[Required]
1313
public string? QueryText { get; set; }

Interfaces/Cosmos.DataTransfer.Interfaces/ValidationExtensions.cs

+5-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ namespace Cosmos.DataTransfer.Interfaces;
44

55
public static class ValidationExtensions
66
{
7-
public static IEnumerable<string?> GetValidationErrors<T>(this T? settings)
7+
public static IEnumerable<string> GetValidationErrors<T>(this T? settings)
88
where T : class, IDataExtensionSettings, new()
99
{
1010
if (settings == null)
@@ -18,7 +18,10 @@ public static class ValidationExtensions
1818
Validator.TryValidateObject(settings, context, results, true);
1919
foreach (var validationResult in results)
2020
{
21-
yield return validationResult.ErrorMessage;
21+
if (validationResult.ErrorMessage is not null)
22+
{
23+
yield return validationResult.ErrorMessage;
24+
}
2225
}
2326
}
2427

0 commit comments

Comments
 (0)