From d0ab5b7eaeb25d0e1af991099d45c0dd27366845 Mon Sep 17 00:00:00 2001 From: Carol Wang Date: Tue, 16 Apr 2024 03:17:13 +0000 Subject: [PATCH 1/6] dotnet-svcutil: write referenced assembly name instead of absolute path to generated json file --- src/dotnet-svcutil/lib/src/CommandProcessorOptions.cs | 7 ++++++- .../lib/src/Shared/Options/UpdateOptions.cs | 10 ++++++++++ .../ServiceReference/dotnet-svcutil.params.json | 2 +- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/dotnet-svcutil/lib/src/CommandProcessorOptions.cs b/src/dotnet-svcutil/lib/src/CommandProcessorOptions.cs index f9b7b294b08..9a43bb790d3 100644 --- a/src/dotnet-svcutil/lib/src/CommandProcessorOptions.cs +++ b/src/dotnet-svcutil/lib/src/CommandProcessorOptions.cs @@ -627,7 +627,12 @@ private async Task ProcessReferencesOptionAsync(CancellationToken cancellationTo { for (int idx = this.References.Count - 1; idx >= 0; idx--) { - if (!references.Contains(this.References[idx])) + var selected = references.Where(x => this.References[idx].Name == x.Name).FirstOrDefault(); + if (selected != null) + { + this.References[idx] = selected; + } + else { this.References.RemoveAt(idx); } diff --git a/src/dotnet-svcutil/lib/src/Shared/Options/UpdateOptions.cs b/src/dotnet-svcutil/lib/src/Shared/Options/UpdateOptions.cs index b1c5781515d..017e879fc74 100644 --- a/src/dotnet-svcutil/lib/src/Shared/Options/UpdateOptions.cs +++ b/src/dotnet-svcutil/lib/src/Shared/Options/UpdateOptions.cs @@ -97,6 +97,16 @@ public void MakePathsRelativeTo(DirectoryInfo optionsFileDirectory) this.Inputs[idx] = new Uri(relPath, UriKind.Relative); } } + + //update referenced assembly path + for (int idx = 0; idx < this.References.Count; idx++) + { + var reference = this.References[idx]; + if (reference.DependencyType.Equals(ProjectDependencyType.Binary)) + { + this.References[idx] = ProjectDependency.FromAssembly(reference.AssemblyName); + } + } } public void ResolveFullPathsFrom(DirectoryInfo optionsFileDirectory) diff --git a/src/dotnet-svcutil/lib/tests/Baselines/MultiTargetTypeReuse/TypeReuseClient/ServiceReference/dotnet-svcutil.params.json b/src/dotnet-svcutil/lib/tests/Baselines/MultiTargetTypeReuse/TypeReuseClient/ServiceReference/dotnet-svcutil.params.json index db493e18ee4..0b2ee6e8299 100644 --- a/src/dotnet-svcutil/lib/tests/Baselines/MultiTargetTypeReuse/TypeReuseClient/ServiceReference/dotnet-svcutil.params.json +++ b/src/dotnet-svcutil/lib/tests/Baselines/MultiTargetTypeReuse/TypeReuseClient/ServiceReference/dotnet-svcutil.params.json @@ -10,7 +10,7 @@ ], "outputFile": "Reference.cs", "references": [ - "$TEMP$MultiTargetTypeReuse//TypeReuseClient//bin//Debug//net6.0//BinLib.dll" + "BinLib" ], "targetFramework": "N.N", "typeReuseMode": "All" From 33d576b4f007463110251f3ec31ad50cfe44884d Mon Sep 17 00:00:00 2001 From: Carol Wang Date: Wed, 18 Sep 2024 11:22:53 +0800 Subject: [PATCH 2/6] Update. --- src/dotnet-svcutil/lib/src/CommandProcessorOptions.cs | 2 +- .../lib/src/Shared/Options/UpdateOptions.cs | 10 ---------- src/dotnet-svcutil/lib/src/Shared/ProjectDependency.cs | 2 +- 3 files changed, 2 insertions(+), 12 deletions(-) diff --git a/src/dotnet-svcutil/lib/src/CommandProcessorOptions.cs b/src/dotnet-svcutil/lib/src/CommandProcessorOptions.cs index 9a43bb790d3..41c8478c2f6 100644 --- a/src/dotnet-svcutil/lib/src/CommandProcessorOptions.cs +++ b/src/dotnet-svcutil/lib/src/CommandProcessorOptions.cs @@ -627,7 +627,7 @@ private async Task ProcessReferencesOptionAsync(CancellationToken cancellationTo { for (int idx = this.References.Count - 1; idx >= 0; idx--) { - var selected = references.Where(x => this.References[idx].Name == x.Name).FirstOrDefault(); + var selected = references.Where(x => string.Equals(this.References[idx].Name, x.Name, StringComparison.OrdinalIgnoreCase)).FirstOrDefault(); if (selected != null) { this.References[idx] = selected; diff --git a/src/dotnet-svcutil/lib/src/Shared/Options/UpdateOptions.cs b/src/dotnet-svcutil/lib/src/Shared/Options/UpdateOptions.cs index 017e879fc74..b1c5781515d 100644 --- a/src/dotnet-svcutil/lib/src/Shared/Options/UpdateOptions.cs +++ b/src/dotnet-svcutil/lib/src/Shared/Options/UpdateOptions.cs @@ -97,16 +97,6 @@ public void MakePathsRelativeTo(DirectoryInfo optionsFileDirectory) this.Inputs[idx] = new Uri(relPath, UriKind.Relative); } } - - //update referenced assembly path - for (int idx = 0; idx < this.References.Count; idx++) - { - var reference = this.References[idx]; - if (reference.DependencyType.Equals(ProjectDependencyType.Binary)) - { - this.References[idx] = ProjectDependency.FromAssembly(reference.AssemblyName); - } - } } public void ResolveFullPathsFrom(DirectoryInfo optionsFileDirectory) diff --git a/src/dotnet-svcutil/lib/src/Shared/ProjectDependency.cs b/src/dotnet-svcutil/lib/src/Shared/ProjectDependency.cs index 8e392855b6f..99664c2b5ed 100644 --- a/src/dotnet-svcutil/lib/src/Shared/ProjectDependency.cs +++ b/src/dotnet-svcutil/lib/src/Shared/ProjectDependency.cs @@ -153,7 +153,7 @@ private ProjectDependency(string filePath = "", string packageName = "", string this.ReferenceIdentity = this.DependencyType == ProjectDependencyType.Package || this.DependencyType == ProjectDependencyType.Tool || !string.IsNullOrWhiteSpace(packageName) ? string.Format(CultureInfo.InvariantCulture, "{0}, {{{1}, {2}}}", this.AssemblyName, this.Name, this.Version) : - this.FullPath; + this.AssemblyName; this.IsFramework = this.Name == NetCoreAppPackageID || this.Name == NetStandardLibraryPackageID; } From 11e215c275a34c483126f080bafe5dd6db10df29 Mon Sep 17 00:00:00 2001 From: Carol Wang Date: Tue, 15 Oct 2024 17:29:13 +0800 Subject: [PATCH 3/6] update. --- src/dotnet-svcutil/lib/src/Shared/ProjectDependency.cs | 2 +- .../TypeReuseClient/ServiceReference/dotnet-svcutil.params.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dotnet-svcutil/lib/src/Shared/ProjectDependency.cs b/src/dotnet-svcutil/lib/src/Shared/ProjectDependency.cs index 99664c2b5ed..e408ea2251c 100644 --- a/src/dotnet-svcutil/lib/src/Shared/ProjectDependency.cs +++ b/src/dotnet-svcutil/lib/src/Shared/ProjectDependency.cs @@ -153,7 +153,7 @@ private ProjectDependency(string filePath = "", string packageName = "", string this.ReferenceIdentity = this.DependencyType == ProjectDependencyType.Package || this.DependencyType == ProjectDependencyType.Tool || !string.IsNullOrWhiteSpace(packageName) ? string.Format(CultureInfo.InvariantCulture, "{0}, {{{1}, {2}}}", this.AssemblyName, this.Name, this.Version) : - this.AssemblyName; + string.Format(CultureInfo.InvariantCulture, "{0}, {1}", this.AssemblyName, this.Version); this.IsFramework = this.Name == NetCoreAppPackageID || this.Name == NetStandardLibraryPackageID; } diff --git a/src/dotnet-svcutil/lib/tests/Baselines/MultiTargetTypeReuse/TypeReuseClient/ServiceReference/dotnet-svcutil.params.json b/src/dotnet-svcutil/lib/tests/Baselines/MultiTargetTypeReuse/TypeReuseClient/ServiceReference/dotnet-svcutil.params.json index 0b2ee6e8299..85b60066f93 100644 --- a/src/dotnet-svcutil/lib/tests/Baselines/MultiTargetTypeReuse/TypeReuseClient/ServiceReference/dotnet-svcutil.params.json +++ b/src/dotnet-svcutil/lib/tests/Baselines/MultiTargetTypeReuse/TypeReuseClient/ServiceReference/dotnet-svcutil.params.json @@ -10,7 +10,7 @@ ], "outputFile": "Reference.cs", "references": [ - "BinLib" + "BinLib, *" ], "targetFramework": "N.N", "typeReuseMode": "All" From 1530698bcbb6eb33cea9917d2f6bd763d8ae3b03 Mon Sep 17 00:00:00 2001 From: Carol Wang Date: Fri, 18 Oct 2024 20:07:54 +0800 Subject: [PATCH 4/6] update fix. --- .../lib/src/Shared/Options/UpdateOptions.cs | 21 +++++++++++++++++++ .../lib/src/Shared/ProjectDependency.cs | 6 +++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/dotnet-svcutil/lib/src/Shared/Options/UpdateOptions.cs b/src/dotnet-svcutil/lib/src/Shared/Options/UpdateOptions.cs index b1c5781515d..fba627672f9 100644 --- a/src/dotnet-svcutil/lib/src/Shared/Options/UpdateOptions.cs +++ b/src/dotnet-svcutil/lib/src/Shared/Options/UpdateOptions.cs @@ -97,6 +97,17 @@ public void MakePathsRelativeTo(DirectoryInfo optionsFileDirectory) this.Inputs[idx] = new Uri(relPath, UriKind.Relative); } } + + // Update references + for (int idx = 0; idx < this.References.Count; idx++) + { + var reference = this.References[idx]; + if (reference.DependencyType == ProjectDependencyType.Project || reference.DependencyType == ProjectDependencyType.Binary) + { + PathHelper.GetRelativePath(reference.FullPath, optionsFileDirectory, out relPath); + this.References[idx].ReferenceIdentity = relPath; + } + } } public void ResolveFullPathsFrom(DirectoryInfo optionsFileDirectory) @@ -116,6 +127,16 @@ public void ResolveFullPathsFrom(DirectoryInfo optionsFileDirectory) this.Inputs[idx] = fileUri; } } + + // Update references full path + for (int idx = 0; idx < this.References.Count; idx++) + { + var reference = this.References[idx]; + if (reference.DependencyType == ProjectDependencyType.Project || reference.DependencyType == ProjectDependencyType.Binary) + { + this.References[idx].FullPath = Path.Combine(optionsFileDirectory.FullName, reference.ReferenceIdentity); + } + } } } } diff --git a/src/dotnet-svcutil/lib/src/Shared/ProjectDependency.cs b/src/dotnet-svcutil/lib/src/Shared/ProjectDependency.cs index e408ea2251c..c484da3899e 100644 --- a/src/dotnet-svcutil/lib/src/Shared/ProjectDependency.cs +++ b/src/dotnet-svcutil/lib/src/Shared/ProjectDependency.cs @@ -43,7 +43,7 @@ internal class ProjectDependency : IComparable /// /// Assembly full path. /// - public string FullPath { get; private set; } + public string FullPath { get; set; } /// /// Assembly name. @@ -63,7 +63,7 @@ internal class ProjectDependency : IComparable /// /// The package identity, used for describing the dependency passed to Svcutil. /// - public string ReferenceIdentity { get; private set; } + public string ReferenceIdentity { get; set; } #region instance contruction methods // this ctr is private to ensure the integrity of the data which can be done only by the provided static instance creation (FromXXX) methods. @@ -153,7 +153,7 @@ private ProjectDependency(string filePath = "", string packageName = "", string this.ReferenceIdentity = this.DependencyType == ProjectDependencyType.Package || this.DependencyType == ProjectDependencyType.Tool || !string.IsNullOrWhiteSpace(packageName) ? string.Format(CultureInfo.InvariantCulture, "{0}, {{{1}, {2}}}", this.AssemblyName, this.Name, this.Version) : - string.Format(CultureInfo.InvariantCulture, "{0}, {1}", this.AssemblyName, this.Version); + this.FullPath; this.IsFramework = this.Name == NetCoreAppPackageID || this.Name == NetStandardLibraryPackageID; } From db11dd1e28fa17084a3813d4b5b926abf941df4a Mon Sep 17 00:00:00 2001 From: Carol Wang Date: Mon, 21 Oct 2024 09:08:00 +0800 Subject: [PATCH 5/6] Update test baseline. --- .../TypeReuseClient/ServiceReference/dotnet-svcutil.params.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dotnet-svcutil/lib/tests/Baselines/MultiTargetTypeReuse/TypeReuseClient/ServiceReference/dotnet-svcutil.params.json b/src/dotnet-svcutil/lib/tests/Baselines/MultiTargetTypeReuse/TypeReuseClient/ServiceReference/dotnet-svcutil.params.json index 85b60066f93..04374f6339f 100644 --- a/src/dotnet-svcutil/lib/tests/Baselines/MultiTargetTypeReuse/TypeReuseClient/ServiceReference/dotnet-svcutil.params.json +++ b/src/dotnet-svcutil/lib/tests/Baselines/MultiTargetTypeReuse/TypeReuseClient/ServiceReference/dotnet-svcutil.params.json @@ -10,7 +10,7 @@ ], "outputFile": "Reference.cs", "references": [ - "BinLib, *" + "../bin/Debug/net6.0/BinLib.dll" ], "targetFramework": "N.N", "typeReuseMode": "All" From 3f52c4d33ab7db332559ee8d4a008e660c0f898e Mon Sep 17 00:00:00 2001 From: Carol Wang Date: Mon, 21 Oct 2024 13:39:10 +0800 Subject: [PATCH 6/6] update. --- src/dotnet-svcutil/lib/src/CommandProcessorOptions.cs | 7 +------ src/dotnet-svcutil/lib/src/Shared/Options/UpdateOptions.cs | 7 ++++--- src/dotnet-svcutil/lib/src/Shared/ProjectDependency.cs | 2 +- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/dotnet-svcutil/lib/src/CommandProcessorOptions.cs b/src/dotnet-svcutil/lib/src/CommandProcessorOptions.cs index 41c8478c2f6..f9b7b294b08 100644 --- a/src/dotnet-svcutil/lib/src/CommandProcessorOptions.cs +++ b/src/dotnet-svcutil/lib/src/CommandProcessorOptions.cs @@ -627,12 +627,7 @@ private async Task ProcessReferencesOptionAsync(CancellationToken cancellationTo { for (int idx = this.References.Count - 1; idx >= 0; idx--) { - var selected = references.Where(x => string.Equals(this.References[idx].Name, x.Name, StringComparison.OrdinalIgnoreCase)).FirstOrDefault(); - if (selected != null) - { - this.References[idx] = selected; - } - else + if (!references.Contains(this.References[idx])) { this.References.RemoveAt(idx); } diff --git a/src/dotnet-svcutil/lib/src/Shared/Options/UpdateOptions.cs b/src/dotnet-svcutil/lib/src/Shared/Options/UpdateOptions.cs index fba627672f9..692f37de860 100644 --- a/src/dotnet-svcutil/lib/src/Shared/Options/UpdateOptions.cs +++ b/src/dotnet-svcutil/lib/src/Shared/Options/UpdateOptions.cs @@ -104,8 +104,7 @@ public void MakePathsRelativeTo(DirectoryInfo optionsFileDirectory) var reference = this.References[idx]; if (reference.DependencyType == ProjectDependencyType.Project || reference.DependencyType == ProjectDependencyType.Binary) { - PathHelper.GetRelativePath(reference.FullPath, optionsFileDirectory, out relPath); - this.References[idx].ReferenceIdentity = relPath; + this.References[idx].ReferenceIdentity = PathHelper.GetRelativePath(reference.FullPath, optionsFileDirectory, out relPath) ? relPath : reference.FullPath; } } } @@ -134,7 +133,9 @@ public void ResolveFullPathsFrom(DirectoryInfo optionsFileDirectory) var reference = this.References[idx]; if (reference.DependencyType == ProjectDependencyType.Project || reference.DependencyType == ProjectDependencyType.Binary) { - this.References[idx].FullPath = Path.Combine(optionsFileDirectory.FullName, reference.ReferenceIdentity); + string fullPath = Path.GetFullPath(Path.Combine(optionsFileDirectory.FullName, reference.ReferenceIdentity)); + this.References[idx].FullPath = fullPath; + this.References[idx].ReferenceIdentity = fullPath; } } } diff --git a/src/dotnet-svcutil/lib/src/Shared/ProjectDependency.cs b/src/dotnet-svcutil/lib/src/Shared/ProjectDependency.cs index c484da3899e..4ba6b138400 100644 --- a/src/dotnet-svcutil/lib/src/Shared/ProjectDependency.cs +++ b/src/dotnet-svcutil/lib/src/Shared/ProjectDependency.cs @@ -153,7 +153,7 @@ private ProjectDependency(string filePath = "", string packageName = "", string this.ReferenceIdentity = this.DependencyType == ProjectDependencyType.Package || this.DependencyType == ProjectDependencyType.Tool || !string.IsNullOrWhiteSpace(packageName) ? string.Format(CultureInfo.InvariantCulture, "{0}, {{{1}, {2}}}", this.AssemblyName, this.Name, this.Version) : - this.FullPath; + filePath; this.IsFramework = this.Name == NetCoreAppPackageID || this.Name == NetStandardLibraryPackageID; }