Search Unity

  1. Unity 2019.1 beta is now available.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. We're looking for insight from anyone who has experience with game testing to help us better Unity. Take our survey here. If chosen to participate you'll be entered into a sweepstake to win an Amazon gift card.
    Dismiss Notice
  4. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  5. Unity 2018.3 is now released.
    Dismiss Notice
  6. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

Update to 3.0.1 collision with Moq framework

Discussion in 'Unity Ads' started by kaladrius-trip, Feb 12, 2019 at 9:26 AM.

  1. kaladrius-trip

    kaladrius-trip

    Joined:
    Jan 14, 2014
    Posts:
    1
    When i update to new version of Advertisement from package manager, i have little bit problem with delegate
    Action<T1, T2, T3, T4, T5>
    For reproduce this exception you should have Unity 2018.3.5f1 and you may install UniRx Ver 6.2.2 and Advertisement 3.0.1 from package manager.
    The type 'Action<T1, T2, T3, T4, T5>' exists in both 'Moq, Version=4.0.10827.0, Culture=neutral, PublicKeyToken=69f491c39445e920' and 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
     
    Bladgharm likes this.
  2. HaakonL

    HaakonL

    Joined:
    Mar 13, 2014
    Posts:
    96
    Same here.
     
    Bladgharm likes this.
  3. Bladgharm

    Bladgharm

    Joined:
    Jan 22, 2014
    Posts:
    1
    I have this problem in my project too. I comment conflicted part of the code, but for me it is important. Any suggestions how to fix it?
     
  4. HaakonL

    HaakonL

    Joined:
    Mar 13, 2014
    Posts:
    96
    I have made a temporary fix using a custom class as the Action argument instead:

    In UniTaskTrackerTreeView replace the BuildRoot function on line 125 with this:


    Code (CSharp):
    1. protected override TreeViewItem BuildRoot()
    2.         {
    3.             var root = new TreeViewItem { depth = -1 };
    4.  
    5.             var children = new List<TreeViewItem>();
    6.  
    7.             TaskTracker.ForEachActiveTask(stupid =>
    8.             {
    9.                 children.Add(new UniTaskTrackerViewItem(stupid.TrackingId) { TaskType = stupid.TypeName, Status = stupid.Status.ToString(), Elapsed = (DateTime.UtcNow - stupid.AddTime).TotalSeconds.ToString("00.00"), Position = stupid.StackTrace });
    10.             });
    11.  
    12.             CurrentBindingItems = children;
    13.             root.children = CurrentBindingItems as List<TreeViewItem>;
    14.             return root;
    15.         }
    In TaskTracker replace the ForEachActiveTask with this:

    Code (CSharp):
    1. public static void ForEachActiveTask(Action<StupidFix> action)
    2.         {
    3.             lock (listPool)
    4.             {
    5.                 var count = tracking.ToList(ref listPool, clear: false);
    6.                 try
    7.                 {
    8.                     for (int i = 0; i < count; i++)
    9.                     {
    10.                         string typeName = null;
    11.                         var keyType = listPool[i].Key.GetType();
    12.                         if (keyType.IsNested)
    13.                         {
    14.                             typeName = keyType.DeclaringType.Name + "." + keyType.Name;
    15.                         }
    16.                         else
    17.                         {
    18.                             typeName = keyType.Name;
    19.                         }
    20.                         action(new StupidFix(listPool[i].Value.trackingId, typeName, listPool[i].Key.Status, listPool[i].Value.addTime, listPool[i].Value.stackTrace));
    21.                         listPool[i] = new KeyValuePair<IAwaiter, (int trackingId, DateTime addTime, string stackTrace)>(null, (0, default(DateTime), null)); // clear
    22.                     }
    23.                 }
    24.                 catch
    25.                 {
    26.                     listPool.Clear();
    27.                     throw;
    28.                 }
    29.             }
    30.         }

    Add a new cs class somewhere in your project:

    Code (CSharp):
    1. public class StupidFix
    2.     {
    3.         public StupidFix(int trackingId, string typeName, AwaiterStatus status, DateTime addTime, string stackTrace)
    4.         {
    5.             TrackingId = trackingId;
    6.             TypeName = typeName;
    7.             Status = status;
    8.             AddTime = addTime;
    9.             StackTrace = stackTrace;
    10.         }
    11.  
    12.         public int TrackingId { get; }
    13.         public string TypeName { get; }
    14.         public AwaiterStatus Status { get; }
    15.         public DateTime AddTime { get; }
    16.         public string StackTrace { get; }
    17.     }
     
  5. DenisasK

    DenisasK

    Unity Technologies

    Joined:
    Oct 13, 2016
    Posts:
    64
    For a quick workaround, you can try to replace Ads package with Monetization 3.0.1 AssetStore package, it should help to get rid of the error.
     
  6. HaakonL

    HaakonL

    Joined:
    Mar 13, 2014
    Posts:
    96
    That's better than my solution. But I am quite puzzled with all these double packages you keep going, Unity. Such a mess. When to use Package Manager and when to use the Asset Store is a big mystery. And some stuff even requires both a package and the asset store equivalent.