Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
<PropertyGroup>
<RepositoryName>wpf</RepositoryName>
<WindowsDesktopARM64Support>true</WindowsDesktopARM64Support>
<TargetFramework>net8.0</TargetFramework>
<TargetFrameworkVersion>8.0</TargetFrameworkVersion>
<TargetFramework>net481</TargetFramework>
<TargetFrameworkVersion>4.8.1</TargetFrameworkVersion>
<RunRefApiCompat>false</RunRefApiCompat>
</PropertyGroup>
<!-- Normalize $(TestWpfArcadeSdkPath) by appending a '\' to it if one is missing -->
<PropertyGroup Condition="'$(TestWpfArcadeSdkPath)'!=''">
Expand All @@ -22,6 +23,11 @@
<WpfArcadeSdkTargets>$(WpfArcadeSdkPath)Sdk\Sdk.targets</WpfArcadeSdkTargets>
</PropertyGroup>

<ItemDefinitionGroup Condition="'$(TargetFrameworkIdentifier)'=='.NETFramework'">
<!-- We always want MSBuild properties generated that point at the restored location of each package. -->
<PackageReference GeneratePathProperty="true" />
</ItemDefinitionGroup>

<Import Project="$(WpfArcadeSdkProps)"
Condition="Exists('$(WpfArcadeSdkProps)') And Exists('$(WpfArcadeSdkTargets)')"/>

Expand Down
31 changes: 31 additions & 0 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,35 @@
Project="Sdk.targets"
Condition="!Exists('$(WpfArcadeSdkProps)') Or !Exists('$(WpfArcadeSdkTargets)')"/>

<PropertyGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework' and '$(SignAssembly)' != 'false' and '$(PublicSign)' == 'true'">
<!-- Don't public sign .NETFramework assemblies -->
<DelaySign>true</DelaySign>
<PublicSign>false</PublicSign>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFrameworkIdentifier)'=='.NETFramework'">
<PackageReference Include="$(SystemIOPackagingPackage)" Version="$(SystemIOPackagingVersion)" ExcludeAssets="compile" />
<PackageReference Include="$(SystemMemoryPackage)" Version="$(SystemMemoryPackageVersion)" />
</ItemGroup>

<Target Condition="'$(TargetFrameworkIdentifier)'=='.NETFramework'" Name="FixNetFxReferences" BeforeTargets="ResolveAssemblyReferences">
<ItemGroup>
<Reference Remove="WindowsBase" />
<Reference Remove="$(FrameworkPathOverride)\WindowsBase.dll" />
<Reference Remove="$(PkgSystem_IO_Packaging)\lib\net462\System.IO.Packaging.dll" />
</ItemGroup>
<ItemGroup>
<Reference Include="Accessibility" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.Security" />
<Reference Include="System.Windows.Forms" />
<Reference Include="$(PkgSystem_IO_Packaging)\lib\netstandard2.0\System.IO.Packaging.dll" />
</ItemGroup>
</Target>

<Target Condition="'$(TargetFrameworkIdentifier)'=='.NETFramework'" Name="AliasNetFxReferences" AfterTargets="ResolveAssemblyReferences" BeforeTargets="CoreCompile">
<ItemGroup>
<ReferencePath Include="@(ReferencePath->WithMetadataValue('FileName', 'System'))" Aliases="System" />
</ItemGroup>
</Target>
</Project>
2 changes: 2 additions & 0 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<SystemDrawingCommonVersion>8.0.12</SystemDrawingCommonVersion>
<SystemDirectoryServicesVersion>8.0.0</SystemDirectoryServicesVersion>
<SystemIOPackagingVersion>8.0.1</SystemIOPackagingVersion>
<SystemMemoryPackageVersion>4.6.0</SystemMemoryPackageVersion>
<SystemReflectionMetadataLoadContextVersion>8.0.1</SystemReflectionMetadataLoadContextVersion>
<SystemReflectionTypeExtensionsPackageVersion>4.6.0-preview4.19176.11</SystemReflectionTypeExtensionsPackageVersion>
<SystemResourcesExtensionsVersion>8.0.0</SystemResourcesExtensionsVersion>
Expand Down Expand Up @@ -95,6 +96,7 @@
<SystemDirectoryServicesPackage>System.DirectoryServices</SystemDirectoryServicesPackage>
<MicrosoftDotNetWpfDncEngPackage>Microsoft.DotNet.Wpf.DncEng</MicrosoftDotNetWpfDncEngPackage>
<SystemIOPackagingPackage>System.IO.Packaging</SystemIOPackagingPackage>
<SystemMemoryPackage>System.Memory</SystemMemoryPackage>
<SystemReflectionMetadataLoadContextPackage>System.Reflection.MetadataLoadContext</SystemReflectionMetadataLoadContextPackage>
</PropertyGroup>
<PropertyGroup>
Expand Down
3 changes: 2 additions & 1 deletion eng/WpfArcadeSdk/tools/Wpf.Cpp.props
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,8 @@
<!--<AdditionalOptions>/Zc:twoPhase- %(AdditionalOptions)</AdditionalOptions>-->
<!--<ConformanceMode>false</ConformanceMode>-->

