-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove reflections: Misc and Summary #1137
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
btw comparsion of loading XSSF file. The performance is better for smaller files. And it looks like no obvious performance gains from removing Reflections alone.
Nuget: the nuget version. |
This comment was marked as outdated.
This comment was marked as outdated.
@@ -22,7 +22,7 @@ public T Parse(Stream stream) | |||
} | |||
public T Create() | |||
{ | |||
return (T)Activator.CreateInstance(typeof(T)); | |||
return new T(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although new T()
uses Activator.CreateInstance
internally, this semantic is slightly different for AOT analyzers I believe.
@@ -37,7 +37,8 @@ public OperandPtg Copy() | |||
{ | |||
try | |||
{ | |||
return (OperandPtg)Clone(); | |||
// REMOVE-REFLECTION: After careful inspection, MemberwiseClone() should be enough for all built-in OpreandPtgs. | |||
return (OperandPtg)MemberwiseClone(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All derived classes of OperandPtg
holds only value types (some unused members are not, but that's fine).
// private virtual object Clone() | ||
//{ | ||
//return this.Copy(); | ||
//} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not used elsewhere. And IClonable.Clone
throws NotImplementedException
, see below.
I created a new branch called AOT. AOT branch will become a RC version for NPOI vNext. I'd like to compare the performance between AOT and non-AOT release. |
Thanks, I'm here if you want some help. |
try to fix #957
I found some upstream dependencies don't support AOT therefore NPOI cannot be completed AOTed. The library will get some performance improvement from removing reflections though.
@tonyqus What are your thoughts on this? These are the issues I've witnessed.
XWPFTableRow.CloneRow
CT_*
objects, henceNPOI.Util.ObjectExtensions.Copy<T>()
.rd.xml
or source generators for deepcopy. Perhaps it will just work.NPOI.OpenXml4Net.Util.XmlHelper
XMLSerializer
and enum names relies on reflections obviously.NPOI.DDF.DefaultEscherRecordFactory
NPOI.HSSF.Record.RecordFactory
NPOI.POIFS.Crypt.EncryptionInfo
GetBuilder
NPOI.XSSF.UserModel.XSSFFactory
CreateDocumentPart
NPOI.XSSF.UserModel.XWPFFactory
CreateDocumentPart
NPOI.HSSF.UserModel.OperationEvaluatorFactory
NPOI.POIFS.NIO.FileBackedDataSource.unmap
NPOI.SS.Formula.Eval.Forked.ForkedEvaluator.CreateEvaluationWorkbook
NPOI.OpenXml4Net.Util.ZipSecureFile.AddThreshold
NPOI.Util.POILogFactory.GetLogger
_loggerClassName
isName
of the type butType.GetType
requiresFullName
. It all ends up using the null logger.NPOI.SS.Formula.OperationEvaluatorFactory.Add
Ptg
,OperandPtg
IClonable
is removed fromPtg
because not used and requires deepcopy, except forOperandPtg
. After inspection, all derived classes ofOperandPtg
contain only value-type members soMemberwiseClone
is enough. (besides,Ptg.IClonable.Clone()
throwsNotImplementedException
so I doubt anyone is using it.)HSSFColor
(T[])ArrayList.ToArray(typeof(T))
NPOI.Util.SystemOutLogger
&NPOI.Util.POILogFactory
Probably need to add
net8.0
as another target since .NET 6 doesn't fully support AOT and AOT analyzers. But the Github CI/action don't support .NET 8.Generally there's no breaking change, except Remove reflections in POI Logger #1162