Imported Upstream version 6.8.0.73

Former-commit-id: d18deab1b47cfd3ad8cba82b3f37d00eec2170af
This commit is contained in:
Xamarin Public Jenkins (auto-signing) 2019-12-10 18:00:56 +00:00
parent bceda29824
commit 73ee7591e8
1043 changed files with 16271 additions and 22080 deletions

View File

@ -21,14 +21,14 @@ endif
if ENABLE_NETCORE
update_submodules =
SUBDIRS = mk llvm mono runtime netcore
SUBDIRS = mk llvm mono runtime netcore netcore/corerun
else
update_submodules = update_submodules
SUBDIRS = $(build_with_msvc) mk po $(libgc_dir) llvm mono $(ikvm_native_dir) support data runtime scripts man samples $(tools_dir) $(build_without_msvc) $(docs_dir) acceptance-tests
endif
# Keep in sync with SUBDIRS
DIST_SUBDIRS = $(build_with_msvc) m4 mk po $(libgc_dir) llvm mono ikvm-native support data runtime scripts man samples tools $(build_without_msvc) docs acceptance-tests netcore
DIST_SUBDIRS = $(build_with_msvc) m4 mk po $(libgc_dir) llvm mono ikvm-native support data runtime scripts man samples tools $(build_without_msvc) docs acceptance-tests netcore netcore/corerun
all: $(update_submodules)
@ -46,9 +46,10 @@ EXTRA_DIST= \
winconfig.h \
code_of_conduct.md \
external \
netcore/Makefile \
mcs/class/referencesource
DISTCHECK_CONFIGURE_FLAGS = EXTERNAL_MCS=false EXTERNAL_RUNTIME=false
DISTCHECK_CONFIGURE_FLAGS = EXTERNAL_RUNTIME=false
# Distribute the 'mcs' tree too
GIT_DIR ?= $(srcdir)/.git

View File

@ -301,6 +301,7 @@ INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
INTERP_CFLAGS = @INTERP_CFLAGS@
INTL = @INTL@
INVARIANT_AOT_OPTIONS = @INVARIANT_AOT_OPTIONS@
JEMALLOC_AUTOCONF_FLAGS = @JEMALLOC_AUTOCONF_FLAGS@
@ -503,10 +504,10 @@ MONOTOUCH_SUBDIRS = $(libgc_dir) mono
@ENABLE_NETCORE_FALSE@update_submodules = update_submodules
@ENABLE_NETCORE_TRUE@update_submodules =
@ENABLE_NETCORE_FALSE@SUBDIRS = $(build_with_msvc) mk po $(libgc_dir) llvm mono $(ikvm_native_dir) support data runtime scripts man samples $(tools_dir) $(build_without_msvc) $(docs_dir) acceptance-tests
@ENABLE_NETCORE_TRUE@SUBDIRS = mk llvm mono runtime netcore
@ENABLE_NETCORE_TRUE@SUBDIRS = mk llvm mono runtime netcore netcore/corerun
# Keep in sync with SUBDIRS
DIST_SUBDIRS = $(build_with_msvc) m4 mk po $(libgc_dir) llvm mono ikvm-native support data runtime scripts man samples tools $(build_without_msvc) docs acceptance-tests netcore
DIST_SUBDIRS = $(build_with_msvc) m4 mk po $(libgc_dir) llvm mono ikvm-native support data runtime scripts man samples tools $(build_without_msvc) docs acceptance-tests netcore netcore/corerun
EXTRA_DIST = \
README.md \
LICENSE \
@ -516,9 +517,10 @@ EXTRA_DIST = \
winconfig.h \
code_of_conduct.md \
external \
netcore/Makefile \
mcs/class/referencesource
DISTCHECK_CONFIGURE_FLAGS = EXTERNAL_MCS=false EXTERNAL_RUNTIME=false
DISTCHECK_CONFIGURE_FLAGS = EXTERNAL_RUNTIME=false
pkgconfigdir = $(libdir)/pkgconfig
noinst_DATA = mono-uninstalled.pc
DISTCLEANFILES = mono-uninstalled.pc

View File

@ -1 +1 @@
472b93a07fd7c07ed8c5b43beb68961486a1f729
930a27e684805f373e65684b696c1512bf0f1a15

View File

@ -620,6 +620,9 @@
/* Have large file support */
#undef HAVE_LARGE_FILE_SUPPORT
/* lchflags */
#undef HAVE_LCHFLAGS
/* Define to 1 if you have the `iconv' library (-liconv). */
#undef HAVE_LIBICONV
@ -975,6 +978,9 @@
/* struct stat.st_birthtimespec */
#undef HAVE_STAT_BIRTHTIME
/* struct stat.st_flags */
#undef HAVE_STAT_FLAGS
/* struct stat.st_atimensec */
#undef HAVE_STAT_NSEC

View File

@ -1 +1 @@
30bc3192fe7c329d0c0e0ce80f458d396d8bbe69
b8ba159bbd60b12015a3c0ea74f7436213e62335

View File

@ -1 +1 @@
1b5c1decda620ceb7c24a9921ab6459634cf4bae
612e6f088c12dc8b2912628d2cfa6e5dcbe28a40

View File

@ -323,6 +323,7 @@ INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
INTERP_CFLAGS = @INTERP_CFLAGS@
INTL = @INTL@
INVARIANT_AOT_OPTIONS = @INVARIANT_AOT_OPTIONS@
JEMALLOC_AUTOCONF_FLAGS = @JEMALLOC_AUTOCONF_FLAGS@

View File

@ -244,6 +244,7 @@ INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
INTERP_CFLAGS = @INTERP_CFLAGS@
INTL = @INTL@
INVARIANT_AOT_OPTIONS = @INVARIANT_AOT_OPTIONS@
JEMALLOC_AUTOCONF_FLAGS = @JEMALLOC_AUTOCONF_FLAGS@

View File

@ -304,6 +304,7 @@ INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
INTERP_CFLAGS = @INTERP_CFLAGS@
INTL = @INTL@
INVARIANT_AOT_OPTIONS = @INVARIANT_AOT_OPTIONS@
JEMALLOC_AUTOCONF_FLAGS = @JEMALLOC_AUTOCONF_FLAGS@

View File

@ -244,6 +244,7 @@ INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
INTERP_CFLAGS = @INTERP_CFLAGS@
INTL = @INTL@
INVARIANT_AOT_OPTIONS = @INVARIANT_AOT_OPTIONS@
JEMALLOC_AUTOCONF_FLAGS = @JEMALLOC_AUTOCONF_FLAGS@

View File

@ -304,6 +304,7 @@ INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
INTERP_CFLAGS = @INTERP_CFLAGS@
INTL = @INTL@
INVARIANT_AOT_OPTIONS = @INVARIANT_AOT_OPTIONS@
JEMALLOC_AUTOCONF_FLAGS = @JEMALLOC_AUTOCONF_FLAGS@

View File

@ -244,6 +244,7 @@ INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
INTERP_CFLAGS = @INTERP_CFLAGS@
INTL = @INTL@
INVARIANT_AOT_OPTIONS = @INVARIANT_AOT_OPTIONS@
JEMALLOC_AUTOCONF_FLAGS = @JEMALLOC_AUTOCONF_FLAGS@

View File

@ -304,6 +304,7 @@ INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
INTERP_CFLAGS = @INTERP_CFLAGS@
INTL = @INTL@
INVARIANT_AOT_OPTIONS = @INVARIANT_AOT_OPTIONS@
JEMALLOC_AUTOCONF_FLAGS = @JEMALLOC_AUTOCONF_FLAGS@

View File

@ -245,6 +245,7 @@ INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
INTERP_CFLAGS = @INTERP_CFLAGS@
INTL = @INTL@
INVARIANT_AOT_OPTIONS = @INVARIANT_AOT_OPTIONS@
JEMALLOC_AUTOCONF_FLAGS = @JEMALLOC_AUTOCONF_FLAGS@

View File

