Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add netstandard2.0 target framework support for System.Xaml #51

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from 7 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
4 changes: 2 additions & 2 deletions src/Microsoft.DotNet.Wpf/src/System.Xaml/System.Xaml.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<ProjectGuid>{9AC36357-34B7-40A1-95CA-FE9F46D089A7}</ProjectGuid>
<AssemblyName>System.Xaml</AssemblyName>
<TargetFrameworks>netcoreapp3.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net461;netcoreapp2.0;netcoreapp2.1;netcoreapp3.0</TargetFrameworks>
<Platforms>AnyCPU;x64</Platforms>

wieslawsoltes marked this conversation as resolved.
Show resolved Hide resolved
<NoWarn>$(NoWarn);0618;NU5125</NoWarn>
Expand Down Expand Up @@ -70,7 +70,7 @@

<ItemGroup>
<Compile Remove="System\Xaml\XamlProperty.cs" />
<Compile Remove="System\Windows\Markup\ValueSerializerAttribute.cs" />
<Compile Remove="System\Windows\Markup\ValueSerializerAttribute.cs" Condition="'$(TargetFramework)'=='net461' OR '$(TargetFramework)'=='netcoreapp3.0'" />
<Compile Remove="System\Xaml\Schema\ClrProperty.cs" />
<Compile Remove="System\Xaml\Schema\ImplicitProperty.cs" />
<Compile Remove="System\Xaml\Schema\ClrAttachableEvent.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,68 @@
using System;
using System.Runtime.CompilerServices;

#if NETSTANDARD2_0 || NETCOREAPP2_0 || NETCOREAPP2_1
namespace System.Windows.Markup
{
/// <summary>
/// Attribute to associate a ValueSerializer class with a value type or to override
/// which value serializer to use for a property. A value serializer can be associated
/// with an attached property by placing the attribute on the static accessor for the
/// attached property.
/// </summary>
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Property | AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
[TypeForwardedFrom("WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35")]
public sealed class ValueSerializerAttribute : Attribute
{
private Type _valueSerializerType;
private string _valueSerializerTypeName;

/// <summary>
/// Constructor for the ValueSerializerAttribute
/// </summary>
/// <param name="valueSerializerType">Type of the value serializer being associated with a type or property</param>
public ValueSerializerAttribute(Type valueSerializerType)
{
_valueSerializerType = valueSerializerType;
}

/// <summary>
/// Constructor for the ValueSerializerAttribute
/// </summary>
/// <param name="valueSerializerTypeName">Fully qualified type name of the value serializer being associated with a type or property</param>
public ValueSerializerAttribute(string valueSerializerTypeName)
{
_valueSerializerTypeName = valueSerializerTypeName;
}

/// <summary>
/// The type of the value serializer to create for this type or property.
/// </summary>
public Type ValueSerializerType
{
get
{
if (_valueSerializerType == null && _valueSerializerTypeName != null)
_valueSerializerType = Type.GetType(_valueSerializerTypeName);
return _valueSerializerType;
}
}

/// <summary>
/// The assembly qualified name of the value serializer type for this type or property.
/// </summary>
public string ValueSerializerTypeName
{
get
{
if (_valueSerializerType != null)
return _valueSerializerType.AssemblyQualifiedName;
else
return _valueSerializerTypeName;
}
}
}
}
#else
[assembly:TypeForwardedTo(typeof(System.Windows.Markup.ValueSerializerAttribute))]
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ private XamlRuntime CreateRuntime(XamlObjectWriterSettings settings, XamlSchemaC
if (settings != null)
{
runtimeSettings = new XamlRuntimeSettings { IgnoreCanConvert = settings.IgnoreCanConvert };
#if !TARGETTING35SP1
#if !TARGETTING35SP1 && !NETSTANDARD2_0
if (settings.AccessLevel != null)
{
result = new PartialTrustTolerantRuntime(runtimeSettings, settings.AccessLevel, schemaContext);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using System.Xaml.Permissions;
using System.Xaml.MS.Impl;

#if !NETSTANDARD2_0
namespace MS.Internal.Xaml.Runtime
{

Expand Down Expand Up @@ -744,3 +745,4 @@ private void Emit_TypeOf(ILGenerator ilGenerator, Type type)
}
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using System.Xaml.Schema;
using System.Xaml.Permissions;

#if !NETSTANDARD2_0
namespace MS.Internal.Xaml.Runtime
{
// Perf notes
Expand Down Expand Up @@ -464,3 +465,4 @@ private static bool IsDefaultConverter<TConverterBase>(XamlValueConverter<TConve
}
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -1123,7 +1123,11 @@ public bool IsComplete
}
}

#if NETCOREAPP2_0 || NETCOREAPP2_1 || NETCOREAPP3_0
public new V TryAdd(K name, V member)
#else
public V TryAdd(K name, V member)
#endif
{
// This instance is always held in a private field, safe to lock on
lock (this)
Expand Down