diff --git a/src/dotnet-svcutil/lib/src/CommandProcessorOptions.cs b/src/dotnet-svcutil/lib/src/CommandProcessorOptions.cs index be7357b2566..14f8599591d 100644 --- a/src/dotnet-svcutil/lib/src/CommandProcessorOptions.cs +++ b/src/dotnet-svcutil/lib/src/CommandProcessorOptions.cs @@ -619,21 +619,33 @@ private async Task ProcessReferencesOptionAsync(CancellationToken cancellationTo await logger.WriteMessageAsync(Shared.Resources.ResolvingProjectReferences, logToUI: this.ToolContext <= OperationalContext.Global).ConfigureAwait(false); var references = await this.Project.ResolveProjectReferencesAsync(ProjectDependency.IgnorableDependencies, logger, cancellationToken).ConfigureAwait(false); + var projectDependencies = references.ToList(); + ToolConsole.WriteLine($"TypeReuseMode: {TypeReuseMode}"); if (this.TypeReuseMode == Svcutil.TypeReuseMode.All) { this.References.Clear(); - this.References.AddRange(references); + this.References.AddRange(projectDependencies); } - else // Update operation: remove any reference no longer in the project! + else { + // Update operation: remove any reference no longer in the project! for (int idx = this.References.Count - 1; idx >= 0; idx--) { - if (!references.Contains(this.References[idx])) + if (!projectDependencies.Contains(this.References[idx])) { this.References.RemoveAt(idx); } } + + // Add any new references that are not already in the list. + foreach (var missingReference in projectDependencies) + { + if (!this.References.Contains(missingReference)) + { + this.References.Add(missingReference); + } + } } } } diff --git a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/CodeExporter.cs b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/CodeExporter.cs index 98fd88e5d35..20ab09b3b00 100644 --- a/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/CodeExporter.cs +++ b/src/dotnet-svcutil/lib/src/FrameworkFork/System.Runtime.Serialization/System/Runtime/Serialization/CodeExporter.cs @@ -560,7 +560,7 @@ private CodeTypeReference GetReferencedType(DataContract dataContract) throw /*System.Runtime.Serialization.*/DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidDataContractException(string.Format(SRSerialization.TypeMustBeIXmlSerializable, DataContract.GetClrTypeFullName(type), DataContract.GetClrTypeFullName(Globals.TypeOfIXmlSerializable), dataContract.StableName.Name, dataContract.StableName.Namespace))); } DataContract referencedContract = _dataContractSet.GetDataContract(type); - if (referencedContract.Equals(dataContract)) + if (referencedContract.StableName.Equals(dataContract.StableName)) { typeReference = GetCodeTypeReference(type); typeReference.UserData.Add(s_codeUserDataActualTypeKey, type);