Skip to content

Commit be9b7e0

Browse files
authored
Merge pull request #11 from husaft/master
Updated all projects to be NET 6
2 parents 71d01d6 + 13345a8 commit be9b7e0

File tree

12 files changed

+196
-451
lines changed

12 files changed

+196
-451
lines changed

Source/RtfDomParser.Tests/Helper.cs

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
namespace RtfDomParser.Tests
2+
{
3+
internal static class Helper
4+
{
5+
/// <summary>
6+
/// Test to generate a little rtf document
7+
/// </summary>
8+
/// <param name="w">RTF text writer</param>
9+
internal static void TestBuildRTF(RTFWriter w)
10+
{
11+
w.Encoding = System.Text.Encoding.GetEncoding(936);
12+
// write header
13+
w.WriteStartGroup();
14+
w.WriteKeyword("rtf1");
15+
w.WriteKeyword("ansi");
16+
w.WriteKeyword("ansicpg" + w.Encoding.CodePage);
17+
// wirte font table
18+
w.WriteStartGroup();
19+
w.WriteKeyword("fonttbl");
20+
w.WriteStartGroup();
21+
w.WriteKeyword("f0");
22+
w.WriteText("Arial;");
23+
w.WriteEndGroup();
24+
w.WriteStartGroup();
25+
w.WriteKeyword("f1");
26+
w.WriteText("Times New Roman;");
27+
w.WriteEndGroup();
28+
w.WriteEndGroup();
29+
// write color table
30+
w.WriteStartGroup();
31+
w.WriteKeyword("colortbl");
32+
w.WriteText(";");
33+
w.WriteKeyword("red0");
34+
w.WriteKeyword("green0");
35+
w.WriteKeyword("blue255");
36+
w.WriteText(";");
37+
w.WriteEndGroup();
38+
// write content
39+
w.WriteKeyword("qc"); // set alignment center
40+
w.WriteKeyword("f0"); // set font
41+
w.WriteKeyword("fs30"); // set font size
42+
w.WriteText("This is the first paragraph text ");
43+
w.WriteKeyword("cf1"); // set text color
44+
w.WriteText("Arial ");
45+
w.WriteKeyword("cf0"); // set default color
46+
w.WriteKeyword("f1"); // set font
47+
w.WriteText("Align center ABC12345");
48+
w.WriteKeyword("par"); // new paragraph
49+
w.WriteKeyword("pard"); // clear format
50+
w.WriteKeyword("f1"); // set font
51+
w.WriteKeyword("fs20"); // set font size
52+
w.WriteKeyword("cf1");
53+
w.WriteText("This is the secend paragraph Arial left alignment ABC12345");
54+
// finish
55+
w.WriteEndGroup();
56+
}
57+
}
58+
}
Lines changed: 24 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,24 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3-
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4-
<PropertyGroup>
5-
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6-
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7-
<ProjectGuid>{C2283E51-A105-4FF3-96B4-C77DAC45F2E4}</ProjectGuid>
8-
<OutputType>Library</OutputType>
9-
<AppDesignerFolder>Properties</AppDesignerFolder>
10-
<RootNamespace>RtfDomParser.Tests</RootNamespace>
11-
<AssemblyName>RtfDomParser.Tests</AssemblyName>
12-
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
13-
<FileAlignment>512</FileAlignment>
14-
</PropertyGroup>
15-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
16-
<DebugSymbols>true</DebugSymbols>
17-
<DebugType>full</DebugType>
18-
<Optimize>false</Optimize>
19-
<OutputPath>bin\Debug\</OutputPath>
20-
<DefineConstants>DEBUG;TRACE</DefineConstants>
21-
<ErrorReport>prompt</ErrorReport>
22-
<WarningLevel>4</WarningLevel>
23-
</PropertyGroup>
24-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
25-
<DebugType>pdbonly</DebugType>
26-
<Optimize>true</Optimize>
27-
<OutputPath>bin\Release\</OutputPath>
28-
<DefineConstants>TRACE</DefineConstants>
29-
<ErrorReport>prompt</ErrorReport>
30-
<WarningLevel>4</WarningLevel>
31-
</PropertyGroup>
32-
<ItemGroup>
33-
<Reference Include="nunit.framework, Version=2.6.4.14350, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
34-
<HintPath>..\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
35-
<Private>True</Private>
36-
</Reference>
37-
<Reference Include="System" />
38-
<Reference Include="System.Core" />
39-
<Reference Include="System.Xml.Linq" />
40-
<Reference Include="System.Data.DataSetExtensions" />
41-
<Reference Include="Microsoft.CSharp" />
42-
<Reference Include="System.Data" />
43-
<Reference Include="System.Net.Http" />
44-
<Reference Include="System.Xml" />
45-
</ItemGroup>
46-
<ItemGroup>
47-
<Compile Include="Properties\AssemblyInfo.cs" />
48-
</ItemGroup>
49-
<ItemGroup>
50-
<None Include="packages.config" />
51-
</ItemGroup>
52-
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
53-
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
54-
Other similar extension points exist, see Microsoft.Common.targets.
55-
<Target Name="BeforeBuild">
56-
</Target>
57-
<Target Name="AfterBuild">
58-
</Target>
59-
-->
60-
</Project>
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net6.0-windows</TargetFramework>
5+
<IsPackable>false</IsPackable>
6+
<UseWindowsForms>true</UseWindowsForms>
7+
8+
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
9+
<NoWarn>CA1416</NoWarn>
10+
</PropertyGroup>
11+
12+
<ItemGroup>
13+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
14+
<PackageReference Include="NUnit" Version="3.13.3" />
15+
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
16+
<PackageReference Include="NUnit.Analyzers" Version="3.3.0" />
17+
<PackageReference Include="coverlet.collector" Version="3.1.2" />
18+
</ItemGroup>
19+
20+
<ItemGroup>
21+
<ProjectReference Include="..\RtfDomParser\RtfDomParser.csproj" />
22+
</ItemGroup>
23+
24+
</Project>

Source/RtfDomParser.Tests/RtfTest.cs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
using System.IO;
2+
using System.Threading;
3+
using NUnit.Framework;
4+
5+
namespace RtfDomParser.Tests
6+
{
7+
[TestFixture]
8+
public class RtfTest
9+
{
10+
[SetUp]
11+
public void Setup()
12+
{
13+
Defaults.FontName = System.Windows.Forms.Control.DefaultFont.Name;
14+
}
15+
16+
/// <summary>
17+
/// Test generate rtf file
18+
/// after execute this function you can open c:\a.rtf
19+
/// </summary>
20+
[Test]
21+
public void TestWriteFile()
22+
{
23+
string file = Path.GetFullPath("a.rtf");
24+
RTFWriter w = new RTFWriter(file);
25+
Helper.TestBuildRTF(w);
26+
w.Close();
27+
System.Windows.Forms.MessageBox.Show($"OK, you can open file {file} now.");
28+
}
29+
30+
/// <summary>
31+
/// Test generate rtf text and copy to windows clipboard
32+
/// after execute this function , you can paste rtf text in MS Word
33+
/// </summary>
34+
[Test]
35+
[RequiresThread(ApartmentState.STA)]
36+
public void TestClipboard()
37+
{
38+
System.IO.StringWriter myStr = new System.IO.StringWriter();
39+
RTFWriter w = new RTFWriter(myStr);
40+
Helper.TestBuildRTF(w);
41+
w.Close();
42+
System.Windows.Forms.DataObject data = new System.Windows.Forms.DataObject();
43+
data.SetData(System.Windows.Forms.DataFormats.Rtf, myStr.ToString());
44+
System.Windows.Forms.Clipboard.SetDataObject(data, true);
45+
System.Windows.Forms.MessageBox.Show("OK, you can paste words in MS Word.");
46+
}
47+
}
48+
}

