Fixed a case where exceptions were thrown in the constructors. Fixes #482
- only dispose the list if the list was actually created - sign the tests so we can use InternalsVisibleTo - added a test to identify #482
This commit is contained in:
Родитель
7cd2ed9d62
Коммит
0b38873fee
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Resources;
|
using System.Resources;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
|
||||||
[assembly: AssemblyTitle("SkiaSharp")]
|
[assembly: AssemblyTitle("SkiaSharp")]
|
||||||
[assembly: AssemblyDescription("SkiaSharp is a cross-platform 2D graphics API for .NET platforms that can be used across mobile, server and desktop models to render images.")]
|
[assembly: AssemblyDescription("SkiaSharp is a cross-platform 2D graphics API for .NET platforms that can be used across mobile, server and desktop models to render images.")]
|
||||||
|
@ -14,3 +15,10 @@ using System.Resources;
|
||||||
#else
|
#else
|
||||||
[assembly: AssemblyConfiguration("Release")]
|
[assembly: AssemblyConfiguration("Release")]
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
[assembly: InternalsVisibleTo("SkiaSharp.Tests, PublicKey=" +
|
||||||
|
"002400000480000094000000060200000024000052534131000400000100010079159977d2d03a" +
|
||||||
|
"8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c" +
|
||||||
|
"3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fd" +
|
||||||
|
"dafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef00" +
|
||||||
|
"65d016df")]
|
||||||
|
|
|
@ -60,6 +60,8 @@ namespace SkiaSharp
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Dispose(bool disposing)
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (ownedObjects != null)
|
||||||
{
|
{
|
||||||
lock (ownedObjects)
|
lock (ownedObjects)
|
||||||
{
|
{
|
||||||
|
@ -69,6 +71,7 @@ namespace SkiaSharp
|
||||||
}
|
}
|
||||||
ownedObjects.Clear();
|
ownedObjects.Clear();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var zero = DeregisterHandle(Handle, this);
|
var zero = DeregisterHandle(Handle, this);
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@
|
||||||
Generate the assembly versioning attributes.
|
Generate the assembly versioning attributes.
|
||||||
===================================================================================================================
|
===================================================================================================================
|
||||||
-->
|
-->
|
||||||
<Target Name="_GenerateAssemblyVersionInfo" BeforeTargets="CoreCompile">
|
<Target Name="_GenerateAssemblyVersionInfo" BeforeTargets="CoreCompile" Condition=" '$(SkipGenerateAssemblyVersionInfo)' != 'true' ">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<_VersionSourceFile>$(IntermediateOutputPath)\$(AssemblyName).Version.cs</_VersionSourceFile>
|
<_VersionSourceFile>$(IntermediateOutputPath)\$(AssemblyName).Version.cs</_VersionSourceFile>
|
||||||
<_VersionTxtFile>$(MSBuildThisFileDirectory)..\VERSIONS.txt</_VersionTxtFile>
|
<_VersionTxtFile>$(MSBuildThisFileDirectory)..\VERSIONS.txt</_VersionTxtFile>
|
||||||
|
@ -90,7 +90,7 @@
|
||||||
Copy the project output into the root output folder.
|
Copy the project output into the root output folder.
|
||||||
===================================================================================================================
|
===================================================================================================================
|
||||||
-->
|
-->
|
||||||
<Target Name="_CopyToOutputDirectory" AfterTargets="Build">
|
<Target Name="_CopyToOutputDirectory" AfterTargets="Build" Condition=" '$(SkipCopyToOutputDirectory)' != 'true' ">
|
||||||
<ItemGroup Condition=" '$(PackagingLocation)' == '' ">
|
<ItemGroup Condition=" '$(PackagingLocation)' == '' ">
|
||||||
<_CopyItems Include="$(TargetPath)" Dest="nuget\lib\$(PackagingPlatform)\$(TargetFileName)" />
|
<_CopyItems Include="$(TargetPath)" Dest="nuget\lib\$(PackagingPlatform)\$(TargetFileName)" />
|
||||||
<_CopyItems Include="$(TargetDir)$(TargetName).xml" Dest="nuget\lib\$(PackagingPlatform)\$(TargetName).xml" Condition=" Exists('$(TargetDir)$(TargetName).xml') " />
|
<_CopyItems Include="$(TargetDir)$(TargetName).xml" Dest="nuget\lib\$(PackagingPlatform)\$(TargetName).xml" Condition=" Exists('$(TargetDir)$(TargetName).xml') " />
|
||||||
|
@ -119,7 +119,7 @@
|
||||||
This runs during the build phase.
|
This runs during the build phase.
|
||||||
===================================================================================================================
|
===================================================================================================================
|
||||||
-->
|
-->
|
||||||
<Target Name="MDocGenerateDocs" AfterTargets="CoreCompile">
|
<Target Name="MDocGenerateDocs" AfterTargets="CoreCompile" Condition=" '$(SkipMDocGenerateDocs)' != 'true' ">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<MDocVersion Condition=" '%(Identity)' == 'mdoc' ">@(PackageReference -> '%(Version)')</MDocVersion>
|
<MDocVersion Condition=" '%(Identity)' == 'mdoc' ">@(PackageReference -> '%(Version)')</MDocVersion>
|
||||||
<MDocPackagePath Condition=" '%(Name)' == 'mdoc' ">@(PackageDefinitions -> '%(ResolvedPath)')</MDocPackagePath>
|
<MDocPackagePath Condition=" '%(Name)' == 'mdoc' ">@(PackageDefinitions -> '%(ResolvedPath)')</MDocPackagePath>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="..\..\source\SkiaSharp.Build.props" />
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
@ -8,7 +9,10 @@
|
||||||
<RootNamespace>SkiaSharp.Tests</RootNamespace>
|
<RootNamespace>SkiaSharp.Tests</RootNamespace>
|
||||||
<AssemblyName>SkiaSharp.Tests</AssemblyName>
|
<AssemblyName>SkiaSharp.Tests</AssemblyName>
|
||||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||||
<ShouldIncludeNativeSkiaSharp>True</ShouldIncludeNativeSkiaSharp>
|
<ShouldIncludeNativeSkiaSharp>true</ShouldIncludeNativeSkiaSharp>
|
||||||
|
<SkipGenerateAssemblyVersionInfo>true</SkipGenerateAssemblyVersionInfo>
|
||||||
|
<SkipMDocGenerateDocs>true</SkipMDocGenerateDocs>
|
||||||
|
<SkipCopyToOutputDirectory>true</SkipCopyToOutputDirectory>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
<DebugSymbols>true</DebugSymbols>
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
@ -121,7 +125,11 @@
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="..\..\output\SkiaSharp\nuget\build\net45\SkiaSharp.targets" Condition="Exists('..\..\output\SkiaSharp\nuget\build\net45\SkiaSharp.targets')" />
|
<Import Project="..\..\output\SkiaSharp\nuget\build\net45\SkiaSharp.targets" Condition="Exists('..\..\output\SkiaSharp\nuget\build\net45\SkiaSharp.targets')" />
|
||||||
<Import Project="..\..\output\HarfBuzzSharp\nuget\build\net45\HarfBuzzSharp.targets" Condition="Exists('..\..\output\HarfBuzzSharp\nuget\build\net45\HarfBuzzSharp.targets')" />
|
<Import Project="..\..\output\HarfBuzzSharp\nuget\build\net45\HarfBuzzSharp.targets" Condition="Exists('..\..\output\HarfBuzzSharp\nuget\build\net45\HarfBuzzSharp.targets')" />
|
||||||
|
<Import Project="..\..\source\SkiaSharp.Build.targets" />
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
</Project>
|
</Project>
|
|
@ -1,5 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
<Import Project="..\..\source\SkiaSharp.Build.props" />
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp2.0</TargetFramework>
|
<TargetFramework>netcoreapp2.0</TargetFramework>
|
||||||
<DefineConstants>$(DefineConstants);NET_STANDARD</DefineConstants>
|
<DefineConstants>$(DefineConstants);NET_STANDARD</DefineConstants>
|
||||||
|
@ -11,6 +12,9 @@
|
||||||
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
|
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
|
||||||
<RuntimeIdentifiers>win7-x64;win7-x86;osx.10.10-x64;osx.10.11-x64;ubuntu.14.04-x64;ubuntu.14.10-x64;ubuntu.16.04-x64;ubuntu.16.10-x64</RuntimeIdentifiers>
|
<RuntimeIdentifiers>win7-x64;win7-x86;osx.10.10-x64;osx.10.11-x64;ubuntu.14.04-x64;ubuntu.14.10-x64;ubuntu.16.04-x64;ubuntu.16.10-x64</RuntimeIdentifiers>
|
||||||
<RuntimeFrameworkVersion>2.0.0</RuntimeFrameworkVersion>
|
<RuntimeFrameworkVersion>2.0.0</RuntimeFrameworkVersion>
|
||||||
|
<SkipGenerateAssemblyVersionInfo>true</SkipGenerateAssemblyVersionInfo>
|
||||||
|
<SkipMDocGenerateDocs>true</SkipMDocGenerateDocs>
|
||||||
|
<SkipCopyToOutputDirectory>true</SkipCopyToOutputDirectory>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="xunit" Version="2.4.0-beta.1.build3958" />
|
<PackageReference Include="xunit" Version="2.4.0-beta.1.build3958" />
|
||||||
|
@ -36,4 +40,5 @@
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<Import Project="..\..\source\SkiaSharp.Build.targets" />
|
||||||
</Project>
|
</Project>
|
|
@ -136,5 +136,45 @@ namespace SkiaSharp.Tests
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[SkippableFact]
|
||||||
|
public void ExceptionsThrownInTheConstructorFailGracefully()
|
||||||
|
{
|
||||||
|
BrokenObject broken = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
broken = new BrokenObject();
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
broken?.Dispose();
|
||||||
|
broken = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// try and trigger the finalizer
|
||||||
|
GC.Collect();
|
||||||
|
GC.WaitForPendingFinalizers();
|
||||||
|
}
|
||||||
|
|
||||||
|
private class BrokenObject : SKObject
|
||||||
|
{
|
||||||
|
public BrokenObject()
|
||||||
|
: base(broken_native_method(), true)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private static IntPtr broken_native_method()
|
||||||
|
{
|
||||||
|
throw new Exception("BREAK!");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче