Skip to content

Commit e3036ff

Browse files
Merge pull request #3 from undergroundwires/releasing-1.7
Released 1.7
2 parents bcbda60 + 39e5307 commit e3036ff

33 files changed

+208
-154
lines changed

src/AsyncWindowsClipboard.Tests/WindowsClipboardServiceTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public async Task Can_set_and_get_text()
1818
var actual = await sut.GetTextAsync();
1919
Assert.That(actual, Is.EqualTo(expected));
2020
}
21+
2122
[Test]
2223
public void Ctor_SetsTheTimeoutProperty()
2324
{
@@ -26,4 +27,4 @@ public void Ctor_SetsTheTimeoutProperty()
2627
Assert.That(span, Is.EqualTo(sut.Timeout));
2728
}
2829
}
29-
}
30+
}

src/AsyncWindowsClipboard.Tests/WindowsClipboardSessionTests.cs

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ namespace AsyncWindowsClipboard.Tests
88
[TestFixture]
99
public class WindowsClipboardSessionTests
1010
{
11+
private static IWindowsClipboardSession GetSut() => new WindowsClipboardSession();
1112

1213
[Test]
1314
public void IsOpen_InstanceClosed_ReturnsFalse()
@@ -21,56 +22,54 @@ public void IsOpen_InstanceClosed_ReturnsFalse()
2122
}
2223

2324
[Test]
24-
public void IsOpen_InstanceOpened_ReturnsTrue()
25+
public void IsOpen_InstanceClosed_ReturnsTrue()
2526
{
2627
// Arrange
2728
var sut = GetSut();
28-
// Act
2929
sut.Open();
30+
// Act
31+
sut.Close();
3032
var actual = sut.IsOpen;
3133
// Assert
32-
Assert.True(actual);
34+
Assert.False(actual);
3335
}
3436

3537
[Test]
36-
public void IsOpen_InstanceClosed_ReturnsTrue()
38+
public void IsOpen_InstanceOpened_ReturnsTrue()
3739
{
3840
// Arrange
3941
var sut = GetSut();
40-
sut.Open();
4142
// Act
42-
sut.Close();
43+
sut.Open();
4344
var actual = sut.IsOpen;
4445
// Assert
45-
Assert.False(actual);
46+
Assert.True(actual);
4647
}
4748

4849
[Test]
49-
public void IsSuccessful_InstanceOpened_ReturnsTrue()
50+
public void IsSuccessful_InstanceClosed_ReturnsTrue()
5051
{
5152
// Arrange
5253
var sut = GetSut();
5354
sut.Open();
5455
// Act
55-
var openResult = sut.Open();
56-
var actual = openResult.IsSuccessful;
56+
var closeResult = sut.Close();
57+
var actual = closeResult.IsSuccessful;
5758
// Assert
5859
Assert.True(actual);
5960
}
6061

6162
[Test]
62-
public void IsSuccessful_InstanceClosed_ReturnsTrue()
63+
public void IsSuccessful_InstanceOpened_ReturnsTrue()
6364
{
6465
// Arrange
6566
var sut = GetSut();
6667
sut.Open();
6768
// Act
68-
var closeResult = sut.Close();
69-
var actual = closeResult.IsSuccessful;
69+
var openResult = sut.Open();
70+
var actual = openResult.IsSuccessful;
7071
// Assert
7172
Assert.True(actual);
7273
}
73-
74-
private static IWindowsClipboardSession GetSut() => new WindowsClipboardSession();
7574
}
7675
}
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
<?xml version="1.0" encoding="utf-8" ?>
1+
<?xml version="1.0" encoding="utf-8"?>
2+
23
<configuration>
3-
<startup>
4-
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
5-
</startup>
4+
<startup>
5+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
6+
</startup>
67
</configuration>

src/AsyncWindowsClipboard.WpfTests/App.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
xmlns:local="clr-namespace:AsyncWindowsClipboard.WpfTests"
55
StartupUri="MainWindow.xaml">
66
<Application.Resources>
7-
7+
88
</Application.Resources>
9-
</Application>
9+
</Application>

src/AsyncWindowsClipboard.WpfTests/App.xaml.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
namespace AsyncWindowsClipboard.WpfTests
55
{
66
/// <summary>
7-
/// Interaction logic for App.xaml
7+
/// Interaction logic for App.xaml
88
/// </summary>
99
public partial class App : Application
1010
{
1111
public App()
1212
{
13-
var bitmap = new WindowsClipboardService(timeout:TimeSpan.FromMilliseconds(100));
13+
var bitmap = new WindowsClipboardService(timeout: TimeSpan.FromMilliseconds(100));
1414
}
1515
}
16-
}
16+
}

