Skip to content

Commit 336440b

Browse files
Upgrades Dev Proxy to .NET 10. Closes #1445 (#1449)
* Upgrades Dev Proxy to .NET 10. Closes #1445 * Updates workflows to .NET 10
1 parent 36d4d90 commit 336440b

Some content is hidden

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

45 files changed

+409
-559
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/codeql-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
- name: Setup .NET
5050
uses: actions/setup-dotnet@2016bd2012dba4e32de620c46fe006a3ac9f0602 # v5.0.1
5151
with:
52-
dotnet-version: 9.0.x
52+
dotnet-version: 10.0.x
5353

5454
# Initializes the CodeQL tools for scanning.
5555
- name: Initialize CodeQL

.github/workflows/create-release.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
- name: Setup .NET
3535
uses: actions/setup-dotnet@2016bd2012dba4e32de620c46fe006a3ac9f0602 # v5.0.1
3636
with:
37-
dotnet-version: 9.0.x
37+
dotnet-version: 10.0.x
3838
- name: Rename executable for beta
3939
if: contains(github.ref_name, '-beta')
4040
run: |
@@ -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'

.github/workflows/dotnet.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- name: Setup .NET
2323
uses: actions/setup-dotnet@2016bd2012dba4e32de620c46fe006a3ac9f0602 # v5.0.1
2424
with:
25-
dotnet-version: 9.0.x
25+
dotnet-version: 10.0.x
2626
- name: Restore workloads
2727
run: dotnet workload restore
2828
- name: Restore dependencies

.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;

0 commit comments

Comments
 (0)