Skip to content
Merged
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ bld/

# Visual Studio 2017 auto generated files
Generated\ Files/
*.g.cs

# MSTest test Results
[Tt]est[Rr]esult*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Helpers\BackgroundHelper.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Helpers\IconHelper.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Helpers\NavigationViewHelper.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Helpers\PackageProjectUrlAttribute.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Pages\GettingStartedPage.xaml.cs">
<DependentUpon>GettingStartedPage.xaml</DependentUpon>
</Compile>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;

namespace CommunityToolkit.Attributes;

[AttributeUsage(AttributeTargets.Assembly)]
public class PackageProjectUrlAttribute : Attribute
{
public string PackageProjectUrl { get; set; }

public PackageProjectUrlAttribute(string url)
{
PackageProjectUrl = url;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#endif
#endif

#if __WASM__
#if WASM
using Markdig;
using Uno.Foundation.Interop;
using Uno.UI.Runtime.WebAssembly;
Expand All @@ -27,7 +27,7 @@ namespace CommunityToolkit.Labs.Shared.Renderers;
/// <summary>
/// Provide an abstraction around the Toolkit MarkdownTextBlock for both UWP and WinUI 3 in the same namespace (until 8.0) as well as a polyfill for WebAssembly/WASM.
/// </summary>
#if __WASM__
#if WASM
[HtmlElement("div")]
public partial class MarkdownTextBlock : TextBlock
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@

<StackPanel Orientation="Horizontal"
Spacing="8">
<Button Grid.Column="0"
Visibility="{x:Bind renderer:ToolkitDocumentationRenderer.IsIdValid(Metadata.DiscussionId), Mode=OneWay}">
<Button Visibility="{x:Bind renderer:ToolkitDocumentationRenderer.IsIdValid(Metadata.DiscussionId), Mode=OneWay}">
<StackPanel Orientation="Horizontal">
<FontIcon FontSize="14"
Glyph="&#xE8F2;" />
Expand All @@ -125,12 +124,11 @@
</StackPanel>
<interactivity:Interaction.Behaviors>
<interactions:EventTriggerBehavior EventName="Click">
<behaviors:NavigateToUriAction NavigateUri="{x:Bind renderer:ToolkitDocumentationRenderer.ToLabsUri('discussions', Metadata.DiscussionId), Mode=OneWay}" />
<behaviors:NavigateToUriAction NavigateUri="{x:Bind renderer:ToolkitDocumentationRenderer.ToGitHubUri('discussions', Metadata.DiscussionId), Mode=OneWay}" />
</interactions:EventTriggerBehavior>
</interactivity:Interaction.Behaviors>
</Button>
<Button Grid.Column="1"
Visibility="{x:Bind renderer:ToolkitDocumentationRenderer.IsIdValid(Metadata.IssueId), Mode=OneWay}">
<Button Visibility="{x:Bind renderer:ToolkitDocumentationRenderer.IsIdValid(Metadata.IssueId), Mode=OneWay}">
<StackPanel Orientation="Horizontal">
<PathIcon Margin="-3"
VerticalAlignment="Center"
Expand All @@ -147,7 +145,7 @@
</StackPanel>
<interactivity:Interaction.Behaviors>
<interactions:EventTriggerBehavior EventName="Click">
<behaviors:NavigateToUriAction NavigateUri="{x:Bind renderer:ToolkitDocumentationRenderer.ToLabsUri('issues', Metadata.IssueId), Mode=OneWay}" />
<behaviors:NavigateToUriAction NavigateUri="{x:Bind renderer:ToolkitDocumentationRenderer.ToGitHubUri('issues', Metadata.IssueId), Mode=OneWay}" />
</interactions:EventTriggerBehavior>
</interactivity:Interaction.Behaviors>
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,18 @@ public sealed partial class ToolkitDocumentationRenderer : Page
{
private const string MarkdownRegexSampleTagExpression = @"^>\s*\[!SAMPLE\s*(?<sampleid>.*)\s*\]\s*$";
private static readonly Regex MarkdownRegexSampleTag = new Regex(MarkdownRegexSampleTagExpression, RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Multiline);
private static string? ProjectUrl = null;

public ToolkitDocumentationRenderer()
{
// Check and Cache here before we use in XAML.
if (ProjectUrl == null)
{
ProjectUrl = Assembly.GetExecutingAssembly()?.GetCustomAttribute<CommunityToolkit.Attributes.PackageProjectUrlAttribute>()?.PackageProjectUrl;
}

// TODO: If ProjectUrl is null should we log an error?

this.InitializeComponent();
}

Expand Down Expand Up @@ -214,7 +223,7 @@ private async void MarkdownTextBlock_LinkClicked(object sender, LinkClickedEvent
}
#endif

public static Uri ToLabsUri(string path, int id) => new Uri($"https://github.com/CommunityToolkit/Labs-Windows/{path}/{id}");
public static Uri ToGitHubUri(string path, int id) => new Uri($"{ProjectUrl}/{path}/{id}");

public static Visibility IsIdValid(int id) => id switch
{
Expand Down
4 changes: 2 additions & 2 deletions common/Labs.Head.Wasm.props
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
<PackageReference Include="Markdig" Version="0.30.4" />
<PackageReference Include="Microsoft.Windows.Compatibility" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0" />
<PackageReference Include="Uno.Extensions.Logging.WebAssembly.Console" Version="1.0.1" />
<PackageReference Include="Uno.UI.Adapter.Microsoft.Extensions.Logging" Version="4.0.9" />
<PackageReference Include="Uno.Extensions.Logging.WebAssembly.Console" Version="1.4.0" />
<PackageReference Include="Uno.UI.Adapter.Microsoft.Extensions.Logging" Version="4.6.19" />
<PackageReference Include="Uno.Wasm.Bootstrap" Version="3.3.1" />
<PackageReference Include="Uno.Wasm.Bootstrap.DevServer" Version="3.3.1" />
</ItemGroup>
Expand Down
77 changes: 76 additions & 1 deletion common/Labs.Head.props
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<Analyzer Include="$(RepositoryDirectory)common\CommunityToolkit.Labs.Core.SourceGenerators\bin\$(Configuration)\netstandard2.0\CommunityToolkit.Labs.Core.SourceGenerators.dll" />
</ItemGroup>

<ItemGroup>
<ItemGroup>
<Compile Include="$(RepositoryDirectory)common\GlobalUsings_WinUI.cs" />
</ItemGroup>

Expand Down Expand Up @@ -59,5 +59,80 @@

<PropertyGroup>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>

<!-- Turn-off .NET based AssemblyInfo.cs generator, see below -->
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>

<!-- https://stackoverflow.com/questions/10980249/msbuild-task-for-setting-custom-attribute-in-assemblyinfo-cs -->
<!-- https://gist.github.com/KirillOsenkov/f20cb84d37a89b01db63f8aafe03f19b -->
<Target Name="AddAssemblyAttributes" BeforeTargets="BeforeCompile">
<PropertyGroup>
<GeneratedAssemblyInfoPath>$(IntermediateOutputPath)AssemblyInfo.g.cs</GeneratedAssemblyInfoPath>
</PropertyGroup>

<ItemGroup>
<!-- Add our own AssemblyInfo.cs standard attributes -->
<AssemblyAttributes Include="AssemblyTitle">
<_Parameter1>$(Product)</_Parameter1>
</AssemblyAttributes>
<AssemblyAttributes Include="AssemblyDescription">
<_Parameter1>Community Toolkit</_Parameter1>
</AssemblyAttributes>
<AssemblyAttributes Include="AssemblyCompany">
<_Parameter1>$(Company)</_Parameter1>
</AssemblyAttributes>
<AssemblyAttributes Include="AssemblyProduct">
<_Parameter1>$(Product)</_Parameter1>
</AssemblyAttributes>
<AssemblyAttributes Include="AssemblyCopyright">
<_Parameter1>$(Copyright)</_Parameter1>
</AssemblyAttributes>
<AssemblyAttributes Include="AssemblyTrademark">
<_Parameter1></_Parameter1>
</AssemblyAttributes>
<AssemblyAttributes Include="AssemblyCulture">
<_Parameter1></_Parameter1>
</AssemblyAttributes>
<AssemblyAttributes Include="AssemblyConfiguration">
<_Parameter1>$(Configuration)</_Parameter1>
</AssemblyAttributes>
<AssemblyAttributes Include="AssemblyVersion">
<_Parameter1>1.0.0.0</_Parameter1>
</AssemblyAttributes>
<AssemblyAttributes Include="AssemblyFileVersion">
<_Parameter1>1.0.0.0</_Parameter1>
</AssemblyAttributes>
<AssemblyAttributes Include="System.Runtime.InteropServices.ComVisible">
<_Parameter1>false</_Parameter1>
<_Parameter1_TypeName>System.Boolean</_Parameter1_TypeName>
</AssemblyAttributes>

<!-- Add custom attributes, also see https://stackoverflow.com/questions/56835671/how-to-read-a-msbuild-property-in-a-given-project-in-runtime -->
<AssemblyAttributes Include="System.Reflection.AssemblyMetadataAttribute" Condition="'$(SourceRevisionId)' != ''">
<_Parameter1>CommitHash</_Parameter1>
<_Parameter2>$(SourceRevisionId)</_Parameter2>
</AssemblyAttributes>
<AssemblyAttributes Include="CommunityToolkit.Attributes.PackageProjectUrlAttribute">
<_Parameter1>$(PackageProjectUrl)</_Parameter1>
</AssemblyAttributes>
</ItemGroup>

<!-- Extra attributes specific to platforms -->
<ItemGroup Condition="'$(IsWinAppSdk)' == 'true'">
<AssemblyAttributes Include="System.Runtime.Versioning.TargetPlatformAttribute">
<_Parameter1>Windows10.0.19041.0</_Parameter1><!-- TODO: Grab from variable -->
</AssemblyAttributes>
<AssemblyAttributes Include="System.Runtime.Versioning.SupportedOSPlatformAttribute">
<_Parameter1>Windows10.0.17763.0</_Parameter1><!-- TODO: Grab from variable -->
</AssemblyAttributes>
</ItemGroup>

<ItemGroup>
<Compile Include="$(GeneratedAssemblyInfoPath)" />
</ItemGroup>

<!-- Write out new auto-generated AssemblyInfo.g.cs file -->
<WriteCodeFragment Language="C#" OutputFile="$(GeneratedAssemblyInfoPath)" AssemblyAttributes="@(AssemblyAttributes)" />
</Target>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@
<AssemblyName>CanvasLayoutExperiment.Samples.Uwp</AssemblyName>
<ProjectGuid>{C3F460EC-A0A6-4B22-A91A-6CF98B30FD8A}</ProjectGuid>
</PropertyGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="Properties\Default.rd.xml" />
</ItemGroup>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
</PropertyGroup>

<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Content Include="Properties\Default.rd.xml" />
<AppxManifest Include="Package.appxmanifest">
<SubType>Designer</SubType>
Expand Down

This file was deleted.

3 changes: 0 additions & 3 deletions labs/CanvasView/samples/CanvasView.Uwp/CanvasView.Uwp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@
<AssemblyName>CanvasViewExperiment.Samples.Uwp</AssemblyName>
<ProjectGuid>{11B0021A-DEC6-4942-B478-4367079357E4}</ProjectGuid>
</PropertyGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="Properties\Default.rd.xml" />
</ItemGroup>
Expand Down
33 changes: 0 additions & 33 deletions labs/CanvasView/samples/CanvasView.Uwp/Properties/AssemblyInfo.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
</PropertyGroup>

<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Content Include="Properties\Default.rd.xml" />
<AppxManifest Include="Package.appxmanifest">
<SubType>Designer</SubType>
Expand Down

This file was deleted.

Loading