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

No match for field with name objectSpaceProviders and flags Instance | NonPublic | Public | Static on type #940

Closed
Siratigui opened this issue Jul 21, 2022 · 18 comments

Comments

@Siratigui
Copy link

Hi,

objectSpaceProviders access has been changed by DevExpress.

application.GetFieldValue("objectSpaceProviders") is not longer working.

Now can not open the model because it can not find objectSpaceProviders.

You can access now access it from:
application.GetFieldValue("_objectSpaceProviderContainer").GetFieldValue("_objectSpaceProviders")

I faced this error in WorldCreator and solved it by changing:

public WorldCreatorApplication(IObjectSpaceProvider objectSpaceProvider, IEnumerable<ModuleBase> moduleList)
        {
            ((IList<IObjectSpaceProvider>)GetOrCreateObjectSpaceProviderContainer().GetFieldValue("_objectSpaceProviders")).Add(objectSpaceProvider);
            var moduleBases = moduleList.Select(m => m.GetType().CreateInstance()).Cast<ModuleBase>().OrderBy(m => m.Name).Distinct().ToArray();
            foreach (var moduleBase in moduleBases)
            {
                if (Modules.FindModule(moduleBase.GetType()) == null)
                    Modules.Add(moduleBase);
            }
            ObjectSpaceCreated += Application_ObjectSpaceCreated;
        }

and

public static WorldCreatorObjectSpaceProvider Create(XafApplication application, bool threadSafe)
        {
            var worldCreatorObjectSpaceProvider = application.ObjectSpaceProviders.OfType<WorldCreatorObjectSpaceProvider>().SingleOrDefault();
            if (worldCreatorObjectSpaceProvider != null)
            {
                worldCreatorObjectSpaceProvider.threadSafe = threadSafe;
                return worldCreatorObjectSpaceProvider;
            }

            ((IList<IObjectSpaceProvider>)application.GetFieldValue("_objectSpaceProviderContainer")
                .GetFieldValue("_objectSpaceProviders")).Add(new WorldCreatorObjectSpaceProvider());
            return Create(application, threadSafe);
        }

and

private void AddDynamicModulesObjectSpaceProviders()
        {
            var providerBuilder = new DatastoreObjectSpaceProviderBuilder(DynamicModules);
            providerBuilder.CreateProviders().Each(provider => ((IList<IObjectSpaceProvider>)Application.GetFieldValue("_objectSpaceProviderContainer")
                .GetFieldValue("_objectSpaceProviders")).Add(provider));
        }

@Siratigui
Copy link
Author

In 22.1.302 version

@apobekiaris
Copy link
Member

please send a PR where u have tessted your suggestions and they work for you and happy to send a build.

thanks for the understanding and help

@apobekiaris
Copy link
Member

@vimarx since you also affected after @Siratigui PR could you also update us if his changes work for u for #939

@Siratigui
Copy link
Author

It will take so much time for me to create a sample because the project is very customized. I think that you can face this error in any WorldCreator project.

@apobekiaris
Copy link
Member

I do not want a sample, as I understand you modified the source right? can u push a PR with those modifications?

@apobekiaris
Copy link
Member

nevermind just wanted you to take the credits for the fix, easier to do it myself. anyways feel free to PR any futures changes.

thnks again pushin in lab now

@apobekiaris
Copy link
Member

i do not see how it relates with #939 maybe I missunderstood?

@Siratigui
Copy link
Author

when opening the ModelDifference DetailView the expression application.GetFieldValue("objectSpaceProviders") is executed somewhere. application.GetFieldValue("objectSpaceProviders") is not valid anymore. you may change it anywhere it is called in the codes i guess.

@apobekiaris
Copy link
Member

can u test in your WC code that this method works

public static IEnumerable<IObjectSpaceProvider> AddObjectSpaceProvider(this XafApplication application, params IObjectSpaceProvider[] providers) 
            => ((IList<IObjectSpaceProvider>)application.CallMethod("GetOrCreateObjectSpaceProviderContainer").GetFieldValue("_objectSpaceProviders")).AddRange(providers);

AddRange can be used from the Xpand.Extensions.XAF.XafApplicationExtensions namespace therefore the Xpand.Extensions.XAF

I want to use that method instead

@apobekiaris
Copy link
Member

eXpand.lab release 22.1.302.1 includes commit that relate to this task:

Please test if it addresses the problem. If you use nuget add our LAB NugetServer as a nuget package source in VS.

To minimize version conflicts we recommend that you switch to PackageReference format and use only the eXpandAgnostic, eXpandWin, eXpandWeb packages. Doing so, all packages will be at your disposal and .NET will add a dependecy only to those packages that you actually use and not to all (see the Modules installation-registrations youtube video).

Thanks a lot for your contribution.

@apobekiaris apobekiaris added this to the 21.2.702.0 milestone Jul 21, 2022
@apobekiaris
Copy link
Member

apobekiaris commented Jul 21, 2022

AddRange can be used from the Xpand.Extensions.XAF.XafApplicationExtensions namespace therefore the Xpand.Extensions.XAF

or simply if u do not have dependecies is like this

           public static partial class LinqExtensions{
        public static T[] AddRange<T>(this IEnumerable<T> source,IEnumerable<T> enumerable,bool ignoreDuplicates=false) 
            => source is IList<T> list
                    ? enumerable.Where(arg => !ignoreDuplicates || !source.Contains(arg)).Execute(list.Add).ToArray()
                    : source.AddToArray(enumerable, ignoreDuplicates);

        public static void Add(this IList source, object item, bool ignoreDuplicates=false) {
            if (!ignoreDuplicates || !source.Contains(item)) {
                source.Add(item);
            }
        }

        public static T[] AddToArray<T>(this IEnumerable<T> source, T item, bool ignoreDuplicates = false) {
            var enumerable = source as T[] ?? source.ToArray();
            return !ignoreDuplicates && enumerable.Any(arg => arg.Equals(item))
                ? enumerable : enumerable.Concat(item.YieldItem()).ToArray();
        }

        public static T[] AddToArray<T>(this IEnumerable<T> source, IEnumerable<T> items, bool ignoreDuplicates = false) 
            => items.SelectMany(arg => source.AddToArray(arg, ignoreDuplicates)).ToArray();

        public static T Add<T>(this IList<T> source, T item, bool ignoreDuplicates = false) {
            if (!ignoreDuplicates || !source.Contains(item)) {
                source.Add(item);
                return item;
            }

            return default;
        }
            
    }

@Siratigui
Copy link
Author

objectspaceproviders

I tried the release in lab. I still get the same error when trying to open the modeldifference detailview due the xafApplication.GetFieldValue("objectSpaceProviders") in the picture above.

can you please change it wherever it is used.

@apobekiaris
Copy link
Member

this release was send before your suggestion to replace everything and apparently we need one method to rule them all and not search and replace the universe so that why i asked what I asked previoslt

@Siratigui
Copy link
Author

public static IEnumerable<IObjectSpaceProvider> AddObjectSpaceProvider(this XafApplication application, params IObjectSpaceProvider[] providers) 
            => ((IList<IObjectSpaceProvider>)application.CallMethod("GetOrCreateObjectSpaceProviderContainer").GetFieldValue("_objectSpaceProviders")).AddRange(providers);

I tested the method it works.

@apobekiaris
Copy link
Member

cool I need to push both repositories though as thi is going to live in Xpand.XAF.Extensions package of the RX repositories. So give me 1 day or 2 there are works in progress in the RX repo

@apobekiaris
Copy link
Member

The pre-release 4.221.1.0 in the Reactive.XAF lab branch includes commits that relate to this task:

To minimize version conflicts we recommend that you use the Xpand.XAF.Core.All, Xpand.XAF.Win.All, Xpand.XAF.Web.All packages. Doing so, all packages will be at your disposal and .NET will add a dependecy only to those packages that you actually use and not to all (see the Modules installation-registrations youtube video).