<AdditionalOptions Condition="'$(ManagedCxx)'=='true'">%(AdditionalOptions) /clr:netcore /wd4956</AdditionalOptions>
<AdditionalOptions Condition="('$(ManagedCxx)'=='true') and ('$(TargetFramework)'!='net481')">%(AdditionalOptions) /clr:netcore /wd4956</AdditionalOptions>
<AdditionalOptions Condition="('$(ManagedCxx)'=='true') and ('$(TargetFramework)'=='net481')">%(AdditionalOptions) /wd4956</AdditionalOptions>
<ShowIncludes Condition="'$(ShowIncludes)'=='true'">true</ShowIncludes>
</ClCompile>
<Link>
Expand Down
26 changes: 24 additions & 2 deletions eng/WpfArcadeSdk/tools/Wpf.Cpp.targets
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,15 @@ using namespace System::Runtime::Versioning;
<Output ItemName="_NugetReferencesForCppCli" TaskParameter="Result" />
</FilterItem1ByItem2>
</Target>
<Target
Name="GetPackagePathProperties"
Returns="%40(NugetPackagePaths)">
<ItemGroup>
<NugetPackagePaths Include="PkgSystem_IO_Packaging">
<Value>%24(PkgSystem_IO_Packaging)</Value>
</NugetPackagePaths>
</ItemGroup>
</Target>
<ItemGroup>
<NugetReferencesForCppCli Include="%40(_NugetReferencesForCppCli->'%25(OriginalItemSpec)')" />
</ItemGroup>
Expand Down Expand Up @@ -410,11 +419,24 @@ using namespace System::Runtime::Versioning;
</ProjectToBuild>
</ItemGroup>
<MSBuild Projects="@(ProjectToBuild)"
Targets="Restore;ResolveReferences;IdentifyNugetReferences"
Targets="Restore"
Properties="TargetFramework=$(TargetFramework);Platform=$(Architecture);RuntimeIdentifier=win-$(Architecture);ForceEvalOnNextMsBuild=true" />

<MSBuild Projects="@(ProjectToBuild)"
Targets="ResolveReferences;IdentifyNugetReferences;GetPackagePathProperties"
Properties="TargetFramework=$(TargetFramework);Platform=$(Architecture);RuntimeIdentifier=win-$(Architecture)">
<Output TaskParameter="TargetOutputs" ItemName="NugetReferencesForCppCli" />
<Output TaskParameter="TargetOutputs" ItemName="MixedTargetOutputs" />
</MSBuild>

<ItemGroup>
<NugetReferencesForCppCli Condition="'%(MixedTargetOutputs.MSBuildSourceTargetName)'=='ResolveReferences'" Include="@(MixedTargetOutputs)" />
<NugetPackagePaths Condition="'%(MixedTargetOutputs.MSBuildSourceTargetName)'=='GetPackagePathProperties'" Include="@(MixedTargetOutputs)" />
</ItemGroup>

<CreateProperty Value="%(NugetPackagePaths.Value)">
<Output TaskParameter="Value" PropertyName="%(NugetPackagePaths.Identity)" />
</CreateProperty>

<!--
Add the newly discovered list of .NET core references to $(AdditionalExplicitAssemblyReferences)
-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@
</ItemGroup>

<!-- Windows Forms validation and packaging -->
<Import Project="Microsoft.NET.Sdk.WindowsDesktop.WinForms.Packaging.targets" />
<Import Condition="$(TargetFramework.StartsWith('net4'))!='true'" Project="Microsoft.NET.Sdk.WindowsDesktop.WinForms.Packaging.targets" />

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,20 @@
<PropertyGroup>
<UseDestinationLibFolder>true</UseDestinationLibFolder>
<TargetFrameworkIdentifier>.NETCoreApp</TargetFrameworkIdentifier>
<TargetFrameworkIdentifier Condition="$(TargetFramework.StartsWith('net4'))!='true'">.NETFramework</TargetFrameworkIdentifier>
<RestoreProjectStyle>Unknown</RestoreProjectStyle>
<!--
<!--
Opting out of this to ensure _WindowsBaseReference is used as
OutputItemsType in the project reference later.
-->
<LegacyNativeReferenceResolution>true</LegacyNativeReferenceResolution>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup>
<Keyword>NetCoreCProj</Keyword>
<CLRSupport>pure</CLRSupport>
<Keyword Condition="'$(TargetFrameworkIdentifier)'!='.NETFramework'">NetCoreCProj</Keyword>
<Keyword Condition="'$(TargetFrameworkIdentifier)'=='.NETFramework'">ManagedCProj</Keyword>
<CLRSupport Condition="'$(TargetFrameworkIdentifier)'!='.NETFramework'">pure</CLRSupport>
<CLRSupport Condition="'$(TargetFrameworkIdentifier)'=='.NETFramework'">true</CLRSupport>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<ConfigurationType>DynamicLibrary</ConfigurationType>
</PropertyGroup>
Expand Down Expand Up @@ -89,7 +92,7 @@
<!--
PackageReferences to pass to CppCliHelper target
-->
<ItemGroup>
<ItemGroup Condition="'$(TargetFrameworkIdentifier)'!='.NETFramework'">
<AdditionalPackageReference Include="$(SystemIOPackagingPackage)" Version="$(SystemIOPackagingVersion)" />
</ItemGroup>
<!--
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net472;net8.0</TargetFrameworks>
<TargetFrameworks>net472;net481;net8.0</TargetFrameworks>
<EnableDefaultItems>false</EnableDefaultItems>
<EnablePInvokeAnalyzer>true</EnablePInvokeAnalyzer>

