Skip to content
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

NullBufferedCipher Broken #1153

Closed
r-ising opened this issue Aug 3, 2023 · 14 comments
Closed

NullBufferedCipher Broken #1153

r-ising opened this issue Aug 3, 2023 · 14 comments

Comments

@r-ising
Copy link

r-ising commented Aug 3, 2023

Hello,

i created a fresh console .net 7 project and used npoi 2.6.1 (newest version).

using NPOI.POIFS.Crypt.Standard;
var x = new NullBufferedCipher();

Than you get the following exception:

Unhandled exception. System.TypeLoadException: Method 'ProcessByte' in type 'NPOI.POIFS.Crypt.Standard.NullBufferedCipher' from assembly 'NPOI.Core, Version=2.6.1.0, Culture=neutral, PublicKeyToken=0df73ec7942b34e1' does not have an implementation.

Can you please fix it?

@tonyqus
Copy link
Member

tonyqus commented Aug 3, 2023

Why do you wanna use NullBufferedCipher?

@r-ising
Copy link
Author

r-ising commented Aug 3, 2023

@tonyqus we dont want to use NullBufferedCipher but we are doing some reflaction stuff in our unit tests.

Something like this:

var workbook = new XSSFWorkbook();
var types = AppDomain.CurrentDomain.GetAssemblies()
    .SelectMany(s => s.GetTypes())
    .ToList();

Than you get the same error, so your break with npoi the .net reflaction GetTypes() function.

@tonyqus
Copy link
Member

tonyqus commented Aug 3, 2023

Not every class in NPOI is fully implemented. I have no idea why you wanna iterate all the classes in NPOI.

@r-ising
Copy link
Author

r-ising commented Aug 3, 2023

With version 2.6.0 it's works fine. Its feels a little bit unsafe, if we using a library, where some classes are not working correctly and they are public and not internal.

We are using 87 different nuget packages and no one did something like that, so its feels like a bad habbit.

But if you say its a good practice to do something like that, maybe other libraries will following this trend and we need to accept it.

@r-ising
Copy link
Author

r-ising commented Aug 3, 2023

Some follow up: @tonyqus
That is not working too:

var x = new NPOI.XSSF.Streaming.SXSSFCell(null, CellType.Blank);
x.SetCellValue(DateOnly.MinValue);

You publish a nuget package with .netstandard2.0 and .netstandard2.1, but you use .net 6 feature like dateonly in your project. see https://www.nuget.org/packages/NPOI

#if NET6_0_OR_GREATER
        public void SetCellValue(DateOnly value)
        {
            bool date1904 = ((SXSSFWorkbook)Sheet.Workbook).XssfWorkbook.IsDate1904();
            SetCellValue(DateUtil.GetExcelDate(value, date1904));
        }

This compile condition will never be true since you are using .netstandard2.1.

@r-ising
Copy link
Author

r-ising commented Aug 3, 2023

Screenshot 2023-08-03 at 11 32 37

@Bykiev
Copy link
Collaborator

Bykiev commented Aug 3, 2023

Some follow up: @tonyqus That is not working too:

var x = new NPOI.XSSF.Streaming.SXSSFCell(null, CellType.Blank);
x.SetCellValue(DateOnly.MinValue);

You publish a nuget package with .netstandard2.0 and .netstandard2.1, but you use .net 6 feature like dateonly in your project. see https://www.nuget.org/packages/NPOI

#if NET6_0_OR_GREATER
        public void SetCellValue(DateOnly value)
        {
            bool date1904 = ((SXSSFWorkbook)Sheet.Workbook).XssfWorkbook.IsDate1904();
            SetCellValue(DateUtil.GetExcelDate(value, date1904));
        }

This compile condition will never be true since you are using .netstandard2.1.

It was already reported in #1118

@r-ising
Copy link
Author

r-ising commented Aug 3, 2023

Okay so then the NullBufferedCipher will be fixed in #1118 too, like you see here:

So the answer "Not every class in NPOI is fully implemented. I have no idea why you wanna iterate all the classes in NPOI." is not correct, because you implement the NullBufferedCipher correctly and we can use GetTypes like before.

@tonyqus tonyqus added the dotnet7 label Aug 3, 2023
@tonyqus tonyqus added this to the NPOI 2.6.2 milestone Aug 3, 2023
@tonyqus tonyqus added the bug label Aug 3, 2023
@tonyqus
Copy link
Member

tonyqus commented Aug 3, 2023

We are evaluating the impact of the incorrect release of NPOI 2.6.1. If impact is huge, we will release NPOI 2.6.2. But it looks not many developers are using new features of .NET 6.0 or .NET 7.0

@connwap135
Copy link

I'm having the same issue too

@theolivenbaum
Copy link

Same issue here too - any reflection that attempts to load the NPOI assembly throws this:

System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types.
Method 'ProcessByte' in type 'NPOI.POIFS.Crypt.Standard.NullBufferedCipher' from assembly 'NPOI.Core, Version=2.6.1.0, Culture=neutral, PublicKeyToken=0df73ec7942b34e1' does not have an implementation

@tonyqus
Copy link
Member

tonyqus commented Aug 28, 2023

I'm preparing NPOI 2.6.2 release. This issue will be fixed.

Release notes: #1168

@tonyqus tonyqus closed this as completed Sep 2, 2023
@tonyqus
Copy link
Member

tonyqus commented Sep 2, 2023

NPOI 2.6.2 rc1 released

@r-ising
Copy link
Author

r-ising commented Oct 2, 2023

@tonyqus Thanks for releasing 2.6.2, everything is working fine now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants