Skip to content

Commit

Permalink
Refactor Project and Build related files
Browse files Browse the repository at this point in the history
- Refactor Project files
- Refactor Markdown files
- Remove unnecessary files
- Use latest NuGet and config
- Update 'Monaco.Editor' package
- Update test package references
  • Loading branch information
Nirmal4G committed Sep 10, 2021
1 parent 5dfc575 commit e3ae65e
Show file tree
Hide file tree
Showing 28 changed files with 105 additions and 119 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
[Rr]eleases/
x64/
x86/
build/
bld/
[Bb]in/
[Oo]bj/
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
<Import Project="$(BuildToolsDirectory)Windows.Toolkit.VisualStudio.Design.props" Condition="$(IsDesignProject)" />

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

<Choose>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
</When>

<When Condition="'$(TargetFramework)' == 'net5.0'">
<!-- .NET 5 SDK doesn't define "NETSTANDARD2_1_OR_GREATER" until a later revision -->
<PropertyGroup>
<DefineConstants>NETSTANDARD2_1_OR_GREATER</DefineConstants>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
- Box&lt;T&gt;: a type mapping boxed value types and exposing some utility and high performance methods.
- Ref&lt;T&gt;: a stack-only struct that can store a reference to a value of a specified type.
- NullableRef&lt;T&gt;: a stack-only struct similar to Ref&lt;T&gt;, which also supports nullable references.
</Description>
</Description>
<PackageTags>Parallel;Performance;Unsafe;Span;Memory;String;StringPool;Array;Stream;Buffer;Extensions;Helpers</PackageTags>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>9.0</LangVersion>
<Nullable>enable</Nullable>
<Nullable>Enable</Nullable>
<IsPackable>false</IsPackable>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<Compile Remove="EmbeddedResources\INotifyPropertyChanged.cs" />
<Compile Remove="EmbeddedResources\NotNullAttribute.cs" />
<Compile Remove="EmbeddedResources\NotNullIfNotNullAttribute.cs" />
<Compile Remove="EmbeddedResources\ObservableObject.cs" />
<Compile Remove="EmbeddedResources\ObservableRecipient.cs" />
<Compile Remove="EmbeddedResources\*.cs" />
</ItemGroup>

<ItemGroup>
Expand All @@ -34,12 +29,12 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.9.0" PrivateAssets="all" Pack="false" />
<AdditionalFiles Include="AnalyzerReleases.Shipped.md" />
<AdditionalFiles Include="AnalyzerReleases.Unshipped.md" />
</ItemGroup>

<ItemGroup>
<AdditionalFiles Include="AnalyzerReleases.Shipped.md" />
<AdditionalFiles Include="AnalyzerReleases.Unshipped.md" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.9.0" PrivateAssets="All" Pack="false" />
</ItemGroup>

</Project>
12 changes: 7 additions & 5 deletions Microsoft.Toolkit.Mvvm/Microsoft.Toolkit.Mvvm.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,18 @@
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="5.0.0" />
</ItemGroup>

<!-- Source generator project reference for packing -->
<ItemGroup>
<ProjectReference Include="..\Microsoft.Toolkit.Mvvm.SourceGenerators\Microsoft.Toolkit.Mvvm.SourceGenerators.csproj" PrivateAssets="all" />
</ItemGroup>

<!-- Target to pack the source generator into the "analyzers\dotnet\cs" package folder.
The condition is set to .NET Standard 2.0 so that the analyzer is only added to the package
when that target is being built, instead of once for all three targets, which would fail.
It will still be available for all targets anyway though, as analyzers don't have a target. -->
<!--
Target to pack the source generator into the "analyzers\dotnet\cs" package folder.
The condition is set to .NET Standard 2.0 so that the analyzer is only added to the package
when that target is being built, instead of once for all three targets, which would fail.
It will still be available for all targets anyway though, as analyzers don't have a target.
-->
<Target Name="CopyAnalyzerProjectReferencesToPackage" DependsOnTargets="BuildOnlySettings;ResolveReferences" Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<ItemGroup>
<TfmSpecificPackageFile Include="@(ReferenceCopyLocalPaths->WithMetadataValue('ReferenceSourceTarget', 'ProjectReference')->WithMetadataValue('PrivateAssets', 'All'))">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,60 +1,58 @@
<Project Sdk="MSBuild.Sdk.Extras">

