From fbd197398368bf9f226d55bd4dfe82da8131bba1 Mon Sep 17 00:00:00 2001 From: bernd Date: Thu, 8 Jan 2026 23:36:46 +0100 Subject: [PATCH 1/4] add netstandard2.0 support --- XmlResolver/ResourceAccess.cs | 17 ++++++-- XmlResolver/Utils/NetStandardExtensions.cs | 48 ++++++++++++++++++++++ XmlResolver/Utils/UriUtils.cs | 1 - XmlResolver/XmlResolver.csproj | 20 +++++++-- XmlResolver/XmlResolverConfiguration.cs | 4 +- 5 files changed, 80 insertions(+), 10 deletions(-) create mode 100644 XmlResolver/Utils/NetStandardExtensions.cs diff --git a/XmlResolver/ResourceAccess.cs b/XmlResolver/ResourceAccess.cs index 2b1fb8d..25e6a2b 100644 --- a/XmlResolver/ResourceAccess.cs +++ b/XmlResolver/ResourceAccess.cs @@ -191,7 +191,7 @@ private static (Uri resolvedUri, HttpResponseMessage resp) _getHttpResponse(Uri status = resp.StatusCode; if (seen.Contains(resolvedUri)) { - throw new HttpRequestException("Redirect loop", null, status); + throw CreateHttpRequestException("Redirect loop", status); } seen.Add(resolvedUri); @@ -204,7 +204,7 @@ private static (Uri resolvedUri, HttpResponseMessage resp) _getHttpResponse(Uri if (resp.StatusCode == HttpStatusCode.Moved || resp.StatusCode == HttpStatusCode.Redirect) { resolvedUri = resp.Content.Headers.ContentLocation - ?? throw new HttpRequestException("Redirect without location", null, status); + ?? throw CreateHttpRequestException("Redirect without location", status); } else { @@ -214,10 +214,19 @@ private static (Uri resolvedUri, HttpResponseMessage resp) _getHttpResponse(Uri if (count <= 0) { - throw new HttpRequestException("Too many redirects", null, status); + throw CreateHttpRequestException("Too many redirects", status); } - throw new HttpRequestException("Failed to read resource", null, status); + throw CreateHttpRequestException("Failed to read resource", status); + + HttpRequestException CreateHttpRequestException(string text, HttpStatusCode statusCode) + { +#if NETSTANDARD2_0 + return new HttpRequestException($"{text} ({statusCode})"); +#else + return new HttpRequestException(text, null, statusCode); +#endif + } } private static IResourceResponse _getFileResource(IResourceRequest request, Uri uri) diff --git a/XmlResolver/Utils/NetStandardExtensions.cs b/XmlResolver/Utils/NetStandardExtensions.cs new file mode 100644 index 0000000..590bb8d --- /dev/null +++ b/XmlResolver/Utils/NetStandardExtensions.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Net.Http; +using System.Text; +using System.Threading.Tasks; + +#if NETSTANDARD2_0 +namespace XmlResolver.Utils +{ + internal static class NetStandardExtensions + { + public static int IndexOf(this string s, char value, StringComparison comparisonType) + { + return s.IndexOf($"{value}", comparisonType); + } + + public static Span Split(this string s, string sep, StringSplitOptions stringSplitOptions = StringSplitOptions.None) + { + char[] sepChars = [.. s]; + return s.Split(sepChars, stringSplitOptions); + } + + public static bool StartsWith(this string s, char c) + { + if (s.Length > 0) + { + if (s[0] == c) + { + return true; + } + } + return false; + } + + public static HttpResponseMessage Send(this HttpClient client, HttpRequestMessage message) + { + return client.SendAsync(message).Result; + } + + public static Stream ReadAsStream(this HttpContent content) + { + return content.ReadAsStreamAsync().Result; + } + } +} +#endif \ No newline at end of file diff --git a/XmlResolver/Utils/UriUtils.cs b/XmlResolver/Utils/UriUtils.cs index d6017d2..9f4ace7 100644 --- a/XmlResolver/Utils/UriUtils.cs +++ b/XmlResolver/Utils/UriUtils.cs @@ -1,7 +1,6 @@ using System; using System.Buffers; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Globalization; using System.IO; using System.IO.Compression; diff --git a/XmlResolver/XmlResolver.csproj b/XmlResolver/XmlResolver.csproj index 22ef11b..012db2e 100644 --- a/XmlResolver/XmlResolver.csproj +++ b/XmlResolver/XmlResolver.csproj @@ -2,7 +2,8 @@ - net8.0 + net8.0;netstandard2.0 + 14 True Norman Walsh The xmlresolver project provides an implementation of the System.Xml.XmlResolver. It uses the OASIS XML Catalogs V1.1 Standard to provide a mapping from external identifiers and URIs to local resources. @@ -22,11 +23,24 @@ - + + + + + + + + + + + + + + - + diff --git a/XmlResolver/XmlResolverConfiguration.cs b/XmlResolver/XmlResolverConfiguration.cs index c1109b8..6f6171d 100644 --- a/XmlResolver/XmlResolverConfiguration.cs +++ b/XmlResolver/XmlResolverConfiguration.cs @@ -407,7 +407,7 @@ private void LoadPropertiesConfiguration(Uri propertyFile, IConfigurationSection property = section.GetSection("catalogs"); if (property.Value != null) { - String[] tokens = property.Value.Split(";"); + var tokens = property.Value.Split(";"); catalogs.Clear(); if (showConfigChanges) { logger.Debug("Catalog list cleared"); @@ -429,7 +429,7 @@ private void LoadPropertiesConfiguration(Uri propertyFile, IConfigurationSection property = section.GetSection("catalogAdditions"); if (property.Value != null) { - String[] tokens = property.Value.Split(";"); + var tokens = property.Value.Split(";"); foreach (var token in tokens) { if (!"".Equals(token)) { string caturi = token; From 49edef5322406fd095b080c5792421c06cc026f3 Mon Sep 17 00:00:00 2001 From: bernd Date: Thu, 8 Jan 2026 23:40:37 +0100 Subject: [PATCH 2/4] fix gitignore (add .gitignore code from dotnet/roslyn - it handles almost everything) --- .gitignore | 197 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 197 insertions(+) diff --git a/.gitignore b/.gitignore index cf7e353..34ac338 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,200 @@ build/ /XmlResolverData/Data /XmlResolverData/XmlResolverData.csproj /DataTests/DataTest.cs + + +# User-specific files +*.suo +*.user +*.userprefs +*.sln.docstates +*.svclog +.vs/ +.vscode/settings.json + +# Build results +[Aa]rtifacts/ +[Dd]ebug/ +[Rr]elease/ +[Bb]inaries/ +[Bb]in/ +[Oo]bj/ +.dotnet/ +.tools/ +.packages/ +.nuget/ +.complog/ +/MSBuild_Logs/ + +# Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets +!packages/*/build/ + +# Debug artifacts +launchSettings.json + +# Prevent accidental re-checkin of NuGet.exe +NuGet.exe + +# NuGet restore semaphore +build/ToolsetPackages/toolsetpackages.semaphore + +# NuGet package +src/Tools/UploadNugetZip/*.zip + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* +UnitTestResults.html + +# NuGet V3 artifacts +*-packages.config +*.nuget.props +*.nuget.targets +project.lock.json +*.binlog +*.project.lock.json + +*_i.c +*_p.c +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.wrn +*.vspscc +*.vssscc +.builds +*.pidb +*.log +*.scc + +# Visual Studio cache files +*.sln.ide/ + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opensdf +*.sdf +*.cachefile +*.VC.opendb +*.VC.db + +# Visual Studio profiler +*.psess +*.vsp +*.vspx + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +*.ncrunch* +.*crunch*.local.xml + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.Publish.xml + +# NuGet Packages Directory +packages/ + +# Windows Azure Build Output +csx +*.build.csdef + +# Windows Store app package directory +AppPackages/ + +# Others +sql/ +*.Cache +ClientBin/ +[Ss]tyle[Cc]op.* +~$* +*~ +*.dbmdl +*.[Pp]ublish.xml +*.pfx +*.publishsettings + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file to a newer +# Visual Studio version. Backup files are not needed, because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +App_Data/*.mdf +App_Data/*.ldf + + +#LightSwitch generated files +GeneratedArtifacts/ +_Pvt_Extensions/ +ModelManifest.xml + +# ========================= +# Windows detritus +# ========================= + +# Windows image file caches +Thumbs.db +ehthumbs.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Mac desktop service store files +.DS_Store + +# JetBrains Rider +.idea/ + +# WPF temp projects +*wpftmp.* + From d606ac7f04b8b6c6a6897a3c099c20fc7a256cd3 Mon Sep 17 00:00:00 2001 From: bernd Date: Thu, 8 Jan 2026 23:41:51 +0100 Subject: [PATCH 3/4] data assembly has no framework dependencies so we can set the target framework to netstandard2_0 --- tools/make-csproj.xsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/make-csproj.xsl b/tools/make-csproj.xsl index 2018d84..8ad2f39 100644 --- a/tools/make-csproj.xsl +++ b/tools/make-csproj.xsl @@ -12,7 +12,7 @@ - net8.0 + netstandard2.0 True Norman Walsh This package provides a common set of XML resources and an XML Catalog that resolves them. It’s most commonly used with the xmlresolver package. From 57209b6c859b50fda8a622f17f0355e1a6a4b6be Mon Sep 17 00:00:00 2001 From: Norman Walsh Date: Fri, 9 Jan 2026 09:43:16 +0000 Subject: [PATCH 4/4] Move LangVersion back to 12 (for .NET 8?) --- XmlResolver/XmlResolver.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/XmlResolver/XmlResolver.csproj b/XmlResolver/XmlResolver.csproj index 012db2e..24ea6a7 100644 --- a/XmlResolver/XmlResolver.csproj +++ b/XmlResolver/XmlResolver.csproj @@ -3,7 +3,7 @@ net8.0;netstandard2.0 - 14 + 12 True Norman Walsh The xmlresolver project provides an implementation of the System.Xml.XmlResolver. It uses the OASIS XML Catalogs V1.1 Standard to provide a mapping from external identifiers and URIs to local resources.