@ -621,6 +621,12 @@ mono_gc_wait_for_bridge_processing (void)
<h3>Write Barriers</h3>
<p />SGen is a concurrent and generational GC, features which require
tracking changes to the state of the heap. This is achieved through
write barriers. Whenever native code is changing the state of the
heap by storing references into another managed object, it needs to
do it using this write barrier API.
</div> <!-- class=mapi -->
<a name="api:mono_gc_wbarrier_arrayref_copy"></a>
@ -632,8 +638,16 @@ mono_gc_wait_for_bridge_processing (void)
<div class="mapi-ptr"></div>
<div class="mapi-declaration mapi-section">Syntax</div>
<div class="mapi-prototype">mono_gc_wbarrier_arrayref_copy</div>
<div class="mapi-prototype">void
mono_gc_wbarrier_arrayref_copy (void* dest_ptr, /*const*/ void* src_ptr, int count)
</div>
<p />
<div class="mapi-section">Parameters</div>
<table class="mapi-parameters"><tbody><tr><td><i>dest_ptr</i></td><td> destination slot address</td></tr><tr><td><i>src_ptr</i></td><td> source slot address</td></tr><tr><td><i>count</i></td><td> number of references to copy</td></tr></tbody></table> <div class="mapi-section">Description</div>
<div>
Copies <i>count</i> references from one array to another, executing a write
barrier if needed.</div>
</div><!--mapi-description -->
</div><!--height container -->
</div> <!-- class=mapi -->
@ -647,8 +661,15 @@ mono_gc_wait_for_bridge_processing (void)
<div class="mapi-ptr"></div>
<div class="mapi-declaration mapi-section">Syntax</div>
<div class="mapi-prototype">mono_gc_wbarrier_generic_nostore</div>
<div class="mapi-prototype">void
mono_gc_wbarrier_generic_nostore (void* ptr)
</div>
<p />
<div class="mapi-section">Description</div>
<div>
Executes a write barrier for an address, informing the GC that
the reference stored at that address has been changed.</div>
</div><!--mapi-description -->
</div><!--height container -->
</div> <!-- class=mapi -->
@ -667,6 +688,11 @@ mono_gc_wbarrier_generic_store (void* ptr, MonoObject* value)
</div>
<p />
<div class="mapi-section">Parameters</div>
<table class="mapi-parameters"><tbody><tr><td><i>ptr</i></td><td> address of field</td></tr><tr><td><i>obj</i></td><td> object to store</td></tr></tbody></table> <div class="mapi-section">Description</div>
<div>
Stores the <i>value</i> object inside the field represented by <i>ptr</i>,
executing a write barrier if needed.</div>
</div><!--mapi-description -->
</div><!--height container -->
</div> <!-- class=mapi -->
@ -680,8 +706,15 @@ mono_gc_wbarrier_generic_store (void* ptr, MonoObject* value)
<div class="mapi-ptr"></div>
<div class="mapi-declaration mapi-section">Syntax</div>
<div class="mapi-prototype">mono_gc_wbarrier_generic_store_atomic</div>
<div class="mapi-prototype">void
mono_gc_wbarrier_generic_store_atomic (void *ptr, MonoObject *value)
</div>
<p />
<div class="mapi-section">Description</div>
<div>
Same as <code>mono_gc_wbarrier_generic_store</code> but performs the store
as an atomic operation with release semantics.</div>
</div><!--mapi-description -->
</div><!--height container -->
</div> <!-- class=mapi -->
@ -700,10 +733,11 @@ mono_gc_wbarrier_object_copy (MonoObject* obj, MonoObject *src)
</div>
<p />
<div class="mapi-section">Description</div>
<div class="mapi-section">Parameters</div>
<table class="mapi-parameters"><tbody><tr><td><i>obj</i></td><td> destination object</td></tr><tr><td><i>src</i></td><td> source object</td></tr></tbody></table> <div class="mapi-section">Description</div>
<div>
<p />
Write barrier to call when <i>obj</i> is the result of a clone or copy of an object.</div>
Copies contents of <i>src</i> to <i>obj</i>, executing any necessary write
barriers.</div>
</div><!--mapi-description -->
</div><!--height container -->
</div> <!-- class=mapi -->
@ -722,6 +756,11 @@ mono_gc_wbarrier_set_arrayref (MonoArray *arr, void* slot_ptr, MonoObject* value
</div>
<p />
<div class="mapi-section">Parameters</div>
<table class="mapi-parameters"><tbody><tr><td><i>arr</i></td><td> array containing the destination slot</td></tr><tr><td><i>slot_ptr</i></td><td> address of slot inside the array</td></tr><tr><td><i>value</i></td><td> reference to the object to be stored</td></tr></tbody></table> <div class="mapi-section">Description</div>
<div>
Stores an object reference inside an array of objects, executing a write
barrier if needed.</div>
</div><!--mapi-description -->
</div><!--height container -->
</div> <!-- class=mapi -->
@ -740,5 +779,10 @@ mono_gc_wbarrier_set_field (MonoObject *obj, void* field_ptr, MonoObject* value)
</div>
<p />
<div class="mapi-section">Parameters</div>
<table class="mapi-parameters"><tbody><tr><td><i>obj</i></td><td> object containing the destination field</td></tr><tr><td><i>field_ptr</i></td><td> address of field inside the object</td></tr><tr><td><i>value</i></td><td> reference to the object to be stored</td></tr></tbody></table> <div class="mapi-section">Description</div>
<div>
Stores an object reference inside another object, executing a write barrier
if needed.</div>
</div><!--mapi-description -->
</div><!--height container -->

View File

@ -959,9 +959,12 @@ mono_array_length (MonoArray *array)
<div>
with elements of size sizeof(type) to the provided <i>value</i>.
<p />
This macro does not attempt to perform type checking or bounds checking.
This macro does not attempt to perform type checking or bounds checking
and it doesn't execute any write barriers.
<p />
Use this to set value types in a <code>MonoArray</code>.</div>
Use this to set value types in a <code>MonoArray</code>. This shouldn't be used if
the copied value types contain references. Use <code>mono_gc_wbarrier_value_copy</code>
instead when also copying references.</div>
</div><!--mapi-description -->
</div><!--height container -->
</div> <!-- class=mapi -->

View File

@ -377,6 +377,9 @@ mono_thread_manage (void)
</div>
<p />
<div class="mapi-section">Description</div>
<div>
<p /></div>
</div><!--mapi-description -->
</div><!--height container -->
</div> <!-- class=mapi -->

View File

@ -740,7 +740,7 @@ mono_runtime_object_init (MonoObject *this_obj)
<div class="mapi-declaration mapi-section">Syntax</div>
<div class="mapi-prototype">void
mono_runtime_quit ()
mono_runtime_quit (void)
</div>
<p />

View File

@ -109,6 +109,12 @@ typedef struct {
<h3>Write Barriers</h3>
<p>SGen is a concurrent and generational GC, features which require
tracking changes to the state of the heap. This is achieved through
write barriers. Whenever native code is changing the state of the
heap by storing references into another managed object, it needs to
do it using this write barrier API.
<h4><a name="api:mono_gc_wbarrier_arrayref_copy">mono_gc_wbarrier_arrayref_copy</a></h4>
<h4><a name="api:mono_gc_wbarrier_generic_nostore">mono_gc_wbarrier_generic_nostore</a></h4>
<h4><a name="api:mono_gc_wbarrier_generic_store">mono_gc_wbarrier_generic_store</a></h4>

View File

@ -1 +1 @@
675faa3a855f9b309b9764157c4f30f3a2eef014
23a53f6a657256c50759b9c4f4b3f27827d21a79

View File

@ -1 +1 @@
072b075c7d65a7754b26747e60ce1daab71dc0c1
ee94acf7f8f15010d1417f44b9131319ac821155

View File

@ -1 +1 @@
8de80e92b25690f3c330c1a77f4211e145e371ce
3e8933930502d0d8ded2c9654341153068d92d73

View File

@ -1 +1 @@
4eab3daf447a9db125e2b7d24282b35b14aa7f64
68d28c31b98019e06fa4ba81b96365aad2004da1

View File

@ -1 +1 @@
6b337acd79c5f1288e336dd395d2b0508a4b167e
b0e3f98db76152ae1cf353af732450926d11f876

View File

@ -30,7 +30,7 @@ namespace System.Net.Http
public ByteArrayContent(byte[] content) { }
public ByteArrayContent(byte[] content, int offset, int count) { }
protected override System.Threading.Tasks.Task<System.IO.Stream> CreateContentReadStreamAsync() { throw null; }
protected internal override System.Threading.Tasks.Task SerializeToStreamAsync(System.IO.Stream stream, System.Net.TransportContext context) { throw null; }
protected override System.Threading.Tasks.Task SerializeToStreamAsync(System.IO.Stream stream, System.Net.TransportContext context) { throw null; }
protected internal override bool TryComputeLength(out long length) { throw null; }
}
public enum ClientCertificateOption
@ -145,7 +145,7 @@ namespace System.Net.Http
public System.Threading.Tasks.Task<byte[]> ReadAsByteArrayAsync() { throw null; }
public System.Threading.Tasks.Task<System.IO.Stream> ReadAsStreamAsync() { throw null; }
public System.Threading.Tasks.Task<string> ReadAsStringAsync() { throw null; }
protected internal abstract System.Threading.Tasks.Task SerializeToStreamAsync(System.IO.Stream stream, System.Net.TransportContext context);
protected abstract System.Threading.Tasks.Task SerializeToStreamAsync(System.IO.Stream stream, System.Net.TransportContext context);
protected internal abstract bool TryComputeLength(out long length);
}
public abstract partial class HttpMessageHandler : System.IDisposable
@ -235,9 +235,10 @@ namespace System.Net.Http
public MultipartContent(string subtype) { }
public MultipartContent(string subtype, string boundary) { }
public virtual void Add(System.Net.Http.HttpContent content) { }
protected override System.Threading.Tasks.Task<System.IO.Stream> CreateContentReadStreamAsync() { throw null; }
protected override void Dispose(bool disposing) { }
public System.Collections.Generic.IEnumerator<System.Net.Http.HttpContent> GetEnumerator() { throw null; }
protected internal override System.Threading.Tasks.Task SerializeToStreamAsync(System.IO.Stream stream, System.Net.TransportContext context) { throw null; }
protected override System.Threading.Tasks.Task SerializeToStreamAsync(System.IO.Stream stream, System.Net.TransportContext context) { throw null; }
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; }
protected internal override bool TryComputeLength(out long length) { throw null; }
}
@ -252,16 +253,43 @@ namespace System.Net.Http
public sealed partial class ReadOnlyMemoryContent : System.Net.Http.HttpContent
{
public ReadOnlyMemoryContent(System.ReadOnlyMemory<byte> content) { }
protected internal override System.Threading.Tasks.Task SerializeToStreamAsync(System.IO.Stream stream, System.Net.TransportContext context) { throw null; }
protected override System.Threading.Tasks.Task<System.IO.Stream> CreateContentReadStreamAsync() { throw null; }
protected override System.Threading.Tasks.Task SerializeToStreamAsync(System.IO.Stream stream, System.Net.TransportContext context) { throw null; }
protected internal override bool TryComputeLength(out long length) { throw null; }
}
public sealed partial class SocketsHttpHandler : System.Net.Http.HttpMessageHandler, System.IDisposable
{
public SocketsHttpHandler() { }
public bool AllowAutoRedirect { get { throw null; } set { } }
public System.Net.DecompressionMethods AutomaticDecompression { get { throw null; } set { } }
public System.TimeSpan ConnectTimeout { get { throw null; } set { } }
public System.Net.CookieContainer CookieContainer { get { throw null; } set { } }
public System.Net.ICredentials Credentials { get { throw null; } set { } }
public System.Net.ICredentials DefaultProxyCredentials { get { throw null; } set { } }
public System.TimeSpan Expect100ContinueTimeout { get { throw null; } set { } }
public int MaxAutomaticRedirections { get { throw null; } set { } }
public int MaxConnectionsPerServer { get { throw null; } set { } }
public int MaxResponseDrainSize { get { throw null; } set { } }
public int MaxResponseHeadersLength { get { throw null; } set { } }
public System.TimeSpan PooledConnectionIdleTimeout { get { throw null; } set { } }
public System.TimeSpan PooledConnectionLifetime { get { throw null; } set { } }
public bool PreAuthenticate { get { throw null; } set { } }
public System.Collections.Generic.IDictionary<string, object> Properties { get { throw null; } }
public System.Net.IWebProxy Proxy { get { throw null; } set { } }
public System.TimeSpan ResponseDrainTimeout { get { throw null; } set { } }
public System.Net.Security.SslClientAuthenticationOptions SslOptions { get { throw null; } set { } }
public bool UseCookies { get { throw null; } set { } }
public bool UseProxy { get { throw null; } set { } }
protected override void Dispose(bool disposing) { }
protected internal override System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> SendAsync(System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) { throw null; }
}
public partial class StreamContent : System.Net.Http.HttpContent
{
public StreamContent(System.IO.Stream content) { }
public StreamContent(System.IO.Stream content, int bufferSize) { }
protected override System.Threading.Tasks.Task<System.IO.Stream> CreateContentReadStreamAsync() { throw null; }
protected override void Dispose(bool disposing) { }
protected internal override System.Threading.Tasks.Task SerializeToStreamAsync(System.IO.Stream stream, System.Net.TransportContext context) { throw null; }
protected override System.Threading.Tasks.Task SerializeToStreamAsync(System.IO.Stream stream, System.Net.TransportContext context) { throw null; }
protected internal override bool TryComputeLength(out long length) { throw null; }
}
public partial class StringContent : System.Net.Http.ByteArrayContent
@ -484,17 +512,18 @@ namespace System.Net.Http.Headers
public override string ToString() { throw null; }
public static bool TryParse(string input, out System.Net.Http.Headers.MediaTypeHeaderValue parsedValue) { throw null; }
}
public sealed partial class MediaTypeWithQualityHeaderValue : System.Net.Http.Headers.MediaTypeHeaderValue
public sealed partial class MediaTypeWithQualityHeaderValue : System.Net.Http.Headers.MediaTypeHeaderValue, System.ICloneable
{
public MediaTypeWithQualityHeaderValue(string mediaType) : base (default(string)) { }
public MediaTypeWithQualityHeaderValue(string mediaType, double quality) : base (default(string)) { }
public MediaTypeWithQualityHeaderValue(string mediaType) : base (default(System.Net.Http.Headers.MediaTypeHeaderValue)) { }
public MediaTypeWithQualityHeaderValue(string mediaType, double quality) : base (default(System.Net.Http.Headers.MediaTypeHeaderValue)) { }
public System.Nullable<double> Quality { get { throw null; } set { } }
public static new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue Parse(string input) { throw null; }
object System.ICloneable.Clone() { throw null; }
public static bool TryParse(string input, out System.Net.Http.Headers.MediaTypeWithQualityHeaderValue parsedValue) { throw null; }
}
public partial class NameValueHeaderValue : System.ICloneable
{
protected internal NameValueHeaderValue(System.Net.Http.Headers.NameValueHeaderValue source) { }
protected NameValueHeaderValue(System.Net.Http.Headers.NameValueHeaderValue source) { }
public NameValueHeaderValue(string name) { }
public NameValueHeaderValue(string name, string value) { }
public string Name { get { throw null; } }
@ -622,12 +651,13 @@ namespace System.Net.Http.Headers
public override string ToString() { throw null; }
public static bool TryParse(string input, out System.Net.Http.Headers.TransferCodingHeaderValue parsedValue) { throw null; }
}
public sealed partial class TransferCodingWithQualityHeaderValue : System.Net.Http.Headers.TransferCodingHeaderValue
public sealed partial class TransferCodingWithQualityHeaderValue : System.Net.Http.Headers.TransferCodingHeaderValue, System.ICloneable
{
public TransferCodingWithQualityHeaderValue(string value) : base (default(string)) { }
public TransferCodingWithQualityHeaderValue(string value, double quality) : base (default(string)) { }
public TransferCodingWithQualityHeaderValue(string value) : base (default(System.Net.Http.Headers.TransferCodingHeaderValue)) { }
public TransferCodingWithQualityHeaderValue(string value, double quality) : base (default(System.Net.Http.Headers.TransferCodingHeaderValue)) { }
public System.Nullable<double> Quality { get { throw null; } set { } }
public static new System.Net.Http.Headers.TransferCodingWithQualityHeaderValue Parse(string input) { throw null; }
object System.ICloneable.Clone() { throw null; }
public static bool TryParse(string input, out System.Net.Http.Headers.TransferCodingWithQualityHeaderValue parsedValue) { throw null; }
}
public partial class ViaHeaderValue : System.ICloneable

View File

@ -1 +1 @@
a5b17251bf1b4f417ac562f2e9c98d4073d0ff5b
ed1414ca828ee9519a6607ede29370c74a68f69b

View File

@ -1 +1 @@
90d02a101ed04da6a18a169ddf1ec2799c16fcdf
3d86cbc178ecc58c1640325d9c50613a8db0a299

View File

@ -1 +1 @@
e1f35668ff12c7719a94dbad1f42fe4317d3f553
7d65de02df2ecf34d5528debc47da5e04ca08c3c

View File