Source/RtfDomParser.WinFormsDemo/Program.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ static class Program
1212
[STAThread]
1313
static void Main()
1414
{
15+
Defaults.FontName = System.Windows.Forms.Control.DefaultFont.Name;
16+
1517
Application.EnableVisualStyles();
1618
Application.SetCompatibleTextRenderingDefault(false);
1719
Application.Run(new frmRTFTest());
Lines changed: 20 additions & 150 deletions
Original file line numberDiff line numberDiff line change
@@ -1,151 +1,21 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
3-
<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>{E91ECAF1-8270-4BD2-8517-5F28DF5B8058}</ProjectGuid>
9-
<OutputType>WinExe</OutputType>
10-
<AppDesignerFolder>Properties</AppDesignerFolder>
11-
<RootNamespace>XDesigner.RTF.Test</RootNamespace>
12-
<AssemblyName>XDesigner.RTF.Test</AssemblyName>
13-
<SccProjectName>
14-
</SccProjectName>
15-
<SccLocalPath>
16-
</SccLocalPath>
17-
<SccAuxPath>
18-
</SccAuxPath>
19-
<SccProvider>
20-
</SccProvider>
21-
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
22-
<FileUpgradeFlags>
23-
</FileUpgradeFlags>
24-
<OldToolsVersion>2.0</OldToolsVersion>
25-
<UpgradeBackupLocation />
26-
<PublishUrl>http://localhost/XDesigner.RTF.Test/</PublishUrl>
27-
<Install>true</Install>
28-
<InstallFrom>Web</InstallFrom>
29-
<UpdateEnabled>true</UpdateEnabled>
30-
<UpdateMode>Foreground</UpdateMode>
31-
<UpdateInterval>7</UpdateInterval>
32-
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
33-
<UpdatePeriodically>false</UpdatePeriodically>
34-
<UpdateRequired>false</UpdateRequired>
35-
<MapFileExtensions>true</MapFileExtensions>
36-
<ApplicationRevision>0</ApplicationRevision>
37-
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
38-
<IsWebBootstrapper>true</IsWebBootstrapper>
39-
<UseApplicationTrust>false</UseApplicationTrust>
40-
<BootstrapperEnabled>true</BootstrapperEnabled>
41-
</PropertyGroup>
42-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
43-
<DebugSymbols>true</DebugSymbols>
44-
<DebugType>full</DebugType>
45-
<Optimize>false</Optimize>
46-
<OutputPath>bin\Debug\</OutputPath>
47-
<DefineConstants>DEBUG;TRACE</DefineConstants>
48-
<ErrorReport>prompt</ErrorReport>
49-
<WarningLevel>4</WarningLevel>
50-
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
51-
<PlatformTarget>x86</PlatformTarget>
52-
</PropertyGroup>
53-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
54-
<DebugType>pdbonly</DebugType>
55-
<Optimize>true</Optimize>
56-
<OutputPath>bin\Release\</OutputPath>
57-
<DefineConstants>TRACE</DefineConstants>
58-
<ErrorReport>prompt</ErrorReport>
59-
<WarningLevel>4</WarningLevel>
60-
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
61-
</PropertyGroup>
62-
<ItemGroup>
63-
<Reference Include="System" />
64-
<Reference Include="System.Data" />
65-
<Reference Include="System.Deployment" />
66-
<Reference Include="System.Drawing" />
67-
<Reference Include="System.Windows.Forms" />
68-
<Reference Include="System.Xml" />
69-
</ItemGroup>
70-
<ItemGroup>
71-
<Compile Include="frmRTFTest.cs">
72-
<SubType>Form</SubType>
73-
</Compile>
74-
<Compile Include="frmRTFTest.Designer.cs">
75-
<DependentUpon>frmRTFTest.cs</DependentUpon>
76-
</Compile>
77-
<Compile Include="Program.cs" />
78-
<EmbeddedResource Include="frmRTFTest.en.resx">
79-
<DependentUpon>frmRTFTest.cs</DependentUpon>
80-
<SubType>Designer</SubType>
81-
</EmbeddedResource>
82-
<EmbeddedResource Include="frmRTFTest.resx">
83-
<DependentUpon>frmRTFTest.cs</DependentUpon>
84-
<SubType>Designer</SubType>
85-
</EmbeddedResource>
86-
<None Include="RTFDemo\htmlrtf1.rtf" />
87-
<None Include="RTFDemo\htmlrtf2.rtf" />
88-
<None Include="RTFDemo\htmlrtf3.rtf" />
89-
<None Include="RTFDemo\Three layer nested table.rtf">
90-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
91-
</None>
92-
<None Include="RTFDemo\Images.rtf">
93-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
94-
</None>
95-
<None Include="RTFDemo\Complex table.rtf">
96-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
97-
</None>
98-
<None Include="RTFDemo\Formated text.rtf">
99-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
100-
</None>
101-
<None Include="RTFDemo\Text box.rtf">
102-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
103-
</None>
104-
<None Include="RTFDemo\Blank.rtf">
105-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
106-
</None>
107-
<None Include="RTFDemo\Simple text.rtf">
108-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
109-
</None>
110-
<None Include="RTFDemo\Simple table.rtf">
111-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
112-
</None>
113-
<None Include="RTFDemo\NestTable.rtf">
114-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
115-
</None>
116-
</ItemGroup>
117-
<ItemGroup>
118-
<ProjectReference Include="..\RtfDomParser\RtfDomParser.csproj">
119-
<Project>{D35F9B37-CF93-48AE-9A1A-3A99930F04FB}</Project>
120-
<Name>XDesigner.RTF</Name>
121-
</ProjectReference>
122-
</ItemGroup>
123-
<ItemGroup>
124-
<Folder Include="Properties\" />
125-
</ItemGroup>
126-
<ItemGroup>
127-
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
128-
<Visible>False</Visible>
129-
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
130-
<Install>false</Install>
131-
</BootstrapperPackage>
132-
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
133-
<Visible>False</Visible>
134-
<ProductName>.NET Framework 3.5 SP1</ProductName>
135-
<Install>true</Install>
136-
</BootstrapperPackage>
137-
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
138-
<Visible>False</Visible>
139-
<ProductName>Windows Installer 3.1</ProductName>
140-
<Install>true</Install>
141-
</BootstrapperPackage>
142-
</ItemGroup>
143-
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
144-
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
145-
Other similar extension points exist, see Microsoft.Common.targets.
146-
<Target Name="BeforeBuild">
147-
</Target>
148-
<Target Name="AfterBuild">
149-
</Target>
150-
-->
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>WinExe</OutputType>
5+
<TargetFramework>net6.0-windows</TargetFramework>
6+
<UseWindowsForms>true</UseWindowsForms>
7+
8+
<RootNamespace>RtfDomParser.Test</RootNamespace>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<ProjectReference Include="..\RtfDomParser\RtfDomParser.csproj" />
13+
</ItemGroup>
14+
15+
<ItemGroup>
16+
<None Update="RTFDemo\*.rtf">
17+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
18+
</None>
19+
</ItemGroup>
20+
15121
</Project>

Source/RtfDomParser/ByteBuffer.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
*/
99

1010
using System;
11-
using System.Windows.Forms;
1211

1312
namespace RtfDomParser
1413
{

0 commit comments

Comments
 (0)