Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/client-smoke-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6.1.0
with:
dotnet-version: 10.0.x
dotnet-version: 11.0.x
- name: Setup Node.js
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
Expand All @@ -42,5 +42,5 @@ jobs:
dotnet build DevProxy.Plugins/DevProxy.Plugins.csproj -c Release --no-restore
- name: Run client smoke tests
env:
DEVPROXY: ${{ github.workspace }}/DevProxy/bin/Release/net10.0/devproxy
DEVPROXY: ${{ github.workspace }}/DevProxy/bin/Release/net11.0/devproxy
run: tests/clients/run.sh
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6.1.0
with:
dotnet-version: 10.0.x
dotnet-version: 11.0.x

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
Expand Down
26 changes: 18 additions & 8 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6.1.0
with:
dotnet-version: 10.0.x
dotnet-version: 11.0.x
- name: Rename executable for prerelease
if: contains(github.ref_name, '-beta') || contains(github.ref_name, '-alpha')
run: |
Expand All @@ -60,7 +60,7 @@ jobs:
if: matrix.architecture == 'win-x64'
run: dotnet build ./DevProxy.Abstractions/DevProxy.Abstractions.csproj -p:InformationalVersion=$("${{ github.ref_name }}".Substring(1)) -c Release --no-self-contained
- name: Add plugins to output
run: cp ./DevProxy/bin/Release/net10.0/${{ matrix.architecture }}/plugins ./${{ env.release }} -r
run: cp ./DevProxy/bin/Release/net11.0/${{ matrix.architecture }}/plugins ./${{ env.release }} -r
- name: Remove unnecessary files
run: |
pushd
Expand Down Expand Up @@ -110,10 +110,11 @@ jobs:
path: ./${{ env.release }}.zip
- name: Sign abstractions
if: matrix.architecture == 'win-x64'
working-directory: ./DevProxy.Abstractions/bin/Release
shell: pwsh
run: >
./sign code azure-key-vault
./DevProxy.Abstractions/bin/Release/net10.0/DevProxy.Abstractions.dll
../../../sign code azure-key-vault
**/DevProxy.Abstractions.dll
--publisher-name "${{ env.APP_PUBLISHER }}"
--description "${{ env.APP_DESCRIPTION }}"
--description-url "${{ env.APP_DESCRIPTION_URL }}"
Expand All @@ -123,19 +124,28 @@ jobs:
--azure-key-vault-url "${{ secrets.DOTNET_VAULT_URL }}"
--timestamp-url http://timestamp.digicert.com
--verbosity Debug
- name: Archive abstractions
- name: Archive abstractions (net10.0)
if: matrix.architecture == 'win-x64'
uses: thedoctor0/zip-release@b57d897cb5d60cb78b51a507f63fa184cfe35554 # master
with:
filename: '../../../../DevProxy.Abstractions-${{ github.ref_name }}.zip'
filename: '../../../../DevProxy.Abstractions-${{ github.ref_name }}-net10.0.zip'
directory: './DevProxy.Abstractions/bin/Release/net10.0'
exclusions: '*.json'
- name: Archive abstractions (net11.0)
if: matrix.architecture == 'win-x64'
uses: thedoctor0/zip-release@b57d897cb5d60cb78b51a507f63fa184cfe35554 # master
with:
filename: '../../../../DevProxy.Abstractions-${{ github.ref_name }}-net11.0.zip'
directory: './DevProxy.Abstractions/bin/Release/net11.0'
exclusions: '*.json'
- name: Upload abstractions
if: matrix.architecture == 'win-x64'
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: binaries-dev-proxy-abstractions-${{ github.ref_name }}
path: ./DevProxy.Abstractions-${{ github.ref_name }}.zip
path: |
./DevProxy.Abstractions-${{ github.ref_name }}-net10.0.zip
./DevProxy.Abstractions-${{ github.ref_name }}-net11.0.zip
- name: Add installer icon
if: contains(matrix.architecture, 'win-')
run: |
Expand Down Expand Up @@ -208,7 +218,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6.1.0
with:
dotnet-version: 10.0.x
dotnet-version: 11.0.x
- name: Get version from tag
id: get_version
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6.1.0
with:
dotnet-version: 10.0.x
dotnet-version: 11.0.x
- name: Cache NuGet packages
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
Expand Down Expand Up @@ -77,7 +77,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6.1.0
with:
dotnet-version: 10.0.x
dotnet-version: 11.0.x
- name: Cache NuGet packages
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
Expand Down
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/DevProxy/bin/Debug/net10.0/devproxy.dll",
"program": "${workspaceFolder}/DevProxy/bin/Debug/net11.0/devproxy.dll",
"args": [],
"cwd": "${workspaceFolder}/DevProxy/bin/Debug/net10.0",
"cwd": "${workspaceFolder}/DevProxy/bin/Debug/net11.0",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"console": "integratedTerminal",
"stopAtEntry": false,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<TargetFramework>net11.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
Expand Down
27 changes: 20 additions & 7 deletions DevProxy.Abstractions/DevProxy.Abstractions.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<!-- Keep net10.0 so existing plugin projects that target it can still reference this package -->
<TargetFrameworks>net10.0;net11.0</TargetFrameworks>
<RootNamespace>DevProxy.Abstractions</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
Expand Down Expand Up @@ -38,12 +39,6 @@