@ -1 +1 @@
703aeb84b7f468abb1a4821829683c566a004026
d4965059d547194b07315ea2eccdd9324bcfbf8c

View File

@ -1 +1 @@
80b79ba367d12c121332316fea3dcc10f9ac278f
46468e5b458af1df7c4d502ad8f5c2a83527e649

View File

@ -1 +1 @@
00725101599ebd8c039e531859320754cb521f2e
d22c0752cbf3a18e72df8083ab5354f346c648f8

View File

@ -1 +1 @@
03f0d6f3e5645ad55d73b26135212076a5119877
422a5ed0cc55c2bd8c7a4e5ab98f378ce5d8aded

View File

@ -878,6 +878,7 @@ class Package:
elif orig_suffix is not None:
suffixed = os.path.join(
dest_dir, reldir, add_suffix(filename, orig_suffix))
trace(dest_orig_file)
trace(suffixed)
shutil.move(dest_orig_file, suffixed)
os.symlink(os.path.basename(suffixed), dest_orig_file)

View File

@ -4,7 +4,7 @@ class GtkSharp212ReleasePackage (Package):
Package.__init__(self, 'gtk-sharp',
sources=['git://github.com/mono/gtk-sharp.git'],
git_branch='gtk-sharp-2-12-branch',
revision='dedce8ddbe37ae467f18ff785255e04fd9ccd782',
revision='76a9a14ad72b75b66fdda12fab1532c2e5318cc5',
override_properties={
'configure': './bootstrap-2.12 --prefix=%{package_prefix}',
}

View File

@ -1,38 +0,0 @@
trigger:
- master
pr:
- master
jobs:
- job: Linux
pool:
vmImage: 'ubuntu-16.04'
steps:
- script: |
dotnet build -c Debug Mono.Cecil.sln
displayName: 'Build'
- script: |
dotnet test --no-build -c Debug -f netcoreapp2.1 Mono.Cecil.sln
displayName: 'Test .NET Core'
- task: NuGetToolInstaller@0
displayName: 'Install nuget'
- task: NuGetCommand@2
inputs:
command: 'custom'
arguments: 'install NUnit.Console -Version 3.9.0 -OutputDirectory ./packages'
displayName: 'Get NUnit.Console'
- script: |
mono ./packages/NUnit.ConsoleRunner.3.9.0/tools/nunit3-console.exe ./Mono.Cecil.nunit
displayName: 'Test .NET 4.0 using Mono'
- job: Windows
pool:
vmImage: 'vs2017-win2016'
steps:
- script: |
dotnet build -c Debug Mono.Cecil.sln
displayName: 'Build'
- script: |
dotnet test --no-build -c Debug Mono.Cecil.sln
displayName: 'Test'

View File

@ -0,0 +1,35 @@
name: CI
on:
push:
branches:
- master
- release/*
pull_request:
branches:
- master
- release/*
jobs:
windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v1
- name: Build
run: dotnet build -c Debug Mono.Cecil.sln
- name: Test
run: dotnet test --no-build -c Debug Mono.Cecil.sln
linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Build
run: dotnet build -c Debug Mono.Cecil.sln
- name: Test .NET Core
run: dotnet test --no-build -c Debug Mono.Cecil.sln
- name: Get NuGet
run: curl -o ./nuget.exe https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
- name: Get NUnit.Console
run: mono ./nuget.exe install NUnit.Console -Version 3.9.0 -OutputDirectory ./packages
- name: Test .NET 4.0 using Mono
run: mono ./packages/NUnit.ConsoleRunner.3.9.0/tools/nunit3-console.exe ./Mono.Cecil.nunit

View File

@ -14,3 +14,5 @@ TestResults
project.lock.json
.vs/
.idea/
packages/*
nuget.exe

View File

@ -350,7 +350,7 @@ namespace Mono.Cecil.PE {
PointerToRawData = ReadInt32 (),
};
if (directory.PointerToRawData == 0) {
if (directory.PointerToRawData == 0 || directory.SizeOfData < 0) {
entries [i] = new ImageDebugHeaderEntry (directory, Empty<byte>.Array);
continue;
}

View File

@ -1,6 +1,6 @@
<NUnitProject>
<Settings activeconfig="Debug" />
<Config name="Debug" runtimeFramework="v4.0.30319">
<Config name="Debug" runtimeFramework="v4.0.30319" domainUsage="Single">
<assembly path="./Test/bin/Debug/net40/Mono.Cecil.Tests.dll" />
<assembly path="./rocks/Test/bin/Debug/net40/Mono.Cecil.Rocks.Tests.dll" />
<assembly path="./symbols/mdb/Test/bin/Debug/net40/Mono.Cecil.Mdb.Tests.dll" />

View File

@ -102,8 +102,8 @@ namespace Mono.Cecil {
if (symbol_writer_provider == null && parameters.WriteSymbols)
symbol_writer_provider = new DefaultSymbolWriterProvider ();
if (parameters.StrongNameKeyPair != null && name != null) {
name.PublicKey = parameters.StrongNameKeyPair.PublicKey;
if (parameters.HasStrongNameKey && name != null) {
name.PublicKey = CryptoService.GetPublicKey (parameters);
module.Attributes |= ModuleAttributes.StrongNameSigned;
}
@ -125,8 +125,8 @@ namespace Mono.Cecil {
stream.value.SetLength (0);
writer.WriteImage ();
if (parameters.StrongNameKeyPair != null)
CryptoService.StrongName (stream.value, writer, parameters.StrongNameKeyPair);
if (parameters.HasStrongNameKey)
CryptoService.StrongName (stream.value, writer, parameters);
}
} finally {
module.metadata_builder = null;

View File

@ -199,6 +199,8 @@ namespace Mono.Cecil {
Stream symbol_stream;
ISymbolWriterProvider symbol_writer_provider;
bool write_symbols;
byte [] key_blob;
string key_container;
SR.StrongNameKeyPair key_pair;
public uint? Timestamp {
@ -221,6 +223,20 @@ namespace Mono.Cecil {
set { write_symbols = value; }
}
public bool HasStrongNameKey {
get { return key_pair != null || key_blob != null || key_container != null; }
}
public byte [] StrongNameKeyBlob {
get { return key_blob; }
set { key_blob = value; }
}
public string StrongNameKeyContainer {
get { return key_container; }
set { key_container = value; }
}
public SR.StrongNameKeyPair StrongNameKeyPair {
get { return key_pair; }
set { key_pair = value; }

View File

@ -29,6 +29,8 @@ namespace Mono.Cecil {
UI1 = 17,
UI2 = 18,
UI4 = 19,
I8 = 20,
UI8 = 21,
Int = 22,
UInt = 23
}

View File

@ -44,6 +44,16 @@ namespace Mono.Security.Cryptography {
return (uint)((bytes [offset+3] << 24) | (bytes [offset+2] << 16) | (bytes [offset+1] << 8) | bytes [offset]);
}
static private byte [] GetBytesLE (int val)
{
return new byte [] {
(byte) (val & 0xff),
(byte) ((val >> 8) & 0xff),
(byte) ((val >> 16) & 0xff),
(byte) ((val >> 24) & 0xff)
};
}
static private byte[] Trim (byte[] array)
{
for (int i=0; i < array.Length; i++) {
@ -240,5 +250,41 @@ namespace Mono.Security.Cryptography {
}
throw new CryptographicException ("Unknown blob format.");
}
static public byte[] ToCapiPublicKeyBlob (RSA rsa)
{
RSAParameters p = rsa.ExportParameters (false);
int keyLength = p.Modulus.Length; // in bytes
byte[] blob = new byte [20 + keyLength];
blob [0] = 0x06; // Type - PUBLICKEYBLOB (0x06)
blob [1] = 0x02; // Version - Always CUR_BLOB_VERSION (0x02)
// [2], [3] // RESERVED - Always 0
blob [5] = 0x24; // ALGID - Always 00 24 00 00 (for CALG_RSA_SIGN)
blob [8] = 0x52; // Magic - RSA1 (ASCII in hex)
blob [9] = 0x53;
blob [10] = 0x41;
blob [11] = 0x31;
byte[] bitlen = GetBytesLE (keyLength << 3);
blob [12] = bitlen [0]; // bitlen
blob [13] = bitlen [1];
blob [14] = bitlen [2];
blob [15] = bitlen [3];
// public exponent (DWORD)
int pos = 16;
int n = p.Exponent.Length;
while (n > 0)
blob [pos++] = p.Exponent [--n];
// modulus
pos = 20;
byte[] part = p.Modulus;
int len = part.Length;
Array.Reverse (part, 0, len);
Buffer.BlockCopy (part, 0, blob, pos, len);
pos += len;
return blob;
}
}
}

View File

@ -26,11 +26,33 @@ namespace Mono.Cecil {
static class CryptoService {
public static void StrongName (Stream stream, ImageWriter writer, StrongNameKeyPair key_pair)
public static byte [] GetPublicKey (WriterParameters parameters)
{
using (var rsa = parameters.CreateRSA ()) {
var cspBlob = CryptoConvert.ToCapiPublicKeyBlob (rsa);
var publicKey = new byte [12 + cspBlob.Length];
Buffer.BlockCopy (cspBlob, 0, publicKey, 12, cspBlob.Length);
// The first 12 bytes are documented at:
// http://msdn.microsoft.com/library/en-us/cprefadd/html/grfungethashfromfile.asp
// ALG_ID - Signature
publicKey [1] = 36;
// ALG_ID - Hash
publicKey [4] = 4;
publicKey [5] = 128;
// Length of Public Key (in bytes)
publicKey [8] = (byte) (cspBlob.Length >> 0);
publicKey [9] = (byte) (cspBlob.Length >> 8);
publicKey [10] = (byte) (cspBlob.Length >> 16);
publicKey [11] = (byte) (cspBlob.Length >> 24);
return publicKey;
}
}
public static void StrongName (Stream stream, ImageWriter writer, WriterParameters parameters)
{
int strong_name_pointer;
var strong_name = CreateStrongName (key_pair, HashStream (stream, writer, out strong_name_pointer));
var strong_name = CreateStrongName (parameters, HashStream (stream, writer, out strong_name_pointer));
PatchStrongName (stream, strong_name_pointer, strong_name);
}
@ -40,11 +62,11 @@ namespace Mono.Cecil {
stream.Write (strong_name, 0, strong_name.Length);
}
static byte [] CreateStrongName (StrongNameKeyPair key_pair, byte [] hash)
static byte [] CreateStrongName (WriterParameters parameters, byte [] hash)
{
const string hash_algo = "SHA1";
using (var rsa = key_pair.CreateRSA ()) {
using (var rsa = parameters.CreateRSA ()) {
var formatter = new RSAPKCS1SignatureFormatter (rsa);
formatter.SetHashAlgorithm (hash_algo);
@ -74,7 +96,6 @@ namespace Mono.Cecil {
var sha1 = new SHA1Managed ();
var buffer = new byte [buffer_size];
using (var crypto_stream = new CryptoStream (Stream.Null, sha1, CryptoStreamMode.Write)) {
stream.Seek (0, SeekOrigin.Begin);
CopyStreamChunk (stream, crypto_stream, buffer, header_size);
@ -125,7 +146,7 @@ namespace Mono.Cecil {
using (var crypto_stream = new CryptoStream (Stream.Null, sha1, CryptoStreamMode.Write)) {
for (int i = 0; i < buffers.Length; i++) {
crypto_stream.Write (buffers [0].buffer, 0, buffers [0].length);
crypto_stream.Write (buffers [i].buffer, 0, buffers [i].length);
}
}
@ -148,12 +169,17 @@ namespace Mono.Cecil {
static partial class Mixin {
public static RSA CreateRSA (this StrongNameKeyPair key_pair)
public static RSA CreateRSA (this WriterParameters writer_parameters)
{
byte [] key;
string key_container;
if (!TryGetKeyContainer (key_pair, out key, out key_container))
if (writer_parameters.StrongNameKeyBlob != null)
return CryptoConvert.FromCapiKeyBlob (writer_parameters.StrongNameKeyBlob);
if (writer_parameters.StrongNameKeyContainer != null)
key_container = writer_parameters.StrongNameKeyContainer;
else if (!TryGetKeyContainer (writer_parameters.StrongNameKeyPair, out key, out key_container))
return CryptoConvert.FromCapiKeyBlob (key);
var parameters = new CspParameters {

View File

@ -354,6 +354,9 @@ namespace Mono.Cecil.Tests {
static string WinSdkTool (string tool)
{
var sdks = new [] {
@"Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools",
@"Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.7.2 Tools",
@"Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.7.1 Tools",
@"Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.7 Tools",
@"Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.2 Tools",
@"Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools",

View File

@ -683,5 +683,42 @@ class Program
using (var module = ModuleDefinition.ReadModule (destination, new ReaderParameters { SymbolReaderProvider = new PortablePdbReaderProvider () })) {
}
}
[Test]
public void DoubleWriteAndReadAgainModuleWithDeterministicMvid ()
{
Guid mvid1_in, mvid1_out, mvid2_in, mvid2_out;
{
const string resource = "foo.dll";
string destination = Path.GetTempFileName ();
using (var module = GetResourceModule (resource, new ReaderParameters { })) {
mvid1_in = module.Mvid;
module.Write (destination, new WriterParameters { DeterministicMvid = true });
}
using (var module = ModuleDefinition.ReadModule (destination, new ReaderParameters { })) {
mvid1_out = module.Mvid;
}
}
{
const string resource = "hello2.exe";
string destination = Path.GetTempFileName ();
using (var module = GetResourceModule (resource, new ReaderParameters { })) {
mvid2_in = module.Mvid;
module.Write (destination, new WriterParameters { DeterministicMvid = true });
}
using (var module = ModuleDefinition.ReadModule (destination, new ReaderParameters { })) {
mvid2_out = module.Mvid;
}
}
Assert.AreNotEqual (mvid1_in, mvid2_in);
Assert.AreNotEqual (mvid1_out, mvid2_out);
}
}
}

View File

@ -1,13 +1,6 @@
//-----------------------------------------------------------------------------
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the Microsoft Public License.
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//-----------------------------------------------------------------------------
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
using System.IO;
using System.Text;
@ -19,6 +12,11 @@ namespace Microsoft.Cci.Pdb {
this.buffer = new byte[capacity];
}
internal BitAccess(byte[] buffer) {
this.buffer = buffer;
offset = 0;
}
internal byte[] Buffer {
get { return buffer; }
}

View File

@ -1,13 +1,6 @@
//-----------------------------------------------------------------------------
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the Microsoft Public License.
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//-----------------------------------------------------------------------------
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
namespace Microsoft.Cci.Pdb {

View File

@ -1,32 +1,6 @@
//-----------------------------------------------------------------------------
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the Microsoft Public License.
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//-----------------------------------------------------------------------------
//
// File: CvInfo.cs
//
// Generic CodeView information definitions
//
// Structures, constants, etc. for accessing and interpreting
// CodeView information.
//
// The master copy of this file resides in the langapi project (in C++).
// All Microsoft projects are required to use the master copy without
// modification. Modification of the master version or a copy
// without consultation with all parties concerned is extremely
// risky.
//
// When this file is modified, the corresponding documentation file
// omfdeb.doc in the langapi project must be updated.
//
// This is a read-only copy of the C++ file converted to C#.
//
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
namespace Microsoft.Cci.Pdb {

View File

@ -1,13 +1,6 @@
//-----------------------------------------------------------------------------
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the Microsoft Public License.
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//-----------------------------------------------------------------------------
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
using System.IO;

View File

@ -1,13 +1,6 @@
//-----------------------------------------------------------------------------
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the Microsoft Public License.
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//-----------------------------------------------------------------------------
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
namespace Microsoft.Cci.Pdb {

View File

@ -1,13 +1,6 @@
//-----------------------------------------------------------------------------
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the Microsoft Public License.
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//-----------------------------------------------------------------------------
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
namespace Microsoft.Cci.Pdb {

View File

@ -1,13 +1,6 @@
//-----------------------------------------------------------------------------
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the Microsoft Public License.
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//-----------------------------------------------------------------------------
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
namespace Microsoft.Cci.Pdb {

View File

@ -1,13 +1,6 @@
//-----------------------------------------------------------------------------
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the Microsoft Public License.
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//-----------------------------------------------------------------------------
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
namespace Microsoft.Cci.Pdb {

View File

@ -1,13 +1,6 @@
//-----------------------------------------------------------------------------
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the Microsoft Public License.
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//-----------------------------------------------------------------------------
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
using System.Collections;

View File

@ -1,12 +1,12 @@
using System;
using System.Collections.Generic;
namespace Microsoft.Cci {
namespace Microsoft.Cci.Pdb {
/// <summary>
/// A range of CLR IL operations that comprise a lexical scope, specified as an IL offset and a length.
/// </summary>
public interface ILocalScope {
interface ILocalScope {
/// <summary>
/// The offset of the first operation in the scope.
/// </summary>
@ -22,7 +22,7 @@ namespace Microsoft.Cci {
/// A description of the lexical scope in which a namespace type has been nested. This scope is tied to a particular
/// method body, so that partial types can be accommodated.
/// </summary>
public interface INamespaceScope {
interface INamespaceScope {
/// <summary>
/// Zero or more used namespaces. These correspond to using clauses in C#.
@ -35,7 +35,7 @@ namespace Microsoft.Cci {
/// <summary>
/// A namespace that is used (imported) inside a namespace scope.
/// </summary>
public interface IUsedNamespace {
interface IUsedNamespace {
/// <summary>
/// An alias for a namespace. For example the "x" of "using x = y.z;" in C#. Empty if no alias is present.
/// </summary>
@ -50,7 +50,7 @@ namespace Microsoft.Cci {
/// <summary>
/// The name of an entity. Typically name instances come from a common pool. Within the pool no two distinct instances will have the same Value or UniqueKey.
/// </summary>
public interface IName {
interface IName {
/// <summary>
/// An integer that is unique within the pool from which the name instance has been allocated. Useful as a hashtable key.
/// </summary>

View File

@ -1,22 +1,21 @@
Microsoft Public License (Ms-PL)
The MIT License (MIT)
This license governs use of the accompanying software. If you use the software, you
accept this license. If you do not accept the license, do not use the software.
Copyright (c) Microsoft
1. Definitions
The terms "reproduce," "reproduction," "derivative works," and "distribution" have the
same meaning here as under U.S. copyright law.
A "contribution" is the original software, or any additions or changes to the software.
A "contributor" is any person that distributes its contribution under this license.
"Licensed patents" are a contributor's patent claims that read directly on its contribution.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
2. Grant of Rights
(A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.
(B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
3. Conditions and Limitations
(A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
(B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your patent license from such contributor to the software ends automatically.
(C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution notices that are present in the software.
(D) If you distribute any portion of the software in source code form, you may do so only under this license by including a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object code form, you may only do so under a license that complies with this license.
(E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular purpose and non-infringement.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -1,13 +1,6 @@
//-----------------------------------------------------------------------------
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the Microsoft Public License.
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//-----------------------------------------------------------------------------
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
namespace Microsoft.Cci.Pdb {

View File

@ -1,22 +1,22 @@
//-----------------------------------------------------------------------------
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the Microsoft Public License.
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//-----------------------------------------------------------------------------
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
using System.Runtime.InteropServices;
namespace Microsoft.Cci.Pdb {
/// <summary />
internal class PdbConstant {
internal string name;
internal uint token;
internal object value;
internal PdbConstant(string name, uint token, object value) {
this.name = name;
this.token = token;
this.value = value;
}
internal PdbConstant(BitAccess bits) {
bits.ReadUInt32(out this.token);
byte tag1;

View File

@ -1,13 +1,6 @@
//-----------------------------------------------------------------------------
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the Microsoft Public License.
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//-----------------------------------------------------------------------------
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
using System.IO;

View File

@ -1,13 +1,6 @@
//-----------------------------------------------------------------------------
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the Microsoft Public License.
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//-----------------------------------------------------------------------------
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
using System.IO;

View File

@ -1,29 +1,40 @@
//-----------------------------------------------------------------------------
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the Microsoft Public License.
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//-----------------------------------------------------------------------------
using System;
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using Mono.Cecil.Cil;
namespace Microsoft.Cci.Pdb {
internal class PdbFile {
/// <summary>
/// GUID of the Basic source language.
/// </summary>
private static readonly Guid BasicLanguageGuid = new Guid(974311608, -15764, 4560, 180, 66, 0, 160, 36, 74, 29, 210);
private PdbFile() // This class can't be instantiated.
{
}
static void LoadGuidStream(BitAccess bits, out Guid doctype, out Guid language, out Guid vendor) {
static void LoadInjectedSourceInformation(BitAccess bits, out Guid doctype, out Guid language, out Guid vendor, out Guid checksumAlgo, out byte[] checksum) {
int checksumSize;
int injectedSourceSize;
checksum = null;
bits.ReadGuid(out language);
bits.ReadGuid(out vendor);
bits.ReadGuid(out doctype);
bits.ReadGuid(out checksumAlgo);
bits.ReadInt32(out checksumSize);
bits.ReadInt32(out injectedSourceSize);
if (checksumSize > 0) {
checksum = new byte[checksumSize];
bits.ReadBytes(checksum);
}
}
static Dictionary<string, int> LoadNameIndex(BitAccess bits, out int age, out Guid guid) {
@ -131,11 +142,11 @@ namespace Microsoft.Cci.Pdb {
return ht;
}
private static PdbFunction match = new PdbFunction();
private static int FindFunction(PdbFunction[] funcs, ushort sec, uint off) {
var match = new PdbFunction {
segment = sec,
address = off,
};
match.segment = sec;
match.address = off;
return Array.BinarySearch(funcs, match, PdbFunction.byAddress);
}
@ -146,11 +157,13 @@ namespace Microsoft.Cci.Pdb {
MsfDirectory dir,
Dictionary<string, int> nameIndex,
PdbReader reader,
uint limit) {
uint limit,
Dictionary<string, PdbSource> sourceCache)
{
Array.Sort(funcs, PdbFunction.byAddressAndToken);
int begin = bits.Position;
IntHashTable checks = ReadSourceFileInfo(bits, limit, names, dir, nameIndex, reader);
IntHashTable checks = ReadSourceFileInfo(bits, limit, names, dir, nameIndex, reader, sourceCache);
// Read the lines next.
bits.Position = begin;
@ -213,6 +226,11 @@ namespace Microsoft.Cci.Pdb {
bits.ReadUInt32(out file.linsiz); // Size of payload.
PdbSource src = (PdbSource)checks[(int)file.index];
if (src.language.Equals(BasicLanguageGuid))
{
func.AdjustVisualBasicScopes();
}
PdbLines tmp = new PdbLines(src, file.count);
func.lines[block++] = tmp;
PdbLine[] lines = tmp.lines;
@ -258,7 +276,9 @@ namespace Microsoft.Cci.Pdb {
bool readStrings,
MsfDirectory dir,
Dictionary<string, int> nameIndex,
PdbReader reader) {
PdbReader reader,
Dictionary<string, PdbSource> sourceCache)
{
PdbFunction[] funcs = null;
bits.Position = 0;
@ -276,7 +296,8 @@ namespace Microsoft.Cci.Pdb {
if (funcs != null) {
bits.Position = info.cbSyms + info.cbOldLines;
LoadManagedLines(funcs, names, bits, dir, nameIndex, reader,
(uint)(info.cbSyms + info.cbOldLines + info.cbLines));
(uint)(info.cbSyms + info.cbOldLines + info.cbLines),
sourceCache);
for (int i = 0; i < funcs.Length; i++) {
funcList.Add(funcs[i]);
@ -337,32 +358,43 @@ namespace Microsoft.Cci.Pdb {
bits.Position = end;
}
internal static PdbFunction[] LoadFunctions(Stream read, out Dictionary<uint, PdbTokenLine> tokenToSourceMapping, out string sourceServerData, out int age, out Guid guid) {
tokenToSourceMapping = new Dictionary<uint, PdbTokenLine>();
BitAccess bits = new BitAccess(512 * 1024);
internal static PdbInfo LoadFunctions(Stream read) {
PdbInfo pdbInfo = new PdbInfo();
pdbInfo.TokenToSourceMapping = new Dictionary<uint, PdbTokenLine>();
BitAccess bits = new BitAccess(64 * 1024);
PdbFileHeader head = new PdbFileHeader(read, bits);
PdbReader reader = new PdbReader(read, head.pageSize);
MsfDirectory dir = new MsfDirectory(reader, head, bits);
DbiModuleInfo[] modules = null;
DbiDbgHdr header;
Dictionary<string, PdbSource> sourceCache = new Dictionary<string, PdbSource>();
dir.streams[1].Read(reader, bits);
Dictionary<string, int> nameIndex = LoadNameIndex(bits, out age, out guid);
Dictionary<string, int> nameIndex = LoadNameIndex(bits, out pdbInfo.Age, out pdbInfo.Guid);
int nameStream;
if (!nameIndex.TryGetValue("/NAMES", out nameStream)) {
throw new PdbException("No `name' stream");
throw new PdbException("Could not find the '/NAMES' stream: the PDB file may be a public symbol file instead of a private symbol file");
}
dir.streams[nameStream].Read(reader, bits);
IntHashTable names = LoadNameStream(bits);
int srcsrvStream;
if (!nameIndex.TryGetValue("SRCSRV", out srcsrvStream))
sourceServerData = string.Empty;
pdbInfo.SourceServerData = string.Empty;
else {
DataStream dataStream = dir.streams[srcsrvStream];
byte[] bytes = new byte[dataStream.contentSize];
dataStream.Read(reader, bits);
sourceServerData = bits.ReadBString(bytes.Length);
pdbInfo.SourceServerData = bits.ReadBString(bytes.Length);
}
int sourceLinkStream;
if (nameIndex.TryGetValue("SOURCELINK", out sourceLinkStream)) {
DataStream dataStream = dir.streams[sourceLinkStream];
pdbInfo.SourceLinkData = new byte[dataStream.contentSize];
dataStream.Read(reader, bits);
bits.ReadBytes(pdbInfo.SourceLinkData);
}
dir.streams[3].Read(reader, bits);
@ -376,10 +408,10 @@ namespace Microsoft.Cci.Pdb {
if (module.stream > 0) {
dir.streams[module.stream].Read(reader, bits);
if (module.moduleName == "TokenSourceLineInfo") {
LoadTokenToSourceInfo(bits, module, names, dir, nameIndex, reader, tokenToSourceMapping);
LoadTokenToSourceInfo(bits, module, names, dir, nameIndex, reader, pdbInfo.TokenToSourceMapping, sourceCache);
continue;
}
LoadFuncsFromDbiModule(bits, module, names, funcList, true, dir, nameIndex, reader);
LoadFuncsFromDbiModule(bits, module, names, funcList, true, dir, nameIndex, reader, sourceCache);
}
}
}
@ -400,11 +432,12 @@ namespace Microsoft.Cci.Pdb {
//
Array.Sort(funcs, PdbFunction.byAddressAndToken);
//Array.Sort(funcs, PdbFunction.byToken);
return funcs;
pdbInfo.Functions = funcs;
return pdbInfo;
}
private static void LoadTokenToSourceInfo(BitAccess bits, DbiModuleInfo module, IntHashTable names, MsfDirectory dir,
Dictionary<string, int> nameIndex, PdbReader reader, Dictionary<uint, PdbTokenLine> tokenToSourceMapping) {
Dictionary<string, int> nameIndex, PdbReader reader, Dictionary<uint, PdbTokenLine> tokenToSourceMapping, Dictionary<string,PdbSource> sourceCache) {
bits.Position = 0;
int sig;
bits.ReadInt32(out sig);
@ -477,15 +510,18 @@ namespace Microsoft.Cci.Pdb {
bits.Position = module.cbSyms + module.cbOldLines;
int limit = module.cbSyms + module.cbOldLines + module.cbLines;
IntHashTable sourceFiles = ReadSourceFileInfo(bits, (uint)limit, names, dir, nameIndex, reader);
IntHashTable sourceFiles = ReadSourceFileInfo(bits, (uint)limit, names, dir, nameIndex, reader, sourceCache);
foreach (var tokenLine in tokenToSourceMapping.Values) {
tokenLine.sourceFile = (PdbSource)sourceFiles[(int)tokenLine.file_id];
}
}
public static readonly Guid SymDocumentType_Text = new Guid(1518771467, 26129, 4563, 189, 42, 0, 0, 248, 8, 73, 189);
private static IntHashTable ReadSourceFileInfo(BitAccess bits, uint limit, IntHashTable names, MsfDirectory dir,
Dictionary<string, int> nameIndex, PdbReader reader) {
Dictionary<string, int> nameIndex, PdbReader reader, Dictionary<string, PdbSource> sourceCache)
{
IntHashTable checks = new IntHashTable();
int begin = bits.Position;
@ -508,17 +544,26 @@ namespace Microsoft.Cci.Pdb {
bits.ReadUInt8(out chk.type);
string name = (string)names[(int)chk.name];
int guidStream;
Guid doctypeGuid = DocumentType.Text.ToGuid();
Guid languageGuid = Guid.Empty;
Guid vendorGuid = Guid.Empty;
if (nameIndex.TryGetValue("/SRC/FILES/"+name.ToUpperInvariant(), out guidStream)) {
var guidBits = new BitAccess(0x100);
dir.streams[guidStream].Read(reader, guidBits);
LoadGuidStream(guidBits, out doctypeGuid, out languageGuid, out vendorGuid);
}
PdbSource src = new PdbSource(/*(uint)ni,*/ name, doctypeGuid, languageGuid, vendorGuid);
PdbSource src;
if (!sourceCache.TryGetValue(name, out src))
{
int guidStream;
Guid doctypeGuid = SymDocumentType_Text;
Guid languageGuid = Guid.Empty;
Guid vendorGuid = Guid.Empty;
Guid checksumAlgoGuid = Guid.Empty;
byte[] checksum = null;
if (nameIndex.TryGetValue("/SRC/FILES/" + name.ToUpperInvariant(), out guidStream))
{
var guidBits = new BitAccess(0x100);
dir.streams[guidStream].Read(reader, guidBits);
LoadInjectedSourceInformation(guidBits, out doctypeGuid, out languageGuid, out vendorGuid, out checksumAlgoGuid, out checksum);
}
src = new PdbSource(name, doctypeGuid, languageGuid, vendorGuid, checksumAlgoGuid, checksum);
sourceCache.Add(name, src);
}
checks.Add(ni, src);
bits.Position += chk.len;
bits.Align(4);

