<commit_before>﻿#region -- License Terms --
//
// MessagePack for CLI
//
// Copyright (C) 2010 FUJIWARA, Yusuke
//
//    Licensed under the Apache License, Version 2.0 (the "License");
//    you may not use this file except in compliance with the License.
//    You may obtain a copy of the License at
//
//        http://www.apache.org/licenses/LICENSE-2.0
//
//    Unless required by applicable law or agreed to in writing, software
//    distributed under the License is distributed on an "AS IS" BASIS,
//    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//    See the License for the specific language governing permissions and
//    limitations under the License.
//
#endregion -- License Terms --

using System;
using System.ComponentModel;
using System.Diagnostics.Contracts;
using System.Net;
using System.Net.NetworkInformation;
using System.Net.Sockets;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Security;

namespace MsgPack.Rpc
{
#if !NET_4_5
	internal sealed class ExceptionDispatchInfo
	{
		private static readonly Type[] _constructorParameterStringException = new[] { typeof( string ), typeof( Exception ) };
		private static readonly PropertyInfo _exceptionHResultProperty = typeof( Exception ).GetProperty( "HResult", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance );
		private static readonly MethodInfo _safeCreateMatroshikaMethod = typeof( ExceptionDispatchInfo ).GetMethod( "SafeCreateMatroshika", BindingFlags.Static | BindingFlags.NonPublic );
		private static readonly MethodInfo _safeCreateWrapperWin32ExceptionMethod = typeof( ExceptionDispatchInfo ).GetMethod( "SafeCreateWrapperWin32Exception", BindingFlags.Static | BindingFlags.NonPublic );

		private readonly Exception _source;

		private ExceptionDispatchInfo( Exception source )
		{
			if ( source == null )
			{
				throw new ArgumentNullException( "source" );
			}

			this._source = source;
		}

		public void Throw()
		{
			throw CreateMatroshika( this._source );
		}

		internal static Exception CreateMatroshika( Exception inner )
		{
			Contract.Requires( inner != null );
			Contract.Ensures( Contract.Result<Exception>() != null );

			Exception result = HandleKnownWin32Exception( inner );
			if ( result != null )
			{<commit_msg>Add contracts.<commit_after>﻿#region -- License Terms --
//
// MessagePack for CLI
//
// Copyright (C) 2010 FUJIWARA, Yusuke
//
//    Licensed under the Apache License, Version 2.0 (the "License");
//    you may not use this file except in compliance with the License.
//    You may obtain a copy of the License at
//
//        http://www.apache.org/licenses/LICENSE-2.0
//
//    Unless required by applicable law or agreed to in writing, software
//    distributed under the License is distributed on an "AS IS" BASIS,
//    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//    See the License for the specific language governing permissions and
//    limitations under the License.
//
#endregion -- License Terms --

using System;
using System.ComponentModel;
using System.Diagnostics.Contracts;
using System.Net;
using System.Net.NetworkInformation;
using System.Net.Sockets;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Security;

namespace MsgPack.Rpc
{
#if !NET_4_5
	internal sealed class ExceptionDispatchInfo
	{
		private static readonly Type[] _constructorParameterStringException = new[] { typeof( string ), typeof( Exception ) };
		private static readonly PropertyInfo _exceptionHResultProperty = typeof( Exception ).GetProperty( "HResult", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance );
		private static readonly MethodInfo _safeCreateMatroshikaMethod = typeof( ExceptionDispatchInfo ).GetMethod( "SafeCreateMatroshika", BindingFlags.Static | BindingFlags.NonPublic );
		private static readonly MethodInfo _safeCreateWrapperWin32ExceptionMethod = typeof( ExceptionDispatchInfo ).GetMethod( "SafeCreateWrapperWin32Exception", BindingFlags.Static | BindingFlags.NonPublic );

		private readonly Exception _source;

		private ExceptionDispatchInfo( Exception source )
		{
			if ( source == null )
			{
				throw new ArgumentNullException( "source" );
			}

			Contract.EndContractBlock();

			this._source = source;

		[ContractInvariantMethod]
		private void ObjectInvariant()
		{
			Contract.Invariant( this._source != null );
		}

		public void Throw()
		{
			throw CreateMatroshika( this._source );
		}

		internal static Exception CreateMatroshika( Exception inner )
		{
			Contract.Requires( inner != null );
			Contract.Ensures( Contract.Result<Exception>() != null );

			Exception result = HandleKnownWin32Exception( inner );
			if ( result != null )
			{
{'fraction_non_alphanumeric': 0.09216880117572958, 'fraction_numerical': 0.006718454755406256, 'mean_word_length': 4.1280947255113025, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '967972', 'n_tokens_mistral': 1355, 'n_tokens_neox': 1237, 'n_words': 417}