Closed ithielnor closed 6 years ago
Using your example, I created a new unit test and pointed it to an internal and a private class but they worked just fine.
I noticed both the class and the property were named Status
- I assumed
that was just for the example.
Is this class being generated at runtime, perhaps, rather than at compile time?
Also, it might have to do with the class being internal
rather than
private
(the default if not indicated is internal). The .NET runtime has
some pretty crazy restrictions on accessing internal members via reflection.
Any additional information you can provide would be appreciated.
The names are just for example. Yes, it's unspecified. It's a compiled class.
Can you tell me a little bit more about your environment? Is this for an ASP.NET application, Silverlight, .NET Core, etc.? I'm just trying to figure out what the magic ingredient is; I'm unable to create a unit test that fails.
I actually find this surprising because in a recent version I added code to support more private
and internal
properties/fields/constructors. Both the fixed-length and separated value mappers are using the same underlying classes to create/read/write objects, so it's weird one would work and the other wouldn't.
We're targeting .Net Framework 4.6.2. This is run from a windows service.
I'm gonna try a few more things on my end and see if I can find out what the cause is myself. From your tests, it sounds like my initial assumption was incorrect.
I setup a test with a similar file locally and can't hit the problem here either.
It must have something to do with my stream reader. Our files are stored on S3 and buffered into a memory stream for parsing. Something like this:
using (var reader = new StreamReader(bll.GetStream(file)))
{
IEnumerable<Status> data = mapper.Read(reader, new SeparatedValueOptions()
{
IsFirstRecordSchema = false,
RecordSeparator = "\n",
Separator = ",",
Quote = '"'
}).ToArray(); // Errors upon enumeration here
}
public Stream GetStream(string amazonFileName)
{
MemoryStream responseStream = new MemoryStream();
GetObjectRequest request = new GetObjectRequest()
{
BucketName = Bucket,
Key = amazonFileName
};
using (GetObjectResponse response = _client.GetObject(request))
{
BufferedStream bstream = new BufferedStream(response.ResponseStream);
byte[] buffer = new byte[0x2000];
int count = 0;
while ((count = bstream.Read(buffer, 0, buffer.Length)) > 0)
{
responseStream.Write(buffer, 0, count);
}
responseStream.Seek(0, SeekOrigin.Begin);
}
return responseStream;
}
I don't see why that would cause a problem, but it's the only difference I can see from the working tests.
I'm closing this since it's been open for a while and there's been no progress.
We upgraded from 0.3.23 to 1.6.2 and started getting an error on our private dto classes.
Here's how we're using it
Previously the class MyClass.Status did not have to be public, but now if it's not public, we receive an error like this one:
Is this intended behavior? Why does the
FixedLengthTypeMapper
still work fine with private classes?