<PropertyGroup>
<TargetFrameworks>netstandard1.4;uap10.0.19041;net461;netcoreapp3.1;net5.0;net5.0-windows10.0.17763.0;native</TargetFrameworks>
<DefineConstants>$(DefineConstants);NETFX_CORE</DefineConstants>
<TargetFrameworks>netstandard1.4;uap10.0.16299;net461;netcoreapp3.1;net5.0;net5.0-windows10.0.17763;native</TargetFrameworks>
<NuspecFile>Microsoft.Toolkit.Uwp.Notifications.nuspec</NuspecFile>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'uap10.0.19041'">
<TargetPlatformVersion>10.0.19041.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.16299.0</TargetPlatformMinVersion>
<PropertyGroup Condition="'$(TargetFramework)' == 'uap10.0.16299' or '$(TargetFramework)' == 'native'">
<TargetPlatformVersion>10.0.$(TargetPlatformRevision).0</TargetPlatformVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)' != 'uap10.0.16299'">
<DefineConstants>$(DefineConstants);NETFX_CORE</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'net461' or '$(TargetFramework)' == 'netcoreapp3.1' or '$(TargetFramework)' == 'net5.0-windows10.0.17763.0'">
<!-- Define the WINDOWS_UWP conditional symbol, since the Windows.Data.Xml and the Windows.UI.Notification namespaces are available -->
<PropertyGroup Condition="'$(TargetFramework)' == 'net461' or '$(TargetFramework)' == 'netcoreapp3.1' or '$(TargetFramework)' == 'net5.0-windows10.0.17763'">
<!-- Define the WINDOWS_UWP conditional symbol, since the 'Windows.Data.Xml' and the 'Windows.UI.Notification' namespaces are available -->
<DefineConstants>$(DefineConstants);WINDOWS_UWP;WIN32</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'native'">
<OutputType>winmdobj</OutputType>
<!-- Build -->
<DebugType>Full</DebugType>
<OutputType>WinMDObj</OutputType>
<AssetTargetFallback>uap10.0</AssetTargetFallback>
<!-- Targets -->
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
<!-- Workaround for issue NuGet/Home#8388; change behavior during NuGet restore time vs. final build to avoid NuGet conflict in VS 2019 -->
<NuGetTargetMoniker Condition="'$(DesignTimeBuild)' == 'true'">native</NuGetTargetMoniker>
<NuGetTargetMoniker Condition="'$(DesignTimeBuild)' != 'true'">UAP,Version=v10.0</NuGetTargetMoniker>
<PackageTargetFallback>uap10.0</PackageTargetFallback>
<TargetPlatformVersion>10.0.19041.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.10240.0</TargetPlatformMinVersion>
<DefineConstants Condition="'$(DisableImplicitFrameworkDefines)' != 'true'">$(DefineConstants);WINDOWS_UWP;WINRT</DefineConstants>
<CopyLocalLockFileAssemblies Condition="'$(CopyLocalLockFileAssemblies)' == ''">false</CopyLocalLockFileAssemblies>
<TargetFrameworkIdentifier>.NETCore</TargetFrameworkIdentifier>
<TargetFrameworkVersion>v5.0</TargetFrameworkVersion>
<!-- Misc -->
<CopyLocalLockFileAssemblies>false</CopyLocalLockFileAssemblies>
<DefineConstants>$(DefineConstants);WINDOWS_UWP;WINRT</DefineConstants>
<LanguageTargets>$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets</LanguageTargets>
<ExtrasImplicitPlatformPackageIsPrivate>true</ExtrasImplicitPlatformPackageIsPrivate>

