Skip to content

Commit

Permalink
Updated code styles
Browse files Browse the repository at this point in the history
  • Loading branch information
anpetroc committed Dec 25, 2023
1 parent 4e4d9a2 commit d8c0cb3
Show file tree
Hide file tree
Showing 103 changed files with 6,357 additions and 6,717 deletions.
9 changes: 6 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ dotnet_sort_system_directives_first = true
dotnet_separate_import_directive_groups = false

file_header_template = Copyright (c) Microsoft Corporation.\nLicensed under the MIT License.

dotnet_diagnostic.IDE0005.severity = error # Remove unnecessary using directives
dotnet_diagnostic.IDE0073.severity = error # Require file header
dotnet_diagnostic.IDE0161.severity = error # Namespace declaration preferences

dotnet_diagnostic.SA0001.severity = none

Expand Down Expand Up @@ -473,10 +476,10 @@ dotnet_style_prefer_auto_properties = true:silent

[*.cs]
csharp_indent_labels = one_less_than_current
csharp_using_directive_placement = outside_namespace:silent
csharp_using_directive_placement = outside_namespace:error
csharp_prefer_simple_using_statement = true:suggestion
csharp_prefer_braces = true:silent
csharp_style_namespace_declarations = block_scoped:silent
csharp_style_namespace_declarations = file_scoped:error
csharp_style_prefer_method_group_conversion = true:silent
csharp_style_prefer_top_level_statements = true:silent
csharp_style_prefer_primary_constructors = true:suggestion
Expand All @@ -487,4 +490,4 @@ csharp_style_expression_bodied_properties = true:silent
csharp_style_expression_bodied_indexers = true:silent
csharp_style_expression_bodied_accessors = true:silent
csharp_style_expression_bodied_lambdas = true:silent
csharp_style_expression_bodied_local_functions = false:silent
csharp_style_expression_bodied_local_functions = false:silent
2 changes: 2 additions & 0 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<CodeAnalysisTreatWarningsAsErrors>true</CodeAnalysisTreatWarningsAsErrors>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<NoWarn>1591</NoWarn>
</PropertyGroup>

<ItemGroup Label="Global usings">
Expand Down
2 changes: 1 addition & 1 deletion src/PAModel/Checksum/ChecksumMaker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ internal static string ChecksumToString(byte[] bytes)
}

/// <summary>
/// Checksum version is of the format: C<int version><hash>. Eg. C6_S88Ujgp7HEnrT7m55yNtgjimcgSoY70Krf8k2HecWYA=
/// Checksum version is of the format: C int version hash. Eg. C6_S88Ujgp7HEnrT7m55yNtgjimcgSoY70Krf8k2HecWYA=
/// This method extracts the int version of the checksum.
/// </summary>
/// <param name="checksum">The checksum.</param>
Expand Down
80 changes: 38 additions & 42 deletions src/PAModel/ControlTemplates/CommonControlProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,61 +2,57 @@
// Licensed under the MIT License.

using Microsoft.AppMagic.Authoring.Persistence;
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Text;
using System.Xml.Linq;

namespace Microsoft.PowerPlatform.Formulas.Tools.ControlTemplates
namespace Microsoft.PowerPlatform.Formulas.Tools.ControlTemplates;

internal class CommonControlProperties
{
internal class CommonControlProperties
{
// Key is property name
private readonly Dictionary<string, ControlProperty> _properties = new Dictionary<string, ControlProperty>();
// Key is property name
private readonly Dictionary<string, ControlProperty> _properties = new Dictionary<string, ControlProperty>();

private static readonly string _fileName = "Microsoft.PowerPlatform.Formulas.Tools.ControlTemplates.commonStyleProperties.xml";
private static CommonControlProperties _instance;
private static readonly string _fileName = "Microsoft.PowerPlatform.Formulas.Tools.ControlTemplates.commonStyleProperties.xml";
private static CommonControlProperties _instance;

public static CommonControlProperties Instance
public static CommonControlProperties Instance
{
get
{
get
{
if (_instance == null)
_instance = new CommonControlProperties();
return _instance;
}
if (_instance == null)
_instance = new CommonControlProperties();
return _instance;
}
}

private CommonControlProperties()
{
Load();
}
private CommonControlProperties()
{
Load();
}

private void Load()
{
var assembly = Assembly.GetExecutingAssembly();
using var stream = assembly.GetManifestResourceStream(_fileName);
var commonProps = XDocument.Load(stream);
if (commonProps == null)
return;

private void Load()
foreach (var property in commonProps.Root.Elements(ControlMetadataXNames.PropertyTag))
{
var assembly = Assembly.GetExecutingAssembly();
using var stream = assembly.GetManifestResourceStream(_fileName);
var commonProps = XDocument.Load(stream);
if (commonProps == null)
return;

foreach (var property in commonProps.Root.Elements(ControlMetadataXNames.PropertyTag))
{
ControlProperty controlProperty = ControlTemplateParser.ParseProperty(property);
if (controlProperty == null)
continue;
_properties.Add(controlProperty.Name, controlProperty);
}
ControlProperty controlProperty = ControlTemplateParser.ParseProperty(property);
if (controlProperty == null)
continue;
_properties.Add(controlProperty.Name, controlProperty);
}
}

// Null if property not found
public string GetDefaultValue(string propertyName, AppType type)
{
if (!_properties.TryGetValue(propertyName, out var controlProperty))
return null;
// Null if property not found
public string GetDefaultValue(string propertyName, AppType type)
{
if (!_properties.TryGetValue(propertyName, out var controlProperty))
return null;

return controlProperty.GetDefaultValue(type);
}
return controlProperty.GetDefaultValue(type);
}
}
Loading

0 comments on commit d8c0cb3

Please sign in to comment.