diff --git a/Directory.Build.props b/Directory.Build.props index 21c80043ee2..6fab6f96759 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -2,8 +2,9 @@ wpf true - net8.0 - 8.0 + net481 + 4.8.1 + false @@ -22,6 +23,11 @@ $(WpfArcadeSdkPath)Sdk\Sdk.targets + + + + + diff --git a/Directory.Build.targets b/Directory.Build.targets index 224a9dbc152..76987df9563 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -7,4 +7,35 @@ Project="Sdk.targets" Condition="!Exists('$(WpfArcadeSdkProps)') Or !Exists('$(WpfArcadeSdkTargets)')"/> + + + true + false + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/eng/Versions.props b/eng/Versions.props index a5653f40b5b..0c5f2b07615 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -36,6 +36,7 @@ 8.0.12 8.0.0 8.0.1 + 4.6.0 8.0.1 4.6.0-preview4.19176.11 8.0.0 @@ -95,6 +96,7 @@ System.DirectoryServices Microsoft.DotNet.Wpf.DncEng System.IO.Packaging + System.Memory System.Reflection.MetadataLoadContext diff --git a/eng/WpfArcadeSdk/tools/Wpf.Cpp.props b/eng/WpfArcadeSdk/tools/Wpf.Cpp.props index e489910eaaf..66087a09640 100644 --- a/eng/WpfArcadeSdk/tools/Wpf.Cpp.props +++ b/eng/WpfArcadeSdk/tools/Wpf.Cpp.props @@ -247,7 +247,8 @@ - %(AdditionalOptions) /clr:netcore /wd4956 + %(AdditionalOptions) /clr:netcore /wd4956 + %(AdditionalOptions) /wd4956 true diff --git a/eng/WpfArcadeSdk/tools/Wpf.Cpp.targets b/eng/WpfArcadeSdk/tools/Wpf.Cpp.targets index d98a8708e26..0fd55646821 100644 --- a/eng/WpfArcadeSdk/tools/Wpf.Cpp.targets +++ b/eng/WpfArcadeSdk/tools/Wpf.Cpp.targets @@ -381,6 +381,15 @@ using namespace System::Runtime::Versioning; + + + + %24(PkgSystem_IO_Packaging) + + + @@ -410,11 +419,24 @@ using namespace System::Runtime::Versioning; + + - + + + + + + + + + + diff --git a/packaging/Microsoft.NET.Sdk.WindowsDesktop/Microsoft.NET.Sdk.WindowsDesktop.ArchNeutral.csproj b/packaging/Microsoft.NET.Sdk.WindowsDesktop/Microsoft.NET.Sdk.WindowsDesktop.ArchNeutral.csproj index 2da6fb78938..7563d828f26 100644 --- a/packaging/Microsoft.NET.Sdk.WindowsDesktop/Microsoft.NET.Sdk.WindowsDesktop.ArchNeutral.csproj +++ b/packaging/Microsoft.NET.Sdk.WindowsDesktop/Microsoft.NET.Sdk.WindowsDesktop.ArchNeutral.csproj @@ -28,6 +28,6 @@ - + diff --git a/src/Microsoft.DotNet.Wpf/src/DirectWriteForwarder/DirectWriteForwarder.vcxproj b/src/Microsoft.DotNet.Wpf/src/DirectWriteForwarder/DirectWriteForwarder.vcxproj index 55531081afc..286933f8d17 100644 --- a/src/Microsoft.DotNet.Wpf/src/DirectWriteForwarder/DirectWriteForwarder.vcxproj +++ b/src/Microsoft.DotNet.Wpf/src/DirectWriteForwarder/DirectWriteForwarder.vcxproj @@ -29,8 +29,9 @@ true .NETCoreApp + .NETFramework Unknown - @@ -38,8 +39,10 @@ - NetCoreCProj - pure + NetCoreCProj + ManagedCProj + pure + true 10.0 DynamicLibrary @@ -89,7 +92,7 @@ - + - + diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/DpiUtil/DpiUtil+ProcessDpiAwarenessHelper.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/DpiUtil/DpiUtil+ProcessDpiAwarenessHelper.cs index 189f76ad0d1..c3a676e9ae6 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/DpiUtil/DpiUtil+ProcessDpiAwarenessHelper.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/DpiUtil/DpiUtil+ProcessDpiAwarenessHelper.cs @@ -2,10 +2,17 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#if NETFX +extern alias System; +#endif namespace MS.Internal { +#if NETFX + using System::Microsoft.Win32.SafeHandles; +#else using Microsoft.Win32.SafeHandles; +#endif using MS.Win32; using System; using System.Diagnostics; diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/FontCache/FontCacheUtil.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/FontCache/FontCacheUtil.cs index 9ced7b76bbe..3b5eb010644 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/FontCache/FontCacheUtil.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/FontCache/FontCacheUtil.cs @@ -661,7 +661,11 @@ private static string NormalizeFontFamilyReference(string fontFamilyReference, i { // No fragment separator. The entire string is a family name so convert to uppercase // and add a fragment separator at the beginning. +#if NETFX + return string.Concat("#", fontFamilyReference.Substring(startIndex, length)).ToUpperInvariant(); +#else return string.Concat("#", fontFamilyReference.AsSpan(startIndex, length)).ToUpperInvariant(); +#endif } else if (fragmentIndex + 1 == startIndex + length) { diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/IO/Packaging/ByteRangeDownloader.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/IO/Packaging/ByteRangeDownloader.cs index 0a215e43329..37c9ce4d525 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/IO/Packaging/ByteRangeDownloader.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/IO/Packaging/ByteRangeDownloader.cs @@ -797,9 +797,13 @@ static private bool CheckContentRange(WebHeaderCollection responseHeaders, int b } // Get the first byte offset of the range (XXX) - int firstByteOffset = Int32.Parse(contentRange.AsSpan(ByteRangeUnit.Length, - index - ByteRangeUnit.Length), - NumberStyles.None, NumberFormatInfo.InvariantInfo); + int firstByteOffset = Int32.Parse( +#if NETFX + contentRange.Substring(ByteRangeUnit.Length, index - ByteRangeUnit.Length), +#else + contentRange.AsSpan(ByteRangeUnit.Length, index - ByteRangeUnit.Length), +#endif + NumberStyles.None, NumberFormatInfo.InvariantInfo); ReadOnlySpan contentRangeSpan = contentRange.AsSpan(index + 1); // ContentRange: YYY/ZZZ @@ -811,7 +815,13 @@ static private bool CheckContentRange(WebHeaderCollection responseHeaders, int b } // Get the last byte offset of the range (YYY) - int lastByteOffset = Int32.Parse(contentRangeSpan.Slice(0, index), NumberStyles.None, NumberFormatInfo.InvariantInfo); + int lastByteOffset = Int32.Parse( +#if NETFX + contentRangeSpan.Slice(0, index).ToString(), +#else + contentRangeSpan.Slice(0, index), +#endif + NumberStyles.None, NumberFormatInfo.InvariantInfo); // Get the instance length // ContentRange: ZZZ @@ -822,7 +832,13 @@ static private bool CheckContentRange(WebHeaderCollection responseHeaders, int b // if it is not an integer or the integer is bigger than Int32 since HttpWebRequest.AddRange // only supports Int32 // Once HttpWebRequest.AddRange start supporting Int64 we should change it to Int64 and long - Int32.Parse(contentRangeSpan, NumberStyles.None, NumberFormatInfo.InvariantInfo); + Int32.Parse( +#if NETFX + contentRangeSpan.ToString(), +#else + contentRangeSpan, +#endif + NumberStyles.None, NumberFormatInfo.InvariantInfo); } // The response is considered to be successful if diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/PresentationCore.csproj b/src/Microsoft.DotNet.Wpf/src/PresentationCore/PresentationCore.csproj index 2664fc6fcbb..63138cd181b 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/PresentationCore.csproj +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/PresentationCore.csproj @@ -1360,6 +1360,13 @@ + + + + + + + @@ -1405,8 +1412,8 @@ - - + + diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/InputScopeConverter.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/InputScopeConverter.cs index f5bf15c24c4..74e51499dc7 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/InputScopeConverter.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/InputScopeConverter.cs @@ -120,7 +120,11 @@ public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo c if (!spanSource.IsEmpty) { +#if NETFX + sn = (InputScopeNameValue)Enum.Parse(typeof(InputScopeNameValue), spanSource.ToString()); +#else sn = Enum.Parse(spanSource); +#endif } } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/KeyTimeConverter.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/KeyTimeConverter.cs index 7b1d87f101d..ec25e67d004 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/KeyTimeConverter.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/KeyTimeConverter.cs @@ -189,7 +189,11 @@ public override object ConvertTo( keyTime.Percent * 100.0, destinationType); +#if NETFX + return string.Concat(returnValue, "%"); +#else return string.Concat(returnValue, (ReadOnlySpan)stackalloc char[] { '%' }); +#endif case KeyTimeType.TimeSpan: diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/CharacterMetrics.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/CharacterMetrics.cs index 39d3b67744a..ef8a0bbf1a0 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/CharacterMetrics.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/CharacterMetrics.cs @@ -169,7 +169,11 @@ private static double[] ParseMetrics(string s) // Non-empty field; convert it to double. ReadOnlySpan field = s.AsSpan(i, k - i); if (!double.TryParse( +#if NETFX + field.ToString(), +#else field, +#endif NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, System.Windows.Markup.TypeConverterHelper.InvariantEnglishUS, out metrics[fieldIndex] diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Color.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Color.cs index 96967556977..02aa8b4e27a 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Color.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Color.cs @@ -279,7 +279,11 @@ internal string ConvertToString(string format, IFormatProvider provider) { if (format == null) { +#if NETFX + return $"#{this.sRgbColor.a:X2}{this.sRgbColor.r:X2}{this.sRgbColor.g:X2}{this.sRgbColor.b:X2}"; +#else return string.Create(provider, stackalloc char[128], $"#{this.sRgbColor.a:X2}{this.sRgbColor.r:X2}{this.sRgbColor.g:X2}{this.sRgbColor.b:X2}"); +#endif } else { diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/UniqueEventHelper.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/UniqueEventHelper.cs index 08e4b08cbea..6777086c648 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/UniqueEventHelper.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/UniqueEventHelper.cs @@ -7,6 +7,10 @@ namespace System.Windows.Media { +#if NETFX + using ArgumentNullException = System.Xaml.ArgumentNullException; +#endif + /// /// Aids in making events unique. i.e. you register the same function for /// the same event twice, but it will only be called once for each time diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Navigation/BaseUriHelper.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Navigation/BaseUriHelper.cs index b885542ed60..ea5b851fd66 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Navigation/BaseUriHelper.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Navigation/BaseUriHelper.cs @@ -643,7 +643,11 @@ private static byte[] ParseAssemblyKey(string assemblyKey) byte[] keyToken = new byte[byteCount]; for (int i = 0; i < byteCount; i++) { +#if NETFX + keyToken[i] = byte.Parse(assemblyKey.Substring(i * 2, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture); +#else keyToken[i] = byte.Parse(assemblyKey.AsSpan(i * 2, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture); +#endif } return keyToken; diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/ref/PresentationCore-ref.csproj b/src/Microsoft.DotNet.Wpf/src/PresentationCore/ref/PresentationCore-ref.csproj index 75d9e1c713d..abf46aec113 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/ref/PresentationCore-ref.csproj +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/ref/PresentationCore-ref.csproj @@ -11,7 +11,6 @@ MS.Internal.PresentationCore None AnyCPU;x64;arm64 - @@ -63,8 +62,8 @@ - - + + diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Data/AccessorTable.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Data/AccessorTable.cs index 1cefa808957..d044745d130 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Data/AccessorTable.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Data/AccessorTable.cs @@ -19,6 +19,7 @@ property. We cache the result of this discovery process in the using System.Collections.Generic; using System.ComponentModel; // IBindingList using System.Diagnostics; +using System.Linq; using System.Reflection; // TypeDescriptor using System.Windows; // SR using System.Windows.Threading; // Dispatcher @@ -115,6 +116,18 @@ private object CleanupOperation(object arg) int originalCount = _table.Count; #endif +#if NETFX + List keys = _table.Keys.ToList(); + + foreach (AccessorTableKey key in keys) + { + int age = _generation - _table[key].Generation; + if (age >= AgeLimit) + { + _table.Remove(key); + } + } +#else // Remove entries that are sufficiently old foreach (KeyValuePair entry in _table) { @@ -124,6 +137,7 @@ private object CleanupOperation(object arg) _table.Remove(entry.Key); } } +#endif #if DEBUG if (_traceSize) diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Navigation/BindStream.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Navigation/BindStream.cs index 7fea021c178..2ba48cec177 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Navigation/BindStream.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Navigation/BindStream.cs @@ -291,7 +291,9 @@ public override int GetHashCode() /// Overridden InitializeLifetimeService method /// /// - [ObsoleteAttribute("InitializeLifetimeService is obsolete.", false)] +#if !NETFX + [Obsolete("InitializeLifetimeService is obsolete.", false)] +#endif public override object InitializeLifetimeService() { return _stream.InitializeLifetimeService(); diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/ListMarkerSourceInfo.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/ListMarkerSourceInfo.cs index 8c2c8f6a9e5..45d8fb85383 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/ListMarkerSourceInfo.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/PtsHost/ListMarkerSourceInfo.cs @@ -190,6 +190,7 @@ private static string ConvertNumberToString(int number, bool oneBased, string nu } // Build string in reverse order starting with suffix. +#if !NETFX return string.Create(digits + 1, (numericSymbols, number, b, disjoint), (result, state) => // digits + suffix { result[result.Length - 1] = NumberSuffix; @@ -199,6 +200,25 @@ private static string ConvertNumberToString(int number, bool oneBased, string nu result[i] = state.numericSymbols[remainder]; } }); +#else + return Reverse(digits + 1, numericSymbols, number, b, disjoint); + + // Local methods + + static string Reverse(int length, string numericSymbols, int number, int b, int disjoint) + { + char[] result = new char[length]; + + result[result.Length - 1] = NumberSuffix; + for (int i = result.Length - 2; i >= 0; --i) + { + number = Math.DivRem(number, b, out int remainder) - disjoint; + result[i] = numericSymbols[remainder]; + } + + return new string(result); + } +#endif } } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/WindowsRuntime/Generated/WinRT/ComWrappersSupport.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/WindowsRuntime/Generated/WinRT/ComWrappersSupport.cs index acaedd94748..3a5ab05eee1 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/WindowsRuntime/Generated/WinRT/ComWrappersSupport.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/WindowsRuntime/Generated/WinRT/ComWrappersSupport.cs @@ -36,7 +36,11 @@ static ComWrappersSupport() PlatformSpecificInitialize(); } +#if NETFX + static unsafe partial void PlatformSpecificInitialize(); +#else static partial void PlatformSpecificInitialize(); +#endif public static TReturn MarshalDelegateInvoke(IntPtr thisPtr, Func invoke) where TDelegate : class, Delegate diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/WindowsRuntime/Generated/WinRT/ComWrappersSupport.net5.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/WindowsRuntime/Generated/WinRT/ComWrappersSupport.net5.cs index 1492530057a..f5f4c458965 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/WindowsRuntime/Generated/WinRT/ComWrappersSupport.net5.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/WindowsRuntime/Generated/WinRT/ComWrappersSupport.net5.cs @@ -11,6 +11,7 @@ using WinRT.Interop; using static System.Runtime.InteropServices.ComWrappers; +#if !NETFX namespace WinRT { internal static partial class ComWrappersSupport @@ -157,3 +158,4 @@ public VtableEntriesCleanupScout(ComInterfaceEntry* data) } } } +#endif diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/WindowsRuntime/Generated/WinRT/ComWrappersSupport.netfx.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/WindowsRuntime/Generated/WinRT/ComWrappersSupport.netfx.cs new file mode 100644 index 00000000000..8d5e1613e5b --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/WindowsRuntime/Generated/WinRT/ComWrappersSupport.netfx.cs @@ -0,0 +1,74 @@ +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using WinRT.Interop; + +#if NETFX +namespace System.Runtime.InteropServices +{ + internal abstract partial class ComWrappers + { + /// + /// Interface type and pointer to targeted VTable. + /// + public struct ComInterfaceEntry + { + public Guid IID; + public IntPtr Vtable; + } + } +} + +namespace WinRT +{ + internal static partial class ComWrappersSupport + { + public static readonly ConditionalWeakTable InspectableInfoTable = new ConditionalWeakTable(); + + public static unsafe InspectableInfo GetInspectableInfo(IntPtr pThis) + { + var _this = FindObject(pThis); + return InspectableInfoTable.GetValue(_this, o => PregenerateNativeTypeInformation(o).inspectableInfo); + } + + public static object CreateRcwForComObject(IntPtr ptr) + { + return Marshal.GetObjectForIUnknown(ptr); + } + + public static void RegisterObjectForInterface(object obj, IntPtr thisPtr) => TryRegisterObjectForInterface(obj, thisPtr); + + public static object TryRegisterObjectForInterface(object obj, IntPtr thisPtr) => Marshal.GetObjectForIUnknown(thisPtr); + + public static IObjectReference CreateCCWForObject(object obj) + { + IntPtr ccw = Marshal.GetIUnknownForObject(obj); + return ObjectReference.Attach(ref ccw); + } + + public static unsafe T FindObject(IntPtr ptr) + where T : class => (T)Marshal.GetObjectForIUnknown(ptr); + + private static T FindDelegate(IntPtr thisPtr) + where T : class, System.Delegate => FindObject(thisPtr); + + public static IUnknownVftbl IUnknownVftbl { get; private set; } + + public static IntPtr AllocateVtableMemory(Type vtableType, int size) => Marshal.AllocHGlobal(size); + + static unsafe partial void PlatformSpecificInitialize() + { + IntPtr pUnk = Marshal.GetIUnknownForObject(new object()); + + IUnknownVftbl = new IUnknownVftbl + { + QueryInterface = Marshal.GetDelegateForFunctionPointer(new IntPtr((*(void***)pUnk)[0])), + AddRef = Marshal.GetDelegateForFunctionPointer(new IntPtr((*(void***)pUnk)[1])), + Release = Marshal.GetDelegateForFunctionPointer(new IntPtr((*(void***)pUnk)[2])), + }; + + Marshal.Release(pUnk); + } + } +} +#endif diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/WindowsRuntime/Generated/WinRT/GuidGenerator.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/WindowsRuntime/Generated/WinRT/GuidGenerator.cs index 3ce4223467d..9c9ad0773e3 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/WindowsRuntime/Generated/WinRT/GuidGenerator.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/WindowsRuntime/Generated/WinRT/GuidGenerator.cs @@ -136,7 +136,12 @@ public static Guid CreateIID(Type type) return new Guid(sig); } var data = wrt_pinterface_namespace.ToByteArray().Concat(UTF8Encoding.UTF8.GetBytes(sig)).ToArray(); +#if NETFX + using SHA1 sha1 = SHA1.Create(); + return encode_guid(sha1.ComputeHash(data)); +#else return encode_guid(SHA1.HashData(data)); +#endif } } } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/FileDialog.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/FileDialog.cs index a6d6a811aad..7db3d56b27d 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/FileDialog.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/Microsoft/Win32/FileDialog.cs @@ -624,14 +624,24 @@ private bool ProcessFileNames() // of the filename in s. string newFilename; - if (((ReadOnlySpan)extensions[j]).IndexOfAny('*', '?') != -1) +#if NETFX + string extension = extensions[j]; + if (extension.IndexOfAny(new char[] { '*', '?' }) != -1) +#else + var extension = ((ReadOnlySpan)extensions[j]); + if (extension.IndexOfAny('*', '?') != -1) +#endif { // we don't want to append the extension if it contains wild cards newFilename = fileName.Substring(0, fileName.Length - currentExtension.Length); } else { +#if NETFX + newFilename = string.Concat(fileName.Substring(0, fileName.Length - currentExtension.Length), ".", extensions[j]); +#else newFilename = string.Concat(fileName.AsSpan(0, fileName.Length - currentExtension.Length), ".", extensions[j]); +#endif } // If FOS_FILEMUSTEXIST is not set, or if it is set but the filename we generated @@ -731,7 +741,11 @@ private string[] GetFilterExtensions() if (filter != null) { // Filter strings are '|' delimited, so we split on them +#if NETFX + string[] tokens = filter.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); +#else string[] tokens = filter.Split('|', StringSplitOptions.RemoveEmptyEntries); +#endif // Calculate the index of the token containing extension(s) selected // by the FilterIndex property. Remember FilterIndex is one based. diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/PresentationFramework.csproj b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/PresentationFramework.csproj index 3699d671419..6d84ecf7a25 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/PresentationFramework.csproj +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/PresentationFramework.csproj @@ -1359,6 +1359,10 @@ + + + + @@ -1443,8 +1447,8 @@ - - + + true + false true false @@ -213,11 +214,11 @@ - + - - + + - + - + - + - + - - + - + + + - - - - - + + + - - - <_Temporary Include ="@(EmbeddedResource)" Condition="'%(EmbeddedResource.ManifestResourceName)' != '' "/> - <_Temporary> - $(TargetPath) - $(ProjectPath) - - + + + <_Temporary Include ="@(EmbeddedResource)" Condition="'%(EmbeddedResource.ManifestResourceName)' != '' "/> + <_Temporary> + $(TargetPath) + $(ProjectPath) + + - - - + + - - <_Temporary Remove="@(_Temporary)"/> - <_OutOfDateEmbeddedResource Remove="@(_OutOfDateEmbeddedResource)" /> - - + + <_Temporary Remove="@(_Temporary)"/> + <_OutOfDateEmbeddedResource Remove="@(_OutOfDateEmbeddedResource)" /> + + diff --git a/src/Microsoft.DotNet.Wpf/src/System.Printing/ref/System.Printing-ref.csproj b/src/Microsoft.DotNet.Wpf/src/System.Printing/ref/System.Printing-ref.csproj index c2776b69197..03b2352e448 100644 --- a/src/Microsoft.DotNet.Wpf/src/System.Printing/ref/System.Printing-ref.csproj +++ b/src/Microsoft.DotNet.Wpf/src/System.Printing/ref/System.Printing-ref.csproj @@ -10,7 +10,6 @@ - false diff --git a/src/Microsoft.DotNet.Wpf/src/System.Windows.Controls.Ribbon/Microsoft/Windows/Controls/Ribbon/RibbonControlLengthConverter.cs b/src/Microsoft.DotNet.Wpf/src/System.Windows.Controls.Ribbon/Microsoft/Windows/Controls/Ribbon/RibbonControlLengthConverter.cs index 1ccfece983b..bc2a2de1438 100644 --- a/src/Microsoft.DotNet.Wpf/src/System.Windows.Controls.Ribbon/Microsoft/Windows/Controls/Ribbon/RibbonControlLengthConverter.cs +++ b/src/Microsoft.DotNet.Wpf/src/System.Windows.Controls.Ribbon/Microsoft/Windows/Controls/Ribbon/RibbonControlLengthConverter.cs @@ -239,7 +239,13 @@ internal static RibbonControlLength FromString(string s, CultureInfo cultureInfo DoubleUtil.AreClose(unitFactor, 1.0)); ReadOnlySpan valueString = goodString.AsSpan(0, strLen - strLenUnit); - value = double.Parse(valueString, provider: cultureInfo) * unitFactor; + value = double.Parse( +#if NETFX + valueString.ToString(), +#else + valueString, +#endif + provider: cultureInfo) * unitFactor; } return new RibbonControlLength(value, unit); diff --git a/src/Microsoft.DotNet.Wpf/src/System.Windows.Controls.Ribbon/System.Windows.Controls.Ribbon.csproj b/src/Microsoft.DotNet.Wpf/src/System.Windows.Controls.Ribbon/System.Windows.Controls.Ribbon.csproj index fc4369d6723..3aac40f4617 100644 --- a/src/Microsoft.DotNet.Wpf/src/System.Windows.Controls.Ribbon/System.Windows.Controls.Ribbon.csproj +++ b/src/Microsoft.DotNet.Wpf/src/System.Windows.Controls.Ribbon/System.Windows.Controls.Ribbon.csproj @@ -1,8 +1,6 @@  - - AnyCPU;x64;arm64 false $(DefineConstants);RIBBON_IN_FRAMEWORK @@ -11,9 +9,9 @@ true + false true false - @@ -154,7 +152,6 @@ - @@ -177,7 +174,6 @@ - diff --git a/src/Microsoft.DotNet.Wpf/src/System.Xaml/OtherAssemblyAttrs.cs b/src/Microsoft.DotNet.Wpf/src/System.Xaml/OtherAssemblyAttrs.cs index 0264cd4ef60..3abf093f27f 100644 --- a/src/Microsoft.DotNet.Wpf/src/System.Xaml/OtherAssemblyAttrs.cs +++ b/src/Microsoft.DotNet.Wpf/src/System.Xaml/OtherAssemblyAttrs.cs @@ -13,10 +13,12 @@ [assembly:Dependency("System,", LoadHint.Always)] [assembly:Dependency("System.Xml,", LoadHint.Sometimes)] +#if !NETFX [assembly: TypeForwardedTo(typeof(System.Xaml.Permissions.XamlAccessLevel))] #pragma warning disable SYSLIB0003 // Type or member is obsolete [assembly: TypeForwardedTo(typeof(System.Xaml.Permissions.XamlLoadPermission))] #pragma warning restore SYSLIB0003 // Type or member is obsolete +#endif [assembly: TypeForwardedTo(typeof(System.Windows.Markup.ValueSerializerAttribute))] [assembly:XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml", "System.Windows.Markup")] diff --git a/src/Microsoft.DotNet.Wpf/src/System.Xaml/System.Xaml.csproj b/src/Microsoft.DotNet.Wpf/src/System.Xaml/System.Xaml.csproj index 5518a80a7e2..97c27695910 100644 --- a/src/Microsoft.DotNet.Wpf/src/System.Xaml/System.Xaml.csproj +++ b/src/Microsoft.DotNet.Wpf/src/System.Xaml/System.Xaml.csproj @@ -57,6 +57,21 @@ + + + Common\WPF\OtherAssemblyAttrs.Global.cs + + + Common\WPF\System\DictionaryHelpers.cs + + + Common\WPF\System\InternalArgumentNullException.cs + + + Common\WPF\System\ReferenceEqualityComparer.cs + + + @@ -121,7 +136,7 @@ - + diff --git a/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/MS/Impl/KnownStrings.cs b/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/MS/Impl/KnownStrings.cs index e18d473c6d2..1b78cac66b1 100644 --- a/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/MS/Impl/KnownStrings.cs +++ b/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/MS/Impl/KnownStrings.cs @@ -2,6 +2,8 @@ // 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.Globalization; + namespace System.Xaml.MS.Impl { internal static class KnownStrings @@ -67,6 +69,13 @@ public static bool Eq(ReadOnlySpan a, ReadOnlySpan b) return a.Equals(b, StringComparison.Ordinal); } +#if NETFX + public static bool Eq(ReadOnlySpan a, string b) + { + return a.Equals(b.AsSpan(), StringComparison.Ordinal); + } +#endif + /// /// Standard String Index search operation. /// @@ -80,7 +89,11 @@ public static int IndexOf(string src, string chars) /// public static int IndexOf(string src, char ch) { +#if NETFX + return src.IndexOf(ch); +#else return src.IndexOf(ch, StringComparison.Ordinal); +#endif } public static bool EndsWith(string src, string target) diff --git a/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Parser/XamlName.cs b/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Parser/XamlName.cs index c9798d80ea1..d2e26547274 100644 --- a/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Parser/XamlName.cs +++ b/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Parser/XamlName.cs @@ -37,7 +37,11 @@ public XamlName(string prefix, string name) public static bool ContainsDot(string name) { +#if NETFX + return name.Contains("."); +#else return name.Contains(Dot); +#endif } public static bool IsValidXamlName(string name) diff --git a/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Permissions/XamlAccessLevel.cs b/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Permissions/XamlAccessLevel.cs new file mode 100644 index 00000000000..9a42f39076d --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Permissions/XamlAccessLevel.cs @@ -0,0 +1,54 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Reflection; +using System.Security; + +#nullable enable + +#if NETFX +namespace System.Xaml.Permissions +{ + public class XamlAccessLevel + { + private XamlAccessLevel(string assemblyName, string? typeName) + { + AssemblyNameString = assemblyName; + PrivateAccessToTypeName = typeName; + } + + public static XamlAccessLevel AssemblyAccessTo(Assembly assembly) + { + return new XamlAccessLevel(assembly.FullName!, null); + } + + public static XamlAccessLevel AssemblyAccessTo(AssemblyName assemblyName) + { + return new XamlAccessLevel(assemblyName.FullName, null); + } + + public static XamlAccessLevel PrivateAccessTo(Type type) + { + return new XamlAccessLevel(type.Assembly.FullName!, type.FullName); + } + + public static XamlAccessLevel PrivateAccessTo(string assemblyQualifiedTypeName) + { + int nameBoundary = assemblyQualifiedTypeName.IndexOf(','); + string typeName = assemblyQualifiedTypeName.AsSpan(0, nameBoundary).Trim().ToString(); + string assemblyFullName = assemblyQualifiedTypeName.AsSpan(nameBoundary + 1).Trim().ToString(); + AssemblyName assemblyName = new AssemblyName(assemblyFullName); + return new XamlAccessLevel(assemblyName.FullName, typeName); + } + + public AssemblyName AssemblyAccessToAssemblyName + { + get { return new AssemblyName(AssemblyNameString); } + } + + public string? PrivateAccessToTypeName { get; } + + internal string AssemblyNameString { get; } + } +} +#endif diff --git a/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Permissions/XamlLoadPermission.cs b/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Permissions/XamlLoadPermission.cs new file mode 100644 index 00000000000..d9813da50d7 --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Permissions/XamlLoadPermission.cs @@ -0,0 +1,36 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Runtime.InteropServices; +using System.Runtime.Versioning; +using System.Security; +using System.Security.Permissions; + +#nullable enable + +#if NETFX +namespace System.Xaml.Permissions +{ + public sealed class XamlLoadPermission : CodeAccessPermission, IUnrestrictedPermission + { + public XamlLoadPermission(PermissionState state) { } + public XamlLoadPermission(XamlAccessLevel allowedAccess) { } + public XamlLoadPermission(IEnumerable allowedAccess) { } + [ComVisible(false)] + public override bool Equals(object obj) { return ReferenceEquals(this, obj); } + [ComVisible(false)] + public override int GetHashCode() { return base.GetHashCode(); } + public IList AllowedAccess { get; } = new ReadOnlyCollection(Array.Empty()); + public override IPermission Copy() { return new XamlLoadPermission(PermissionState.Unrestricted); } + public override void FromXml(SecurityElement elem) { } + public bool Includes(XamlAccessLevel requestedAccess) { return true; } + public override IPermission Intersect(IPermission target) { return new XamlLoadPermission(PermissionState.Unrestricted); } + public override bool IsSubsetOf(IPermission target) { return true; } + public override SecurityElement? ToXml() { return default(SecurityElement); } + public override IPermission Union(IPermission other) { return new XamlLoadPermission(PermissionState.Unrestricted); } + public bool IsUnrestricted() { return true; } + } +} +#endif diff --git a/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Schema/TypeReflector.cs b/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Schema/TypeReflector.cs index 9e606eefffc..38b597cd5a1 100644 --- a/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Schema/TypeReflector.cs +++ b/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Schema/TypeReflector.cs @@ -1119,7 +1119,11 @@ public bool IsComplete } } - public new V TryAdd(K name, V member) + public +#if !NETFX + new +#endif + V TryAdd(K name, V member) { // This instance is always held in a private field, safe to lock on lock (this) diff --git a/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/XamlType.cs b/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/XamlType.cs index 1b83edf1b14..dd5817c9d32 100644 --- a/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/XamlType.cs +++ b/src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/XamlType.cs @@ -1511,7 +1511,11 @@ private static string GetTypeName(Type type) // save the subscript string subscript; typeName = GenericTypeNameScanner.StripSubscript(typeName, out subscript); +#if NETFX + typeName = string.Concat(typeName.Substring(0, index), subscript); +#else typeName = string.Concat(typeName.AsSpan(0, index), subscript); +#endif } // if nested, add the containing name if (type.IsNested) diff --git a/src/Microsoft.DotNet.Wpf/src/System.Xaml/ref/System.Xaml-ref.csproj b/src/Microsoft.DotNet.Wpf/src/System.Xaml/ref/System.Xaml-ref.csproj index 7498f329404..a55b8e6ae56 100644 --- a/src/Microsoft.DotNet.Wpf/src/System.Xaml/ref/System.Xaml-ref.csproj +++ b/src/Microsoft.DotNet.Wpf/src/System.Xaml/ref/System.Xaml-ref.csproj @@ -15,6 +15,11 @@ + + + + + @@ -50,6 +55,6 @@ - + diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Aero/PresentationFramework.Aero.csproj b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Aero/PresentationFramework.Aero.csproj index b7aacf881e1..5948505be83 100644 --- a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Aero/PresentationFramework.Aero.csproj +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Aero/PresentationFramework.Aero.csproj @@ -2,8 +2,6 @@ - - None AnyCPU;x64;arm64 false @@ -16,6 +14,7 @@ true + false true false diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Aero2/PresentationFramework.Aero2.csproj b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Aero2/PresentationFramework.Aero2.csproj index 4964d7d6f99..1c21714ff6a 100644 --- a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Aero2/PresentationFramework.Aero2.csproj +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Aero2/PresentationFramework.Aero2.csproj @@ -2,8 +2,6 @@ - - None AnyCPU;x64;arm64 false @@ -16,6 +14,7 @@ true + false true false diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.AeroLite/PresentationFramework.AeroLite.csproj b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.AeroLite/PresentationFramework.AeroLite.csproj index f5756f96944..ff47ab6b7a6 100644 --- a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.AeroLite/PresentationFramework.AeroLite.csproj +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.AeroLite/PresentationFramework.AeroLite.csproj @@ -2,8 +2,6 @@ - - None AnyCPU;x64;arm64 false @@ -16,6 +14,7 @@ true + false true false diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Classic/PresentationFramework.Classic.csproj b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Classic/PresentationFramework.Classic.csproj index 5c3caa12da4..1d9e26980d6 100644 --- a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Classic/PresentationFramework.Classic.csproj +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Classic/PresentationFramework.Classic.csproj @@ -2,8 +2,6 @@ - - None AnyCPU;x64;arm64 false @@ -16,9 +14,9 @@ true + false true false - diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Luna/PresentationFramework.Luna.csproj b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Luna/PresentationFramework.Luna.csproj index 98d7ffc9426..a26147f4e22 100644 --- a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Luna/PresentationFramework.Luna.csproj +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Luna/PresentationFramework.Luna.csproj @@ -2,8 +2,6 @@ - - None AnyCPU;x64;arm64 false @@ -16,6 +14,7 @@ true + false true false diff --git a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Royale/PresentationFramework.Royale.csproj b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Royale/PresentationFramework.Royale.csproj index 7a67eab4d74..af4cdae9e92 100644 --- a/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Royale/PresentationFramework.Royale.csproj +++ b/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Royale/PresentationFramework.Royale.csproj @@ -2,8 +2,6 @@ - - None AnyCPU;x64;arm64 false @@ -16,6 +14,7 @@ true + false true false diff --git a/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/IO/Packaging/CompoundFile/RightsManagementEncryptionTransform.cs b/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/IO/Packaging/CompoundFile/RightsManagementEncryptionTransform.cs index c4ee598dbe9..14fad886d6c 100644 --- a/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/IO/Packaging/CompoundFile/RightsManagementEncryptionTransform.cs +++ b/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/IO/Packaging/CompoundFile/RightsManagementEncryptionTransform.cs @@ -1093,7 +1093,11 @@ private static string ContentUser user ) { +#if NETFX + return $"{user.AuthenticationType}:{user.Name}"; +#else return string.Create(null, stackalloc char[128], $"{user.AuthenticationType}:{user.Name}"); +#endif } /// diff --git a/src/Microsoft.DotNet.Wpf/src/WindowsBase/OtherAssemblyAttrs.cs b/src/Microsoft.DotNet.Wpf/src/WindowsBase/OtherAssemblyAttrs.cs index 2ba2d259deb..818ce19e28f 100644 --- a/src/Microsoft.DotNet.Wpf/src/WindowsBase/OtherAssemblyAttrs.cs +++ b/src/Microsoft.DotNet.Wpf/src/WindowsBase/OtherAssemblyAttrs.cs @@ -85,6 +85,7 @@ [assembly:TypeForwardedTo(typeof(System.IO.Packaging.PackageRelationshipSelector))] [assembly:TypeForwardedTo(typeof(System.IO.Packaging.PackageRelationshipSelectorType))] +#if !NETFX #pragma warning disable SYSLIB0003 // Type or member is obsolete [assembly: TypeForwardedTo(typeof(System.Security.Permissions.MediaPermissionAudio))] [assembly: TypeForwardedTo(typeof(System.Security.Permissions.MediaPermissionVideo))] @@ -95,6 +96,7 @@ [assembly: TypeForwardedTo(typeof(System.Security.Permissions.WebBrowserPermission))] [assembly: TypeForwardedTo(typeof(System.Security.Permissions.WebBrowserPermissionAttribute))] #pragma warning restore SYSLIB0003 // Type or member is obsolete +#endif [assembly: TypeForwardedTo(typeof(System.Collections.ObjectModel.ReadOnlyObservableCollection<>))] [assembly: TypeForwardedTo(typeof(System.Collections.ObjectModel.ObservableCollection<>))] diff --git a/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/IO/Packaging/CompoundFile/VersionPair.cs b/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/IO/Packaging/CompoundFile/VersionPair.cs index 4d71d8d4501..431ce2bdca1 100644 --- a/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/IO/Packaging/CompoundFile/VersionPair.cs +++ b/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/IO/Packaging/CompoundFile/VersionPair.cs @@ -109,8 +109,11 @@ public Int16 Minor /// Returns a string that represents the current VersionPair object. /// The string is of the form (major,minor). /// +#if NETFX + public override string ToString() => $"({_major},{_minor})"; +#else public override string ToString() => string.Create(null, stackalloc char[64], $"({_major},{_minor})"); - +#endif #endif #endregion diff --git a/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Security/Permissions/MediaPermission.cs b/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Security/Permissions/MediaPermission.cs new file mode 100644 index 00000000000..e44d2785908 --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Security/Permissions/MediaPermission.cs @@ -0,0 +1,65 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +#if NETFX + +namespace System.Security.Permissions +{ + public enum MediaPermissionAudio + { + NoAudio, + SiteOfOriginAudio, + SafeAudio, + AllAudio + } + + public enum MediaPermissionVideo + { + NoVideo, + SiteOfOriginVideo, + SafeVideo, + AllVideo, + } + + public enum MediaPermissionImage + { + NoImage, + SiteOfOriginImage, + SafeImage, + AllImage, + } + + public sealed class MediaPermission : CodeAccessPermission, IUnrestrictedPermission + { + public MediaPermission() { } + public MediaPermission(PermissionState state) { } + public MediaPermission(MediaPermissionAudio permissionAudio) { } + public MediaPermission(MediaPermissionVideo permissionVideo) { } + public MediaPermission(MediaPermissionImage permissionImage) { } + public MediaPermission(MediaPermissionAudio permissionAudio, + MediaPermissionVideo permissionVideo, + MediaPermissionImage permissionImage) + { } + public bool IsUnrestricted() { return true; } + public override bool IsSubsetOf(IPermission target) { return true; } + public override IPermission Intersect(IPermission target) { return new MediaPermission(); } + public override IPermission Union(IPermission target) { return new MediaPermission(); } + public override IPermission Copy() { return new MediaPermission(); } + public override SecurityElement ToXml() { return default(SecurityElement); } + public override void FromXml(SecurityElement securityElement) { } + public MediaPermissionAudio Audio { get { return MediaPermissionAudio.AllAudio; } } + public MediaPermissionVideo Video { get { return MediaPermissionVideo.AllVideo; } } + public MediaPermissionImage Image { get { return MediaPermissionImage.AllImage; } } + } + + [AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Assembly, AllowMultiple = true, Inherited = false)] + public sealed class MediaPermissionAttribute : CodeAccessSecurityAttribute + { + public MediaPermissionAttribute(SecurityAction action) : base(action) { } + public override IPermission CreatePermission() { return new MediaPermission(); } + public MediaPermissionAudio Audio { get { return MediaPermissionAudio.AllAudio; } set { } } + public MediaPermissionVideo Video { get { return MediaPermissionVideo.AllVideo; } set { } } + public MediaPermissionImage Image { get { return MediaPermissionImage.AllImage; } set { } } + } +} +#endif diff --git a/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Security/Permissions/WebBrowserPermissions.cs b/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Security/Permissions/WebBrowserPermissions.cs new file mode 100644 index 00000000000..d062bdb4925 --- /dev/null +++ b/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Security/Permissions/WebBrowserPermissions.cs @@ -0,0 +1,38 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +#if NETFX + +namespace System.Security.Permissions +{ + public enum WebBrowserPermissionLevel + { + None, + Safe, + Unrestricted + } + + public sealed class WebBrowserPermission : CodeAccessPermission, IUnrestrictedPermission + { + public WebBrowserPermission() { } + public WebBrowserPermission(PermissionState state) { } + public WebBrowserPermission(WebBrowserPermissionLevel webBrowserPermissionLevel) { } + public bool IsUnrestricted() { return true; } + public override bool IsSubsetOf(IPermission target) { return true; } + public override IPermission Intersect(IPermission target) { return new WebBrowserPermission(); } + public override IPermission Union(IPermission target) { return new WebBrowserPermission(); } + public override IPermission Copy() { return new WebBrowserPermission(); } + public override SecurityElement ToXml() { return default(SecurityElement); } + public override void FromXml(SecurityElement securityElement) { } + public WebBrowserPermissionLevel Level { get { return WebBrowserPermissionLevel.Unrestricted; } set { } } + } + + [AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Assembly, AllowMultiple = true, Inherited = false)] + public sealed class WebBrowserPermissionAttribute : CodeAccessSecurityAttribute + { + public WebBrowserPermissionAttribute(SecurityAction action) : base(action) { } + public override IPermission CreatePermission() { return new WebBrowserPermission(); } + public WebBrowserPermissionLevel Level { get { return WebBrowserPermissionLevel.Unrestricted; } set { } } + } +} +#endif diff --git a/src/Microsoft.DotNet.Wpf/src/WindowsBase/WindowsBase.csproj b/src/Microsoft.DotNet.Wpf/src/WindowsBase/WindowsBase.csproj index 6ec5301c16c..d6aeae61e54 100644 --- a/src/Microsoft.DotNet.Wpf/src/WindowsBase/WindowsBase.csproj +++ b/src/Microsoft.DotNet.Wpf/src/WindowsBase/WindowsBase.csproj @@ -360,6 +360,14 @@ + + + + + + + +