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

Commit b2c6ab7

Browse files
author
John Chen (CLR)
committed
Enable PInvoke analyzer for S.P.CoreLib.dll
1 parent 97b9927 commit b2c6ab7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+229
-289
lines changed

BuildToolsVersion.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0.27-prerelease-01205-03
1+
1.0.27-prerelease-01209-01

src/mscorlib/System.Private.CoreLib.csproj

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,14 @@
205205
</EmbeddedResource>
206206
</ItemGroup>
207207

208-
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.Targets" />
208+
<PropertyGroup Condition="'$(BuildOS)' == 'Windows_NT'">
209+
<EnableDotnetAnalyzers Condition="'$(EnableDotnetAnalyzers)'==''">true</EnableDotnetAnalyzers>
210+
<UseWin32Apis>true</UseWin32Apis>
211+
<OSGroup>Windows_NT</OSGroup>
212+
</PropertyGroup>
213+
<Import Project="$(ToolsDir)\codeAnalysis.targets" />
214+
215+
<Import Project="$(ToolsDir)\Microsoft.CSharp.Targets" />
209216

210217
<PropertyGroup>
211218
<StrongNameSig>Silverlight</StrongNameSig>
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
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+
internal partial class Interop
6+
{
7+
internal partial class Errors
8+
{
9+
internal const int ERROR_SUCCESS = 0x0;
10+
internal const int ERROR_INVALID_FUNCTION = 0x1;
11+
internal const int ERROR_FILE_NOT_FOUND = 0x2;
12+
internal const int ERROR_PATH_NOT_FOUND = 0x3;
13+
internal const int ERROR_ACCESS_DENIED = 0x5;
14+
internal const int ERROR_INVALID_HANDLE = 0x6;
15+
internal const int ERROR_NOT_ENOUGH_MEMORY = 0x8;
16+
internal const int ERROR_INVALID_DATA = 0xD;
17+
internal const int ERROR_INVALID_DRIVE = 0xF;
18+
internal const int ERROR_NO_MORE_FILES = 0x12;
19+
internal const int ERROR_NOT_READY = 0x15;
20+
internal const int ERROR_BAD_LENGTH = 0x18;
21+
internal const int ERROR_SHARING_VIOLATION = 0x20;
22+
internal const int ERROR_LOCK_VIOLATION = 0x21;
23+
internal const int ERROR_HANDLE_EOF = 0x26;
24+
internal const int ERROR_FILE_EXISTS = 0x50;
25+
internal const int ERROR_INVALID_PARAMETER = 0x57;
26+
internal const int ERROR_BROKEN_PIPE = 0x6D;
27+
internal const int ERROR_INSUFFICIENT_BUFFER = 0x7A;
28+
internal const int ERROR_INVALID_NAME = 0x7B;
29+
internal const int ERROR_NEGATIVE_SEEK = 0x83;
30+
internal const int ERROR_DIR_NOT_EMPTY = 0x91;
31+
internal const int ERROR_BAD_PATHNAME = 0xA1;
32+
internal const int ERROR_LOCK_FAILED = 0xA7;
33+
internal const int ERROR_BUSY = 0xAA;
34+
internal const int ERROR_ALREADY_EXISTS = 0xB7;
35+
internal const int ERROR_BAD_EXE_FORMAT = 0xC1;
36+
internal const int ERROR_ENVVAR_NOT_FOUND = 0xCB;
37+
internal const int ERROR_FILENAME_EXCED_RANGE = 0xCE;
38+
internal const int ERROR_EXE_MACHINE_TYPE_MISMATCH = 0xD8;
39+
internal const int ERROR_PIPE_BUSY = 0xE7;
40+
internal const int ERROR_NO_DATA = 0xE8;
41+
internal const int ERROR_PIPE_NOT_CONNECTED = 0xE9;
42+
internal const int ERROR_MORE_DATA = 0xEA;
43+
internal const int ERROR_NO_MORE_ITEMS = 0x103;
44+
internal const int ERROR_PARTIAL_COPY = 0x12B;
45+
internal const int ERROR_ARITHMETIC_OVERFLOW = 0x216;
46+
internal const int ERROR_PIPE_CONNECTED = 0x217;
47+
internal const int ERROR_PIPE_LISTENING = 0x218;
48+
internal const int ERROR_OPERATION_ABORTED = 0x3E3;
49+
internal const int ERROR_IO_PENDING = 0x3E5;
50+
internal const int ERROR_NO_TOKEN = 0x3f0;
51+
internal const int ERROR_DLL_INIT_FAILED = 0x45A;
52+
internal const int ERROR_NOT_FOUND = 0x490;
53+
internal const int ERROR_NON_ACCOUNT_SID = 0x4E9;
54+
internal const int ERROR_NOT_ALL_ASSIGNED = 0x514;
55+
internal const int ERROR_UNKNOWN_REVISION = 0x519;
56+
internal const int ERROR_INVALID_OWNER = 0x51B;
57+
internal const int ERROR_INVALID_PRIMARY_GROUP = 0x51C;
58+
internal const int ERROR_NO_SUCH_PRIVILEGE = 0x521;
59+
internal const int ERROR_PRIVILEGE_NOT_HELD = 0x522;
60+
internal const int ERROR_INVALID_ACL = 0x538;
61+
internal const int ERROR_INVALID_SECURITY_DESCR = 0x53A;
62+
internal const int ERROR_INVALID_SID = 0x539;
63+
internal const int ERROR_BAD_IMPERSONATION_LEVEL = 0x542;
64+
internal const int ERROR_CANT_OPEN_ANONYMOUS = 0x543;
65+
internal const int ERROR_NO_SECURITY_ON_OBJECT = 0x546;
66+
internal const int ERROR_TRUSTED_RELATIONSHIP_FAILURE = 0x6FD;
67+
internal const int ERROR_RESOURCE_LANG_NOT_FOUND = 0x717;
68+
internal const int EFail = unchecked((int)0x80004005);
69+
internal const int E_FILENOTFOUND = unchecked((int)0x80070002);
70+
}
71+
}