<!-- Need to override the built-in implicit defines for UAP or it'll be NETCORE5_0. This makes it UAP10_0_10240_0 to match the rest -->
<ImplicitFrameworkDefine Condition="'$(DisableImplicitFrameworkDefines)' != 'true'">UAP$(TargetPlatformMinVersion.Replace('.', '_'))</ImplicitFrameworkDefine>
<DisableImplicitFrameworkDefines Condition="'$(DisableImplicitFrameworkDefines)' != 'true'">true</DisableImplicitFrameworkDefines>
<!-- Workaround for issue NuGet/Home#8388; Restore conflict in VS IDE 2019 during DesignTime vs BuildTime. -->
<NuGetTargetMoniker Condition="'$(DesignTimeBuild)' != 'true'">UAP,Version=v10.0</NuGetTargetMoniker>
<NuGetTargetMoniker Condition="'$(DesignTimeBuild)' == 'true'">Native,Version=v0.0</NuGetTargetMoniker>
</PropertyGroup>

<ItemGroup>
<None Include="Microsoft.Toolkit.Uwp.Notifications.targets" Pack="true" PackagePath="build\native" />
</ItemGroup>

<!-- In order to support .NET Native, we need to include an appropriate .rd.xml for UWP (remove from everything else) -->
<ItemGroup Condition="'$(TargetFramework)' != 'uap10.0.19041' and '$(TargetFramework)' != 'native'">
<!-- In order to support .NET Native, we need to include an appropriate '.rd.xml' for UWP (remove from everything else) -->
<ItemGroup Condition="'$(TargetFramework)' != 'uap10.0.16299' and '$(TargetFramework)' != 'native'">
<EmbeddedResource Remove="Properties\Microsoft.Toolkit.Uwp.Notifications.rd.xml" />
</ItemGroup>

<!-- Desktop Win32 apps -->
<!-- For Desktop Win32 apps' WinRT APIs support -->
<ItemGroup Condition="'$(TargetFramework)' == 'net461' or '$(TargetFramework)' == 'netcoreapp3.1'">
<!-- Reference Windows SDK NuGet of correct target platform version -->
<PackageReference Include="Microsoft.Windows.SDK.Contracts" Version="10.0.19041.1" />
</ItemGroup>

<!-- The .NET Core desktop apps also need the Registry NuGet package and System.Reflection.Emit for generating COM class dynamically -->
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1' or '$(TargetFramework)' == 'net5.0-windows10.0.17763.0'">
<!-- The .NET Core desktop apps also need the Registry NuGet package and 'System.Reflection.Emit' for generating COM class dynamically -->
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1' or '$(TargetFramework)' == 'net5.0-windows10.0.17763'">
<PackageReference Include="Microsoft.Win32.Registry" Version="4.7.0" />
<PackageReference Include="System.Reflection.Emit" Version="4.7.0" />
<PackageReference Include="System.Drawing.Common" Version="4.7.0" />
Expand All @@ -64,12 +62,15 @@
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform" Version="$(ExtrasUwpMetaPackageVersion)" PrivateAssets="All" IsImplicitlyDefined="true" />
</ItemGroup>

<!-- Native (C++) doesn't need 'System.ValueTuple' (plus it's incompatible with this package) -->
<!-- Native (C++) does not need 'System.ValueTuple' (plus it is incompatible with this package) -->
<ItemGroup Condition="'$(TargetFramework)' != 'native'">
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
</ItemGroup>

<!-- Set the nuspec properties. Dependent on version which isn't updated till after 'GetBuildVersion'. Condition ensures we only set once since this runs multiple times for each target. -->
<!--
Set the nuspec properties. Dependent on version which is not updated till after 'GetBuildVersion'.
Condition ensures we only set once since this runs multiple times for each target.
-->
<Target Name="SetNuspecProperties" AfterTargets="GetBuildVersion">
<PropertyGroup Condition="'$(NuspecProperties)' == ''">
<NuspecProperties>buildOutput=bin\$(Configuration);version=$(Version)</NuspecProperties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,19 @@
<file src="$buildOutput$\net5.0\Microsoft.Toolkit.Uwp.Notifications.dll" target="lib\net5.0\Microsoft.Toolkit.Uwp.Notifications.dll" />
<file src="$buildOutput$\net5.0\Microsoft.Toolkit.Uwp.Notifications.pdb" target="lib\net5.0\Microsoft.Toolkit.Uwp.Notifications.pdb" />
<file src="$buildOutput$\net5.0\Microsoft.Toolkit.Uwp.Notifications.xml" target="lib\net5.0\Microsoft.Toolkit.Uwp.Notifications.xml" />
<file src="$buildOutput$\net5.0-windows10.0.17763.0\Microsoft.Toolkit.Uwp.Notifications.dll" target="lib\net5.0-windows10.0.17763\Microsoft.Toolkit.Uwp.Notifications.dll" />
<file src="$buildOutput$\net5.0-windows10.0.17763.0\Microsoft.Toolkit.Uwp.Notifications.pdb" target="lib\net5.0-windows10.0.17763\Microsoft.Toolkit.Uwp.Notifications.pdb" />
<file src="$buildOutput$\net5.0-windows10.0.17763.0\Microsoft.Toolkit.Uwp.Notifications.xml" target="lib\net5.0-windows10.0.17763\Microsoft.Toolkit.Uwp.Notifications.xml" />
<file src="$buildOutput$\net5.0-windows10.0.17763\Microsoft.Toolkit.Uwp.Notifications.dll" target="lib\net5.0-windows10.0.17763\Microsoft.Toolkit.Uwp.Notifications.dll" />
<file src="$buildOutput$\net5.0-windows10.0.17763\Microsoft.Toolkit.Uwp.Notifications.pdb" target="lib\net5.0-windows10.0.17763\Microsoft.Toolkit.Uwp.Notifications.pdb" />
<file src="$buildOutput$\net5.0-windows10.0.17763\Microsoft.Toolkit.Uwp.Notifications.xml" target="lib\net5.0-windows10.0.17763\Microsoft.Toolkit.Uwp.Notifications.xml" />
<file src="$buildOutput$\netcoreapp3.1\Microsoft.Toolkit.Uwp.Notifications.dll" target="lib\netcoreapp3.1\Microsoft.Toolkit.Uwp.Notifications.dll" />
<file src="$buildOutput$\netcoreapp3.1\Microsoft.Toolkit.Uwp.Notifications.pdb" target="lib\netcoreapp3.1\Microsoft.Toolkit.Uwp.Notifications.pdb" />
<file src="$buildOutput$\netcoreapp3.1\Microsoft.Toolkit.Uwp.Notifications.xml" target="lib\netcoreapp3.1\Microsoft.Toolkit.Uwp.Notifications.xml" />
<file src="$buildOutput$\netstandard1.4\Microsoft.Toolkit.Uwp.Notifications.dll" target="lib\netstandard1.4\Microsoft.Toolkit.Uwp.Notifications.dll" />
<file src="$buildOutput$\netstandard1.4\Microsoft.Toolkit.Uwp.Notifications.pdb" target="lib\netstandard1.4\Microsoft.Toolkit.Uwp.Notifications.pdb" />
<file src="$buildOutput$\netstandard1.4\Microsoft.Toolkit.Uwp.Notifications.xml" target="lib\netstandard1.4\Microsoft.Toolkit.Uwp.Notifications.xml" />
<file src="$buildOutput$\uap10.0.19041\Microsoft.Toolkit.Uwp.Notifications.dll" target="lib\uap10.0.16299\Microsoft.Toolkit.Uwp.Notifications.dll" />
<file src="$buildOutput$\uap10.0.19041\Microsoft.Toolkit.Uwp.Notifications.pdb" target="lib\uap10.0.16299\Microsoft.Toolkit.Uwp.Notifications.pdb" />
<file src="$buildOutput$\uap10.0.19041\Microsoft.Toolkit.Uwp.Notifications.pri" target="lib\uap10.0.16299\Microsoft.Toolkit.Uwp.Notifications.pri" />
<file src="$buildOutput$\uap10.0.19041\Microsoft.Toolkit.Uwp.Notifications.xml" target="lib\uap10.0.16299\Microsoft.Toolkit.Uwp.Notifications.xml" />
<file src="$buildOutput$\uap10.0.16299\Microsoft.Toolkit.Uwp.Notifications.dll" target="lib\uap10.0.16299\Microsoft.Toolkit.Uwp.Notifications.dll" />
<file src="$buildOutput$\uap10.0.16299\Microsoft.Toolkit.Uwp.Notifications.pdb" target="lib\uap10.0.16299\Microsoft.Toolkit.Uwp.Notifications.pdb" />
<file src="$buildOutput$\uap10.0.16299\Microsoft.Toolkit.Uwp.Notifications.pri" target="lib\uap10.0.16299\Microsoft.Toolkit.Uwp.Notifications.pri" />
<file src="$buildOutput$\uap10.0.16299\Microsoft.Toolkit.Uwp.Notifications.xml" target="lib\uap10.0.16299\Microsoft.Toolkit.Uwp.Notifications.xml" />
<file src="$buildOutput$\native\Microsoft.Toolkit.Uwp.Notifications.pdb" target="lib\native\Microsoft.Toolkit.Uwp.Notifications.pdb" />
<file src="$buildOutput$\native\Microsoft.Toolkit.Uwp.Notifications.pri" target="lib\native\Microsoft.Toolkit.Uwp.Notifications.pri" />
<file src="$buildOutput$\native\Microsoft.Toolkit.Uwp.Notifications.winmd" target="lib\native\Microsoft.Toolkit.Uwp.Notifications.winmd" />
Expand Down
40 changes: 21 additions & 19 deletions Microsoft.Toolkit.Uwp.Notifications/ReadMe.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,38 @@
Welcome to the Notifications section of the toolkit! This contains the Notifications library, including the object model for tile, toast, and badge XML (previously called NotificationsExtensions).
# UWP Notifications

