Skip to content

Commit 3c9039b

Browse files
committed
Update WCF sample Compression Encoder code to conditionally support .NET framework / Core
1 parent 6d83421 commit 3c9039b

File tree

13 files changed

+201
-336
lines changed

13 files changed

+201
-336
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,99 +1,36 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
1+
<Project Sdk="Microsoft.NET.Sdk">
32
<PropertyGroup>
4-
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5-
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6-
<ProductVersion>8.0.50727</ProductVersion>
7-
<SchemaVersion>2.0</SchemaVersion>
8-
<ProjectGuid>{97E8A065-31ED-4506-B3A4-6B2E2ED5B124}</ProjectGuid>
3+
<TargetFrameworks>net462;net6.0</TargetFrameworks>
94
<OutputType>Exe</OutputType>
10-
<AppDesignerFolder>Properties</AppDesignerFolder>
11-
<RootNamespace>Microsoft.Samples.GZipEncoder</RootNamespace>
12-
<AssemblyName>Client</AssemblyName>
13-
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
14-
<FileUpgradeFlags>
15-
</FileUpgradeFlags>
16-
<OldToolsVersion>2.0</OldToolsVersion>
17-
<UpgradeBackupLocation />
18-
<PublishUrl>publish\</PublishUrl>
19-
<Install>true</Install>
20-
<InstallFrom>Disk</InstallFrom>
21-
<UpdateEnabled>false</UpdateEnabled>
22-
<UpdateMode>Foreground</UpdateMode>
23-
<UpdateInterval>7</UpdateInterval>
24-
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
25-
<UpdatePeriodically>false</UpdatePeriodically>
26-
<UpdateRequired>false</UpdateRequired>
27-
<MapFileExtensions>true</MapFileExtensions>
28-
<ApplicationRevision>0</ApplicationRevision>
29-
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
30-
<IsWebBootstrapper>false</IsWebBootstrapper>
31-
<UseApplicationTrust>false</UseApplicationTrust>
32-
<BootstrapperEnabled>true</BootstrapperEnabled>
33-
<TargetFrameworkProfile />
5+
<Title>Client</Title>
6+
<Description>GZipEncoder</Description>
7+
<Company>Microsoft Corporation</Company>
8+
<Product>Windows Communication Foundation and Windows Workflow Foundation SDK</Product>
9+
<Copyright>Copyright (c) Microsoft Corporation</Copyright>
3410
</PropertyGroup>
35-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
36-
<DebugSymbols>true</DebugSymbols>
37-
<DebugType>full</DebugType>
38-
<Optimize>false</Optimize>
39-
<OutputPath>bin\</OutputPath>
40-
<DefineConstants>DEBUG;TRACE</DefineConstants>
41-
<ErrorReport>prompt</ErrorReport>
42-
<WarningLevel>4</WarningLevel>
43-
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
44-
</PropertyGroup>
45-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
46-
<DebugType>pdbonly</DebugType>
47-
<Optimize>true</Optimize>
48-
<OutputPath>bin\Release\</OutputPath>
49-
<DefineConstants>TRACE</DefineConstants>
50-
<ErrorReport>prompt</ErrorReport>
51-
<WarningLevel>4</WarningLevel>
52-
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
53-
</PropertyGroup>
54-
<ItemGroup>
55-
<Reference Include="System" />
56-
<Reference Include="System.configuration" />
57-
<Reference Include="System.Data" />
58-
<Reference Include="System.Runtime.Serialization" />
59-
<Reference Include="System.ServiceModel" />
60-
<Reference Include="System.Xml" />
11+
12+
<ItemGroup Condition=" '$(TargetFramework)' == 'net462' ">
13+
<None Remove="Connected Services\Microsoft.Samples.GZipEncoder\ConnectedService.json" />
14+
<Compile Remove="Connected Services\Microsoft.Samples.GZipEncoder\Reference.cs" />
15+
<None Include="Connected Services\Microsoft.Samples.GZipEncoder\Reference.cs" />
6116
</ItemGroup>
62-
<ItemGroup>
63-
<Compile Include="generatedClient.cs" />
64-
<Compile Include="Program.cs" />
65-
<Compile Include="Properties\AssemblyInfo.cs" />
17+
18+
<ItemGroup Condition=" '$(TargetFramework)' == 'net6.0' ">
19+
<None Remove="App.config" />
20+
<Compile Remove="generatedClient.cs" />
21+
<None Include="generatedClient.cs" />
6622
</ItemGroup>
67-
<ItemGroup>
68-
<None Include="app.config" />
23+
24+
<ItemGroup Condition=" '$(TargetFramework)' == 'net462' ">
25+
<Reference Include="System.ServiceModel" />
6926
</ItemGroup>
70-
<ItemGroup>
71-
<ProjectReference Include="..\GZipEncoder\GZipEncoder.csproj">
72-
<Project>{3EB736C4-62EA-4887-B040-948B13EF29B9}</Project>
73-
<Name>GZipEncoder</Name>
74-
</ProjectReference>
27+
28+
<ItemGroup Condition=" '$(TargetFramework)' == 'net6.0' ">
29+
<PackageReference Include="System.ServiceModel.Primitives" Version="6.*" />
30+
<PackageReference Include="System.ServiceModel.Http" Version="6.*" />
7531
</ItemGroup>
32+
7633
<ItemGroup>
77-
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
78-
<Visible>False</Visible>
79-
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
80-
<Install>false</Install>
81-
</BootstrapperPackage>
82-
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
83-
<Visible>False</Visible>
84-
<ProductName>.NET Framework 3.5 SP1</ProductName>
85-
<Install>true</Install>
86-
</BootstrapperPackage>
87-
<BootstrapperPackage Include="Microsoft.VisualBasic.PowerPacks.10.0">
88-
<Visible>False</Visible>
89-
<ProductName>Microsoft Visual Basic PowerPacks 10.0</ProductName>
90-
<Install>true</Install>
91-
</BootstrapperPackage>
92-
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
93-
<Visible>False</Visible>
94-
<ProductName>Windows Installer 3.1</ProductName>
95-
<Install>true</Install>
96-
</BootstrapperPackage>
34+
<ProjectReference Include="..\GZipEncoder\GZipEncoder.csproj" />
9735
</ItemGroup>
98-
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
99-
</Project>
36+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"ExtendedData": {
3+
"inputs": [
4+
"http://localhost:8000/samples/GZipEncoder?wsdl"
5+
],
6+
"collectionTypes": [
7+
"System.Array",
8+
"System.Collections.Generic.Dictionary`2"
9+
],
10+
"namespaceMappings": [
11+
"*, Microsoft.Samples.GZipEncoder"
12+
],
13+
"sync": true,
14+
"targetFramework": "net6.0",
15+
"typeReuseMode": "None"
16+
}
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
//------------------------------------------------------------------------------
2+
// <auto-generated>
3+
// This code was generated by a tool.
4+
//
5+
// Changes to this file may cause incorrect behavior and will be lost if
6+
// the code is regenerated.
7+
// </auto-generated>
8+
//------------------------------------------------------------------------------
9+
10+
namespace Microsoft.Samples.GZipEncoder
11+
{
12+
13+
14+
[System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.1.0")]
15+
[System.ServiceModel.ServiceContractAttribute(ConfigurationName="Microsoft.Samples.GZipEncoder.ISampleServer")]
16+
public interface ISampleServer
17+
{
18+
19+
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ISampleServer/Echo", ReplyAction="http://tempuri.org/ISampleServer/EchoResponse")]
20+
string Echo(string input);
21+
22+
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ISampleServer/Echo", ReplyAction="http://tempuri.org/ISampleServer/EchoResponse")]
23+
System.Threading.Tasks.Task<string> EchoAsync(string input);
24+
25+
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ISampleServer/BigEcho", ReplyAction="http://tempuri.org/ISampleServer/BigEchoResponse")]
26+
string[] BigEcho(string[] input);
27+
28+
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ISampleServer/BigEcho", ReplyAction="http://tempuri.org/ISampleServer/BigEchoResponse")]
29+
System.Threading.Tasks.Task<string[]> BigEchoAsync(string[] input);
30+
}
31+
32+
[System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.1.0")]
33+
public interface ISampleServerChannel : Microsoft.Samples.GZipEncoder.ISampleServer, System.ServiceModel.IClientChannel
34+
{
35+
}
36+
37+
[System.Diagnostics.DebuggerStepThroughAttribute()]
38+
[System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.1.0")]
39+
public partial class SampleServerClient : System.ServiceModel.ClientBase<Microsoft.Samples.GZipEncoder.ISampleServer>, Microsoft.Samples.GZipEncoder.ISampleServer
40+
{
41+
42+
public SampleServerClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) :
43+
base(binding, remoteAddress)
44+
{
45+
}
46+
47+
public string Echo(string input)
48+
{
49+
return base.Channel.Echo(input);
50+
}
51+
52+
public System.Threading.Tasks.Task<string> EchoAsync(string input)
53+
{
54+
return base.Channel.EchoAsync(input);
55+
}
56+
57+
public string[] BigEcho(string[] input)
58+
{
59+
return base.Channel.BigEcho(input);
60+
}
61+
62+
public System.Threading.Tasks.Task<string[]> BigEchoAsync(string[] input)
63+
{
64+
return base.Channel.BigEchoAsync(input);
65+
}
66+
67+
public virtual System.Threading.Tasks.Task OpenAsync()
68+
{
69+
return System.Threading.Tasks.Task.Factory.FromAsync(((System.ServiceModel.ICommunicationObject)(this)).BeginOpen(null, null), new System.Action<System.IAsyncResult>(((System.ServiceModel.ICommunicationObject)(this)).EndOpen));
70+
}
71+
}
72+
}

framework/wcf/Extensibility/MessageEncoder/Compression/CS/Client/Program.cs

+9
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,23 @@
33
//----------------------------------------------------------------
44

55
using System;
6+
using System.ServiceModel;
7+
using System.ServiceModel.Channels;
68

79
namespace Microsoft.Samples.GZipEncoder
810
{
911
static class Program
1012
{
1113
static void Main()
1214
{
15+
#if NET6_0_OR_GREATER
16+
Binding binding = new CustomBinding(new GZipMessageEncodingBindingElement(), new HttpTransportBindingElement());
17+
EndpointAddress endpointAddress = new EndpointAddress(new Uri("http://localhost:8000/samples/GZipEncoder"));
18+
SampleServerClient client = new SampleServerClient(binding, endpointAddress);
19+
#else
1320
SampleServerClient client = new SampleServerClient();
21+
#endif
22+
1423

1524
Console.WriteLine("Calling Echo(string):");
1625
Console.WriteLine("Server responds: {0}", client.Echo("Simple hello"));

framework/wcf/Extensibility/MessageEncoder/Compression/CS/Client/Properties/AssemblyInfo.cs

-23
This file was deleted.

framework/wcf/Extensibility/MessageEncoder/Compression/CS/Client/app.config

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@
2424
</customBinding>
2525
</bindings>
2626
</system.serviceModel>
27-
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
27+
</configuration>
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,22 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
1+
<Project Sdk="Microsoft.NET.Sdk">
32
<PropertyGroup>
4-
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5-
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6-
<ProductVersion>8.0.50727</ProductVersion>
7-
<SchemaVersion>2.0</SchemaVersion>
8-
<ProjectGuid>{3EB736C4-62EA-4887-B040-948B13EF29B9}</ProjectGuid>
3+
<TargetFrameworks>net462;net6.0</TargetFrameworks>
94
<OutputType>Library</OutputType>
10-
<RootNamespace>Microsoft.Samples.GZipEncoder</RootNamespace>
11-
<AssemblyName>GZipEncoder</AssemblyName>
12-
<WarningLevel>4</WarningLevel>
13-
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
14-
<FileUpgradeFlags>
15-
</FileUpgradeFlags>
16-
<OldToolsVersion>2.0</OldToolsVersion>
17-
<UpgradeBackupLocation />
18-
<PublishUrl>publish\</PublishUrl>
19-
<Install>true</Install>
20-
<InstallFrom>Disk</InstallFrom>
21-
<UpdateEnabled>false</UpdateEnabled>
22-
<UpdateMode>Foreground</UpdateMode>
23-
<UpdateInterval>7</UpdateInterval>
24-
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
25-
<UpdatePeriodically>false</UpdatePeriodically>
26-
<UpdateRequired>false</UpdateRequired>
27-
<MapFileExtensions>true</MapFileExtensions>
28-
<ApplicationRevision>0</ApplicationRevision>
29-
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
30-
<IsWebBootstrapper>false</IsWebBootstrapper>
31-
<UseApplicationTrust>false</UseApplicationTrust>
32-
<BootstrapperEnabled>true</BootstrapperEnabled>
33-
<TargetFrameworkProfile />
5+
<Title>GZipEncoder</Title>
6+
<Description>GZipEncoder</Description>
7+
<Company>Microsoft Corporation</Company>
8+
<Product>Windows Communication Foundation and Windows Workflow Foundation SDK</Product>
9+
<Copyright>Copyright (c) Microsoft Corporation</Copyright>
3410
</PropertyGroup>
35-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
36-
<DebugSymbols>true</DebugSymbols>
37-
<DebugType>full</DebugType>
38-
<Optimize>false</Optimize>
39-
<OutputPath>.\bin\</OutputPath>
40-
<DefineConstants>DEBUG;TRACE</DefineConstants>
41-
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
42-
</PropertyGroup>
43-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
44-
<DebugType>pdbonly</DebugType>
45-
<Optimize>true</Optimize>
46-
<OutputPath>.\bin\Release\</OutputPath>
47-
<DefineConstants>TRACE</DefineConstants>
48-
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
49-
</PropertyGroup>
50-
<ItemGroup>
51-
<Reference Include="System" />
11+
12+
<ItemGroup Condition=" '$(TargetFramework)' == 'net462' ">
5213
<Reference Include="System.Configuration" />
53-
<Reference Include="System.Data" />
54-
<Reference Include="System.Runtime.Serialization" />
5514
<Reference Include="System.ServiceModel" />
56-
<Reference Include="System.Xml" />
57-
</ItemGroup>
58-
<ItemGroup>
59-
<Compile Include="GZipMessageEncoderFactory.cs" />
60-
<Compile Include="GZipMessageEncodingBindingElement.cs" />
61-
<Compile Include="Properties\AssemblyInfo.cs" />
62-
<Compile Include="GZipMessageEncodingBindingElementImporter.cs" />
6315
</ItemGroup>
64-
<ItemGroup>
65-
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
66-
<Visible>False</Visible>
67-
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
68-
<Install>false</Install>
69-
</BootstrapperPackage>
70-
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
71-
<Visible>False</Visible>
72-
<ProductName>.NET Framework 3.5 SP1</ProductName>
73-
<Install>true</Install>
74-
</BootstrapperPackage>
75-
<BootstrapperPackage Include="Microsoft.VisualBasic.PowerPacks.10.0">
76-
<Visible>False</Visible>
77-
<ProductName>Microsoft Visual Basic PowerPacks 10.0</ProductName>
78-
<Install>true</Install>
79-
</BootstrapperPackage>
80-
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
81-
<Visible>False</Visible>
82-
<ProductName>Windows Installer 3.1</ProductName>
83-
<Install>true</Install>
84-
</BootstrapperPackage>
16+
17+
<ItemGroup Condition=" '$(TargetFramework)' == 'net6.0' ">
18+
<PackageReference Include="System.ServiceModel.Primitives" Version="6.*" />
19+
<PackageReference Include="System.ServiceModel.Http" Version="6.*" />
8520
</ItemGroup>
86-
<Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" />
87-
</Project>
21+
22+
</Project>

0 commit comments

Comments
 (0)