// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== /*============================================================ ** ** This file exists to contain miscellaneous module-level attributes ** and other miscellaneous stuff. ** ** ** ===========================================================*/ using System.Runtime.InteropServices; using System.Runtime.CompilerServices; using System.Collections.Generic; using System.Reflection; using System.Security; #if FEATURE_COMINTEROP using System.Runtime.InteropServices.WindowsRuntime; [assembly:Guid("BED7F4EA-1A96-11d2-8F08-00A0C9A6186D")] // The following attribute are required to ensure COM compatibility. [assembly:System.Runtime.InteropServices.ComCompatibleVersion(1, 0, 3300, 0)] [assembly:System.Runtime.InteropServices.TypeLibVersion(2, 4)] #endif // FEATURE_COMINTEROP [assembly:DefaultDependencyAttribute(LoadHint.Always)] // mscorlib would like to have its literal strings frozen if possible [assembly: System.Runtime.CompilerServices.StringFreezingAttribute()] namespace System { static class Internal { // This method is purely an aid for NGen to statically deduce which // instantiations to save in the ngen image. // Otherwise, the JIT-compiler gets used, which is bad for working-set. // Note that IBC can provide this information too. // However, this helps in keeping the JIT-compiler out even for // test scenarios which do not use IBC. // This can be removed after V2, when we implement other schemes // of keeping the JIT-compiler out for generic instantiations. static void CommonlyUsedGenericInstantiations_HACK() { // Make absolutely sure we include some of the most common // instantiations here in mscorlib's ngen image. // Note that reference type instantiations are already included // automatically for us. System.Array.Sort(null); System.Array.Sort(null); System.Array.Sort(null); new ArraySegment(new byte[1], 0, 0); new Dictionary(); new Dictionary(); new Dictionary(); new Dictionary(); // Added for Visual Studio 2010 new Dictionary(); new Dictionary(); new Dictionary(); new Dictionary(); new Dictionary(); new Dictionary(); new Dictionary(); new Dictionary(); new Dictionary(); new Dictionary(); new Dictionary(); // Added for Visual Studio 2010 new Dictionary(); // NCL team needs this new Dictionary(); new Dictionary(); new Dictionary(); // Microsoft.Windows.Design new Dictionary(); new EnumEqualityComparer(); // Microsoft.Expression.DesignModel new Dictionary>(); new Dictionary, Object>(); NullableHelper_HACK(); NullableHelper_HACK(); NullableHelper_HACK(); NullableHelper_HACK(); NullableHelper_HACK(); NullableHelper_HACK(); NullableHelper_HACK(); NullableHelper_HACK(); NullableHelper_HACK(); NullableHelper_HACK(); NullableHelper_HACK(); NullableHelper_HACK(); NullableHelper_HACK(); // For SQL new List(); new List(); new List(); new List(); new List(); new List(); new List(); new List(); new List(); new List(); new List(); new List(); new List(); new List(); new List(); new List(); new List(); new List>(); new List(); // NCL team needs this new List(); new KeyValuePair('\0', UInt16.MinValue); new KeyValuePair(UInt16.MinValue, Double.MinValue); new KeyValuePair(String.Empty, Int32.MinValue); new KeyValuePair(Int32.MinValue, Int32.MinValue); SZArrayHelper_HACK(null); SZArrayHelper_HACK(null); SZArrayHelper_HACK(null); SZArrayHelper_HACK(null); SZArrayHelper_HACK(null); SZArrayHelper_HACK(null); SZArrayHelper_HACK(null); SZArrayHelper_HACK(null); SZArrayHelper_HACK(null); SZArrayHelper_HACK(null); SZArrayHelper_HACK(null); SZArrayHelper_HACK(null); SZArrayHelper_HACK(null); SZArrayHelper_HACK(null); SZArrayHelper_HACK(null); SZArrayHelper_HACK(null); SZArrayHelper_HACK(null); SZArrayHelper_HACK(null); } static T NullableHelper_HACK() where T : struct { Nullable.Compare(null, null); Nullable.Equals(null, null); Nullable nullable = new Nullable(); return nullable.GetValueOrDefault(); } static void SZArrayHelper_HACK(SZArrayHelper oSZArrayHelper) { // Instantiate common methods for IList implementation on Array oSZArrayHelper.get_Count(); oSZArrayHelper.get_Item(0); oSZArrayHelper.GetEnumerator(); } #if FEATURE_COMINTEROP // Similar to CommonlyUsedGenericInstantiations_HACK but for instantiations of marshaling stubs used // for WinRT redirected interfaces. Note that we do care about reference types here as well because, // say, IList and IList cannot share marshaling stubs. // The methods below "call" most commonly used stub methods on redirected interfaces and take arguments // typed as matching instantiations of mscorlib copies of WinRT interfaces (IIterable, IVector, // IMap, ...) which is necessary to generate all required IL stubs. [SecurityCritical] static void CommonlyUsedWinRTRedirectedInterfaceStubs_HACK() { WinRT_IEnumerable_HACK(null, null, null); WinRT_IEnumerable_HACK(null, null, null); WinRT_IEnumerable_HACK(null, null, null); WinRT_IEnumerable_HACK(null, null, null); WinRT_IEnumerable_HACK(null, null, null); WinRT_IEnumerable_HACK(null, null, null); WinRT_IEnumerable_HACK(null, null, null); WinRT_IEnumerable_HACK(null, null, null); WinRT_IEnumerable_HACK(null, null, null); WinRT_IEnumerable_HACK(null, null, null); WinRT_IEnumerable_HACK(null, null, null); WinRT_IEnumerable_HACK(null, null, null); WinRT_IList_HACK(null, null, null, null); WinRT_IList_HACK(null, null, null, null); WinRT_IList_HACK(null, null, null, null); WinRT_IReadOnlyList_HACK(null, null, null); WinRT_IReadOnlyList_HACK(null, null, null); WinRT_IReadOnlyList_HACK(null, null, null); WinRT_IDictionary_HACK(null, null, null, null); WinRT_IDictionary_HACK(null, null, null, null); WinRT_IDictionary_HACK(null, null, null, null); WinRT_IDictionary_HACK(null, null, null, null); WinRT_IReadOnlyDictionary_HACK(null, null, null, null); WinRT_IReadOnlyDictionary_HACK(null, null, null, null); WinRT_IReadOnlyDictionary_HACK(null, null, null, null); WinRT_IReadOnlyDictionary_HACK(null, null, null, null); } [SecurityCritical] static void WinRT_IEnumerable_HACK(IterableToEnumerableAdapter iterableToEnumerableAdapter, EnumerableToIterableAdapter enumerableToIterableAdapter, IIterable iterable) { // instantiate stubs for the one method on IEnumerable and the one method on IIterable iterableToEnumerableAdapter.GetEnumerator_Stub(); enumerableToIterableAdapter.First_Stub(); } [SecurityCritical] static void WinRT_IList_HACK(VectorToListAdapter vectorToListAdapter, VectorToCollectionAdapter vectorToCollectionAdapter, ListToVectorAdapter listToVectorAdapter, IVector vector) { WinRT_IEnumerable_HACK(null, null, null); // instantiate stubs for commonly used methods on IList and ICollection vectorToListAdapter.Indexer_Get(0); vectorToListAdapter.Indexer_Set(0, default(T)); vectorToListAdapter.Insert(0, default(T)); vectorToListAdapter.RemoveAt(0); vectorToCollectionAdapter.Count(); vectorToCollectionAdapter.Add(default(T)); vectorToCollectionAdapter.Clear(); // instantiate stubs for commonly used methods on IVector listToVectorAdapter.GetAt(0); listToVectorAdapter.Size(); listToVectorAdapter.SetAt(0, default(T)); listToVectorAdapter.InsertAt(0, default(T)); listToVectorAdapter.RemoveAt(0); listToVectorAdapter.Append(default(T)); listToVectorAdapter.RemoveAtEnd(); listToVectorAdapter.Clear(); } [SecurityCritical] static void WinRT_IReadOnlyCollection_HACK(VectorViewToReadOnlyCollectionAdapter vectorViewToReadOnlyCollectionAdapter) { WinRT_IEnumerable_HACK(null, null, null); // instantiate stubs for commonly used methods on IReadOnlyCollection vectorViewToReadOnlyCollectionAdapter.Count(); } [SecurityCritical] static void WinRT_IReadOnlyList_HACK(IVectorViewToIReadOnlyListAdapter vectorToListAdapter, IReadOnlyListToIVectorViewAdapter listToVectorAdapter, IVectorView vectorView) { WinRT_IEnumerable_HACK(null, null, null); WinRT_IReadOnlyCollection_HACK(null); // instantiate stubs for commonly used methods on IReadOnlyList vectorToListAdapter.Indexer_Get(0); // instantiate stubs for commonly used methods on IVectorView listToVectorAdapter.GetAt(0); listToVectorAdapter.Size(); } [SecurityCritical] static void WinRT_IDictionary_HACK(MapToDictionaryAdapter mapToDictionaryAdapter, MapToCollectionAdapter mapToCollectionAdapter, DictionaryToMapAdapter dictionaryToMapAdapter, IMap map) { WinRT_IEnumerable_HACK>(null, null, null); // instantiate stubs for commonly used methods on IDictionary and ICollection> V dummy; mapToDictionaryAdapter.Indexer_Get(default(K)); mapToDictionaryAdapter.Indexer_Set(default(K), default(V)); mapToDictionaryAdapter.ContainsKey(default(K)); mapToDictionaryAdapter.Add(default(K), default(V)); mapToDictionaryAdapter.Remove(default(K)); mapToDictionaryAdapter.TryGetValue(default(K), out dummy); mapToCollectionAdapter.Count(); mapToCollectionAdapter.Add(new KeyValuePair(default(K), default(V))); mapToCollectionAdapter.Clear(); // instantiate stubs for commonly used methods on IMap dictionaryToMapAdapter.Lookup(default(K)); dictionaryToMapAdapter.Size(); dictionaryToMapAdapter.HasKey(default(K)); dictionaryToMapAdapter.Insert(default(K), default(V)); dictionaryToMapAdapter.Remove(default(K)); dictionaryToMapAdapter.Clear(); } [SecurityCritical] static void WinRT_IReadOnlyDictionary_HACK(IMapViewToIReadOnlyDictionaryAdapter mapToDictionaryAdapter, IReadOnlyDictionaryToIMapViewAdapter dictionaryToMapAdapter, IMapView mapView, MapViewToReadOnlyCollectionAdapter mapViewToReadOnlyCollectionAdapter) { WinRT_IEnumerable_HACK>(null, null, null); WinRT_IReadOnlyCollection_HACK>(null); // instantiate stubs for commonly used methods on IReadOnlyDictionary V dummy; mapToDictionaryAdapter.Indexer_Get(default(K)); mapToDictionaryAdapter.ContainsKey(default(K)); mapToDictionaryAdapter.TryGetValue(default(K), out dummy); // instantiate stubs for commonly used methods in IReadOnlyCollection mapViewToReadOnlyCollectionAdapter.Count(); // instantiate stubs for commonly used methods on IMapView dictionaryToMapAdapter.Lookup(default(K)); dictionaryToMapAdapter.Size(); dictionaryToMapAdapter.HasKey(default(K)); } #endif // FEATURE_COMINTEROP } }