src/mscorlib/corefx/Interop/Windows/mincore/Interop.CancelIoEx.cs renamed to src/mscorlib/corefx/Interop/Windows/kernel32/Interop.CancelIoEx.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
internal partial class Interop
1010
{
11-
internal partial class mincore
11+
internal partial class Kernel32
1212
{
13-
[DllImport(Libraries.IO, SetLastError = true)]
14-
internal static unsafe extern bool CancelIoEx(SafeHandle handle, NativeOverlapped* lpOverlapped);
13+
[DllImport(Libraries.Kernel32, SetLastError = true)]
14+
internal static extern unsafe bool CancelIoEx(SafeHandle handle, NativeOverlapped* lpOverlapped);
1515
}
1616
}

src/mscorlib/corefx/Interop/Windows/mincore/Interop.CloseHandle.cs renamed to src/mscorlib/corefx/Interop/Windows/kernel32/Interop.CloseHandle.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77

88
internal partial class Interop
99
{
10-
internal partial class mincore
10+
internal partial class Kernel32
1111
{
12-
[DllImport(Libraries.Handle, SetLastError = true)]
12+
[DllImport(Libraries.Kernel32, SetLastError = true)]
1313
[return: MarshalAs(UnmanagedType.Bool)]
1414
internal static extern bool CloseHandle(IntPtr handle);
1515
}

src/mscorlib/corefx/Interop/Windows/mincore/Interop.CreateFile.cs renamed to src/mscorlib/corefx/Interop/Windows/kernel32/Interop.CreateFile.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99

1010
internal partial class Interop
1111
{
12-
internal partial class mincore
12+
internal partial class Kernel32
1313
{
1414
/// <summary>
1515
/// WARNING: This method does not implicitly handle long paths. Use CreateFile.
1616
/// </summary>
17-
[DllImport(Libraries.CoreFile_L1, EntryPoint = "CreateFileW", SetLastError = true, CharSet = CharSet.Unicode, BestFitMapping = false)]
17+
[DllImport(Libraries.Kernel32, EntryPoint = "CreateFileW", SetLastError = true, CharSet = CharSet.Unicode, BestFitMapping = false)]
1818
private static extern SafeFileHandle CreateFilePrivate(
1919
string lpFileName,
2020
int dwDesiredAccess,

src/mscorlib/corefx/Interop/Windows/mincore/Interop.FileOperations.cs renamed to src/mscorlib/corefx/Interop/Windows/kernel32/Interop.FileOperations.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
internal partial class Interop
66
{
7-
internal partial class mincore
7+
internal partial class Kernel32
88
{
99
internal partial class IOReparseOptions
1010
{

src/mscorlib/corefx/Interop/Windows/mincore/Interop.FileTypes.cs renamed to src/mscorlib/corefx/Interop/Windows/kernel32/Interop.FileTypes.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
internal partial class Interop
66
{
7-
internal partial class mincore
7+
internal partial class Kernel32
88
{
99
internal partial class FileTypes
1010
{

src/mscorlib/corefx/Interop/Windows/mincore/Interop.FlushFileBuffers.cs renamed to src/mscorlib/corefx/Interop/Windows/kernel32/Interop.FlushFileBuffers.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
internal partial class Interop
1010
{
11-
internal partial class mincore
11+
internal partial class Kernel32
1212
{
13-
[DllImport(Libraries.CoreFile_L1, SetLastError = true)]
13+
[DllImport(Libraries.Kernel32, SetLastError = true)]
1414
[return: MarshalAs(UnmanagedType.Bool)]
1515
internal static extern bool FlushFileBuffers(SafeHandle hHandle);
1616
}

src/mscorlib/corefx/Interop/Windows/mincore/Interop.FormatMessage.cs renamed to src/mscorlib/corefx/Interop/Windows/kernel32/Interop.FormatMessage.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
internal partial class Interop
1010
{
11-
internal partial class mincore
11+
internal partial class Kernel32
1212
{
1313
private const int FORMAT_MESSAGE_IGNORE_INSERTS = 0x00000200;
1414
private const int FORMAT_MESSAGE_FROM_HMODULE = 0x00000800;
@@ -18,7 +18,7 @@ internal partial class mincore
1818

1919
private const int ERROR_INSUFFICIENT_BUFFER = 0x7A;
2020

21-
[DllImport(Libraries.Localization, CharSet = CharSet.Unicode, EntryPoint = "FormatMessageW", SetLastError = true, BestFitMapping = true)]
21+
[DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, EntryPoint = "FormatMessageW", SetLastError = true, BestFitMapping = true)]
2222
private static extern int FormatMessage(
2323
int dwFlags,
2424
IntPtr lpSource,

0 commit comments

Comments
 (0)