Welcome to the Notifications section of the toolkit! This contains the Notifications library, including the object model for tile, toast, and badge XML (previously called `NotificationsExtensions`).

## Where should I add new code?
Any code for generating notifications should be written in the Microsoft.Toolkit.Uwp.Notifications project.

Any code for generating notifications should be written in the `Microsoft.Toolkit.Uwp.Notifications` project.

If there's UWP-specific code, use the appropriate `#ifdef`, `WINDOWS_UWP` or `WINRT`.

## What are all the projects for?
All the code is contained on the Microsoft.Toolkit.Uwp.Notifications project.

It outputs `netstandard1.4`, `uap10.0`, `native` for WinRT, and netcoreapp for .Net Core projects. The UWP library is only for C#, while the WinRT library is a Windows Runtime Component for C++.

All the code is contained on the `Microsoft.Toolkit.Uwp.Notifications` project.

| C# | C++ |
| ---------------- | ------------------- |
| NET Standard 1.4 | UWP WinRT Component |
| UWP C# DLL | |
| .Net Core DLL | |

It outputs `netstandard1.4`, `uap10.0`, `native` for WinRT, and `netcoreapp3.1` for .NET Core projects. The UWP library is only for C#, while the WinRT library is a Windows Runtime Component for C++.

| C# | C++ |
| --------------------- | ------------------- |
| .NET Standard Library | UWP WinRT Component |
| .NET Core Library | |
| UWP C# Library | |

## Scenarios we want to support

Imagine you add this library to a .NET Standard class library, and you also add it to your UWP app. In this case, your .NET Standard class library will receive the NETStandard dll. Your UWP project will receive the UWP dll.
Imagine you add this library to a .NET Standard class library, and you also add it to your UWP app. In this case, your .NET Standard class library will receive the .NET Standard DLL. Your UWP project will receive the UWP DLL.

## How are the test projects organized?

If you look in the UnitTests folder of the repo, you'll notice that there's three projects...
- UnitTests.Notifications.Shared
- UnitTests.Notifications.NetCore
- UnitTests.Notifications.UWP
- UnitTests.Notifications.WinRT
If you look in the `UnitTests` folder of the repo, you'll notice that there are three projects...

- `UnitTests.Notifications.Shared`
- `UnitTests.Notifications.NetCore`
- `UnitTests.Notifications.UWP`
- `UnitTests.Notifications.WinRT`

That's because in our source code, we have some #IF defs for switching between the different types of reflection that C# uses, since it's different between a .NET Standard and WinRT code.
That's because in our source code, we have some `#ifdef` for switching between the different types of reflection that C# uses, since it's different between a .NET Standard and WinRT code.

Therefore, there are two different code paths, one path for NETFX_CORE, and another for when that isn't present. The two test projects exercise both code paths.
Therefore, there are two different code paths, one path for `NETFX_CORE`, and another for when that isn't present. The two test projects exercise both code paths.
Loading

0 comments on commit e3ae65e

Please sign in to comment.