Expand Down Expand Up @@ -51,7 +51,7 @@
<!--
Limit the assemblies that are packaged into Microsoft.NET.Sdk.WindowsDesktop
-->
<ItemGroup Condition="'$(TargetFramework)'=='net472'">
<ItemGroup Condition="'$(TargetFrameworkIdentifier)'=='.NETFramework'">
<PackagingAssemblyContent Include="PresentationBuildTasks.dll" />
<PackagingAssemblyContent Include="System.Collections.Immutable.dll" />
<PackagingAssemblyContent Include="System.Memory.dll" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<char> contentRangeSpan = contentRange.AsSpan(index + 1);
// ContentRange: YYY/ZZZ
Expand All @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1360,6 +1360,13 @@
<Compile Include="System\Windows\Resources\AssemblyAssociatedContentFileAttribute.cs" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFrameworkIdentifier)'=='.NETFramework'">
<Compile Include="$(WpfSharedDir)\OtherAssemblyAttrs.Global.cs" />
<Compile Include="$(WpfSharedDir)\System\DictionaryHelpers.cs" />
<Compile Include="$(WpfSharedDir)\System\InternalArgumentNullException.cs" />
<Compile Include="$(WpfSharedDir)\System\ReferenceEqualityComparer.cs" />
</ItemGroup>

<ItemGroup>
<NetCoreReference Include="Microsoft.Win32.Primitives" />
<NetCoreReference Include="Microsoft.Win32.Registry" />
Expand Down Expand Up @@ -1405,8 +1412,8 @@

<ItemGroup>
<PackageReference Include="System.Configuration.ConfigurationManager" Version="$(SystemConfigurationConfigurationManagerPackageVersion)" />
<PackageReference Include="System.Windows.Extensions" Version="$(SystemWindowsExtensionsPackageVersion)" />
<PackageReference Include="$(SystemIOPackagingPackage)" Version="$(SystemIOPackagingVersion)" />
<PackageReference Condition="'$(TargetFrameworkIdentifier)'!='.NETFramework'" Include="System.Windows.Extensions" Version="$(SystemWindowsExtensionsPackageVersion)" />
<PackageReference Condition="'$(TargetFrameworkIdentifier)'!='.NETFramework'" Include="$(SystemIOPackagingPackage)" Version="$(SystemIOPackagingVersion)" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<InputScopeNameValue>(spanSource);
#endif
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<char>)stackalloc char[] { '%' });
#endif

case KeyTimeType.TimeSpan:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,11 @@ private static double[] ParseMetrics(string s)
// Non-empty field; convert it to double.
ReadOnlySpan<char> 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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@

namespace System.Windows.Media
{
#if NETFX
using ArgumentNullException = System.Xaml.ArgumentNullException;
#endif

/// <summary>
/// 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
<GenerateResourcesSRNamespace>MS.Internal.PresentationCore</GenerateResourcesSRNamespace>
<ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>None</ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>
<Platforms>AnyCPU;x64;arm64</Platforms>

</PropertyGroup>

<ItemGroup>
Expand Down Expand Up @@ -63,8 +62,8 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="System.Configuration.ConfigurationManager" Version="$(SystemConfigurationConfigurationManagerPackageVersion)" />
<PackageReference Include="System.Windows.Extensions" Version="$(SystemWindowsExtensionsPackageVersion)" />
<PackageReference Include="$(SystemIOPackagingPackage)" Version="$(SystemIOPackagingVersion)" />
<PackageReference Condition="'$(TargetFrameworkIdentifier)'!='.NETFramework'" Include="System.Windows.Extensions" Version="$(SystemWindowsExtensionsPackageVersion)" />
<PackageReference Condition="'$(TargetFrameworkIdentifier)'!='.NETFramework'" Include="$(SystemIOPackagingPackage)" Version="$(SystemIOPackagingVersion)" />
</ItemGroup>
<ItemGroup>
<!-- required for internals access -->
Expand Down
Loading