src/AsyncWindowsClipboard.WpfTests/MainWindow.xaml.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ namespace AsyncWindowsClipboard.WpfTests
88
/// </summary>
99
public partial class MainWindow : Window
1010
{
11-
private readonly IAsyncClipboardService _asyncClipboardService = new WindowsClipboardService(timeout:TimeSpan.FromMilliseconds(100));
11+
private readonly IAsyncClipboardService _asyncClipboardService =
12+
new WindowsClipboardService(timeout: TimeSpan.FromMilliseconds(100));
1213

1314
public MainWindow()
1415
{
@@ -32,10 +33,7 @@ private async void ButtonPasteText_Click(object sender, RoutedEventArgs e)
3233
private async void ButtonDropFileListPaste_Click(object sender, RoutedEventArgs e)
3334
{
3435
var files = await _asyncClipboardService.GetFileDropListAsync();
35-
if (files != null)
36-
{
37-
TextBoxText.Text = string.Join(System.Environment.NewLine, files);
38-
}
36+
if (files != null) TextBoxText.Text = string.Join(Environment.NewLine, files);
3937
}
4038

4139
private async void ButtonDropFileListCopy_Click(object sender, RoutedEventArgs e)
Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,47 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<TargetFrameworks>netstandard2.0;net45;</TargetFrameworks>
4-
<PackageId>AsyncWindowsClipboard</PackageId>
54
<LangVersion>latest</LangVersion>
65
<OutputType>Library</OutputType>
6+
<AssemblyTitle>AsyncWindowsClipboard</AssemblyTitle>
7+
<AssemblyName>AsyncWindowsClipboard</AssemblyName>
78
</PropertyGroup>
89
<ItemGroup>
910
<None Include="..\..\LICENSE" Link="LICENSE" Pack="true" PackagePath="" />
1011
<Content Include="..\..\README.md" Link="README.md" Pack="true" PackagePath="" />
1112
<None Include="..\..\icon.png" Pack="true" PackagePath="\" />
1213
</ItemGroup>
13-
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard1.6'">
14-
<PackageReference Include="System.Threading.Thread">
15-
<Version>4.3.0</Version>
16-
</PackageReference>
17-
</ItemGroup>
1814
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
1915
<Optimize>true</Optimize>
2016
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
2117
<GenerateDocumentationFile>true</GenerateDocumentationFile>
2218
<Description>Thread-safe, asynchronous windows clipboard service with timeout strategy for .NET, C#.</Description>
19+
<PackageTags>asynchronous async clipboard timeout WPF windows forms</PackageTags>
2320
<Copyright>Copyright 2016 - 2019</Copyright>
2421
<PackageLicenseExpression>MIT</PackageLicenseExpression>
25-
<AssemblyTitle>AsyncWindowsClipboard</AssemblyTitle>
22+
<PackageId>AsyncClipboardService</PackageId>
2623
<Authors>undergroundwires</Authors>
27-
<AssemblyName>AsyncWindowsClipboard</AssemblyName>
2824
<PackageProjectUrl>https://github.com/undergroundwires/AsyncWindowsClipboard</PackageProjectUrl>
29-
<PackageLicenseUrl>https://raw.githubusercontent.com/undergroundwires/AsyncWindowsClipboard/master/LICENSE</PackageLicenseUrl>
3025
<RepositoryType>git</RepositoryType>
3126
<RepositoryUrl>https://github.com/undergroundwires/AsyncWindowsClipboard</RepositoryUrl>
3227
<AppDesignerFolder>Properties</AppDesignerFolder>
3328
<RootNamespace>AsyncWindowsClipboard</RootNamespace>
3429
<AssemblyName>AsyncClipboardService</AssemblyName>
35-
<Version>1.6.0</Version>
30+
<Version>1.7.0</Version>
3631
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
37-
3832
<PackageReleaseNotes>
39-
- Included documentation file
40-
- Added support for net45, net451, net46, net462, net47, net471, net472
33+
- Changed license to MIT.
34+
- More documentation and typo fixes.
35+
- Better exception messages for OS errors and fixed swollen exception.
36+
- Changed locking logic to support all types of applications (not Window only).
37+
- Namespace changes in internal classes.
38+
- Support for .netstandard2.0
4139
</PackageReleaseNotes>
42-
<PackageIconUrl>https://raw.githubusercontent.com/undergroundwires/AsyncWindowsClipboard/master/icon.png</PackageIconUrl>
40+
<PackageIcon>icon.png</PackageIcon>
41+
<PackageReadmeFile>README.md</PackageReadmeFile>
42+
<!-- including PDB files in NuGet for source link because symbolsource.org does not support portable PDBs -->
43+
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
44+
<IncludeSymbols>true</IncludeSymbols>
45+
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
4346
</PropertyGroup>
4447
</Project>

src/AsyncWindowsClipboard/Clipboard/ClipboardDataType.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ namespace AsyncWindowsClipboard.Clipboard
77
/// </summary>
88
/// <remarks>
99
/// The clipboard formats defined by the system are called standard clipboard formats.
10-
/// See more at : https://msdn.microsoft.com/en-us/library/windows/desktop/ff729168%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396
10+
/// See more at : https://kutt.it/EGdSiY
1111
/// </remarks>
12-
/// <seealso cref="NativeMethods"/>
12+
/// <seealso cref="NativeMethods" />
1313
internal enum ClipboardDataType : uint
1414
{
1515
/// <summary>
Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,43 @@
11
namespace AsyncWindowsClipboard.Clipboard
22
{
3+
/// <summary>
4+
/// Result of the Clipboard operation
5+
/// </summary>
36
public enum ClipboardOperationResultCode
47
{
58
/// <summary>
6-
/// Clipboard operations was successful
9+
/// Clipboard operations was successful
710
/// </summary>
811
Success = 0,
12+
913
/// <summary>
10-
/// Clipboard operation failed due to an error during opening clipboard.
14+
/// Clipboard operation failed due to an error during opening clipboard.
1115
/// </summary>
1216
ErrorOpenClipboard,
17+
1318
/// <summary>
14-
/// Clipboard operation failed due to an error during closing clipboard.
19+
/// Clipboard operation failed due to an error during closing clipboard.
1520
/// </summary>
1621
ErrorCloseClipboard,
22+
1723
/// <summary>
18-
/// Clipboard operation failed due to an error during clearing clipboard.
24+
/// Clipboard operation failed due to an error during clearing clipboard.
1925
/// </summary>
2026
ErrorClearClipboard,
2127

28+
/// <summary>
29+
/// Clipboard operation when allocating native bytes for the clipboard.
30+
/// </summary>
2231
ErrorGlobalAlloc,
32+
33+
/// <summary>
34+
/// Clipboard operation when communicating native bytes with the clipboard.
35+
/// </summary>
2336
ErrorGlobalLock,
37+
38+
/// <summary>
39+
/// Clipboard operation when communicating wit the clipboard.
40+
/// </summary>
2441
ErrorSetClipboardData
25-
};
26-
}
42+
}
43+
}

src/AsyncWindowsClipboard/Clipboard/Connection/ClipboardOpenerWithTimeout.cs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,15 @@ internal sealed class ClipboardOpenerWithTimeout : IClipboardOpenerWithTimeout
99
{
1010
public const int DefaultDelayMilliseconds = 30;
1111

12-
/// <exception cref="T:System.ArgumentNullException"><paramref name="session"/> is <see langword="null"/></exception>
12+
/// <exception cref="T:System.ArgumentNullException"><paramref name="session" /> is <see langword="null" /></exception>
1313
/// <exception cref="T:System.ArgumentOutOfRangeException">
14-
/// <p><paramref name="timeout" /> is too short. It must be higher than 30.</p>
14+
/// <p><paramref name="timeout" /> is too short. It must be higher than 30.</p>
1515
/// <p><paramref name="delayMilliseconds" /> is too short. It must be higher than 15.</p>
1616
/// </exception>
17-
/// <exception cref="T:System.ArgumentException"><paramref name="timeout" /> must is lower than <paramref name="delayMilliseconds" /></exception>
17+
/// <exception cref="T:System.ArgumentException">
18+
/// <paramref name="timeout" /> must is lower than
19+
/// <paramref name="delayMilliseconds" />
20+
/// </exception>
1821
public IClipboardOperationResult Open(IWindowsClipboardSession session, TimeSpan timeout,
1922
int delayMilliseconds = DefaultDelayMilliseconds)
2023
{
@@ -33,7 +36,8 @@ public IClipboardOperationResult Open(IWindowsClipboardSession session, TimeSpan
3336
return result ? ClipboardOperationResult.SuccessResult : GetErrorResult(errorCodes, counter);
3437
}
3538

36-
private static bool TryOpenSession(IWindowsClipboardSession session, ICollection<uint> errorCodes, ref int counter)
39+
private static bool TryOpenSession(IWindowsClipboardSession session, ICollection<uint> errorCodes,
40+
ref int counter)
3741
{
3842
counter++;
3943
var result = session.Open();
@@ -50,23 +54,25 @@ private static ClipboardOperationResult GetErrorResult(IEnumerable<uint> errorCo
5054
if (errors.Any())
5155
return GetResultForMultipleErrors(errors, counter);
5256
return new ClipboardOperationResult(
53-
resultCode: ClipboardOperationResultCode.ErrorOpenClipboard,
57+
resultCode: ClipboardOperationResultCode.ErrorOpenClipboard,
5458
message: $"Clipboard could not be opened after {counter} tries");
5559
}
5660

5761
private static ClipboardOperationResult GetResultForSingleError(uint error, int counter)
5862
{
5963
return new ClipboardOperationResult(
6064
resultCode: ClipboardOperationResultCode.ErrorOpenClipboard,
61-
message: $"Clipboard has been tried to be reached {counter} times and all of them returned {error} error code.",
65+
message:
66+
$"Clipboard has been tried to be reached {counter} times and all of them returned {error} error code.",
6267
errorCode: error);
6368
}
6469

6570
private static ClipboardOperationResult GetResultForMultipleErrors(IEnumerable<uint> errorList, int counter)
6671
{
6772
return new ClipboardOperationResult(
6873
resultCode: ClipboardOperationResultCode.ErrorOpenClipboard,
69-
message: $"Clipboard has been tried to be reached {counter} times and returned {errorList.Count()} unique errors.");
74+
message:
75+
$"Clipboard has been tried to be reached {counter} times and returned {errorList.Count()} unique errors.");
7076
}
7177
}
7278
}

0 commit comments

Comments
 (0)