Skip to content

Commit

Permalink
Update nuget icon (#146)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
shweaver-MSFT authored Aug 17, 2021
1 parent ad7efbd commit 2c58710
Show file tree
Hide file tree
Showing 13 changed files with 204 additions and 123 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>

Expand Down
13 changes: 7 additions & 6 deletions CommunityToolkit.Graph.Uwp/CommunityToolkit.Graph.Uwp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@
<PackageTags>UWP Community Toolkit Windows Controls Microsoft Graph Login Person PeoplePicker Presenter</PackageTags>
<LangVersion>9.0</LangVersion>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\CommunityToolkit.Authentication\CommunityToolkit.Authentication.csproj" />
<ProjectReference Include="..\CommunityToolkit.Graph\CommunityToolkit.Graph.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
<PackageReference Include="Microsoft.Graph" Version="4.0.0" />
<PackageReference Include="Microsoft.Graph" Version="4.2.0" />
<PackageReference Include="Microsoft.Toolkit.Uwp.UI.Controls.Input" Version="7.0.2" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\CommunityToolkit.Authentication\CommunityToolkit.Authentication.csproj" />
<ProjectReference Include="..\CommunityToolkit.Graph\CommunityToolkit.Graph.csproj" />
</ItemGroup>

<ItemGroup>
<Content Include="Assets\person.png" />
Expand All @@ -50,4 +50,5 @@
<Message Text="CSFiles: @(GeneratedCSFiles->'&quot;%(Identity)&quot;')" />
<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" />
</Target>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using System.Threading;
using Microsoft.Graph;
using Microsoft.Toolkit.Uwp;
using Newtonsoft.Json.Linq;
using Windows.System;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
Expand All @@ -20,14 +20,6 @@ namespace CommunityToolkit.Graph.Uwp.Controls
/// </summary>
public class GraphPresenter : ContentPresenter
{
/// <summary>
/// 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.
/// </summary>
public IBaseRequestBuilder RequestBuilder
{
get { return (IBaseRequestBuilder)GetValue(RequestBuilderProperty); }
set { SetValue(RequestBuilderProperty, value); }
}

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

/// <summary>
/// Initializes a new instance of the <see cref="GraphPresenter"/> class.
/// </summary>
public GraphPresenter()
{
this.Loaded += this.GraphPresenter_Loaded;
}

/// <summary>
/// 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.
/// </summary>
public IBaseRequestBuilder RequestBuilder
{
get { return (IBaseRequestBuilder)this.GetValue(RequestBuilderProperty); }
set { this.SetValue(RequestBuilderProperty, value); }
}

/// <summary>
/// Gets or sets the <see cref="Type"/> of item returned by the <see cref="RequestBuilder"/>.
/// Set to the base item type and use the <see cref="IsCollection"/> property to indicate if a collection is expected back.
Expand All @@ -59,52 +68,47 @@ public IBaseRequestBuilder RequestBuilder
/// </summary>
public string OrderBy { get; set; }

/// <summary>
/// Initializes a new instance of the <see cref="GraphPresenter"/> class.
/// </summary>
public GraphPresenter()
{
Loaded += GraphPresenter_Loaded;
}

private async void GraphPresenter_Loaded(object sender, RoutedEventArgs e)
{
var dispatcherQueue = DispatcherQueue.GetForCurrentThread();

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

// Handle Special QueryOptions
if (!string.IsNullOrWhiteSpace(OrderBy))
if (!string.IsNullOrWhiteSpace(this.OrderBy))
{
request.QueryOptions.Add(new Microsoft.Graph.QueryOption("$orderby", OrderBy));
request.QueryOptions.Add(new Microsoft.Graph.QueryOption("$orderby", this.OrderBy));
}

try
{
var response = await request.SendAsync<object>(null, CancellationToken.None).ConfigureAwait(false) as JObject;
var responseObj = await request.SendAsync<object>(null, CancellationToken.None).ConfigureAwait(false);

//// TODO: Deal with paging?
if (responseObj is JsonElement responseElement)
{
//// TODO: Deal with paging?

var values = response["value"];
object data = null;
var value = responseElement.GetProperty("value");
object data = null;

if (IsCollection)
{
data = values.ToObject(Array.CreateInstance(ResponseType, 0).GetType());
}
else
{
data = values.ToObject(ResponseType);
}
if (this.IsCollection)
{
data = value.EnumerateArray().ToList().Select(elem => System.Text.Json.JsonSerializer.Deserialize(elem.GetRawText(), this.ResponseType));
}
else
{
data = System.Text.Json.JsonSerializer.Deserialize(value.GetRawText(), this.ResponseType);
}

_ = dispatcherQueue.EnqueueAsync(() => Content = data);
_ = dispatcherQueue.EnqueueAsync(() => this.Content = data);
}
}
catch
{
Expand Down
2 changes: 1 addition & 1 deletion CommunityToolkit.Graph/CommunityToolkit.Graph.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Graph" Version="4.0.0" />
<PackageReference Include="Microsoft.Graph" Version="4.2.0" />
<PackageReference Include="Microsoft.Toolkit" Version="7.1.0-preview1" />
</ItemGroup>

Expand Down
95 changes: 32 additions & 63 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,94 +1,63 @@
<Project>

<PropertyGroup>
<Authors>Microsoft.Toolkit</Authors>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<NoPackageAnalysis>true</NoPackageAnalysis>
<PackageIconUrl>https://raw.githubusercontent.com/CommunityToolkit/CommunityToolkit/master/build/nuget.png</PackageIconUrl>
<PackageProjectUrl>https://github.com/CommunityToolkit/WindowsCommunityToolkit</PackageProjectUrl>
<PackageLicenseUrl>https://github.com/CommunityToolkit/WindowsCommunityToolkit/blob/master/License.md</PackageLicenseUrl>
<PackageReleaseNotes>https://github.com/CommunityToolkit/WindowsCommunityToolkit/releases</PackageReleaseNotes>
<Copyright>(c) .NET Foundation and Contributors. All rights reserved.</Copyright>
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)Toolkit.ruleset</CodeAnalysisRuleSet>
<DefaultLanguage>en-US</DefaultLanguage>
<IsDesignProject>$(MSBuildProjectName.Contains('.Design'))</IsDesignProject>
<IsTestProject>$(MSBuildProjectName.Contains('Test'))</IsTestProject>
<IsUwpProject Condition="'$(IsDesignProject)' != 'true'">$(MSBuildProjectName.Contains('Uwp'))</IsUwpProject>
<IsSampleProject>$(MSBuildProjectName.Contains('Sample'))</IsSampleProject>
<IsWpfProject>$(MSBuildProjectName.Contains('Wpf'))</IsWpfProject>
<DefaultTargetPlatformVersion>19041</DefaultTargetPlatformVersion>
<DefaultTargetPlatformMinVersion>17763</DefaultTargetPlatformMinVersion>
<PackageOutputPath>$(MSBuildThisFileDirectory)bin\nupkg</PackageOutputPath>
<RepositoryDirectory>$(MSBuildThisFileDirectory)</RepositoryDirectory>
<BuildToolsDirectory>$(RepositoryDirectory)build\</BuildToolsDirectory>
</PropertyGroup>

<PropertyGroup>
<SignAssembly Condition="'$(SignAssembly)' == '' and '$(IsUwpProject)' != 'true'" >true</SignAssembly>
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)toolkit.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<Import Project="$(BuildToolsDirectory)Windows.Toolkit.Common.props" />

<Choose>
<When Condition="'$(IsTestProject)' != 'true' and '$(IsSampleProject)' != 'true' and '$(IsDesignProject)' != 'true'">
<When Condition="$(IsCoreProject)">
<PropertyGroup>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageOutputPath>$(RepositoryDirectory)bin\nupkg</PackageOutputPath>
<GenerateLibraryLayout Condition="$(IsUwpProject)">true</GenerateLibraryLayout>
<!--<TreatWarningsAsErrors Condition="'$(Configuration)' == 'Release'">true</TreatWarningsAsErrors>-->
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup>
<IsPackable>false</IsPackable>
<IsPublishable>false</IsPublishable>
<NoWarn>$(NoWarn);CS8002;SA0001</NoWarn>
</PropertyGroup>
</Otherwise>
</Choose>

<Choose>
<When Condition="('$(IsUwpProject)' == 'true') and '$(IsSampleProject)' != 'true' and '$(IsDesignProject)' != 'true'">
<When Condition="$(IsUwpProject)">
<PropertyGroup>
<GenerateLibraryLayout>true</GenerateLibraryLayout>
<!-- 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. -->
<NoWarn>$(NoWarn);CS8002</NoWarn>
<!-- For including default @(Page) and @(Resource) items via 'MSBuild.Sdk.Extras' Sdk package. Also provides up to date check and file nesting -->
<ExtrasEnableDefaultXamlItems>true</ExtrasEnableDefaultXamlItems>
</PropertyGroup>
</When>
</Choose>

<ItemGroup>
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="All" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Nerdbank.GitVersioning" Version="3.3.37" PrivateAssets="All" />
</ItemGroup>

<Choose>
<When Condition="'$(IsTestProject)' != 'true' and '$(SourceLinkEnabled)' != 'false' and '$(IsSampleProject)' != 'true' and '$(IsDesignProject)' != 'true'">
<When Condition="!$(IsSampleProject) and '$(SourceLinkEnabled)' != 'false'">
<PropertyGroup>
<!-- Optional: Declare that the Repository URL can be published to NuSpec -->
<!-- Declare that the Repository URL can be published to NuSpec -->
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<!-- Optional: Embed source files that are not tracked by the source control manager to the PDB -->
<!-- Embed source files that are not tracked by the source control manager to the PDB -->
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<!-- Optional: Include PDB in the built .nupkg -->
<!-- Include PDB in the built .nupkg -->
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.AzureRepos.Git" Version="1.0.0" PrivateAssets="All"/>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All"/>
</ItemGroup>
</When>
</Choose>

<Choose>
<When Condition="'$(IsTestProject)' != 'true' and '$(IsSampleProject)' != 'true' and '$(IsDesignProject)' != 'true' and '$(IsWpfProject)' != 'true'">
<ItemGroup>
<!--<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="15.3.83" PrivateAssets="all" />-->
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" />

<EmbeddedResource Include="**\*.rd.xml" />
<Page Include="**\*.xaml" Exclude="**\bin\**\*.xaml;**\obj\**\*.xaml" SubType="Designer" Generator="MSBuild:Compile" />
<Compile Update="**\*.xaml.cs" DependentUpon="%(Filename)" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
</ItemGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Release' or '$(Configuration)' == 'CI'">
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
</When>
</Choose>

<PropertyGroup Condition="'$(IsUwpProject)' == 'true'">

<!-- 8002 is a strong named -> non-strong-named reference -->
<!-- This is valid for platforms other than .NET Framework (and is needed for the UWP targets -->
<NoWarn>$(NoWarn);8002</NoWarn>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Nerdbank.GitVersioning" Version="3.3.37" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
<AdditionalFiles Include="$(MSBuildThisFileDirectory)stylecop.json">
<Link>stylecop.json</Link>
</AdditionalFiles>
</ItemGroup>
</Project>
34 changes: 18 additions & 16 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
<Project>

<Import Project="$(BuildToolsDirectory)Windows.Toolkit.Common.targets" />

<PropertyGroup>
<UseUWP Condition="($(TargetFramework.StartsWith('uap10.0')) or '$(TargetFramework)' == 'net461')">true</UseUWP>
<UseUWP Condition="'$(UseUWP)' == ''">false</UseUWP>
</PropertyGroup>

<Choose>
<When Condition="'$(TargetFramework)' == 'uap10.0' or '$(TargetFramework)' == 'uap10.0.17763' or '$(TargetFramework)' == 'native' or '$(TargetFramework)' == 'net461'">
<!-- UAP versions for uap10.0 where TPMV isn't implied -->
<When Condition="!($(TargetFramework.StartsWith('uap10.0')) or '$(TargetFramework)' == 'native' or $(IsSampleProject))">
<PropertyGroup>
<TargetPlatformVersion>10.0.$(DefaultTargetPlatformVersion).0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.$(DefaultTargetPlatformMinVersion).0</TargetPlatformMinVersion>
<DebugType>Full</DebugType>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)toolkit.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>

<ItemGroup>
<SDKReference Condition="'$(UseWindowsDesktopSdk)' == 'true' " Include="WindowsDesktop, Version=$(TargetPlatformVersion)">
<Name>Windows Desktop Extensions for the UWP</Name>
</SDKReference>
<SDKReference Condition="'$(UseWindowsMobileSdk)' == 'true' " Include="WindowsMobile, Version=$(TargetPlatformVersion)">
<Name>Windows Mobile Extensions for the UWP</Name>
</SDKReference>
</ItemGroup>
</When>
</Choose>

<Import Project="$(BuildToolsDirectory)Windows.Toolkit.UWP.Build.targets" Condition="$(UseUWP)" />

<Import Project="$(BuildToolsDirectory)Windows.Toolkit.Workarounds.Xaml.targets" Condition="$(IsCoreProject)" />

<Target Name="AddCommitHashToAssemblyAttributes" BeforeTargets="GetAssemblyAttributes">
<ItemGroup>
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute" Condition=" '$(SourceRevisionId)' != '' ">
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute" Condition="'$(SourceRevisionId)' != ''">
<_Parameter1>CommitHash</_Parameter1>
<_Parameter2>$(SourceRevisionId)</_Parameter2>
</AssemblyAttribute>
</ItemGroup>
</Target>
</Project>

</Project>
2 changes: 1 addition & 1 deletion SampleTest/SampleTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Graph">
<Version>4.0.0</Version>
<Version>4.2.0</Version>
</PackageReference>
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
<Version>6.2.12</Version>
Expand Down
2 changes: 1 addition & 1 deletion UnitTests/UnitTests.UWP/UnitTests.UWP.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@
<Version>5.10.3</Version>
</PackageReference>
<PackageReference Include="Microsoft.Graph">
<Version>4.0.0</Version>
<Version>4.2.0</Version>
</PackageReference>
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
<Version>6.2.12</Version>
Expand Down
4 changes: 4 additions & 0 deletions Windows-Toolkit-Graph-Controls.sln
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build Config", "Build Confi
settings.xamlstyler = settings.xamlstyler
stylecop.json = stylecop.json
version.json = version.json
build\Windows.Toolkit.Common.props = build\Windows.Toolkit.Common.props
build\Windows.Toolkit.Common.targets = build\Windows.Toolkit.Common.targets
build\Windows.Toolkit.UWP.Build.targets = build\Windows.Toolkit.UWP.Build.targets
build\Windows.Toolkit.Workarounds.Xaml.targets = build\Windows.Toolkit.Workarounds.Xaml.targets
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleTest", "SampleTest\SampleTest.csproj", "{26F5807A-25B5-4E09-8C72-1749C4C59591}"
Expand Down
Loading

0 comments on commit 2c58710

Please sign in to comment.