Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dotnet-svcutil: update netnamedpipe pkg for metadata downloads and improve exception handling for WCFCSTools #5543

Closed
wants to merge 4 commits into from

Conversation

imcarolwang
Copy link
Contributor

No description provided.

@imcarolwang imcarolwang changed the title Update netnamedpipe pkg for metadata downloads and improve exception handling for WCFCSTools dotnet-svcutil: update netnamedpipe pkg for metadata downloads and improve exception handling for WCFCSTools May 16, 2024
<PackageReference Include="System.ServiceModel.NetNamedPipe" Version="6.0.*" Condition="'$(TargetFramework)' == 'net6.0'">
<PrivateAssets>contentfiles;analyzers;build</PrivateAssets>
<PackageReference Include="System.ServiceModel.NetNamedPipe" Version="6.2.*" Condition="'$(TargetFramework)' == 'net6.0'">
<IncludeAssets>all</IncludeAssets>
</PackageReference>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since this 8.0 version of dotnet-svcutil.exe, only need to reference 8.0 version of WCF Client library.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If only reference the 8.0 NetNamedPipe package, it can cause issues for user project targeting net6.0, particularly when adding net.pipe service reference with type reuse option enabled. In such case, the associated bootstrapper project will also target net6.0, causing problem situation of loading the 8.0 NetNamedPipe package assembly in a net6.0 runtime environment.

We have two potential solutions::

  1. Use the 6.2 named pipe package for net6.0 target and 8.0 named pipe package for the net8.0 target.
  2. Use the 6.2 named pipe package for both net6.0 and net8.0 targets.

The current implementation adopts the 1st option.

<ItemGroup>
<PublishedDlls Include="$(OutputPath)\*.dll" />
</ItemGroup>
<Copy SourceFiles="@(PublishedDlls)" DestinationFolder="$(CustomOutputFolder)\internalAssets\net6.0" Condition="$(OutputPath.Contains('net6.0'))" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same reason as above.

@@ -107,7 +107,7 @@ public async Task ImportMetadataAsync(Action<WsdlImporter> onWsdlImporterCreated
}
else
{
tfn = "net6.0";
tfn = Environment.Version.Major >= 8 ? "net8.0" : "net6.0";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this only relying on .NET 8.0? If so, throw some kind of exception? Is this protected somewhere else? If so, at least add a comment.

Copy link
Contributor Author

@imcarolwang imcarolwang Jun 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Determined by NetNamedPipe package versions referenced by Microsoft.Svcutil.NamedPipeMetadataImporter.csproj's framework targets, there are two versions of the NetNamedPipe package assembly to choose from for downloading metadata: one based on .net8.0 and the other on net6.0 runtime. Here we pick the right version based on the execution CLR version.

try
{
object typeInstance = Activator.CreateInstance(type, null);
MethodInfo methodInfo = type.GetMethod("GetMetadatadataAsync", BindingFlags.Public | BindingFlags.Instance);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this necessary? If necessary, at least add comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is necessary. As per our original plan, we are utilizing a reflection approach to download metadata for the named pipe service. The method entry point for this is GetMetadataAsync, defined within Microsoft.Svcutil.NamedPipeMetadataImporter.csproj.

@imcarolwang
Copy link
Contributor Author

Closing. This will be addressed in separate PRs #5582 and #5604.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants