Skip to content

Commit

Permalink
improve the generation of invocations for static methods
Browse files Browse the repository at this point in the history
  • Loading branch information
NeVeSpl committed May 17, 2024
1 parent 3de56bd commit 7707bbe
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,7 @@ public static IMemberOverride ByFunc<TReturnType>(Expression<Func<Document, TFor
var compiledGetter = getter.Compile();
var methodCallExpression = getter.Body as MethodCallExpression;

string syntax = null;
if (methodCallExpression.Object is ParameterExpression)
{
var uniformMethodCallExpression = methodCallExpression.Update(Expression.Parameter(methodCallExpression.Object.Type, "item"), methodCallExpression.Arguments);
syntax = uniformMethodCallExpression.ToString();
}
if (methodCallExpression.Object == null)
{
syntax = $"{methodCallExpression.Method.DeclaringType.Name}." + methodCallExpression.ToString();
}
string syntax = methodCallExpression.ToCeSharp();
var uniqueId = getter.GetUniqueId();

return new MemberOverride<TForType>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static ISnoopableMemberTemplate Create<TReturnType>(Expression<Func<Docum
var memberAccessor = new MemberAccessorByFunc<TForType, TReturnType>(compiledGetter);

memberAccessor.UniqueId = $"{typeof(TForType).Name}_{getter.GetUniqueId()}";

memberAccessor.DefaultInvocation.Syntax = methodCallExpression.ToCeSharp();

return WithCustomAC(methodCallExpression.Method.DeclaringType, methodCallExpression.Method.Name, memberAccessor, canBeUsed, kind, () => RevitDocumentationReader.GetMethodComments(methodCallExpression.Method));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using Autodesk.Revit.DB;
using RevitDBExplorer.Domain.DataModel.Members;
using RevitDBExplorer.Domain.DataModel.Members.Base;
Expand All @@ -12,6 +13,14 @@ internal class Document_Overrides : IHaveMembersOverrides
public IEnumerable<IMemberOverride> GetOverrides() =>
[
MemberOverride<Document>.ByFunc((doc, document) => Document.GetDocumentVersion(document)),

#if R2023_MIN
MemberOverride<Document>.ByFunc((doc, document) => document.GetChangedElements(Guid.Empty)),
#endif
#if R2024_MIN
MemberOverride<Document>.ByFunc((doc, document) => document.GetUnusedElements(new HashSet<ElementId>())),
MemberOverride<Document>.ByFunc((doc, document) => document.GetAllUnusedElements(new HashSet<ElementId>())),
#endif
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,12 @@ namespace RevitDBExplorer.Domain.DataModel.MembersTemplates
internal class Document_Templates : IHaveMemberTemplates
{
public IEnumerable<ISnoopableMemberTemplate> GetTemplates() =>
[
#if R2023_MIN
MemberTemplate<Document>.Create((doc, target) => target.GetChangedElements(Guid.Empty), kind: MemberKind.Method),
#endif

[
MemberTemplate<Document>.Create((doc, target) => BasicFileInfo.Extract(target.PathName), kind: MemberKind.StaticMethod),

MemberTemplate<Document>.Create((doc, target) => BasePoint.GetSurveyPoint(doc), kind: MemberKind.StaticMethod),
MemberTemplate<Document>.Create((doc, target) => BasePoint.GetProjectBasePoint(doc), kind: MemberKind.StaticMethod),
MemberTemplate<Document>.Create((doc, target) => InternalOrigin.Get(doc), kind: MemberKind.StaticMethod),

#if R2024_MIN
MemberTemplate<Document>.Create((doc, target) => doc.GetUnusedElements(new HashSet<ElementId>()), kind: MemberKind.Method),
MemberTemplate<Document>.Create((doc, target) => doc.GetAllUnusedElements(new HashSet<ElementId>()), kind: MemberKind.Method),
#endif
];
}
}
1 change: 1 addition & 0 deletions sources/RevitDBExplorer/RevitDBExplorer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@


<ItemGroup>
<PackageReference Include="ExpressionTreeToString" Version="3.4.71" />
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="7.0.0" />
<PackageReference Include="CircularBuffer" Version="1.3.0" />
<PackageReference Include="LoxSmoke.DocXml" Version="3.5.0" />
Expand Down

0 comments on commit 7707bbe

Please sign in to comment.