Skip to content

Commit

Permalink
removes redundant type (on enums and enum like types)
Browse files Browse the repository at this point in the history
  • Loading branch information
tesar-tech committed Nov 28, 2024
1 parent 4d1e4ad commit a5a402c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,6 @@ private static string GenerateComponentsApiSource( Compilation compilation, Immu
{
string componentType = component.Type.ToStringWithGenerics();
string componentTypeName = StringHelpers.GetSimplifiedTypeName( component.Type );
Logger.IsOn = component.Type.Name == "Button";
Logger.Log( component.Type.Name );

var propertiesData = component.Properties.Select( property =>
InfoExtractor.GetPropertyDetails( compilation, property ) )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static ApiDocsForComponentProperty GetPropertyDetails( Compilation compil
};
string defaultValueAsString = property.Type.Name == "String" ? defaultValueString : $""""
$$"""
{StringHelpers.TypeToStringDetails( defaultValueString )}
{StringHelpers.TypeToStringDetails( defaultValueString, propertyDetails.TypeName )}
"""
"""";
propertyDetails.DefaultValueString = defaultValueAsString;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,22 @@ public static string FormatProperly( object value )
return defaultValue;
}

const string toReplace = "global::";
const string toReplace2 = "Blazorise.";

public static string TypeToStringDetails( string value )
public static string TypeToStringDetails( string value, string propertyDetailsTypeName )
{
const string toReplace = "global::";

if ( value.StartsWith( toReplace ) )
{
value = value.Substring( toReplace.Length );
}
const string toReplace2 = "Blazorise.";
if ( value.StartsWith( toReplace2 ) )
{
value = value.Substring( toReplace2.Length );
string propertyDetailsTypeNameWithDot = propertyDetailsTypeName + ".";//From Color.Default => Default
if ( value.StartsWith( propertyDetailsTypeNameWithDot ) )
value = value.Substring( propertyDetailsTypeNameWithDot.Length );
}
return value;

Expand All @@ -69,16 +73,16 @@ internal static string ExtractFromXmlComment( ISymbol iSymbol, ExtractorParts pa
// Check if the XML contains <inheritdoc/>
if ( xmlComment.Contains( "<inheritdoc" ) )
{
return GetXmlCommentForInheritdocInterfaces( iSymbol,part );
return GetXmlCommentForInheritdocInterfaces( iSymbol, part );
}

var match = Regex.Match( xmlComment, $"<{part.GetXmlTag()}>(.*?)</{part.GetXmlTag()}>", RegexOptions.Singleline );
if ( !match.Success )
return part.GetDefault();
return part.GetDefault();
var text = match.Groups[1].Value.Trim();

XmlCommentToHtmlConverter converter = new();
text = converter.Convert( text );
text = converter.Convert( text );
return text;
}
private static string GetXmlCommentForInheritdocInterfaces( ISymbol iSymbol, ExtractorParts part )
Expand Down

0 comments on commit a5a402c

Please sign in to comment.