View File

@ -1,19 +1,20 @@
//-----------------------------------------------------------------------------
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the Microsoft Public License.
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//-----------------------------------------------------------------------------
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
using System.IO;
using System.Linq;
using System.Text;
namespace Microsoft.Cci.Pdb {
internal class PdbFileHeader {
private readonly byte[] windowsPdbMagic = new byte[32] {
0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66, // "Microsof"
0x74, 0x20, 0x43, 0x2F, 0x43, 0x2B, 0x2B, 0x20, // "t C/C++ "
0x4D, 0x53, 0x46, 0x20, 0x37, 0x2E, 0x30, 0x30, // "MSF 7.00"
0x0D, 0x0A, 0x1A, 0x44, 0x53, 0x00, 0x00, 0x00 // "^^^DS^^^"
};
//internal PdbFileHeader(int pageSize) {
// this.magic = new byte[32] {
// 0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66, // "Microsof"
@ -24,8 +25,6 @@ namespace Microsoft.Cci.Pdb {
// this.pageSize = pageSize;
//}
const string MAGIC = "Microsoft C/C++ MSF 7.00";
internal PdbFileHeader(Stream reader, BitAccess bits) {
bits.MinCapacity(56);
reader.Seek(0, SeekOrigin.Begin);
@ -39,18 +38,20 @@ namespace Microsoft.Cci.Pdb {
bits.ReadInt32(out this.directorySize); // 44..47
bits.ReadInt32(out this.zero); // 48..51
if (Magic != MAGIC) {
throw new InvalidOperationException("Magic is wrong.");
if (!this.magic.SequenceEqual(windowsPdbMagic))
{
throw new PdbException("The PDB file is not recognized as a Windows PDB file");
}
int directoryPages = ((((directorySize + pageSize - 1) / pageSize) * 4) + pageSize - 1) / pageSize;
this.directoryRoot = new int[directoryPages];
bits.FillBuffer(reader, directoryPages * 4);
bits.ReadInt32(this.directoryRoot);
}
string Magic {
get { return StringFromBytesUTF8(magic, 0, MAGIC.Length); }
}
//internal string Magic {
// get { return StringFromBytesUTF8(magic); }
//}
//internal void Write(Stream writer, BitAccess bits) {
// bits.MinCapacity(pageSize);
@ -68,18 +69,18 @@ namespace Microsoft.Cci.Pdb {
//////////////////////////////////////////////////// Helper Functions.
//
static string StringFromBytesUTF8(byte[] bytes) {
return StringFromBytesUTF8(bytes, 0, bytes.Length);
}
//internal static string StringFromBytesUTF8(byte[] bytes) {
// return StringFromBytesUTF8(bytes, 0, bytes.Length);
//}
static string StringFromBytesUTF8(byte[] bytes, int offset, int length) {
for (int i = 0; i < length; i++) {
if (bytes[offset + i] < ' ') {
length = i;
}
}
return Encoding.UTF8.GetString(bytes, offset, length);
}
//internal static string StringFromBytesUTF8(byte[] bytes, int offset, int length) {
// for (int i = 0; i < length; i++) {
// if (bytes[offset + i] < ' ') {
// length = i;
// }
// }
// return Encoding.UTF8.GetString(bytes, offset, length);
//}
////////////////////////////////////////////////////////////// Fields.
//

View File

@ -1,17 +1,12 @@
//-----------------------------------------------------------------------------
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the Microsoft Public License.
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//-----------------------------------------------------------------------------
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
using System.Collections;
using System.Collections.Generic;
#pragma warning disable 1591 // TODO: doc comments
namespace Microsoft.Cci.Pdb {
internal class PdbFunction {
static internal readonly Guid msilMetaData = new Guid(0xc6ea3fc9, 0x59b3, 0x49d6, 0xbc, 0x25,
@ -43,6 +38,13 @@ namespace Microsoft.Cci.Pdb {
internal List<ILocalScope>/*?*/ iteratorScopes;
internal PdbSynchronizationInformation/*?*/ synchronizationInformation;
/// <summary>
/// Flag saying whether the method has been identified as a product of VB compilation using
/// the legacy Windows PDB symbol format, in which case scope ends need to be shifted by 1
/// due to different semantics of scope limits in VB and C# compilers.
/// </summary>
private bool visualBasicScopesAdjusted = false;
private static string StripNamespace(string module) {
int li = module.LastIndexOf('.');
if (li > 0) {
@ -51,6 +53,36 @@ namespace Microsoft.Cci.Pdb {
return module;
}
/// <summary>
/// When the Windows PDB reader identifies a PdbFunction as having 'Basic' as its source language,
/// it calls this method which adjusts all scopes by adding 1 to their lengths to compensate
/// for different behavior of VB vs. the C# compiler w.r.t. emission of scope info.
/// </summary>
internal void AdjustVisualBasicScopes()
{
if (!visualBasicScopesAdjusted)
{
visualBasicScopesAdjusted = true;
// Don't adjust root scope as that one is correct
foreach (PdbScope scope in scopes)
{
AdjustVisualBasicScopes(scope.scopes);
}
}
}
/// <summary>
/// Recursively update the entire scope tree by adding 1 to the length of each scope.
/// </summary>
private void AdjustVisualBasicScopes(PdbScope[] scopes)
{
foreach (PdbScope scope in scopes)
{
scope.length++;
AdjustVisualBasicScopes(scope.scopes);
}
}
internal static PdbFunction[] LoadManagedFunctions(/*string module,*/
BitAccess bits, uint limit,
@ -260,15 +292,7 @@ namespace Microsoft.Cci.Pdb {
if (oem.idOem == msilMetaData) {
string name = bits.ReadString();
if (name == "MD2") {
byte version;
bits.ReadUInt8(out version);
if (version == 4) {
byte count;
bits.ReadUInt8(out count);
bits.Align(4);
while (count-- > 0)
this.ReadCustomMetadata(bits);
}
ReadMD2CustomMetadata(bits);
} else if (name == "asyncMethodInfo") {
this.synchronizationInformation = new PdbSynchronizationInformation(bits);
}
@ -338,27 +362,47 @@ namespace Microsoft.Cci.Pdb {
}
}
private void ReadCustomMetadata(BitAccess bits) {
int savedPosition = bits.Position;
internal void ReadMD2CustomMetadata(BitAccess bits)
{
byte version;
bits.ReadUInt8(out version);
if (version != 4) {
throw new PdbDebugException("Unknown custom metadata item version: {0}", version);
if (version == 4) {
byte count;
bits.ReadUInt8(out count);
bits.Align(4);
while (count-- > 0)
this.ReadCustomMetadata(bits);
}
byte kind;
bits.ReadUInt8(out kind);
bits.Align(4);
uint numberOfBytesInItem;
bits.ReadUInt32(out numberOfBytesInItem);
switch (kind) {
case 0: this.ReadUsingInfo(bits); break;
case 1: this.ReadForwardInfo(bits); break;
case 2: break; // this.ReadForwardedToModuleInfo(bits); break;
case 3: this.ReadIteratorLocals(bits); break;
case 4: this.ReadForwardIterator(bits); break;
// TODO: handle unknown custom metadata, 5 & 6 are new with roslyn, see https://roslyn.codeplex.com/workitem/54
}
bits.Position = savedPosition+(int)numberOfBytesInItem;
}
private void ReadCustomMetadata(BitAccess bits)
{
int savedPosition = bits.Position;
byte version;
bits.ReadUInt8(out version);
byte kind;
bits.ReadUInt8(out kind);
bits.Position += 2; // 2-bytes padding
uint numberOfBytesInItem;
bits.ReadUInt32(out numberOfBytesInItem);
if (version == 4)
{
switch (kind)
{
case 0: this.ReadUsingInfo(bits); break;
case 1: this.ReadForwardInfo(bits); break;
case 2: break; // this.ReadForwardedToModuleInfo(bits); break;
case 3: this.ReadIteratorLocals(bits); break;
case 4: this.ReadForwardIterator(bits); break;
case 5: break; // dynamic locals - see http://index/#Microsoft.VisualStudio.LanguageServices/Shared/CustomDebugInfoReader.cs,a3031f7681d76e93
case 6: break; // EnC data
case 7: break; // EnC data for lambdas and closures
// ignore any other unknown record types that may be added in future, instead of throwing an exception
// see more details here: https://github.com/tmat/roslyn/blob/portable-pdb/docs/specs/PortablePdb-Metadata.md
default: break; // throw new PdbDebugException("Unknown custom metadata item kind: {0}", kind);
}
}
bits.Position = savedPosition + (int)numberOfBytesInItem;
}
private void ReadForwardIterator(BitAccess bits) {

View File

@ -0,0 +1,43 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
using System.Collections.Generic;
namespace Microsoft.Cci.Pdb {
/// <summary>
/// This class represents the information read from a PDB file (both legacy Windows and Portable).
/// </summary>
internal class PdbInfo {
/// <summary>
/// Enumeration of per-function information contained in the PDB file.
/// </summary>
public PdbFunction[] Functions;
/// <summary>
/// Mapping from tokens to source files and line numbers.
/// </summary>
public Dictionary<uint, PdbTokenLine> TokenToSourceMapping;
/// <summary>
/// Source server data information.
/// </summary>
public string SourceServerData;
/// <summary>
/// Age of the PDB file is used to match the PDB against the PE binary.
/// </summary>
public int Age;
/// <summary>
/// GUID of the PDB file is used to match the PDB against the PE binary.
/// </summary>
public Guid Guid;
/// <summary>
/// Source link data information.
/// </summary>
public byte[] SourceLinkData;
}
}

View File

@ -1,13 +1,6 @@
//-----------------------------------------------------------------------------
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the Microsoft Public License.
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//-----------------------------------------------------------------------------
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
namespace Microsoft.Cci.Pdb {

View File

@ -1,13 +1,6 @@
//-----------------------------------------------------------------------------
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the Microsoft Public License.
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//-----------------------------------------------------------------------------
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
namespace Microsoft.Cci.Pdb {

View File

@ -1,13 +1,6 @@
//-----------------------------------------------------------------------------
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the Microsoft Public License.
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//-----------------------------------------------------------------------------
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
using System.IO;

View File

@ -1,13 +1,6 @@
//-----------------------------------------------------------------------------
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the Microsoft Public License.
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//-----------------------------------------------------------------------------
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
namespace Microsoft.Cci.Pdb {
@ -22,16 +15,21 @@ namespace Microsoft.Cci.Pdb {
internal uint offset;
internal uint length;
internal PdbScope(uint address, uint length, PdbSlot[] slots, PdbConstant[] constants, string[] usedNamespaces) {
internal PdbScope(uint address, uint offset, uint length, PdbSlot[] slots, PdbConstant[] constants, string[] usedNamespaces) {
this.constants = constants;
this.slots = slots;
this.scopes = new PdbScope[0];
this.usedNamespaces = usedNamespaces;
this.address = address;
this.offset = 0;
this.offset = offset;
this.length = length;
}
internal PdbScope(uint address, uint length, PdbSlot[] slots, PdbConstant[] constants, string[] usedNamespaces)
: this(address, 0, length, slots, constants, usedNamespaces)
{
}
internal PdbScope(uint funcOffset, BlockSym32 block, BitAccess bits, out uint typind) {
//this.segment = block.seg;
this.address = block.off;

View File

@ -1,13 +1,6 @@
//-----------------------------------------------------------------------------
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the Microsoft Public License.
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//-----------------------------------------------------------------------------
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
namespace Microsoft.Cci.Pdb {
@ -19,6 +12,14 @@ namespace Microsoft.Cci.Pdb {
//internal uint segment;
//internal uint address;
internal PdbSlot(uint slot, uint typeToken, string name, ushort flags)
{
this.slot = slot;
this.typeToken = typeToken;
this.name = name;
this.flags = flags;
}
internal PdbSlot(BitAccess bits) {
AttrSlotSym slot;

View File

@ -1,13 +1,6 @@
//-----------------------------------------------------------------------------
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the Microsoft Public License.
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//-----------------------------------------------------------------------------
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
namespace Microsoft.Cci.Pdb {
@ -17,13 +10,17 @@ namespace Microsoft.Cci.Pdb {
internal Guid doctype;
internal Guid language;
internal Guid vendor;
internal Guid checksumAlgorithm;
internal byte[] checksum;
internal PdbSource(/*uint index, */string name, Guid doctype, Guid language, Guid vendor) {
internal PdbSource(/*uint index, */string name, Guid doctype, Guid language, Guid vendor, Guid checksumAlgorithm, byte[] checksum) {
//this.index = index;
this.name = name;
this.doctype = doctype;
this.language = language;
this.vendor = vendor;
this.checksumAlgorithm = checksumAlgorithm;
this.checksum = checksum;
}
}
}

View File

@ -1,13 +1,6 @@
//-----------------------------------------------------------------------------
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the Microsoft Public License.
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//-----------------------------------------------------------------------------
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
namespace Microsoft.Cci.Pdb {

View File

@ -1,16 +1,13 @@
//-----------------------------------------------------------------------------
//
// Copyright (C) Microsoft Corporation. All Rights Reserved.
//
//-----------------------------------------------------------------------------
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
using System.Collections.Generic;
using System.IO;
using Microsoft.Cci;
using Microsoft.Cci.Pdb;
using System.Text;
namespace Microsoft.Cci {
#pragma warning disable 1591 // TODO: doc comments
namespace Microsoft.Cci.Pdb {
internal sealed class PdbIteratorScope : ILocalScope {

View File

@ -6,6 +6,7 @@
// Licensed under the MIT/X11 license.
//
using System;
using System.Runtime.InteropServices;
namespace Mono.Cecil.Pdb {
@ -14,5 +15,7 @@ namespace Mono.Cecil.Pdb {
[InterfaceType (ComInterfaceType.InterfaceIsIUnknown)]
[ComImport]
interface ISymUnmanagedDocumentWriter {
void SetSource (uint sourceSize, [MarshalAs (UnmanagedType.LPArray, SizeParamIndex = 0)] byte [] source);
void SetCheckSum (Guid algorithmId, uint checkSumSize, [MarshalAs (UnmanagedType.LPArray, SizeParamIndex = 1)] byte [] checkSum);
}
}

View File

@ -90,17 +90,12 @@ namespace Mono.Cecil.Pdb {
bool PopulateFunctions ()
{
using (pdb_file) {
Dictionary<uint, PdbTokenLine> tokenToSourceMapping;
string sourceServerData;
int age;
Guid guid;
var info = PdbFile.LoadFunctions (pdb_file.value);
var funcs = PdbFile.LoadFunctions (pdb_file.value, out tokenToSourceMapping, out sourceServerData, out age, out guid);
if (this.guid != guid)
if (this.guid != info.Guid)
return false;
foreach (PdbFunction function in funcs)
foreach (PdbFunction function in info.Functions)
functions.Add (function.token, function);
}
@ -357,9 +352,11 @@ namespace Mono.Cecil.Pdb {
return document;
document = new Document (name) {
Language = source.language.ToLanguage (),
LanguageVendor = source.vendor.ToVendor (),
Type = source.doctype.ToType (),
LanguageGuid = source.language,
LanguageVendorGuid = source.vendor,
TypeGuid = source.doctype,
HashAlgorithmGuid = source.checksumAlgorithm,
Hash = source.checksum,
};
documents.Add (name, document);
return document;

View File

@ -246,6 +246,9 @@ namespace Mono.Cecil.Pdb {
document.LanguageVendorGuid,
document.TypeGuid);
if (!document.Hash.IsNullOrEmpty ())
doc_writer.SetCheckSum (document.HashAlgorithmGuid, document.Hash);
documents [document.Url] = doc_writer;
return doc_writer;
}

View File

@ -13,16 +13,26 @@ namespace Mono.Cecil.Pdb
{
internal class SymDocumentWriter
{
readonly ISymUnmanagedDocumentWriter m_unmanagedDocumentWriter;
readonly ISymUnmanagedDocumentWriter writer;
public SymDocumentWriter (ISymUnmanagedDocumentWriter unmanagedDocumentWriter)
public ISymUnmanagedDocumentWriter Writer
{
m_unmanagedDocumentWriter = unmanagedDocumentWriter;
get { return writer; }
}
public ISymUnmanagedDocumentWriter GetUnmanaged ()
public SymDocumentWriter (ISymUnmanagedDocumentWriter writer)
{
return m_unmanagedDocumentWriter;
this.writer = writer;
}
public void SetSource (byte [] source)
{
writer.SetSource ((uint) source.Length, source);
}
public void SetCheckSum (Guid hashAlgo, byte [] checkSum)
{
writer.SetCheckSum (hashAlgo, (uint) checkSum.Length, checkSum);
}
}
}

View File

@ -28,7 +28,7 @@ namespace Mono.Cecil.Pdb
static Guid s_symUnmangedWriterIID = new Guid("0b97726e-9e6d-4f05-9a26-424022093caa");
static Guid s_CorSymWriter_SxS_ClassID = new Guid ("108296c1-281e-11d3-bd22-0000f80849bd");
readonly ISymUnmanagedWriter2 m_writer;
readonly ISymUnmanagedWriter2 writer;
readonly Collection<ISymUnmanagedDocumentWriter> documents;
public SymWriter ()
@ -36,7 +36,7 @@ namespace Mono.Cecil.Pdb
object objWriter;
CoCreateInstance (ref s_CorSymWriter_SxS_ClassID, null, 1, ref s_symUnmangedWriterIID, out objWriter);
m_writer = (ISymUnmanagedWriter2) objWriter;
writer = (ISymUnmanagedWriter2) objWriter;
documents = new Collection<ISymUnmanagedDocumentWriter> ();
}
@ -45,10 +45,10 @@ namespace Mono.Cecil.Pdb
int size;
// get size of debug info
m_writer.GetDebugInfo (out idd, 0, out size, null);
writer.GetDebugInfo (out idd, 0, out size, null);
byte[] debug_info = new byte[size];
m_writer.GetDebugInfo (out idd, size, out size, debug_info);
writer.GetDebugInfo (out idd, size, out size, debug_info);
return debug_info;
}
@ -63,23 +63,23 @@ namespace Mono.Cecil.Pdb
int startOffset,
int endOffset)
{
m_writer.DefineLocalVariable2 (name, (int)attributes, sigToken, 1 /* ILOffset*/, addr1, addr2, addr3, startOffset, endOffset);
writer.DefineLocalVariable2 (name, (int)attributes, sigToken, 1 /* ILOffset*/, addr1, addr2, addr3, startOffset, endOffset);
}
public void DefineConstant2 (string name, object value, int sigToken)
{
if (value == null) {
m_writer.DefineConstant2 (name, 0, sigToken);
writer.DefineConstant2 (name, 0, sigToken);
return;
}
m_writer.DefineConstant2 (name, value, sigToken);
writer.DefineConstant2 (name, value, sigToken);
}
public void Close ()
{
m_writer.Close ();
Marshal.ReleaseComObject (m_writer);
writer.Close ();
Marshal.ReleaseComObject (writer);
foreach (var document in documents)
Marshal.ReleaseComObject (document);
@ -87,69 +87,69 @@ namespace Mono.Cecil.Pdb
public void CloseMethod ()
{
m_writer.CloseMethod ();
writer.CloseMethod ();
}
public void CloseNamespace ()
{
m_writer.CloseNamespace ();
writer.CloseNamespace ();
}
public void CloseScope (int endOffset)
{
m_writer.CloseScope (endOffset);
writer.CloseScope (endOffset);
}
public SymDocumentWriter DefineDocument (string url, Guid language, Guid languageVendor, Guid documentType)
{
ISymUnmanagedDocumentWriter unmanagedDocumentWriter;
m_writer.DefineDocument (url, ref language, ref languageVendor, ref documentType, out unmanagedDocumentWriter);
ISymUnmanagedDocumentWriter doc_writer;
writer.DefineDocument (url, ref language, ref languageVendor, ref documentType, out doc_writer);
documents.Add (unmanagedDocumentWriter);
return new SymDocumentWriter (unmanagedDocumentWriter);
documents.Add (doc_writer);
return new SymDocumentWriter (doc_writer);
}
public void DefineSequencePoints (SymDocumentWriter document, int[] offsets, int[] lines, int[] columns, int[] endLines, int[] endColumns)
{
m_writer.DefineSequencePoints (document.GetUnmanaged(), offsets.Length, offsets, lines, columns, endLines, endColumns);
writer.DefineSequencePoints (document.Writer, offsets.Length, offsets, lines, columns, endLines, endColumns);
}
public void Initialize (object emitter, string filename, bool fFullBuild)
{
m_writer.Initialize (emitter, filename, null, fFullBuild);
writer.Initialize (emitter, filename, null, fFullBuild);
}
public void SetUserEntryPoint (int methodToken)
{
m_writer.SetUserEntryPoint (methodToken);
writer.SetUserEntryPoint (methodToken);
}
public void OpenMethod (int methodToken)
{
m_writer.OpenMethod (methodToken);
writer.OpenMethod (methodToken);
}
public void OpenNamespace (string name)
{
m_writer.OpenNamespace (name);
writer.OpenNamespace (name);
}
public int OpenScope (int startOffset)
{
int result;
m_writer.OpenScope (startOffset, out result);
writer.OpenScope (startOffset, out result);
return result;
}
public void UsingNamespace (string fullName)
{
m_writer.UsingNamespace (fullName);
writer.UsingNamespace (fullName);
}
public void DefineCustomMetadata (string name, byte [] metadata)
{
var handle = GCHandle.Alloc (metadata, GCHandleType.Pinned);
m_writer.SetSymAttribute (0, name, (uint) metadata.Length, handle.AddrOfPinnedObject ());
writer.SetSymAttribute (0, name, (uint) metadata.Length, handle.AddrOfPinnedObject ());
handle.Free ();
}
}

View File

@ -99,7 +99,8 @@ namespace Mono.Cecil.Tests {
Assert.AreEqual (@"c:\sources\cecil\symbols\Mono.Cecil.Pdb\Test\Resources\assemblies\test.cs", document.Url);
Assert.AreEqual (DocumentType.Text, document.Type);
Assert.AreEqual (DocumentHashAlgorithm.None, document.HashAlgorithm);
Assert.AreEqual (DocumentHashAlgorithm.MD5, document.HashAlgorithm);
Assert.AreEqual (new byte [] { 228, 176, 152, 54, 82, 238, 238, 68, 237, 156, 5, 142, 118, 160, 118, 245 }, document.Hash);
Assert.AreEqual (DocumentLanguage.CSharp, document.Language);
Assert.AreEqual (DocumentLanguageVendor.Microsoft, document.LanguageVendor);
}, readOnly: !Platform.HasNativePdbSupport, symbolReaderProvider: typeof(PdbReaderProvider), symbolWriterProvider: typeof(PdbWriterProvider));
@ -119,7 +120,8 @@ namespace Mono.Cecil.Tests {
Assert.AreEqual (@"c:\tmp\VBConsApp\Program.vb", document.Url);
Assert.AreEqual (DocumentType.Text, document.Type);
Assert.AreEqual (DocumentHashAlgorithm.None, document.HashAlgorithm);
Assert.AreEqual (DocumentHashAlgorithm.MD5, document.HashAlgorithm);
Assert.AreEqual (new byte [] { 184, 188, 100, 23, 27, 123, 187, 201, 175, 206, 110, 198, 242, 139, 154, 119 }, document.Hash);
Assert.AreEqual (DocumentLanguage.Basic, document.Language);
Assert.AreEqual (DocumentLanguageVendor.Microsoft, document.LanguageVendor);
}, readOnly: !Platform.HasNativePdbSupport, symbolReaderProvider: typeof(PdbReaderProvider), symbolWriterProvider: typeof(PdbWriterProvider));

View File

@ -30,21 +30,21 @@ internal static partial class Interop
internal byte* Name;
internal int NameLength;
internal NodeType InodeType;
internal const int NameBufferSize = 256;
internal const int NameBufferSize = 256; // sizeof(dirent->d_name) == NAME_MAX + 1
internal ReadOnlySpan<char> GetName(Span<char> buffer)
{
Debug.Assert(buffer.Length >= Encoding.UTF8.GetMaxCharCount(NameBufferSize - 1), "should have enough space for the max file name");
// -1 for null terminator (buffer will not include one),
// and -1 because GetMaxCharCount pessimistically assumes the buffer may start with a partial surrogate
Debug.Assert(buffer.Length >= Encoding.UTF8.GetMaxCharCount(NameBufferSize - 1 - 1));
Debug.Assert(Name != null, "should not have a null name");
ReadOnlySpan<byte> nameBytes = (NameLength == -1)
// In this case the struct was allocated via struct dirent *readdir(DIR *dirp);
? new ReadOnlySpan<byte>(Name, new ReadOnlySpan<byte>(Name, NameBufferSize - 1).IndexOf<byte>(0))
? new ReadOnlySpan<byte>(Name, new ReadOnlySpan<byte>(Name, NameBufferSize).IndexOf<byte>(0))
: new ReadOnlySpan<byte>(Name, NameLength);
Debug.Assert(nameBytes.Length > 0, "we shouldn't have gotten a garbage value from the OS");
if (nameBytes.Length == 0)
return buffer.Slice(0, 0);
int charCount = Encoding.UTF8.GetChars(nameBytes, buffer);
ReadOnlySpan<char> value = buffer.Slice(0, charCount);

View File

@ -33,6 +33,7 @@ internal static partial class Interop
internal long BirthTimeNsec;
internal long Dev;
internal long Ino;
internal uint UserFlags;
}
internal static class FileTypes

View File

@ -0,0 +1,26 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Runtime.InteropServices;
internal static partial class Interop
{
internal static partial class Sys
{
[Flags]
internal enum UserFlags : uint
{
UF_HIDDEN = 0x8000
}
[DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_LChflags", SetLastError = true)]
internal static extern int LChflags(string path, uint flags);
internal static readonly bool CanSetHiddenFlag = (LChflagsCanSetHiddenFlag() != 0);
[DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_LChflagsCanSetHiddenFlag")]
private static extern int LChflagsCanSetHiddenFlag();
}
}

View File

@ -33,6 +33,7 @@ internal static partial class Interop
internal long BirthTimeNsec;
internal long Dev;
internal long Ino;
internal uint UserFlags;
}
internal static class FileTypes

View File

@ -16,6 +16,8 @@
#cmakedefine01 HAVE_STAT_TIMESPEC
#cmakedefine01 HAVE_STAT_TIM
#cmakedefine01 HAVE_STAT_NSEC
#cmakedefine01 HAVE_STAT_FLAGS
#cmakedefine01 HAVE_LCHFLAGS
#cmakedefine01 HAVE_GNU_STRERROR_R
#cmakedefine01 HAVE_READDIR_R
#cmakedefine01 HAVE_DIRENT_NAME_LEN

View File

@ -166,6 +166,12 @@ static void ConvertFileStatus(const struct stat_* src, struct FileStatus* dst)
dst->BirthTime = 0;
dst->BirthTimeNsec = 0;
#endif
#if defined(HAVE_STAT_FLAGS) && defined(UF_HIDDEN)
dst->UserFlags = ((src->st_flags & UF_HIDDEN) == UF_HIDDEN) ? PAL_UF_HIDDEN : 0;
#else
dst->UserFlags = 0;
#endif
}
// CoreCLR expects the "2" suffixes on these: they should be cleaned up in our
@ -1460,6 +1466,28 @@ int32_t SystemNative_LockFileRegion(intptr_t fd, int64_t offset, int64_t length,
return ret;
}
int32_t SystemNative_LChflags(const char* path, uint32_t flags)
{
#if HAVE_LCHFLAGS
int32_t result;
while ((result = lchflags(path, flags)) < 0 && errno == EINTR);
return result;
#else
(void)path, (void)flags;
errno = ENOTSUP;
return -1;
#endif
}
int32_t SystemNative_LChflagsCanSetHiddenFlag(void)
{
#if defined(UF_HIDDEN) && defined(HAVE_STAT_FLAGS) && defined(HAVE_LCHFLAGS)
return true;
#else
return false;
#endif
}
int32_t SystemNative_Symlink(const char* target, const char* linkPath)
{
return symlink(target, linkPath);

View File

@ -35,6 +35,7 @@ struct FileStatus
int64_t BirthTimeNsec; // nanosecond part
int64_t Dev; // ID of the device containing the file
int64_t Ino; // inode number of the file
uint32_t UserFlags; // user defined flags
};
/* Provide consistent access to nanosecond fields, if they exist. */
@ -153,6 +154,14 @@ enum
FILESTATUS_FLAGS_HAS_BIRTHTIME = 1,
};
/**
* Constants for interpreting FileStatus.UserFlags.
*/
enum
{
PAL_UF_HIDDEN = 0x8000
};
/**
* Constants from dirent.h for the inode type returned from readdir variants
*/
@ -750,6 +759,20 @@ DLLEXPORT int32_t SystemNative_GetPeerID(intptr_t socket, uid_t* euid);
*/
DLLEXPORT int32_t SystemNative_LockFileRegion(intptr_t fd, int64_t offset, int64_t length, int16_t lockType);
/**
* Changes the file flags of the file whose location is specified in path
*
* Returns 0 for success, -1 for failure. Sets errno for failure.
*/
DLLEXPORT int32_t SystemNative_LChflags(const char* path, uint32_t flags);
/**
* Determines if the current platform supports setting UF_HIDDEN (0x8000) flag
*
* Returns true (non-zero) if supported, false (zero) if not.
*/
DLLEXPORT int32_t SystemNative_LChflagsCanSetHiddenFlag(void);
/**
* Creates a symbolic link at "linkPath", pointing at "target".
* "target" may or may not exist (dangling symbolic links are valid filesystem objects)

View File

@ -284,6 +284,9 @@
<Compile Include="$(CommonPath)\Interop\Unix\System.Native\Interop.Read.cs">
<Link>Common\Interop\Unix\Interop.Read.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\Interop\Unix\System.Native\Interop.LChflags.cs">
<Link>Common\Interop\Unix\Interop.LChflags.cs</Link>
</Compile>
<Compile Include="$(CommonPath)\Interop\Unix\System.Native\Interop.Rename.cs">
<Link>Common\Interop\Unix\Interop.Rename.cs</Link>
</Compile>

View File

@ -11,13 +11,12 @@ namespace System.IO.Enumeration
/// </summary>
public unsafe ref partial struct FileSystemEntry
{
private const int FileNameBufferSize = 256;
internal Interop.Sys.DirectoryEntry _directoryEntry;
private FileStatus _status;
private Span<char> _pathBuffer;
private ReadOnlySpan<char> _fullPath;
private ReadOnlySpan<char> _fileName;
private fixed char _fileNameBuffer[FileNameBufferSize];
private fixed char _fileNameBuffer[Interop.Sys.DirectoryEntry.NameBufferSize];
private FileAttributes _initialAttributes;
internal static FileAttributes Initialize(
@ -112,7 +111,7 @@ namespace System.IO.Enumeration
{
fixed (char* c = _fileNameBuffer)
{
Span<char> buffer = new Span<char>(c, FileNameBufferSize);
Span<char> buffer = new Span<char>(c, Interop.Sys.DirectoryEntry.NameBufferSize);
_fileName = _directoryEntry.GetName(buffer);
}
}

View File

@ -84,8 +84,8 @@ namespace System.IO
if (_isDirectory)
attributes |= FileAttributes.Directory;
// If the filename starts with a period, it's hidden.
if (fileName.Length > 0 && fileName[0] == '.')
// If the filename starts with a period or has UF_HIDDEN flag set, it's hidden.
if (fileName.Length > 0 && (fileName[0] == '.' || (_fileStatus.UserFlags & (uint)Interop.Sys.UserFlags.UF_HIDDEN) == (uint)Interop.Sys.UserFlags.UF_HIDDEN))
attributes |= FileAttributes.Hidden;
return attributes != default ? attributes : FileAttributes.Normal;
@ -98,10 +98,10 @@ namespace System.IO
const FileAttributes allValidFlags =
FileAttributes.Archive | FileAttributes.Compressed | FileAttributes.Device |
FileAttributes.Directory | FileAttributes.Encrypted | FileAttributes.Hidden |
FileAttributes.Hidden | FileAttributes.IntegrityStream | FileAttributes.Normal |
FileAttributes.NoScrubData | FileAttributes.NotContentIndexed | FileAttributes.Offline |
FileAttributes.ReadOnly | FileAttributes.ReparsePoint | FileAttributes.SparseFile |
FileAttributes.System | FileAttributes.Temporary;
FileAttributes.IntegrityStream | FileAttributes.Normal | FileAttributes.NoScrubData |
FileAttributes.NotContentIndexed | FileAttributes.Offline | FileAttributes.ReadOnly |
FileAttributes.ReparsePoint | FileAttributes.SparseFile | FileAttributes.System |
FileAttributes.Temporary;
if ((attributes & ~allValidFlags) != 0)
{
// Using constant string for argument to match historical throw
@ -113,6 +113,26 @@ namespace System.IO
if (!_exists)
FileSystemInfo.ThrowNotFound(path);
if (Interop.Sys.CanSetHiddenFlag)
{
if ((attributes & FileAttributes.Hidden) != 0)
{
if ((_fileStatus.UserFlags & (uint)Interop.Sys.UserFlags.UF_HIDDEN) == 0)
{
// If Hidden flag is set and cached file status does not have the flag set then set it
Interop.CheckIo(Interop.Sys.LChflags(path, (_fileStatus.UserFlags | (uint)Interop.Sys.UserFlags.UF_HIDDEN)), path, InitiallyDirectory);
}
}
else
{
if ((_fileStatus.UserFlags & (uint)Interop.Sys.UserFlags.UF_HIDDEN) == (uint)Interop.Sys.UserFlags.UF_HIDDEN)
{
// If Hidden flag is not set and cached file status does have the flag set then remove it
Interop.CheckIo(Interop.Sys.LChflags(path, (_fileStatus.UserFlags & ~(uint)Interop.Sys.UserFlags.UF_HIDDEN)), path, InitiallyDirectory);
}
}
}
// The only thing we can reasonably change is whether the file object is readonly by changing permissions.
int newMode = _fileStatus.Mode;

View File

@ -16,9 +16,16 @@ namespace System.IO.Tests
public void SettingAttributes_Unix(FileAttributes attributes)
{
string path = CreateItem();
SetAttributes(path, attributes);
Assert.Equal(attributes, GetAttributes(path));
SetAttributes(path, 0);
AssertSettingAttributes(path, attributes);
}
[Theory]
[InlineData(FileAttributes.Hidden)]
[PlatformSpecific(TestPlatforms.OSX | TestPlatforms.FreeBSD)]
public void SettingAttributes_OSXAndFreeBSD(FileAttributes attributes)
{
string path = CreateItem();
AssertSettingAttributes(path, attributes);
}
[Theory]
@ -33,6 +40,11 @@ namespace System.IO.Tests
public void SettingAttributes_Windows(FileAttributes attributes)
{
string path = CreateItem();
AssertSettingAttributes(path, attributes);
}
private void AssertSettingAttributes(string path, FileAttributes attributes)
{
SetAttributes(path, attributes);
Assert.Equal(attributes, GetAttributes(path));
SetAttributes(path, 0);
@ -48,8 +60,16 @@ namespace System.IO.Tests
public void SettingInvalidAttributes_Unix(FileAttributes attributes)
{
string path = CreateItem();
SetAttributes(path, attributes);
Assert.Equal(FileAttributes.Normal, GetAttributes(path));
AssertSettingInvalidAttributes(path, attributes);
}
[Theory]
[InlineData(FileAttributes.Hidden)]
[PlatformSpecific(TestPlatforms.AnyUnix & ~(TestPlatforms.OSX | TestPlatforms.FreeBSD))]
public void SettingInvalidAttributes_UnixExceptOSXAndFreeBSD(FileAttributes attributes)
{
string path = CreateItem();
AssertSettingInvalidAttributes(path, attributes);
}
[Theory]
@ -62,6 +82,11 @@ namespace System.IO.Tests
public void SettingInvalidAttributes_Windows(FileAttributes attributes)
{
string path = CreateItem();
AssertSettingInvalidAttributes(path, attributes);
}
private void AssertSettingInvalidAttributes(string path, FileAttributes attributes)
{
SetAttributes(path, attributes);
Assert.Equal(FileAttributes.Normal, GetAttributes(path));
}

View File

@ -2,6 +2,9 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO.Enumeration;
using Xunit;
@ -96,5 +99,39 @@ namespace System.IO.Tests
Assert.Equal(info.FullName, ie.DirectoryFinished);
}
}
[Fact]
public void VariableLengthFileNames_AllCreatableFilesAreEnumerable()
{
DirectoryInfo testDirectory = Directory.CreateDirectory(GetTestFilePath());
var names = new List<string>();
for (int length = 1; length < 10_000; length++) // arbitrarily large limit for the test
{
string name = new string('a', length);
try { File.Create(Path.Join(testDirectory.FullName, name)).Dispose(); }
catch { break; }
names.Add(name);
}
Assert.InRange(names.Count, 1, int.MaxValue);
Assert.Equal(names.OrderBy(n => n), Directory.GetFiles(testDirectory.FullName).Select(n => Path.GetFileName(n)).OrderBy(n => n));
}
[Fact]
public void VariableLengthDirectoryNames_AllCreatableDirectoriesAreEnumerable()
{
DirectoryInfo testDirectory = Directory.CreateDirectory(GetTestFilePath());
var names = new List<string>();
for (int length = 1; length < 10_000; length++) // arbitrarily large limit for the test
{
string name = new string('a', length);
try { Directory.CreateDirectory(Path.Join(testDirectory.FullName, name)); }
catch { break; }
names.Add(name);
}
Assert.InRange(names.Count, 1, int.MaxValue);
Assert.Equal(names.OrderBy(n => n), Directory.GetDirectories(testDirectory.FullName).Select(n => Path.GetFileName(n)).OrderBy(n => n));
}
}
}

View File

@ -168,6 +168,33 @@ namespace System.IO.Tests
#region PlatformSpecific
[Fact]
[PlatformSpecific(TestPlatforms.AnyUnix)]
public void LongDirectoryName()
{
// 255 = NAME_MAX on Linux and macOS
DirectoryInfo path = Directory.CreateDirectory(Path.Combine(GetTestFilePath(), new string('a', 255)));
Assert.True(Directory.Exists(path.FullName));
Directory.Delete(path.FullName);
Assert.False(Directory.Exists(path.FullName));
}
[Fact]
[PlatformSpecific(TestPlatforms.AnyUnix)]
public void LongFileName()
{
// 255 = NAME_MAX on Linux and macOS
var dir = GetTestFilePath();
Directory.CreateDirectory(dir);
var path = Path.Combine(dir, new string('b', 255));
File.Create(path).Dispose();
Assert.True(File.Exists(path));
File.Delete(path);
Assert.False(File.Exists(path));
}
[Fact]
[PlatformSpecific(CaseSensitivePlatforms)]
public void CaseSensitive()

View File

@ -28,5 +28,18 @@ namespace System.IO.Tests
test.Refresh();
Assert.Equal(false, test.IsReadOnly);
}
[Theory]
[InlineData(".", true)]
[InlineData("", false)]
[PlatformSpecific(TestPlatforms.OSX)]
public void HiddenAttributeSetCorrectly_OSX(string filePrefix, bool hidden)
{
string testFilePath = Path.Combine(TestDirectory, $"{filePrefix}{GetTestFileName()}");
FileInfo fileInfo = new FileInfo(testFilePath);
fileInfo.Create().Dispose();
Assert.Equal(hidden, (fileInfo.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden);
}
}
}

View File

@ -153,7 +153,7 @@ namespace System.IO.Tests
}
}
[Theory]
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotWindowsSubsystemForLinux))] // https://github.com/dotnet/corefx/issues/34397
[InlineData(10, 0, 10, 1, 2)]
[InlineData(10, 3, 5, 3, 5)]
[InlineData(10, 3, 5, 3, 4)]

View File

@ -31,9 +31,15 @@ namespace System.Linq.Parallel
// Whether to preserve order by default, when neither AsOrdered nor AsUnordered is used.
internal const bool DefaultPreserveOrder = false;
#if MONO
// By default limit to degree of 16 to avoid too much contention. It's
// still possible to override that to a maximum of MAX_SUPPORTED_DOP.
internal static int DefaultDegreeOfParallelism = Math.Min(Environment.ProcessorCount, 16);
#else
// The default degree of parallelism, or -1 if unspecified. Dev unit tests set this value
// to change the default DOP.
internal static int DefaultDegreeOfParallelism = Math.Min(Environment.ProcessorCount, MAX_SUPPORTED_DOP);
#endif
// The size to use for bounded buffers.
internal const int DEFAULT_BOUNDED_BUFFER_CAPACITY = 512;

View File

@ -13,8 +13,17 @@ namespace System.Net.Http.Headers
{
private UriKind _uriKind;
#if MONO
// FIXME: Workaround for https://github.com/mono/mono/issues/17897.
// This is the same as setting the MONO_URI_DOTNETRELATIVEORABSOLUTE=true
// environment variable.
// See https://github.com/mono/mono/blob/1454b010ae1165a0f2cf261b9420e32d1b52fdaf/mcs/class/referencesource/System/net/System/URI.cs#L991.
internal static readonly UriHeaderParser RelativeOrAbsoluteUriParser =
new UriHeaderParser((UriKind)300);
#else
internal static readonly UriHeaderParser RelativeOrAbsoluteUriParser =
new UriHeaderParser(UriKind.RelativeOrAbsolute);
#endif
private UriHeaderParser(UriKind uriKind)
: base(false)

View File

@ -3,9 +3,9 @@
<ProductDependencies>
</ProductDependencies>
<ToolsetDependencies>
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="1.0.0-beta.19412.1">
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="5.0.0-beta.19502.11">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>ec2dd5b3e7d11b88b2ca0688bb1685836cfad20a</Sha>
<Sha>da75c6547c64a91eb8a9cecf8c503331c2cc394a</Sha>
</Dependency>
</ToolsetDependencies>
</Dependencies>

View File

@ -5,16 +5,11 @@
<PreReleaseVersionLabel>prerelease</PreReleaseVersionLabel>
</PropertyGroup>
<PropertyGroup>
<MicrosoftNetCoreIlasmPackageVersion>3.0.0-preview4-27520-71</MicrosoftNetCoreIlasmPackageVersion>
<!-- ilasm -->
<MicrosoftNETCoreILAsmPackageVersion>5.0.0-alpha1.19413.7</MicrosoftNETCoreILAsmPackageVersion>
<!-- These should match the SDK version at https://github.com/dotnet/sdk/blob/master/eng/Versions.props -->
<SystemReflectionMetadataVersion>1.5.0</SystemReflectionMetadataVersion>
<MicrosoftBuildFrameworkVersion>15.4.8</MicrosoftBuildFrameworkVersion>
<MicrosoftBuildUtilitiesCoreVersion>15.4.8</MicrosoftBuildUtilitiesCoreVersion>
</PropertyGroup>
<PropertyGroup>
<RestoreSources>
$(RestoreSources);
https://dotnetfeed.blob.core.windows.net/dotnet-coreclr/index.json
</RestoreSources>
</PropertyGroup>
</Project>

View File

@ -1,3 +1,10 @@
trigger:
batch: true
branches:
include:
- master
- release/*
variables:
- name: officialBuild
value: ${{ and(ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}
@ -29,7 +36,7 @@ jobs:
${{ if eq(variables.officialBuild, 'false') }}:
name: Hosted VS2017
${{ if eq(variables.officialBuild, 'true') }}:
name: NetCoreInternal-Int-Pool
name: NetCoreInternal-Pool
queue: BuildPool.Windows.10.Amd64.VS2017
variables:
- ${{ if eq(variables.officialBuild, 'false') }}:

View File

@ -85,6 +85,10 @@ function Build {
# Re-assign properties to a new variable because PowerShell doesn't let us append properties directly for unclear reasons.
# Explicitly set the type as string[] because otherwise PowerShell would make this char[] if $properties is empty.
[string[]] $msbuildArgs = $properties
# Resolve relative project paths into full paths
$projects = ($projects.Split(';').ForEach({Resolve-Path $_}) -join ';')
$msbuildArgs += "/p:Projects=$projects"
$properties = $msbuildArgs
}

Some files were not shown because too many files have changed in this diff Show More