akaaafk commited on
Commit
3edc4ff
·
verified ·
1 Parent(s): b8d8c1a

Add files using upload-large-folder tool

Browse files
Files changed (20) hide show
  1. benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.ide.visualstudio@2.0.7/Editor/Messaging/MessageType.cs +48 -0
  2. benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.ide.visualstudio@2.0.7/Editor/Messaging/MessageType.cs.meta +11 -0
  3. benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.ide.visualstudio@2.0.7/Editor/Messaging/Messenger.cs +220 -0
  4. benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.ide.visualstudio@2.0.7/Editor/Messaging/Messenger.cs.meta +11 -0
  5. benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.ide.visualstudio@2.0.7/Editor/Messaging/Serializer.cs +43 -0
  6. benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.ide.visualstudio@2.0.7/Editor/Messaging/Serializer.cs.meta +11 -0
  7. benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.ide.visualstudio@2.0.7/Editor/Messaging/TcpClient.cs +93 -0
  8. benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.ide.visualstudio@2.0.7/Editor/Messaging/TcpClient.cs.meta +11 -0
  9. benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.ide.visualstudio@2.0.7/Editor/Messaging/TcpListener.cs +82 -0
  10. benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.ide.visualstudio@2.0.7/Editor/Messaging/TcpListener.cs.meta +11 -0
  11. benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.ide.visualstudio@2.0.7/Editor/Messaging/UdpSocket.cs +55 -0
  12. benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.ide.visualstudio@2.0.7/Editor/Messaging/UdpSocket.cs.meta +11 -0
  13. benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.ide.visualstudio@2.0.7/Editor/Plugins/.gitattributes +1 -0
  14. benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.ide.visualstudio@2.0.7/Editor/Plugins/AppleEventIntegration.bundle.meta +28 -0
  15. benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.ide.visualstudio@2.0.7/Editor/ProjectGeneration/AssemblyNameProvider.cs +190 -0
  16. benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.ide.visualstudio@2.0.7/Editor/ProjectGeneration/AssemblyNameProvider.cs.meta +11 -0
  17. benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.ide.visualstudio@2.0.7/Editor/ProjectGeneration/FileIOProvider.cs +36 -0
  18. benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.ide.visualstudio@2.0.7/Editor/ProjectGeneration/FileIOProvider.cs.meta +11 -0
  19. benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.ide.visualstudio@2.0.7/Editor/ProjectGeneration/GUIDProvider.cs +26 -0
  20. benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.ide.visualstudio@2.0.7/Editor/ProjectGeneration/GUIDProvider.cs.meta +11 -0
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.ide.visualstudio@2.0.7/Editor/Messaging/MessageType.cs ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License. See License.txt in the project root for license information.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ namespace Microsoft.Unity.VisualStudio.Editor.Messaging
6
+ {
7
+ internal enum MessageType
8
+ {
9
+ None = 0,
10
+
11
+ Ping,
12
+ Pong,
13
+
14
+ Play,
15
+ Stop,
16
+ Pause,
17
+ Unpause,
18
+
19
+ Build,
20
+ Refresh,
21
+
22
+ Info,
23
+ Error,
24
+ Warning,
25
+
26
+ Open,
27
+ Opened,
28
+
29
+ Version,
30
+ UpdatePackage,
31
+
32
+ ProjectPath,
33
+
34
+ // This message is a technical one for big messages, not intended to be used directly
35
+ Tcp,
36
+
37
+ RunStarted,
38
+ RunFinished,
39
+ TestStarted,
40
+ TestFinished,
41
+ TestListRetrieved,
42
+
43
+ RetrieveTestList,
44
+ ExecuteTests,
45
+
46
+ ShowUsage
47
+ }
48
+ }
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.ide.visualstudio@2.0.7/Editor/Messaging/MessageType.cs.meta ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ fileFormatVersion: 2
2
+ guid: f3edbdc86577af648a23263aa75161e1
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.ide.visualstudio@2.0.7/Editor/Messaging/Messenger.cs ADDED
@@ -0,0 +1,220 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License. See License.txt in the project root for license information.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ using System;
6
+ using System.Net;
7
+ using System.Net.Sockets;
8
+
9
+ namespace Microsoft.Unity.VisualStudio.Editor.Messaging
10
+ {
11
+ internal class Messager : IDisposable
12
+ {
13
+ public event EventHandler<MessageEventArgs> ReceiveMessage;
14
+ public event EventHandler<ExceptionEventArgs> MessagerException;
15
+
16
+ private readonly UdpSocket _socket;
17
+ private readonly object _disposeLock = new object();
18
+ private bool _disposed;
19
+
20
+ protected Messager(int port)
21
+ {
22
+ _socket = new UdpSocket();
23
+ _socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ExclusiveAddressUse, false);
24
+ _socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
25
+ _socket.Bind(IPAddress.Any, port);
26
+
27
+ BeginReceiveMessage();
28
+ }
29
+
30
+ private void BeginReceiveMessage()
31
+ {
32
+ var buffer = new byte[UdpSocket.BufferSize];
33
+ var any = UdpSocket.Any();
34
+
35
+ try
36
+ {
37
+ lock (_disposeLock)
38
+ {
39
+ if (_disposed)
40
+ return;
41
+
42
+ _socket.BeginReceiveFrom(buffer, 0, buffer.Length, SocketFlags.None, ref any, ReceiveMessageCallback, buffer);
43
+ }
44
+ }
45
+ catch (SocketException se)
46
+ {
47
+ MessagerException?.Invoke(this, new ExceptionEventArgs(se));
48
+
49
+ BeginReceiveMessage();
50
+ }
51
+ catch (ObjectDisposedException)
52
+ {
53
+ }
54
+ }
55
+
56
+ private void ReceiveMessageCallback(IAsyncResult result)
57
+ {
58
+ try
59
+ {
60
+ var endPoint = UdpSocket.Any();
61
+
62
+ lock (_disposeLock)
63
+ {
64
+ if (_disposed)
65
+ return;
66
+
67
+ _socket.EndReceiveFrom(result, ref endPoint);
68
+ }
69
+
70
+ var message = DeserializeMessage(UdpSocket.BufferFor(result));
71
+ if (message != null)
72
+ {
73
+ message.Origin = (IPEndPoint)endPoint;
74
+
75
+ int port;
76
+ int bufferSize;
77
+ if (IsValidTcpMessage(message, out port, out bufferSize))
78
+ {
79
+ // switch to TCP mode to handle big messages
80
+ TcpClient.Queue(message.Origin.Address, port, bufferSize, buffer =>
81
+ {
82
+ var originalMessage = DeserializeMessage(buffer);
83
+ originalMessage.Origin = message.Origin;
84
+ ReceiveMessage?.Invoke(this, new MessageEventArgs(originalMessage));
85
+ });
86
+ }
87
+ else
88
+ {
89
+ ReceiveMessage?.Invoke(this, new MessageEventArgs(message));
90
+ }
91
+ }
92
+ }
93
+ catch (ObjectDisposedException)
94
+ {
95
+ return;
96
+ }
97
+ catch (Exception e)
98
+ {
99
+ RaiseMessagerException(e);
100
+ }
101
+
102
+ BeginReceiveMessage();
103
+ }
104
+
105
+ private static bool IsValidTcpMessage(Message message, out int port, out int bufferSize)
106
+ {
107
+ port = 0;
108
+ bufferSize = 0;
109
+ if (message.Value == null)
110
+ return false;
111
+ if (message.Type != MessageType.Tcp)
112
+ return false;
113
+ var parts = message.Value.Split(':');
114
+ if (parts.Length != 2)
115
+ return false;
116
+ if (!int.TryParse(parts[0], out port))
117
+ return false;
118
+ return int.TryParse(parts[1], out bufferSize);
119
+ }
120
+
121
+ private void RaiseMessagerException(Exception e)
122
+ {
123
+ MessagerException?.Invoke(this, new ExceptionEventArgs(e));
124
+ }
125
+
126
+ private static Message MessageFor(MessageType type, string value)
127
+ {
128
+ return new Message { Type = type, Value = value };
129
+ }
130
+
131
+ public void SendMessage(IPEndPoint target, MessageType type, string value = "")
132
+ {
133
+ var message = MessageFor(type, value);
134
+ var buffer = SerializeMessage(message);
135
+
136
+ try
137
+ {
138
+ lock (_disposeLock)
139
+ {
140
+ if (_disposed)
141
+ return;
142
+
143
+ if (buffer.Length >= UdpSocket.BufferSize)
144
+ {
145
+ // switch to TCP mode to handle big messages
146
+ var port = TcpListener.Queue(buffer);
147
+ if (port > 0)
148
+ {
149
+ // success, replace original message with "switch to tcp" marker + port information + buffer length
150
+ message = MessageFor(MessageType.Tcp, string.Concat(port, ':', buffer.Length));
151
+ buffer = SerializeMessage(message);
152
+ }
153
+ }
154
+
155
+ _socket.BeginSendTo(buffer, 0, Math.Min(buffer.Length, UdpSocket.BufferSize), SocketFlags.None, target, SendMessageCallback, null);
156
+ }
157
+ }
158
+ catch (SocketException se)
159
+ {
160
+ MessagerException?.Invoke(this, new ExceptionEventArgs(se));
161
+ }
162
+ }
163
+
164
+ private void SendMessageCallback(IAsyncResult result)
165
+ {
166
+ try
167
+ {
168
+ lock (_disposeLock)
169
+ {
170
+ if (_disposed)
171
+ return;
172
+
173
+ _socket.EndSendTo(result);
174
+ }
175
+ }
176
+ catch (SocketException se)
177
+ {
178
+ MessagerException?.Invoke(this, new ExceptionEventArgs(se));
179
+ }
180
+ catch (ObjectDisposedException)
181
+ {
182
+ }
183
+ }
184
+
185
+ private static byte[] SerializeMessage(Message message)
186
+ {
187
+ var serializer = new Serializer();
188
+ serializer.WriteInt32((int)message.Type);
189
+ serializer.WriteString(message.Value);
190
+
191
+ return serializer.Buffer();
192
+ }
193
+
194
+ private static Message DeserializeMessage(byte[] buffer)
195
+ {
196
+ if (buffer.Length < 4)
197
+ return null;
198
+
199
+ var deserializer = new Deserializer(buffer);
200
+ var type = (MessageType)deserializer.ReadInt32();
201
+ var value = deserializer.ReadString();
202
+
203
+ return new Message { Type = type, Value = value };
204
+ }
205
+
206
+ public static Messager BindTo(int port)
207
+ {
208
+ return new Messager(port);
209
+ }
210
+
211
+ public void Dispose()
212
+ {
213
+ lock (_disposeLock)
214
+ {
215
+ _disposed = true;
216
+ _socket.Close();
217
+ }
218
+ }
219
+ }
220
+ }
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.ide.visualstudio@2.0.7/Editor/Messaging/Messenger.cs.meta ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ fileFormatVersion: 2
2
+ guid: 5e249ae353801f043a6e4173410c6152
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.ide.visualstudio@2.0.7/Editor/Messaging/Serializer.cs ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License. See License.txt in the project root for license information.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ using System.IO;
6
+ using System.Text;
7
+
8
+ namespace Microsoft.Unity.VisualStudio.Editor.Messaging
9
+ {
10
+ internal class Serializer
11
+ {
12
+ private readonly MemoryStream _stream;
13
+ private readonly BinaryWriter _writer;
14
+
15
+ public Serializer()
16
+ {
17
+ _stream = new MemoryStream();
18
+ _writer = new BinaryWriter(_stream);
19
+ }
20
+
21
+ public void WriteInt32(int i)
22
+ {
23
+ _writer.Write(i);
24
+ }
25
+
26
+ public void WriteString(string s)
27
+ {
28
+ var bytes = Encoding.UTF8.GetBytes(s ?? "");
29
+ if (bytes.Length > 0)
30
+ {
31
+ _writer.Write(bytes.Length);
32
+ _writer.Write(bytes);
33
+ }
34
+ else
35
+ _writer.Write(0);
36
+ }
37
+
38
+ public byte[] Buffer()
39
+ {
40
+ return _stream.ToArray();
41
+ }
42
+ }
43
+ }
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.ide.visualstudio@2.0.7/Editor/Messaging/Serializer.cs.meta ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ fileFormatVersion: 2
2
+ guid: 369c09afe05d2c346af49faef943c773
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.ide.visualstudio@2.0.7/Editor/Messaging/TcpClient.cs ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License. See License.txt in the project root for license information.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ using System;
6
+ using System.Net;
7
+ using System.Net.Sockets;
8
+ using System.Threading;
9
+
10
+ namespace Microsoft.Unity.VisualStudio.Editor.Messaging
11
+ {
12
+ internal class TcpClient
13
+ {
14
+ private const int ConnectOrReadTimeoutMilliseconds = 5000;
15
+
16
+ private class State
17
+ {
18
+ public System.Net.Sockets.TcpClient TcpClient;
19
+ public NetworkStream NetworkStream;
20
+ public byte[] Buffer;
21
+ public Action<byte[]> OnBufferAvailable;
22
+ }
23
+
24
+ public static void Queue(IPAddress address, int port, int bufferSize, Action<byte[]> onBufferAvailable)
25
+ {
26
+ var client = new System.Net.Sockets.TcpClient();
27
+ var state = new State {OnBufferAvailable = onBufferAvailable, TcpClient = client, Buffer = new byte[bufferSize]};
28
+
29
+ try
30
+ {
31
+ ThreadPool.QueueUserWorkItem(_ =>
32
+ {
33
+ var handle = client.BeginConnect(address, port, OnClientConnected, state);
34
+ if (!handle.AsyncWaitHandle.WaitOne(ConnectOrReadTimeoutMilliseconds))
35
+ Cleanup(state);
36
+ });
37
+ }
38
+ catch (Exception)
39
+ {
40
+ Cleanup(state);
41
+ }
42
+ }
43
+
44
+ private static void OnClientConnected(IAsyncResult result)
45
+ {
46
+ var state = (State)result.AsyncState;
47
+
48
+ try
49
+ {
50
+ state.TcpClient.EndConnect(result);
51
+ state.NetworkStream = state.TcpClient.GetStream();
52
+ var handle = state.NetworkStream.BeginRead(state.Buffer, 0, state.Buffer.Length, OnEndRead, state);
53
+ if (!handle.AsyncWaitHandle.WaitOne(ConnectOrReadTimeoutMilliseconds))
54
+ Cleanup(state);
55
+ }
56
+ catch (Exception)
57
+ {
58
+ Cleanup(state);
59
+ }
60
+ }
61
+
62
+ private static void OnEndRead(IAsyncResult result)
63
+ {
64
+ var state = (State)result.AsyncState;
65
+
66
+ try
67
+ {
68
+ var count = state.NetworkStream.EndRead(result);
69
+ if (count == state.Buffer.Length)
70
+ state.OnBufferAvailable?.Invoke(state.Buffer);
71
+ }
72
+ catch (Exception)
73
+ {
74
+ // Ignore and cleanup
75
+ }
76
+ finally
77
+ {
78
+ Cleanup(state);
79
+ }
80
+ }
81
+
82
+ private static void Cleanup(State state)
83
+ {
84
+ state.NetworkStream?.Dispose();
85
+ state.TcpClient?.Close();
86
+
87
+ state.NetworkStream = null;
88
+ state.TcpClient = null;
89
+ state.Buffer = null;
90
+ state.OnBufferAvailable = null;
91
+ }
92
+ }
93
+ }
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.ide.visualstudio@2.0.7/Editor/Messaging/TcpClient.cs.meta ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ fileFormatVersion: 2
2
+ guid: f6674c38820d12a49ac116d416521d85
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.ide.visualstudio@2.0.7/Editor/Messaging/TcpListener.cs ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License. See License.txt in the project root for license information.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ using System;
6
+ using System.Net;
7
+ using System.Threading;
8
+
9
+ namespace Microsoft.Unity.VisualStudio.Editor.Messaging
10
+ {
11
+ internal class TcpListener
12
+ {
13
+ private const int ListenTimeoutMilliseconds = 5000;
14
+
15
+ private class State
16
+ {
17
+ public System.Net.Sockets.TcpListener TcpListener;
18
+ public byte[] Buffer;
19
+ }
20
+
21
+ public static int Queue(byte[] buffer)
22
+ {
23
+ var tcpListener = new System.Net.Sockets.TcpListener(IPAddress.Any, 0);
24
+ var state = new State {Buffer = buffer, TcpListener = tcpListener};
25
+
26
+ try
27
+ {
28
+ tcpListener.Start();
29
+
30
+ int port = ((IPEndPoint)tcpListener.LocalEndpoint).Port;
31
+
32
+ ThreadPool.QueueUserWorkItem(_ =>
33
+ {
34
+ bool listening = true;
35
+
36
+ while (listening)
37
+ {
38
+ var handle = tcpListener.BeginAcceptTcpClient(OnIncomingConnection, state);
39
+ listening = handle.AsyncWaitHandle.WaitOne(ListenTimeoutMilliseconds);
40
+ }
41
+
42
+ Cleanup(state);
43
+ });
44
+
45
+ return port;
46
+ }
47
+ catch (Exception)
48
+ {
49
+ Cleanup(state);
50
+ return -1;
51
+ }
52
+ }
53
+
54
+ private static void OnIncomingConnection(IAsyncResult result)
55
+ {
56
+ var state = (State)result.AsyncState;
57
+
58
+ try
59
+ {
60
+ using (var client = state.TcpListener.EndAcceptTcpClient(result))
61
+ {
62
+ using (var stream = client.GetStream())
63
+ {
64
+ stream.Write(state.Buffer, 0, state.Buffer.Length);
65
+ }
66
+ }
67
+ }
68
+ catch (Exception)
69
+ {
70
+ // Ignore and cleanup
71
+ }
72
+ }
73
+
74
+ private static void Cleanup(State state)
75
+ {
76
+ state.TcpListener?.Stop();
77
+
78
+ state.TcpListener = null;
79
+ state.Buffer = null;
80
+ }
81
+ }
82
+ }
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.ide.visualstudio@2.0.7/Editor/Messaging/TcpListener.cs.meta ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ fileFormatVersion: 2
2
+ guid: ded625cf0d03fa94c9f939fd13ced18d
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.ide.visualstudio@2.0.7/Editor/Messaging/UdpSocket.cs ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License. See License.txt in the project root for license information.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ using System;
6
+ using System.Net;
7
+ using System.Net.Sockets;
8
+
9
+ namespace Microsoft.Unity.VisualStudio.Editor.Messaging
10
+ {
11
+ internal class UdpSocket : Socket
12
+ {
13
+ // Maximum UDP payload is 65507 bytes.
14
+ // TCP mode will be used when the payload is bigger than this BufferSize
15
+ public const int BufferSize = 1024 * 8;
16
+
17
+ internal UdpSocket()
18
+ : base(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp)
19
+ {
20
+ SetIOControl();
21
+ }
22
+
23
+ public void Bind(IPAddress address, int port = 0)
24
+ {
25
+ Bind(new IPEndPoint(address ?? IPAddress.Any, port));
26
+ }
27
+
28
+ private void SetIOControl()
29
+ {
30
+ if (!VisualStudioEditor.IsWindows)
31
+ return;
32
+
33
+ try
34
+ {
35
+ const int SIO_UDP_CONNRESET = -1744830452;
36
+
37
+ IOControl(SIO_UDP_CONNRESET, new byte[] { 0 }, new byte[0]);
38
+ }
39
+ catch
40
+ {
41
+ // fallback
42
+ }
43
+ }
44
+
45
+ public static byte[] BufferFor(IAsyncResult result)
46
+ {
47
+ return (byte[])result.AsyncState;
48
+ }
49
+
50
+ public static EndPoint Any()
51
+ {
52
+ return new IPEndPoint(IPAddress.Any, 0);
53
+ }
54
+ }
55
+ }
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.ide.visualstudio@2.0.7/Editor/Messaging/UdpSocket.cs.meta ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ fileFormatVersion: 2
2
+ guid: 38cb3a4a17d2cfd41926da95ce675934
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.ide.visualstudio@2.0.7/Editor/Plugins/.gitattributes ADDED
@@ -0,0 +1 @@
 
 
1
+ AppleEventIntegration.bundle/Contents/MacOS/AppleEventIntegration binary
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.ide.visualstudio@2.0.7/Editor/Plugins/AppleEventIntegration.bundle.meta ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ fileFormatVersion: 2
2
+ guid: a20df6e3467b24ed5b49c857ce39e096
3
+ folderAsset: yes
4
+ PluginImporter:
5
+ externalObjects: {}
6
+ serializedVersion: 2
7
+ iconMap: {}
8
+ executionOrder: {}
9
+ defineConstraints: []
10
+ isPreloaded: 0
11
+ isOverridable: 1
12
+ isExplicitlyReferenced: 0
13
+ validateReferences: 1
14
+ platformData:
15
+ - first:
16
+ Any:
17
+ second:
18
+ enabled: 0
19
+ settings: {}
20
+ - first:
21
+ Editor: Editor
22
+ second:
23
+ enabled: 1
24
+ settings:
25
+ DefaultValueInitialized: true
26
+ userData:
27
+ assetBundleName:
28
+ assetBundleVariant:
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.ide.visualstudio@2.0.7/Editor/ProjectGeneration/AssemblyNameProvider.cs ADDED
@@ -0,0 +1,190 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Unity Technologies.
3
+ * Copyright (c) Microsoft Corporation. All rights reserved.
4
+ * Licensed under the MIT License. See License.txt in the project root for license information.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ using System;
7
+ using System.Collections.Generic;
8
+ using System.Linq;
9
+ using UnityEditor;
10
+ using UnityEditor.Compilation;
11
+ using UnityEditor.PackageManager;
12
+
13
+ namespace Microsoft.Unity.VisualStudio.Editor
14
+ {
15
+ public interface IAssemblyNameProvider
16
+ {
17
+ string[] ProjectSupportedExtensions { get; }
18
+ string ProjectGenerationRootNamespace { get; }
19
+ ProjectGenerationFlag ProjectGenerationFlag { get; }
20
+
21
+ string GetAssemblyNameFromScriptPath(string path);
22
+ string GetAssemblyName(string assemblyOutputPath, string assemblyName);
23
+ bool IsInternalizedPackagePath(string path);
24
+ IEnumerable<Assembly> GetAssemblies(Func<string, bool> shouldFileBePartOfSolution);
25
+ IEnumerable<string> GetAllAssetPaths();
26
+ UnityEditor.PackageManager.PackageInfo FindForAssetPath(string assetPath);
27
+ ResponseFileData ParseResponseFile(string responseFilePath, string projectDirectory, string[] systemReferenceDirectories);
28
+ void ToggleProjectGeneration(ProjectGenerationFlag preference);
29
+ }
30
+
31
+ public class AssemblyNameProvider : IAssemblyNameProvider
32
+ {
33
+ ProjectGenerationFlag m_ProjectGenerationFlag = (ProjectGenerationFlag)EditorPrefs.GetInt(
34
+ "unity_project_generation_flag",
35
+ (int)(ProjectGenerationFlag.Local | ProjectGenerationFlag.Embedded));
36
+
37
+ public string[] ProjectSupportedExtensions => EditorSettings.projectGenerationUserExtensions;
38
+
39
+ public string ProjectGenerationRootNamespace => EditorSettings.projectGenerationRootNamespace;
40
+
41
+ public ProjectGenerationFlag ProjectGenerationFlag
42
+ {
43
+ get => m_ProjectGenerationFlag;
44
+ private set
45
+ {
46
+ EditorPrefs.SetInt("unity_project_generation_flag", (int)value);
47
+ m_ProjectGenerationFlag = value;
48
+ }
49
+ }
50
+
51
+ public string GetAssemblyNameFromScriptPath(string path)
52
+ {
53
+ return CompilationPipeline.GetAssemblyNameFromScriptPath(path);
54
+ }
55
+
56
+ public IEnumerable<Assembly> GetAssemblies(Func<string, bool> shouldFileBePartOfSolution)
57
+ {
58
+ foreach (var assembly in CompilationPipeline.GetAssemblies())
59
+ {
60
+ if (assembly.sourceFiles.Any(shouldFileBePartOfSolution))
61
+ {
62
+ var options = new ScriptCompilerOptions
63
+ {
64
+ ResponseFiles = assembly.compilerOptions.ResponseFiles,
65
+ AllowUnsafeCode = assembly.compilerOptions.AllowUnsafeCode,
66
+ ApiCompatibilityLevel = assembly.compilerOptions.ApiCompatibilityLevel
67
+ };
68
+
69
+ yield return new Assembly(assembly.name, @"Temp\Bin\Debug\",
70
+ assembly.sourceFiles, new[] { "DEBUG", "TRACE" }.Concat(assembly.defines).Concat(EditorUserBuildSettings.activeScriptCompilationDefines).ToArray(),
71
+ assembly.assemblyReferences,
72
+ assembly.compiledAssemblyReferences,
73
+ assembly.flags,
74
+ #if UNITY_2020_2_OR_NEWER
75
+ options,
76
+ assembly.rootNamespace);
77
+ #else
78
+ options);
79
+ #endif
80
+ }
81
+ }
82
+
83
+ if (ProjectGenerationFlag.HasFlag(ProjectGenerationFlag.PlayerAssemblies))
84
+ {
85
+ foreach (var assembly in CompilationPipeline.GetAssemblies(AssembliesType.Player).Where(assembly => assembly.sourceFiles.Any(shouldFileBePartOfSolution)))
86
+ {
87
+ var options = new ScriptCompilerOptions
88
+ {
89
+ ResponseFiles = assembly.compilerOptions.ResponseFiles,
90
+ AllowUnsafeCode = assembly.compilerOptions.AllowUnsafeCode,
91
+ ApiCompatibilityLevel = assembly.compilerOptions.ApiCompatibilityLevel
92
+ };
93
+
94
+ yield return
95
+ new Assembly(assembly.name, @"Temp\Bin\Debug\Player\",
96
+ assembly.sourceFiles,
97
+ new[] { "DEBUG", "TRACE" }.Concat(assembly.defines).ToArray(),
98
+ assembly.assemblyReferences,
99
+ assembly.compiledAssemblyReferences,
100
+ assembly.flags,
101
+ #if UNITY_2020_2_OR_NEWER
102
+ options,
103
+ assembly.rootNamespace);
104
+ #else
105
+ options);
106
+ #endif
107
+ }
108
+ }
109
+ }
110
+
111
+ public string GetCompileOutputPath(string assemblyName)
112
+ {
113
+ return assemblyName.EndsWith(".Player", StringComparison.Ordinal) ? @"Temp\Bin\Debug\Player\" : @"Temp\Bin\Debug\";
114
+ }
115
+
116
+ public IEnumerable<string> GetAllAssetPaths()
117
+ {
118
+ return AssetDatabase.GetAllAssetPaths();
119
+ }
120
+
121
+ public UnityEditor.PackageManager.PackageInfo FindForAssetPath(string assetPath)
122
+ {
123
+ return UnityEditor.PackageManager.PackageInfo.FindForAssetPath(assetPath);
124
+ }
125
+
126
+ public bool IsInternalizedPackagePath(string path)
127
+ {
128
+ if (string.IsNullOrEmpty(path.Trim()))
129
+ {
130
+ return false;
131
+ }
132
+ var packageInfo = FindForAssetPath(path);
133
+ if (packageInfo == null)
134
+ {
135
+ return false;
136
+ }
137
+ var packageSource = packageInfo.source;
138
+ switch (packageSource)
139
+ {
140
+ case PackageSource.Embedded:
141
+ return !ProjectGenerationFlag.HasFlag(ProjectGenerationFlag.Embedded);
142
+ case PackageSource.Registry:
143
+ return !ProjectGenerationFlag.HasFlag(ProjectGenerationFlag.Registry);
144
+ case PackageSource.BuiltIn:
145
+ return !ProjectGenerationFlag.HasFlag(ProjectGenerationFlag.BuiltIn);
146
+ case PackageSource.Unknown:
147
+ return !ProjectGenerationFlag.HasFlag(ProjectGenerationFlag.Unknown);
148
+ case PackageSource.Local:
149
+ return !ProjectGenerationFlag.HasFlag(ProjectGenerationFlag.Local);
150
+ case PackageSource.Git:
151
+ return !ProjectGenerationFlag.HasFlag(ProjectGenerationFlag.Git);
152
+ case PackageSource.LocalTarball:
153
+ return !ProjectGenerationFlag.HasFlag(ProjectGenerationFlag.LocalTarBall);
154
+ }
155
+
156
+ return false;
157
+ }
158
+
159
+ public ResponseFileData ParseResponseFile(string responseFilePath, string projectDirectory, string[] systemReferenceDirectories)
160
+ {
161
+ return CompilationPipeline.ParseResponseFile(
162
+ responseFilePath,
163
+ projectDirectory,
164
+ systemReferenceDirectories
165
+ );
166
+ }
167
+
168
+ public void ToggleProjectGeneration(ProjectGenerationFlag preference)
169
+ {
170
+ if (ProjectGenerationFlag.HasFlag(preference))
171
+ {
172
+ ProjectGenerationFlag ^= preference;
173
+ }
174
+ else
175
+ {
176
+ ProjectGenerationFlag |= preference;
177
+ }
178
+ }
179
+
180
+ public void ResetProjectGenerationFlag()
181
+ {
182
+ ProjectGenerationFlag = ProjectGenerationFlag.None;
183
+ }
184
+
185
+ public string GetAssemblyName(string assemblyOutputPath, string assemblyName)
186
+ {
187
+ return assemblyOutputPath.EndsWith(@"\Player\", StringComparison.Ordinal) ? assemblyName + ".Player" : assemblyName;
188
+ }
189
+ }
190
+ }
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.ide.visualstudio@2.0.7/Editor/ProjectGeneration/AssemblyNameProvider.cs.meta ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ fileFormatVersion: 2
2
+ guid: 57537f08f8e923f488e4aadabb831c9b
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.ide.visualstudio@2.0.7/Editor/ProjectGeneration/FileIOProvider.cs ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Unity Technologies.
3
+ * Copyright (c) Microsoft Corporation. All rights reserved.
4
+ * Licensed under the MIT License. See License.txt in the project root for license information.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ using System.IO;
7
+ using System.Text;
8
+
9
+ namespace Microsoft.Unity.VisualStudio.Editor
10
+ {
11
+ public interface IFileIO
12
+ {
13
+ bool Exists(string fileName);
14
+
15
+ string ReadAllText(string fileName);
16
+ void WriteAllText(string fileName, string content);
17
+ }
18
+
19
+ class FileIOProvider : IFileIO
20
+ {
21
+ public bool Exists(string fileName)
22
+ {
23
+ return File.Exists(fileName);
24
+ }
25
+
26
+ public string ReadAllText(string fileName)
27
+ {
28
+ return File.ReadAllText(fileName);
29
+ }
30
+
31
+ public void WriteAllText(string fileName, string content)
32
+ {
33
+ File.WriteAllText(fileName, content, Encoding.UTF8);
34
+ }
35
+ }
36
+ }
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.ide.visualstudio@2.0.7/Editor/ProjectGeneration/FileIOProvider.cs.meta ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ fileFormatVersion: 2
2
+ guid: ec80b1fb8938b3b4ab442d10390c5315
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.ide.visualstudio@2.0.7/Editor/ProjectGeneration/GUIDProvider.cs ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Unity Technologies.
3
+ * Copyright (c) Microsoft Corporation. All rights reserved.
4
+ * Licensed under the MIT License. See License.txt in the project root for license information.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ namespace Microsoft.Unity.VisualStudio.Editor
7
+ {
8
+ public interface IGUIDGenerator
9
+ {
10
+ string ProjectGuid(string projectName, string assemblyName);
11
+ string SolutionGuid(string projectName, ScriptingLanguage scriptingLanguage);
12
+ }
13
+
14
+ class GUIDProvider : IGUIDGenerator
15
+ {
16
+ public string ProjectGuid(string projectName, string assemblyName)
17
+ {
18
+ return SolutionGuidGenerator.GuidForProject(projectName + assemblyName);
19
+ }
20
+
21
+ public string SolutionGuid(string projectName, ScriptingLanguage scriptingLanguage)
22
+ {
23
+ return SolutionGuidGenerator.GuidForSolution(projectName, scriptingLanguage);
24
+ }
25
+ }
26
+ }
benchmark/NYU_CTF_Bench/test/2022/CSAW-Quals/rev/AnyaGacha/src/client/Library/PackageCache/com.unity.ide.visualstudio@2.0.7/Editor/ProjectGeneration/GUIDProvider.cs.meta ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ fileFormatVersion: 2
2
+ guid: 7652904b1008e324fb7cfb952ea87656
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant: