mirror of https://github.com/icsharpcode/ILSpy.git
Browse Source
Decompiler.Tests targeted net11.0-windows only because
Microsoft.DiaSymReader.Native is Win-only and Tester.cs hardcoded ilasm.exe
/ ildasm.exe filenames. Both are narrow problems: gate the Native package
to Windows, replace the ".exe" suffix with an OS-aware helper, and drop
the -windows TFM. The Microsoft.NETCore.IL{,D}Asm metapackages' RID graph
already ships ilasm/ildasm for linux + osx via per-RID runtime sub-packages
when RuntimeIdentifier resolves dynamically, so the tool just lands in the
test output dir with the right suffix on every host.
Windows-only test fixtures (RoundtripAssembly + the RunWithTestRunner,
SignAssembly, FindMSBuild call sites) gate via Assert.Ignore +
[Platform("Win")] so they skip on non-Windows instead of failing. CA1416
joins NoWarn -- the analyzer can't see the runtime guards, and the test
inputs (Console.CapsLock, Registry access) are decompilation targets, not
infrastructure.
BuildTools/pre-commit learns to find dotnet-format on non-Windows (XDG
basedir + no .exe suffix) so the hook can run wherever the build now does.
Assisted-by: Claude:claude-opus-4-7:Claude Code
pull/3755/head
7 changed files with 66 additions and 31 deletions
@ -1,26 +1,45 @@ |
|||||||
#!/bin/sh |
#!/bin/sh |
||||||
# |
# |
||||||
# To enable this hook, copy/symlink this file to ".git/hooks/pre-commit". |
# To enable this hook, copy/symlink this file to ".git/hooks/pre-commit". |
||||||
# mklink .git\hooks\pre-commit ..\..\BuildTools\pre-commit |
# Windows: mklink .git\hooks\pre-commit ..\..\BuildTools\pre-commit |
||||||
|
# Linux/Mac: ln -s ../../BuildTools/pre-commit .git/hooks/pre-commit |
||||||
|
|
||||||
set -eu |
set -eu |
||||||
|
|
||||||
DOTNET_FORMAT_VERSION=10.0.100-rtm.25531.102 |
DOTNET_FORMAT_VERSION=10.0.100-rtm.25531.102 |
||||||
DOTNET_FORMAT_SOURCE="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet10-transport/nuget/v3/index.json" |
DOTNET_FORMAT_SOURCE="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet10-transport/nuget/v3/index.json" |
||||||
DOTNET_PATH="$LOCALAPPDATA/ICSharpCode/ILSpy/dotnet-format-$DOTNET_FORMAT_VERSION" |
|
||||||
|
# Per-OS tool cache location + binary suffix. Windows uses %LOCALAPPDATA% and a .exe |
||||||
|
# suffix; Unix-likes follow the XDG basedir spec (falling back to ~/.local/share) and |
||||||
|
# drop the suffix. Keeping the tool installed under the same logical path on both |
||||||
|
# platforms means a single repo clone can host hook installs from either OS. |
||||||
|
case "$(uname -s 2>/dev/null)" in |
||||||
|
MINGW*|MSYS*|CYGWIN*|Windows*) |
||||||
|
DOTNET_CACHE_ROOT="$LOCALAPPDATA" |
||||||
|
EXE_SUFFIX=".exe" |
||||||
|
;; |
||||||
|
*) |
||||||
|
DOTNET_CACHE_ROOT="${XDG_DATA_HOME:-$HOME/.local/share}" |
||||||
|
EXE_SUFFIX="" |
||||||
|
;; |
||||||
|
esac |
||||||
|
|
||||||
|
DOTNET_PATH="$DOTNET_CACHE_ROOT/ICSharpCode/ILSpy/dotnet-format-$DOTNET_FORMAT_VERSION" |
||||||
if [ ! -d "$DOTNET_PATH" ]; then |
if [ ! -d "$DOTNET_PATH" ]; then |
||||||
echo "Downloading dotnet-format $DOTNET_FORMAT_VERSION..." |
echo "Downloading dotnet-format $DOTNET_FORMAT_VERSION..." |
||||||
dotnet tool install --tool-path "$DOTNET_PATH" dotnet-format --version "$DOTNET_FORMAT_VERSION" --add-source "$DOTNET_FORMAT_SOURCE" |
dotnet tool install --tool-path "$DOTNET_PATH" dotnet-format --version "$DOTNET_FORMAT_VERSION" --add-source "$DOTNET_FORMAT_SOURCE" |
||||||
fi |
fi |
||||||
|
|
||||||
"$DOTNET_PATH/dotnet-format.exe" --version |
DOTNET_FORMAT="$DOTNET_PATH/dotnet-format$EXE_SUFFIX" |
||||||
|
|
||||||
|
"$DOTNET_FORMAT" --version |
||||||
if [ "${1:-}" = "--format" ]; then |
if [ "${1:-}" = "--format" ]; then |
||||||
# called via format.bat |
# called via format.bat |
||||||
"$DOTNET_PATH/dotnet-format.exe" whitespace --no-restore --verbosity detailed ILSpy.sln |
"$DOTNET_FORMAT" whitespace --no-restore --verbosity detailed ILSpy.sln |
||||||
elif git diff --quiet --ignore-submodules; then |
elif git diff --quiet --ignore-submodules; then |
||||||
"$DOTNET_PATH/dotnet-format.exe" whitespace --no-restore --verbosity detailed ILSpy.sln |
"$DOTNET_FORMAT" whitespace --no-restore --verbosity detailed ILSpy.sln |
||||||
git add -u -- \*\*.cs |
git add -u -- \*\*.cs |
||||||
else |
else |
||||||
echo Partial commit: only verifying formatting |
echo Partial commit: only verifying formatting |
||||||
exec "$DOTNET_PATH/dotnet-format.exe" whitespace --verify-no-changes --no-restore --verbosity detailed ILSpy.sln |
exec "$DOTNET_FORMAT" whitespace --verify-no-changes --no-restore --verbosity detailed ILSpy.sln |
||||||
fi |
fi |
||||||
|
|||||||
Loading…
Reference in new issue