<ItemGroup>
<PackageReference Include="Markdig" Version="1.6.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="10.0.15" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="11.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="11.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="11.0.0" />
<PackageReference Include="Microsoft.Extensions.FileSystemGlobbing" Version="11.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="11.0.0" />
<PackageReference Include="Microsoft.OpenApi" Version="3.11.1" />
<PackageReference Include="Microsoft.OpenApi.YamlReader" Version="3.11.1" />
<PackageReference Include="Newtonsoft.Json.Schema" Version="4.0.2" />
Expand All @@ -52,4 +47,22 @@
<PackageReference Include="YamlDotNet" Version="18.1.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net10.0'">
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="10.0.15" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="10.0.15" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="10.0.15" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="10.0.15" />
<PackageReference Include="Microsoft.Extensions.FileSystemGlobbing" Version="10.0.15" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.15" />
</ItemGroup>

<!-- Microsoft.Extensions.Logging.Abstractions comes in transitively on net11.0; referencing it raises NU1510 -->
<ItemGroup Condition="'$(TargetFramework)' == 'net11.0'">
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="11.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="11.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="11.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="11.0.0" />
<PackageReference Include="Microsoft.Extensions.FileSystemGlobbing" Version="11.0.0" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions DevProxy.Abstractions/Proxy/WatchedHostExtractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public static bool IsHostWide(Regex urlRegex)
return true;
}

var pathStart = pattern.IndexOf('/', scheme + 3);
return pathStart < 0 || pattern[pathStart..] is "/" or "/*";
var pathOffset = pattern.AsSpan(scheme + 3).IndexOf('/');
return pathOffset < 0 || pattern[(scheme + 3 + pathOffset)..] is "/" or "/*";
}
}
21 changes: 21 additions & 0 deletions DevProxy.Abstractions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,25 @@ public class MyPlugin(
}
```

## Target framework

This package targets `net10.0` and `net11.0`. Target the same .NET version as the Dev Proxy release that runs your plugin, or an earlier one. Dev Proxy can load a plugin built for an earlier .NET version, but not for a later one.

## Don't ship shared assemblies with your plugin

Dev Proxy already loads `DevProxy.Abstractions` and the `Microsoft.Extensions.*` packages that it depends on. If your plugin ships its own copy of these assemblies, Dev Proxy loads a second copy, and your plugin's types won't match Dev Proxy's types. To avoid this, reference `DevProxy.Abstractions` and the shared packages with `Private=false` and `ExcludeAssets=runtime`:

```xml
<ItemGroup>
<PackageReference Include="DevProxy.Abstractions" Version="x.y.z">
<Private>false</Private>
<ExcludeAssets>runtime</ExcludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="x.y.z">
<Private>false</Private>
<ExcludeAssets>runtime</ExcludeAssets>
</PackageReference>
</ItemGroup>
```

For more information, see the [Dev Proxy documentation](https://aka.ms/devproxy/docs).
6 changes: 3 additions & 3 deletions DevProxy.Abstractions/Utils/ProxyUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ public static IEnumerable<string> GetWildcardPatterns(ReadOnlyCollection<string>
// For single URLs, use the URL up to the last segment
var uri = new Uri(url);
var path = uri.AbsolutePath;
var lastSlashIndex = path.LastIndexOf('/');
var lastSlashIndex = path.AsSpan().LastIndexOf('/');
return $"{group.Key}{path[..lastSlashIndex]}/*";
}

Expand Down Expand Up @@ -899,7 +899,7 @@ private static List<string> SplitOutsideQuotes(string value, char separator)

private static bool IsPlaceHolderSegment(string segment)
{
return segment.StartsWith('{') && segment.EndsWith('}');
return segment is ['{', .., '}'];
}

private static ParsedSample ParseSampleUrl(string url, string? version = null)
Expand Down Expand Up @@ -993,7 +993,7 @@ private static string GetCommonPrefix(List<string> paths)

// Find the last complete path segment
var prefix = firstPath[..commonPrefixLength];
var lastSlashIndex = prefix.LastIndexOf('/');
var lastSlashIndex = prefix.AsSpan().LastIndexOf('/');
return lastSlashIndex >= 0 ? prefix[..(lastSlashIndex + 1)] : prefix;
}
}
Loading
Loading