Skip to content

Commit d37b992

Browse files
authored
Merge pull request #1204 from progressonderwijs/robin/optional-instead-of-throw
Fix crash when disposing SqlConnectionContext (calling SiteBase.Name for logging/diagnostic purposes)
2 parents 3923583 + 4036191 commit d37b992

File tree

3 files changed

+6
-16
lines changed

3 files changed

+6
-16
lines changed

src/ProgressOnderwijsUtils/Data/SiteBase.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,5 @@ public virtual IContainer? Container
1616
public virtual bool DesignMode
1717
=> throw new NotSupportedException();
1818

19-
public virtual string? Name
20-
{
21-
get => throw new NotSupportedException();
22-
set => throw new NotSupportedException();
23-
}
19+
public string? Name { get; set; }
2420
}

src/ProgressOnderwijsUtils/Data/SqlCommandCreationContext.cs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,8 @@ public interface IHasDefaultCommandTimeout
1010
CommandTimeoutDefaults TimeoutDefaults { get; }
1111
}
1212

13-
public sealed class SqlConnectionContext : SiteBase, IAttachedToTracer, IHasDefaultCommandTimeout
13+
public sealed class SqlConnectionContext(ISqlCommandTracer tracer, CommandTimeoutDefaults timeoutDefaults) : SiteBase, IAttachedToTracer, IHasDefaultCommandTimeout
1414
{
15-
public SqlConnectionContext(ISqlCommandTracer tracer, CommandTimeoutDefaults timeoutDefaults)
16-
{
17-
Tracer = tracer;
18-
TimeoutDefaults = timeoutDefaults;
19-
}
20-
21-
public ISqlCommandTracer Tracer { get; }
22-
public CommandTimeoutDefaults TimeoutDefaults { get; set; }
15+
public ISqlCommandTracer Tracer { get; } = tracer;
16+
public CommandTimeoutDefaults TimeoutDefaults { get; set; } = timeoutDefaults;
2317
}

src/ProgressOnderwijsUtils/ProgressOnderwijsUtils.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<Import Project="..\NugetPackagesCommon.props" />
33
<PropertyGroup Label="Configuration">
4-
<Version>110.2.0</Version>
5-
<PackageReleaseNotes>Give the possibility to serialize rowversion columns to number properties in the JSON reader.</PackageReleaseNotes>
4+
<Version>110.3.0</Version>
5+
<PackageReleaseNotes>Do not throw on accessing the Name of SqlConnectionContext to prevent errors on disposing.</PackageReleaseNotes>
66
<Title>ProgressOnderwijsUtils</Title>
77
<Description>Collection of utilities developed by ProgressOnderwijs</Description>
88
<PackageTags>ProgressOnderwijs</PackageTags>

0 commit comments

Comments
 (0)