Skip to content

.netstandard2.0 support? #64

@ikijano

Description

@ikijano

Looks a fantastic library and I like to use it in my work project but unfortunate I'm stuck in .net framework world so i'm unable to use this library :(
Have you ever considered supporting .netstandard2.0?

I played a little bit library source code and I managed get it compile when targeting to netstandard2.0 with langversion 10 using help of IsExternalInit and Nullable packages and re-ordering of namespace and using statements on couple files because of stylecop.
It looks like there is no actual show stoppers in library code only some tests needs slight modifications. When running tests "only" 207/442 tests fails on .net framework 4.8. Common pattern seems to be that ArgumentException message format is slightly different on .net framework vs .net core. Tests are assuming blindly .net core message format instead of using real message format implemented by runtime which I considered to be implementation bug. If runtime implementation ever changes all these test will fail.

In example following test will fail on .net framework 4.8:

    public void Throw_WhenCustomExceptionMessage_ShouldThrowArgumentExceptionWithCustomMessage()
    {
        // Arrange
        ExceptionCustomizations exceptionCustomizations = ParameterConstants.CustomMessage;

        // Act
        Action action = () => ExceptionThrower.Throw(ParameterConstants.ParamName, exceptionCustomizations);

        // Assert
        action.Should().ThrowExactly<ArgumentException>().WithMessage($"{ParameterConstants.CustomMessage} (Parameter '{ParameterConstants.ParamName}')");
    }

Message:

Expected exception message to match the equivalent of "custom message (Parameter 'paramName')", but "custom message
Parameter name: paramName" does not.

if I change test to following form (not assuming any message format implementation details) test will succeed:

        // Assert
         action.Should().ThrowExactly<ArgumentException>().WithMessage(new ArgumentException(ParameterConstants.CustomMessage, ParameterConstants.ParamName).Message);

test repo (no test modifications)
https://github.com/ikijano/throw/tree/wip-netstandard2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions