Commit 609e910b authored by Mikael Lindemann's avatar Mikael Lindemann
Browse files

Include documentation in nuget package.

parent e7bae075
[*.cs]
# CA1031: Do not catch general exception types
dotnet_diagnostic.CA1031.severity = silent
......@@ -3,7 +3,13 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29806.167
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Appstract.UmbracoContactNumber", "Appstract.UmbracoContactNumber\Appstract.UmbracoContactNumber.csproj", "{13039FC7-1946-45AB-9C10-25662BFB7C70}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Appstract.UmbracoContactNumber", "Appstract.UmbracoContactNumber\Appstract.UmbracoContactNumber.csproj", "{13039FC7-1946-45AB-9C10-25662BFB7C70}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{EEFA0116-3375-4A6C-8964-148AD3A53B65}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
UmbracoPackage.targets = UmbracoPackage.targets
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
......
......@@ -15,6 +15,7 @@
<ContentTargetFolders>content</ContentTargetFolders>
<IncludeSymbols>true</IncludeSymbols>
<DocumentationFile>$(BaseOutputPath)\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
<RootNamespace>Appstract.UmbracoContactNumber</RootNamespace>
<AssemblyName>Appstract.UmbracoContactNumber</AssemblyName>
<TargetFramework>net472</TargetFramework>
......@@ -23,32 +24,18 @@
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
<!-- According to Umbraco Packaging guidelines, there should not be a NuGet package dependency to the core Umbraco libraries. -->
<PackageReference Include="UmbracoCms.Core" Version="8.1.0" PrivateAssets="all" />
</ItemGroup>
<ItemGroup>
<Content Include="App_Plugins\Appstract.UmbracoContactNumber\**\*.*" Pack="true" />
<None Include="..\.editorconfig" Link=".editorconfig" />
<None Include="Appstract-a Logo.png" Pack="true" PackagePath="images\icon.png" />
<PackageSourceFiles Include="App_Plugins\Appstract.UmbracoContactNumber\**\*.*" />
<PackageSourceFiles Include="bin\Release\net472\Appstract.UmbracoContactNumber.dll" />
<PackageSourceFiles Include="package.xml" />
<UmbracoPackageContent Include="App_Plugins\Appstract.UmbracoContactNumber\**\*.*" />
<UmbracoPackageContent Include="$(OutputPath)\$(AssemblyName).dll" />
<UmbracoPackageContent Include="package.xml" />
</ItemGroup>
<PropertyGroup>
<PackageIntermediateOutputPath>$(BaseIntermediateOutputPath)\package_output\</PackageIntermediateOutputPath>
</PropertyGroup>
<Target Name="UmbracoPackage" AfterTargets="AfterBuild" Condition=" '$(Configuration)' == 'Release' ">
<MakeDir Directories="$(PackageIntermediateOutputPath)" />
<Delete Files="$(PackageIntermediateOutputPath)\*" />
<Copy SourceFiles="@(PackageSourceFiles)" DestinationFolder="$(PackageIntermediateOutputPath)" />
<XmlPoke XmlInputPath="$(PackageIntermediateOutputPath)\package.xml" Value="$(Version)" Query="/umbPackage/info/package/version" />
<ZipDirectory SourceDirectory="$(PackageIntermediateOutputPath)" DestinationFile="$(BaseOutputPath)$(Configuration)\$(AssemblyName).$(Version).zip" Overwrite="true" />
</Target>
<Target Name="UmbracoPackageClean" AfterTargets="Clean">
<Delete Files="$(PackageIntermediateOutputPath)\*" />
<RemoveDir Directories="$(PackageIntermediateOutputPath)" />
</Target>
<Import Project="../UmbracoPackage.targets" />
</Project>
\ No newline at end of file
......@@ -4,15 +4,39 @@ using System.Linq;
namespace Appstract.UmbracoContactNumber
{
/// <summary>
/// ContactNumber contains the country code and local number of a phone number.
/// </summary>
public class ContactNumber
{
/// <summary>
/// CountryCodeAndPhoneCode gets or sets the two-letter country code as well as the phone code in the format "dk#45"
/// </summary>
[JsonProperty("CountryCodeAndPhoneCode")]
public string CountryCodeAndPhoneCode { get; set; }
/// <summary>
/// Number gets or sets the phone number.
/// </summary>
[JsonProperty("ContactNumber")]
public string Number { get; set; }
/// <summary>
/// FormattedContactNumber gets the formatted <see cref="PhoneCode"/> and <see cref="Number"/> in the format "+45 12345678".
/// If no <see cref="PhoneCode"/> is present, the phone number will be returned.
/// </summary>
public string FormattedContactNumber => string.IsNullOrWhiteSpace(PhoneCode) ? $"{Number}" : $"+{PhoneCode} {Number}";
/// <summary>
/// PhoneCode gets the phone code for the chosen country code.
/// </summary>
public string PhoneCode => CountryCodeAndPhoneCode?.Split('#')?.LastOrDefault();
/// <summary>
/// GetFormattedPhoneFromJson deserializes the input JSON into the ContactNumber class and returns the value of <see cref="FormattedContactNumber"/>.
/// </summary>
/// <param name="jsonPhone">The JSON serialized <see cref="ContactNumber"/>.</param>
/// <returns>The formatted contact number if successful. The input JSON otherwise.</returns>
public static string GetFormattedPhoneFromJson(string jsonPhone)
{
if (string.IsNullOrEmpty(jsonPhone)) { return null; }
......
......@@ -5,18 +5,12 @@ using Umbraco.Core.PropertyEditors;
namespace Appstract.UmbracoContactNumber
{
/// <summary>
/// ContactNumberValueConverter converts JSON into instances of the <see cref="ContactNumber"/> class.
/// </summary>
public class ContactNumberValueConverter : PropertyValueConverterBase
{
public override object ConvertIntermediateToObject(IPublishedElement owner, IPublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview)
{
return inter;
}
public override object ConvertIntermediateToXPath(IPublishedElement owner, IPublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview)
{
return null;
}
/// <inheritdoc/>
public override object ConvertSourceToIntermediate(IPublishedElement owner, IPublishedPropertyType propertyType, object source, bool preview)
{
if (!(source is string s))
......@@ -27,16 +21,19 @@ namespace Appstract.UmbracoContactNumber
return JsonConvert.DeserializeObject<ContactNumber>(s);
}
/// <inheritdoc/>
public override PropertyCacheLevel GetPropertyCacheLevel(IPublishedPropertyType propertyType)
{
return PropertyCacheLevel.Element;
}
/// <inheritdoc/>
public override Type GetPropertyValueType(IPublishedPropertyType propertyType)
{
return typeof(ContactNumber);
}
/// <inheritdoc/>
public override bool IsConverter(IPublishedPropertyType propertyType)
{
return propertyType.EditorAlias.Equals("AppstractUmbracoContactNumber");
......
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<UmbracoPackageIntermediateOutputPath>$(BaseIntermediateOutputPath)\umbracopackage_staging\</UmbracoPackageIntermediateOutputPath>
</PropertyGroup>
<!-- Copies the file from UmbracoPackageContent into an intermediate output path ignoring the structure of the source. -->
<!-- Then updates the version of the package.xml file to be the same as the MSBuild Version property. -->
<!-- Then zips the intermediate output path, and puts the result in the same location as the .nupkg files. -->
<Target Name="UmbracoPackage" AfterTargets="AfterBuild" Inputs="@(UmbracoPackageContent)" Outputs="$(BaseOutputPath)$(Configuration)\$(AssemblyName).$(Version).zip">
<MakeDir Directories="$(UmbracoPackageIntermediateOutputPath)" />
<Delete Files="$(UmbracoPackageIntermediateOutputPath)\*" />
<Copy SourceFiles="@(UmbracoPackageContent)" DestinationFolder="$(UmbracoPackageIntermediateOutputPath)" />
<XmlPoke XmlInputPath="$(UmbracoPackageIntermediateOutputPath)\package.xml" Value="$(Version)" Query="/umbPackage/info/package/version" />
<ZipDirectory SourceDirectory="$(UmbracoPackageIntermediateOutputPath)" DestinationFile="$(BaseOutputPath)\$(Configuration)\$(AssemblyName).$(Version).zip" Overwrite="true" />
</Target>
<Target Name="UmbracoPackageClean" AfterTargets="Clean">
<Delete Files="$(UmbracoPackageIntermediateOutputPath)\*" />
<RemoveDir Directories="$(UmbracoPackageIntermediateOutputPath)" />
</Target>
</Project>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment