Skip to content

Commit

Permalink
Merge branch 'master' into fix-idictionary-clear
Browse files Browse the repository at this point in the history
  • Loading branch information
ujjwalchadha committed Nov 3, 2020
2 parents 5b17869 + 8d6b661 commit 4ac4147
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 13 deletions.
26 changes: 22 additions & 4 deletions UnitTest/TestComponentCSharp_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,26 @@ public void TestVectorCastConversion()
var uriVector = vector.Cast<Uri>();
var first = uriVector.First();
Assert.Equal(vector, uriVector);
}

}

async Task LookupPorts()
{
var ports = await Windows.Devices.Enumeration.DeviceInformation.FindAllAsync(
Windows.Devices.SerialCommunication.SerialDevice.GetDeviceSelector(),
new string[] { "System.ItemNameDisplay" });
foreach (var port in ports)
{
object o = port.Properties["System.ItemNameDisplay"];
Assert.NotNull(o);
}
}

[Fact]
public void TestReadOnlyDictionaryLookup()
{
Assert.True(LookupPorts().Wait(1000));
}

#if NET5_0
[Fact]
public void TestAsStream()
Expand Down Expand Up @@ -353,8 +371,8 @@ public void TestBuffer()
Assert.True(arr1[1] == arr2[1]);
}

#endif

#endif

async Task TestStorageFileAsync()
{
var folderPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
Expand Down
2 changes: 1 addition & 1 deletion WinRT.Runtime/Projections/IReadOnlyDictionary.net5.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public class FromAbiHelper : global::System.Collections.Generic.IReadOnlyDiction
public FromAbiHelper(global::Windows.Foundation.Collections.IMapView<K, V> mapView, ObjectReference<Vftbl> objRef)
{
_mapView = mapView;
_enumerable = (System.Collections.Generic.IEnumerable<global::System.Collections.Generic.KeyValuePair<K, V>>)new IInspectable(objRef);
_enumerable = (global::System.Collections.Generic.IEnumerable<global::System.Collections.Generic.KeyValuePair<K, V>>)new IInspectable(objRef);
}

public int Count
Expand Down
25 changes: 18 additions & 7 deletions WinRT.Runtime/Projections/Type.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ internal void Dispose()
}
}

public static Marshaler CreateMarshaler(global::System.Type value)
{
private static (String Name, TypeKind Kind) ToAbi(global::System.Type value)
{
TypeKind kind = TypeKind.Custom;

if (value is object)
Expand All @@ -47,12 +47,18 @@ public static Marshaler CreateMarshaler(global::System.Type value)
{
kind = TypeKind.Metadata;
}
}
}

return (kind == TypeKind.Custom ? value.AssemblyQualifiedName : TypeNameSupport.GetNameForType(value, TypeNameGenerationFlags.None), kind);
}

public static Marshaler CreateMarshaler(global::System.Type value)
{
var abi = ToAbi(value);
return new Marshaler
{
Name = MarshalString.CreateMarshaler(kind == TypeKind.Custom ? value.AssemblyQualifiedName : TypeNameSupport.GetNameForType(value, TypeNameGenerationFlags.None)),
Kind = kind
Name = MarshalString.CreateMarshaler(abi.Name),
Kind = abi.Kind
};
}

Expand Down Expand Up @@ -85,8 +91,13 @@ public static unsafe void CopyAbi(Marshaler arg, IntPtr dest) =>
*(Type*)dest.ToPointer() = GetAbi(arg);

public static Type FromManaged(global::System.Type value)
{
return GetAbi(CreateMarshaler(value));
{
var abi = ToAbi(value);
return new Type
{
Name = MarshalString.FromManaged(abi.Name),
Kind = abi.Kind
};
}

public static unsafe void CopyManaged(global::System.Type arg, IntPtr dest) =>
Expand Down
3 changes: 2 additions & 1 deletion nuget/Microsoft.Windows.CsWinRT.targets
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Copyright (C) Microsoft Corporation. All rights reserved.
<CsWinRTGenerateProjection Condition="'$(CsWinRTGenerateProjection)' == ''">true</CsWinRTGenerateProjection>
<AllowUnsafeBlocks Condition="'$(CsWinRTComponent)' == 'true'">true</AllowUnsafeBlocks>
<AllowUnsafeBlocks Condition="$(CsWinRTEnabled)">true</AllowUnsafeBlocks>
<CoreCompileDependsOn>CsWinRTIncludeProjection;CsWinRTRemoveWinMDReferences;$(CoreCompileDependsOn)</CoreCompileDependsOn>
</PropertyGroup>

<!--Remove Windows.Winmd reference to prevent compile collisions-->
Expand All @@ -24,7 +25,7 @@ Copyright (C) Microsoft Corporation. All rights reserved.
</ItemGroup>
</Target>

<Target Name="CsWinRTRemoveWinMDReferences" BeforeTargets="ResolveReferences;BeforeCompile" AfterTargets="AfterResolveReferences">
<Target Name="CsWinRTRemoveWinMDReferences" BeforeTargets="BeforeCompile" AfterTargets="ResolveReferences">
<ItemGroup>
<!--Move winmd references into private item group to prevent subsequent winmd reference errors-->
<CsWinRTRemovedReferences Include="@(ReferencePath)" Condition="'%(ReferencePath.Extension)' == '.winmd'" />
Expand Down

0 comments on commit 4ac4147

Please sign in to comment.