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

ValidationContext missing ServiceContainer #229

Open
stefanolson opened this Issue Jan 1, 2019 · 4 comments

Comments

Projects
None yet
3 participants
@stefanolson
Copy link

stefanolson commented Jan 1, 2019

  • .NET Core Version: 3.0 Preview1
  • Windows version: 10 1809
  • Does the bug reproduce also in WPF for .NET Framework 4.8?: No

Problem description:
This code compiles fine in WPF for the .net framework. It is using a validation context within a validation context to deal with collection/child classes. therefore it needs to be able to pass the current service container through to the the new validation context. Whilst the validation context has a service container parameter, there seems to be no way to access the service container:
`ValidationContext validationContext;

var context = new ValidationContext(val, validationContext.ServiceContainer, null);`

Actual behavior:
Compile time error: 'ValidationContext' does not contain a definition for 'ServiceContainer' and no accessible extension method 'ServiceContainer' accepting a first argument of type 'ValidationContext' could be found

Expected behavior:
no compile time error.

Minimal repro:
See above.

@vatsan-madhavan

This comment has been minimized.

Copy link
Member

vatsan-madhavan commented Jan 1, 2019

@stefanolson, Is the missing type exposed by WPF assemblies? Could this instead be in reference to types from System.ComponentModel.DataAnnotations.dll ?

@stefanolson

This comment has been minimized.

Copy link

stefanolson commented Jan 1, 2019

@vatsan-madhavan Fair point - is in .nuget\packages\microsoft.netcore.app\3.0.0-preview-27122-01\ref\netcoreapp3.0\System.ComponentModel.Annotations.dll. Not sure therefore where this should be filed but is an incompatibility with existing .net framework applications.

I've been unable to find an explanation for the reasoning behind this so is not clear to me if it will break my existing code or not.

Running the existing code through the debugger the object that I want to pass is a: System.ComponentModel.DataAnnotations.ValidationContext.ValidationContextServiceContainer.

Ideally this property would be exposed and/or an explanation documented as to why it is not there and how to make any existing code compatible. Please do move the thread through to the correct place if I filed wrongly

@vatsan-madhavan

This comment has been minimized.

Copy link
Member

vatsan-madhavan commented Jan 2, 2019

@ericstj, would this be a good fit for corefx?

@ericstj

This comment has been minimized.

Copy link
Member

ericstj commented Jan 7, 2019

Correct, please open the issue in corefx along with your scenario for usage. This looks like the same as dotnet/corefx#18075 which was closed because we couldn't find any usage for the API.

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