Skip to content

Instantly share code, notes, and snippets.

@richarth
richarth / ModelTests.java
Created February 9, 2017 14:14
Sample code to demonstrate cannot serialize abstract class issue with Auto Value and Moshi
@RunWith(JUnit4.class)
public class ModelTests {
@Test
public void verifyJsonConvertsToModel() throws Exception {
String sampleMovieJson = "{\"adult\":false,\"backdrop_path\":\"/lubzBMQLLmG88CLQ4F3TxZr2Q7N.jpg\",\"belongs_to_collection\":{\"id\":427084,\"name\":\"The Secret Life of Pets Collection\",\"poster_path\":\"/aDNbXvuRiuYxk8qCwXNQQ7UEHau.jpg\",\"backdrop_path\":null},\"budget\":75000000,\"genres\":[{\"id\":12,\"name\":\"Adventure\"},{\"id\":16,\"name\":\"Animation\"},{\"id\":35,\"name\":\"Comedy\"},{\"id\":10751,\"name\":\"Family\"}],\"homepage\":\"http://www.thesecretlifeofpets.com/\",\"id\":328111,\"imdb_id\":\"tt2709768\",\"original_language\":\"en\",\"original_title\":\"The Secret Life of Pets\",\"overview\":\"The quiet life of a terrier named Max is upended when his owner takes in Duke, a stray whom Max instantly dislikes.\",\"popularity\":129.924005,\"poster_path\":\"/WLQN5aiQG8wc9SeKwixW7pAR8K.jpg\",\"production_companies\":[{\"name\":\"Universal Pictures\",\"id\":33},{\"name\":
@richarth
richarth / gist:bdaebe383c1e4a99f2af9def838701c2
Created March 4, 2019 11:33
Umbraco no ID on node error message
2019-03-04 11:27:35,480 [P1052/D2/T8] ERROR Umbraco.Web.Editors.EntityController - Unhandled controller exception occurred
System.InvalidOperationException: Node has no ID attribute.
at Umbraco.Web.PublishedCache.XmlPublishedCache.XmlPublishedContent.Get(XmlNode node, Boolean isPreviewing)
at Umbraco.Web.PublishedCache.XmlPublishedCache.PublishedContentCache.GetSingleByXPath(UmbracoContext umbracoContext, Boolean preview, String xpath, XPathVariable[] vars)
at Umbraco.Web.PublishedCache.ContextualPublishedCache`1.GetSingleByXPath(Boolean preview, String xpath, XPathVariable[] vars)
at Umbraco.Web.Editors.EntityController.GetByQuery(String query, Int32 nodeContextId, UmbracoEntityTypes type)
at lambda_method(Closure , Object , Object[] )
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters)
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instanc
@richarth
richarth / gist:400201d0e27d381d13c263850802e67b
Created March 8, 2019 16:50
SuperValueConverters front end error
2019-03-08 16:36:06,764 [P9180/D2/T15] ERROR Umbraco.Core.UmbracoApplicationBase - An unhandled exception occurred
System.NullReferenceException: Object reference not set to an instance of an object.
at Umbraco.Core.Cache.HttpRequestCacheProvider.GetCacheItem(String cacheKey, Func`1 getCacheItem)
at Umbraco.Web.PublishedCache.XmlPublishedCache.XmlPublishedContent.Get(XmlNode node, Boolean isPreviewing)
at Umbraco.Web.PublishedCache.XmlPublishedCache.PublishedContentCache.GetById(UmbracoContext umbracoContext, Boolean preview, Int32 nodeId)
at Umbraco.Web.PublishedCache.XmlPublishedCache.PublishedContentCache.DetermineIdByRoute(UmbracoContext umbracoContext, Boolean preview, String route, Boolean hideTopLevelNode)
at Umbraco.Web.PublishedCache.XmlPublishedCache.PublishedContentCache.GetByRoute(UmbracoContext umbracoContext, Boolean preview, String route, Nullable`1 hideTopLevelNode)
at Umbraco.Web.Routing.ContentFinderByNiceUrl.FindContent(PublishedContentRequest docreq, String route)
at U
@richarth
richarth / error.txt
Created April 16, 2019 14:52
Error with Our.Umbraco.SuperValueConverters 1.1.0
Failed to build models.
Object reference not set to an instance of an object.
at Our.Umbraco.SuperValueConverters.ValueConverters.BaseValueConverter.<>c.<GetTypeForPicker>b__3_0(Type x)
at System.Linq.Enumerable.<>c__DisplayClass7_0`3.<CombineSelectors>b__0(TSource x)
at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
at Our.Umbraco.SuperValueConverters.Extensions.IEnumerableExtensions.IntersectMany[T](IEnumerable`1 values)
at Our.Umbraco.SuperValueConverters.ValueConverters.BaseValueConverter.GetTypeForPicker(IPickerSettings pickerSettings)
at Our.Umbraco.SuperValueConverters.ValueConverters.BaseValueConverter.GetPropertyValueType(PublishedPropertyType propertyType, IPickerSettings pickerSettings)
at Our.Umbraco.SuperValueConverters.ValueConverters.MultiNodeTreePickerValueConverter.GetPropertyValueType(PublishedPropertyType propertyType)
@richarth
richarth / error.txt
Last active July 30, 2019 09:50
Our.Umbraco.SuperValueConverters back office error in Umbraco 7.15.1
An error occured
Mapping types:
Content -> String[]
Umbraco.Core.Models.Content -> System.String[]
Destination path:
ContentItemDisplay.Urls.Urls
@richarth
richarth / error.txt
Created July 30, 2019 09:51
Our.Umbraco.SuperValueConverters front end error in Umbraco 7.15.1
[ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.]
Umbraco.Core.Cache.HttpRequestCacheProvider.GetCacheItem(String cacheKey, Func`1 getCacheItem) +288
Umbraco.Web.PublishedCache.XmlPublishedCache.XmlPublishedContent.Get(XmlNode node, Boolean isPreviewing) +155
Umbraco.Web.PublishedCache.XmlPublishedCache.PublishedContentCache.GetById(UmbracoContext umbracoContext, Boolean preview, Int32 nodeId) +68
Umbraco.Web.PublishedCache.XmlPublishedCache.PublishedContentCache.DetermineIdByRoute(UmbracoContext umbracoContext, Boolean preview, String route, Boolean hideTopLevelNode) +189
Umbraco.Web.PublishedCache.XmlPublishedCache.PublishedContentCache.GetByRoute(UmbracoContext umbracoContext, Boolean preview, String route, Nullable`1 hideTopLevelNode) +202
Umbraco.Web.Routing.ContentFinderByNiceUrl.FindContent(PublishedContentRequest docreq, String route) +207
Umbraco.Web.Routing.ContentFinderByNiceUrl.TryFind
@richarth
richarth / gist:b5ad28a9f9b783ceb25a2b93d69ed501
Created October 8, 2019 10:10
Our.Umbraco.SuperValueConverters error in Umbraco 7.15.3
2019-10-08 10:52:29,939 [P8668/D4/T17] ERROR Umbraco.Core.UmbracoApplicationBase - An unhandled exception occurred
System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
at Umbraco.Core.Cache.HttpRequestCacheProvider.GetCacheItem(String cacheKey, Func`1 getCacheItem)
at Umbraco.Web.PublishedCache.XmlPublishedCache.XmlPublishedContent.Get(XmlNode node, Boolean isPreviewing)
at Umbraco.Web.PublishedCache.XmlPublishedCache.PublishedContentCache.GetById(UmbracoContext umbracoContext, Boolean preview, Int32 nodeId)
at Umbraco.Web.PublishedCache.XmlPublishedCache.PublishedContentCache.DetermineIdByRoute(UmbracoContext umbracoContext, Boolean preview, String route, Boolean hideTopLevelNode)
at Umbraco.Web.PublishedCache.XmlPublishedCache.PublishedContentCache.GetByRoute(UmbracoContext umbracoContext, Boolean preview, String route, Nullable`1 hideTopLevelNode)
at Umbraco.Web.Routing.ContentFinderB
@richarth
richarth / gist:613e0e1850245e3ce7c7f927b3971184
Created October 8, 2019 10:12
Our.Umbraco.SuperValueConverters models builder error
Failed to build models.
Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
at System.Reflection.RuntimeModule.GetTypes()
at System.Reflection.Assembly.GetTypes()
at Our.Umbraco.SuperValueConverters.Helpers.TypeHelper.<>c.<GetType>b__0_0(Assembly x)
at System.Linq.Enumerable.<SelectManyIterator>d__17`2.MoveNext()
at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
at Our.Umbraco.SuperValueConverters.Helpers.TypeHelper.GetType(String typeName, String namespaceName)
@richarth
richarth / BannerTests.cs
Created October 29, 2019 16:00
An example xUnit test where dispose is not called when running multiple tests at once.
using ApprovalTests;
using ApprovalTests.Namers;
using ApprovalTests.Reporters;
using ApprovalTests.Reporters.TestFrameworks;
using Moq;
using RazorGenerator.Testing;
using Umbraco.Core.Composing;
using Xunit;
using Xunit.Abstractions;
@richarth
richarth / TestBase.cs
Created October 29, 2019 16:01
Cut down demo of a base class for our xUnit tests
using UCommerce.EntitiesV2;
using Xunit.Abstractions;
namespace Website.Tests
{
public class TestBase : XunitApprovalBase
{
protected TestBase(ITestOutputHelper output)
: base(output)
{