Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit aaf99f8

Browse files
jkotassafern
authored andcommitted
Move a few more files to shared CoreLib partition
Signed-off-by: dotnet-bot-corefx-mirror <dotnet-bot@microsoft.com>
1 parent 1ae42a8 commit aaf99f8

File tree

8 files changed

+1086
-2
lines changed

8 files changed

+1086
-2
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using System;
6+
using System.Runtime.InteropServices;
7+
8+
namespace Microsoft.Win32.SafeHandles
9+
{
10+
// Class of safe handle which uses only -1 as an invalid handle.
11+
public abstract class SafeHandleMinusOneIsInvalid : SafeHandle
12+
{
13+
protected SafeHandleMinusOneIsInvalid(bool ownsHandle) : base(new IntPtr(-1), ownsHandle)
14+
{
15+
}
16+
17+
public override bool IsInvalid => handle == new IntPtr(-1);
18+
}
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using System;
6+
using System.Runtime.InteropServices;
7+
8+
namespace Microsoft.Win32.SafeHandles
9+
{
10+
// Class of safe handle which uses 0 or -1 as an invalid handle.
11+
public abstract class SafeHandleZeroOrMinusOneIsInvalid : SafeHandle
12+
{
13+
protected SafeHandleZeroOrMinusOneIsInvalid(bool ownsHandle) : base(IntPtr.Zero, ownsHandle)
14+
{
15+
}
16+
17+
public override bool IsInvalid => handle == IntPtr.Zero || handle == new IntPtr(-1);
18+
}
19+
}

src/Common/src/CoreLib/System.Private.CoreLib.Shared.projitems

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,21 @@
1616
<ItemGroup>
1717
<Compile Include="$(MSBuildThisFileDirectory)Microsoft\Win32\SafeHandles\CriticalHandleMinusOneIsInvalid.cs"/>
1818
<Compile Include="$(MSBuildThisFileDirectory)Microsoft\Win32\SafeHandles\CriticalHandleZeroOrMinusOneIsInvalid.cs"/>
19+
<Compile Include="$(MSBuildThisFileDirectory)Microsoft\Win32\SafeHandles\SafeHandleMinusOneIsInvalid.cs"/>
20+
<Compile Include="$(MSBuildThisFileDirectory)Microsoft\Win32\SafeHandles\SafeHandleZeroOrMinusOneIsInvalid.cs"/>
1921
<Compile Include="$(MSBuildThisFileDirectory)System\Action.cs"/>
2022
<Compile Include="$(MSBuildThisFileDirectory)System\ApplicationException.cs"/>
2123
<Compile Include="$(MSBuildThisFileDirectory)System\ArgumentException.cs"/>
2224
<Compile Include="$(MSBuildThisFileDirectory)System\ArgumentNullException.cs"/>
25+
<Compile Include="$(MSBuildThisFileDirectory)System\ArgumentOutOfRangeException.cs"/>
2326
<Compile Include="$(MSBuildThisFileDirectory)System\ArithmeticException.cs"/>
2427
<Compile Include="$(MSBuildThisFileDirectory)System\ArrayTypeMismatchException.cs"/>
2528
<Compile Include="$(MSBuildThisFileDirectory)System\AssemblyLoadEventArgs.cs" />
2629
<Compile Include="$(MSBuildThisFileDirectory)System\AssemblyLoadEventHandler.cs" />
2730
<Compile Include="$(MSBuildThisFileDirectory)System\AsyncCallback.cs"/>
2831
<Compile Include="$(MSBuildThisFileDirectory)System\AttributeTargets.cs"/>
2932
<Compile Include="$(MSBuildThisFileDirectory)System\AttributeUsageAttribute.cs"/>
33+
<Compile Include="$(MSBuildThisFileDirectory)System\BadImageFormatException.cs"/>
3034
<Compile Include="$(MSBuildThisFileDirectory)System\Buffers\ArrayPool.cs"/>
3135
<Compile Include="$(MSBuildThisFileDirectory)System\Buffers\ConfigurableArrayPool.cs"/>
3236
<Compile Include="$(MSBuildThisFileDirectory)System\Buffers\TlsOverPerCoreLockedStacksArrayPool.cs"/>
@@ -253,7 +257,10 @@
253257
<Compile Include="$(MSBuildThisFileDirectory)System\Resources\MissingManifestResourceException.cs"/>
254258
<Compile Include="$(MSBuildThisFileDirectory)System\Resources\MissingSatelliteAssemblyException.cs"/>
255259
<Compile Include="$(MSBuildThisFileDirectory)System\Resources\NeutralResourcesLanguageAttribute.cs"/>
260+
<Compile Include="$(MSBuildThisFileDirectory)System\Resources\ResourceFallbackManager.cs"/>
261+
<Compile Include="$(MSBuildThisFileDirectory)System\Resources\ResourceSet.cs"/>
256262
<Compile Include="$(MSBuildThisFileDirectory)System\Resources\ResourceTypeCode.cs"/>
263+
<Compile Include="$(MSBuildThisFileDirectory)System\Resources\RuntimeResourceSet.cs"/>
257264
<Compile Include="$(MSBuildThisFileDirectory)System\Resources\SatelliteContractVersionAttribute.cs"/>
258265
<Compile Include="$(MSBuildThisFileDirectory)System\Resources\UltimateResourceFallbackLocation.cs"/>
259266
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\AccessedThroughPropertyAttribute.cs"/>
@@ -275,8 +282,8 @@
275282
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\FormattableStringFactory.cs"/>
276283
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\IAsyncStateMachine.cs"/>
277284
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\IndexerNameAttribute.cs"/>
278-
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\InternalsVisibleToAttribute.cs"/>
279285
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\INotifyCompletion.cs"/>
286+
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\InternalsVisibleToAttribute.cs"/>
280287
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\IsConst.cs"/>
281288
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\IsVolatile.cs"/>
282289
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\IteratorStateMachineAttribute.cs"/>
@@ -355,9 +362,9 @@
355362
<Compile Include="$(MSBuildThisFileDirectory)System\Text\EncodingProvider.cs"/>
356363
<Compile Include="$(MSBuildThisFileDirectory)System\Text\Normalization.cs"/>
357364
<Compile Include="$(MSBuildThisFileDirectory)System\Text\StringBuilder.cs"/>
365+
<Compile Include="$(MSBuildThisFileDirectory)System\Text\UnicodeEncoding.cs"/>
358366
<Compile Include="$(MSBuildThisFileDirectory)System\Text\UTF32Encoding.cs"/>
359367
<Compile Include="$(MSBuildThisFileDirectory)System\Text\UTF8Encoding.cs"/>
360-
<Compile Include="$(MSBuildThisFileDirectory)System\Text\UnicodeEncoding.cs"/>
361368
<Compile Include="$(MSBuildThisFileDirectory)System\ThreadAttributes.cs"/>
362369
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\AbandonedMutexException.cs"/>
363370
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\ApartmentState.cs"/>
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
/*=============================================================================
6+
**
7+
**
8+
**
9+
** Purpose: Exception class for method arguments outside of the legal range.
10+
**
11+
**
12+
=============================================================================*/
13+
14+
using System.Globalization;
15+
using System.Runtime.Serialization;
16+
17+
namespace System
18+
{
19+
// The ArgumentOutOfRangeException is thrown when an argument
20+
// is outside the legal range for that argument.
21+
[Serializable]
22+
public class ArgumentOutOfRangeException : ArgumentException
23+
{
24+
private Object _actualValue;
25+
26+
// Creates a new ArgumentOutOfRangeException with its message
27+
// string set to a default message explaining an argument was out of range.
28+
public ArgumentOutOfRangeException()
29+
: base(SR.Arg_ArgumentOutOfRangeException)
30+
{
31+
HResult = __HResults.COR_E_ARGUMENTOUTOFRANGE;
32+
}
33+
34+
public ArgumentOutOfRangeException(String paramName)
35+
: base(SR.Arg_ArgumentOutOfRangeException, paramName)
36+
{
37+
HResult = __HResults.COR_E_ARGUMENTOUTOFRANGE;
38+
}
39+
40+
public ArgumentOutOfRangeException(String paramName, String message)
41+
: base(message, paramName)
42+
{
43+
HResult = __HResults.COR_E_ARGUMENTOUTOFRANGE;
44+
}
45+
46+
public ArgumentOutOfRangeException(String message, Exception innerException)
47+
: base(message, innerException)
48+
{
49+
HResult = __HResults.COR_E_ARGUMENTOUTOFRANGE;
50+
}
51+
52+
// We will not use this in the classlibs, but we'll provide it for
53+
// anyone that's really interested so they don't have to stick a bunch
54+
// of printf's in their code.
55+
public ArgumentOutOfRangeException(String paramName, Object actualValue, String message)
56+
: base(message, paramName)
57+
{
58+
_actualValue = actualValue;
59+
HResult = __HResults.COR_E_ARGUMENTOUTOFRANGE;
60+
}
61+
62+
protected ArgumentOutOfRangeException(SerializationInfo info, StreamingContext context)
63+
: base(info, context)
64+
{
65+
_actualValue = info.GetValue("ActualValue", typeof(Object));
66+
}
67+
68+
public override void GetObjectData(SerializationInfo info, StreamingContext context)
69+
{
70+
base.GetObjectData(info, context);
71+
info.AddValue("ActualValue", _actualValue, typeof(Object));
72+
}
73+
74+
public override String Message
75+
{
76+
get
77+
{
78+
String s = base.Message;
79+
if (_actualValue != null)
80+
{
81+
String valueMessage = SR.Format(SR.ArgumentOutOfRange_ActualValue, _actualValue.ToString());
82+
if (s == null)
83+
return valueMessage;
84+
return s + Environment.NewLine + valueMessage;
85+
}
86+
return s;
87+
}
88+
}
89+
90+
// Gets the value of the argument that caused the exception.
91+
// Note - we don't set this anywhere in the class libraries in
92+
// version 1, but it might come in handy for other developers who
93+
// want to avoid sticking printf's in their code.
94+
public virtual Object ActualValue
95+
{
96+
get { return _actualValue; }
97+
}
98+
}
99+
}
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
/*============================================================
6+
**
7+
**
8+
**
9+
** Purpose: Exception to an invalid dll or executable format.
10+
**
11+
**
12+
===========================================================*/
13+
14+
using System.Globalization;
15+
using System.IO;
16+
using System.Runtime.Serialization;
17+
18+
namespace System
19+
{
20+
[Serializable]
21+
public class BadImageFormatException : SystemException
22+
{
23+
private String _fileName; // The name of the corrupt PE file.
24+
private String _fusionLog; // fusion log (when applicable)
25+
26+
public BadImageFormatException()
27+
: base(SR.Arg_BadImageFormatException)
28+
{
29+
HResult = __HResults.COR_E_BADIMAGEFORMAT;
30+
}
31+
32+
public BadImageFormatException(String message)
33+
: base(message)
34+
{
35+
HResult = __HResults.COR_E_BADIMAGEFORMAT;
36+
}
37+
38+
public BadImageFormatException(String message, Exception inner)
39+
: base(message, inner)
40+
{
41+
HResult = __HResults.COR_E_BADIMAGEFORMAT;
42+
}
43+
44+
public BadImageFormatException(String message, String fileName) : base(message)
45+
{
46+
HResult = __HResults.COR_E_BADIMAGEFORMAT;
47+
_fileName = fileName;
48+
}
49+
50+
public BadImageFormatException(String message, String fileName, Exception inner)
51+
: base(message, inner)
52+
{
53+
HResult = __HResults.COR_E_BADIMAGEFORMAT;
54+
_fileName = fileName;
55+
}
56+
57+
protected BadImageFormatException(SerializationInfo info, StreamingContext context)
58+
: base(info, context)
59+
{
60+
_fileName = info.GetString("BadImageFormat_FileName");
61+
_fusionLog = info.GetString("BadImageFormat_FusionLog");
62+
}
63+
64+
public override void GetObjectData(SerializationInfo info, StreamingContext context)
65+
{
66+
base.GetObjectData(info, context);
67+
68+
info.AddValue("BadImageFormat_FileName", _fileName, typeof(String));
69+
info.AddValue("BadImageFormat_FusionLog", _fusionLog, typeof(String));
70+
}
71+
72+
public override String Message
73+
{
74+
get
75+
{
76+
SetMessageField();
77+
return _message;
78+
}
79+
}
80+
81+
private void SetMessageField()
82+
{
83+
if (_message == null)
84+
{
85+
if ((_fileName == null) &&
86+
(HResult == __HResults.COR_E_EXCEPTION))
87+
_message = SR.Arg_BadImageFormatException;
88+
89+
else
90+
_message = FileLoadException.FormatFileLoadExceptionMessage(_fileName, HResult);
91+
}
92+
}
93+
94+
public String FileName
95+
{
96+
get { return _fileName; }
97+
}
98+
99+
public override String ToString()
100+
{
101+
String s = GetType().ToString() + ": " + Message;
102+
103+
if (_fileName != null && _fileName.Length != 0)
104+
s += Environment.NewLine + SR.Format(SR.IO_FileName_Name, _fileName);
105+
106+
if (InnerException != null)
107+
s = s + " ---> " + InnerException.ToString();
108+
109+
if (StackTrace != null)
110+
s += Environment.NewLine + StackTrace;
111+
112+
if (_fusionLog != null)
113+
{
114+
if (s == null)
115+
s = " ";
116+
s += Environment.NewLine;
117+
s += Environment.NewLine;
118+
s += _fusionLog;
119+
}
120+
121+
return s;
122+
}
123+
124+
public String FusionLog
125+
{
126+
get { return _fusionLog; }
127+
}
128+
}
129+
}

0 commit comments

Comments
 (0)