Skip to content

Commit f163457

Browse files
Upgrades Dev Proxy to .NET 10. Closes #1445
1 parent e8cc938 commit f163457

Some content is hidden

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

43 files changed

+406
-556
lines changed

.editorconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,8 @@ dotnet_diagnostic.CA1303.severity = none
236236
dotnet_diagnostic.CA1308.severity = none
237237
# Avoid uninstantiated internal classes
238238
dotnet_diagnostic.CA1812.severity = none
239+
# Avoid potentially expensive logging
240+
dotnet_diagnostic.CA1873.severity = none
239241
# Use the LoggerMessage delegates
240242
dotnet_diagnostic.CA1848.severity = none
241243
# Possible multiple enumerations of IEnumerable collection

.github/workflows/create-release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ jobs:
5959
if: matrix.architecture == 'win-x64'
6060
run: dotnet build ./DevProxy.Abstractions/DevProxy.Abstractions.csproj -p:InformationalVersion=$("${{ github.ref_name }}".Substring(1)) -c Release --no-self-contained
6161
- name: Add plugins to output
62-
run: cp ./DevProxy/bin/Release/net9.0/${{ matrix.architecture }}/plugins ./${{ env.release }} -r
62+
run: cp ./DevProxy/bin/Release/net10.0/${{ matrix.architecture }}/plugins ./${{ env.release }} -r
6363
- name: Remove unnecessary files
6464
run: |
6565
pushd
@@ -112,7 +112,7 @@ jobs:
112112
shell: pwsh
113113
run: >
114114
./sign code azure-key-vault
115-
./DevProxy.Abstractions/bin/Release/net9.0/DevProxy.Abstractions.dll
115+
./DevProxy.Abstractions/bin/Release/net10.0/DevProxy.Abstractions.dll
116116
--publisher-name "${{ env.APP_PUBLISHER }}"
117117
--description "${{ env.APP_DESCRIPTION }}"
118118
--description-url "${{ env.APP_DESCRIPTION_URL }}"
@@ -127,7 +127,7 @@ jobs:
127127
uses: thedoctor0/zip-release@b57d897cb5d60cb78b51a507f63fa184cfe35554 # master
128128
with:
129129
filename: '../../../../DevProxy.Abstractions-${{ github.ref_name }}.zip'
130-
directory: './DevProxy.Abstractions/bin/Release/net9.0'
130+
directory: './DevProxy.Abstractions/bin/Release/net10.0'
131131
exclusions: '*.json'
132132
- name: Upload abstractions
133133
if: matrix.architecture == 'win-x64'

.vscode/launch.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
"request": "launch",
1111
"preLaunchTask": "build",
1212
// If you have changed target frameworks, make sure to update the program path.
13-
"program": "${workspaceFolder}/DevProxy/bin/Debug/net9.0/devproxy.dll",
13+
"program": "${workspaceFolder}/DevProxy/bin/Debug/net10.0/devproxy.dll",
1414
"args": [],
15-
"cwd": "${workspaceFolder}/DevProxy/bin/Debug/net9.0",
15+
"cwd": "${workspaceFolder}/DevProxy/bin/Debug/net10.0",
1616
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
1717
"console": "integratedTerminal",
1818
"stopAtEntry": false,

DevProxy.Abstractions/DevProxy.Abstractions.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net9.0</TargetFramework>
4+
<TargetFramework>net10.0</TargetFramework>
55
<RootNamespace>DevProxy.Abstractions</RootNamespace>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<Nullable>enable</Nullable>

DevProxy.Abstractions/LanguageModel/OllamaLanguageModelClient.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ public sealed class OllamaLanguageModelClient(
5454

5555
if (Configuration.CacheResponses && _cacheChatCompletion.TryGetCacheValue(messages, out var cachedResponse))
5656
{
57-
Logger.LogDebug("Returning cached response for message: {LastMessage}", messages.Last().Content);
57+
if (Logger.IsEnabled(LogLevel.Debug))
58+
{
59+
Logger.LogDebug("Returning cached response for message: {LastMessage}", messages.Last().Content);
60+
}
5861
return cachedResponse;
5962
}
6063

@@ -181,7 +184,10 @@ protected override async Task<bool> IsEnabledCoreAsync(CancellationToken cancell
181184
try
182185
{
183186
var url = $"{Configuration.Url?.TrimEnd('/')}/api/chat";
184-
Logger.LogDebug("Requesting chat completion. Message: {LastMessage}", messages.Last().Content);
187+
if (Logger.IsEnabled(LogLevel.Debug))
188+
{
189+
Logger.LogDebug("Requesting chat completion. Message: {LastMessage}", messages.Last().Content);
190+
}
185191

186192
var response = await _httpClient.PostAsJsonAsync(url,
187193
new

DevProxy.Abstractions/LanguageModel/OpenAILanguageModelClient.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ public sealed class OpenAILanguageModelClient(
6262

6363
if (Configuration.CacheResponses && _cacheChatCompletion.TryGetCacheValue(messages, out var cachedResponse))
6464
{
65-
_logger.LogDebug("Returning cached response for message: {LastMessage}", messages.Last().Content);
65+
if (_logger.IsEnabled(LogLevel.Debug))
66+
{
67+
_logger.LogDebug("Returning cached response for message: {LastMessage}", messages.Last().Content);
68+
}
6669
return cachedResponse;
6770
}
6871

@@ -148,7 +151,10 @@ protected override async Task<bool> IsEnabledCoreAsync(CancellationToken cancell
148151
try
149152
{
150153
var url = $"{Configuration.Url?.TrimEnd('/')}/chat/completions";
151-
_logger.LogDebug("Requesting chat completion. Message: {LastMessage}", messages.Last().Content);
154+
if (_logger.IsEnabled(LogLevel.Debug))
155+
{
156+
_logger.LogDebug("Requesting chat completion. Message: {LastMessage}", messages.Last().Content);
157+
}
152158

153159
var payload = new OpenAIChatCompletionRequest
154160
{

DevProxy.Abstractions/Models/MockResponse.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ public object Clone()
2121

2222
public static MockResponse FromHttpResponse(string httpResponse, ILogger logger)
2323
{
24+
ArgumentNullException.ThrowIfNull(logger);
25+
2426
logger.LogTrace("{Method} called", nameof(FromHttpResponse));
2527

2628
if (string.IsNullOrWhiteSpace(httpResponse))
@@ -40,7 +42,10 @@ public static MockResponse FromHttpResponse(string httpResponse, ILogger logger)
4042
for (var i = 0; i < lines.Length; i++)
4143
{
4244
var line = lines[i];
43-
logger.LogTrace("Processing line {LineNumber}: {LineContent}", i + 1, line);
45+
if (logger.IsEnabled(LogLevel.Trace))
46+
{
47+
logger.LogTrace("Processing line {LineNumber}: {LineContent}", i + 1, line);
48+
}
4449

4550
if (i == 0)
4651
{

DevProxy.Abstractions/Plugins/BaseLoader.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,10 @@ private async Task<bool> ValidateFileContentsAsync(string fileContents, Cancella
9191

9292
if (!IsValid)
9393
{
94-
Logger.LogError("Schema validation failed for {File} with the following errors: {Errors}", FilePath, string.Join(", ", ValidationErrors));
94+
if (Logger.IsEnabled(LogLevel.Error))
95+
{
96+
Logger.LogError("Schema validation failed for {File} with the following errors: {Errors}", FilePath, string.Join(", ", ValidationErrors));
97+
}
9598
}
9699

97100
return IsValid;

DevProxy.Abstractions/Plugins/BasePlugin.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,10 @@ public override async Task InitializeAsync(InitArgs e, CancellationToken cancell
110110
var (IsValid, ValidationErrors) = await ValidatePluginConfigAsync(cancellationToken);
111111
if (!IsValid)
112112
{
113-
Logger.LogError("Plugin configuration validation failed with the following errors: {Errors}", string.Join(", ", ValidationErrors));
113+
if (Logger.IsEnabled(LogLevel.Error))
114+
{
115+
Logger.LogError("Plugin configuration validation failed with the following errors: {Errors}", string.Join(", ", ValidationErrors));
116+
}
114117
}
115118
}
116119

DevProxy.Abstractions/packages.lock.json

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"version": 1,
33
"dependencies": {
4-
"net9.0": {
4+
"net10.0": {
55
"Markdig": {
66
"type": "Direct",
77
"requested": "[0.41.3, )",
@@ -20,8 +20,7 @@
2020
"Microsoft.Extensions.DependencyModel": "9.0.4",
2121
"Microsoft.Extensions.Logging": "9.0.4",
2222
"SQLitePCLRaw.bundle_e_sqlite3": "2.1.10",
23-
"SQLitePCLRaw.core": "2.1.10",
24-
"System.Text.Json": "9.0.4"
23+
"SQLitePCLRaw.core": "2.1.10"
2524
}
2625
},
2726
"Microsoft.Extensions.Configuration": {
@@ -102,8 +101,7 @@
102101
"contentHash": "HiICGm0e44+i4aVHpLn+aphmSC2eQnDvlTttw1rE0hntOZKoLGRy37sydqqbRP1ZokMf3Mt0GEgSWxDwnucKGg==",
103102
"dependencies": {
104103
"BouncyCastle.Cryptography": "2.4.0",
105-
"Microsoft.Extensions.Logging.Abstractions": "8.0.1",
106-
"System.Runtime.CompilerServices.Unsafe": "6.0.0"
104+
"Microsoft.Extensions.Logging.Abstractions": "8.0.1"
107105
}
108106
},
109107
"YamlDotNet": {
@@ -168,8 +166,7 @@
168166
"Microsoft.Extensions.Configuration.Abstractions": "9.0.4",
169167
"Microsoft.Extensions.DependencyModel": "9.0.4",
170168
"Microsoft.Extensions.Logging": "9.0.4",
171-
"SQLitePCLRaw.core": "2.1.10",
172-
"System.Text.Json": "9.0.4"
169+
"SQLitePCLRaw.core": "2.1.10"
173170
}
174171
},
175172
"Microsoft.Extensions.Caching.Abstractions": {
@@ -304,10 +301,7 @@
304301
"SQLitePCLRaw.core": {
305302
"type": "Transitive",
306303
"resolved": "2.1.10",
307-
"contentHash": "Ii8JCbC7oiVclaE/mbDEK000EFIJ+ShRPwAvvV89GOZhQ+ZLtlnSWl6ksCNMKu/VGXA4Nfi2B7LhN/QFN9oBcw==",
308-
"dependencies": {
309-
"System.Memory": "4.5.3"
310-
}
304+
"contentHash": "Ii8JCbC7oiVclaE/mbDEK000EFIJ+ShRPwAvvV89GOZhQ+ZLtlnSWl6ksCNMKu/VGXA4Nfi2B7LhN/QFN9oBcw=="
311305
},
312306
"SQLitePCLRaw.lib.e_sqlite3": {
313307
"type": "Transitive",
@@ -321,21 +315,6 @@
321315
"dependencies": {
322316
"SQLitePCLRaw.core": "2.1.10"
323317
}
324-
},
325-
"System.Memory": {
326-
"type": "Transitive",
327-
"resolved": "4.5.3",
328-
"contentHash": "3oDzvc/zzetpTKWMShs1AADwZjQ/36HnsufHRPcOjyRAAMLDlu2iD33MBI2opxnezcVUtXyqDXXjoFMOU9c7SA=="
329-
},
330-
"System.Runtime.CompilerServices.Unsafe": {
331-
"type": "Transitive",
332-
"resolved": "6.0.0",
333-
"contentHash": "/iUeP3tq1S0XdNNoMz5C9twLSrM/TH+qElHkXWaPvuNOt+99G75NrV0OS2EqHx5wMN7popYjpc8oTjC1y16DLg=="
334-
},
335-
"System.Text.Json": {
336-
"type": "Transitive",
337-
"resolved": "9.0.4",
338-
"contentHash": "pYtmpcO6R3Ef1XilZEHgXP2xBPVORbYEzRP7dl0IAAbN8Dm+kfwio8aCKle97rAWXOExr292MuxWYurIuwN62g=="
339318
}
340319
}
341320
}

0 commit comments

Comments
 (0)