Skip to content

Commit 2c58710

Browse files
Update nuget icon (#146)
* Updated targets and props files to include nuget package icon * Fixed GraphPresenter after props and targets update * Updated Graph version in UnitTests app * Fixed issue with xaml type reflection * Commented out TreatWarningAsErrors
1 parent ad7efbd commit 2c58710

File tree

13 files changed

+204
-123
lines changed

13 files changed

+204
-123
lines changed

CommunityToolkit.Authentication.Msal/CommunityToolkit.Authentication.Msal.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2+
23
<PropertyGroup>
34
<TargetFramework>netstandard2.0</TargetFramework>
45

CommunityToolkit.Graph.Uwp/CommunityToolkit.Graph.Uwp.csproj

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@
2121
<PackageTags>UWP Community Toolkit Windows Controls Microsoft Graph Login Person PeoplePicker Presenter</PackageTags>
2222
<LangVersion>9.0</LangVersion>
2323
</PropertyGroup>
24-
25-
<ItemGroup>
26-
<ProjectReference Include="..\CommunityToolkit.Authentication\CommunityToolkit.Authentication.csproj" />
27-
<ProjectReference Include="..\CommunityToolkit.Graph\CommunityToolkit.Graph.csproj" />
28-
</ItemGroup>
2924

3025
<ItemGroup>
3126
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
32-
<PackageReference Include="Microsoft.Graph" Version="4.0.0" />
27+
<PackageReference Include="Microsoft.Graph" Version="4.2.0" />
3328
<PackageReference Include="Microsoft.Toolkit.Uwp.UI.Controls.Input" Version="7.0.2" />
3429
</ItemGroup>
30+
31+
<ItemGroup>
32+
<ProjectReference Include="..\CommunityToolkit.Authentication\CommunityToolkit.Authentication.csproj" />
33+
<ProjectReference Include="..\CommunityToolkit.Graph\CommunityToolkit.Graph.csproj" />
34+
</ItemGroup>
3535

3636
<ItemGroup>
3737
<Content Include="Assets\person.png" />
@@ -50,4 +50,5 @@
5050
<Message Text="CSFiles: @(GeneratedCSFiles->'&quot;%(Identity)&quot;')" />
5151
<Exec Command="for %%f in (@(GeneratedCSFiles->'&quot;%(Identity)&quot;')) do echo #pragma warning disable &gt; %%f.temp &amp;&amp; type %%f &gt;&gt; %%f.temp &amp;&amp; move /y %%f.temp %%f &gt; NUL" />
5252
</Target>
53+
5354
</Project>

CommunityToolkit.Graph.Uwp/Controls/GraphPresenter/GraphPresenter.cs

Lines changed: 39 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
using System;
66
using System.Collections.Generic;
77
using System.Linq;
8+
using System.Text.Json;
89
using System.Threading;
910
using Microsoft.Graph;
1011
using Microsoft.Toolkit.Uwp;
11-
using Newtonsoft.Json.Linq;
1212
using Windows.System;
1313
using Windows.UI.Xaml;
1414
using Windows.UI.Xaml.Controls;
@@ -20,14 +20,6 @@ namespace CommunityToolkit.Graph.Uwp.Controls
2020
/// </summary>
2121
public class GraphPresenter : ContentPresenter
2222
{
23-
/// <summary>
24-
/// Gets or sets a <see cref="IBaseRequestBuilder"/> to be used to make a request to the graph. The results will be automatically populated to the <see cref="ContentPresenter.Content"/> property. Use a <see cref="ContentPresenter.ContentTemplate"/> to change the presentation of the data.
25-
/// </summary>
26-
public IBaseRequestBuilder RequestBuilder
27-
{
28-
get { return (IBaseRequestBuilder)GetValue(RequestBuilderProperty); }
29-
set { SetValue(RequestBuilderProperty, value); }
30-
}
3123

3224
/// <summary>
3325
/// Identifies the <see cref="RequestBuilder"/> dependency property.
@@ -38,6 +30,23 @@ public IBaseRequestBuilder RequestBuilder
3830
public static readonly DependencyProperty RequestBuilderProperty =
3931
DependencyProperty.Register(nameof(RequestBuilder), typeof(IBaseRequestBuilder), typeof(GraphPresenter), new PropertyMetadata(null));
4032

33+
/// <summary>
34+
/// Initializes a new instance of the <see cref="GraphPresenter"/> class.
35+
/// </summary>
36+
public GraphPresenter()
37+
{
38+
this.Loaded += this.GraphPresenter_Loaded;
39+
}
40+
41+
/// <summary>
42+
/// Gets or sets a <see cref="IBaseRequestBuilder"/> to be used to make a request to the graph. The results will be automatically populated to the <see cref="ContentPresenter.Content"/> property. Use a <see cref="ContentPresenter.ContentTemplate"/> to change the presentation of the data.
43+
/// </summary>
44+
public IBaseRequestBuilder RequestBuilder
45+
{
46+
get { return (IBaseRequestBuilder)this.GetValue(RequestBuilderProperty); }
47+
set { this.SetValue(RequestBuilderProperty, value); }
48+
}
49+
4150
/// <summary>
4251
/// Gets or sets the <see cref="Type"/> of item returned by the <see cref="RequestBuilder"/>.
4352
/// Set to the base item type and use the <see cref="IsCollection"/> property to indicate if a collection is expected back.
@@ -59,52 +68,47 @@ public IBaseRequestBuilder RequestBuilder
5968
/// </summary>
6069
public string OrderBy { get; set; }
6170

62-
/// <summary>
63-
/// Initializes a new instance of the <see cref="GraphPresenter"/> class.
64-
/// </summary>
65-
public GraphPresenter()
66-
{
67-
Loaded += GraphPresenter_Loaded;
68-
}
69-
7071
private async void GraphPresenter_Loaded(object sender, RoutedEventArgs e)
7172
{
7273
var dispatcherQueue = DispatcherQueue.GetForCurrentThread();
7374

7475
// Note: some interfaces from the Graph SDK don't implement IBaseRequestBuilder properly, see https://github.com/microsoftgraph/msgraph-sdk-dotnet/issues/722
75-
if (RequestBuilder != null)
76+
if (this.RequestBuilder != null)
7677
{
77-
var request = new BaseRequest(RequestBuilder.RequestUrl, RequestBuilder.Client) // TODO: Do we need separate Options here?
78+
var request = new BaseRequest(this.RequestBuilder.RequestUrl, this.RequestBuilder.Client) // TODO: Do we need separate Options here?
7879
{
7980
Method = HttpMethods.GET,
80-
QueryOptions = QueryOptions?.Select(option => (Microsoft.Graph.QueryOption)option)?.ToList() ?? new List<Microsoft.Graph.QueryOption>(),
81+
QueryOptions = this.QueryOptions?.Select(option => (Microsoft.Graph.QueryOption)option)?.ToList() ?? new List<Microsoft.Graph.QueryOption>(),
8182
};
8283

8384
// Handle Special QueryOptions
84-
if (!string.IsNullOrWhiteSpace(OrderBy))
85+
if (!string.IsNullOrWhiteSpace(this.OrderBy))
8586
{
86-
request.QueryOptions.Add(new Microsoft.Graph.QueryOption("$orderby", OrderBy));
87+
request.QueryOptions.Add(new Microsoft.Graph.QueryOption("$orderby", this.OrderBy));
8788
}
8889

8990
try
9091
{
91-
var response = await request.SendAsync<object>(null, CancellationToken.None).ConfigureAwait(false) as JObject;
92+
var responseObj = await request.SendAsync<object>(null, CancellationToken.None).ConfigureAwait(false);
9293

93-
//// TODO: Deal with paging?
94+
if (responseObj is JsonElement responseElement)
95+
{
96+
//// TODO: Deal with paging?
9497

95-
var values = response["value"];
96-
object data = null;
98+
var value = responseElement.GetProperty("value");
99+
object data = null;
97100

98-
if (IsCollection)
99-
{
100-
data = values.ToObject(Array.CreateInstance(ResponseType, 0).GetType());
101-
}
102-
else
103-
{
104-
data = values.ToObject(ResponseType);
105-
}
101+
if (this.IsCollection)
102+
{
103+
data = value.EnumerateArray().ToList().Select(elem => System.Text.Json.JsonSerializer.Deserialize(elem.GetRawText(), this.ResponseType));
104+
}
105+
else
106+
{
107+
data = System.Text.Json.JsonSerializer.Deserialize(value.GetRawText(), this.ResponseType);
108+
}
106109

107-
_ = dispatcherQueue.EnqueueAsync(() => Content = data);
110+
_ = dispatcherQueue.EnqueueAsync(() => this.Content = data);
111+
}
108112
}
109113
catch
110114
{

CommunityToolkit.Graph/CommunityToolkit.Graph.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
</PropertyGroup>
2121

2222
<ItemGroup>
23-
<PackageReference Include="Microsoft.Graph" Version="4.0.0" />
23+
<PackageReference Include="Microsoft.Graph" Version="4.2.0" />
2424
<PackageReference Include="Microsoft.Toolkit" Version="7.1.0-preview1" />
2525
</ItemGroup>
2626

Directory.Build.props

Lines changed: 32 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,94 +1,63 @@
11
<Project>
22

33
<PropertyGroup>
4-
<Authors>Microsoft.Toolkit</Authors>
5-
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
6-
<NoPackageAnalysis>true</NoPackageAnalysis>
7-
<PackageIconUrl>https://raw.githubusercontent.com/CommunityToolkit/CommunityToolkit/master/build/nuget.png</PackageIconUrl>
8-
<PackageProjectUrl>https://github.com/CommunityToolkit/WindowsCommunityToolkit</PackageProjectUrl>
9-
<PackageLicenseUrl>https://github.com/CommunityToolkit/WindowsCommunityToolkit/blob/master/License.md</PackageLicenseUrl>
10-
<PackageReleaseNotes>https://github.com/CommunityToolkit/WindowsCommunityToolkit/releases</PackageReleaseNotes>
11-
<Copyright>(c) .NET Foundation and Contributors. All rights reserved.</Copyright>
12-
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)Toolkit.ruleset</CodeAnalysisRuleSet>
13-
<DefaultLanguage>en-US</DefaultLanguage>
14-
<IsDesignProject>$(MSBuildProjectName.Contains('.Design'))</IsDesignProject>
15-
<IsTestProject>$(MSBuildProjectName.Contains('Test'))</IsTestProject>
16-
<IsUwpProject Condition="'$(IsDesignProject)' != 'true'">$(MSBuildProjectName.Contains('Uwp'))</IsUwpProject>
17-
<IsSampleProject>$(MSBuildProjectName.Contains('Sample'))</IsSampleProject>
18-
<IsWpfProject>$(MSBuildProjectName.Contains('Wpf'))</IsWpfProject>
19-
<DefaultTargetPlatformVersion>19041</DefaultTargetPlatformVersion>
20-
<DefaultTargetPlatformMinVersion>17763</DefaultTargetPlatformMinVersion>
21-
<PackageOutputPath>$(MSBuildThisFileDirectory)bin\nupkg</PackageOutputPath>
4+
<RepositoryDirectory>$(MSBuildThisFileDirectory)</RepositoryDirectory>
5+
<BuildToolsDirectory>$(RepositoryDirectory)build\</BuildToolsDirectory>
226
</PropertyGroup>
237

24-
<PropertyGroup>
25-
<SignAssembly Condition="'$(SignAssembly)' == '' and '$(IsUwpProject)' != 'true'" >true</SignAssembly>
26-
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)toolkit.snk</AssemblyOriginatorKeyFile>
27-
</PropertyGroup>
8+
<Import Project="$(BuildToolsDirectory)Windows.Toolkit.Common.props" />
289

2910
<Choose>
30-
<When Condition="'$(IsTestProject)' != 'true' and '$(IsSampleProject)' != 'true' and '$(IsDesignProject)' != 'true'">
11+
<When Condition="$(IsCoreProject)">
3112
<PropertyGroup>
3213
<GenerateDocumentationFile>true</GenerateDocumentationFile>
14+
<PackageOutputPath>$(RepositoryDirectory)bin\nupkg</PackageOutputPath>
15+
<GenerateLibraryLayout Condition="$(IsUwpProject)">true</GenerateLibraryLayout>
16+
<!--<TreatWarningsAsErrors Condition="'$(Configuration)' == 'Release'">true</TreatWarningsAsErrors>-->
3317
</PropertyGroup>
3418
</When>
19+
<Otherwise>
20+
<PropertyGroup>
21+
<IsPackable>false</IsPackable>
22+
<IsPublishable>false</IsPublishable>
23+
<NoWarn>$(NoWarn);CS8002;SA0001</NoWarn>
24+
</PropertyGroup>
25+
</Otherwise>
3526
</Choose>
3627

3728
<Choose>
38-
<When Condition="('$(IsUwpProject)' == 'true') and '$(IsSampleProject)' != 'true' and '$(IsDesignProject)' != 'true'">
29+
<When Condition="$(IsUwpProject)">
3930
<PropertyGroup>
40-
<GenerateLibraryLayout>true</GenerateLibraryLayout>
31+
<!-- Code CS8002 is a warning for strong named -> non-strong-named reference. This is valid for platforms other than .NET Framework (and is needed for the UWP targets. -->
32+
<NoWarn>$(NoWarn);CS8002</NoWarn>
33+
<!-- For including default @(Page) and @(Resource) items via 'MSBuild.Sdk.Extras' Sdk package. Also provides up to date check and file nesting -->
34+
<ExtrasEnableDefaultXamlItems>true</ExtrasEnableDefaultXamlItems>
4135
</PropertyGroup>
4236
</When>
4337
</Choose>
38+
39+
<ItemGroup>
40+
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="All" />
41+
</ItemGroup>
42+
43+
<ItemGroup>
44+
<PackageReference Include="Nerdbank.GitVersioning" Version="3.3.37" PrivateAssets="All" />
45+
</ItemGroup>
4446

4547
<Choose>
46-
<When Condition="'$(IsTestProject)' != 'true' and '$(SourceLinkEnabled)' != 'false' and '$(IsSampleProject)' != 'true' and '$(IsDesignProject)' != 'true'">
48+
<When Condition="!$(IsSampleProject) and '$(SourceLinkEnabled)' != 'false'">
4749
<PropertyGroup>
48-
<!-- Optional: Declare that the Repository URL can be published to NuSpec -->
50+
<!-- Declare that the Repository URL can be published to NuSpec -->
4951
<PublishRepositoryUrl>true</PublishRepositoryUrl>
50-
<!-- Optional: Embed source files that are not tracked by the source control manager to the PDB -->
52+
<!-- Embed source files that are not tracked by the source control manager to the PDB -->
5153
<EmbedUntrackedSources>true</EmbedUntrackedSources>
52-
<!-- Optional: Include PDB in the built .nupkg -->
54+
<!-- Include PDB in the built .nupkg -->
5355
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
5456
</PropertyGroup>
5557
<ItemGroup>
56-
<PackageReference Include="Microsoft.SourceLink.AzureRepos.Git" Version="1.0.0" PrivateAssets="All"/>
57-
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All"/>
58-
</ItemGroup>
59-
</When>
60-
</Choose>
61-
62-
<Choose>
63-
<When Condition="'$(IsTestProject)' != 'true' and '$(IsSampleProject)' != 'true' and '$(IsDesignProject)' != 'true' and '$(IsWpfProject)' != 'true'">
64-
<ItemGroup>
65-
<!--<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="15.3.83" PrivateAssets="all" />-->
66-
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" />
67-
68-
<EmbeddedResource Include="**\*.rd.xml" />
69-
<Page Include="**\*.xaml" Exclude="**\bin\**\*.xaml;**\obj\**\*.xaml" SubType="Designer" Generator="MSBuild:Compile" />
70-
<Compile Update="**\*.xaml.cs" DependentUpon="%(Filename)" />
58+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
7159
</ItemGroup>
72-
<PropertyGroup Condition="'$(Configuration)' == 'Release' or '$(Configuration)' == 'CI'">
73-
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
74-
</PropertyGroup>
7560
</When>
7661
</Choose>
7762

78-
<PropertyGroup Condition="'$(IsUwpProject)' == 'true'">
79-
80-
<!-- 8002 is a strong named -> non-strong-named reference -->
81-
<!-- This is valid for platforms other than .NET Framework (and is needed for the UWP targets -->
82-
<NoWarn>$(NoWarn);8002</NoWarn>
83-
</PropertyGroup>
84-
85-
<ItemGroup>
86-
<PackageReference Include="Nerdbank.GitVersioning" Version="3.3.37" PrivateAssets="all" />
87-
</ItemGroup>
88-
89-
<ItemGroup>
90-
<AdditionalFiles Include="$(MSBuildThisFileDirectory)stylecop.json">
91-
<Link>stylecop.json</Link>
92-
</AdditionalFiles>
93-
</ItemGroup>
9463
</Project>

Directory.Build.targets

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,32 @@
11
<Project>
2+
3+
<Import Project="$(BuildToolsDirectory)Windows.Toolkit.Common.targets" />
4+
5+
<PropertyGroup>
6+
<UseUWP Condition="($(TargetFramework.StartsWith('uap10.0')) or '$(TargetFramework)' == 'net461')">true</UseUWP>
7+
<UseUWP Condition="'$(UseUWP)' == ''">false</UseUWP>
8+
</PropertyGroup>
9+
210
<Choose>
3-
<When Condition="'$(TargetFramework)' == 'uap10.0' or '$(TargetFramework)' == 'uap10.0.17763' or '$(TargetFramework)' == 'native' or '$(TargetFramework)' == 'net461'">
4-
<!-- UAP versions for uap10.0 where TPMV isn't implied -->
11+
<When Condition="!($(TargetFramework.StartsWith('uap10.0')) or '$(TargetFramework)' == 'native' or $(IsSampleProject))">
512
<PropertyGroup>
6-
<TargetPlatformVersion>10.0.$(DefaultTargetPlatformVersion).0</TargetPlatformVersion>
7-
<TargetPlatformMinVersion>10.0.$(DefaultTargetPlatformMinVersion).0</TargetPlatformMinVersion>
8-
<DebugType>Full</DebugType>
13+
<SignAssembly>true</SignAssembly>
14+
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)toolkit.snk</AssemblyOriginatorKeyFile>
915
</PropertyGroup>
10-
11-
<ItemGroup>
12-
<SDKReference Condition="'$(UseWindowsDesktopSdk)' == 'true' " Include="WindowsDesktop, Version=$(TargetPlatformVersion)">
13-
<Name>Windows Desktop Extensions for the UWP</Name>
14-
</SDKReference>
15-
<SDKReference Condition="'$(UseWindowsMobileSdk)' == 'true' " Include="WindowsMobile, Version=$(TargetPlatformVersion)">
16-
<Name>Windows Mobile Extensions for the UWP</Name>
17-
</SDKReference>
18-
</ItemGroup>
1916
</When>
2017
</Choose>
2118

19+
<Import Project="$(BuildToolsDirectory)Windows.Toolkit.UWP.Build.targets" Condition="$(UseUWP)" />
20+
21+
<Import Project="$(BuildToolsDirectory)Windows.Toolkit.Workarounds.Xaml.targets" Condition="$(IsCoreProject)" />
22+
2223
<Target Name="AddCommitHashToAssemblyAttributes" BeforeTargets="GetAssemblyAttributes">
2324
<ItemGroup>
24-
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute" Condition=" '$(SourceRevisionId)' != '' ">
25+
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute" Condition="'$(SourceRevisionId)' != ''">
2526
<_Parameter1>CommitHash</_Parameter1>
2627
<_Parameter2>$(SourceRevisionId)</_Parameter2>
2728
</AssemblyAttribute>
2829
</ItemGroup>
2930
</Target>
30-
</Project>
31+
32+
</Project>

SampleTest/SampleTest.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@
160160
</ItemGroup>
161161
<ItemGroup>
162162
<PackageReference Include="Microsoft.Graph">
163-
<Version>4.0.0</Version>
163+
<Version>4.2.0</Version>
164164
</PackageReference>
165165
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
166166
<Version>6.2.12</Version>

UnitTests/UnitTests.UWP/UnitTests.UWP.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@
160160
<Version>5.10.3</Version>
161161
</PackageReference>
162162
<PackageReference Include="Microsoft.Graph">
163-
<Version>4.0.0</Version>
163+
<Version>4.2.0</Version>
164164
</PackageReference>
165165
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
166166
<Version>6.2.12</Version>

Windows-Toolkit-Graph-Controls.sln

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build Config", "Build Confi
2121
settings.xamlstyler = settings.xamlstyler
2222
stylecop.json = stylecop.json
2323
version.json = version.json
24+
build\Windows.Toolkit.Common.props = build\Windows.Toolkit.Common.props
25+
build\Windows.Toolkit.Common.targets = build\Windows.Toolkit.Common.targets
26+
build\Windows.Toolkit.UWP.Build.targets = build\Windows.Toolkit.UWP.Build.targets
27+
build\Windows.Toolkit.Workarounds.Xaml.targets = build\Windows.Toolkit.Workarounds.Xaml.targets
2428
EndProjectSection
2529
EndProject
2630
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleTest", "SampleTest\SampleTest.csproj", "{26F5807A-25B5-4E09-8C72-1749C4C59591}"

0 commit comments

Comments
 (0)