Skip to content

Commit

Permalink
Use collection expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
volkanceylan committed Nov 25, 2024
1 parent b344152 commit fd21bb5
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions common-features/build/shared/Conditionals.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ namespace Build;

public static partial class Shared
{
public static readonly (string prefix, string suffix, string eelse, string ending)[] ConditionalPatterns = new[]
{
public static readonly (string prefix, string suffix, string eelse, string ending)[] ConditionalPatterns =
[
("//<if:", "//>", "//<else>", "//</if:{0}>"),
("//#if(", ")", "//#else", "//#endif"),
("//#if (", ")", "//#else", "//#endif"),
Expand All @@ -18,7 +18,7 @@ public static readonly (string prefix, string suffix, string eelse, string endin
("<!--<if:", ">-->", "<!--<else>-->", "<!--<endif:{0}>-->"),
("<!--#if(", ")-->", "<!--#else-->", "<!--#endif-->"),
("<!--#if (", ")-->", "<!--#else-->", "<!--#endif-->")
};
];

public static bool HasConditionals(string content)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,8 @@ public static void EnsureDatabase(string databaseKey, string contentRoot, ISqlCo
using var fbConnection = sqlConnections.New(cb.ConnectionString,
cs.ProviderName, cs.Dialect);
((WrappedConnection)fbConnection).ActualConnection.GetType()
.GetMethod("CreateDatabase", new Type[] { typeof(string), typeof(bool) })
.Invoke(null, new object[] { fbConnection.ConnectionString, false });
.GetMethod("CreateDatabase", [typeof(string), typeof(bool)])
.Invoke(null, [fbConnection.ConnectionString, false]);

return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ static string effective(string key)
if (key.StartsWith("Navigation.", StringComparison.Ordinal))
{
key = key["Navigation.".Length..];
return key.Split(new char[] { '/' }).Last();
return key.Split(['/']).Last();
}
else if (key.StartsWith("Forms.", StringComparison.Ordinal) &&
key.Contains(".Categories.", StringComparison.Ordinal))
{
return key.Split(new char[] { '.' }).Last().TrimToNull();
return key.Split(['.']).Last().TrimToNull();
}

return key;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public override Task<ProviderCultureResult> DetermineProviderCultureResult(HttpC
};

private static List<CultureInfo> supportedCultures;
private static readonly string[] supportedCultureIdentifiers = new string[] {
private static readonly string[] supportedCultureIdentifiers = [
"de-DE",
"en-US",
"en-GB",
Expand All @@ -48,7 +48,7 @@ public override Task<ProviderCultureResult> DetermineProviderCultureResult(HttpC
"tr-TR",
"vi-VN",
"zh-CN"
};
];

public static IList<CultureInfo> SupportedCultures
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static bool GetFirst(this SqlQuery query, IDbConnection connection, IEnti
using IDataReader reader = SqlHelper.ExecuteReader(connection, query, param);
if (reader.Read())
{
query.GetFromReader(reader, new IEntity[] { row });
query.GetFromReader(reader, [row]);
return true;
}
else
Expand Down Expand Up @@ -84,7 +84,7 @@ public static bool GetSingle(this SqlQuery query, IDbConnection connection, IRow
using IDataReader reader = SqlHelper.ExecuteReader(connection, query, param);
if (reader.Read())
{
query.GetFromReader(reader, new IRow[] { row });
query.GetFromReader(reader, [row]);

if (reader.Read())
throw new InvalidOperationException("Query returned more than one result!");
Expand Down
2 changes: 1 addition & 1 deletion src/Serenity.Net.Web/Mvc/PageAuthorizeAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class PageAuthorizeAttribute : TypeFilterAttribute
public PageAuthorizeAttribute()
: base(typeof(PageAuthorizeFilter))
{
Arguments = new[] { this };
Arguments = [this];
}

private class PageAuthorizeFilter(PageAuthorizeAttribute attr) : IResourceFilter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void Constructor_SetsPropertiesCorrectly_WithTitleOnly()
public void IncludeProperty_CanBeSetAndRetrieved()
{
var attribute = new NavigationGroupAttribute("Title");
string[] includePaths = { "B/", "C/" };
string[] includePaths = ["B/", "C/"];
attribute.Include = includePaths;
Assert.Equal(includePaths, attribute.Include);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ public void Title_Should_Use_Row_Properties_If_Available(string propertyName,
var processor = new BasicPropertyProcessor();

var registry = new LocalTextRegistry();
EntityLocalTexts.AddRowTexts(registry, new[] { new DisplayWithRowRow() });
EntityLocalTexts.AddRowTexts(registry, [new DisplayWithRowRow()]);

var item = new PropertyItem();
var property = typeof(DisplayWithRowForm).GetProperty(propertyName);
Expand Down

0 comments on commit fd21bb5

Please sign in to comment.