Released packages: Xpand.Extensions v.4.221.1
Xpand.Extensions.Blazor v.4.221.1
Xpand.Extensions.Mono.Cecil v.4.221.1
Xpand.Extensions.Office.Cloud v.4.221.1
Xpand.Extensions.Office.Cloud.Google.Blazor v.4.221.1
Xpand.Extensions.Reactive v.4.221.1
Xpand.Extensions.XAF v.4.221.1
Xpand.Extensions.XAF.Xpo v.4.221.1
Xpand.TestsLib v.4.221.1
Xpand.TestsLib.Blazor v.4.221.1
Xpand.TestsLib.Common v.4.221.1
Xpand.TestsLib.EasyTest v.4.221.1
Xpand.VersionConverter v.4.221.1
Xpand.XAF.Core.All v.4.221.1
Xpand.XAF.Modules.AutoCommit v.4.221.1
Xpand.XAF.Modules.Blazor v.4.221.1
Xpand.XAF.Modules.BulkObjectUpdate v.4.221.1
Xpand.XAF.Modules.CloneMemberValue v.4.221.1
Xpand.XAF.Modules.CloneModelView v.4.221.1
Xpand.XAF.Modules.Email v.4.221.1
Xpand.XAF.Modules.GridListEditor v.4.221.1
Xpand.XAF.Modules.HideToolBar v.4.221.1
Xpand.XAF.Modules.JobScheduler.Hangfire v.4.221.1
Xpand.XAF.Modules.JobScheduler.Notification v.4.221.1
Xpand.XAF.Modules.MasterDetail v.4.221.1
Xpand.XAF.Modules.ModelMapper v.4.221.1
Xpand.XAF.Modules.ModelViewInheritance v.4.221.1
Xpand.XAF.Modules.Office.Cloud.Google v.4.221.1
Xpand.XAF.Modules.Office.Cloud.Google.Calendar v.4.221.1
Xpand.XAF.Modules.Office.Cloud.Google.Tasks v.4.221.1
Xpand.XAF.Modules.Office.Cloud.Microsoft v.4.221.1
Xpand.XAF.Modules.Office.Cloud.Microsoft.Calendar v.4.221.1
Xpand.XAF.Modules.Office.Cloud.Microsoft.Todo v.4.221.1
Xpand.XAF.Modules.Office.DocumentStyleManager v.4.221.1
Xpand.XAF.Modules.OneView v.4.221.1
Xpand.XAF.Modules.PositionInListView v.4.221.1
Xpand.XAF.Modules.ProgressBarViewItem v.4.221.1
Xpand.XAF.Modules.RazorView v.4.221.1
Xpand.XAF.Modules.Reactive v.4.221.1
Xpand.XAF.Modules.Reactive.Logger v.4.221.1
Xpand.XAF.Modules.Reactive.Logger.Client.Win v.4.221.1
Xpand.XAF.Modules.Reactive.Logger.Hub v.4.221.1
Xpand.XAF.Modules.Reactive.Rest v.4.221.1
Xpand.XAF.Modules.RefreshView v.4.221.1
Xpand.XAF.Modules.SequenceGenerator v.4.221.1
Xpand.XAF.Modules.SuppressConfirmation v.4.221.1
Xpand.XAF.Modules.TenantManager v.4.221.1
Xpand.XAF.Modules.ViewEditMode v.4.221.1
Xpand.XAF.Modules.ViewItemValue v.4.221.1
Xpand.XAF.Modules.ViewWizard v.4.221.1
Xpand.XAF.Modules.Windows v.4.221.1
Xpand.XAF.Web.All v.4.221.1
Xpand.XAF.Win.All v.4.221.1

Please update the related Nuget packages and test if issues is addressed. These are nightly nuget packages available only from our NugetServer.

If you do not use these packages directly but through a module of the main eXpandFramework project, please wait for the bot to notify you again when integration is finished or update the related packages manually.

Thanks a lot for your contribution.

@apobekiaris
Copy link
Member

eXpand.lab release 22.1.302.2 includes commit that relate to this task:

Please test if it addresses the problem. If you use nuget add our LAB NugetServer as a nuget package source in VS.

To minimize version conflicts we recommend that you switch to PackageReference format and use only the eXpandAgnostic, eXpandWin, eXpandWeb packages. Doing so, all packages will be at your disposal and .NET will add a dependecy only to those packages that you actually use and not to all (see the Modules installation-registrations youtube video).

Thanks a lot for your contribution.

@apobekiaris
Copy link
Member

eXpand.lab release 22.2.400.0 includes commit that relate to this task:

Please test if it addresses the problem. If you use nuget add our LAB NugetServer as a nuget package source in VS.

To minimize version conflicts we recommend that you switch to PackageReference format and use only the eXpandAgnostic, eXpandWin, eXpandWeb packages. Doing so, all packages will be at your disposal and .NET will add a dependecy only to those packages that you actually use and not to all (see the Modules installation-registrations youtube video).

Thanks a lot for your contribution.

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

2 participants