Skip to content

Commit

Permalink
add no extension overload of ContentTypes.IsText (#154)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp authored Oct 9, 2023
1 parent 2311444 commit 59bfd99
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 5 deletions.
8 changes: 5 additions & 3 deletions src/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -140,15 +140,17 @@ resharper_wrap_before_binary_pattern_op = false
resharper_wrap_object_and_collection_initializer_style = chop_always
resharper_place_simple_initializer_on_single_line = false

# space
resharper_space_around_lambda_arrow = true

dotnet_style_require_accessibility_modifiers = never:error
resharper_place_type_constraints_on_same_line = false
resharper_blank_lines_inside_namespace = 0
resharper_blank_lines_after_file_scoped_namespace_directive = 1
resharper_blank_lines_inside_type = 0

insert_final_newline = false
resharper_place_attribute_on_same_line = false
resharper_space_around_lambda_arrow = true
resharper_place_constructor_initializer_on_same_line = false

#braces https://www.jetbrains.com/help/resharper/EditorConfig_CSHARP_CSharpCodeStylePageImplSchema.html#Braces
resharper_braces_for_ifelse = required
resharper_braces_for_foreach = required
Expand Down
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project>
<PropertyGroup>
<NoWarn>CS1591;CS0649</NoWarn>
<Version>4.5.2</Version>
<Version>4.6.0</Version>
<LangVersion>preview</LangVersion>
<AssemblyVersion>1.0.0</AssemblyVersion>
<Description>A collection of minimal binary files.</Description>
Expand Down
3 changes: 3 additions & 0 deletions src/EmptyFiles/ContentTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

public static class ContentTypes
{
public static bool IsText(string? mediaType) =>
IsText(mediaType, out _);

public static bool IsText(string? mediaType, [NotNullWhen(true)] out string? extension)
{
if (TryGetExtension(mediaType, out extension))
Expand Down
5 changes: 4 additions & 1 deletion src/Shared.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,16 @@
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=MergeIntoPattern/@EntryIndexedValue">ERROR</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=MergeNestedPropertyPatterns/@EntryIndexedValue">ERROR</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=MergeSequentialChecks/@EntryIndexedValue">ERROR</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=MoveLocalFunctionAfterJumpStatement/@EntryIndexedValue">DO_NOT_SHOW</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=NotAccessedField_002ELocal/@EntryIndexedValue">ERROR</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=NotAccessedPositionalProperty_002ELocal/@EntryIndexedValue">ERROR</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=PatternIsAlwaysTrueOrFalse/@EntryIndexedValue">ERROR</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RedundantAssignment/@EntryIndexedValue">ERROR</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RedundantBoolCompare/@EntryIndexedValue">ERROR</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RedundantStringInterpolation/@EntryIndexedValue">ERROR</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RawStringCanBeSimplified/@EntryIndexedValue">ERROR</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RedundantTypeDeclarationBody/@EntryIndexedValue">ERROR</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RedundantUsingDirective_002EGlobal/@EntryIndexedValue">ERROR</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ReplaceAsyncWithTaskReturn/@EntryIndexedValue">ERROR</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=SeparateLocalFunctionsWithJumpStatement/@EntryIndexedValue">DO_NOT_SHOW</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=StringLiteralAsInterpolationArgument/@EntryIndexedValue">ERROR</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=TryStatementsCanBeMerged/@EntryIndexedValue">ERROR</s:String>
Expand All @@ -42,6 +44,7 @@
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=TabsAreDisallowed/@EntryIndexedValue">ERROR</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=UseRawString/@EntryIndexedValue">ERROR</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=UseSwitchCasePatternVariable/@EntryIndexedValue">ERROR</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=UseSymbolAlias/@EntryIndexedValue">ERROR</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=UseUtf8StringLiteral/@EntryIndexedValue">ERROR</s:String>
<s:String x:Key="/Default/CodeInspection/Browsers/Browsers/@EntryValue">C90+,E79+,S14+</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ConditionalAccessQualifierIsNonNullableAccordingToAPIContract/@EntryIndexedValue">ERROR</s:String>
Expand Down
4 changes: 4 additions & 0 deletions src/Tests/ContentTypesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,9 @@ public void IsText()
Assert.True(ContentTypes.IsText("foo/bar+json", out extension));
Assert.AreEqual("json", extension);
Assert.False(ContentTypes.IsText("foo/bin", out extension));

Assert.True(ContentTypes.IsText("application/json"));
Assert.True(ContentTypes.IsText("foo/bar+json"));
Assert.False(ContentTypes.IsText("foo/bin"));
}
}

0 comments on commit 59bfd99

Please sign in to comment.